@happyvertical/smrt-commerce 0.55.23 → 0.55.24

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 (49) hide show
  1. package/AGENTS.md +7 -8
  2. package/README.md +37 -2
  3. package/agents/customer-vendor-ui.md +61 -2
  4. package/dist/chunks/types-zVnIjSOk.js.map +1 -1
  5. package/dist/index.d.ts +2 -1
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +276 -33
  8. package/dist/index.js.map +1 -1
  9. package/dist/manifest.json +259 -57
  10. package/dist/models/Contract.d.ts.map +1 -1
  11. package/dist/models/ContractLineItem.d.ts.map +1 -1
  12. package/dist/models/Customer.d.ts +13 -1
  13. package/dist/models/Customer.d.ts.map +1 -1
  14. package/dist/models/Invoice.d.ts.map +1 -1
  15. package/dist/models/InvoiceLineItem.d.ts.map +1 -1
  16. package/dist/models/PaymentAllocation.d.ts.map +1 -1
  17. package/dist/models/Vendor.d.ts +6 -1
  18. package/dist/models/Vendor.d.ts.map +1 -1
  19. package/dist/party-contacts.d.ts +146 -0
  20. package/dist/party-contacts.d.ts.map +1 -0
  21. package/dist/smrt-knowledge.json +54 -12
  22. package/dist/svelte/components/CustomerDetail.svelte +16 -5
  23. package/dist/svelte/components/CustomerDetail.svelte.d.ts +5 -0
  24. package/dist/svelte/components/CustomerDetail.svelte.d.ts.map +1 -1
  25. package/dist/svelte/components/CustomerDirectory.svelte +16 -5
  26. package/dist/svelte/components/CustomerDirectory.svelte.d.ts +5 -0
  27. package/dist/svelte/components/CustomerDirectory.svelte.d.ts.map +1 -1
  28. package/dist/svelte/components/CustomerForm.svelte +23 -0
  29. package/dist/svelte/components/CustomerForm.svelte.d.ts +9 -2
  30. package/dist/svelte/components/CustomerForm.svelte.d.ts.map +1 -1
  31. package/dist/svelte/components/PartyContactFields.svelte +4 -0
  32. package/dist/svelte/components/PartyContactFields.svelte.d.ts.map +1 -1
  33. package/dist/svelte/components/VendorDetail.svelte +16 -5
  34. package/dist/svelte/components/VendorDetail.svelte.d.ts +5 -0
  35. package/dist/svelte/components/VendorDetail.svelte.d.ts.map +1 -1
  36. package/dist/svelte/components/VendorDirectory.svelte +16 -5
  37. package/dist/svelte/components/VendorDirectory.svelte.d.ts +5 -0
  38. package/dist/svelte/components/VendorDirectory.svelte.d.ts.map +1 -1
  39. package/dist/svelte/components/VendorForm.svelte +23 -0
  40. package/dist/svelte/components/VendorForm.svelte.d.ts +9 -2
  41. package/dist/svelte/components/VendorForm.svelte.d.ts.map +1 -1
  42. package/dist/svelte/index.d.ts +1 -1
  43. package/dist/svelte/index.d.ts.map +1 -1
  44. package/dist/svelte/party-types.d.ts +15 -1
  45. package/dist/svelte/party-types.d.ts.map +1 -1
  46. package/dist/svelte/party-types.js +1 -0
  47. package/dist/types/index.d.ts +17 -0
  48. package/dist/types/index.d.ts.map +1 -1
  49. package/package.json +11 -11
@@ -1 +1 @@
1
- {"version":3,"file":"Contract.d.ts","sourceRoot":"","sources":["../../src/models/Contract.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAGL,KAAK,IAAI,EACT,UAAU,EAEX,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,KAAK,eAAe,EACpB,cAAc,EACd,YAAY,EACZ,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EAC1B,MAAM,mBAAmB,CAAC;AA2C3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAOa,QAAS,SAAQ,UAAU;IACtC;;;OAGG;IAEH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE/B;;OAEG;IAKH,YAAY,EAAE,YAAY,CAAsB;IAEhD;;OAEG;IAKH,MAAM,EAAE,cAAc,CAAwB;IAE9C;;OAEG;IAIH,UAAU,EAAE,MAAM,GAAG,IAAI,CAAQ;IAEjC;;OAEG;IAIH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE/B;;;;;;;OAOG;IAEH,QAA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,EAAE,MAAM,CAAO;IAEtB;;;;OAIG;IAEH,MAAM,EAAE,MAAM,CAAK;IAEnB;;OAEG;IAKH,SAAS,EAAE,MAAM,CAAM;IAEvB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAM;IAEjB;;OAEG;IACH,SAAS,EAAE,IAAI,GAAG,IAAI,CAAQ;IAE9B;;OAEG;IACH,OAAO,EAAE,IAAI,GAAG,IAAI,CAAQ;IAE5B;;OAEG;IACH,aAAa,EAAE,MAAM,CAAM;IAE3B;;OAEG;IACH,SAAS,EAAE,MAAM,CAAK;gBAEV,OAAO,GAAE,uBAA4B;IAoBjD;;;;;;;;OAQG;IACH,eAAe,IAAI,MAAM;IAMzB;;OAEG;IACH,WAAW,IAAI,OAAO;IAItB;;OAEG;IACH,oBAAoB,IAAI,OAAO;CAUhC;AAED,eAAe,gBAAgB,CAAC"}
@@ -3,7 +3,7 @@
3
3
  * @packageDocumentation
4
4
  */
5
5
  import { SmrtObject } from '@happyvertical/smrt-core';
6
- import { type Address, type CustomerOptions, CustomerStatus, CustomerType } from '../types/index.js';
6
+ import { type Address, type CustomerOptions, CustomerStatus, CustomerType, type PartyContact } from '../types/index.js';
7
7
  /**
8
8
  * Customer represents the customer role for a Profile.
9
9
  *
@@ -78,7 +78,19 @@ export declare class Customer extends SmrtObject {
78
78
  * Internal notes about this customer
79
79
  */
80
80
  notes: string;
81
+ /**
82
+ * People to reach at this customer, stored as a JSON column (#3501). Write
83
+ * form rows through `savePartyContacts()`; every save normalizes the shape.
84
+ */
85
+ contacts: PartyContact[];
81
86
  constructor(options?: CustomerOptions);
87
+ /**
88
+ * Re-normalize contacts after the framework's option-override pass, which
89
+ * re-applies raw option values (including a stored JSON string).
90
+ */
91
+ initialize(): Promise<this>;
92
+ /** Save with a final contacts normalization against direct assignment. */
93
+ save(): Promise<this>;
82
94
  /**
83
95
  * Convenience predicate: is this a wholesale customer?
84
96
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Customer.d.ts","sourceRoot":"","sources":["../../src/models/Customer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAGL,UAAU,EAEX,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,eAAe,EACpB,cAAc,EACd,YAAY,EACb,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;;;;;GAcG;AACH,qBAMa,QAAS,SAAQ,UAAU;IACtC;;;OAGG;IAEH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE/B;;;OAGG;IAKH,SAAS,EAAE,MAAM,CAAM;IAEvB;;;;;;;;OAQG;IAKH,WAAW,EAAE,MAAM,CAAK;IAExB;;OAEG;IAKH,YAAY,EAAE,MAAM,CAAM;IAE1B;;OAEG;IAIH,SAAS,EAAE,OAAO,CAAS;IAE3B;;;;;OAKG;IAMH,KAAK,EAAE,MAAM,CAAM;IAEnB;;OAEG;IAKH,sBAAsB,EAAE,OAAO,CAAM;IAErC;;OAEG;IAEH,qBAAqB,EAAE,OAAO,CAAM;IAEpC;;OAEG;IAKH,MAAM,EAAE,cAAc,CAAyB;IAE/C;;;;;OAKG;IAKH,YAAY,EAAE,YAAY,CAAoB;IAE9C;;OAEG;IAKH,KAAK,EAAE,MAAM,CAAM;gBAEP,OAAO,GAAE,eAAoB;IA4BzC;;OAEG;IACH,WAAW,IAAI,OAAO;IAItB;;OAEG;IACH,QAAQ,IAAI,OAAO;IAInB;;OAEG;IACH,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAK3C;;;;;;;;;;OAUG;IACH,YAAY,IAAI,MAAM;CAGvB;AAED,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"Customer.d.ts","sourceRoot":"","sources":["../../src/models/Customer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAGL,UAAU,EAEX,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,eAAe,EACpB,cAAc,EACd,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e,eAAe,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"PaymentAllocation.d.ts","sourceRoot":"","sources":["../../src/models/PaymentAllocation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAqB,UAAU,EAAQ,MAAM,0BAA0B,CAAC;AAI/E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAYlE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,qBAoBa,iBAAkB,SAAQ,UAAU;IAC/C;;;OAGG;IAEH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE/B;;OAEG;IAGH,SAAS,EAAE,MAAM,CAAM;IAEvB;;OAEG;IAGH,SAAS,EAAE,MAAM,CAAM;IAEvB;;;;;;;;;OASG;IAEH,MAAM,EAAE,MAAM,CAAK;IAEnB;;OAEG;IAEH,WAAW,EAAE,IAAI,CAAc;IAE/B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAM;IAEzB;;OAEG;IAEH,KAAK,EAAE,MAAM,CAAM;gBAEP,OAAO,GAAE,wBAA6B;IAalD,6EAA6E;IAC9D,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAgFrC;AAED,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"PaymentAllocation.d.ts","sourceRoot":"","sources":["../../src/models/PaymentAllocation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAqB,UAAU,EAAQ,MAAM,0BAA0B,CAAC;AAI/E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAYlE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,qBAoBa,iBAAkB,SAAQ,UAAU;IAC/C;;;OAGG;IAEH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE/B;;OAEG;IAGH,SAAS,EAAE,MAAM,CAAM;IAEvB;;OAEG;IAGH,SAAS,EAAE,MAAM,CAAM;IAEvB;;;;;;;;;OASG;IAKH,MAAM,EAAE,MAAM,CAAK;IAEnB;;OAEG;IAEH,WAAW,EAAE,IAAI,CAAc;IAE/B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAM;IAEzB;;OAEG;IAEH,KAAK,EAAE,MAAM,CAAM;gBAEP,OAAO,GAAE,wBAA6B;IAalD,6EAA6E;IAC9D,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAgFrC;AAED,eAAe,iBAAiB,CAAC"}
@@ -3,7 +3,7 @@
3
3
  * @packageDocumentation
4
4
  */
5
5
  import { SmrtObject } from '@happyvertical/smrt-core';
6
- import { type VendorOptions, VendorStatus } from '../types/index.js';
6
+ import { type PartyContact, type VendorOptions, VendorStatus } from '../types/index.js';
7
7
  /**
8
8
  * Vendor represents the vendor/supplier role for a Profile.
9
9
  *
@@ -86,6 +86,11 @@ export declare class Vendor extends SmrtObject {
86
86
  * responses and rejected as a `where` filter key.
87
87
  */
88
88
  payoutAddresses: Record<string, string>;
89
+ /**
90
+ * People to reach at this vendor, stored as a JSON column (#3501). Write
91
+ * form rows through `savePartyContacts()`; every save normalizes the shape.
92
+ */
93
+ contacts: PartyContact[];
89
94
  constructor(options?: VendorOptions);
90
95
  /**
91
96
  * The framework's {@link SmrtObject.initialize} re-applies `options` keys on
@@ -1 +1 @@
1
- {"version":3,"file":"Vendor.d.ts","sourceRoot":"","sources":["../../src/models/Vendor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAGL,UAAU,EAEX,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,KAAK,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAErE;;;;;;;;;;;;;;;GAeG;AACH,qBAMa,MAAO,SAAQ,UAAU;IACpC;;;OAGG;IAEH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE/B;;;OAGG;IAKH,SAAS,EAAE,MAAM,CAAM;IAEvB;;OAEG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Q7D;;;OAGG;IACH,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAU1C;;;;;;;;;OASG;IACH,OAAO,CAAC,MAAM,CAAC,wBAAwB;CAqBxC;AAED,eAAe,MAAM,CAAC"}
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Contact rows for customers and vendors (#3501).
3
+ *
4
+ * `CustomerForm` and `VendorForm` (`./svelte`) post contacts as repeated
5
+ * field names in DOM order, one value per row for each of `contactId`,
6
+ * `contactName`, `contactLabel`, `contactEmail`, `contactPhone`, and
7
+ * `contactAddress` (all overridable through the forms' `fieldNames`). The
8
+ * helpers here read that payload, apply the native add/remove intents, and
9
+ * write the rows to `Customer.contacts` / `Vendor.contacts`.
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+ import type { CustomerCollection } from './collections/CustomerCollection.js';
14
+ import type { VendorCollection } from './collections/VendorCollection.js';
15
+ import type { PartyContact } from './types/index.js';
16
+ /** One submitted contact row, exactly as posted (untrimmed strings). */
17
+ export type PartyContactInput = Partial<PartyContact>;
18
+ /** The text fields of a contact, which are also its error keys. */
19
+ export type PartyContactField = Exclude<keyof PartyContact, 'id'>;
20
+ /** HTML names of the repeated contact fields; defaults match the forms. */
21
+ export interface PartyContactFieldNames {
22
+ contactId: string;
23
+ contactName: string;
24
+ contactLabel: string;
25
+ contactEmail: string;
26
+ contactPhone: string;
27
+ contactAddress: string;
28
+ /** Hidden presence marker: the number of contact rows the form rendered. */
29
+ contactCount: string;
30
+ }
31
+ /** Default contact field names, matching `DEFAULT_PARTY_FIELD_NAMES` in `./svelte`. */
32
+ export declare const DEFAULT_PARTY_CONTACT_FIELD_NAMES: PartyContactFieldNames;
33
+ /** Maximum lengths, matching the form controls' `maxlength`. */
34
+ export declare const PARTY_CONTACT_MAX_LENGTHS: Readonly<Record<PartyContactField, number>>;
35
+ /**
36
+ * Per-row validation error codes, keyed by field. `unknown_contact` (on
37
+ * `id`) means the posted id is not one of the party's saved contacts — a
38
+ * stale or altered form; reload the party and show its current rows.
39
+ */
40
+ export type PartyContactErrorCode = 'too_long' | 'invalid_email' | 'unknown_contact';
41
+ /** Errors for one submitted row; indexes match the submitted rows. */
42
+ export type PartyContactRowErrors = Partial<Record<PartyContactField | 'id', PartyContactErrorCode>>;
43
+ /** Thrown by {@link savePartyContacts} when any row is invalid; nothing is written. */
44
+ export declare class PartyContactValidationError extends Error {
45
+ /** Errors aligned with the submitted rows; `undefined` for a valid row. */
46
+ readonly errors: Array<PartyContactRowErrors | undefined>;
47
+ constructor(errors: Array<PartyContactRowErrors | undefined>);
48
+ }
49
+ /**
50
+ * Thrown by {@link readPartyContactRows} (and so {@link savePartyContacts}
51
+ * given a form) when the posted contact payload cannot be trusted:
52
+ * `missing` — no `contactCount` marker, so the editable contact block did
53
+ * not render or was posted under other field names (treating that as "no
54
+ * contacts" would delete them all); `misaligned` — the repeated fields or
55
+ * the marker disagree on the row count. Nothing is written.
56
+ */
57
+ export declare class PartyContactPayloadError extends Error {
58
+ readonly reason: 'missing' | 'misaligned';
59
+ constructor(reason: 'missing' | 'misaligned', message: string);
60
+ }
61
+ /** Thrown by {@link savePartyContacts} when the party is not visible in the current tenant. */
62
+ export declare class PartyContactPartyNotFoundError extends Error {
63
+ constructor(partyId: string);
64
+ }
65
+ /**
66
+ * Normalize stored contacts (an array, a JSON string, or nothing) into
67
+ * well-formed {@link PartyContact} rows. Non-object entries and non-string
68
+ * values are dropped; a row without an id is given one.
69
+ */
70
+ export declare function normalizePartyContacts(value: unknown): PartyContact[];
71
+ /** Minimal form-data reader; `FormData` and `URLSearchParams` both satisfy it. */
72
+ export interface PartyContactFormSource {
73
+ getAll(name: string): unknown[];
74
+ }
75
+ /**
76
+ * Read the contact rows a party form posted, in DOM order. The editable
77
+ * contact block always posts a `contactCount` marker with its row count, and
78
+ * every row renders all six fields. A missing marker (the block did not
79
+ * render, or `fieldNames` differ from the form's) or any disagreeing count
80
+ * throws {@link PartyContactPayloadError}, so zero rows is only ever read
81
+ * when the form really posted an empty contact list.
82
+ */
83
+ export declare function readPartyContactRows(form: PartyContactFormSource, fieldNames?: Partial<PartyContactFieldNames>): PartyContactInput[];
84
+ /** Submitter values for the forms' native contact row actions. */
85
+ export interface PartyContactIntents {
86
+ /** Defaults to the forms' `addContact`. */
87
+ addIntent?: string;
88
+ /** Parses a remove submitter into a row index; defaults to `removeContact:<index>`. */
89
+ parseRemoveIntent?: (intent: string) => number | undefined;
90
+ }
91
+ /**
92
+ * Apply an add or remove submitter to the posted rows and return the rows
93
+ * to render back into the form. Nothing is persisted: a row action is a
94
+ * round trip, and only the save intent writes. `handled` is `false` for any
95
+ * other intent (including save), with the rows unchanged; when it is `true`,
96
+ * render the returned rows and do not save.
97
+ */
98
+ export declare function applyPartyContactIntent(rows: readonly PartyContactInput[], intent: string, intents?: PartyContactIntents): {
99
+ contacts: PartyContactInput[];
100
+ handled: boolean;
101
+ };
102
+ /**
103
+ * Validate posted rows without persisting them. Returns the trimmed rows
104
+ * that would be written (blank rows dropped) and, when any row is invalid,
105
+ * errors aligned with the submitted rows. Ids are checked against the
106
+ * party's saved contacts only by {@link savePartyContacts}.
107
+ */
108
+ export declare function validatePartyContactRows(rows: readonly PartyContactInput[]): {
109
+ contacts: PartyContactInput[];
110
+ errors?: Array<PartyContactRowErrors | undefined>;
111
+ };
112
+ /** Options for {@link savePartyContacts}. */
113
+ export interface SavePartyContactsOptions {
114
+ /** Field names used to read a posted form; must match the form's `fieldNames`. */
115
+ fieldNames?: Partial<PartyContactFieldNames>;
116
+ /**
117
+ * When set, the party must belong to this tenant. Use it to bind a form's
118
+ * posted tenant to the loaded row in addition to the active tenant
119
+ * context, which already scopes the lookup.
120
+ */
121
+ expectedTenantId?: string | null;
122
+ }
123
+ /**
124
+ * Replace a customer's or vendor's contacts with the rows its form posted.
125
+ *
126
+ * Pass the posted `FormData` (with `options.fieldNames` when the form
127
+ * overrides them): it is read with {@link readPartyContactRows}, so a payload
128
+ * without the contact block's presence marker throws
129
+ * {@link PartyContactPayloadError} instead of removing every contact. An
130
+ * array is taken as rows the caller already read through that function.
131
+ *
132
+ * The party is loaded through `collection.get()`, so the active tenant
133
+ * context scopes it: a party in another tenant is not found. Rows are
134
+ * validated ({@link validatePartyContactRows}), blank rows dropped, kept
135
+ * rows matched to saved contacts by id (new rows get a fresh id), and rows
136
+ * that were not posted are removed. A posted id the party does not have is
137
+ * an `unknown_contact` error. On any error nothing is written and a
138
+ * {@link PartyContactValidationError} is thrown.
139
+ *
140
+ * This is a read-modify-write of one row: concurrent saves of the same party
141
+ * are last-writer-wins, like any other field edit.
142
+ *
143
+ * @returns The saved contacts, in submitted order.
144
+ */
145
+ export declare function savePartyContacts(collection: CustomerCollection | VendorCollection, partyId: string, posted: PartyContactFormSource | readonly PartyContactInput[], options?: SavePartyContactsOptions): Promise<PartyContact[]>;
146
+ //# sourceMappingURL=party-contacts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"party-contacts.d.ts","sourceRoot":"","sources":["../src/party-contacts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAG1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,wEAAwE;AACxE,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AAEtD,mEAAmE;AACnE,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,MAAM,YAAY,EAAE,IAAI,CAAC,CAAC;AAElE,2EAA2E;AAC3E,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CA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,CAwCrB;AAED,kEAAkE;AAClE,MAAM,WAAW,mBAAmB;IAClC,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uFAAuF;IACvF,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;CAC5D;AAOD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,SAAS,iBAAiB,EAAE,EAClC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,mBAAwB,GAChC;IAAE,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAYrD;AAMD;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,SAAS,iBAAiB,EAAE,GAAG;IAC5E,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAC9B,MAAM,CAAC,EAAE,KAAK,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAAC;CACnD,CAoBA;AAED,6CAA6C;AAC7C,MAAM,WAAW,wBAAwB;IACvC,kFAAkF;IAClF,UAAU,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAC7C;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,kBAAkB,GAAG,gBAAgB,EACjD,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,sBAAsB,GAAG,SAAS,iBAAiB,EAAE,EAC7D,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,YAAY,EAAE,CAAC,CAqDzB"}
@@ -3,16 +3,16 @@
3
3
  "sensitiveFieldsExcluded": true,
4
4
  "generatedAt": "1970-01-01T00:00:00.000Z",
5
5
  "packageName": "@happyvertical/smrt-commerce",
6
- "packageVersion": "0.55.23",
6
+ "packageVersion": "0.55.24",
7
7
  "sourceManifestPath": "dist/manifest.json",
8
8
  "agentDocPath": "AGENTS.md",
9
9
  "sourceHashes": {
10
- "manifest": "a202a959eaf27e21d4bd3f8d7b8a2dc968209b1f47f1d157ae80c89d95a0c0cb",
11
- "packageJson": "1fa58e8977a263200a504c19909c3b05ab29e71367bc954cd9aa0b763f47ed19",
12
- "agents": "5a4901577a0f007cf44f04658c4394e1b1fe292f24701d0ff00ccf66095b4217",
10
+ "manifest": "5fecd03ae3b2033ab017298d7beef3d4d38b2069d60f169e372c1f7e14ca8338",
11
+ "packageJson": "ba52e7d3b68131242e425cd105318d8ea47f9371d464e56c7c633ed03ad89719",
12
+ "agents": "1ec9ceb9d4380f1f239051a6726afbb2afe31ce0485498b8e40afc28aeb76356",
13
+ "moduleDoc:agents/customer-vendor-ui.md": "744fb88c23ad05e7fd953edc2598e7c13f15f0ffd69c9cba70dd3e0668ae17f8",
13
14
  "moduleDoc:agents/invoice-quantity.md": "bc3b617d4fb8cc87511763b281283107557ba64795e64522193ef967a3715d32",
14
15
  "moduleDoc:agents/payment-allocations.md": "46c0b921f0e40060cd1caec2dcefb01ed6612e31e4bf220a1a0b61e4e2a58212",
15
- "moduleDoc:agents/customer-vendor-ui.md": "1187b4d14e6bab661a2bb3312315239952dc955f90eceb177719f48dd0979150",
16
16
  "moduleDoc:agents/commercial-ui.md": "308729a481c82903d06837e7052c04509a92cf17d17345f71dce88d8d42d0431",
17
17
  "moduleDoc:agents/quote-ui.md": "514568e4e7815c47113627ac044a1f31a6933377b3f6c70f5d54b2508d94200c",
18
18
  "moduleDoc:agents/purchasing-ui.md": "c7d633c5ba45078c51f4066f68d90112cd748ac089ac34d209f9bf025739589f",
@@ -9094,6 +9094,14 @@
9094
9094
  "columnType": "TEXT",
9095
9095
  "default": "",
9096
9096
  "description": "Anything worth remembering about this customer."
9097
+ },
9098
+ {
9099
+ "name": "contacts",
9100
+ "type": "json",
9101
+ "required": false,
9102
+ "columnType": "JSON",
9103
+ "default": [],
9104
+ "description": "The people you deal with at this customer, with their role and how to reach them."
9097
9105
  }
9098
9106
  ],
9099
9107
  "relationships": [
@@ -9108,8 +9116,10 @@
9108
9116
  "methods": [
9109
9117
  "getProfileId",
9110
9118
  "hasAvailableCredit",
9119
+ "initialize",
9111
9120
  "isActive",
9112
- "isWholesale"
9121
+ "isWholesale",
9122
+ "save"
9113
9123
  ],
9114
9124
  "methodSignatures": [
9115
9125
  {
@@ -9123,6 +9133,11 @@
9123
9133
  ],
9124
9134
  "returns": "boolean"
9125
9135
  },
9136
+ {
9137
+ "name": "initialize",
9138
+ "async": true,
9139
+ "returns": "Promise<this>"
9140
+ },
9126
9141
  {
9127
9142
  "name": "isActive",
9128
9143
  "returns": "boolean"
@@ -9130,6 +9145,11 @@
9130
9145
  {
9131
9146
  "name": "isWholesale",
9132
9147
  "returns": "boolean"
9148
+ },
9149
+ {
9150
+ "name": "save",
9151
+ "async": true,
9152
+ "returns": "Promise<this>"
9133
9153
  }
9134
9154
  ],
9135
9155
  "tenant": {
@@ -9257,6 +9277,13 @@
9257
9277
  "reason": "not listed in api.include",
9258
9278
  "objectName": "@happyvertical/smrt-commerce:Customer"
9259
9279
  },
9280
+ {
9281
+ "kind": "api",
9282
+ "operation": "initialize",
9283
+ "code": "lifecycle-method",
9284
+ "reason": "`initialize` is a framework lifecycle method, not a distinct operation",
9285
+ "objectName": "@happyvertical/smrt-commerce:Customer"
9286
+ },
9260
9287
  {
9261
9288
  "kind": "api",
9262
9289
  "operation": "isActive",
@@ -9270,6 +9297,13 @@
9270
9297
  "code": "not-included",
9271
9298
  "reason": "not listed in api.include",
9272
9299
  "objectName": "@happyvertical/smrt-commerce:Customer"
9300
+ },
9301
+ {
9302
+ "kind": "api",
9303
+ "operation": "save",
9304
+ "code": "lifecycle-method",
9305
+ "reason": "`save` is a framework lifecycle method, not a distinct operation",
9306
+ "objectName": "@happyvertical/smrt-commerce:Customer"
9273
9307
  }
9274
9308
  ],
9275
9309
  "relationshipFeatures": [
@@ -12730,6 +12764,14 @@
12730
12764
  "columnType": "TEXT",
12731
12765
  "default": "",
12732
12766
  "description": "Anything worth remembering about this vendor."
12767
+ },
12768
+ {
12769
+ "name": "contacts",
12770
+ "type": "json",
12771
+ "required": false,
12772
+ "columnType": "JSON",
12773
+ "default": [],
12774
+ "description": "The people you deal with at this vendor, with their role and how to reach them."
12733
12775
  }
12734
12776
  ],
12735
12777
  "relationships": [
@@ -19833,8 +19875,13 @@
19833
19875
  "polymorphicAssociations": 0,
19834
19876
  "uuidColumns": 162
19835
19877
  },
19836
- "agentDoc": "# @happyvertical/smrt-commerce\n\nE-commerce with Contract STI hierarchy, invoice lifecycle, payment tracking, payout remittance, and optional ledger integration.\n\n## Models\n\n- **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).\n- **Contract** (STI base → Estimate, Order, Lease, Agreement, PurchaseOrder, WholesaleOrder, ProductionOrder, Cart, LicenseSale): 9 contract types sharing one table. Carries `channelId` (open-ended string — `dtc-web`, `wholesale-b2b`, `pos-store-N`, etc.) so the same model serves DTC checkout, B2B portals, and POS.\n- **WholesaleOrder**: B2B order. Conventional pairing — customer has `customerType: 'wholesale'`, NET-30/60 terms, delivered via wholesale-portal channel.\n- **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`).\n- **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.\n- **LicenseSale**: industry-neutral licensing primitive. Carries an *immutable* rights snapshot (`rightsMedium`, `rightsDistributionScope`, `rightsExclusivity`, `rightsDuration`, `rightsTerritory`, `rightsSublicensing`, `rightsDerivatives` — typed `Meta<T>` fields), licensee identity (`licenseeEmail`, optional `licenseeLegalEntity` / `licenseeJurisdiction`), and a signed-PDF reference (`pdfUrl`, `pdfHash`, optional `onChainHashRegistryRef`). Once saved at `ContractStatus.ACCEPTED`, the rights snapshot is frozen — mutating any of the seven rights fields and re-saving throws. The only legal transition out of ACCEPTED is `revoke()` (moves to CANCELLED without touching rights). Useful for stock media, music licensing, code-asset marketplaces, license keys, anywhere rights are sold for a fee.\n- **ContractLineItem**: items on contracts.\n- **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).\n- **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).\n- **Payment** / **PaymentAllocation**: tracks payments against invoices. Status controlled by `Invoice.updatePaymentStatus()`, not Payment model. 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.\n- **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. Use `PaymentInstrumentCollection.setDefaultForCustomer()` to change the default so the single-default-per-customer invariant is enforced; generated create/update routes cannot write `isDefault` directly.\n- **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 via natural key `(tenant_id, offering_ref, licensee_email, idempotency_key)` and `PaymentIntentCollection.getOrCreateByIdempotencyKey()`.\n- **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.\n- **Fulfillment** / **FulfillmentLineItem**: shipment/delivery tracking.\n\n## Recipes (#3590)\n\n`src/recipes.ts` declares four minimal `SmrtRecipe`s, emitted into the built\n`manifest.json` and `smrt-knowledge.json` `recipes`: `commerce.customers`\n(Customer), `commerce.vendors` (Vendor), `commerce.sales` (Order, requires\ncustomers), `commerce.purchases` (PurchaseOrder, requires vendors). Headers\nonly; line items, fulfilment, invoices, and payments are later recipes. Each\nhas user-facing help in `src/<name>.recipe.md` (#3591), and the fields those\nrecipes show carry `@field({ description })` text; keep both in plain\nlanguage for end users and update them when a recipe's fields change. See\n[core recipes](../core/agents/recipes.md).\n\nSee [payment allocation integrity](agents/payment-allocations.md) for atomic splits,\nretry identity, parent corrections and supported dialects.\n\n## Ledger Integration\n\n`@happyvertical/smrt-ledgers` is a regular dependency, loaded lazily via dynamic `import()` so the coupling stays runtime-only (no hard static import; the package graph stays a DAG — see #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.\n\n## Billing-period close (#3060)\n\n`src/billing/` closes periods from smrt-subscriptions charges; see the README\nfor usage.\n\n- **Port, not provider.** Period close, events, and credit checkout call only\n the `BillingProvider` port (integer minor units). `stripe.ts` adapts\n `@happyvertical/accounting`, which takes currency *major* units; convert with\n `units.ts` and never hand-roll a Stripe call here. `units.ts` exponents are\n an explicit ISO 4217 table matching the SDK's, never `Intl` display digits\n (CLDR differs for IQD, MGA, … and drifts by ICU release). The SDK's\n `*Minor` fields are already ISO minor units. Capabilities a rail may lack\n (`chargeSavedPaymentMethod`, `createSetupCheckout`, `getCheckout`,\n `setDefaultPaymentMethod`, `markInvoiceUncollectible`) are optional port\n methods: detect them by presence, and keep additions optional (#3139).\n `sendAndReconcile` refuses a provider invoice whose subtotal or total\n disagrees with the local invoice.\n- **Replay safety is identity.** Close, invoice, line, payment, allocation,\n and claim ids are `deterministicId()`s; `BillingLineSource` (conflict key\n `source_type, source_id`) is the only double-billing guard, so never bill a\n source without claiming it, and never widen that key. Each close step is\n persisted before the next; `acquireCloseLease()` serializes workers. A\n close that nets to a credit keeps its claims and ends `carried_forward`;\n its subtotal is a `credit_carry_forward` source for the payer's next billed\n close, which marks the carried close `completed`.\n- **Cycles and flat-plan coverage (#3116).** `cycles.ts` is the schedule\n (pure; `BillingAccount.billingAnchorAt`, null = calendar months). A close\n with no period closes each payer's `lastEndedBillingPeriod()`. Flat-plan\n claims are the exception to \"id from the source\": their `sourceId` is\n `<subscriptionId>:seq:<chainSequence>` and their `periodStart/End` is the\n exact time they bill. `claimFlatWindow()` reads the last number, then the\n coverage (claims ending after the window start), claims one gap as number\n n + 1, and retries on conflict; reading in that order is what makes it\n safe. That numbering, not the period, stops overlaps when schedules or\n payers change — never claim a flat plan outside it, and keep both reads\n bounded (no whole-history scans). Each numbered claim is its own invoice\n line keyed `lineKey|periodStart` (a function of the claim alone, so a\n resumed close rebuilds the same line ids). Proration is\n `prorateMinorUnits()` (half up, BigInt) against the period's full cycle.\n- **System tables.** `BillingAccount`, `BillingPeriodClose`, and\n `BillingLineSource` are not tenant-scoped and have no generated surface.\n Collections stay unexported; models are root exports (#3082). Invoices,\n payments, and journals are written in the seller's tenant; payer-owned\n subscriptions and credit grants in a system context, only after\n verification.\n- **Events** use smrt-jobs' delivery inbox under provider\n `<name>-billing:<sellerTenantId>` and a provider-filtered\n `ForgeProjectionRuntime`, so a runtime never claims another seller's\n events; any other runtime sharing the inbox must pass `providers` too. Only\n events this package acts on are stored: foreign checkouts are `ignored`,\n and only `smrt_*` checkout metadata is kept; it is\n HMAC-signed with the webhook secret at creation (empty values are omitted:\n Stripe drops them), so another integration on the same account cannot forge\n a credit purchase or a card setup; credit is granted only when the\n collected total equals it plus provider tax. Checkout amounts come from the\n re-read session (`getCheckout()`), never the Stripe event, whose amounts are\n in Stripe's unit. Rotating the webhook secret strands in-flight checkouts\n (up to 24 h). `observe()` re-reads provider state, so ordering never depends\n on delivery order; the only provider writes in `observe()` are idempotent\n (making a saved card the default). The standing hook runs inside the event\n transaction and must be idempotent.\n- **Card on file and top-ups (#3139).** A saved card is the payer customer's\n default `PaymentInstrument` (seller tenant, id from the provider method).\n `autoChargeInvoices` bills such payers `charge_automatically`, decided once\n and saved as `Invoice.collectionMethod` before the first push, which every\n retry reuses (never recompute it: a lost push response would record a\n method the provider was not asked for, #3190); activation follows `paid`, never send. An auto top-up attempt\n is a `PENDING` `Payment` (`reference` `auto-top-up:<policyId>`, id from the\n policy and `count()` of its attempts) inserted before the charge, so racing\n evaluations derive one id and one charge; the charge key is derived from\n that id. `applyAutoTopUpOutcome()` must run in a transaction and starts with\n a conditional `UPDATE … WHERE status = 'pending'` row lock, so the hook and\n the `payment` webhook settle once; the grant is keyed by the charge key.\n Never settle an attempt outside that function. Taxed accounts are charged\n with provider tax by default (#3194): the attempt row holds the credit\n (the charge subtotal), the tax is journaled to tax payable at settlement,\n and the attempt's tax decision is recorded in its `notes` so a re-drive\n repeats the same charge request (the provider refuses a key reused with\n different tax). `claimAttempt()` is the only place that decides a\n skip and reports it (`onAutoTopUpSkipped`); `cardOnFile()` and period close\n use `defaultCardInstrument()` — never copy that predicate. A provider write-off moves the local invoice to\n `WRITTEN_OFF` (a later payment, by card or on a rail (#3188), is recorded\n and reinstates the payer; the status stays, so \"paid in full\" for a\n written-off invoice is read from its allocations).\n- **`Invoice.providerTaxAmount`** is added to line-item tax; it is\n server-managed (not API-writable). `toAccountingInput()` emits major units.\n- **Payment rails (#3138).** A runtime has one issuing `provider` and any\n number of `paymentProviders` (unique names, one inbox namespace each; a\n provider with `capabilities.issuesInvoices === false` can never issue).\n `observe()` resolves the provider from the delivery namespace, never the\n payload. Crypto rails implement the port over `@happyvertical/payments`'\n `CryptoCheckoutGateway`; never call BTCPay (or any gateway) from here.\n Settlement is decided by the pure `decideAttempt()` from gateway state and\n `paymentPolicy` — the gateway's `settled` is authoritative and nothing here\n counts confirmations. A `BillingPaymentAttempt` (`(provider, checkout_id)`\n deterministic id) records every state and settles once; grants and payments\n are keyed by checkout id. Invoice payments close the issuer's invoice out of\n band in `observe()` (idempotent) before `project()` records the payment, and\n `settlePaidInvoice` skips (records nothing for) a `paidOutOfBand` invoice\n the rail latched with `outOfBandRequestedAt`; other out-of-band closes are\n recorded as `OTHER` payments. Rails never save cards or charge tax: a taxed\n credit purchase on a rail needs an explicit `automaticTax: false`. Exceptions are flags for operators;\n nothing reverses or refunds automatically.\n- **Known limits**: write-offs post no bad-debt journal (AR stays until paid\n or journaled by an operator); discounts still reach Stripe as negative lines (the SDK's\n line `discount` would change the lines a replayed push reconciles, so it\n needs its own migration); `RetailCharge` has no adjustment ledger. Flat\n plans are monthly, in arrears; plan changes are not prorated (#3119).\n\n## Cross-Package References\n\n- `customerId` → `@foreignKey('Customer')` (hard reference within package)\n- `profileId` → plain string to smrt-profiles\n- `arJournalId`, `revenueJournalId` → plain string to smrt-ledgers\n- `skuId` (on `PaymentIntent`, `LicenseSale`) → plain string to smrt-products\n- `paymentId` (on `PaymentIntent`, `Payout`, `LicenseSale`) → plain string to `Payment` (same package, but kept as plain string for cross-model consistency)\n- `vendorId` on `Payout` → `@foreignKey(Vendor)` (hard reference within package)\n- Billing records reference tenants with `@crossPackageRef('@happyvertical/smrt-users:Tenant')` and charges, plan periods, and adjustments by plain `sourceId`\n\n## Gotchas\n\n- **Optional tenancy**: all models `@TenantScoped({ mode: 'optional' })` + nullable tenantId\n- **Currency is integer minor units** (cents, satoshis) — `$19.99` is `1999`, like affiliates. Money is exact, so money fields initialize `= 0`, never `= 0.0`: the integer literal is what maps them to INTEGER columns (BIGINT on fresh PostgreSQL/DuckDB databases). Writing a fractional major-unit value is the bug — the model rejects it via `assertIntegerMinorUnits` on `Invoice`/`Payment`/`PaymentAllocation`/`Payout`/`Contract` before the database sees it, because PostgreSQL would reject it with `22P02` while SQLite's affinity silently stores it. `pnpm --filter @happyvertical/smrt-commerce test:postgres` is the lane that holds the line (#2361, #2401, #2373).\n- **Rates are the opposite**: `InvoiceLineItem.taxRate` and `ContractLineItem.taxRate` are inherently fractional and must initialize `= 0.0`. INTEGER would truncate every rate to 0. `ContractLineItem.quantity` is decimal for the same reason (contracts price fractional hours/weight/bandwidth); `InvoiceLineItem.quantity` is also decimal (six fractional places); existing integer columns require the explicit [quantity migration](agents/invoice-quantity.md).\n- **Rounding happens where a rate meets money, and nowhere else**: `InvoiceLineItem` uses exact shared invoice arithmetic to round fractional quantity × price and then tax to minor units; `ContractLineItem.calculateAmount()` uses `Math.round()` for tax. Everything downstream is exact integer arithmetic, which is why **there are no `EPSILON` tolerances left on any money path** (#2401). `Invoice`, `PaymentAllocation`, `Payout` and `PaymentIntent` compare with `===` / `>` / `>=`. Do not reintroduce a tolerance: against integers it forgives a real one-cent discrepancy rather than float fuzz. (`FulfillmentLineItem`'s quantity epsilon is unrelated — quantities are genuinely decimal there.)\n- **Migrating an existing database to minor units**: `preflightCommerceMoneyMinorUnits(db)` reports, per column, whether it still holds major units and which rows would be rounded or exceed JavaScript's safe-integer range; `migrateCommerceMoneyToMinorUnits(db)` converts them. Both are exported from the package root. The rescale is idempotent via a `_smrt_backfills` marker, changes the column type in place on PostgreSQL/DuckDB (`ALTER … TYPE BIGINT USING round(col * 100)`), and on SQLite rescales values only — SQLite cannot alter a declared type in place, so those columns come back in `declaredTypeChangePending` and need the table-rebuild path (#2370).\n- **`Payment.nativeAmount` is NOT in that migration, and must not be.** Its minor unit is a property of the *row's asset*: satoshis on a BTC rail (×1e8), cents on a fiat or stablecoin rail (×1e2), in one column discriminated only by `nativeCurrency`. A blanket ×100 turns 0.00713 BTC into `1` instead of `713000` sats, and a round 0.01 BTC even passes the preflight's integrality check while being wrong by six orders of magnitude. Convert it in two deliberate steps — normalise each row to its own asset's minor units while the column is still floating-point, then `rescaleMoneyColumnsToMinorUnits(db, COMMERCE_NATIVE_UNIT_COLUMNS, { scale: 1, … })` for the type change. `COMMERCE_NATIVE_UNIT_COLUMNS` is exported with a worked example; step one is deliberately the deployment's to write, because only it knows which `nativeCurrency` values it has used.\n- **`PaymentIntent.paymentOptions[].nativeAmount` has the same per-asset problem inside a JSON column and is likewise not migrated.** An intent's price lock defaults to 15 minutes, so the supported answer is to let open intents expire and be re-quoted: an unconverted option fails the exact `!==` reconciliation against the payment that arrives, which is a loud failure rather than a silently mis-scaled quote.\n- **Range and existing deployments**: fresh PostgreSQL/DuckDB INTEGER columns are BIGINT, and the runtime rejects values outside JavaScript's safe-integer range rather than rounding them. Existing PostgreSQL `int4` columns do not self-repair; widen them through the explicit migration tracked in #2424.\n- **Journals posted from commerce carry minor units**: `Payment.recordPayment()` and `Invoice.recognizeRevenue()` write `amount` / `totalAmount` straight into smrt-ledgers entries. smrt-ledgers is unit-agnostic (its `BALANCE_EPSILON` only checks debits === credits), and integer entries balance exactly, so this is strictly tighter than the major-unit journals commerce used to post.\n- **Invoice controls payment status**: not the Payment model — use `Invoice.updatePaymentStatus()`\n- **Tax rate is external**: no tax rate field on Invoice — rate must be calculated externally\n- **Profile linking**: separate `ProfileCollection.create()` needed to fetch actual Profile object\n- **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.\n- **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.\n- **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.\n- **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.\n- **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.\n\n## Commercial UI\n\n`CustomerSelect`/`VendorSelect` are the registered selectors for Customer and\nVendor (`selects` in `src/ui.ts`); models carry `ui.widget` hints. See\n[customer/vendor UI](agents/customer-vendor-ui.md#selectors-3602).\n\nSee [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.\n\n## Quote and estimate UI\n\n`src/svelte/quote-types.ts` separates unparsed draft strings from explicit\nminor-unit revision DTOs. Native row submitters, caller-owned retry identity and\nextension conventions are documented in [agents/quote-ui.md](agents/quote-ui.md).\n\n## Purchasing UI\n\n`PurchaseOrderEditor` preserves allocation IDs and explicit zeroes, including\nretained reduction rows; the server validates review fingerprints before recording.\nSee [agents/purchasing-ui.md](agents/purchasing-ui.md) for caller responsibilities.\n\n## Exact cost billing\n\nPure signed cost billing and explicit tax rounding are available through the\nindependent `cost-billing` subpath; see [contract](agents/cost-billing.md).\n",
19878
+ "agentDoc": "# @happyvertical/smrt-commerce\n\nE-commerce with Contract STI hierarchy, invoice lifecycle, payment tracking, payout remittance, and optional ledger integration.\n\n## Models\n\n- **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).\n- **Contract** (STI base → Estimate, Order, Lease, Agreement, PurchaseOrder, WholesaleOrder, ProductionOrder, Cart, LicenseSale): 9 contract types sharing one table. Carries `channelId` (open-ended string — `dtc-web`, `wholesale-b2b`, `pos-store-N`, etc.) so the same model serves DTC checkout, B2B portals, and POS.\n- **WholesaleOrder**: B2B order. Conventional pairing — customer has `customerType: 'wholesale'`, NET-30/60 terms, delivered via wholesale-portal channel.\n- **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`).\n- **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.\n- **LicenseSale**: industry-neutral licensing primitive. Carries an *immutable* rights snapshot (`rightsMedium`, `rightsDistributionScope`, `rightsExclusivity`, `rightsDuration`, `rightsTerritory`, `rightsSublicensing`, `rightsDerivatives` — typed `Meta<T>` fields), licensee identity (`licenseeEmail`, optional `licenseeLegalEntity` / `licenseeJurisdiction`), and a signed-PDF reference (`pdfUrl`, `pdfHash`, optional `onChainHashRegistryRef`). Once saved at `ContractStatus.ACCEPTED`, the rights snapshot is frozen — mutating any of the seven rights fields and re-saving throws. The only legal transition out of ACCEPTED is `revoke()` (moves to CANCELLED without touching rights). Useful for stock media, music licensing, code-asset marketplaces, license keys, anywhere rights are sold for a fee.\n- **ContractLineItem**: items on contracts.\n- **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).\n- **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).\n- **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.\n- **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).\n- **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.\n- **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.\n- **Fulfillment** / **FulfillmentLineItem**: shipment/delivery tracking.\n\n## Recipes (#3590)\n\n`src/recipes.ts` declares four minimal `SmrtRecipe`s, emitted into the built\n`manifest.json` and `smrt-knowledge.json` `recipes`: `commerce.customers`\n(Customer), `commerce.vendors` (Vendor), `commerce.sales` (Order, requires\ncustomers), `commerce.purchases` (PurchaseOrder, requires vendors). Headers\nonly; line items, fulfilment, invoices, and payments are later recipes. Each\nhas user-facing help in `src/<name>.recipe.md` (#3591), and the fields those\nrecipes show carry `@field({ description })` text; keep both in plain\nlanguage for end users and update them when a recipe's fields change. See\n[core recipes](../core/agents/recipes.md).\n\nSee [payment allocation integrity](agents/payment-allocations.md) for atomic splits,\nretry identity, parent corrections and supported dialects.\n\n## Ledger Integration\n\n`@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.\n\n## Billing-period close (#3060)\n\n`src/billing/` closes periods from smrt-subscriptions charges; see the README\nfor usage.\n\n- **Port, not provider.** Period close, events, and credit checkout call only\n the `BillingProvider` port (integer minor units). `stripe.ts` adapts\n `@happyvertical/accounting`, which takes currency *major* units; convert with\n `units.ts` and never hand-roll a Stripe call here. `units.ts` exponents are\n an explicit ISO 4217 table matching the SDK's, never `Intl` display digits\n (CLDR differs for IQD, MGA, … and drifts by ICU release). The SDK's\n `*Minor` fields are already ISO minor units. Capabilities a rail may lack\n (`chargeSavedPaymentMethod`, `createSetupCheckout`, `getCheckout`,\n `setDefaultPaymentMethod`, `markInvoiceUncollectible`) are optional port\n methods: detect them by presence, and keep additions optional (#3139).\n `sendAndReconcile` refuses a provider invoice whose subtotal or total\n disagrees with the local invoice.\n- **Replay safety is identity.** Close, invoice, line, payment, allocation,\n and claim ids are `deterministicId()`s; `BillingLineSource` (conflict key\n `source_type, source_id`) is the only double-billing guard, so never bill a\n source without claiming it, and never widen that key. Each close step is\n persisted before the next; `acquireCloseLease()` serializes workers. A\n close that nets to a credit keeps its claims and ends `carried_forward`;\n its subtotal is a `credit_carry_forward` source for the payer's next billed\n close, which marks the carried close `completed`.\n- **Cycles and flat-plan coverage (#3116).** `cycles.ts` is the schedule\n (pure; `BillingAccount.billingAnchorAt`, null = calendar months). A close\n with no period closes each payer's `lastEndedBillingPeriod()`. Flat-plan\n claims are the exception to \"id from the source\": their `sourceId` is\n `<subscriptionId>:seq:<chainSequence>` and their `periodStart/End` is the\n exact time they bill. `claimFlatWindow()` reads the last number, then the\n coverage (claims ending after the window start), claims one gap as number\n n + 1, and retries on conflict; reading in that order is what makes it\n safe. That numbering, not the period, stops overlaps when schedules or\n payers change — never claim a flat plan outside it, and keep both reads\n bounded (no whole-history scans). Each numbered claim is its own invoice\n line keyed `lineKey|periodStart` (a function of the claim alone, so a\n resumed close rebuilds the same line ids). Proration is\n `prorateMinorUnits()` (half up, BigInt) against the period's full cycle.\n- **System tables.** `BillingAccount`, `BillingPeriodClose`, and\n `BillingLineSource` are not tenant-scoped and have no generated surface.\n Collections stay unexported; models are root exports (#3082). Invoices,\n payments, and journals are written in the seller's tenant; payer-owned\n subscriptions and credit grants in a system context, only after\n verification.\n- **Events** use smrt-jobs' delivery inbox under provider\n `<name>-billing:<sellerTenantId>` and a provider-filtered\n `ForgeProjectionRuntime`, so a runtime never claims another seller's\n events; any other runtime sharing the inbox must pass `providers` too. Only\n events this package acts on are stored: foreign checkouts are `ignored`,\n and only `smrt_*` checkout metadata is kept; it is\n HMAC-signed with the webhook secret at creation (empty values are omitted:\n Stripe drops them), so another integration on the same account cannot forge\n a credit purchase or a card setup; credit is granted only when the\n collected total equals it plus provider tax. Checkout amounts come from the\n re-read session (`getCheckout()`), never the Stripe event, whose amounts are\n in Stripe's unit. Rotating the webhook secret strands in-flight checkouts\n (up to 24 h). `observe()` re-reads provider state, so ordering never depends\n on delivery order; the only provider writes in `observe()` are idempotent\n (making a saved card the default). The standing hook runs inside the event\n transaction and must be idempotent.\n- **Card on file and top-ups (#3139).** A saved card is the payer customer's\n default `PaymentInstrument` (seller tenant, id from the provider method).\n `autoChargeInvoices` bills such payers `charge_automatically`, decided once\n and saved as `Invoice.collectionMethod` before the first push, which every\n retry reuses (never recompute it: a lost push response would record a\n method the provider was not asked for, #3190); activation follows `paid`, never send. An auto top-up attempt\n is a `PENDING` `Payment` (`reference` `auto-top-up:<policyId>`, id from the\n policy and `count()` of its attempts) inserted before the charge, so racing\n evaluations derive one id and one charge; the charge key is derived from\n that id. `applyAutoTopUpOutcome()` must run in a transaction and starts with\n a conditional `UPDATE … WHERE status = 'pending'` row lock, so the hook and\n the `payment` webhook settle once; the grant is keyed by the charge key.\n Never settle an attempt outside that function. Taxed accounts are charged\n with provider tax by default (#3194): the attempt row holds the credit\n (the charge subtotal), the tax is journaled to tax payable at settlement,\n and the attempt's tax decision is recorded in its `notes` so a re-drive\n repeats the same charge request (the provider refuses a key reused with\n different tax). `claimAttempt()` is the only place that decides a\n skip and reports it (`onAutoTopUpSkipped`); `cardOnFile()` and period close\n use `defaultCardInstrument()` — never copy that predicate. A provider write-off moves the local invoice to\n `WRITTEN_OFF` (a later payment, by card or on a rail (#3188), is recorded\n and reinstates the payer; the status stays, so \"paid in full\" for a\n written-off invoice is read from its allocations).\n- **`Invoice.providerTaxAmount`** is added to line-item tax; it is\n server-managed (not API-writable). `toAccountingInput()` emits major units.\n- **Payment rails (#3138).** A runtime has one issuing `provider` and any\n number of `paymentProviders` (unique names, one inbox namespace each; a\n provider with `capabilities.issuesInvoices === false` can never issue).\n `observe()` resolves the provider from the delivery namespace, never the\n payload. Crypto rails implement the port over `@happyvertical/payments`'\n `CryptoCheckoutGateway`; never call BTCPay (or any gateway) from here.\n Settlement is decided by the pure `decideAttempt()` from gateway state and\n `paymentPolicy` — the gateway's `settled` is authoritative and nothing here\n counts confirmations. A `BillingPaymentAttempt` (`(provider, checkout_id)`\n deterministic id) records every state and settles once; grants and payments\n are keyed by checkout id. Invoice payments close the issuer's invoice out of\n band in `observe()` (idempotent) before `project()` records the payment, and\n `settlePaidInvoice` skips (records nothing for) a `paidOutOfBand` invoice\n the rail latched with `outOfBandRequestedAt`; other out-of-band closes are\n recorded as `OTHER` payments. Rails never save cards or charge tax: a taxed\n credit purchase on a rail needs an explicit `automaticTax: false`. Exceptions are flags for operators;\n nothing reverses or refunds automatically.\n- **Known limits**: write-offs post no bad-debt journal (AR stays until paid\n or journaled by an operator); discounts still reach Stripe as negative lines (the SDK's\n line `discount` would change the lines a replayed push reconciles, so it\n needs its own migration); `RetailCharge` has no adjustment ledger. Flat\n plans are monthly, in arrears; plan changes are not prorated (#3119).\n\n## Cross-Package References\n\n- `customerId` → `@foreignKey('Customer')` (hard reference within package)\n- `profileId` → plain string to smrt-profiles\n- `arJournalId`, `revenueJournalId` → plain string to smrt-ledgers\n- `skuId` (on `PaymentIntent`, `LicenseSale`) → plain string to smrt-products\n- `paymentId` (on `PaymentIntent`, `Payout`, `LicenseSale`) → plain string to `Payment` (same package, but kept as plain string for cross-model consistency)\n- `vendorId` on `Payout` → `@foreignKey(Vendor)` (hard reference within package)\n- Billing records reference tenants with `@crossPackageRef('@happyvertical/smrt-users:Tenant')` and charges, plan periods, and adjustments by plain `sourceId`\n\n## Gotchas\n\n- **Optional tenancy**: all models `@TenantScoped({ mode: 'optional' })` + nullable tenantId\n- **Currency is integer minor units** (cents, satoshis) — `$19.99` is `1999`, like affiliates. Money is exact, so money fields initialize `= 0`, never `= 0.0`: the integer literal is what maps them to INTEGER columns (BIGINT on fresh PostgreSQL/DuckDB databases). Writing a fractional major-unit value is the bug — the model rejects it via `assertIntegerMinorUnits` on `Invoice`/`Payment`/`PaymentAllocation`/`Payout`/`Contract` before the database sees it, because PostgreSQL would reject it with `22P02` while SQLite's affinity silently stores it. `pnpm --filter @happyvertical/smrt-commerce test:postgres` is the lane that holds the line (#2361, #2401, #2373).\n- **Rates are the opposite**: `InvoiceLineItem.taxRate` and `ContractLineItem.taxRate` are inherently fractional and must initialize `= 0.0`. INTEGER would truncate every rate to 0. `ContractLineItem.quantity` is decimal for the same reason (contracts price fractional hours/weight/bandwidth); `InvoiceLineItem.quantity` is also decimal (six fractional places); existing integer columns require the explicit [quantity migration](agents/invoice-quantity.md).\n- **Rounding happens where a rate meets money, and nowhere else**: `InvoiceLineItem` uses exact shared invoice arithmetic to round fractional quantity × price and then tax to minor units; `ContractLineItem.calculateAmount()` uses `Math.round()` for tax. Everything downstream is exact integer arithmetic, which is why **there are no `EPSILON` tolerances left on any money path** (#2401). `Invoice`, `PaymentAllocation`, `Payout` and `PaymentIntent` compare with `===` / `>` / `>=`. Do not reintroduce a tolerance: against integers it forgives a real one-cent discrepancy rather than float fuzz. (`FulfillmentLineItem`'s quantity epsilon is unrelated — quantities are genuinely decimal there.)\n- **Migrating an existing database to minor units**: `preflightCommerceMoneyMinorUnits(db)` reports, per column, whether it still holds major units and which rows would be rounded or exceed JavaScript's safe-integer range; `migrateCommerceMoneyToMinorUnits(db)` converts them. Both are exported from the package root. The rescale is idempotent via a `_smrt_backfills` marker, changes the column type in place on PostgreSQL/DuckDB (`ALTER … TYPE BIGINT USING round(col * 100)`), and on SQLite rescales values only — SQLite cannot alter a declared type in place, so those columns come back in `declaredTypeChangePending` and need the table-rebuild path (#2370).\n- **`Payment.nativeAmount` is NOT in that migration, and must not be.** Its minor unit is a property of the *row's asset*: satoshis on a BTC rail (×1e8), cents on a fiat or stablecoin rail (×1e2), in one column discriminated only by `nativeCurrency`. A blanket ×100 turns 0.00713 BTC into `1` instead of `713000` sats, and a round 0.01 BTC even passes the preflight's integrality check while being wrong by six orders of magnitude. Convert it in two deliberate steps — normalise each row to its own asset's minor units while the column is still floating-point, then `rescaleMoneyColumnsToMinorUnits(db, COMMERCE_NATIVE_UNIT_COLUMNS, { scale: 1, … })` for the type change. `COMMERCE_NATIVE_UNIT_COLUMNS` is exported with a worked example; step one is deliberately the deployment's to write, because only it knows which `nativeCurrency` values it has used.\n- **`PaymentIntent.paymentOptions[].nativeAmount` has the same per-asset problem inside a JSON column and is likewise not migrated.** An intent's price lock defaults to 15 minutes, so the supported answer is to let open intents expire and be re-quoted: an unconverted option fails the exact `!==` reconciliation against the payment that arrives, which is a loud failure rather than a silently mis-scaled quote.\n- **Range and existing deployments**: fresh PostgreSQL/DuckDB INTEGER columns are BIGINT, and the runtime rejects values outside JavaScript's safe-integer range rather than rounding them. Existing PostgreSQL `int4` columns do not self-repair; widen them through the explicit migration tracked in #2424.\n- **Journals posted from commerce carry minor units**: `Payment.recordPayment()` and `Invoice.recognizeRevenue()` write `amount` / `totalAmount` straight into smrt-ledgers entries. smrt-ledgers is unit-agnostic (its `BALANCE_EPSILON` only checks debits === credits), and integer entries balance exactly, so this is strictly tighter than the major-unit journals commerce used to post.\n- **Invoice controls payment status**: not the Payment model — use `Invoice.updatePaymentStatus()`\n- **Tax rate is external**: no tax rate field on Invoice — rate must be calculated externally\n- **Profile linking**: separate `ProfileCollection.create()` needed to fetch actual Profile object\n- **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.\n- **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.\n- **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.\n- **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.\n\n## Commercial UI\n\n`CustomerSelect`/`VendorSelect` are the registered selectors for Customer and\nVendor (`selects` in `src/ui.ts`); models carry `ui.widget` / `ui.format` hints. See\n[customer/vendor UI](agents/customer-vendor-ui.md#selectors-3602).\n\nSee [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.\n\n## Quote and estimate UI\n\n`src/svelte/quote-types.ts` separates unparsed draft strings from explicit\nminor-unit revision DTOs. Native row submitters, caller-owned retry identity and\nextension conventions are documented in [agents/quote-ui.md](agents/quote-ui.md).\n\n## Purchasing UI\n\n`PurchaseOrderEditor` preserves allocation IDs and explicit zeroes, including\nretained reduction rows; the server validates review fingerprints before recording.\nSee [agents/purchasing-ui.md](agents/purchasing-ui.md) for caller responsibilities.\n\n## Exact cost billing\n\nPure signed cost billing and explicit tax rounding are available through the\nindependent `cost-billing` subpath; see [contract](agents/cost-billing.md).\n",
19837
19879
  "moduleDocs": [
19880
+ {
19881
+ "path": "agents/customer-vendor-ui.md",
19882
+ "module": "customer-vendor-ui",
19883
+ "content": "# Customer and vendor UI\n\nImport the provider-free surfaces from `@happyvertical/smrt-commerce/svelte`:\n\n```svelte\n<script lang=\"ts\">\n import {\n CustomerDirectory,\n CustomerDetail,\n CustomerForm,\n VendorDirectory,\n VendorDetail,\n VendorForm,\n type CustomerDisplayData,\n } from '@happyvertical/smrt-commerce/svelte';\n\n let { data, form } = $props();\n</script>\n\n<CustomerForm\n mode=\"edit\"\n values={form?.values ?? data.values}\n errors={form?.errors}\n transport={{\n action: '?/update',\n method: 'post',\n hiddenFields: {\n requestId: form?.values.requestId ?? data.requestId,\n expectedTenantId: data.tenantId,\n },\n }}\n labels={{ singular: 'Client', plural: 'Clients' }}\n cancelHref={`/clients/${data.customer.id}`}\n/>\n```\n\nThe 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)).\n\n`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.\n\n`VendorFormValues.leadTimeDays` is also retained text. The control supplies a numeric keyboard hint without browser number-input sanitization, and the server must parse and validate the submitted non-negative integer.\n\nForms 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.\n\n`CustomerForm` and `VendorForm` accept submit hooks so a host never has to find\nthe form after mount (#3501). `enhance` (`PartyFormEnhance`, action-shaped) is\napplied to the mounted native `<form>` and destroyed with it; SvelteKit's\n`enhance` from `$app/forms` fits directly, or wrap it to pass a submit callback.\nAn `ssr = false` app needs it, because a plain native post answers with the\nempty shell. `onsubmit` receives the native submit event (submission stays\nnative unless it calls `preventDefault()`), and the `getFormElement()` instance\nmethod returns the native element while mounted.\n\n```svelte\n<script lang=\"ts\">\n import { enhance } from '$app/forms';\n</script>\n\n<VendorForm values={form?.values ?? data.values} errors={form?.errors} transport={{ action: '?/save' }} {enhance} />\n```\n\nDirectory 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.\n\nCustomer shipping and billing addresses use the shared `CountrySelect` and\n`ProvinceSelect`. The native names remain `shippingCountry`, `shippingState`,\n`billingCountry`, and `billingState` unless `fieldNames` overrides them. Changing\ncountry changes the region control without clearing its current string; CA and US\nrender localized subdivision choices, while unsupported countries render an\neditable text field. Unknown values remain selectable/postable after a failed\nsubmission. Use `countryOptions` or `provinceOptions` only when the caller must\nrestrict the choices. `VendorForm` has no structured address fields in its public\nDTO and does not invent them.\n\nVendor currency uses the shared `CurrencySelect`. The raw retained string remains\nthe native `currency` payload, including unknown values returned after validation.\nUse `currencyOptions` for caller-authorized restrictions; omitted options use the\nshared currency catalog. Selector labels follow the active smrt-ui i18n locale.\n\nThe forms place a non-focusable default save submitter before contact row actions so Enter in a text field cannot accidentally add or remove a contact. This remains in place when the `actions` snippet customizes the visible action bar; set `transport.saveIntent` to the custom save intent.\n\nUse the `extension` snippets for application fields such as construction roles and trades. Keep those fields and their policy in the application:\n\n```svelte\n<VendorForm values={data.values} transport={{ action: '?/save' }}>\n {#snippet extension(values)}\n <ConstructionVendorFields roles={values.roles} trades={values.trades} />\n {/snippet}\n</VendorForm>\n```\n\nDirectory 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.\n\n`CustomerDirectory`, `CustomerDetail`, `VendorDirectory`, and `VendorDetail`\nrender a `PageHeader` (the page `h1`, a subtitle, and the add/edit action) by\ndefault. A host that frames every page itself passes `headless` to render only\nthe body, then renders its own heading and create/edit affordance; or passes a\n`header` snippet to replace the built-in header in place (#3501). `backHref`\nstays independent of both.\n\nDirectory empty and filter behavior follows this contract:\n\n| State | Empty guidance | Native form behavior |\n| --- | --- | --- |\n| No query, status, or caller filter is active | Explain that no records have been added; when `canCreate` and `addHref` are present, point to creating the first record | Search and status controls retain their normal names |\n| Query or status is active | Suggest changing search or filters | Visible query/status controls remain authoritative over same-named `hiddenFields` |\n| A caller-owned filter is active | Suggest changing search or filters | Render the `filters` snippet inside the directory form and list its names in `filterNames` so same-named hidden fields are omitted |\n| Caller supplies `emptyDescription` | Render the supplied description | Submission behavior is unchanged |\n\nThe `filters` snippet is for domain-adjacent GET controls that belong beside\nsearch and status, such as a trade classification. It does not move filtering\nor authorization into the component. `hasAdditionalFilters` describes whether\nthose controls currently narrow the result, while `filterNames` prevents a\nhidden/visible duplicate name from changing native form serialization.\n\nThe registry keys are `customer-directory`, `customer-detail`, `customer-form`, `vendor-directory`, `vendor-detail`, `vendor-form`, and `party-contact-fields`. Interactive examples are published by `@happyvertical/smrt-commerce/playground` and ship in the next generated Commerce package release. DomaCraft can replace its local routes incrementally by adapting its existing server DTOs and payload names; no identity or database migration is required.\n\nThe 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.\n\n## Contact rows (#3501)\n\n`Customer.contacts` / `Vendor.contacts` store `PartyContact` rows (JSON\ncolumn; additive schema, run `smrt db:migrate`). The root package exports the\nserver half of the form's contact payload:\n\n| Export | Contract |\n| --- | --- |\n| `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. |\n| `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. |\n| `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`. |\n| `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`. |\n\nError codes are not messages: map `PartyContactValidationError.errors` to\nlocalized strings for `PartyFormErrors.contacts`, and return the submitted\nrows as retained `values.contacts`. A form with custom contact `fieldNames`\nmust pass the same names when reading; with mismatched names the marker is\nnot found and the read fails closed instead of removing every contact. Saves are a read-modify-write of the party\nrow (last writer wins). Map saved contacts to `CustomerDisplayData.contacts` /\n`VendorDisplayData.contacts` for the detail screens.\n\n## Selectors (#3602)\n\n`CustomerSelect` and `VendorSelect` are field-sized pickers built on the shared\nsmrt-ui `RelationInput` (`@happyvertical/smrt-ui/forms`, ARIA 1.2 combobox),\nthrough one internal `PartySelect` adapter that maps party DTOs to relation\noptions and localizes the field's text. Search, resolve, debounce, stale-result\nand create handling live in `RelationInput`, not here.\n\n| Prop | Meaning |\n| --- | --- |\n| `name`, `value` (bindable), `label`, `required`, `disabled`, `error`, `placeholder`, `description` | Field basics. `label` defaults to the localized \"Customer\"/\"Vendor\"; `error` renders a linked `role=\"alert\"`. |\n| `search(query)` | Caller-owned lookup returning party DTOs; called with `''` when the list opens and, debounced (`debounceMs`, default 250), as the person types. |\n| `resolve(id)` | Caller-owned lookup of the current value's DTO when it has not been listed; without it a value stays blank until searched. |\n| `onCreate(query)` | Optional. Renders \"+ New customer/vendor\" (`createLabel` overrides); a returned DTO is selected. |\n| `onchange(id)`, `interaction` | Change callback (`''` when cleared) and agent-interaction options. |\n\nRows show `profile.name` with localized status and, for customers, type\n(`Active · Wholesale`). Data never enters the component: no stores, no fetches,\nno tenant logic. A failed `search` shows an inline status, not an exception;\na failed `onCreate` leaves the field as it was. Text comes from the\n`commerce.select.*` messages. The selectors are registered as the\n`customer-select` and `vendor-select` slots, whose `selects` qualified names\nare emitted into the manifest's `uiSelectors`; keep `selects` a string literal\nso the scanner can read it.\n\nWidget hints (`@field({ ui: { widget } })`, #3599) are presentation-only and\nthe build rejects them on non-text fields; `currency` is a currency-code\npicker for ISO 4217 strings and is never applied to minor-unit amounts;\namounts take `ui: { format: 'money' }` instead (#3718).\nBehaviour tests run under jsdom: `pnpm exec vitest run --config\nvitest.selects.config.ts` (also part of `pnpm test:ui`).\n\n## Record page hints (#3718)\n\nMinor-unit amounts on Contract, Invoice, their line items, Payment,\nPaymentAllocation, `Customer.creditLimit` and `Vendor.minimumOrderAmount`\ncarry `ui: { format: 'money' }` (#3718; `widget: 'currency'` stays the\ncurrency-code picker on the text `currency` field). Payout and Payment's\nnative/USD drift amounts are not hinted: their currency is a payout rail or\nfixed USD, not the record's `currency`. The line-item FKs\n(`ContractLineItem.contractId`, `InvoiceLineItem.invoiceId`,\n`FulfillmentLineItem.fulfillmentId`) carry `role: 'items'`, so record pages\nrender them as a line-items table with a totals block;\n`src/__tests__/money-hints-manifest.test.ts` pins both.\n"
19884
+ },
19838
19885
  {
19839
19886
  "path": "agents/invoice-quantity.md",
19840
19887
  "module": "invoice-quantity",
@@ -19845,11 +19892,6 @@
19845
19892
  "module": "payment-allocations",
19846
19893
  "content": "# Payment allocation integrity\n\n`PaymentAllocation.save()` owns the financial boundary for every direct or\ncollection write. Both payment and invoice must exist, belong to the same\nexact tenant (global is distinct), have the same customer and currency, and\nhave room for the positive safe-integer minor-unit amount. Zero-total invoices\nhave no room. Missing or zero-total invoice fixtures no longer bypass the cap.\nPending payments remain allocatable; this command does not establish settlement\nproof. Generated REST/MCP/CLI allocation writes remain closed. Applications\nmust authorize the actor before invoking these backend commands.\n\nUse `PaymentAllocationCollection.allocatePayment({ paymentId, allocations,\nallocatedBy })` for a split. Each allocation is `{ id, invoiceId, amount }`, with\na caller-generated stable UUID retained across retries. Exact replay\nreuses the existing rows without applying money again; an existing id with\ndifferent parents or amount fails. Replay preserves an already-paid invoice's\nrecorded payment date. Reversing\npayment clears that date; reaching full payment again records the new date.\nThe complete batch and invoice payment-status refresh share one transaction. Invoices must\nalready be in a status that permits payment (normally SENT); WRITTEN_OFF retains\nits terminal status. A failed leg rolls back every leg and parent revision.\nDirect allocation saves continue to leave status refresh to the caller. Allocation\nwrites advance both parent revisions: reload a previously held parent with\n`await parent.loadFromId()` before applying later edits or status refresh.\nStale parent saves continue to fail the core revision guard; no implicit\nrevision refresh bypasses another editor. In-package billing follows this rule.\n\nOnce inserted, allocation tenant/payment/invoice identity is immutable. Amount\ncorrections are capped against the other allocations. Parent saves reject\nchanges to tenant, customer, currency or amount that would invalidate committed\nallocations. A payment may be increased or reduced to its allocated total;\ninvoice totals continue to derive from persisted invoice lines where present.\nStandalone payments remain saveable when allocation storage has not been\nprovisioned. An existing allocation table always participates in validation;\nstorage probes and permission errors propagate instead of disabling the guard.\n\nAll participating writes bind collections to the owning transaction executor.\nThey claim parent revisions before reading balances. Concurrent writers can\nreceive a revision conflict or database serialization failure; reload and retry\nthe complete transaction with the same allocation ids. Never retry only the\nlast leg inside an already failed transaction. PostgreSQL Repeatable Read\nsnapshots fail closed through the same revision writes. SQLite serializes the\nowning write transaction. DuckDB is not a supported commerce allocation store:\nthe existing declared foreign keys require ON UPDATE CASCADE, which its DDL\nboundary explicitly refuses; no weaker schema is substituted.\n\n### Undelivered invoice payment progress\n\nAllocation may move an undelivered DRAFT invoice to PARTIAL or PAID without a\ncustomer delivery event. Neither operation invents `sentAt` or `viewedAt`.\nAfter allocations are removed, reload the parent and call\n`updatePaymentStatus(remainingTotal)` and `save()` within the caller transaction.\nZero remaining allocations restore DRAFT only for an undelivered invoice;\na delivered invoice returns to SENT/VIEWED according to its delivery history.\nDRAFT cannot conceal positive allocations. A DRAFT save checks both its supplied\ndelivery timestamps and the currently persisted timestamps, so clearing them\nlocally during reversal cannot bypass the undelivered requirement. This guard\ndoes not introduce an immutable lifetime delivery-history record.\n\nIf a prepaid invoice is actually delivered later, call `markSent()` and save.\nFor PARTIAL/PAID invoices it records the first `sentAt` while preserving payment\nstatus, paid amount, paid date and any existing view timestamp. Repeating this\ncall preserves the first send timestamp. It records the caller's delivery\nevent; it does not send a customer message or manufacture earlier delivery.\n"
19847
19894
  },
19848
- {
19849
- "path": "agents/customer-vendor-ui.md",
19850
- "module": "customer-vendor-ui",
19851
- "content": "# Customer and vendor UI\n\nImport the provider-free surfaces from `@happyvertical/smrt-commerce/svelte`:\n\n```svelte\n<script lang=\"ts\">\n import {\n CustomerDirectory,\n CustomerDetail,\n CustomerForm,\n VendorDirectory,\n VendorDetail,\n VendorForm,\n type CustomerDisplayData,\n } from '@happyvertical/smrt-commerce/svelte';\n\n let { data, form } = $props();\n</script>\n\n<CustomerForm\n mode=\"edit\"\n values={form?.values ?? data.values}\n errors={form?.errors}\n transport={{\n action: '?/update',\n method: 'post',\n hiddenFields: {\n requestId: form?.values.requestId ?? data.requestId,\n expectedTenantId: data.tenantId,\n },\n }}\n labels={{ singular: 'Client', plural: 'Clients' }}\n cancelHref={`/clients/${data.customer.id}`}\n/>\n```\n\nThe 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.\n\n`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.\n\n`VendorFormValues.leadTimeDays` is also retained text. The control supplies a numeric keyboard hint without browser number-input sanitization, and the server must parse and validate the submitted non-negative integer.\n\nForms 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.\n\nDirectory 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.\n\nCustomer shipping and billing addresses use the shared `CountrySelect` and\n`ProvinceSelect`. The native names remain `shippingCountry`, `shippingState`,\n`billingCountry`, and `billingState` unless `fieldNames` overrides them. Changing\ncountry changes the region control without clearing its current string; CA and US\nrender localized subdivision choices, while unsupported countries render an\neditable text field. Unknown values remain selectable/postable after a failed\nsubmission. Use `countryOptions` or `provinceOptions` only when the caller must\nrestrict the choices. `VendorForm` has no structured address fields in its public\nDTO and does not invent them.\n\nVendor currency uses the shared `CurrencySelect`. The raw retained string remains\nthe native `currency` payload, including unknown values returned after validation.\nUse `currencyOptions` for caller-authorized restrictions; omitted options use the\nshared currency catalog. Selector labels follow the active smrt-ui i18n locale.\n\nThe forms place a non-focusable default save submitter before contact row actions so Enter in a text field cannot accidentally add or remove a contact. This remains in place when the `actions` snippet customizes the visible action bar; set `transport.saveIntent` to the custom save intent.\n\nUse the `extension` snippets for application fields such as construction roles and trades. Keep those fields and their policy in the application:\n\n```svelte\n<VendorForm values={data.values} transport={{ action: '?/save' }}>\n {#snippet extension(values)}\n <ConstructionVendorFields roles={values.roles} trades={values.trades} />\n {/snippet}\n</VendorForm>\n```\n\nDirectory 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.\n\nDirectory empty and filter behavior follows this contract:\n\n| State | Empty guidance | Native form behavior |\n| --- | --- | --- |\n| No query, status, or caller filter is active | Explain that no records have been added; when `canCreate` and `addHref` are present, point to creating the first record | Search and status controls retain their normal names |\n| Query or status is active | Suggest changing search or filters | Visible query/status controls remain authoritative over same-named `hiddenFields` |\n| A caller-owned filter is active | Suggest changing search or filters | Render the `filters` snippet inside the directory form and list its names in `filterNames` so same-named hidden fields are omitted |\n| Caller supplies `emptyDescription` | Render the supplied description | Submission behavior is unchanged |\n\nThe `filters` snippet is for domain-adjacent GET controls that belong beside\nsearch and status, such as a trade classification. It does not move filtering\nor authorization into the component. `hasAdditionalFilters` describes whether\nthose controls currently narrow the result, while `filterNames` prevents a\nhidden/visible duplicate name from changing native form serialization.\n\nThe registry keys are `customer-directory`, `customer-detail`, `customer-form`, `vendor-directory`, `vendor-detail`, `vendor-form`, and `party-contact-fields`. Interactive examples are published by `@happyvertical/smrt-commerce/playground` and ship in the next generated Commerce package release. DomaCraft can replace its local routes incrementally by adapting its existing server DTOs and payload names; no identity or database migration is required.\n\nThe 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.\n\n## Selectors (#3602)\n\n`CustomerSelect` and `VendorSelect` are field-sized pickers built on the shared\nsmrt-ui `RelationInput` (`@happyvertical/smrt-ui/forms`, ARIA 1.2 combobox),\nthrough one internal `PartySelect` adapter that maps party DTOs to relation\noptions and localizes the field's text. Search, resolve, debounce, stale-result\nand create handling live in `RelationInput`, not here.\n\n| Prop | Meaning |\n| --- | --- |\n| `name`, `value` (bindable), `label`, `required`, `disabled`, `error`, `placeholder`, `description` | Field basics. `label` defaults to the localized \"Customer\"/\"Vendor\"; `error` renders a linked `role=\"alert\"`. |\n| `search(query)` | Caller-owned lookup returning party DTOs; called with `''` when the list opens and, debounced (`debounceMs`, default 250), as the person types. |\n| `resolve(id)` | Caller-owned lookup of the current value's DTO when it has not been listed; without it a value stays blank until searched. |\n| `onCreate(query)` | Optional. Renders \"+ New customer/vendor\" (`createLabel` overrides); a returned DTO is selected. |\n| `onchange(id)`, `interaction` | Change callback (`''` when cleared) and agent-interaction options. |\n\nRows show `profile.name` with localized status and, for customers, type\n(`Active · Wholesale`). Data never enters the component: no stores, no fetches,\nno tenant logic. A failed `search` shows an inline status, not an exception;\na failed `onCreate` leaves the field as it was. Text comes from the\n`commerce.select.*` messages. The selectors are registered as the\n`customer-select` and `vendor-select` slots, whose `selects` qualified names\nare emitted into the manifest's `uiSelectors`; keep `selects` a string literal\nso the scanner can read it.\n\nWidget hints (`@field({ ui: { widget } })`, #3599) are presentation-only and\nthe build rejects them on non-text fields; `currency` is a currency-code\npicker for ISO 4217 strings and is never applied to minor-unit amounts.\nBehaviour tests run under jsdom: `pnpm exec vitest run --config\nvitest.selects.config.ts` (also part of `pnpm test:ui`).\n"
19852
- },
19853
19895
  {
19854
19896
  "path": "agents/commercial-ui.md",
19855
19897
  "module": "commercial-ui",