@happyvertical/smrt-sales 0.49.2 → 0.49.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/referrals.js CHANGED
@@ -1,3 +1,3 @@
1
- import "./chunks/__smrt-register__-C-eyjsLF.js";
1
+ import "./chunks/__smrt-register__-D5-2z6-A.js";
2
2
  import { A as ReferralClickOperation, B as ATTRIBUTION_RESOLUTION_MODES, C as ReferralTouchCollection, D as ReferralCollection, E as assertHttpTargetUrl, F as validateAttributionPolicyTerms, G as REFERRAL_STATUSES, H as REFERRAL_AGREEMENT_STATUSES, I as ATTRIBUTION_CONFLICT_BEHAVIORS, J as AttributionExceptionCollection, K as REFERRAL_TOUCH_KINDS, L as ATTRIBUTION_CREDIT_MODES, M as ReferralAgreement, N as AttributionPolicyCollection, O as Referral, P as AttributionPolicy, R as ATTRIBUTION_EXCEPTION_STATUSES, S as generateReferralCode, T as ReferralLink, U as REFERRAL_LINK_STATUSES, V as REFERRAL_AGREEMENT_APPROVAL_MODES, W as REFERRAL_PROGRAM_STATUSES, Y as AttributionException, _ as REFERRAL_CODE_ALPHABET, a as ReferralAgreementExecutionService, b as ReferralClickValidationError, c as ReferrerCollection, d as ReferralTermSnapshot, f as ReferralProgramCollection, g as MAX_REFERRAL_CLICK_IDEMPOTENCY_KEY_BYTES, h as MAX_CODE_GENERATION_ATTEMPTS, i as REFERRAL_AGREEMENT_SOURCE_KIND, j as ReferralAgreementCollection, k as ReferralClickOperationCollection, l as Referrer, m as DEFAULT_REFERRAL_CLICK_EVIDENCE_MAX_BYTES, n as REFERRAL_TERMS_SNAPSHOT_KIND, o as AttributionService, p as ReferralProgram, q as REFERRER_STATUSES, r as ReferralCommissionService, s as QualifiedReferralOverrideError, t as ReferralQualificationService, u as ReferralTermSnapshotCollection, v as REFERRAL_CODE_LENGTH, w as ReferralTouch, x as ReferralLinkCollection, y as ReferralClickReplayConflictError, z as ATTRIBUTION_POLICY_STATUSES } from "./chunks/referrals-BsGHbnpW.js";
3
3
  export { ATTRIBUTION_CONFLICT_BEHAVIORS, ATTRIBUTION_CREDIT_MODES, ATTRIBUTION_EXCEPTION_STATUSES, ATTRIBUTION_POLICY_STATUSES, ATTRIBUTION_RESOLUTION_MODES, AttributionException, AttributionExceptionCollection, AttributionPolicy, AttributionPolicyCollection, AttributionService, DEFAULT_REFERRAL_CLICK_EVIDENCE_MAX_BYTES, MAX_CODE_GENERATION_ATTEMPTS, MAX_REFERRAL_CLICK_IDEMPOTENCY_KEY_BYTES, QualifiedReferralOverrideError, REFERRAL_AGREEMENT_APPROVAL_MODES, REFERRAL_AGREEMENT_SOURCE_KIND, REFERRAL_AGREEMENT_STATUSES, REFERRAL_CODE_ALPHABET, REFERRAL_CODE_LENGTH, REFERRAL_LINK_STATUSES, REFERRAL_PROGRAM_STATUSES, REFERRAL_STATUSES, REFERRAL_TERMS_SNAPSHOT_KIND, REFERRAL_TOUCH_KINDS, REFERRER_STATUSES, Referral, ReferralAgreement, ReferralAgreementCollection, ReferralAgreementExecutionService, ReferralClickOperation, ReferralClickOperationCollection, ReferralClickReplayConflictError, ReferralClickValidationError, ReferralCollection, ReferralCommissionService, ReferralLink, ReferralLinkCollection, ReferralProgram, ReferralProgramCollection, ReferralQualificationService, ReferralTermSnapshot, ReferralTermSnapshotCollection, ReferralTouch, ReferralTouchCollection, Referrer, ReferrerCollection, assertHttpTargetUrl, generateReferralCode, validateAttributionPolicyTerms };
@@ -3,12 +3,12 @@
3
3
  "sensitiveFieldsExcluded": true,
4
4
  "generatedAt": "1970-01-01T00:00:00.000Z",
5
5
  "packageName": "@happyvertical/smrt-sales",
6
- "packageVersion": "0.49.2",
6
+ "packageVersion": "0.49.4",
7
7
  "sourceManifestPath": "dist/manifest.json",
8
8
  "agentDocPath": "AGENTS.md",
9
9
  "sourceHashes": {
10
- "manifest": "ebfd5c9186b53336455459e1e104d44439b294d8026658de1fc6310d2b76f2d0",
11
- "packageJson": "4889f0ccc4659d0835965733b84c30e48eaf69e1c12accdb3f7570990963fe87",
10
+ "manifest": "38582514f54abdbabd43c8a67366b0ea21048decedc402097ee9c417547f7e92",
11
+ "packageJson": "a47232a6420b8686890e49082b932e4db8994281f973756e3ca5d2cc37b0196a",
12
12
  "agents": "70ca45be28b73fa742d3ebebe4c7cc25b524ba3684757d7066056f707efc3b22",
13
13
  "moduleDoc:agents/agreements.md": "eb6ff147a0f60ee627d3337e8e9394d06fda955b4a4fff228537a9bd2803f886",
14
14
  "moduleDoc:agents/commissions.md": "e047024aafe5edcf072c1a6b7ea253c24cb15f2fa1beb2edd13651e735921f73",
@@ -60,7 +60,7 @@
60
60
  "name": "AgreementExecutionCollection",
61
61
  "qualifiedName": "@happyvertical/smrt-sales:AgreementExecutionCollection",
62
62
  "collection": "agreementexecutions",
63
- "tableName": "agreement_execution_collections",
63
+ "tableName": "agreement_executions",
64
64
  "packageName": "@happyvertical/smrt-sales",
65
65
  "extends": "SmrtCollection",
66
66
  "fields": [],
@@ -261,7 +261,7 @@
261
261
  "name": "AgreementExecutionEventCollection",
262
262
  "qualifiedName": "@happyvertical/smrt-sales:AgreementExecutionEventCollection",
263
263
  "collection": "agreementexecutionevents",
264
- "tableName": "agreement_execution_event_collections",
264
+ "tableName": "agreement_execution_events",
265
265
  "packageName": "@happyvertical/smrt-sales",
266
266
  "extends": "SmrtCollection",
267
267
  "fields": [],
@@ -347,7 +347,7 @@
347
347
  "name": "ExecutedAgreementCollection",
348
348
  "qualifiedName": "@happyvertical/smrt-sales:ExecutedAgreementCollection",
349
349
  "collection": "executedagreements",
350
- "tableName": "executed_agreement_collections",
350
+ "tableName": "executed_agreements",
351
351
  "packageName": "@happyvertical/smrt-sales",
352
352
  "extends": "SmrtCollection",
353
353
  "fields": [],
@@ -1300,7 +1300,7 @@
1300
1300
  "name": "CommissionAdjustmentCollection",
1301
1301
  "qualifiedName": "@happyvertical/smrt-sales:CommissionAdjustmentCollection",
1302
1302
  "collection": "commissionadjustments",
1303
- "tableName": "commission_adjustment_collections",
1303
+ "tableName": "commission_adjustments",
1304
1304
  "packageName": "@happyvertical/smrt-sales",
1305
1305
  "extends": "SmrtCollection",
1306
1306
  "fields": [],
@@ -1462,7 +1462,7 @@
1462
1462
  "name": "CommissionAdjustmentOperationCollection",
1463
1463
  "qualifiedName": "@happyvertical/smrt-sales:CommissionAdjustmentOperationCollection",
1464
1464
  "collection": "commissionadjustmentoperations",
1465
- "tableName": "commission_adjustment_operation_collections",
1465
+ "tableName": "commission_adjustment_operations",
1466
1466
  "packageName": "@happyvertical/smrt-sales",
1467
1467
  "extends": "SmrtCollection",
1468
1468
  "fields": [],
@@ -1516,7 +1516,7 @@
1516
1516
  "name": "CommissionCollection",
1517
1517
  "qualifiedName": "@happyvertical/smrt-sales:CommissionCollection",
1518
1518
  "collection": "commissions",
1519
- "tableName": "commission_collections",
1519
+ "tableName": "commissions",
1520
1520
  "packageName": "@happyvertical/smrt-sales",
1521
1521
  "extends": "SmrtCollection",
1522
1522
  "fields": [],
@@ -1748,7 +1748,7 @@
1748
1748
  "name": "CommissionPayoutCollection",
1749
1749
  "qualifiedName": "@happyvertical/smrt-sales:CommissionPayoutCollection",
1750
1750
  "collection": "commissionpayouts",
1751
- "tableName": "commission_payout_collections",
1751
+ "tableName": "commission_payouts",
1752
1752
  "packageName": "@happyvertical/smrt-sales",
1753
1753
  "extends": "SmrtCollection",
1754
1754
  "fields": [],
@@ -1917,7 +1917,7 @@
1917
1917
  "name": "CommissionPlanCollection",
1918
1918
  "qualifiedName": "@happyvertical/smrt-sales:CommissionPlanCollection",
1919
1919
  "collection": "commissionplans",
1920
- "tableName": "commission_plan_collections",
1920
+ "tableName": "commission_plans",
1921
1921
  "packageName": "@happyvertical/smrt-sales",
1922
1922
  "extends": "SmrtCollection",
1923
1923
  "fields": [],
@@ -2057,7 +2057,7 @@
2057
2057
  "name": "EarnerCollection",
2058
2058
  "qualifiedName": "@happyvertical/smrt-sales:EarnerCollection",
2059
2059
  "collection": "earners",
2060
- "tableName": "earner_collections",
2060
+ "tableName": "earners",
2061
2061
  "packageName": "@happyvertical/smrt-sales",
2062
2062
  "extends": "SmrtCollection",
2063
2063
  "fields": [],
@@ -2162,7 +2162,7 @@
2162
2162
  "name": "EarnerSourceAttributionCollection",
2163
2163
  "qualifiedName": "@happyvertical/smrt-sales:EarnerSourceAttributionCollection",
2164
2164
  "collection": "earnersourceattributions",
2165
- "tableName": "earner_source_attribution_collections",
2165
+ "tableName": "earner_source_attributions",
2166
2166
  "packageName": "@happyvertical/smrt-sales",
2167
2167
  "extends": "SmrtCollection",
2168
2168
  "fields": [],
@@ -2272,7 +2272,7 @@
2272
2272
  "name": "EarningEventCollection",
2273
2273
  "qualifiedName": "@happyvertical/smrt-sales:EarningEventCollection",
2274
2274
  "collection": "earningevents",
2275
- "tableName": "earning_event_collections",
2275
+ "tableName": "earning_events",
2276
2276
  "packageName": "@happyvertical/smrt-sales",
2277
2277
  "extends": "SmrtCollection",
2278
2278
  "fields": [],
@@ -4663,7 +4663,7 @@
4663
4663
  "name": "LeadCollection",
4664
4664
  "qualifiedName": "@happyvertical/smrt-sales:LeadCollection",
4665
4665
  "collection": "leads",
4666
- "tableName": "lead_collections",
4666
+ "tableName": "leads",
4667
4667
  "packageName": "@happyvertical/smrt-sales",
4668
4668
  "extends": "SmrtCollection",
4669
4669
  "fields": [],
@@ -4829,7 +4829,7 @@
4829
4829
  "name": "OpportunityCollection",
4830
4830
  "qualifiedName": "@happyvertical/smrt-sales:OpportunityCollection",
4831
4831
  "collection": "opportunities",
4832
- "tableName": "opportunity_collections",
4832
+ "tableName": "opportunities",
4833
4833
  "packageName": "@happyvertical/smrt-sales",
4834
4834
  "extends": "SmrtCollection",
4835
4835
  "fields": [],
@@ -4937,7 +4937,7 @@
4937
4937
  "name": "OpportunityConversionCollection",
4938
4938
  "qualifiedName": "@happyvertical/smrt-sales:OpportunityConversionCollection",
4939
4939
  "collection": "opportunityconversions",
4940
- "tableName": "opportunity_conversion_collections",
4940
+ "tableName": "opportunity_conversions",
4941
4941
  "packageName": "@happyvertical/smrt-sales",
4942
4942
  "extends": "SmrtCollection",
4943
4943
  "fields": [],
@@ -5004,7 +5004,7 @@
5004
5004
  "name": "PipelineDefinitionCollection",
5005
5005
  "qualifiedName": "@happyvertical/smrt-sales:PipelineDefinitionCollection",
5006
5006
  "collection": "pipelinedefinitions",
5007
- "tableName": "pipeline_definition_collections",
5007
+ "tableName": "pipeline_definitions",
5008
5008
  "packageName": "@happyvertical/smrt-sales",
5009
5009
  "extends": "SmrtCollection",
5010
5010
  "fields": [],
@@ -5138,7 +5138,7 @@
5138
5138
  "name": "PipelineStageCollection",
5139
5139
  "qualifiedName": "@happyvertical/smrt-sales:PipelineStageCollection",
5140
5140
  "collection": "pipelinestages",
5141
- "tableName": "pipeline_stage_collections",
5141
+ "tableName": "pipeline_stages",
5142
5142
  "packageName": "@happyvertical/smrt-sales",
5143
5143
  "extends": "SmrtCollection",
5144
5144
  "fields": [],
@@ -5206,7 +5206,7 @@
5206
5206
  "name": "SalesActivityCollection",
5207
5207
  "qualifiedName": "@happyvertical/smrt-sales:SalesActivityCollection",
5208
5208
  "collection": "salesactivities",
5209
- "tableName": "sales_activity_collections",
5209
+ "tableName": "sales_activities",
5210
5210
  "packageName": "@happyvertical/smrt-sales",
5211
5211
  "extends": "SmrtCollection",
5212
5212
  "fields": [],
@@ -5275,7 +5275,7 @@
5275
5275
  "name": "SalesRepresentativeCollection",
5276
5276
  "qualifiedName": "@happyvertical/smrt-sales:SalesRepresentativeCollection",
5277
5277
  "collection": "salesrepresentatives",
5278
- "tableName": "sales_representative_collections",
5278
+ "tableName": "sales_representatives",
5279
5279
  "packageName": "@happyvertical/smrt-sales",
5280
5280
  "extends": "SmrtCollection",
5281
5281
  "fields": [],
@@ -7059,7 +7059,7 @@
7059
7059
  "name": "AttributionExceptionCollection",
7060
7060
  "qualifiedName": "@happyvertical/smrt-sales:AttributionExceptionCollection",
7061
7061
  "collection": "attributionexceptions",
7062
- "tableName": "attribution_exception_collections",
7062
+ "tableName": "attribution_exceptions",
7063
7063
  "packageName": "@happyvertical/smrt-sales",
7064
7064
  "extends": "SmrtCollection",
7065
7065
  "fields": [],
@@ -7149,7 +7149,7 @@
7149
7149
  "name": "AttributionPolicyCollection",
7150
7150
  "qualifiedName": "@happyvertical/smrt-sales:AttributionPolicyCollection",
7151
7151
  "collection": "attributionpolicies",
7152
- "tableName": "attribution_policy_collections",
7152
+ "tableName": "attribution_policies",
7153
7153
  "packageName": "@happyvertical/smrt-sales",
7154
7154
  "extends": "SmrtCollection",
7155
7155
  "fields": [],
@@ -7289,7 +7289,7 @@
7289
7289
  "name": "ReferralAgreementCollection",
7290
7290
  "qualifiedName": "@happyvertical/smrt-sales:ReferralAgreementCollection",
7291
7291
  "collection": "referralagreements",
7292
- "tableName": "referral_agreement_collections",
7292
+ "tableName": "referral_agreements",
7293
7293
  "packageName": "@happyvertical/smrt-sales",
7294
7294
  "extends": "SmrtCollection",
7295
7295
  "fields": [],
@@ -7402,7 +7402,7 @@
7402
7402
  "name": "ReferralClickOperationCollection",
7403
7403
  "qualifiedName": "@happyvertical/smrt-sales:ReferralClickOperationCollection",
7404
7404
  "collection": "referralclickoperations",
7405
- "tableName": "referral_click_operation_collections",
7405
+ "tableName": "referral_click_operations",
7406
7406
  "packageName": "@happyvertical/smrt-sales",
7407
7407
  "extends": "SmrtCollection",
7408
7408
  "fields": [],
@@ -7456,7 +7456,7 @@
7456
7456
  "name": "ReferralCollection",
7457
7457
  "qualifiedName": "@happyvertical/smrt-sales:ReferralCollection",
7458
7458
  "collection": "referrals",
7459
- "tableName": "referral_collections",
7459
+ "tableName": "referrals",
7460
7460
  "packageName": "@happyvertical/smrt-sales",
7461
7461
  "extends": "SmrtCollection",
7462
7462
  "fields": [],
@@ -7595,7 +7595,7 @@
7595
7595
  "name": "ReferralLinkCollection",
7596
7596
  "qualifiedName": "@happyvertical/smrt-sales:ReferralLinkCollection",
7597
7597
  "collection": "referrallinks",
7598
- "tableName": "referral_link_collections",
7598
+ "tableName": "referral_links",
7599
7599
  "packageName": "@happyvertical/smrt-sales",
7600
7600
  "extends": "SmrtCollection",
7601
7601
  "fields": [],
@@ -7732,7 +7732,7 @@
7732
7732
  "name": "ReferralProgramCollection",
7733
7733
  "qualifiedName": "@happyvertical/smrt-sales:ReferralProgramCollection",
7734
7734
  "collection": "referralprograms",
7735
- "tableName": "referral_program_collections",
7735
+ "tableName": "referral_programs",
7736
7736
  "packageName": "@happyvertical/smrt-sales",
7737
7737
  "extends": "SmrtCollection",
7738
7738
  "fields": [],
@@ -7837,7 +7837,7 @@
7837
7837
  "name": "ReferralTermSnapshotCollection",
7838
7838
  "qualifiedName": "@happyvertical/smrt-sales:ReferralTermSnapshotCollection",
7839
7839
  "collection": "referraltermsnapshots",
7840
- "tableName": "referral_term_snapshot_collections",
7840
+ "tableName": "referral_term_snapshots",
7841
7841
  "packageName": "@happyvertical/smrt-sales",
7842
7842
  "extends": "SmrtCollection",
7843
7843
  "fields": [],
@@ -7881,7 +7881,7 @@
7881
7881
  "name": "ReferralTouchCollection",
7882
7882
  "qualifiedName": "@happyvertical/smrt-sales:ReferralTouchCollection",
7883
7883
  "collection": "referraltouches",
7884
- "tableName": "referral_touch_collections",
7884
+ "tableName": "referral_touches",
7885
7885
  "packageName": "@happyvertical/smrt-sales",
7886
7886
  "extends": "SmrtCollection",
7887
7887
  "fields": [],
@@ -7972,7 +7972,7 @@
7972
7972
  "name": "ReferrerCollection",
7973
7973
  "qualifiedName": "@happyvertical/smrt-sales:ReferrerCollection",
7974
7974
  "collection": "referrers",
7975
- "tableName": "referrer_collections",
7975
+ "tableName": "referrers",
7976
7976
  "packageName": "@happyvertical/smrt-sales",
7977
7977
  "extends": "SmrtCollection",
7978
7978
  "fields": [],
@@ -14292,7 +14292,7 @@
14292
14292
  "junctionCollections": 0,
14293
14293
  "hierarchicalObjects": 0,
14294
14294
  "polymorphicAssociations": 0,
14295
- "uuidColumns": 136
14295
+ "uuidColumns": 216
14296
14296
  },
14297
14297
  "agentDoc": "# @happyvertical/smrt-sales\n\nModular sales: provider-neutral agreement execution, CRM, referral intake, a neutral commissions financial core, and reusable Svelte surfaces. One installable package with distinct subpath exports:\n\n- `@happyvertical/smrt-sales/agreements`\n- `@happyvertical/smrt-sales/crm`\n- `@happyvertical/smrt-sales/referrals`\n- `@happyvertical/smrt-sales/commissions`\n- `@happyvertical/smrt-sales/svelte`\n\nThe root export re-exports every TS module. `agreements` depends on the provider-neutral `@happyvertical/signatures` contract and `smrt-assets`; provider credentials stay in the injected SDK adapter/secret store. `referrals` binds its versioned terms to `agreements`.\n\n## Validation\n\nRun `pnpm --filter @happyvertical/smrt-sales test` and `pnpm --filter @happyvertical/smrt-sales typecheck` for package changes. PostgreSQL-sensitive changes must also run `pnpm --filter @happyvertical/smrt-sales test:postgres`; the command uses the repository's disposable PostgreSQL harness and is registered in the PostgreSQL CI shard.\n\n## Roles vs. money\n\nReferrers and Sales Representatives are **distinct roles** and stay that way. Both connect to money through one neutral financial account:\n\n- **Earner** (commissions): payout identity — method, threshold, currency, status. Referenced by every Commission and CommissionPayout.\n- **SalesRepresentative** (crm) and **Referrer** (referrals): role models, each holding `profileId` (cross-package string ref to smrt-profiles) and `earnerId`.\n\n## Modules\n\nPer-module semantics live in sibling module docs — read the one for the module\nyou are editing. This file keeps what holds in every module.\n\n| Module | Scope | Module doc |\n|---|---|---|\n| `agreements` | verified execution evidence — private orchestration state, append-only provider events, immutable executed agreements, and the provider-neutral execution service | [agents/agreements.md](agents/agreements.md) |\n| `commissions` | the neutral financial core — earners, versioned plans, earning events, commissions, adjustments, balances, and payout settlement | [agents/commissions.md](agents/commissions.md) |\n| `crm` | leads, configurable pipelines, opportunities, tenant-safe Lead follow-up, activity trail, and idempotent conversion links | [agents/crm.md](agents/crm.md) |\n| `referrals` | referrers, programs, versioned attribution policies, links/touches, referrals, exception review, and term snapshots | [agents/referrals.md](agents/referrals.md) |\n| `svelte` | props-driven presentational surfaces for CRM, the referrer portal, and operator review | [agents/svelte.md](agents/svelte.md) |\n\n## Currency\n\n**All monetary fields are integer cents** with `*Cents` suffixes; that scale is a Sales contract, not an implicit framework currency rule. Fresh PostgreSQL/DuckDB INTEGER columns are BIGINT, while JavaScript hydration rejects values outside the safe-integer range. Rates are decimal (`0`–`1`). Rounding happens once per calculation step via `roundCents()` (half-away-from-zero) and every Commission stores its `calculationTrace` so amounts are reproducible. Convert at display/commerce boundaries with `centsToAmount()`/`amountToCents()`.\n\n## Tenancy\n\nBusiness/domain models are generally `@TenantScoped({ mode: 'optional' })` with `@tenantId({ nullable: true })`. This deliberately departs from legacy smrt-affiliates (which was cross-tenant by design for ad networks): sales programs, earners, and payouts are tenant-owned, while `tenantId: null` remains available for intentional global/operator-level rows. Immutable tenant-bound execution evidence (`AgreementExecution`, `AgreementExecutionEvent`, `ExecutedAgreement`) and private orchestration fences (`CommissionAdjustmentOperation`) instead use required tenancy with a non-null owner; never weaken those rows to optional tenancy.\n\n## Cross-package references (plain strings)\n\n`profileId` → smrt-profiles Profile; `invoiceId` (CommissionPayout) → smrt-commerce Invoice; agreement artifacts → smrt-assets Asset ids. No static imports of unrelated sibling domain packages.\n\n## smrt-affiliates migration\n\n`@happyvertical/smrt-affiliates` is now a deprecated compatibility package that re-exports this package's commissions core under the legacy names (`Partner` → `Earner`, `Payout` → `CommissionPayout`, `Commission`, collections, enums) with `@deprecated` guidance and **no duplicate persistence model**. The data/API mapping lives in `packages/affiliates/MIGRATION.md`.\n\n## Gotchas\n\n- **Cents vs. rates**: `*Cents` fields are INTEGER (`= 0` defaults); `rate`/`probability`/`shareFraction` are DECIMAL (`= 0.0` defaults). Don't mix the two conventions on one field.\n- **Optional same-package foreign keys use null**: execution, supersession, earning-event, and payout references that are absent persist as `null`, never `''`; their physical database constraints remain enabled when a real id is present.\n- **Versioned terms are rows, not edits**: CommissionPlan / AttributionPolicy / ReferralAgreement amendments insert `version + 1`; active versions are save-guarded immutable.\n- **Idempotency is dedupeKey-based**: EarningEvent, Commission, and CommissionPayout carry natural keys (`conflictColumns`) — retried ingestion/settlement upserts instead of duplicating.\n- **Adjustments never rewrite**: correcting an earned/paid Commission means appending a CommissionAdjustment, not editing the Commission.\n- **Adjustment retries use the service**: CommissionAdjustment has no public operation field and rejects an untyped `operationId` constructor option; ordinary legacy creates without one remain compatible. `CommissionAdjustmentService` transactionally claims the private operation fence with insert-on-conflict-no-op, creates the explicit mapped adjustment id only for the winner, then verifies the persisted intent; the same globally unique operation UUID cannot be reused by another tenant.\n- **Manifest objects must remain root-importable**: generated consumer registration imports every manifest-advertised model and collection from `@happyvertical/smrt-sales`. The `CommissionAdjustmentOperation` and `ReferralClickOperation` model/collection values are therefore root and owning-subpath exports for runtime loading, while their `api: false`, `mcp: false`, and `cli: false` decorators keep them off generated application surfaces. Publish-pack validation imports the actual CLI-generated register against the packed tarball.\n- **CommissionPayout, not Payout**: avoids the pre-existing global table-name collision between commerce `Payout` and legacy affiliates `Payout` (`payouts`).\n- **Table names are global**: new models were named to avoid collisions across packages (`commission_payouts`, `sales_activities`, `attribution_policies`, …).\n- **Svelte module is svelte-check-gated**: no runtime component tests; `typecheck` runs `svelte-check` via `scripts/svelte-check-a11y.mjs`. Ship raw `.svelte` via `svelte-package`.\n- **Lead follow-up stays generic**: call `LeadWorkflowService` for audited Lead assignment/status/activity/task mutations under ambient tenancy; it locks rows, rejects cross-tenant identifiers, and has no authorization, SLA, automatic-owner, reminder, website-contact, or conversion policy. `LeadDetail` is props/callback only; host applications map state and call the service.\n- **Model transition methods don't save**: `markEarned()/approve()/markPayable()/markPaid()` (Commission) and the payout transitions mutate + stamp timestamps only — callers save; the settlement/payout services do both.\n- **`reject()` alone strands rows**: the model method only flips status — always reject through `transitionPayoutForSource`, which releases the batch's membership in the same transaction; stamped rows on a rejected payout would be unsettleable forever.\n- **The payout source stamp is derived data, never authorization**: `sourceKind`/`sourceId` on CommissionPayout index the history listing; both the listing and the lifecycle service re-verify actual membership and fail closed when the stamp cannot be proven.\n- **`sweepClearing` treats `clearingEndsAt: null` as immediately sweepable** (no clearing configured ⇒ nothing to wait for).\n- **Agreement freeze scope**: activating a ReferralAgreement requires and freezes its execution/evidence refs along with its commercial terms. `effectiveTo` remains writable for explicit end-dating; signed bytes, hashes, signer evidence, and audit trail exist only on immutable ExecutedAgreement/Asset records.\n- **Circular FK pair by design**: `Referral.snapshotId ↔ ReferralTermSnapshot.referralId`. Fine on SQLite (and no cross-table DDL constraints are emitted for these string FKs); keep an eye on strict-DDL environments.\n- **Attribution resolution is single-writer per (target, program)**: `resolve()` is idempotent against PERSISTED state, but two workers resolving the same target concurrently can both pass the existence check and create duplicate credit — the collection layer has no cross-row transaction (the same stance as payout batching, which relies on disjoint scopes for concurrency). Run intake resolution serially per target (it naturally is, in a request handler); duplicates are visible in the portal and correctable via `override()`.\n- **recordClick inside your transaction participates, never nests**: a nested adapter `transaction()` takes an independent pooled connection (happyvertical/sdk#1108) — it deadlocks undetectably on locks the caller's transaction holds (PostgreSQL sees a promise-wait, not a lock-wait) and refuses caller-created uncommitted links as `unknown_code`. Pass the caller's transaction database as `RecordClickInput.transaction` or bind the collection to it (`{ db: tx, _reuseInitializedDb: true, _deferRuntimeInitialization: true }` — detected and honored automatically); a pool-level database passed as `transaction` is refused with typed reason `invalid_transaction`. Participating results are bound to the caller's transaction — carry ids across the commit boundary; the pool-bound default still self-transacts and rehydrates after commit.\n- **Click retries reuse one key**: pass the exact same non-empty, well-formed-Unicode `recordClick.idempotencyKey` (maximum 256 UTF-8 bytes) on transport/database retry. Omitting it remains source-compatible but creates and returns a one-shot UUID; it cannot deduplicate a later independent invocation. `maxEvidenceBytes` guards creation; changing it cannot turn an already-committed exact replay into failure. Replay validation is against the immutable operation/touch snapshot, not mutable current link fields: later link edits preserve exact replay, the result link is current, and the touch evidence is the original snapshot. The private optional-tenant `ReferralClickOperation` table is the serialization fence and must be included in schema migration. Never pre-bound caller evidence: Sales owns the authoritative final-envelope byte check.\n- **`ObjectRegistry.getConfig(X)` needs the class module imported** (decorator side effects) — manifest-only registration doesn't carry api/mcp/conflictColumns; tests asserting surface configs need a side-effect import of the module barrel.\n",
14298
14298
  "moduleDocs": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happyvertical/smrt-sales",
3
- "version": "0.49.2",
3
+ "version": "0.49.4",
4
4
  "smrtJsdoc": "strict",
5
5
  "description": "Modular sales for the SMRT framework: agreement execution, CRM, referral intake, neutral commissions, and reusable Svelte surfaces",
6
6
  "type": "module",
@@ -43,17 +43,17 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@happyvertical/signatures": "^0.89.6",
46
- "@happyvertical/smrt-assets": "0.49.2",
47
- "@happyvertical/smrt-core": "0.49.2",
48
- "@happyvertical/smrt-tenancy": "0.49.2",
49
- "@happyvertical/smrt-ui": "0.49.2",
46
+ "@happyvertical/smrt-assets": "0.49.4",
47
+ "@happyvertical/smrt-core": "0.49.4",
48
+ "@happyvertical/smrt-tenancy": "0.49.4",
49
+ "@happyvertical/smrt-ui": "0.49.4",
50
50
  "@happyvertical/sql": "^0.89.6"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "svelte": "^5.56.4"
54
54
  },
55
55
  "devDependencies": {
56
- "@happyvertical/smrt-vitest": "0.49.2",
56
+ "@happyvertical/smrt-vitest": "0.49.4",
57
57
  "@sveltejs/package": "^2.5.8",
58
58
  "@sveltejs/vite-plugin-svelte": "^7.1.2",
59
59
  "@types/node": "24.13.2",