@happyvertical/smrt-sales 0.51.32 → 0.51.34
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/agreements/collections/AgreementExecutionCollection.d.ts +1 -1
- package/dist/agreements/collections/AgreementExecutionEventCollection.d.ts +1 -1
- package/dist/agreements/collections/ExecutedAgreementCollection.d.ts +1 -1
- package/dist/agreements/models/AgreementExecution.d.ts +2 -1
- package/dist/agreements/models/AgreementExecutionEvent.d.ts +2 -1
- package/dist/agreements/models/ExecutedAgreement.d.ts +2 -1
- package/dist/agreements/services/AgreementExecutionService.d.ts +7 -6
- package/dist/agreements/types.d.ts +3 -2
- package/dist/agreements.d.ts +7 -0
- package/dist/agreements.js +1 -1
- package/dist/chunks/{__smrt-register__-D4oQpwQY.js → __smrt-register__-CJkQS7rB.js} +2 -2
- package/dist/chunks/{__smrt-register__-D4oQpwQY.js.map → __smrt-register__-CJkQS7rB.js.map} +1 -1
- package/dist/commissions/collections/CommissionAdjustmentCollection.d.ts +13 -0
- package/dist/commissions/collections/CommissionAdjustmentOperationCollection.d.ts +1 -0
- package/dist/commissions/collections/CommissionCollection.d.ts +12 -1
- package/dist/commissions/collections/CommissionPayoutCollection.d.ts +6 -1
- package/dist/commissions/collections/CommissionPlanCollection.d.ts +9 -1
- package/dist/commissions/collections/EarnerCollection.d.ts +5 -1
- package/dist/commissions/collections/EarnerSourceAttributionCollection.d.ts +10 -0
- package/dist/commissions/collections/EarningEventCollection.d.ts +5 -1
- package/dist/commissions/models/Commission.d.ts +27 -1
- package/dist/commissions/models/CommissionAdjustment.d.ts +19 -1
- package/dist/commissions/models/CommissionAdjustmentOperation.d.ts +2 -1
- package/dist/commissions/models/CommissionPayout.d.ts +35 -1
- package/dist/commissions/models/CommissionPlan.d.ts +19 -1
- package/dist/commissions/models/Earner.d.ts +13 -1
- package/dist/commissions/models/EarnerSourceAttribution.d.ts +60 -1
- package/dist/commissions/models/EarningEvent.d.ts +28 -1
- package/dist/commissions/services/CommissionAdjustmentService.d.ts +4 -3
- package/dist/commissions/services/CommissionBalanceService.d.ts +16 -2
- package/dist/commissions/services/CommissionCalculationService.d.ts +16 -4
- package/dist/commissions/services/CommissionPayoutService.d.ts +28 -3
- package/dist/commissions/services/CommissionSettlementService.d.ts +13 -2
- package/dist/commissions/services/EarnerAttributionService.d.ts +22 -4
- package/dist/commissions/types.d.ts +16 -1
- package/dist/commissions.d.ts +9 -0
- package/dist/commissions.js +1 -1
- package/dist/crm/collections/LeadCollection.d.ts +8 -3
- package/dist/crm/collections/OpportunityCollection.d.ts +6 -1
- package/dist/crm/collections/OpportunityConversionCollection.d.ts +6 -1
- package/dist/crm/collections/PipelineDefinitionCollection.d.ts +7 -2
- package/dist/crm/collections/PipelineStageCollection.d.ts +4 -0
- package/dist/crm/collections/SalesActivityCollection.d.ts +5 -1
- package/dist/crm/collections/SalesRepresentativeCollection.d.ts +4 -0
- package/dist/crm/models/Lead.d.ts +5 -1
- package/dist/crm/models/Opportunity.d.ts +5 -1
- package/dist/crm/models/OpportunityConversion.d.ts +5 -1
- package/dist/crm/models/PipelineDefinition.d.ts +5 -1
- package/dist/crm/models/PipelineStage.d.ts +5 -1
- package/dist/crm/models/SalesActivity.d.ts +5 -1
- package/dist/crm/models/SalesRepresentative.d.ts +5 -1
- package/dist/crm/services/LeadWorkflowService.d.ts +15 -5
- package/dist/crm/types.d.ts +16 -5
- package/dist/crm.d.ts +8 -0
- package/dist/crm.js +1 -1
- package/dist/index.d.ts +26 -0
- package/dist/index.js +1 -1
- package/dist/manifest.json +1 -1
- package/dist/referrals/collections/AttributionExceptionCollection.d.ts +5 -0
- package/dist/referrals/collections/AttributionPolicyCollection.d.ts +11 -1
- package/dist/referrals/collections/ReferralAgreementCollection.d.ts +11 -1
- package/dist/referrals/collections/ReferralClickOperationCollection.d.ts +1 -0
- package/dist/referrals/collections/ReferralCollection.d.ts +4 -0
- package/dist/referrals/collections/ReferralLinkCollection.d.ts +9 -2
- package/dist/referrals/collections/ReferralProgramCollection.d.ts +5 -1
- package/dist/referrals/collections/ReferralTermSnapshotCollection.d.ts +8 -0
- package/dist/referrals/collections/ReferralTouchCollection.d.ts +7 -0
- package/dist/referrals/collections/ReferrerCollection.d.ts +5 -1
- package/dist/referrals/models/AttributionException.d.ts +20 -1
- package/dist/referrals/models/AttributionPolicy.d.ts +20 -1
- package/dist/referrals/models/Referral.d.ts +25 -1
- package/dist/referrals/models/ReferralAgreement.d.ts +25 -1
- package/dist/referrals/models/ReferralClickOperation.d.ts +2 -1
- package/dist/referrals/models/ReferralLink.d.ts +5 -1
- package/dist/referrals/models/ReferralProgram.d.ts +5 -1
- package/dist/referrals/models/ReferralTermSnapshot.d.ts +22 -2
- package/dist/referrals/models/ReferralTouch.d.ts +20 -1
- package/dist/referrals/models/Referrer.d.ts +5 -1
- package/dist/referrals/services/AttributionService.d.ts +12 -4
- package/dist/referrals/services/ReferralAgreementExecutionService.d.ts +7 -6
- package/dist/referrals/services/ReferralCommissionService.d.ts +15 -2
- package/dist/referrals/services/ReferralQualificationService.d.ts +18 -3
- package/dist/referrals/types.d.ts +18 -1
- package/dist/referrals.d.ts +9 -0
- package/dist/referrals.js +1 -1
- package/dist/smrt-knowledge.json +4 -4
- package/dist/test-fixtures.d.ts +6 -0
- package/dist/test-fixtures.d.ts.map +1 -0
- package/dist/test-setup.d.ts +2 -0
- package/dist/test-setup.d.ts.map +1 -0
- package/package.json +7 -7
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PipelineDefinitionCollection — collection manager for PipelineDefinition,
|
|
3
|
+
* including the idempotent default-pipeline seeder.
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
1
6
|
import { SmrtCollection } from '@happyvertical/smrt-core';
|
|
2
7
|
import { PipelineDefinition } from '../models/PipelineDefinition.js';
|
|
3
|
-
import { PipelineStage } from '../models/PipelineStage.js';
|
|
4
|
-
import { EnsureDefaultPipelineParams, EnsureDefaultPipelineResult } from '../types.js';
|
|
8
|
+
import type { PipelineStage } from '../models/PipelineStage.js';
|
|
9
|
+
import { type EnsureDefaultPipelineParams, type EnsureDefaultPipelineResult } from '../types.js';
|
|
5
10
|
export declare class PipelineDefinitionCollection extends SmrtCollection<PipelineDefinition> {
|
|
6
11
|
static readonly _itemClass: typeof PipelineDefinition;
|
|
7
12
|
private stageCollectionPromise;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PipelineStageCollection — collection manager for PipelineStage.
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
1
5
|
import { SmrtCollection } from '@happyvertical/smrt-core';
|
|
2
6
|
import { PipelineStage } from '../models/PipelineStage.js';
|
|
3
7
|
export declare class PipelineStageCollection extends SmrtCollection<PipelineStage> {
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SalesActivityCollection — collection manager for the SalesActivity trail.
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
1
5
|
import { SmrtCollection } from '@happyvertical/smrt-core';
|
|
2
6
|
import { SalesActivity } from '../models/SalesActivity.js';
|
|
3
|
-
import { SalesActivitySubjectKind } from '../types.js';
|
|
7
|
+
import type { SalesActivitySubjectKind } from '../types.js';
|
|
4
8
|
export declare class SalesActivityCollection extends SmrtCollection<SalesActivity> {
|
|
5
9
|
static readonly _itemClass: typeof SalesActivity;
|
|
6
10
|
/**
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SalesRepresentativeCollection — collection manager for SalesRepresentative.
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
1
5
|
import { SmrtCollection } from '@happyvertical/smrt-core';
|
|
2
6
|
import { SalesRepresentative } from '../models/SalesRepresentative.js';
|
|
3
7
|
export declare class SalesRepresentativeCollection extends SmrtCollection<SalesRepresentative> {
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lead — identified prospect with guarded lifecycle and audited merge support.
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
1
5
|
import { SmrtObject } from '@happyvertical/smrt-core';
|
|
2
|
-
import { LeadOptions, LeadStatus } from '../types.js';
|
|
6
|
+
import type { LeadOptions, LeadStatus } from '../types.js';
|
|
3
7
|
/**
|
|
4
8
|
* Lead is an identified prospect: a person/organization that showed intent
|
|
5
9
|
* but has not yet been qualified into an Opportunity.
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opportunity — a qualified engagement moving through a pipeline.
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
1
5
|
import { SmrtObject } from '@happyvertical/smrt-core';
|
|
2
|
-
import { OpportunityOptions, OpportunityStatus } from '../types.js';
|
|
6
|
+
import type { OpportunityOptions, OpportunityStatus } from '../types.js';
|
|
3
7
|
/**
|
|
4
8
|
* Opportunity is a qualified engagement: a deal with an expected value moving
|
|
5
9
|
* through the stages of a PipelineDefinition.
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpportunityConversion — idempotent link from a won deal to a downstream record.
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
1
5
|
import { SmrtObject } from '@happyvertical/smrt-core';
|
|
2
|
-
import { OpportunityConversionOptions } from '../types.js';
|
|
6
|
+
import type { OpportunityConversionOptions } from '../types.js';
|
|
3
7
|
/**
|
|
4
8
|
* OpportunityConversion records that a WON opportunity materialized into a
|
|
5
9
|
* downstream record — a client, project, contract, subscription, or any
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PipelineDefinition — a named, tenant-scoped sales pipeline.
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
1
5
|
import { SmrtObject } from '@happyvertical/smrt-core';
|
|
2
|
-
import { PipelineDefinitionOptions, PipelineStatus } from '../types.js';
|
|
6
|
+
import type { PipelineDefinitionOptions, PipelineStatus } from '../types.js';
|
|
3
7
|
/**
|
|
4
8
|
* PipelineDefinition names an ordered set of {@link PipelineStage | stages}
|
|
5
9
|
* that opportunities move through. Pipelines are configuration rows, not
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PipelineStage — one ordered step of a PipelineDefinition.
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
1
5
|
import { SmrtObject } from '@happyvertical/smrt-core';
|
|
2
|
-
import { PipelineStageOptions } from '../types.js';
|
|
6
|
+
import type { PipelineStageOptions } from '../types.js';
|
|
3
7
|
/**
|
|
4
8
|
* PipelineStage is a configurable step within a pipeline. Stages carry the
|
|
5
9
|
* default win `probability` an opportunity adopts on entry and the terminal
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SalesActivity — the activity, next-action, and audit trail for CRM subjects.
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
1
5
|
import { SmrtObject } from '@happyvertical/smrt-core';
|
|
2
|
-
import { SalesActivityOptions, SalesActivitySubjectKind } from '../types.js';
|
|
6
|
+
import type { SalesActivityOptions, SalesActivitySubjectKind } from '../types.js';
|
|
3
7
|
/**
|
|
4
8
|
* Permit one monotonic `completedAt` stamp on a hydrated task.
|
|
5
9
|
*
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SalesRepresentative — the sales-rep role model.
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
1
5
|
import { SmrtObject } from '@happyvertical/smrt-core';
|
|
2
|
-
import { SalesRepresentativeOptions, SalesRepresentativeStatus } from '../types.js';
|
|
6
|
+
import type { SalesRepresentativeOptions, SalesRepresentativeStatus } from '../types.js';
|
|
3
7
|
/**
|
|
4
8
|
* SalesRepresentative is a ROLE model: it links an identity (smrt-profiles
|
|
5
9
|
* Profile) to sales ownership (Leads/Opportunities reference `ownerRepId`).
|
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Tenant-safe, audited follow-up workflow for CRM Leads.
|
|
3
|
+
*
|
|
4
|
+
* The service is intentionally the narrow mutation seam for the generic
|
|
5
|
+
* pre-qualification loop. It does not create opportunities, conversions, or
|
|
6
|
+
* downstream records; those lifecycles remain owned by their existing CRM
|
|
7
|
+
* collections and by the consuming application respectively.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
import type { SmrtClassOptions } from '@happyvertical/smrt-core';
|
|
12
|
+
import type { Lead } from '../models/Lead.js';
|
|
13
|
+
import { type SalesActivity } from '../models/SalesActivity.js';
|
|
14
|
+
import type { SalesRepresentative } from '../models/SalesRepresentative.js';
|
|
15
|
+
import type { LeadStatus } from '../types.js';
|
|
6
16
|
/** Human follow-up kinds accepted by {@link LeadWorkflowService.recordActivity}. */
|
|
7
17
|
export declare const LEAD_HUMAN_ACTIVITY_KINDS: readonly ["note", "call", "email", "meeting"];
|
|
8
18
|
export type LeadHumanActivityKind = (typeof LEAD_HUMAN_ACTIVITY_KINDS)[number];
|
package/dist/crm/types.d.ts
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Shared types, status unions, and operation contracts for the CRM module.
|
|
3
|
+
*
|
|
4
|
+
* Statuses are string-literal unions derived from `as const` arrays so both
|
|
5
|
+
* the runtime list (for validation/UI pickers) and the compile-time union stay
|
|
6
|
+
* in lockstep. All monetary fields across the module are integer cents
|
|
7
|
+
* (`*Cents`, INTEGER columns); rates/probabilities are decimals in `0`–`1`
|
|
8
|
+
* (DECIMAL columns). See `packages/sales/AGENTS.md`.
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
import type { SmrtObjectOptions } from '@happyvertical/smrt-core';
|
|
13
|
+
import type { Lead } from './models/Lead.js';
|
|
14
|
+
import type { OpportunityConversion } from './models/OpportunityConversion.js';
|
|
15
|
+
import type { PipelineDefinition } from './models/PipelineDefinition.js';
|
|
16
|
+
import type { PipelineStage } from './models/PipelineStage.js';
|
|
6
17
|
/** Lifecycle statuses for a {@link SalesRepresentativeOptions | SalesRepresentative} role. */
|
|
7
18
|
export declare const SALES_REPRESENTATIVE_STATUSES: readonly ["active", "inactive", "suspended"];
|
|
8
19
|
export type SalesRepresentativeStatus = (typeof SALES_REPRESENTATIVE_STATUSES)[number];
|
package/dist/crm.d.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subpath entry: `@happyvertical/smrt-sales/crm`.
|
|
3
|
+
*
|
|
4
|
+
* Leads, Opportunities, configurable Pipelines, tenant-safe follow-up,
|
|
5
|
+
* sales activity, ownership, and idempotent conversion links — without
|
|
6
|
+
* referral or commission behavior in the CRM state machine.
|
|
7
|
+
*/
|
|
8
|
+
import './__smrt-register__.js';
|
|
1
9
|
export * from './crm/index.js';
|
|
2
10
|
//# sourceMappingURL=crm.d.ts.map
|
package/dist/crm.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./chunks/__smrt-register__-
|
|
1
|
+
import "./chunks/__smrt-register__-CJkQS7rB.js";
|
|
2
2
|
import { C as SalesActivity, D as Lead, E as Opportunity, S as SalesActivityCollection, T as PipelineStage, _ as SALES_ACTIVITY_KINDS, a as projectLeadWorkQueue, b as PipelineDefinition, c as OpportunityConversionCollection, d as PipelineDefinitionCollection, f as DEFAULT_PIPELINE_KEY, g as PIPELINE_STATUSES, h as OPPORTUNITY_STATUSES, i as MAX_LEAD_WORKFLOW_TEXT_LENGTH, l as OpportunityConversion, m as LEAD_STATUSES, n as LeadWorkflowService, o as SalesRepresentativeCollection, p as DEFAULT_PIPELINE_STAGES, r as LeadWorkflowValidationError, s as SalesRepresentative, t as LEAD_HUMAN_ACTIVITY_KINDS, u as LeadCollection, v as SALES_ACTIVITY_SUBJECT_KINDS, w as PipelineStageCollection, x as OpportunityCollection, y as SALES_REPRESENTATIVE_STATUSES } from "./chunks/crm-C2bD25yv.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.d.ts
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @happyvertical/smrt-sales
|
|
3
|
+
*
|
|
4
|
+
* Modular sales for the SMRT framework, shipped as one installable package
|
|
5
|
+
* with distinct modules:
|
|
6
|
+
*
|
|
7
|
+
* - `agreements` (`@happyvertical/smrt-sales/agreements`): provider-neutral
|
|
8
|
+
* e-signature lifecycle, verified events, and immutable executed evidence.
|
|
9
|
+
* - `crm` (`@happyvertical/smrt-sales/crm`): Leads, Opportunities,
|
|
10
|
+
* configurable Pipelines, tenant-safe Lead follow-up, sales activity,
|
|
11
|
+
* ownership, and idempotent conversion links.
|
|
12
|
+
* - `referrals` (`@happyvertical/smrt-sales/referrals`): Referrers, Referral
|
|
13
|
+
* Programs, links/codes, attribution evidence, versioned attribution
|
|
14
|
+
* policies, referral agreements, and qualification term snapshots.
|
|
15
|
+
* - `commissions` (`@happyvertical/smrt-sales/commissions`): neutral Earners,
|
|
16
|
+
* versioned Commission Plans, earning events, Commissions, append-only
|
|
17
|
+
* adjustments, payable balances, and CommissionPayout batches.
|
|
18
|
+
* - `svelte` (`@happyvertical/smrt-sales/svelte`): reusable dashboard and
|
|
19
|
+
* Referrer/operator portal components.
|
|
20
|
+
*
|
|
21
|
+
* The root export re-exports every module for convenience; the subpath
|
|
22
|
+
* exports keep consumers' bundles scoped to what they use.
|
|
23
|
+
*
|
|
24
|
+
* @packageDocumentation
|
|
25
|
+
*/
|
|
26
|
+
import './__smrt-register__.js';
|
|
1
27
|
export * from './agreements/index.js';
|
|
2
28
|
export * from './commissions/index.js';
|
|
3
29
|
export * from './crm/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./chunks/__smrt-register__-
|
|
1
|
+
import "./chunks/__smrt-register__-CJkQS7rB.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-CxHyIbZB.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-BlJpPXFC.js";
|
|
4
4
|
import { C as SalesActivity, D as Lead, E as Opportunity, S as SalesActivityCollection, T as PipelineStage, _ as SALES_ACTIVITY_KINDS, a as projectLeadWorkQueue, b as PipelineDefinition, c as OpportunityConversionCollection, d as PipelineDefinitionCollection, f as DEFAULT_PIPELINE_KEY, g as PIPELINE_STATUSES, h as OPPORTUNITY_STATUSES, i as MAX_LEAD_WORKFLOW_TEXT_LENGTH, l as OpportunityConversion, m as LEAD_STATUSES, n as LeadWorkflowService, o as SalesRepresentativeCollection, p as DEFAULT_PIPELINE_STAGES, r as LeadWorkflowValidationError, s as SalesRepresentative, t as LEAD_HUMAN_ACTIVITY_KINDS, u as LeadCollection, v as SALES_ACTIVITY_SUBJECT_KINDS, w as PipelineStageCollection, x as OpportunityCollection, y as SALES_REPRESENTATIVE_STATUSES } from "./chunks/crm-C2bD25yv.js";
|
package/dist/manifest.json
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AttributionExceptionCollection — collection manager for
|
|
3
|
+
* {@link AttributionException}.
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
1
6
|
import { SmrtCollection } from '@happyvertical/smrt-core';
|
|
2
7
|
import { AttributionException } from '../models/AttributionException.js';
|
|
3
8
|
export declare class AttributionExceptionCollection extends SmrtCollection<AttributionException> {
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AttributionPolicyCollection — collection manager for
|
|
3
|
+
* {@link AttributionPolicy}.
|
|
4
|
+
*
|
|
5
|
+
* Policies are versioned rows: amendments insert `(policyKey, maxVersion +
|
|
6
|
+
* 1)` drafts via {@link createAmendment}; existing versions are never
|
|
7
|
+
* rewritten (CommissionPlan pattern).
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
1
11
|
import { SmrtCollection } from '@happyvertical/smrt-core';
|
|
2
12
|
import { AttributionPolicy } from '../models/AttributionPolicy.js';
|
|
3
|
-
import { AttributionConflictBehavior, AttributionCreditMode, AttributionPolicyStatus } from '../types.js';
|
|
13
|
+
import type { AttributionConflictBehavior, AttributionCreditMode, AttributionPolicyStatus } from '../types.js';
|
|
4
14
|
/**
|
|
5
15
|
* Fields an amendment may change relative to the version it copies.
|
|
6
16
|
* `policyKey` is fixed (it identifies the policy), `version` is computed,
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ReferralAgreementCollection — collection manager for
|
|
3
|
+
* {@link ReferralAgreement}.
|
|
4
|
+
*
|
|
5
|
+
* Agreements are versioned rows: amendments insert
|
|
6
|
+
* `(referrerId, programId, maxVersion + 1)` drafts via
|
|
7
|
+
* {@link createAmendment}; existing versions are never rewritten.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
1
11
|
import { SmrtCollection } from '@happyvertical/smrt-core';
|
|
2
12
|
import { ReferralAgreement } from '../models/ReferralAgreement.js';
|
|
3
|
-
import { ReferralAgreementApprovalMode } from '../types.js';
|
|
13
|
+
import type { ReferralAgreementApprovalMode } from '../types.js';
|
|
4
14
|
/**
|
|
5
15
|
* Fields an amendment may change relative to the version it copies.
|
|
6
16
|
* `referrerId`/`programId` are fixed (they identify the agreement),
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ReferralCollection — collection manager for {@link Referral}.
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
1
5
|
import { SmrtCollection } from '@happyvertical/smrt-core';
|
|
2
6
|
import { Referral } from '../models/Referral.js';
|
|
3
7
|
export declare class ReferralCollection extends SmrtCollection<Referral> {
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ReferralLinkCollection — collection manager for {@link ReferralLink}:
|
|
3
|
+
* crypto-random code minting with collision retry, code lookup, and click
|
|
4
|
+
* recording (link counter + immutable ReferralTouch evidence).
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
1
8
|
import { SmrtCollection } from '@happyvertical/smrt-core';
|
|
2
|
-
import { DatabaseInterface } from '@happyvertical/sql';
|
|
9
|
+
import type { DatabaseInterface } from '@happyvertical/sql';
|
|
3
10
|
import { ReferralLink } from '../models/ReferralLink.js';
|
|
4
|
-
import { ReferralTouch } from '../models/ReferralTouch.js';
|
|
11
|
+
import type { ReferralTouch } from '../models/ReferralTouch.js';
|
|
5
12
|
/** Length of generated share codes. */
|
|
6
13
|
export declare const REFERRAL_CODE_LENGTH = 10;
|
|
7
14
|
/** Alphabet generated codes draw from (lowercase alphanumeric). */
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ReferralProgramCollection — collection manager for {@link ReferralProgram}.
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
1
5
|
import { SmrtCollection } from '@happyvertical/smrt-core';
|
|
2
6
|
import { ReferralProgram } from '../models/ReferralProgram.js';
|
|
3
|
-
import { ReferralProgramStatus } from '../types.js';
|
|
7
|
+
import type { ReferralProgramStatus } from '../types.js';
|
|
4
8
|
export declare class ReferralProgramCollection extends SmrtCollection<ReferralProgram> {
|
|
5
9
|
static readonly _itemClass: typeof ReferralProgram;
|
|
6
10
|
/**
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ReferralTermSnapshotCollection — collection manager for
|
|
3
|
+
* {@link ReferralTermSnapshot}.
|
|
4
|
+
*
|
|
5
|
+
* Snapshots are immutable history: this collection only creates and reads.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
1
9
|
import { SmrtCollection } from '@happyvertical/smrt-core';
|
|
2
10
|
import { ReferralTermSnapshot } from '../models/ReferralTermSnapshot.js';
|
|
3
11
|
export declare class ReferralTermSnapshotCollection extends SmrtCollection<ReferralTermSnapshot> {
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ReferralTouchCollection — collection manager for {@link ReferralTouch}.
|
|
3
|
+
*
|
|
4
|
+
* Touches are immutable evidence: this collection only creates and reads.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
1
8
|
import { SmrtCollection } from '@happyvertical/smrt-core';
|
|
2
9
|
import { ReferralTouch } from '../models/ReferralTouch.js';
|
|
3
10
|
/** Input for {@link ReferralTouchCollection.findByTargetWindow}. */
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ReferrerCollection — collection manager for {@link Referrer}.
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
1
5
|
import { SmrtCollection } from '@happyvertical/smrt-core';
|
|
2
6
|
import { Referrer } from '../models/Referrer.js';
|
|
3
|
-
import { ReferrerStatus } from '../types.js';
|
|
7
|
+
import type { ReferrerStatus } from '../types.js';
|
|
4
8
|
export declare class ReferrerCollection extends SmrtCollection<Referrer> {
|
|
5
9
|
static readonly _itemClass: typeof Referrer;
|
|
6
10
|
/**
|
|
@@ -1,5 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AttributionException — the conflict-review queue and override audit trail.
|
|
3
|
+
*
|
|
4
|
+
* When attribution cannot conclude automatically (exact-timestamp ties,
|
|
5
|
+
* competing manual assignments, or a policy whose `conflictBehavior` is
|
|
6
|
+
* `review`), `AttributionService.resolve()` creates an OPEN exception
|
|
7
|
+
* carrying the candidate touches and creates NO referral rows. A human (or
|
|
8
|
+
* policy re-run) resolves it via `AttributionService.resolveException()`,
|
|
9
|
+
* which requires a `resolutionReason`, creates the awarded referral(s), and
|
|
10
|
+
* stamps the resolution audit fields here. `AttributionService.override()`
|
|
11
|
+
* writes an already-RESOLVED exception row as the audit record of a
|
|
12
|
+
* re-attribution.
|
|
13
|
+
*
|
|
14
|
+
* The generated surface is read-only (`list`/`get`): exceptions are minted
|
|
15
|
+
* and resolved exclusively by the attribution service so the audit fields
|
|
16
|
+
* stay trustworthy.
|
|
17
|
+
*
|
|
18
|
+
* @packageDocumentation
|
|
19
|
+
*/
|
|
1
20
|
import { SmrtObject } from '@happyvertical/smrt-core';
|
|
2
|
-
import { AttributionExceptionCandidate, AttributionExceptionOptions, AttributionExceptionStatus } from '../types.js';
|
|
21
|
+
import type { AttributionExceptionCandidate, AttributionExceptionOptions, AttributionExceptionStatus } from '../types.js';
|
|
3
22
|
export declare class AttributionException extends SmrtObject {
|
|
4
23
|
/** Tenant ID for multi-tenant isolation (nullable → global rows). */
|
|
5
24
|
tenantId: string | null;
|
|
@@ -1,5 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AttributionPolicy — versioned attribution terms.
|
|
3
|
+
*
|
|
4
|
+
* A policy is identified by its `(policyKey, version)` natural key. Versions
|
|
5
|
+
* are ROWS, not edits: amending a policy inserts a `version + 1` draft (see
|
|
6
|
+
* `AttributionPolicyCollection.createAmendment`) and the prior version is
|
|
7
|
+
* never rewritten. Once a row has been saved non-draft, its policy-defining
|
|
8
|
+
* identity (window, credit mode, conflict behavior, eligibility flags and
|
|
9
|
+
* lists, key/version, effectiveFrom) is frozen — re-saving with any of them
|
|
10
|
+
* changed throws (same WeakMap-serialize pattern as commerce `LicenseSale`
|
|
11
|
+
* and this package's `CommissionPlan`). Status transitions remain allowed on
|
|
12
|
+
* frozen rows.
|
|
13
|
+
*
|
|
14
|
+
* Generated write surface is deliberately narrow: `create` only (drafts) —
|
|
15
|
+
* amendments are new rows, and status moves go through the guarded
|
|
16
|
+
* transition methods / legal save-time edges.
|
|
17
|
+
*
|
|
18
|
+
* @packageDocumentation
|
|
19
|
+
*/
|
|
1
20
|
import { SmrtObject } from '@happyvertical/smrt-core';
|
|
2
|
-
import { AttributionConflictBehavior, AttributionCreditMode, AttributionPolicyOptions, AttributionPolicyStatus } from '../types.js';
|
|
21
|
+
import { type AttributionConflictBehavior, type AttributionCreditMode, type AttributionPolicyOptions, type AttributionPolicyStatus } from '../types.js';
|
|
3
22
|
/**
|
|
4
23
|
* Validate a policy's terms. Throws a descriptive error on the first
|
|
5
24
|
* violation. Called by {@link AttributionPolicy.activate} and by activating
|
|
@@ -1,5 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Referral — the introduction record.
|
|
3
|
+
*
|
|
4
|
+
* A Referral says "this referrer introduced this target under this program"
|
|
5
|
+
* — the target is a GENERIC `(targetKind, targetId)` pair (lead,
|
|
6
|
+
* opportunity, client, project, subscription, …) so the referrals module
|
|
7
|
+
* never depends on CRM or any downstream domain.
|
|
8
|
+
*
|
|
9
|
+
* Lifecycle (save-time guarded against the AUTHORITATIVE prior persisted
|
|
10
|
+
* status — commerce pattern):
|
|
11
|
+
*
|
|
12
|
+
* - `pending → attributed | under_review | disqualified | expired`
|
|
13
|
+
* - `under_review → attributed | disqualified`
|
|
14
|
+
* - `attributed → qualified | disqualified | expired`
|
|
15
|
+
* - `qualified → disqualified` (rare clawback path)
|
|
16
|
+
* - `disqualified` / `expired` are terminal.
|
|
17
|
+
*
|
|
18
|
+
* Transition methods ({@link markAttributed} / {@link markUnderReview} /
|
|
19
|
+
* {@link markQualified} / {@link disqualify} / {@link markExpired}) mutate
|
|
20
|
+
* and stamp timestamps but DO NOT save — the caller saves (one explicit
|
|
21
|
+
* persistence point per mutation, matching the sibling modules).
|
|
22
|
+
*
|
|
23
|
+
* @packageDocumentation
|
|
24
|
+
*/
|
|
1
25
|
import { SmrtObject } from '@happyvertical/smrt-core';
|
|
2
|
-
import { ReferralOptions, ReferralStatus } from '../types.js';
|
|
26
|
+
import type { ReferralOptions, ReferralStatus } from '../types.js';
|
|
3
27
|
export declare class Referral extends SmrtObject {
|
|
4
28
|
/** Tenant ID for multi-tenant isolation (nullable → global referrals). */
|
|
5
29
|
tenantId: string | null;
|
|
@@ -1,5 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ReferralAgreement — versioned per-Referrer terms binding.
|
|
3
|
+
*
|
|
4
|
+
* An agreement binds one Referrer to one ReferralProgram under specific
|
|
5
|
+
* commission terms: which CommissionPlan key (optionally pinned to a
|
|
6
|
+
* version), the clearing window, and the approval mode. Natural key
|
|
7
|
+
* `(referrerId, programId, version)` — amendments insert `version + 1`
|
|
8
|
+
* drafts (see `ReferralAgreementCollection.createAmendment`); prior versions
|
|
9
|
+
* are never rewritten.
|
|
10
|
+
*
|
|
11
|
+
* Lifecycle: `draft → active | terminated`; `active → superseded |
|
|
12
|
+
* terminated`; `superseded` / `terminated` are terminal. Activation requires
|
|
13
|
+
* bound commercial terms and an immutable {@link executedAgreementId}.
|
|
14
|
+
*
|
|
15
|
+
* Immutability: once a row has been saved non-draft, its TERMS
|
|
16
|
+
* (`referrerId`, `programId`, `version`, `commissionPlanKey`,
|
|
17
|
+
* `commissionPlanVersion`, `clearingDays`, `approvalMode`, `effectiveFrom`)
|
|
18
|
+
* are frozen via the WeakMap-serialize guard (commerce `LicenseSale`
|
|
19
|
+
* pattern). Status transitions stay allowed and `effectiveTo` stays mutable
|
|
20
|
+
* so an operator can end-date an agreement. Signed artifacts and signer/audit
|
|
21
|
+
* evidence live only on immutable `ExecutedAgreement` records.
|
|
22
|
+
*
|
|
23
|
+
* @packageDocumentation
|
|
24
|
+
*/
|
|
1
25
|
import { SmrtObject } from '@happyvertical/smrt-core';
|
|
2
|
-
import { ReferralAgreementApprovalMode, ReferralAgreementOptions, ReferralAgreementStatus } from '../types.js';
|
|
26
|
+
import type { ReferralAgreementApprovalMode, ReferralAgreementOptions, ReferralAgreementStatus } from '../types.js';
|
|
3
27
|
export declare class ReferralAgreement extends SmrtObject {
|
|
4
28
|
/** Tenant ID for multi-tenant isolation (nullable → global agreements). */
|
|
5
29
|
tenantId: string | null;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/** Private idempotency fence for atomic referral-click recording. */
|
|
2
|
+
import { SmrtObject, type SmrtObjectOptions } from '@happyvertical/smrt-core';
|
|
2
3
|
interface ReferralClickOperationOptions extends SmrtObjectOptions {
|
|
3
4
|
tenantId?: string | null;
|
|
4
5
|
keyHash?: string;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ReferralLink — shareable link/code per Referrer + Program.
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
1
5
|
import { SmrtObject } from '@happyvertical/smrt-core';
|
|
2
|
-
import { ReferralLinkOptions, ReferralLinkStatus } from '../types.js';
|
|
6
|
+
import type { ReferralLinkOptions, ReferralLinkStatus } from '../types.js';
|
|
3
7
|
/**
|
|
4
8
|
* Assert that a target URL is an absolute http/https URL. Exported for the
|
|
5
9
|
* collection's create path; the model also enforces it at save time so no
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ReferralProgram — program-level defaults for referral intake.
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
1
5
|
import { SmrtObject } from '@happyvertical/smrt-core';
|
|
2
|
-
import { ReferralProgramOptions, ReferralProgramStatus } from '../types.js';
|
|
6
|
+
import type { ReferralProgramOptions, ReferralProgramStatus } from '../types.js';
|
|
3
7
|
/**
|
|
4
8
|
* A ReferralProgram anchors links, touches, referrals, agreements, and
|
|
5
9
|
* exceptions, and carries the program-level DEFAULTS:
|
|
@@ -1,6 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ReferralTermSnapshot — the terms frozen at qualification.
|
|
3
|
+
*
|
|
4
|
+
* When a Referral qualifies, `ReferralQualificationService` copies
|
|
5
|
+
* EVERYTHING later earnings depend on into one immutable row: the resolved
|
|
6
|
+
* agreement/plan/policy version references plus the CALCULATION INPUTS
|
|
7
|
+
* themselves (`components`, `currency`, `clearingDays`, `approvalMode`).
|
|
8
|
+
* `ReferralCommissionService` calculates exclusively from this row — never
|
|
9
|
+
* from a live plan — so a plan amendment after qualification can NEVER
|
|
10
|
+
* change what an already-qualified referral earns. Reproducibility over
|
|
11
|
+
* convenience.
|
|
12
|
+
*
|
|
13
|
+
* FULLY immutable post-create: a save guard rejects ANY field change to a
|
|
14
|
+
* persisted row (and blind writes onto an existing id from a non-hydrated
|
|
15
|
+
* instance). Amended terms mean a NEW snapshot via
|
|
16
|
+
* `ReferralQualificationService.requalify()` — the old row stands as
|
|
17
|
+
* history, still referenced by any Commission it produced.
|
|
18
|
+
*
|
|
19
|
+
* @packageDocumentation
|
|
20
|
+
*/
|
|
1
21
|
import { SmrtObject } from '@happyvertical/smrt-core';
|
|
2
|
-
import { CommissionPlanComponent } from '../../commissions/index.js';
|
|
3
|
-
import { ReferralAgreementApprovalMode, ReferralTermSnapshotOptions } from '../types.js';
|
|
22
|
+
import type { CommissionPlanComponent } from '../../commissions/index.js';
|
|
23
|
+
import type { ReferralAgreementApprovalMode, ReferralTermSnapshotOptions } from '../types.js';
|
|
4
24
|
export declare class ReferralTermSnapshot extends SmrtObject {
|
|
5
25
|
/** Tenant ID for multi-tenant isolation (nullable → global rows). */
|
|
6
26
|
tenantId: string | null;
|
|
@@ -1,5 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ReferralTouch — immutable attribution evidence.
|
|
3
|
+
*
|
|
4
|
+
* A touch records that a prospect interacted with a referral artifact: a
|
|
5
|
+
* link click, a code entry, a partner-submitted introduction, or an
|
|
6
|
+
* operator's manual assignment. Touches are the CANDIDATE SET attribution
|
|
7
|
+
* resolves over — `AttributionService.resolve()` gathers eligible touches
|
|
8
|
+
* within the policy window and credits per the policy's mode.
|
|
9
|
+
*
|
|
10
|
+
* Immutability contract (same as the commissions module's `EarningEvent`):
|
|
11
|
+
* touches are evidence. The generated surface exposes `create`/`list`/`get`
|
|
12
|
+
* only (no update, no delete), and application code must treat persisted
|
|
13
|
+
* rows as append-only — Referrals point at their winning touch via
|
|
14
|
+
* `primaryTouchId` and AttributionExceptions embed candidate touches, so
|
|
15
|
+
* rewriting a touch would orphan the audit trail. Corrections are modelled
|
|
16
|
+
* as NEW touches (e.g. a `manual_assignment`).
|
|
17
|
+
*
|
|
18
|
+
* @packageDocumentation
|
|
19
|
+
*/
|
|
1
20
|
import { SmrtObject } from '@happyvertical/smrt-core';
|
|
2
|
-
import { ReferralTouchKind, ReferralTouchOptions } from '../types.js';
|
|
21
|
+
import type { ReferralTouchKind, ReferralTouchOptions } from '../types.js';
|
|
3
22
|
export declare class ReferralTouch extends SmrtObject {
|
|
4
23
|
/** Tenant ID for multi-tenant isolation (nullable → global touches). */
|
|
5
24
|
tenantId: string | null;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Referrer — the referral role model.
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
1
5
|
import { SmrtObject } from '@happyvertical/smrt-core';
|
|
2
|
-
import { ReferrerOptions, ReferrerStatus } from '../types.js';
|
|
6
|
+
import type { ReferrerOptions, ReferrerStatus } from '../types.js';
|
|
3
7
|
/**
|
|
4
8
|
* Referrer is a ROLE model: it links an identity (smrt-profiles Profile) to
|
|
5
9
|
* referral activity (ReferralLinks, ReferralTouches, and Referrals reference
|