@happyvertical/smrt-sales 0.55.0 → 0.55.2

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.
@@ -70,6 +70,8 @@ export interface CreateLeadInput {
70
70
  contactName?: string;
71
71
  phone?: string;
72
72
  organizationName?: string;
73
+ /** Optional host-authorized Profile identity for the prospect/requester. */
74
+ profileId?: string;
73
75
  sourceKind: string;
74
76
  sourceId?: string;
75
77
  acquisitionContext?: Record<string, unknown>;
@@ -100,6 +102,18 @@ export interface QualifyLeadResult {
100
102
  opportunity: Opportunity;
101
103
  created: boolean;
102
104
  }
105
+ export interface MoveOpportunityToStageInput {
106
+ opportunityId: string;
107
+ stageId: string;
108
+ actorProfileId: string;
109
+ probabilityOverride?: number;
110
+ now?: Date;
111
+ }
112
+ export interface MoveOpportunityToStageResult {
113
+ opportunity: Opportunity;
114
+ /** `false` for an exact retry of the current stage and probability. */
115
+ changed: boolean;
116
+ }
103
117
  export interface OpportunityConversionInput {
104
118
  targetKind: string;
105
119
  targetId: string;
@@ -174,7 +188,7 @@ export interface GetLeadWorkStateInput {
174
188
  timeZone?: string;
175
189
  }
176
190
  /** Stable machine-readable refusal reasons for workflow callers. */
177
- export type LeadWorkflowValidationReason = 'tenant_context_required' | 'transaction_unavailable' | 'lead_unavailable' | 'representative_unavailable' | 'representative_inactive' | 'lead_not_actionable' | 'invalid_transition' | 'reason_required' | 'reason_too_long' | 'summary_required' | 'summary_too_long' | 'invalid_activity_kind' | 'invalid_metadata' | 'invalid_due_at' | 'task_unavailable' | 'task_not_open' | 'completion_replay_conflict' | 'name_required' | 'contact_required' | 'invalid_email' | 'source_kind_required' | 'invalid_dedupe_policy' | 'invalid_idempotency_key' | 'idempotency_conflict' | 'pipeline_unavailable' | 'pipeline_has_no_terminal_stage' | 'opportunity_unavailable' | 'invalid_value' | 'invalid_conversion' | 'opportunity_replay_conflict';
191
+ export type LeadWorkflowValidationReason = 'tenant_context_required' | 'transaction_unavailable' | 'lead_unavailable' | 'representative_unavailable' | 'representative_inactive' | 'lead_not_actionable' | 'invalid_transition' | 'reason_required' | 'reason_too_long' | 'summary_required' | 'summary_too_long' | 'invalid_activity_kind' | 'invalid_metadata' | 'invalid_due_at' | 'task_unavailable' | 'task_not_open' | 'completion_replay_conflict' | 'name_required' | 'contact_required' | 'invalid_email' | 'source_kind_required' | 'invalid_dedupe_policy' | 'invalid_idempotency_key' | 'idempotency_conflict' | 'pipeline_unavailable' | 'pipeline_has_no_terminal_stage' | 'stage_unavailable' | 'opportunity_unavailable' | 'invalid_value' | 'invalid_conversion' | 'opportunity_replay_conflict';
178
192
  /** Workflow validation error that never reveals cross-tenant row existence. */
179
193
  export declare class LeadWorkflowValidationError extends Error {
180
194
  readonly reason: LeadWorkflowValidationReason;
@@ -194,6 +208,8 @@ export declare class LeadWorkflowService {
194
208
  createLead(input: CreateLeadInput): Promise<CreateLeadResult>;
195
209
  /** Qualify a Lead through the collection lifecycle in one transaction. */
196
210
  qualifyLead(input: QualifyLeadInput): Promise<QualifyLeadResult>;
211
+ /** Move an open Opportunity between nonterminal stages in one transaction. */
212
+ moveOpportunityToStage(input: MoveOpportunityToStageInput): Promise<MoveOpportunityToStageResult>;
197
213
  /** Close an opportunity at its configured terminal stage and optionally link conversion. */
198
214
  closeOpportunity(input: CloseOpportunityInput): Promise<CloseOpportunityResult>;
199
215
  /** Assign or reassign an active representative, with one audit row per change. */
@@ -221,6 +237,7 @@ export declare class LeadWorkflowService {
221
237
  private lockLead;
222
238
  private lockLeadTask;
223
239
  private lockOpportunity;
240
+ private lockPipelineStage;
224
241
  private lockOperationFence;
225
242
  private findDedupeMatches;
226
243
  private readLead;
@@ -1 +1 @@
1
- {"version":3,"file":"LeadWorkflowService.d.ts","sourceRoot":"","sources":["../../../src/crm/services/LeadWorkflowService.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAajE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CAAC,iBAAiB;IAazB,OAAO,CAAC,kBAAkB;IAoB1B,OAAO,CAAC,iBAAiB;IAczB,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,oBAAoB;IAU5B,OAAO,CAAC,mBAAmB;IAU3B,OAAO,CAAC,qBAAqB;IAQ7B,OAAO,CAAC,GAAG;IAIX,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,OAAO;CAMhB;AA4GD,eAAe,mBAAmB,CAAC"}
package/dist/crm.js CHANGED
@@ -1,3 +1,3 @@
1
- import "./chunks/__smrt-register__-B51ohBYo.js";
2
- import { C as PIPELINE_STATUSES, D as Lead, E as SALES_REPRESENTATIVE_STATUSES, S as OPPORTUNITY_STATUSES, T as SALES_ACTIVITY_SUBJECT_KINDS, _ as PipelineStage, a as projectLeadWorkQueue, b as DEFAULT_PIPELINE_STAGES, c as LeadCollection, d as PipelineDefinitionCollection, f as PipelineDefinition, g as PipelineStageCollection, h as SalesActivity, i as MAX_LEAD_WORKFLOW_TEXT_LENGTH, l as SalesRepresentativeCollection, m as SalesActivityCollection, n as LeadWorkflowService, o as OpportunityConversionCollection, p as OpportunityCollection, r as LeadWorkflowValidationError, s as OpportunityConversion, t as LEAD_HUMAN_ACTIVITY_KINDS, u as SalesRepresentative, v as Opportunity, w as SALES_ACTIVITY_KINDS, x as LEAD_STATUSES, y as DEFAULT_PIPELINE_KEY } from "./chunks/crm-DfRKKvWV.js";
1
+ import "./chunks/__smrt-register__-C3xJS35z.js";
2
+ import { C as PIPELINE_STATUSES, D as Lead, E as SALES_REPRESENTATIVE_STATUSES, S as OPPORTUNITY_STATUSES, T as SALES_ACTIVITY_SUBJECT_KINDS, _ as PipelineStage, a as projectLeadWorkQueue, b as DEFAULT_PIPELINE_STAGES, c as LeadCollection, d as PipelineDefinitionCollection, f as PipelineDefinition, g as PipelineStageCollection, h as SalesActivity, i as MAX_LEAD_WORKFLOW_TEXT_LENGTH, l as SalesRepresentativeCollection, m as SalesActivityCollection, n as LeadWorkflowService, o as OpportunityConversionCollection, p as OpportunityCollection, r as LeadWorkflowValidationError, s as OpportunityConversion, t as LEAD_HUMAN_ACTIVITY_KINDS, u as SalesRepresentative, v as Opportunity, w as SALES_ACTIVITY_KINDS, x as LEAD_STATUSES, y as DEFAULT_PIPELINE_KEY } from "./chunks/crm-B-irXbbr.js";
3
3
  export { DEFAULT_PIPELINE_KEY, DEFAULT_PIPELINE_STAGES, LEAD_HUMAN_ACTIVITY_KINDS, LEAD_STATUSES, Lead, LeadCollection, LeadWorkflowService, LeadWorkflowValidationError, MAX_LEAD_WORKFLOW_TEXT_LENGTH, OPPORTUNITY_STATUSES, Opportunity, OpportunityCollection, OpportunityConversion, OpportunityConversionCollection, PIPELINE_STATUSES, PipelineDefinition, PipelineDefinitionCollection, PipelineStage, PipelineStageCollection, SALES_ACTIVITY_KINDS, SALES_ACTIVITY_SUBJECT_KINDS, SALES_REPRESENTATIVE_STATUSES, SalesActivity, SalesActivityCollection, SalesRepresentative, SalesRepresentativeCollection, projectLeadWorkQueue };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import "./chunks/__smrt-register__-B51ohBYo.js";
1
+ import "./chunks/__smrt-register__-C3xJS35z.js";
2
2
  import { a as AgreementExecutionEvent, c as AGREEMENT_EXECUTION_STATUSES, d as sanitizeSignerIntent, i as AgreementExecutionEventCollection, l as coerceAgreementDate, n as ExecutedAgreementCollection, o as AgreementExecutionCollection, r as ExecutedAgreement, s as AgreementExecution, t as AgreementExecutionService, u as sanitizeSignerEvidence } from "./chunks/agreements-BB_tNU0U.js";
3
3
  import { A as EARNING_EVENT_KINDS, C as COMMISSION_ADJUSTMENT_KINDS, D as COMMISSION_STATUSES, E as COMMISSION_PLAN_STATUSES, F as Commission, I as CommissionAdjustmentOperationCollection, L as CommissionAdjustmentOperation, M as CommissionPayoutCollection, N as CommissionPayout, O as EARNER_SOURCE_ATTRIBUTION_STATUSES, P as CommissionCollection, R as CommissionAdjustmentCollection, S as ADJUSTMENT_SETTLEABLE_COMMISSION_STATUSES, T as COMMISSION_PAYOUT_STATUSES, _ as EarnerCollection, a as CommissionBalanceService, b as CommissionPlan, c as CommissionAdjustmentValidationError, d as centsToAmount, f as roundCents, g as EarnerSourceAttribution, h as EarnerSourceAttributionCollection, i as CommissionCalculationService, j as PAYOUT_METHODS, k as EARNER_STATUSES, l as amountToCents, m as EarningEvent, n as CommissionSettlementService, o as CommissionAdjustmentReplayConflictError, p as EarningEventCollection, r as CommissionPayoutService, s as CommissionAdjustmentService, t as EarnerAttributionService, u as calculateCommissionAmountCents, v as Earner, w as COMMISSION_BASES, x as validateCommissionPlanComponents, y as CommissionPlanCollection, z as CommissionAdjustment } from "./chunks/commissions-Cs4MsxVg.js";
4
- import { C as PIPELINE_STATUSES, D as Lead, E as SALES_REPRESENTATIVE_STATUSES, S as OPPORTUNITY_STATUSES, T as SALES_ACTIVITY_SUBJECT_KINDS, _ as PipelineStage, a as projectLeadWorkQueue, b as DEFAULT_PIPELINE_STAGES, c as LeadCollection, d as PipelineDefinitionCollection, f as PipelineDefinition, g as PipelineStageCollection, h as SalesActivity, i as MAX_LEAD_WORKFLOW_TEXT_LENGTH, l as SalesRepresentativeCollection, m as SalesActivityCollection, n as LeadWorkflowService, o as OpportunityConversionCollection, p as OpportunityCollection, r as LeadWorkflowValidationError, s as OpportunityConversion, t as LEAD_HUMAN_ACTIVITY_KINDS, u as SalesRepresentative, v as Opportunity, w as SALES_ACTIVITY_KINDS, x as LEAD_STATUSES, y as DEFAULT_PIPELINE_KEY } from "./chunks/crm-DfRKKvWV.js";
4
+ import { C as PIPELINE_STATUSES, D as Lead, E as SALES_REPRESENTATIVE_STATUSES, S as OPPORTUNITY_STATUSES, T as SALES_ACTIVITY_SUBJECT_KINDS, _ as PipelineStage, a as projectLeadWorkQueue, b as DEFAULT_PIPELINE_STAGES, c as LeadCollection, d as PipelineDefinitionCollection, f as PipelineDefinition, g as PipelineStageCollection, h as SalesActivity, i as MAX_LEAD_WORKFLOW_TEXT_LENGTH, l as SalesRepresentativeCollection, m as SalesActivityCollection, n as LeadWorkflowService, o as OpportunityConversionCollection, p as OpportunityCollection, r as LeadWorkflowValidationError, s as OpportunityConversion, t as LEAD_HUMAN_ACTIVITY_KINDS, u as SalesRepresentative, v as Opportunity, w as SALES_ACTIVITY_KINDS, x as LEAD_STATUSES, y as DEFAULT_PIPELINE_KEY } from "./chunks/crm-B-irXbbr.js";
5
5
  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-CrFDsdq-.js";
6
6
  export { ADJUSTMENT_SETTLEABLE_COMMISSION_STATUSES, AGREEMENT_EXECUTION_STATUSES, ATTRIBUTION_CONFLICT_BEHAVIORS, ATTRIBUTION_CREDIT_MODES, ATTRIBUTION_EXCEPTION_STATUSES, ATTRIBUTION_POLICY_STATUSES, ATTRIBUTION_RESOLUTION_MODES, AgreementExecution, AgreementExecutionCollection, AgreementExecutionEvent, AgreementExecutionEventCollection, AgreementExecutionService, AttributionException, AttributionExceptionCollection, AttributionPolicy, AttributionPolicyCollection, AttributionService, COMMISSION_ADJUSTMENT_KINDS, COMMISSION_BASES, COMMISSION_PAYOUT_STATUSES, COMMISSION_PLAN_STATUSES, COMMISSION_STATUSES, Commission, CommissionAdjustment, CommissionAdjustmentCollection, CommissionAdjustmentOperation, CommissionAdjustmentOperationCollection, CommissionAdjustmentReplayConflictError, CommissionAdjustmentService, CommissionAdjustmentValidationError, CommissionBalanceService, CommissionCalculationService, CommissionCollection, CommissionPayout, CommissionPayoutCollection, CommissionPayoutService, CommissionPlan, CommissionPlanCollection, CommissionSettlementService, DEFAULT_PIPELINE_KEY, DEFAULT_PIPELINE_STAGES, DEFAULT_REFERRAL_CLICK_EVIDENCE_MAX_BYTES, EARNER_SOURCE_ATTRIBUTION_STATUSES, EARNER_STATUSES, EARNING_EVENT_KINDS, Earner, EarnerAttributionService, EarnerCollection, EarnerSourceAttribution, EarnerSourceAttributionCollection, EarningEvent, EarningEventCollection, ExecutedAgreement, ExecutedAgreementCollection, LEAD_HUMAN_ACTIVITY_KINDS, LEAD_STATUSES, Lead, LeadCollection, LeadWorkflowService, LeadWorkflowValidationError, MAX_CODE_GENERATION_ATTEMPTS, MAX_LEAD_WORKFLOW_TEXT_LENGTH, MAX_REFERRAL_CLICK_IDEMPOTENCY_KEY_BYTES, OPPORTUNITY_STATUSES, Opportunity, OpportunityCollection, OpportunityConversion, OpportunityConversionCollection, PAYOUT_METHODS, PIPELINE_STATUSES, PipelineDefinition, PipelineDefinitionCollection, PipelineStage, PipelineStageCollection, 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, SALES_ACTIVITY_KINDS, SALES_ACTIVITY_SUBJECT_KINDS, SALES_REPRESENTATIVE_STATUSES, SalesActivity, SalesActivityCollection, SalesRepresentative, SalesRepresentativeCollection, amountToCents, assertHttpTargetUrl, calculateCommissionAmountCents, centsToAmount, coerceAgreementDate, generateReferralCode, projectLeadWorkQueue, roundCents, sanitizeSignerEvidence, sanitizeSignerIntent, validateAttributionPolicyTerms, validateCommissionPlanComponents };
@@ -2,7 +2,7 @@
2
2
  "version": "1.0.0",
3
3
  "timestamp": 0,
4
4
  "packageName": "@happyvertical/smrt-sales",
5
- "packageVersion": "0.55.0",
5
+ "packageVersion": "0.55.2",
6
6
  "objects": {
7
7
  "@happyvertical/smrt-sales:AgreementExecutionCollection": {
8
8
  "name": "agreementexecutioncollection",
@@ -1332,6 +1332,7 @@
1332
1332
  "extends": "SmrtObject",
1333
1333
  "exportName": "AgreementExecution",
1334
1334
  "collectionExportName": "AgreementExecutionCollection",
1335
+ "displayLabelField": "title",
1335
1336
  "validationRules": [
1336
1337
  {
1337
1338
  "field": "provider",
@@ -6084,6 +6085,7 @@
6084
6085
  "extends": "SmrtObject",
6085
6086
  "exportName": "CommissionPlan",
6086
6087
  "collectionExportName": "CommissionPlanCollection",
6088
+ "displayLabelField": "name",
6087
6089
  "validationRules": [
6088
6090
  {
6089
6091
  "field": "planKey",
@@ -8585,6 +8587,7 @@
8585
8587
  "extends": "SmrtObject",
8586
8588
  "exportName": "Lead",
8587
8589
  "collectionExportName": "LeadCollection",
8590
+ "displayLabelField": "name",
8588
8591
  "validationRules": [
8589
8592
  {
8590
8593
  "field": "name",
@@ -8963,6 +8966,7 @@
8963
8966
  "extends": "SmrtObject",
8964
8967
  "exportName": "Opportunity",
8965
8968
  "collectionExportName": "OpportunityCollection",
8969
+ "displayLabelField": "name",
8966
8970
  "validationRules": [
8967
8971
  {
8968
8972
  "field": "name",
@@ -9524,6 +9528,7 @@
9524
9528
  "extends": "SmrtObject",
9525
9529
  "exportName": "PipelineDefinition",
9526
9530
  "collectionExportName": "PipelineDefinitionCollection",
9531
+ "displayLabelField": "name",
9527
9532
  "validationRules": [
9528
9533
  {
9529
9534
  "field": "key",
@@ -9758,6 +9763,7 @@
9758
9763
  "extends": "SmrtObject",
9759
9764
  "exportName": "PipelineStage",
9760
9765
  "collectionExportName": "PipelineStageCollection",
9766
+ "displayLabelField": "name",
9761
9767
  "validationRules": [
9762
9768
  {
9763
9769
  "field": "pipelineId",
@@ -10255,6 +10261,7 @@
10255
10261
  "extends": "SmrtObject",
10256
10262
  "exportName": "SalesRepresentative",
10257
10263
  "collectionExportName": "SalesRepresentativeCollection",
10264
+ "displayLabelField": "title",
10258
10265
  "schema": {
10259
10266
  "tableName": "sales_representatives",
10260
10267
  "ddl": "CREATE TABLE IF NOT EXISTS \"sales_representatives\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"profile_id\" UUID,\n \"earner_id\" UUID,\n \"status\" TEXT DEFAULT 'active',\n \"title\" TEXT DEFAULT '',\n \"metadata\" TEXT DEFAULT '{}'\n);",
@@ -14476,6 +14483,7 @@
14476
14483
  "extends": "SmrtObject",
14477
14484
  "exportName": "ReferralLink",
14478
14485
  "collectionExportName": "ReferralLinkCollection",
14486
+ "displayLabelField": "label",
14479
14487
  "validationRules": [
14480
14488
  {
14481
14489
  "field": "referrerId",
@@ -14749,6 +14757,7 @@
14749
14757
  "extends": "SmrtObject",
14750
14758
  "exportName": "ReferralProgram",
14751
14759
  "collectionExportName": "ReferralProgramCollection",
14760
+ "displayLabelField": "name",
14752
14761
  "validationRules": [
14753
14762
  {
14754
14763
  "field": "key",
@@ -15317,6 +15326,7 @@
15317
15326
  "extends": "SmrtObject",
15318
15327
  "exportName": "ReferralTouch",
15319
15328
  "collectionExportName": "ReferralTouchCollection",
15329
+ "displayLabelField": "code",
15320
15330
  "validationRules": [
15321
15331
  {
15322
15332
  "field": "referrerId",
package/dist/referrals.js CHANGED
@@ -1,3 +1,3 @@
1
- import "./chunks/__smrt-register__-B51ohBYo.js";
1
+ import "./chunks/__smrt-register__-C3xJS35z.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-CrFDsdq-.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,16 +3,16 @@
3
3
  "sensitiveFieldsExcluded": true,
4
4
  "generatedAt": "1970-01-01T00:00:00.000Z",
5
5
  "packageName": "@happyvertical/smrt-sales",
6
- "packageVersion": "0.55.0",
6
+ "packageVersion": "0.55.2",
7
7
  "sourceManifestPath": "dist/manifest.json",
8
8
  "agentDocPath": "AGENTS.md",
9
9
  "sourceHashes": {
10
- "manifest": "94025c569abddc558b0f8a183039e6f444a799d4a6d81a83d2604199414bb4d1",
11
- "packageJson": "96f4e8db0aaf6150f41cfb1697df3c40590e6634e58a6650adde4df4188c7e55",
12
- "agents": "5f8df148793d29cea2d9fba8122b347028ea691302956f3885a8a086138c82f1",
10
+ "manifest": "4c6fc2c09e7b3cb485f4fcf75dc9759f341f834bbc5cef28c08eda7336eecb18",
11
+ "packageJson": "280e203758d634fb1a92d2a944be18476fb0d5f82214e950f80ab103dddea274",
12
+ "agents": "3100099d7cef116237e4deb4f83e32d836f3cc26e0f68a7dd55f14de942eda11",
13
13
  "moduleDoc:agents/agreements.md": "eb6ff147a0f60ee627d3337e8e9394d06fda955b4a4fff228537a9bd2803f886",
14
14
  "moduleDoc:agents/commissions.md": "e047024aafe5edcf072c1a6b7ea253c24cb15f2fa1beb2edd13651e735921f73",
15
- "moduleDoc:agents/crm.md": "b5b8d092a29c23c838adb74855123f6d1f2589d919708e418fb753817dd2dd13",
15
+ "moduleDoc:agents/crm.md": "b2c01c33e6ac559ba32073a089760d885095969d2ad749c30428c76e6aa2cc71",
16
16
  "moduleDoc:agents/referrals.md": "e64b64aad4b3feea08f172a18e3992539d761b5f05ac4e5107338a700c0cc4ce",
17
17
  "moduleDoc:agents/svelte.md": "819f690b91cf93980f6f79e89da8d9629ca6e5c565494e3fd2ca3be7587ad6de"
18
18
  },
@@ -474,6 +474,7 @@
474
474
  {
475
475
  "name": "AgreementExecution",
476
476
  "qualifiedName": "@happyvertical/smrt-sales:AgreementExecution",
477
+ "displayLabelField": "title",
477
478
  "collection": "agreementexecutions",
478
479
  "tableName": "agreement_executions",
479
480
  "packageName": "@happyvertical/smrt-sales",
@@ -3596,6 +3597,7 @@
3596
3597
  {
3597
3598
  "name": "CommissionPlan",
3598
3599
  "qualifiedName": "@happyvertical/smrt-sales:CommissionPlan",
3600
+ "displayLabelField": "name",
3599
3601
  "collection": "commissionplans",
3600
3602
  "tableName": "commission_plans",
3601
3603
  "packageName": "@happyvertical/smrt-sales",
@@ -5391,6 +5393,7 @@
5391
5393
  {
5392
5394
  "name": "Lead",
5393
5395
  "qualifiedName": "@happyvertical/smrt-sales:Lead",
5396
+ "displayLabelField": "name",
5394
5397
  "collection": "leads",
5395
5398
  "tableName": "leads",
5396
5399
  "packageName": "@happyvertical/smrt-sales",
@@ -5779,6 +5782,7 @@
5779
5782
  {
5780
5783
  "name": "Opportunity",
5781
5784
  "qualifiedName": "@happyvertical/smrt-sales:Opportunity",
5785
+ "displayLabelField": "name",
5782
5786
  "collection": "opportunities",
5783
5787
  "tableName": "opportunities",
5784
5788
  "packageName": "@happyvertical/smrt-sales",
@@ -6293,6 +6297,7 @@
6293
6297
  {
6294
6298
  "name": "PipelineDefinition",
6295
6299
  "qualifiedName": "@happyvertical/smrt-sales:PipelineDefinition",
6300
+ "displayLabelField": "name",
6296
6301
  "collection": "pipelinedefinitions",
6297
6302
  "tableName": "pipeline_definitions",
6298
6303
  "packageName": "@happyvertical/smrt-sales",
@@ -6498,6 +6503,7 @@
6498
6503
  {
6499
6504
  "name": "PipelineStage",
6500
6505
  "qualifiedName": "@happyvertical/smrt-sales:PipelineStage",
6506
+ "displayLabelField": "name",
6501
6507
  "collection": "pipelinestages",
6502
6508
  "tableName": "pipeline_stages",
6503
6509
  "packageName": "@happyvertical/smrt-sales",
@@ -6876,6 +6882,7 @@
6876
6882
  {
6877
6883
  "name": "SalesRepresentative",
6878
6884
  "qualifiedName": "@happyvertical/smrt-sales:SalesRepresentative",
6885
+ "displayLabelField": "title",
6879
6886
  "collection": "salesrepresentatives",
6880
6887
  "tableName": "sales_representatives",
6881
6888
  "packageName": "@happyvertical/smrt-sales",
@@ -9857,6 +9864,7 @@
9857
9864
  {
9858
9865
  "name": "ReferralLink",
9859
9866
  "qualifiedName": "@happyvertical/smrt-sales:ReferralLink",
9867
+ "displayLabelField": "label",
9860
9868
  "collection": "referrallinks",
9861
9869
  "tableName": "referral_links",
9862
9870
  "packageName": "@happyvertical/smrt-sales",
@@ -10117,6 +10125,7 @@
10117
10125
  {
10118
10126
  "name": "ReferralProgram",
10119
10127
  "qualifiedName": "@happyvertical/smrt-sales:ReferralProgram",
10128
+ "displayLabelField": "name",
10120
10129
  "collection": "referralprograms",
10121
10130
  "tableName": "referral_programs",
10122
10131
  "packageName": "@happyvertical/smrt-sales",
@@ -10540,6 +10549,7 @@
10540
10549
  {
10541
10550
  "name": "ReferralTouch",
10542
10551
  "qualifiedName": "@happyvertical/smrt-sales:ReferralTouch",
10552
+ "displayLabelField": "code",
10543
10553
  "collection": "referraltouches",
10544
10554
  "tableName": "referral_touches",
10545
10555
  "packageName": "@happyvertical/smrt-sales",
@@ -14355,7 +14365,7 @@
14355
14365
  "polymorphicAssociations": 0,
14356
14366
  "uuidColumns": 216
14357
14367
  },
14358
- "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 validation includes interaction contracts**: intake and inbox components have runtime component tests; `typecheck` also runs `svelte-check` via `scripts/svelte-check-a11y.mjs`. Ship raw `.svelte` via `svelte-package`.\n- **Lead workflows stay generic**: call `LeadWorkflowService` for tenant-safe intake, audited follow-up, qualification, and opportunity closure with optional conversion links. The service delegates CRM lifecycles to their owning collections; hosts supply authorization and create downstream records. `LeadCreateForm`, `LeadList`, and `LeadDetail` are props/callback only. See [agents/crm.md](agents/crm.md) for dedupe, retry, and inbox contracts.\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",
14368
+ "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 validation includes interaction contracts**: intake and inbox components have runtime component tests; `typecheck` also runs `svelte-check` via `scripts/svelte-check-a11y.mjs`. Ship raw `.svelte` via `svelte-package`.\n- **Lead workflows stay generic**: call `LeadWorkflowService` for tenant-safe intake, audited follow-up, qualification, nonterminal Opportunity stage movement, and terminal closure with optional conversion links. Optional intake `profileId` is stored and fingerprinted but remains host-authorized. The service delegates CRM lifecycles to their owning collections; hosts supply authorization and create downstream records. `LeadCreateForm`, `LeadList`, and `LeadDetail` are props/callback only. See [agents/crm.md](agents/crm.md) for dedupe, retry, and inbox contracts.\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",
14359
14369
  "moduleDocs": [
14360
14370
  {
14361
14371
  "path": "agents/agreements.md",
@@ -14370,7 +14380,7 @@
14370
14380
  {
14371
14381
  "path": "agents/crm.md",
14372
14382
  "module": "crm",
14373
- "content": "# smrt-sales/crm\n\nPer-module semantics for `@happyvertical/smrt-sales/crm`. Package orientation, the\ncross-module invariants (currency, tenancy, cross-package refs, roles vs.\nmoney), and the Gotchas that apply before editing anything live in\n[../AGENTS.md](../AGENTS.md) — read that first.\n\n- **SalesRepresentative**: role model (`profileId`, `earnerId`, `status`).\n- **Lead**: identified prospect with owner assignment, generic acquisition source (`sourceKind`/`sourceId`), preserved `acquisitionContext` JSON, and audited merge (`mergedIntoId`; merges preserve activity + acquisition history on both sides).\n- **PipelineDefinition / PipelineStage**: configurable ordered stages with default `new → qualified → discovery → proposal → negotiation → closed_won | closed_lost` (seeded via `ensureDefaultPipeline()`); stages carry `probability` and `isWon`/`isLost` terminal flags.\n- **Opportunity**: qualified engagement — owner, pipeline + stage, `expectedValueCents`, `probability`, `expectedCloseAt`, outcome. Stage movement validated against the pipeline; terminal stages set `won|lost` status.\n- **SalesActivity**: activity/next-action trail for Leads and Opportunities (`subjectKind`/`subjectId`), also the audit trail for assignment, qualification, merges, and stage movement.\n- **LeadWorkflowService**: the required tenant-safe Lead mutation seam. It transactionally locks the affected Lead/Opportunity (and completion task on PostgreSQL), accepts only active same-tenant representatives, writes actor-attributed audits alongside mutations, and returns merge-aware timeline/work-state reads. It owns validated `createLead()` intake, `new | disqualified → working`, `new | working → disqualified`, human follow-up (`note | call | email | meeting`), task scheduling/completion, delegated qualification, and terminal Opportunity closure/conversion. Merging remains a collection lifecycle.\n- **OpportunityConversion**: idempotent conversion links (`targetKind`/`targetId` — client, project, contract, subscription, …) with a composite natural key. CRM never creates downstream records itself and never mutates referral or commission state.\n\nWorkflow calls require ambient tenant context. Mutations require an actor profile\nid except `createLead()`, whose actor is optional for automated intake. Fail\nclosed for foreign/missing Lead, Opportunity, pipeline, representative, and task\nids without revealing their existence. Human metadata is plain JSON-object data;\nframework audit metadata is generated separately. Keep queue projection pure\n(`now`/optional timezone are injected) and do not add assignment, reminder, SLA,\nauthorization, or conversion policy.\n\n`createLead()` requires a name and at least one of email/phone, normalizes email,\nand supports `none | email | email_or_org` tenant-local dedupe. Active duplicates\nreturn the existing Lead and append one `inbound` activity per novel normalized\nintent; terminal matches return `{ created: false, duplicateOf }` without mutation\nso the caller must explicitly retry with `dedupe: 'none'` to create another Lead.\nCaller idempotency keys are persisted through deterministic immutable activity\nids, including when intake resolves to an existing active Lead; reusing a key\nwith changed intent is rejected. PostgreSQL uses transaction advisory/row locks,\nwhile single-connection adapters serialize the entire transaction.\n\n`qualifyLead()` delegates to `LeadCollection.qualify()` on the same transaction\nexecutor and returns whether the Opportunity was newly created. `closeOpportunity()`\nresolves the configured won/lost terminal stage, delegates stage movement, and\noptionally records a won conversion in the same transaction. Exact retries add\nno stage activity or conversion. `getLeadWorkState()` includes the canonical\nlinked Opportunity when present. Transaction-bound result models are reloaded\non the service database after commit before being returned.\n\n`LeadCollection.listInbox({ status?, ownerRepId?, unassigned?, overdue?,\nsearch?, sort?, limit, offset, now? })` requires ambient tenancy and returns\n`{ leads, items, total, statusCounts }`. `leads` are hydrated Lead rows; aligned\n`items` add the hydrated owner and earliest open Lead task as `nextAction`\nwithout per-row queries. Search trims and performs case-insensitive literal\nsubstring matching across name, contact name, email, phone, and organization.\nSort values are `created | next_action | name`, all with stable id tie-breaks;\nmissing next actions sort last. `limit` is required from 1–100 and `offset` is\nrequired and nonnegative.\n\n`total` applies every selected filter. `statusCounts` contains `all`, every Lead\nstatus, `unassigned`, and `overdue`; counts retain owner/search scope but ignore\nthe selected status/unassigned/overdue tab. Overdue means the earliest open task\nis due strictly before injected `now` (default current time).\n"
14383
+ "content": "# smrt-sales/crm\n\nPer-module semantics for `@happyvertical/smrt-sales/crm`. Package orientation, the\ncross-module invariants (currency, tenancy, cross-package refs, roles vs.\nmoney), and the Gotchas that apply before editing anything live in\n[../AGENTS.md](../AGENTS.md) — read that first.\n\n- **SalesRepresentative**: role model (`profileId`, `earnerId`, `status`).\n- **Lead**: identified prospect with owner assignment, generic acquisition source (`sourceKind`/`sourceId`), preserved `acquisitionContext` JSON, and audited merge (`mergedIntoId`; merges preserve activity + acquisition history on both sides).\n- **PipelineDefinition / PipelineStage**: configurable ordered stages with default `new → qualified → discovery → proposal → negotiation → closed_won | closed_lost` (seeded via `ensureDefaultPipeline()`); stages carry `probability` and `isWon`/`isLost` terminal flags.\n- **Opportunity**: qualified engagement — owner, pipeline + stage, `expectedValueCents`, `probability`, `expectedCloseAt`, outcome. Stage movement validated against the pipeline; terminal stages set `won|lost` status.\n- **SalesActivity**: activity/next-action trail for Leads and Opportunities (`subjectKind`/`subjectId`), also the audit trail for assignment, qualification, merges, and stage movement.\n- **LeadWorkflowService**: the required tenant-safe Lead mutation seam. It transactionally locks the affected Lead/Opportunity (and completion task on PostgreSQL), accepts only active same-tenant representatives, writes actor-attributed audits alongside mutations, and returns merge-aware timeline/work-state reads. It owns validated `createLead()` intake, `new | disqualified → working`, `new | working → disqualified`, human follow-up (`note | call | email | meeting`), task scheduling/completion, delegated qualification, nonterminal Opportunity stage movement, and terminal Opportunity closure/conversion. Merging remains a collection lifecycle.\n- **OpportunityConversion**: idempotent conversion links (`targetKind`/`targetId` — client, project, contract, subscription, …) with a composite natural key. CRM never creates downstream records itself and never mutates referral or commission state.\n\nWorkflow calls require ambient tenant context. Mutations require an actor profile\nid except `createLead()`, whose actor is optional for automated intake. Fail\nclosed for foreign/missing Lead, Opportunity, pipeline, representative, and task\nids without revealing their existence. Human metadata is plain JSON-object data;\nframework audit metadata is generated separately. Keep queue projection pure\n(`now`/optional timezone are injected) and do not add assignment, reminder, SLA,\nauthorization, or conversion policy.\n\n`createLead()` requires a name and at least one of email/phone, normalizes email,\nand supports `none | email | email_or_org` tenant-local dedupe. Active duplicates\nreturn the existing Lead and append one `inbound` activity per novel normalized\nintent; terminal matches return `{ created: false, duplicateOf }` without mutation\nso the caller must explicitly retry with `dedupe: 'none'` to create another Lead.\nCaller idempotency keys are persisted through deterministic immutable activity\nids, including when intake resolves to an existing active Lead; reusing a key\nwith changed intent is rejected. PostgreSQL uses transaction advisory/row locks,\nwhile single-connection adapters serialize the entire transaction.\nThe optional `profileId` is a host-authorized cross-package identity link and is\npart of that immutable retry intent; Sales stores it but does not authorize or\nload the referenced Profile.\n\n`qualifyLead()` delegates to `LeadCollection.qualify()` on the same transaction\nexecutor and returns whether the Opportunity was newly created.\n`moveOpportunityToStage()` locks an open Opportunity and atomically moves it to\na nonterminal stage in the same tenant and pipeline. An exact stage/probability\nretry is a no-op; a conflicting same-stage probability is refused. Terminal\nstages remain exclusive to `closeOpportunity()`, which\nresolves the configured won/lost terminal stage, delegates stage movement, and\noptionally records a won conversion in the same transaction. Exact retries add\nno stage activity or conversion. `getLeadWorkState()` includes the canonical\nlinked Opportunity when present. Transaction-bound result models are reloaded\non the service database after commit before being returned.\n\n`LeadCollection.listInbox({ status?, ownerRepId?, unassigned?, overdue?,\nsearch?, sort?, limit, offset, now? })` requires ambient tenancy and returns\n`{ leads, items, total, statusCounts }`. `leads` are hydrated Lead rows; aligned\n`items` add the hydrated owner and earliest open Lead task as `nextAction`\nwithout per-row queries. Search trims and performs case-insensitive literal\nsubstring matching across name, contact name, email, phone, and organization.\nSort values are `created | next_action | name`, all with stable id tie-breaks;\nmissing next actions sort last. `limit` is required from 1–100 and `offset` is\nrequired and nonnegative.\n\n`total` applies every selected filter. `statusCounts` contains `all`, every Lead\nstatus, `unassigned`, and `overdue`; counts retain owner/search scope but ignore\nthe selected status/unassigned/overdue tab. Overdue means the earliest open task\nis due strictly before injected `now` (default current time).\n"
14374
14384
  },
14375
14385
  {
14376
14386
  "path": "agents/referrals.md",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happyvertical/smrt-sales",
3
- "version": "0.55.0",
3
+ "version": "0.55.2",
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",
@@ -42,18 +42,18 @@
42
42
  "./manifest.json": "./dist/manifest.json"
43
43
  },
44
44
  "dependencies": {
45
- "@happyvertical/signatures": "^0.102.1",
46
- "@happyvertical/smrt-assets": "0.55.0",
47
- "@happyvertical/smrt-core": "0.55.0",
48
- "@happyvertical/smrt-tenancy": "0.55.0",
49
- "@happyvertical/smrt-ui": "0.55.0",
50
- "@happyvertical/sql": "^0.102.1"
45
+ "@happyvertical/signatures": "^0.102.2",
46
+ "@happyvertical/smrt-assets": "0.55.2",
47
+ "@happyvertical/smrt-core": "0.55.2",
48
+ "@happyvertical/smrt-tenancy": "0.55.2",
49
+ "@happyvertical/smrt-ui": "0.55.2",
50
+ "@happyvertical/sql": "^0.102.2"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "svelte": "^5.57.0"
54
54
  },
55
55
  "devDependencies": {
56
- "@happyvertical/smrt-vitest": "0.55.0",
56
+ "@happyvertical/smrt-vitest": "0.55.2",
57
57
  "@sveltejs/package": "^2.5.8",
58
58
  "@sveltejs/vite-plugin-svelte": "^7.3.0",
59
59
  "@types/node": "24.13.6",