@happyvertical/smrt-sales 0.57.2 → 0.57.3
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/README.md +70 -2
- package/agents/commissions.md +1 -1
- package/agents/referrals.md +1 -0
- package/dist/agreements/collections/AgreementCollection.d.ts +50 -0
- package/dist/agreements/collections/AgreementCollection.d.ts.map +1 -0
- package/dist/agreements/index.d.ts +2 -0
- package/dist/agreements/index.d.ts.map +1 -1
- package/dist/agreements/models/Agreement.d.ts +67 -0
- package/dist/agreements/models/Agreement.d.ts.map +1 -0
- package/dist/agreements/types.d.ts +32 -0
- package/dist/agreements/types.d.ts.map +1 -1
- package/dist/agreements.d.ts +2 -2
- package/dist/agreements.js +3 -3
- package/dist/chunks/__smrt-register__-DTUQW7wz.js +6 -0
- package/dist/chunks/__smrt-register__-DTUQW7wz.js.map +1 -0
- package/dist/chunks/{agreements-BB_tNU0U.js → agreements-jBiVmttD.js} +450 -4
- package/dist/chunks/agreements-jBiVmttD.js.map +1 -0
- package/dist/chunks/{commissions-Cs4MsxVg.js → commissions-Cip6QZ9Q.js} +350 -6
- package/dist/chunks/commissions-Cip6QZ9Q.js.map +1 -0
- package/dist/chunks/{referrals-CrFDsdq-.js → referrals-CYgrGkEo.js} +17 -3
- package/dist/chunks/{referrals-CrFDsdq-.js.map → referrals-CYgrGkEo.js.map} +1 -1
- package/dist/commissions/collections/CommissionAdjustmentOperationCollection.d.ts.map +1 -1
- package/dist/commissions/collections/CommissionPlanCollection.d.ts +5 -1
- package/dist/commissions/collections/CommissionPlanCollection.d.ts.map +1 -1
- package/dist/commissions/models/CommissionPlan.d.ts +20 -1
- package/dist/commissions/models/CommissionPlan.d.ts.map +1 -1
- package/dist/commissions/services/WaterfallCalculationService.d.ts +22 -0
- package/dist/commissions/services/WaterfallCalculationService.d.ts.map +1 -0
- package/dist/commissions/services/index.d.ts +1 -0
- package/dist/commissions/services/index.d.ts.map +1 -1
- package/dist/commissions/types.d.ts +100 -0
- package/dist/commissions/types.d.ts.map +1 -1
- package/dist/commissions.js +3 -3
- package/dist/crm.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -5
- package/dist/manifest.json +1399 -514
- package/dist/referrals/services/ReferralQualificationService.d.ts +4 -3
- package/dist/referrals/services/ReferralQualificationService.d.ts.map +1 -1
- package/dist/referrals.js +2 -2
- package/dist/smrt-knowledge.json +985 -34
- package/package.json +6 -6
- package/dist/chunks/__smrt-register__-CNn8HXhK.js +0 -6
- package/dist/chunks/__smrt-register__-CNn8HXhK.js.map +0 -1
- package/dist/chunks/agreements-BB_tNU0U.js.map +0 -1
- package/dist/chunks/commissions-Cs4MsxVg.js.map +0 -1
package/dist/smrt-knowledge.json
CHANGED
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
"sensitiveFieldsExcluded": true,
|
|
4
4
|
"generatedAt": "1970-01-01T00:00:00.000Z",
|
|
5
5
|
"packageName": "@happyvertical/smrt-sales",
|
|
6
|
-
"packageVersion": "0.57.
|
|
6
|
+
"packageVersion": "0.57.3",
|
|
7
7
|
"sourceManifestPath": "dist/manifest.json",
|
|
8
8
|
"agentDocPath": "AGENTS.md",
|
|
9
9
|
"sourceHashes": {
|
|
10
|
-
"manifest": "
|
|
11
|
-
"packageJson": "
|
|
10
|
+
"manifest": "94c0a04880d49d99da803c7e3f2542f1a035069da2c2d53eabffc1c596088f3d",
|
|
11
|
+
"packageJson": "b76335ff5c9e9a79836d93cec49174fc05f88fa83a93d31fce78801d47dc3ade",
|
|
12
12
|
"agents": "3100099d7cef116237e4deb4f83e32d836f3cc26e0f68a7dd55f14de942eda11",
|
|
13
13
|
"moduleDoc:agents/agreements.md": "eb6ff147a0f60ee627d3337e8e9394d06fda955b4a4fff228537a9bd2803f886",
|
|
14
|
-
"moduleDoc:agents/commissions.md": "
|
|
14
|
+
"moduleDoc:agents/commissions.md": "b649ef658d41f9c27287281f6d3c9ee06dec2aede89da070a3ebfc7b4c289798",
|
|
15
15
|
"moduleDoc:agents/crm.md": "b2c01c33e6ac559ba32073a089760d885095969d2ad749c30428c76e6aa2cc71",
|
|
16
|
-
"moduleDoc:agents/referrals.md": "
|
|
16
|
+
"moduleDoc:agents/referrals.md": "ef48c88e63155e3d08b9003f4643bc66ebb1942f1fb713252dc042ddcaad38e5",
|
|
17
17
|
"moduleDoc:agents/svelte.md": "819f690b91cf93980f6f79e89da8d9629ca6e5c565494e3fd2ca3be7587ad6de"
|
|
18
18
|
},
|
|
19
19
|
"exports": [
|
|
@@ -68,6 +68,149 @@
|
|
|
68
68
|
"sensitive-fields-excluded"
|
|
69
69
|
],
|
|
70
70
|
"objects": [
|
|
71
|
+
{
|
|
72
|
+
"name": "AgreementCollection",
|
|
73
|
+
"qualifiedName": "@happyvertical/smrt-sales:AgreementCollection",
|
|
74
|
+
"collection": "agreements",
|
|
75
|
+
"description": "Versioned rows for one ordered (kind, partyA, partyB) relationship.",
|
|
76
|
+
"tableName": "agreements",
|
|
77
|
+
"packageName": "@happyvertical/smrt-sales",
|
|
78
|
+
"extends": "SmrtCollection",
|
|
79
|
+
"fields": [],
|
|
80
|
+
"relationships": [],
|
|
81
|
+
"methods": [
|
|
82
|
+
"activateAmendment",
|
|
83
|
+
"activeFor",
|
|
84
|
+
"createAmendment",
|
|
85
|
+
"findVersions",
|
|
86
|
+
"withdrawAmendment"
|
|
87
|
+
],
|
|
88
|
+
"methodSignatures": [
|
|
89
|
+
{
|
|
90
|
+
"name": "activateAmendment",
|
|
91
|
+
"async": true,
|
|
92
|
+
"params": [
|
|
93
|
+
"id: string"
|
|
94
|
+
],
|
|
95
|
+
"returns": "Promise<Agreement>"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"name": "activeFor",
|
|
99
|
+
"async": true,
|
|
100
|
+
"params": [
|
|
101
|
+
"kind: string",
|
|
102
|
+
"partyA: AgreementParty",
|
|
103
|
+
"partyB: AgreementParty",
|
|
104
|
+
"at?: Date",
|
|
105
|
+
"tenantId?: string | null"
|
|
106
|
+
],
|
|
107
|
+
"returns": "Promise<Agreement | null>"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"name": "createAmendment",
|
|
111
|
+
"async": true,
|
|
112
|
+
"params": [
|
|
113
|
+
"kind: string",
|
|
114
|
+
"partyA: AgreementParty",
|
|
115
|
+
"partyB: AgreementParty",
|
|
116
|
+
"changes?: AgreementAmendmentChanges"
|
|
117
|
+
],
|
|
118
|
+
"returns": "Promise<Agreement>"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"name": "findVersions",
|
|
122
|
+
"async": true,
|
|
123
|
+
"params": [
|
|
124
|
+
"kind: string",
|
|
125
|
+
"partyA: AgreementParty",
|
|
126
|
+
"partyB: AgreementParty"
|
|
127
|
+
],
|
|
128
|
+
"returns": "Promise<Agreement[]>"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"name": "withdrawAmendment",
|
|
132
|
+
"async": true,
|
|
133
|
+
"params": [
|
|
134
|
+
"id: string"
|
|
135
|
+
],
|
|
136
|
+
"returns": "Promise<Agreement>"
|
|
137
|
+
}
|
|
138
|
+
],
|
|
139
|
+
"surfaces": [
|
|
140
|
+
{
|
|
141
|
+
"kind": "cli",
|
|
142
|
+
"name": "agreementcollection_findVersions",
|
|
143
|
+
"operation": "findVersions",
|
|
144
|
+
"objectName": "@happyvertical/smrt-sales:AgreementCollection"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"kind": "cli",
|
|
148
|
+
"name": "agreementcollection_activeFor",
|
|
149
|
+
"operation": "activeFor",
|
|
150
|
+
"objectName": "@happyvertical/smrt-sales:AgreementCollection"
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"kind": "cli",
|
|
154
|
+
"name": "agreementcollection_createAmendment",
|
|
155
|
+
"operation": "createAmendment",
|
|
156
|
+
"objectName": "@happyvertical/smrt-sales:AgreementCollection"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"kind": "cli",
|
|
160
|
+
"name": "agreementcollection_activateAmendment",
|
|
161
|
+
"operation": "activateAmendment",
|
|
162
|
+
"objectName": "@happyvertical/smrt-sales:AgreementCollection"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"kind": "cli",
|
|
166
|
+
"name": "agreementcollection_withdrawAmendment",
|
|
167
|
+
"operation": "withdrawAmendment",
|
|
168
|
+
"objectName": "@happyvertical/smrt-sales:AgreementCollection"
|
|
169
|
+
}
|
|
170
|
+
],
|
|
171
|
+
"withheldSurfaces": [
|
|
172
|
+
{
|
|
173
|
+
"kind": "api",
|
|
174
|
+
"operation": "activateAmendment",
|
|
175
|
+
"code": "not-included",
|
|
176
|
+
"reason": "not listed in api.include",
|
|
177
|
+
"objectName": "@happyvertical/smrt-sales:AgreementCollection"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"kind": "api",
|
|
181
|
+
"operation": "activeFor",
|
|
182
|
+
"code": "not-included",
|
|
183
|
+
"reason": "not listed in api.include",
|
|
184
|
+
"objectName": "@happyvertical/smrt-sales:AgreementCollection"
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"kind": "api",
|
|
188
|
+
"operation": "createAmendment",
|
|
189
|
+
"code": "not-included",
|
|
190
|
+
"reason": "not listed in api.include",
|
|
191
|
+
"objectName": "@happyvertical/smrt-sales:AgreementCollection"
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"kind": "api",
|
|
195
|
+
"operation": "findVersions",
|
|
196
|
+
"code": "not-included",
|
|
197
|
+
"reason": "not listed in api.include",
|
|
198
|
+
"objectName": "@happyvertical/smrt-sales:AgreementCollection"
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
"kind": "api",
|
|
202
|
+
"operation": "withdrawAmendment",
|
|
203
|
+
"code": "not-included",
|
|
204
|
+
"reason": "not listed in api.include",
|
|
205
|
+
"objectName": "@happyvertical/smrt-sales:AgreementCollection"
|
|
206
|
+
}
|
|
207
|
+
],
|
|
208
|
+
"relationshipFeatures": [
|
|
209
|
+
"uuidColumns"
|
|
210
|
+
],
|
|
211
|
+
"tags": [],
|
|
212
|
+
"risks": []
|
|
213
|
+
},
|
|
71
214
|
{
|
|
72
215
|
"name": "AgreementExecutionCollection",
|
|
73
216
|
"qualifiedName": "@happyvertical/smrt-sales:AgreementExecutionCollection",
|
|
@@ -390,55 +533,536 @@
|
|
|
390
533
|
"returns": "Promise<ExecutedAgreement | null>"
|
|
391
534
|
},
|
|
392
535
|
{
|
|
393
|
-
"name": "findByExecution",
|
|
394
|
-
"async": true,
|
|
395
|
-
"params": [
|
|
396
|
-
"executionId: string"
|
|
397
|
-
],
|
|
398
|
-
"returns": "Promise<ExecutedAgreement | null>"
|
|
536
|
+
"name": "findByExecution",
|
|
537
|
+
"async": true,
|
|
538
|
+
"params": [
|
|
539
|
+
"executionId: string"
|
|
540
|
+
],
|
|
541
|
+
"returns": "Promise<ExecutedAgreement | null>"
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
"name": "findVersionsBySource",
|
|
545
|
+
"async": true,
|
|
546
|
+
"params": [
|
|
547
|
+
"sourceKind: string",
|
|
548
|
+
"sourceId: string"
|
|
549
|
+
],
|
|
550
|
+
"returns": "Promise<ExecutedAgreement[]>"
|
|
551
|
+
}
|
|
552
|
+
],
|
|
553
|
+
"surfaces": [],
|
|
554
|
+
"withheldSurfaces": [
|
|
555
|
+
{
|
|
556
|
+
"kind": "api",
|
|
557
|
+
"operation": "createImmutable",
|
|
558
|
+
"code": "not-included",
|
|
559
|
+
"reason": "not listed in api.include",
|
|
560
|
+
"objectName": "@happyvertical/smrt-sales:ExecutedAgreementCollection"
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
"kind": "api",
|
|
564
|
+
"operation": "effectiveForSource",
|
|
565
|
+
"code": "not-included",
|
|
566
|
+
"reason": "not listed in api.include",
|
|
567
|
+
"objectName": "@happyvertical/smrt-sales:ExecutedAgreementCollection"
|
|
568
|
+
},
|
|
569
|
+
{
|
|
570
|
+
"kind": "api",
|
|
571
|
+
"operation": "findByExecution",
|
|
572
|
+
"code": "not-included",
|
|
573
|
+
"reason": "not listed in api.include",
|
|
574
|
+
"objectName": "@happyvertical/smrt-sales:ExecutedAgreementCollection"
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
"kind": "api",
|
|
578
|
+
"operation": "findVersionsBySource",
|
|
579
|
+
"code": "not-included",
|
|
580
|
+
"reason": "not listed in api.include",
|
|
581
|
+
"objectName": "@happyvertical/smrt-sales:ExecutedAgreementCollection"
|
|
582
|
+
}
|
|
583
|
+
],
|
|
584
|
+
"relationshipFeatures": [
|
|
585
|
+
"uuidColumns"
|
|
586
|
+
],
|
|
587
|
+
"tags": [],
|
|
588
|
+
"risks": []
|
|
589
|
+
},
|
|
590
|
+
{
|
|
591
|
+
"name": "Agreement",
|
|
592
|
+
"qualifiedName": "@happyvertical/smrt-sales:Agreement",
|
|
593
|
+
"collection": "agreements",
|
|
594
|
+
"tableName": "agreements",
|
|
595
|
+
"packageName": "@happyvertical/smrt-sales",
|
|
596
|
+
"extends": "SmrtObject",
|
|
597
|
+
"fields": [
|
|
598
|
+
{
|
|
599
|
+
"name": "tenantId",
|
|
600
|
+
"type": "text",
|
|
601
|
+
"required": false,
|
|
602
|
+
"columnType": "UUID"
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
"name": "kind",
|
|
606
|
+
"type": "text",
|
|
607
|
+
"required": true,
|
|
608
|
+
"columnType": "TEXT",
|
|
609
|
+
"default": ""
|
|
610
|
+
},
|
|
611
|
+
{
|
|
612
|
+
"name": "partyA",
|
|
613
|
+
"type": "text",
|
|
614
|
+
"required": true,
|
|
615
|
+
"columnType": "TEXT",
|
|
616
|
+
"default": ""
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
"name": "partyB",
|
|
620
|
+
"type": "text",
|
|
621
|
+
"required": true,
|
|
622
|
+
"columnType": "TEXT",
|
|
623
|
+
"default": ""
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
"name": "version",
|
|
627
|
+
"type": "integer",
|
|
628
|
+
"required": false,
|
|
629
|
+
"columnType": "INTEGER",
|
|
630
|
+
"default": 1
|
|
631
|
+
},
|
|
632
|
+
{
|
|
633
|
+
"name": "status",
|
|
634
|
+
"type": "text",
|
|
635
|
+
"required": false,
|
|
636
|
+
"columnType": "TEXT",
|
|
637
|
+
"default": "draft"
|
|
638
|
+
},
|
|
639
|
+
{
|
|
640
|
+
"name": "terms",
|
|
641
|
+
"type": "text",
|
|
642
|
+
"required": false,
|
|
643
|
+
"columnType": "TEXT",
|
|
644
|
+
"default": "{}"
|
|
645
|
+
},
|
|
646
|
+
{
|
|
647
|
+
"name": "effectiveFrom",
|
|
648
|
+
"type": "datetime",
|
|
649
|
+
"required": false,
|
|
650
|
+
"columnType": "TIMESTAMP"
|
|
651
|
+
},
|
|
652
|
+
{
|
|
653
|
+
"name": "effectiveTo",
|
|
654
|
+
"type": "datetime",
|
|
655
|
+
"required": false,
|
|
656
|
+
"columnType": "TIMESTAMP"
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
"name": "executedAgreementId",
|
|
660
|
+
"type": "foreignKey",
|
|
661
|
+
"required": false,
|
|
662
|
+
"related": "ExecutedAgreement",
|
|
663
|
+
"columnType": "UUID"
|
|
664
|
+
},
|
|
665
|
+
{
|
|
666
|
+
"name": "amendmentPredecessorId",
|
|
667
|
+
"type": "foreignKey",
|
|
668
|
+
"required": false,
|
|
669
|
+
"related": "Agreement",
|
|
670
|
+
"columnType": "UUID"
|
|
671
|
+
},
|
|
672
|
+
{
|
|
673
|
+
"name": "amendmentPredecessorEnd",
|
|
674
|
+
"type": "datetime",
|
|
675
|
+
"required": false,
|
|
676
|
+
"columnType": "TIMESTAMP"
|
|
677
|
+
},
|
|
678
|
+
{
|
|
679
|
+
"name": "metadata",
|
|
680
|
+
"type": "text",
|
|
681
|
+
"required": false,
|
|
682
|
+
"columnType": "TEXT",
|
|
683
|
+
"default": "{}"
|
|
684
|
+
}
|
|
685
|
+
],
|
|
686
|
+
"relationships": [
|
|
687
|
+
{
|
|
688
|
+
"name": "executedAgreementId",
|
|
689
|
+
"type": "foreignKey",
|
|
690
|
+
"required": false,
|
|
691
|
+
"related": "ExecutedAgreement",
|
|
692
|
+
"columnType": "UUID"
|
|
693
|
+
},
|
|
694
|
+
{
|
|
695
|
+
"name": "amendmentPredecessorId",
|
|
696
|
+
"type": "foreignKey",
|
|
697
|
+
"required": false,
|
|
698
|
+
"related": "Agreement",
|
|
699
|
+
"columnType": "UUID"
|
|
700
|
+
}
|
|
701
|
+
],
|
|
702
|
+
"methods": [
|
|
703
|
+
"activate",
|
|
704
|
+
"getPartyA",
|
|
705
|
+
"getPartyB",
|
|
706
|
+
"getTerms",
|
|
707
|
+
"initialize",
|
|
708
|
+
"isActive",
|
|
709
|
+
"isDraft",
|
|
710
|
+
"isEffectiveAt",
|
|
711
|
+
"refreshAfterLifecycleTransition",
|
|
712
|
+
"save",
|
|
713
|
+
"setPartyA",
|
|
714
|
+
"setPartyB",
|
|
715
|
+
"setTerms",
|
|
716
|
+
"supersede",
|
|
717
|
+
"terminate"
|
|
718
|
+
],
|
|
719
|
+
"methodSignatures": [
|
|
720
|
+
{
|
|
721
|
+
"name": "activate",
|
|
722
|
+
"returns": "void"
|
|
723
|
+
},
|
|
724
|
+
{
|
|
725
|
+
"name": "getPartyA",
|
|
726
|
+
"returns": "AgreementParty | null"
|
|
727
|
+
},
|
|
728
|
+
{
|
|
729
|
+
"name": "getPartyB",
|
|
730
|
+
"returns": "AgreementParty | null"
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
"name": "getTerms",
|
|
734
|
+
"returns": "Record<string, unknown>"
|
|
735
|
+
},
|
|
736
|
+
{
|
|
737
|
+
"name": "initialize",
|
|
738
|
+
"async": true,
|
|
739
|
+
"returns": "Promise<this>"
|
|
740
|
+
},
|
|
741
|
+
{
|
|
742
|
+
"name": "isActive",
|
|
743
|
+
"returns": "boolean"
|
|
744
|
+
},
|
|
745
|
+
{
|
|
746
|
+
"name": "isDraft",
|
|
747
|
+
"returns": "boolean"
|
|
748
|
+
},
|
|
749
|
+
{
|
|
750
|
+
"name": "isEffectiveAt",
|
|
751
|
+
"params": [
|
|
752
|
+
"at: Date"
|
|
753
|
+
],
|
|
754
|
+
"returns": "boolean"
|
|
755
|
+
},
|
|
756
|
+
{
|
|
757
|
+
"name": "refreshAfterLifecycleTransition",
|
|
758
|
+
"async": true,
|
|
759
|
+
"returns": "Promise<void>"
|
|
760
|
+
},
|
|
761
|
+
{
|
|
762
|
+
"name": "save",
|
|
763
|
+
"async": true,
|
|
764
|
+
"returns": "Promise<this>"
|
|
765
|
+
},
|
|
766
|
+
{
|
|
767
|
+
"name": "setPartyA",
|
|
768
|
+
"params": [
|
|
769
|
+
"party: AgreementParty"
|
|
770
|
+
],
|
|
771
|
+
"returns": "void"
|
|
772
|
+
},
|
|
773
|
+
{
|
|
774
|
+
"name": "setPartyB",
|
|
775
|
+
"params": [
|
|
776
|
+
"party: AgreementParty"
|
|
777
|
+
],
|
|
778
|
+
"returns": "void"
|
|
779
|
+
},
|
|
780
|
+
{
|
|
781
|
+
"name": "setTerms",
|
|
782
|
+
"params": [
|
|
783
|
+
"terms: Record<string, unknown>"
|
|
784
|
+
],
|
|
785
|
+
"returns": "void"
|
|
786
|
+
},
|
|
787
|
+
{
|
|
788
|
+
"name": "supersede",
|
|
789
|
+
"returns": "void"
|
|
790
|
+
},
|
|
791
|
+
{
|
|
792
|
+
"name": "terminate",
|
|
793
|
+
"params": [
|
|
794
|
+
"at?: Date"
|
|
795
|
+
],
|
|
796
|
+
"returns": "void"
|
|
797
|
+
}
|
|
798
|
+
],
|
|
799
|
+
"tenant": {
|
|
800
|
+
"scoped": true,
|
|
801
|
+
"mode": "optional",
|
|
802
|
+
"field": "tenantId"
|
|
803
|
+
},
|
|
804
|
+
"conflictColumns": [
|
|
805
|
+
"tenant_id",
|
|
806
|
+
"kind",
|
|
807
|
+
"party_a",
|
|
808
|
+
"party_b",
|
|
809
|
+
"version"
|
|
810
|
+
],
|
|
811
|
+
"surfaces": [
|
|
812
|
+
{
|
|
813
|
+
"kind": "api",
|
|
814
|
+
"name": "agreements.list",
|
|
815
|
+
"operation": "list",
|
|
816
|
+
"objectName": "@happyvertical/smrt-sales:Agreement",
|
|
817
|
+
"path": "/agreements",
|
|
818
|
+
"method": "GET"
|
|
819
|
+
},
|
|
820
|
+
{
|
|
821
|
+
"kind": "api",
|
|
822
|
+
"name": "agreements.get",
|
|
823
|
+
"operation": "get",
|
|
824
|
+
"objectName": "@happyvertical/smrt-sales:Agreement",
|
|
825
|
+
"path": "/agreements/[id]",
|
|
826
|
+
"method": "GET"
|
|
827
|
+
},
|
|
828
|
+
{
|
|
829
|
+
"kind": "api",
|
|
830
|
+
"name": "agreements.create",
|
|
831
|
+
"operation": "create",
|
|
832
|
+
"objectName": "@happyvertical/smrt-sales:Agreement",
|
|
833
|
+
"path": "/agreements",
|
|
834
|
+
"method": "POST"
|
|
835
|
+
},
|
|
836
|
+
{
|
|
837
|
+
"kind": "cli",
|
|
838
|
+
"name": "agreement_list",
|
|
839
|
+
"operation": "list",
|
|
840
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
841
|
+
},
|
|
842
|
+
{
|
|
843
|
+
"kind": "cli",
|
|
844
|
+
"name": "agreement_get",
|
|
845
|
+
"operation": "get",
|
|
846
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
847
|
+
},
|
|
848
|
+
{
|
|
849
|
+
"kind": "cli",
|
|
850
|
+
"name": "agreement_create",
|
|
851
|
+
"operation": "create",
|
|
852
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
853
|
+
},
|
|
854
|
+
{
|
|
855
|
+
"kind": "cli",
|
|
856
|
+
"name": "agreement_update",
|
|
857
|
+
"operation": "update",
|
|
858
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
859
|
+
},
|
|
860
|
+
{
|
|
861
|
+
"kind": "cli",
|
|
862
|
+
"name": "agreement_delete",
|
|
863
|
+
"operation": "delete",
|
|
864
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
865
|
+
},
|
|
866
|
+
{
|
|
867
|
+
"kind": "cli",
|
|
868
|
+
"name": "agreement_isDraft",
|
|
869
|
+
"operation": "isDraft",
|
|
870
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
871
|
+
},
|
|
872
|
+
{
|
|
873
|
+
"kind": "cli",
|
|
874
|
+
"name": "agreement_isActive",
|
|
875
|
+
"operation": "isActive",
|
|
876
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
877
|
+
},
|
|
878
|
+
{
|
|
879
|
+
"kind": "cli",
|
|
880
|
+
"name": "agreement_isEffectiveAt",
|
|
881
|
+
"operation": "isEffectiveAt",
|
|
882
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
883
|
+
},
|
|
884
|
+
{
|
|
885
|
+
"kind": "cli",
|
|
886
|
+
"name": "agreement_getPartyA",
|
|
887
|
+
"operation": "getPartyA",
|
|
888
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
889
|
+
},
|
|
890
|
+
{
|
|
891
|
+
"kind": "cli",
|
|
892
|
+
"name": "agreement_getPartyB",
|
|
893
|
+
"operation": "getPartyB",
|
|
894
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
895
|
+
},
|
|
896
|
+
{
|
|
897
|
+
"kind": "cli",
|
|
898
|
+
"name": "agreement_setPartyA",
|
|
899
|
+
"operation": "setPartyA",
|
|
900
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
901
|
+
},
|
|
902
|
+
{
|
|
903
|
+
"kind": "cli",
|
|
904
|
+
"name": "agreement_setPartyB",
|
|
905
|
+
"operation": "setPartyB",
|
|
906
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
907
|
+
},
|
|
908
|
+
{
|
|
909
|
+
"kind": "cli",
|
|
910
|
+
"name": "agreement_getTerms",
|
|
911
|
+
"operation": "getTerms",
|
|
912
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
913
|
+
},
|
|
914
|
+
{
|
|
915
|
+
"kind": "cli",
|
|
916
|
+
"name": "agreement_setTerms",
|
|
917
|
+
"operation": "setTerms",
|
|
918
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
919
|
+
},
|
|
920
|
+
{
|
|
921
|
+
"kind": "cli",
|
|
922
|
+
"name": "agreement_activate",
|
|
923
|
+
"operation": "activate",
|
|
924
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
925
|
+
},
|
|
926
|
+
{
|
|
927
|
+
"kind": "cli",
|
|
928
|
+
"name": "agreement_supersede",
|
|
929
|
+
"operation": "supersede",
|
|
930
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
931
|
+
},
|
|
932
|
+
{
|
|
933
|
+
"kind": "cli",
|
|
934
|
+
"name": "agreement_terminate",
|
|
935
|
+
"operation": "terminate",
|
|
936
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
937
|
+
},
|
|
938
|
+
{
|
|
939
|
+
"kind": "cli",
|
|
940
|
+
"name": "agreement_refreshAfterLifecycleTransition",
|
|
941
|
+
"operation": "refreshAfterLifecycleTransition",
|
|
942
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
943
|
+
},
|
|
944
|
+
{
|
|
945
|
+
"kind": "mcp",
|
|
946
|
+
"name": "agreement_list",
|
|
947
|
+
"operation": "list",
|
|
948
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
949
|
+
},
|
|
950
|
+
{
|
|
951
|
+
"kind": "mcp",
|
|
952
|
+
"name": "agreement_get",
|
|
953
|
+
"operation": "get",
|
|
954
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
955
|
+
}
|
|
956
|
+
],
|
|
957
|
+
"withheldSurfaces": [
|
|
958
|
+
{
|
|
959
|
+
"kind": "api",
|
|
960
|
+
"operation": "activate",
|
|
961
|
+
"code": "not-included",
|
|
962
|
+
"reason": "not listed in api.include",
|
|
963
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
964
|
+
},
|
|
965
|
+
{
|
|
966
|
+
"kind": "api",
|
|
967
|
+
"operation": "getPartyA",
|
|
968
|
+
"code": "not-included",
|
|
969
|
+
"reason": "not listed in api.include",
|
|
970
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
971
|
+
},
|
|
972
|
+
{
|
|
973
|
+
"kind": "api",
|
|
974
|
+
"operation": "getPartyB",
|
|
975
|
+
"code": "not-included",
|
|
976
|
+
"reason": "not listed in api.include",
|
|
977
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
978
|
+
},
|
|
979
|
+
{
|
|
980
|
+
"kind": "api",
|
|
981
|
+
"operation": "getTerms",
|
|
982
|
+
"code": "not-included",
|
|
983
|
+
"reason": "not listed in api.include",
|
|
984
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
985
|
+
},
|
|
986
|
+
{
|
|
987
|
+
"kind": "api",
|
|
988
|
+
"operation": "initialize",
|
|
989
|
+
"code": "lifecycle-method",
|
|
990
|
+
"reason": "`initialize` is a framework lifecycle method, not a distinct operation",
|
|
991
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
992
|
+
},
|
|
993
|
+
{
|
|
994
|
+
"kind": "api",
|
|
995
|
+
"operation": "isActive",
|
|
996
|
+
"code": "not-included",
|
|
997
|
+
"reason": "not listed in api.include",
|
|
998
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
999
|
+
},
|
|
1000
|
+
{
|
|
1001
|
+
"kind": "api",
|
|
1002
|
+
"operation": "isDraft",
|
|
1003
|
+
"code": "not-included",
|
|
1004
|
+
"reason": "not listed in api.include",
|
|
1005
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
1006
|
+
},
|
|
1007
|
+
{
|
|
1008
|
+
"kind": "api",
|
|
1009
|
+
"operation": "isEffectiveAt",
|
|
1010
|
+
"code": "not-included",
|
|
1011
|
+
"reason": "not listed in api.include",
|
|
1012
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
1013
|
+
},
|
|
1014
|
+
{
|
|
1015
|
+
"kind": "api",
|
|
1016
|
+
"operation": "refreshAfterLifecycleTransition",
|
|
1017
|
+
"code": "not-included",
|
|
1018
|
+
"reason": "not listed in api.include",
|
|
1019
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
399
1020
|
},
|
|
400
1021
|
{
|
|
401
|
-
"
|
|
402
|
-
"
|
|
403
|
-
"
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
"returns": "Promise<ExecutedAgreement[]>"
|
|
408
|
-
}
|
|
409
|
-
],
|
|
410
|
-
"surfaces": [],
|
|
411
|
-
"withheldSurfaces": [
|
|
1022
|
+
"kind": "api",
|
|
1023
|
+
"operation": "save",
|
|
1024
|
+
"code": "lifecycle-method",
|
|
1025
|
+
"reason": "`save` is a framework lifecycle method, not a distinct operation",
|
|
1026
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
1027
|
+
},
|
|
412
1028
|
{
|
|
413
1029
|
"kind": "api",
|
|
414
|
-
"operation": "
|
|
1030
|
+
"operation": "setPartyA",
|
|
415
1031
|
"code": "not-included",
|
|
416
1032
|
"reason": "not listed in api.include",
|
|
417
|
-
"objectName": "@happyvertical/smrt-sales:
|
|
1033
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
418
1034
|
},
|
|
419
1035
|
{
|
|
420
1036
|
"kind": "api",
|
|
421
|
-
"operation": "
|
|
1037
|
+
"operation": "setPartyB",
|
|
422
1038
|
"code": "not-included",
|
|
423
1039
|
"reason": "not listed in api.include",
|
|
424
|
-
"objectName": "@happyvertical/smrt-sales:
|
|
1040
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
425
1041
|
},
|
|
426
1042
|
{
|
|
427
1043
|
"kind": "api",
|
|
428
|
-
"operation": "
|
|
1044
|
+
"operation": "setTerms",
|
|
429
1045
|
"code": "not-included",
|
|
430
1046
|
"reason": "not listed in api.include",
|
|
431
|
-
"objectName": "@happyvertical/smrt-sales:
|
|
1047
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
432
1048
|
},
|
|
433
1049
|
{
|
|
434
1050
|
"kind": "api",
|
|
435
|
-
"operation": "
|
|
1051
|
+
"operation": "supersede",
|
|
436
1052
|
"code": "not-included",
|
|
437
1053
|
"reason": "not listed in api.include",
|
|
438
|
-
"objectName": "@happyvertical/smrt-sales:
|
|
1054
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
1055
|
+
},
|
|
1056
|
+
{
|
|
1057
|
+
"kind": "api",
|
|
1058
|
+
"operation": "terminate",
|
|
1059
|
+
"code": "not-included",
|
|
1060
|
+
"reason": "not listed in api.include",
|
|
1061
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
439
1062
|
}
|
|
440
1063
|
],
|
|
441
1064
|
"relationshipFeatures": [
|
|
1065
|
+
"foreignKey",
|
|
442
1066
|
"uuidColumns"
|
|
443
1067
|
],
|
|
444
1068
|
"tags": [],
|
|
@@ -3347,6 +3971,12 @@
|
|
|
3347
3971
|
"required": false,
|
|
3348
3972
|
"columnType": "TIMESTAMP"
|
|
3349
3973
|
},
|
|
3974
|
+
{
|
|
3975
|
+
"name": "effectiveTo",
|
|
3976
|
+
"type": "datetime",
|
|
3977
|
+
"required": false,
|
|
3978
|
+
"columnType": "TIMESTAMP"
|
|
3979
|
+
},
|
|
3350
3980
|
{
|
|
3351
3981
|
"name": "currency",
|
|
3352
3982
|
"type": "text",
|
|
@@ -3361,6 +3991,27 @@
|
|
|
3361
3991
|
"columnType": "TEXT",
|
|
3362
3992
|
"default": "[]"
|
|
3363
3993
|
},
|
|
3994
|
+
{
|
|
3995
|
+
"name": "steps",
|
|
3996
|
+
"type": "text",
|
|
3997
|
+
"required": false,
|
|
3998
|
+
"columnType": "TEXT",
|
|
3999
|
+
"default": "[]"
|
|
4000
|
+
},
|
|
4001
|
+
{
|
|
4002
|
+
"name": "remainderSink",
|
|
4003
|
+
"type": "text",
|
|
4004
|
+
"required": false,
|
|
4005
|
+
"columnType": "TEXT",
|
|
4006
|
+
"default": "{}"
|
|
4007
|
+
},
|
|
4008
|
+
{
|
|
4009
|
+
"name": "applicationFeeOffsetRecipient",
|
|
4010
|
+
"type": "text",
|
|
4011
|
+
"required": false,
|
|
4012
|
+
"columnType": "TEXT",
|
|
4013
|
+
"default": "{}"
|
|
4014
|
+
},
|
|
3364
4015
|
{
|
|
3365
4016
|
"name": "metadata",
|
|
3366
4017
|
"type": "text",
|
|
@@ -3374,6 +4025,9 @@
|
|
|
3374
4025
|
"activate",
|
|
3375
4026
|
"getComponents",
|
|
3376
4027
|
"getMetadata",
|
|
4028
|
+
"getRemainderSink",
|
|
4029
|
+
"getSteps",
|
|
4030
|
+
"getWaterfallPlan",
|
|
3377
4031
|
"initialize",
|
|
3378
4032
|
"isActive",
|
|
3379
4033
|
"isDraft",
|
|
@@ -3381,6 +4035,8 @@
|
|
|
3381
4035
|
"save",
|
|
3382
4036
|
"setComponents",
|
|
3383
4037
|
"setMetadata",
|
|
4038
|
+
"setRemainderSink",
|
|
4039
|
+
"setSteps",
|
|
3384
4040
|
"supersede"
|
|
3385
4041
|
],
|
|
3386
4042
|
"methodSignatures": [
|
|
@@ -3396,6 +4052,18 @@
|
|
|
3396
4052
|
"name": "getMetadata",
|
|
3397
4053
|
"returns": "Record<string, unknown>"
|
|
3398
4054
|
},
|
|
4055
|
+
{
|
|
4056
|
+
"name": "getRemainderSink",
|
|
4057
|
+
"returns": "WaterfallRecipientDescriptor | null"
|
|
4058
|
+
},
|
|
4059
|
+
{
|
|
4060
|
+
"name": "getSteps",
|
|
4061
|
+
"returns": "WaterfallStep[]"
|
|
4062
|
+
},
|
|
4063
|
+
{
|
|
4064
|
+
"name": "getWaterfallPlan",
|
|
4065
|
+
"returns": "WaterfallPlan | null"
|
|
4066
|
+
},
|
|
3399
4067
|
{
|
|
3400
4068
|
"name": "initialize",
|
|
3401
4069
|
"async": true,
|
|
@@ -3432,6 +4100,20 @@
|
|
|
3432
4100
|
],
|
|
3433
4101
|
"returns": "void"
|
|
3434
4102
|
},
|
|
4103
|
+
{
|
|
4104
|
+
"name": "setRemainderSink",
|
|
4105
|
+
"params": [
|
|
4106
|
+
"sink: WaterfallRecipientDescriptor"
|
|
4107
|
+
],
|
|
4108
|
+
"returns": "void"
|
|
4109
|
+
},
|
|
4110
|
+
{
|
|
4111
|
+
"name": "setSteps",
|
|
4112
|
+
"params": [
|
|
4113
|
+
"steps: WaterfallStep[]"
|
|
4114
|
+
],
|
|
4115
|
+
"returns": "void"
|
|
4116
|
+
},
|
|
3435
4117
|
{
|
|
3436
4118
|
"name": "supersede",
|
|
3437
4119
|
"returns": "void"
|
|
@@ -3526,6 +4208,36 @@
|
|
|
3526
4208
|
"operation": "setComponents",
|
|
3527
4209
|
"objectName": "@happyvertical/smrt-sales:CommissionPlan"
|
|
3528
4210
|
},
|
|
4211
|
+
{
|
|
4212
|
+
"kind": "cli",
|
|
4213
|
+
"name": "commissionplan_getSteps",
|
|
4214
|
+
"operation": "getSteps",
|
|
4215
|
+
"objectName": "@happyvertical/smrt-sales:CommissionPlan"
|
|
4216
|
+
},
|
|
4217
|
+
{
|
|
4218
|
+
"kind": "cli",
|
|
4219
|
+
"name": "commissionplan_setSteps",
|
|
4220
|
+
"operation": "setSteps",
|
|
4221
|
+
"objectName": "@happyvertical/smrt-sales:CommissionPlan"
|
|
4222
|
+
},
|
|
4223
|
+
{
|
|
4224
|
+
"kind": "cli",
|
|
4225
|
+
"name": "commissionplan_getRemainderSink",
|
|
4226
|
+
"operation": "getRemainderSink",
|
|
4227
|
+
"objectName": "@happyvertical/smrt-sales:CommissionPlan"
|
|
4228
|
+
},
|
|
4229
|
+
{
|
|
4230
|
+
"kind": "cli",
|
|
4231
|
+
"name": "commissionplan_setRemainderSink",
|
|
4232
|
+
"operation": "setRemainderSink",
|
|
4233
|
+
"objectName": "@happyvertical/smrt-sales:CommissionPlan"
|
|
4234
|
+
},
|
|
4235
|
+
{
|
|
4236
|
+
"kind": "cli",
|
|
4237
|
+
"name": "commissionplan_getWaterfallPlan",
|
|
4238
|
+
"operation": "getWaterfallPlan",
|
|
4239
|
+
"objectName": "@happyvertical/smrt-sales:CommissionPlan"
|
|
4240
|
+
},
|
|
3529
4241
|
{
|
|
3530
4242
|
"kind": "cli",
|
|
3531
4243
|
"name": "commissionplan_getMetadata",
|
|
@@ -3591,6 +4303,27 @@
|
|
|
3591
4303
|
"reason": "not listed in api.include",
|
|
3592
4304
|
"objectName": "@happyvertical/smrt-sales:CommissionPlan"
|
|
3593
4305
|
},
|
|
4306
|
+
{
|
|
4307
|
+
"kind": "api",
|
|
4308
|
+
"operation": "getRemainderSink",
|
|
4309
|
+
"code": "not-included",
|
|
4310
|
+
"reason": "not listed in api.include",
|
|
4311
|
+
"objectName": "@happyvertical/smrt-sales:CommissionPlan"
|
|
4312
|
+
},
|
|
4313
|
+
{
|
|
4314
|
+
"kind": "api",
|
|
4315
|
+
"operation": "getSteps",
|
|
4316
|
+
"code": "not-included",
|
|
4317
|
+
"reason": "not listed in api.include",
|
|
4318
|
+
"objectName": "@happyvertical/smrt-sales:CommissionPlan"
|
|
4319
|
+
},
|
|
4320
|
+
{
|
|
4321
|
+
"kind": "api",
|
|
4322
|
+
"operation": "getWaterfallPlan",
|
|
4323
|
+
"code": "not-included",
|
|
4324
|
+
"reason": "not listed in api.include",
|
|
4325
|
+
"objectName": "@happyvertical/smrt-sales:CommissionPlan"
|
|
4326
|
+
},
|
|
3594
4327
|
{
|
|
3595
4328
|
"kind": "api",
|
|
3596
4329
|
"operation": "initialize",
|
|
@@ -3640,6 +4373,20 @@
|
|
|
3640
4373
|
"reason": "not listed in api.include",
|
|
3641
4374
|
"objectName": "@happyvertical/smrt-sales:CommissionPlan"
|
|
3642
4375
|
},
|
|
4376
|
+
{
|
|
4377
|
+
"kind": "api",
|
|
4378
|
+
"operation": "setRemainderSink",
|
|
4379
|
+
"code": "not-included",
|
|
4380
|
+
"reason": "not listed in api.include",
|
|
4381
|
+
"objectName": "@happyvertical/smrt-sales:CommissionPlan"
|
|
4382
|
+
},
|
|
4383
|
+
{
|
|
4384
|
+
"kind": "api",
|
|
4385
|
+
"operation": "setSteps",
|
|
4386
|
+
"code": "not-included",
|
|
4387
|
+
"reason": "not listed in api.include",
|
|
4388
|
+
"objectName": "@happyvertical/smrt-sales:CommissionPlan"
|
|
4389
|
+
},
|
|
3643
4390
|
{
|
|
3644
4391
|
"kind": "api",
|
|
3645
4392
|
"operation": "supersede",
|
|
@@ -10475,6 +11222,180 @@
|
|
|
10475
11222
|
}
|
|
10476
11223
|
],
|
|
10477
11224
|
"surfaces": [
|
|
11225
|
+
{
|
|
11226
|
+
"kind": "cli",
|
|
11227
|
+
"name": "agreementcollection_findVersions",
|
|
11228
|
+
"operation": "findVersions",
|
|
11229
|
+
"objectName": "@happyvertical/smrt-sales:AgreementCollection"
|
|
11230
|
+
},
|
|
11231
|
+
{
|
|
11232
|
+
"kind": "cli",
|
|
11233
|
+
"name": "agreementcollection_activeFor",
|
|
11234
|
+
"operation": "activeFor",
|
|
11235
|
+
"objectName": "@happyvertical/smrt-sales:AgreementCollection"
|
|
11236
|
+
},
|
|
11237
|
+
{
|
|
11238
|
+
"kind": "cli",
|
|
11239
|
+
"name": "agreementcollection_createAmendment",
|
|
11240
|
+
"operation": "createAmendment",
|
|
11241
|
+
"objectName": "@happyvertical/smrt-sales:AgreementCollection"
|
|
11242
|
+
},
|
|
11243
|
+
{
|
|
11244
|
+
"kind": "cli",
|
|
11245
|
+
"name": "agreementcollection_activateAmendment",
|
|
11246
|
+
"operation": "activateAmendment",
|
|
11247
|
+
"objectName": "@happyvertical/smrt-sales:AgreementCollection"
|
|
11248
|
+
},
|
|
11249
|
+
{
|
|
11250
|
+
"kind": "cli",
|
|
11251
|
+
"name": "agreementcollection_withdrawAmendment",
|
|
11252
|
+
"operation": "withdrawAmendment",
|
|
11253
|
+
"objectName": "@happyvertical/smrt-sales:AgreementCollection"
|
|
11254
|
+
},
|
|
11255
|
+
{
|
|
11256
|
+
"kind": "api",
|
|
11257
|
+
"name": "agreements.list",
|
|
11258
|
+
"operation": "list",
|
|
11259
|
+
"objectName": "@happyvertical/smrt-sales:Agreement",
|
|
11260
|
+
"path": "/agreements",
|
|
11261
|
+
"method": "GET"
|
|
11262
|
+
},
|
|
11263
|
+
{
|
|
11264
|
+
"kind": "api",
|
|
11265
|
+
"name": "agreements.get",
|
|
11266
|
+
"operation": "get",
|
|
11267
|
+
"objectName": "@happyvertical/smrt-sales:Agreement",
|
|
11268
|
+
"path": "/agreements/[id]",
|
|
11269
|
+
"method": "GET"
|
|
11270
|
+
},
|
|
11271
|
+
{
|
|
11272
|
+
"kind": "api",
|
|
11273
|
+
"name": "agreements.create",
|
|
11274
|
+
"operation": "create",
|
|
11275
|
+
"objectName": "@happyvertical/smrt-sales:Agreement",
|
|
11276
|
+
"path": "/agreements",
|
|
11277
|
+
"method": "POST"
|
|
11278
|
+
},
|
|
11279
|
+
{
|
|
11280
|
+
"kind": "cli",
|
|
11281
|
+
"name": "agreement_list",
|
|
11282
|
+
"operation": "list",
|
|
11283
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
11284
|
+
},
|
|
11285
|
+
{
|
|
11286
|
+
"kind": "cli",
|
|
11287
|
+
"name": "agreement_get",
|
|
11288
|
+
"operation": "get",
|
|
11289
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
11290
|
+
},
|
|
11291
|
+
{
|
|
11292
|
+
"kind": "cli",
|
|
11293
|
+
"name": "agreement_create",
|
|
11294
|
+
"operation": "create",
|
|
11295
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
11296
|
+
},
|
|
11297
|
+
{
|
|
11298
|
+
"kind": "cli",
|
|
11299
|
+
"name": "agreement_update",
|
|
11300
|
+
"operation": "update",
|
|
11301
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
11302
|
+
},
|
|
11303
|
+
{
|
|
11304
|
+
"kind": "cli",
|
|
11305
|
+
"name": "agreement_delete",
|
|
11306
|
+
"operation": "delete",
|
|
11307
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
11308
|
+
},
|
|
11309
|
+
{
|
|
11310
|
+
"kind": "cli",
|
|
11311
|
+
"name": "agreement_isDraft",
|
|
11312
|
+
"operation": "isDraft",
|
|
11313
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
11314
|
+
},
|
|
11315
|
+
{
|
|
11316
|
+
"kind": "cli",
|
|
11317
|
+
"name": "agreement_isActive",
|
|
11318
|
+
"operation": "isActive",
|
|
11319
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
11320
|
+
},
|
|
11321
|
+
{
|
|
11322
|
+
"kind": "cli",
|
|
11323
|
+
"name": "agreement_isEffectiveAt",
|
|
11324
|
+
"operation": "isEffectiveAt",
|
|
11325
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
11326
|
+
},
|
|
11327
|
+
{
|
|
11328
|
+
"kind": "cli",
|
|
11329
|
+
"name": "agreement_getPartyA",
|
|
11330
|
+
"operation": "getPartyA",
|
|
11331
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
11332
|
+
},
|
|
11333
|
+
{
|
|
11334
|
+
"kind": "cli",
|
|
11335
|
+
"name": "agreement_getPartyB",
|
|
11336
|
+
"operation": "getPartyB",
|
|
11337
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
11338
|
+
},
|
|
11339
|
+
{
|
|
11340
|
+
"kind": "cli",
|
|
11341
|
+
"name": "agreement_setPartyA",
|
|
11342
|
+
"operation": "setPartyA",
|
|
11343
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
11344
|
+
},
|
|
11345
|
+
{
|
|
11346
|
+
"kind": "cli",
|
|
11347
|
+
"name": "agreement_setPartyB",
|
|
11348
|
+
"operation": "setPartyB",
|
|
11349
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
11350
|
+
},
|
|
11351
|
+
{
|
|
11352
|
+
"kind": "cli",
|
|
11353
|
+
"name": "agreement_getTerms",
|
|
11354
|
+
"operation": "getTerms",
|
|
11355
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
11356
|
+
},
|
|
11357
|
+
{
|
|
11358
|
+
"kind": "cli",
|
|
11359
|
+
"name": "agreement_setTerms",
|
|
11360
|
+
"operation": "setTerms",
|
|
11361
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
11362
|
+
},
|
|
11363
|
+
{
|
|
11364
|
+
"kind": "cli",
|
|
11365
|
+
"name": "agreement_activate",
|
|
11366
|
+
"operation": "activate",
|
|
11367
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
11368
|
+
},
|
|
11369
|
+
{
|
|
11370
|
+
"kind": "cli",
|
|
11371
|
+
"name": "agreement_supersede",
|
|
11372
|
+
"operation": "supersede",
|
|
11373
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
11374
|
+
},
|
|
11375
|
+
{
|
|
11376
|
+
"kind": "cli",
|
|
11377
|
+
"name": "agreement_terminate",
|
|
11378
|
+
"operation": "terminate",
|
|
11379
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
11380
|
+
},
|
|
11381
|
+
{
|
|
11382
|
+
"kind": "cli",
|
|
11383
|
+
"name": "agreement_refreshAfterLifecycleTransition",
|
|
11384
|
+
"operation": "refreshAfterLifecycleTransition",
|
|
11385
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
11386
|
+
},
|
|
11387
|
+
{
|
|
11388
|
+
"kind": "mcp",
|
|
11389
|
+
"name": "agreement_list",
|
|
11390
|
+
"operation": "list",
|
|
11391
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
11392
|
+
},
|
|
11393
|
+
{
|
|
11394
|
+
"kind": "mcp",
|
|
11395
|
+
"name": "agreement_get",
|
|
11396
|
+
"operation": "get",
|
|
11397
|
+
"objectName": "@happyvertical/smrt-sales:Agreement"
|
|
11398
|
+
},
|
|
10478
11399
|
{
|
|
10479
11400
|
"kind": "api",
|
|
10480
11401
|
"name": "executedagreements.list",
|
|
@@ -10735,6 +11656,36 @@
|
|
|
10735
11656
|
"operation": "setComponents",
|
|
10736
11657
|
"objectName": "@happyvertical/smrt-sales:CommissionPlan"
|
|
10737
11658
|
},
|
|
11659
|
+
{
|
|
11660
|
+
"kind": "cli",
|
|
11661
|
+
"name": "commissionplan_getSteps",
|
|
11662
|
+
"operation": "getSteps",
|
|
11663
|
+
"objectName": "@happyvertical/smrt-sales:CommissionPlan"
|
|
11664
|
+
},
|
|
11665
|
+
{
|
|
11666
|
+
"kind": "cli",
|
|
11667
|
+
"name": "commissionplan_setSteps",
|
|
11668
|
+
"operation": "setSteps",
|
|
11669
|
+
"objectName": "@happyvertical/smrt-sales:CommissionPlan"
|
|
11670
|
+
},
|
|
11671
|
+
{
|
|
11672
|
+
"kind": "cli",
|
|
11673
|
+
"name": "commissionplan_getRemainderSink",
|
|
11674
|
+
"operation": "getRemainderSink",
|
|
11675
|
+
"objectName": "@happyvertical/smrt-sales:CommissionPlan"
|
|
11676
|
+
},
|
|
11677
|
+
{
|
|
11678
|
+
"kind": "cli",
|
|
11679
|
+
"name": "commissionplan_setRemainderSink",
|
|
11680
|
+
"operation": "setRemainderSink",
|
|
11681
|
+
"objectName": "@happyvertical/smrt-sales:CommissionPlan"
|
|
11682
|
+
},
|
|
11683
|
+
{
|
|
11684
|
+
"kind": "cli",
|
|
11685
|
+
"name": "commissionplan_getWaterfallPlan",
|
|
11686
|
+
"operation": "getWaterfallPlan",
|
|
11687
|
+
"objectName": "@happyvertical/smrt-sales:CommissionPlan"
|
|
11688
|
+
},
|
|
10738
11689
|
{
|
|
10739
11690
|
"kind": "cli",
|
|
10740
11691
|
"name": "commissionplan_getMetadata",
|
|
@@ -12518,12 +13469,12 @@
|
|
|
12518
13469
|
],
|
|
12519
13470
|
"prompts": [],
|
|
12520
13471
|
"relationshipsV2": {
|
|
12521
|
-
"foreignKeyFields":
|
|
13472
|
+
"foreignKeyFields": 37,
|
|
12522
13473
|
"crossPackageRefFields": 14,
|
|
12523
13474
|
"junctionCollections": 0,
|
|
12524
13475
|
"hierarchicalObjects": 0,
|
|
12525
13476
|
"polymorphicAssociations": 0,
|
|
12526
|
-
"uuidColumns":
|
|
13477
|
+
"uuidColumns": 224
|
|
12527
13478
|
},
|
|
12528
13479
|
"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",
|
|
12529
13480
|
"moduleDocs": [
|
|
@@ -12535,7 +13486,7 @@
|
|
|
12535
13486
|
{
|
|
12536
13487
|
"path": "agents/commissions.md",
|
|
12537
13488
|
"module": "commissions",
|
|
12538
|
-
"content": "# smrt-sales/commissions — neutral financial core\n\nPer-module semantics for `@happyvertical/smrt-sales/commissions`. 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- **Earner**: `profileId`, `status` (`pending|active|suspended`), `payoutMethod` (`bank_transfer|check|paypal|credit|other`), `payoutThresholdCents`, `payoutScheduleKey` (open string: `manual`, `monthly`, …), `currency`, `metadata`.\n- **EarnerSourceAttribution** (#1986): indexed external attribution mapping `(sourceKind, sourceId) → earnerId` with `status` (`active|inactive`) — the queryable replacement for stashing associations in `Earner.metadata`. Natural key `(tenant_id, source_kind, source_id)` (one mapping per key per tenant; a re-`create` upserts/re-points; the adapters' null-aware upsert dedups NULL-tenant keys too, but duplicate global rows minted outside the model layer remain representable). The attribution kind space is consumer-defined and need not match earning-event source kinds. `EarnerAttributionService` is the public API: `registerAttribution` (idempotent; reports `created`/`previousEarnerId`; also the documented metadata-migration backfill primitive — loop earners, register each association, verify, drop the metadata key) and `resolveActiveEarnerBySource`/`resolveActiveEarnersBySources` (single/batched; 2 queries bounded by the REQUESTED ids, never a scan of active earners; fail-closed typed reasons `no_mapping|mapping_inactive|ambiguous_mapping|earner_not_found|earner_not_active` — more than one ACTIVE row for a key refuses rather than guessing). In tenant context mappings resolve within that tenant only; without context, lookups span all rows and cross-tenant duplicates surface as `ambiguous_mapping`.\n- **CommissionPlan**: versioned calculation terms. Natural key `(tenant_id, plan_key, version)` (per-tenant keys; the adapters' null-aware upsert dedups NULL-tenant keys through the model layer, though duplicate global rows minted via raw SQL remain representable); `status` (`draft|active|superseded|retired`); `effectiveFrom`. Components are a JSON-string array (`getComponents()`): each component has `key`, `trigger` (earning-event kind or `*`), `basis` (`fixed|gross|net|margin|custom`), `rate` or `fixedAmountCents`, `recurrence` (`one_time` or `recurring` with optional `maxOccurrences`/`windowMonths`). **Immutable once active** — amendments create a new row with `version + 1`; prior versions are never rewritten. `latestActiveByKey(key, at?)` resolves the highest active version **already in effect at `at`** — a future-dated amendment can be activated ahead of time without governing earlier qualifications (same rule on `AttributionPolicyCollection`).\n- **EarningEvent**: immutable commercial-event evidence (`conversion`, `agreement_execution`, `invoice_payment`, `collected_revenue`, `recognized_margin`, or any extensible kind). Carries `sourceKind`/`sourceId` (generic earning source), `grossAmountCents`/`netAmountCents`/`marginCents`, `currency`, `occurredAt`, and a `dedupeKey` natural key for idempotent ingestion. No update/delete surface, plus a save-time immutability guard: hydrated edits, blind id overwrites, and fresh creates onto an existing dedupe key all throw (the upsert would rotate the row id and orphan referencing Commissions) — idempotent ingestion goes through `getOrCreateByDedupeKey()`.\n- **Commission**: one earning record per earner per plan component per event occurrence. Integer-cents amounts (`baseAmountCents`, `amountCents`), decimal `rate`, `basis`, snapshot references (`planKey`/`planVersion`, generic `termsSnapshotKind`/`termsSnapshotId`), a JSON `calculationTrace` sufficient to reproduce the amount, split support (`splitGroupId`, `shareFraction`), and a `dedupeKey` for idempotent creation. Lifecycle `pending → earned → approved → payable → paid`, enforced by a save-time transition guard with an authoritative prior-status re-read (commerce pattern).\n- **CommissionAdjustment**: append-only corrections (`refund|credit|chargeback|dispute|correction`), signed `amountCents`, required `reason`, immutable once created. `CommissionAdjustmentService.createAdjustment()` is the tenant-required idempotent creation door: callers provide a stable operation UUID; the database creates exactly one row, exact retries return it, and changed tenant/commission/earner/kind/cents/currency/reason/operator/metadata fail with a typed replay conflict. Parent Commission plus denormalized tenant/Earner/currency and operator UUID are validated before insert. The financial row deliberately exposes no operation field. A private, required-tenant `CommissionAdjustmentOperation` table uses the globally unique operation UUID as its primary id, maps it to the adjustment UUID, and is inserted in the same transaction as the adjustment. Existing adjustment schemas and legacy direct creates remain unchanged. Earned/paid Commissions are never rewritten — adjustments append to them.\n- **Payable balance**: computed, not stored — `CommissionBalanceService` sums payable Commissions plus unsettled Adjustments per Earner/currency.\n- **CommissionPayout**: settlement batch per Earner. `pending → approved → processing → completed | failed` (`resetFromFailed()` is the only exit from failed), plus the terminal operator decline `rejected` reachable from pending/approved (#1987 — reject through `transitionPayoutForSource`, which also RELEASES the batch's membership so the rows settle through a future batch; `reject()` on the model mutates status only). Settles rows via the collections' **conditional `claimForPayout`** (model-layer get/save/re-read — tenancy- and dialect-safe; a row owned by another batch is never re-claimed) and stores totals recomputed from the VERIFIED claimed membership; idempotent via `idempotencyKey` natural key (default `${earnerId}:${currency}:${YYYY-MM-DD}`) — a clean replay touches nothing, while a pending payout whose totals disagree with its stamped rows (interrupted claim pass) is repaired on replay (the claim pass re-checks the payout is still pending first). Each batch/repair pass also derives the payout's **single-source stamp** (`sourceKind`/`sourceId`, indexed): set when every claimed commission — and every claimed adjustment through its parent commission — shares exactly one non-empty source; empty for mixed/unknown/empty membership. `completePayout` flips member commissions to `paid` BEFORE the terminal transition, so a mid-loop failure stays retryable. Enforces `totalAmountCents = commissionTotalCents + adjustmentTotalCents` at save; retains `paymentReference`/`providerRef`; optional `invoiceId` cross-package string ref to a commerce Invoice. Generated surface is read-only on ALL doors (api/mcp/cli `list`/`get`) — writes go through `CommissionPayoutService`. `createPayoutBatch` settles the whole earner+currency by default, or a **scoped** subset: pass `sourceKind`+`sourceId` to settle just one earning source (e.g. one ad network), or `commissionIds` for an explicit set (each validated payable+unsettled+earner+currency; requires its own `idempotencyKey`) — adjustments are narrowed to the same scope, and the default idempotency key folds the source in. Scoping is how concurrent per-source batches settle safely: batches scoped to different sources (or disjoint `commissionIds`) gather **disjoint** row sets and never contend. The collection layer has no cross-row transaction, so OVERLAPPING concurrent scopes (a source batch + the earner-wide batch, intersecting id sets, or a batch replay racing a lifecycle transition of the same payout) must be serialized by the caller — `claimForPayout` still won't double-own a row, but a shared commission and its adjustment could split across the two batches.\n- **Source-scoped payout history** (#1985): `CommissionPayoutService.getSourcePayoutHistory({ sourceKind, sourceId, limit?, offset? })` — one page of the payouts belonging to ONE earning source, newest first (`created_at DESC, id DESC`), offset contract (`nextOffset` advances by the scanned count; `null` when exhausted). Candidates come from the indexed stamp, so work is bounded by page size (a sparse source never scans the global history); each page is re-verified against actual membership in three batched queries (no per-payout N+1) — every member commission and every adjustment's parent must carry exactly the requested source and agree on earner/currency/tenant; unprovable rows (mixed-source, missing parents, memberless artifacts, released/rejected batches) are excluded fail-closed and reported in `excluded` with reasons. Adjustment-only payouts prove ownership through parent commissions and list normally. Payouts minted before the stamp existed are invisible until backfilled with `restampPayoutSource(payoutId)` (idempotent, any status).\n- **Source-authorized lifecycle transitions** (#1987): `CommissionPayoutService.transitionPayoutForSource({ payoutId, sourceKind, sourceId, action, expectedStatus?, paymentReference?, reason? })` — atomic alternative to load-verify-transition. Actions `approve | mark_processing | complete | fail | reject`. Everything runs on one transaction database: the payout row is locked (PostgreSQL `SELECT … FOR UPDATE`, replica-safe; single-connection engines serialize transitions per database in-process), membership is re-verified under the lock (every commission and every adjustment through its parent must carry exactly the requested source and matching earner/currency/tenant — else typed fail-closed refusals with no payout/member data), and only authorized calls receive status-derived `already_applied` or `status_conflict` outcomes. Totals are then recomputed under the lock (drift refuses the money-forward actions with `totals_drift`; repair = `createPayoutBatch` replay while pending; `fail`/`reject` proceed despite drift — reject IS the remedy), and the transition plus member writes commit or roll back together (`complete` flips members to paid in the same transaction; `reject` releases membership then declines). Outcomes: `transitioned`, `already_applied` (idempotent echo — terminal completion NEVER rewrites `paymentReference`/`providerRef`/`paidAt`), or `refused` with `{ reason, detail }`. Concurrent duplicate calls for actions that retain membership resolve as one `transitioned` + `already_applied` echoes; `reject` releases its membership evidence, so serialized replays fail `membership_empty` rather than expose rejected state. `expectedStatus` adds optimistic-concurrency strictness after authorization. Memberless batch artifacts cannot pass the source-authorized door (`membership_empty`) — they stay operator-level.\n"
|
|
13489
|
+
"content": "# smrt-sales/commissions — neutral financial core\n\nPer-module semantics for `@happyvertical/smrt-sales/commissions`. 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- **Earner**: `profileId`, `status` (`pending|active|suspended`), `payoutMethod` (`bank_transfer|check|paypal|credit|other`), `payoutThresholdCents`, `payoutScheduleKey` (open string: `manual`, `monthly`, …), `currency`, `metadata`.\n- **EarnerSourceAttribution** (#1986): indexed external attribution mapping `(sourceKind, sourceId) → earnerId` with `status` (`active|inactive`) — the queryable replacement for stashing associations in `Earner.metadata`. Natural key `(tenant_id, source_kind, source_id)` (one mapping per key per tenant; a re-`create` upserts/re-points; the adapters' null-aware upsert dedups NULL-tenant keys too, but duplicate global rows minted outside the model layer remain representable). The attribution kind space is consumer-defined and need not match earning-event source kinds. `EarnerAttributionService` is the public API: `registerAttribution` (idempotent; reports `created`/`previousEarnerId`; also the documented metadata-migration backfill primitive — loop earners, register each association, verify, drop the metadata key) and `resolveActiveEarnerBySource`/`resolveActiveEarnersBySources` (single/batched; 2 queries bounded by the REQUESTED ids, never a scan of active earners; fail-closed typed reasons `no_mapping|mapping_inactive|ambiguous_mapping|earner_not_found|earner_not_active` — more than one ACTIVE row for a key refuses rather than guessing). In tenant context mappings resolve within that tenant only; without context, lookups span all rows and cross-tenant duplicates surface as `ambiguous_mapping`.\n- **CommissionPlan**: versioned calculation terms. Natural key `(tenant_id, plan_key, version)` (per-tenant keys; the adapters' null-aware upsert dedups NULL-tenant keys through the model layer, though duplicate global rows minted via raw SQL remain representable); `status` (`draft|active|superseded|retired`); `effectiveFrom`. Components are a JSON-string array (`getComponents()`): each component has `key`, `trigger` (earning-event kind or `*`), `basis` (`fixed|gross|net|margin|custom`), `rate` or `fixedAmountCents`, `recurrence` (`one_time` or `recurring` with optional `maxOccurrences`/`windowMonths`). **Immutable once active** — amendments create a new row with `version + 1`; prior versions are never rewritten. `latestActiveByKey(key, at?)` resolves the highest active version **already in effect at `at`** — a future-dated amendment can be activated ahead of time without governing earlier qualifications (same rule on `AttributionPolicyCollection`).\n- **EarningEvent**: immutable commercial-event evidence (`conversion`, `agreement_execution`, `invoice_payment`, `collected_revenue`, `recognized_margin`, or any extensible kind). Carries `sourceKind`/`sourceId` (generic earning source), `grossAmountCents`/`netAmountCents`/`marginCents`, `currency`, `occurredAt`, and a `dedupeKey` natural key for idempotent ingestion. No update/delete surface, plus a save-time immutability guard: hydrated edits, blind id overwrites, and fresh creates onto an existing dedupe key all throw (the upsert would rotate the row id and orphan referencing Commissions) — idempotent ingestion goes through `getOrCreateByDedupeKey()`.\n- **Commission**: one earning record per earner per plan component per event occurrence. Integer-cents amounts (`baseAmountCents`, `amountCents`), decimal `rate`, `basis`, snapshot references (`planKey`/`planVersion`, generic `termsSnapshotKind`/`termsSnapshotId`), a JSON `calculationTrace` sufficient to reproduce the amount, split support (`splitGroupId`, `shareFraction`), and a `dedupeKey` for idempotent creation. Lifecycle `pending → earned → approved → payable → paid`, enforced by a save-time transition guard with an authoritative prior-status re-read (commerce pattern).\n- **CommissionAdjustment**: append-only corrections (`refund|credit|chargeback|dispute|correction`), signed `amountCents`, required `reason`, immutable once created. `CommissionAdjustmentService.createAdjustment()` is the tenant-required idempotent creation door: callers provide a stable operation UUID; the database creates exactly one row, exact retries return it, and changed tenant/commission/earner/kind/cents/currency/reason/operator/metadata fail with a typed replay conflict. Parent Commission plus denormalized tenant/Earner/currency and operator UUID are validated before insert. The financial row deliberately exposes no operation field. A private, required-tenant `CommissionAdjustmentOperation` table uses the globally unique operation UUID as its primary id, maps it to the adjustment UUID, and is inserted in the same transaction as the adjustment. Claims tolerate either primary-key or tenant/slug/context uniqueness arbitration without aborting the transaction; only the tenant-scoped operation UUID lookup and immutable intent comparison authorize a replay. Existing adjustment schemas and legacy direct creates remain unchanged. Earned/paid Commissions are never rewritten — adjustments append to them.\n- **Payable balance**: computed, not stored — `CommissionBalanceService` sums payable Commissions plus unsettled Adjustments per Earner/currency.\n- **CommissionPayout**: settlement batch per Earner. `pending → approved → processing → completed | failed` (`resetFromFailed()` is the only exit from failed), plus the terminal operator decline `rejected` reachable from pending/approved (#1987 — reject through `transitionPayoutForSource`, which also RELEASES the batch's membership so the rows settle through a future batch; `reject()` on the model mutates status only). Settles rows via the collections' **conditional `claimForPayout`** (model-layer get/save/re-read — tenancy- and dialect-safe; a row owned by another batch is never re-claimed) and stores totals recomputed from the VERIFIED claimed membership; idempotent via `idempotencyKey` natural key (default `${earnerId}:${currency}:${YYYY-MM-DD}`) — a clean replay touches nothing, while a pending payout whose totals disagree with its stamped rows (interrupted claim pass) is repaired on replay (the claim pass re-checks the payout is still pending first). Each batch/repair pass also derives the payout's **single-source stamp** (`sourceKind`/`sourceId`, indexed): set when every claimed commission — and every claimed adjustment through its parent commission — shares exactly one non-empty source; empty for mixed/unknown/empty membership. `completePayout` flips member commissions to `paid` BEFORE the terminal transition, so a mid-loop failure stays retryable. Enforces `totalAmountCents = commissionTotalCents + adjustmentTotalCents` at save; retains `paymentReference`/`providerRef`; optional `invoiceId` cross-package string ref to a commerce Invoice. Generated surface is read-only on ALL doors (api/mcp/cli `list`/`get`) — writes go through `CommissionPayoutService`. `createPayoutBatch` settles the whole earner+currency by default, or a **scoped** subset: pass `sourceKind`+`sourceId` to settle just one earning source (e.g. one ad network), or `commissionIds` for an explicit set (each validated payable+unsettled+earner+currency; requires its own `idempotencyKey`) — adjustments are narrowed to the same scope, and the default idempotency key folds the source in. Scoping is how concurrent per-source batches settle safely: batches scoped to different sources (or disjoint `commissionIds`) gather **disjoint** row sets and never contend. The collection layer has no cross-row transaction, so OVERLAPPING concurrent scopes (a source batch + the earner-wide batch, intersecting id sets, or a batch replay racing a lifecycle transition of the same payout) must be serialized by the caller — `claimForPayout` still won't double-own a row, but a shared commission and its adjustment could split across the two batches.\n- **Source-scoped payout history** (#1985): `CommissionPayoutService.getSourcePayoutHistory({ sourceKind, sourceId, limit?, offset? })` — one page of the payouts belonging to ONE earning source, newest first (`created_at DESC, id DESC`), offset contract (`nextOffset` advances by the scanned count; `null` when exhausted). Candidates come from the indexed stamp, so work is bounded by page size (a sparse source never scans the global history); each page is re-verified against actual membership in three batched queries (no per-payout N+1) — every member commission and every adjustment's parent must carry exactly the requested source and agree on earner/currency/tenant; unprovable rows (mixed-source, missing parents, memberless artifacts, released/rejected batches) are excluded fail-closed and reported in `excluded` with reasons. Adjustment-only payouts prove ownership through parent commissions and list normally. Payouts minted before the stamp existed are invisible until backfilled with `restampPayoutSource(payoutId)` (idempotent, any status).\n- **Source-authorized lifecycle transitions** (#1987): `CommissionPayoutService.transitionPayoutForSource({ payoutId, sourceKind, sourceId, action, expectedStatus?, paymentReference?, reason? })` — atomic alternative to load-verify-transition. Actions `approve | mark_processing | complete | fail | reject`. Everything runs on one transaction database: the payout row is locked (PostgreSQL `SELECT … FOR UPDATE`, replica-safe; single-connection engines serialize transitions per database in-process), membership is re-verified under the lock (every commission and every adjustment through its parent must carry exactly the requested source and matching earner/currency/tenant — else typed fail-closed refusals with no payout/member data), and only authorized calls receive status-derived `already_applied` or `status_conflict` outcomes. Totals are then recomputed under the lock (drift refuses the money-forward actions with `totals_drift`; repair = `createPayoutBatch` replay while pending; `fail`/`reject` proceed despite drift — reject IS the remedy), and the transition plus member writes commit or roll back together (`complete` flips members to paid in the same transaction; `reject` releases membership then declines). Outcomes: `transitioned`, `already_applied` (idempotent echo — terminal completion NEVER rewrites `paymentReference`/`providerRef`/`paidAt`), or `refused` with `{ reason, detail }`. Concurrent duplicate calls for actions that retain membership resolve as one `transitioned` + `already_applied` echoes; `reject` releases its membership evidence, so serialized replays fail `membership_empty` rather than expose rejected state. `expectedStatus` adds optimistic-concurrency strictness after authorization. Memberless batch artifacts cannot pass the source-authorized door (`membership_empty`) — they stay operator-level.\n"
|
|
12539
13490
|
},
|
|
12540
13491
|
{
|
|
12541
13492
|
"path": "agents/crm.md",
|
|
@@ -12545,7 +13496,7 @@
|
|
|
12545
13496
|
{
|
|
12546
13497
|
"path": "agents/referrals.md",
|
|
12547
13498
|
"module": "referrals",
|
|
12548
|
-
"content": "# smrt-sales/referrals\n\nPer-module semantics for `@happyvertical/smrt-sales/referrals`. 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- **Referrer**: role model (`profileId`, `earnerId`, `status`).\n- **ReferralProgram**: program defaults — default commission plan key, default attribution policy key, eligibility defaults.\n- **AttributionPolicy**: versioned `(tenant_id, policy_key, version)` policy (per-tenant keys) — attribution `windowDays`, credit mode (`first_touch|last_touch|assigned|split`), split shares, self-referral/existing-client eligibility, eligible services/campaigns/regions, conflict behavior. Immutable once active; amendments bump `version`.\n- **ReferralLink**: shareable link/code per Referrer+Program. Codes are crypto-random and uniqueness-checked. `ReferralLinkCollection.recordClick()` transactionally creates one immutable touch plus one counter increment behind a caller replay key. Exact retries return the original touch; changed link/subject/time/evidence intent raises `ReferralClickReplayConflictError`. Replay comparison uses the immutable operation/touch snapshot, so later mutable link edits do not invalidate the retry; the result carries the current link and original touch evidence. The exact canonical persisted evidence JSON, after Sales overwrites `code`, `linkId`, and `targetUrl`, is bounded to 4096 UTF-8 bytes by default (`maxEvidenceBytes` customizes it). By default the click self-transacts and rehydrates results after commit; inside a caller's open transaction it must participate instead — pass the transaction database as `RecordClickInput.transaction`, or call it on a collection bound to that transaction, and the click joins the caller's atomicity with results bound to that transaction (#2083).\n- **ReferralTouch**: immutable attribution evidence (`click|code_entry|manual_assignment|partner_entry`) with subject hints and evidence JSON.\n- **Referral**: the introduction — generic qualifying target (`targetKind`/`targetId`: lead, opportunity, client, project, subscription, …), resolved policy version, credit fraction (splits create sibling Referrals sharing `splitGroupId`), lifecycle `pending → attributed → qualified | disqualified | expired | under_review`.\n- **AttributionException**: conflict review queue. Conclusive policy resolves automatically; ambiguity creates an exception; overrides require a `resolutionReason` and are audited.\n- **ReferralAgreement**: versioned per-Referrer terms binding — pins `commissionPlanKey`/`planVersion`, effective dating, and an immutable `ExecutedAgreement` before activation. Amendments are fresh unsigned drafts and never inherit execution evidence.\n- **ReferralTermSnapshot**: immutable at qualification — freezes agreement/plan/policy version refs plus the calculation inputs needed to reproduce every later earning.\n- **Services**: `ReferralAgreementExecutionService` binds generated Referral Agreement versions to the generic execution service and activates/supersedes them transactionally with future-effective amendment support; `AttributionService`, `ReferralQualificationService`, and `ReferralCommissionService` retain their existing attribution/qualification/earning responsibilities.\n"
|
|
13499
|
+
"content": "# smrt-sales/referrals\n\nPer-module semantics for `@happyvertical/smrt-sales/referrals`. 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- **Referrer**: role model (`profileId`, `earnerId`, `status`).\n- **ReferralProgram**: program defaults — default commission plan key, default attribution policy key, eligibility defaults.\n- **AttributionPolicy**: versioned `(tenant_id, policy_key, version)` policy (per-tenant keys) — attribution `windowDays`, credit mode (`first_touch|last_touch|assigned|split`), split shares, self-referral/existing-client eligibility, eligible services/campaigns/regions, conflict behavior. Immutable once active; amendments bump `version`.\n- **ReferralLink**: shareable link/code per Referrer+Program. Codes are crypto-random and uniqueness-checked. `ReferralLinkCollection.recordClick()` transactionally creates one immutable touch plus one counter increment behind a caller replay key. Exact retries return the original touch; changed link/subject/time/evidence intent raises `ReferralClickReplayConflictError`. Replay comparison uses the immutable operation/touch snapshot, so later mutable link edits do not invalidate the retry; the result carries the current link and original touch evidence. The exact canonical persisted evidence JSON, after Sales overwrites `code`, `linkId`, and `targetUrl`, is bounded to 4096 UTF-8 bytes by default (`maxEvidenceBytes` customizes it). By default the click self-transacts and rehydrates results after commit; inside a caller's open transaction it must participate instead — pass the transaction database as `RecordClickInput.transaction`, or call it on a collection bound to that transaction, and the click joins the caller's atomicity with results bound to that transaction (#2083).\n- **ReferralTouch**: immutable attribution evidence (`click|code_entry|manual_assignment|partner_entry`) with subject hints and evidence JSON.\n- **Referral**: the introduction — generic qualifying target (`targetKind`/`targetId`: lead, opportunity, client, project, subscription, …), resolved policy version, credit fraction (splits create sibling Referrals sharing `splitGroupId`), lifecycle `pending → attributed → qualified | disqualified | expired | under_review`.\n- **AttributionException**: conflict review queue. Conclusive policy resolves automatically; ambiguity creates an exception; overrides require a `resolutionReason` and are audited.\n- **ReferralAgreement**: versioned per-Referrer terms binding — pins `commissionPlanKey`/`planVersion`, effective dating, and an immutable `ExecutedAgreement` before activation. Amendments are fresh unsigned drafts and never inherit execution evidence.\n- **Plan compatibility**: qualification and requalification accept only v1 component plans. A pinned or latest-active v2 waterfall plan returns `unsupported_plan_engine` before snapshot/referral writes; existing snapshots remain valid and unchanged. Bind compatible component terms and retry to recover. Engine changes under a plan key never implicitly migrate referrals.\n- **ReferralTermSnapshot**: immutable at qualification — freezes agreement/plan/policy version refs plus the calculation inputs needed to reproduce every later earning.\n- **Services**: `ReferralAgreementExecutionService` binds generated Referral Agreement versions to the generic execution service and activates/supersedes them transactionally with future-effective amendment support; `AttributionService`, `ReferralQualificationService`, and `ReferralCommissionService` retain their existing attribution/qualification/earning responsibilities.\n"
|
|
12549
13500
|
},
|
|
12550
13501
|
{
|
|
12551
13502
|
"path": "agents/svelte.md",
|