@happyvertical/smrt-sales 0.40.0 → 0.40.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +14 -6
- package/dist/agreements/collections/AgreementExecutionCollection.d.ts +106 -0
- package/dist/agreements/collections/AgreementExecutionCollection.d.ts.map +1 -0
- package/dist/agreements/collections/AgreementExecutionEventCollection.d.ts +16 -0
- package/dist/agreements/collections/AgreementExecutionEventCollection.d.ts.map +1 -0
- package/dist/agreements/collections/ExecutedAgreementCollection.d.ts +17 -0
- package/dist/agreements/collections/ExecutedAgreementCollection.d.ts.map +1 -0
- package/dist/agreements/index.d.ts +18 -0
- package/dist/agreements/index.d.ts.map +1 -0
- package/dist/agreements/models/AgreementExecution.d.ts +66 -0
- package/dist/agreements/models/AgreementExecution.d.ts.map +1 -0
- package/dist/agreements/models/AgreementExecutionEvent.d.ts +25 -0
- package/dist/agreements/models/AgreementExecutionEvent.d.ts.map +1 -0
- package/dist/agreements/models/ExecutedAgreement.d.ts +35 -0
- package/dist/agreements/models/ExecutedAgreement.d.ts.map +1 -0
- package/dist/agreements/services/AgreementExecutionService.d.ts +85 -0
- package/dist/agreements/services/AgreementExecutionService.d.ts.map +1 -0
- package/dist/agreements/types.d.ts +140 -0
- package/dist/agreements/types.d.ts.map +1 -0
- package/dist/agreements.d.ts +2 -0
- package/dist/agreements.d.ts.map +1 -0
- package/dist/agreements.js +3 -0
- package/dist/chunks/__smrt-register__-Cwn1Fb4I.js +6 -0
- package/dist/chunks/{__smrt-register__-DGR1u9K2.js.map → __smrt-register__-Cwn1Fb4I.js.map} +1 -1
- package/dist/chunks/agreements-DbzW1Pcq.js +1640 -0
- package/dist/chunks/agreements-DbzW1Pcq.js.map +1 -0
- package/dist/chunks/{referrals-CzkrPeKv.js → referrals-cYYg4YZw.js} +163 -40
- package/dist/chunks/referrals-cYYg4YZw.js.map +1 -0
- package/dist/commissions.js +1 -1
- package/dist/crm.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/manifest.json +1853 -99
- package/dist/referrals/collections/ReferralAgreementCollection.d.ts +0 -4
- package/dist/referrals/collections/ReferralAgreementCollection.d.ts.map +1 -1
- package/dist/referrals/index.d.ts +1 -0
- package/dist/referrals/index.d.ts.map +1 -1
- package/dist/referrals/models/ReferralAgreement.d.ts +8 -19
- package/dist/referrals/models/ReferralAgreement.d.ts.map +1 -1
- package/dist/referrals/services/ReferralAgreementExecutionService.d.ts +55 -0
- package/dist/referrals/services/ReferralAgreementExecutionService.d.ts.map +1 -0
- package/dist/referrals/types.d.ts +2 -4
- package/dist/referrals/types.d.ts.map +1 -1
- package/dist/referrals.js +3 -3
- package/dist/smrt-knowledge.json +780 -33
- package/dist/svelte/components/ExecutedAgreementsList.svelte +36 -10
- package/dist/svelte/components/ExecutedAgreementsList.svelte.d.ts +2 -0
- package/dist/svelte/components/ExecutedAgreementsList.svelte.d.ts.map +1 -1
- package/dist/svelte/types.d.ts +7 -3
- package/dist/svelte/types.d.ts.map +1 -1
- package/package.json +13 -7
- package/dist/chunks/__smrt-register__-DGR1u9K2.js +0 -6
- package/dist/chunks/referrals-CzkrPeKv.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { g as CommissionPlanCollection, i as CommissionCalculationService, j as CommissionCollection } from "./commissions-pI_MmBxN.js";
|
|
2
2
|
import { SmrtCollection, SmrtObject, crossPackageRef, field, foreignKey, smrt } from "@happyvertical/smrt-core";
|
|
3
|
-
import { TenantScoped, tenantId } from "@happyvertical/smrt-tenancy";
|
|
3
|
+
import { TenantScoped, requireTenantId, tenantId } from "@happyvertical/smrt-tenancy";
|
|
4
4
|
import { randomBytes, randomUUID } from "node:crypto";
|
|
5
5
|
//#region src/referrals/models/AttributionException.ts
|
|
6
6
|
var __defProp$8 = Object.defineProperty;
|
|
@@ -657,17 +657,8 @@ var ReferralAgreement = class extends SmrtObject {
|
|
|
657
657
|
clearingDays = 0;
|
|
658
658
|
/** How earned commissions are approved downstream. */
|
|
659
659
|
approvalMode = "manual";
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
executedArtifactUrl = "";
|
|
663
|
-
/** Content hash of the executed artifact for tamper evidence. */
|
|
664
|
-
executedArtifactHash = "";
|
|
665
|
-
/**
|
|
666
|
-
* Acceptance evidence as a JSON object string (click-through record, IP,
|
|
667
|
-
* timestamp, signer, …). Use
|
|
668
|
-
* {@link getAcceptanceEvidence}/{@link setAcceptanceEvidence}.
|
|
669
|
-
*/
|
|
670
|
-
acceptanceEvidence = "{}";
|
|
660
|
+
executionId = "";
|
|
661
|
+
executedAgreementId = "";
|
|
671
662
|
/**
|
|
672
663
|
* Free-form JSON object stored as a string. Use
|
|
673
664
|
* {@link getMetadata}/{@link setMetadata} instead of parsing manually.
|
|
@@ -686,10 +677,8 @@ var ReferralAgreement = class extends SmrtObject {
|
|
|
686
677
|
if (options.commissionPlanVersion !== void 0) this.commissionPlanVersion = options.commissionPlanVersion;
|
|
687
678
|
if (options.clearingDays !== void 0) this.clearingDays = options.clearingDays;
|
|
688
679
|
if (options.approvalMode !== void 0) this.approvalMode = options.approvalMode;
|
|
689
|
-
if (options.
|
|
690
|
-
if (options.
|
|
691
|
-
if (options.executedArtifactHash !== void 0) this.executedArtifactHash = options.executedArtifactHash;
|
|
692
|
-
if (options.acceptanceEvidence !== void 0) this.acceptanceEvidence = options.acceptanceEvidence;
|
|
680
|
+
if (options.executionId !== void 0) this.executionId = options.executionId;
|
|
681
|
+
if (options.executedAgreementId !== void 0) this.executedAgreementId = options.executedAgreementId;
|
|
693
682
|
if (options.metadata !== void 0) this.metadata = options.metadata;
|
|
694
683
|
}
|
|
695
684
|
/**
|
|
@@ -702,7 +691,7 @@ var ReferralAgreement = class extends SmrtObject {
|
|
|
702
691
|
await super.initialize();
|
|
703
692
|
this.effectiveFrom = ReferralAgreement.coerceDate(this.effectiveFrom);
|
|
704
693
|
this.effectiveTo = ReferralAgreement.coerceDate(this.effectiveTo);
|
|
705
|
-
if (
|
|
694
|
+
if (this.isPersisted) {
|
|
706
695
|
loadedAgreementStatus.set(this, this.status);
|
|
707
696
|
if (this.status !== "draft") frozenAgreementSnapshot.set(this, this.serializeFrozenTerms());
|
|
708
697
|
}
|
|
@@ -724,20 +713,6 @@ var ReferralAgreement = class extends SmrtObject {
|
|
|
724
713
|
if (this.effectiveTo && at.getTime() > this.effectiveTo.getTime()) return false;
|
|
725
714
|
return true;
|
|
726
715
|
}
|
|
727
|
-
/** Parse {@link acceptanceEvidence}; returns `{}` on malformed content. */
|
|
728
|
-
getAcceptanceEvidence() {
|
|
729
|
-
if (!this.acceptanceEvidence) return {};
|
|
730
|
-
try {
|
|
731
|
-
const parsed = JSON.parse(this.acceptanceEvidence);
|
|
732
|
-
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
|
|
733
|
-
} catch {
|
|
734
|
-
return {};
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
/** Serialize and store {@link acceptanceEvidence}. */
|
|
738
|
-
setAcceptanceEvidence(evidence) {
|
|
739
|
-
this.acceptanceEvidence = JSON.stringify(evidence ?? {});
|
|
740
|
-
}
|
|
741
716
|
/** Parse {@link metadata}; returns `{}` on malformed content. */
|
|
742
717
|
getMetadata() {
|
|
743
718
|
if (!this.metadata) return {};
|
|
@@ -760,8 +735,24 @@ var ReferralAgreement = class extends SmrtObject {
|
|
|
760
735
|
activate() {
|
|
761
736
|
if (this.status !== "draft") throw new Error(`ReferralAgreement ${this.referrerId}/${this.programId}@${this.version}: cannot activate from status '${this.status}'`);
|
|
762
737
|
if (!this.commissionPlanKey) throw new Error(`ReferralAgreement ${this.referrerId}/${this.programId}@${this.version}: commissionPlanKey is required to activate`);
|
|
738
|
+
if (!this.executionId || !this.executedAgreementId) throw new Error(`ReferralAgreement ${this.referrerId}/${this.programId}@${this.version}: AgreementExecution and immutable ExecutedAgreement evidence are required to activate`);
|
|
763
739
|
this.status = "active";
|
|
764
740
|
}
|
|
741
|
+
/** Bind the provider workflow to an unsigned draft. */
|
|
742
|
+
bindExecution(executionId) {
|
|
743
|
+
if (this.status !== "draft") throw new Error("Only draft ReferralAgreements can bind an execution");
|
|
744
|
+
if (!executionId) throw new Error("executionId is required");
|
|
745
|
+
if (this.executionId && this.executionId !== executionId) throw new Error("ReferralAgreement is already bound to another execution");
|
|
746
|
+
this.executionId = executionId;
|
|
747
|
+
}
|
|
748
|
+
/** Bind immutable completed evidence to an unsigned draft. */
|
|
749
|
+
bindExecutedAgreement(executedAgreementId) {
|
|
750
|
+
if (this.status !== "draft") throw new Error("Only draft ReferralAgreements can bind executed evidence");
|
|
751
|
+
if (!this.executionId) throw new Error("Bind the AgreementExecution before its executed evidence");
|
|
752
|
+
if (!executedAgreementId) throw new Error("executedAgreementId is required");
|
|
753
|
+
if (this.executedAgreementId && this.executedAgreementId !== executedAgreementId) throw new Error("ReferralAgreement is already bound to different executed evidence");
|
|
754
|
+
this.executedAgreementId = executedAgreementId;
|
|
755
|
+
}
|
|
765
756
|
/** Transition `active → superseded` (a newer version took over). */
|
|
766
757
|
supersede() {
|
|
767
758
|
if (this.status !== "active") throw new Error(`ReferralAgreement ${this.referrerId}/${this.programId}@${this.version}: cannot supersede from status '${this.status}'`);
|
|
@@ -788,7 +779,10 @@ var ReferralAgreement = class extends SmrtObject {
|
|
|
788
779
|
this.assertStatusTransition(prior);
|
|
789
780
|
this.assertFrozenTermsUnchanged();
|
|
790
781
|
await this.assertNaturalKeyNotTaken();
|
|
791
|
-
if (this.status === "active"
|
|
782
|
+
if (this.status === "active") {
|
|
783
|
+
if (!this.commissionPlanKey) throw new Error(`ReferralAgreement ${this.referrerId}/${this.programId}@${this.version}: commissionPlanKey is required while active`);
|
|
784
|
+
if (!this.executionId || !this.executedAgreementId) throw new Error(`ReferralAgreement ${this.referrerId}/${this.programId}@${this.version}: AgreementExecution and ExecutedAgreement evidence are required while active`);
|
|
785
|
+
}
|
|
792
786
|
const result = await super.save();
|
|
793
787
|
loadedAgreementStatus.set(this, this.status);
|
|
794
788
|
if (this.status !== "draft" && !frozenAgreementSnapshot.has(this)) frozenAgreementSnapshot.set(this, this.serializeFrozenTerms());
|
|
@@ -838,7 +832,9 @@ var ReferralAgreement = class extends SmrtObject {
|
|
|
838
832
|
commissionPlanVersion: this.commissionPlanVersion,
|
|
839
833
|
clearingDays: this.clearingDays,
|
|
840
834
|
approvalMode: this.approvalMode,
|
|
841
|
-
effectiveFrom: this.effectiveFrom ? this.effectiveFrom.toISOString() : null
|
|
835
|
+
effectiveFrom: this.effectiveFrom ? this.effectiveFrom.toISOString() : null,
|
|
836
|
+
executionId: this.executionId,
|
|
837
|
+
executedAgreementId: this.executedAgreementId
|
|
842
838
|
});
|
|
843
839
|
}
|
|
844
840
|
static coerceDate(value) {
|
|
@@ -854,7 +850,8 @@ var ReferralAgreement = class extends SmrtObject {
|
|
|
854
850
|
__decorateClass$6([tenantId({ nullable: true })], ReferralAgreement.prototype, "tenantId", 2);
|
|
855
851
|
__decorateClass$6([foreignKey("Referrer", { required: true })], ReferralAgreement.prototype, "referrerId", 2);
|
|
856
852
|
__decorateClass$6([foreignKey("ReferralProgram", { required: true })], ReferralAgreement.prototype, "programId", 2);
|
|
857
|
-
__decorateClass$6([
|
|
853
|
+
__decorateClass$6([foreignKey("AgreementExecution")], ReferralAgreement.prototype, "executionId", 2);
|
|
854
|
+
__decorateClass$6([foreignKey("ExecutedAgreement")], ReferralAgreement.prototype, "executedAgreementId", 2);
|
|
858
855
|
ReferralAgreement = __decorateClass$6([TenantScoped({ mode: "optional" }), smrt({
|
|
859
856
|
conflictColumns: [
|
|
860
857
|
"referrer_id",
|
|
@@ -926,10 +923,8 @@ var ReferralAgreementCollection = class extends SmrtCollection {
|
|
|
926
923
|
approvalMode: changes.approvalMode ?? latest.approvalMode,
|
|
927
924
|
effectiveFrom: changes.effectiveFrom !== void 0 ? changes.effectiveFrom : latest.effectiveFrom,
|
|
928
925
|
effectiveTo: changes.effectiveTo !== void 0 ? changes.effectiveTo : latest.effectiveTo,
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
executedArtifactHash: changes.executedArtifactHash ?? latest.executedArtifactHash,
|
|
932
|
-
acceptanceEvidence: changes.acceptanceEvidence !== void 0 ? JSON.stringify(changes.acceptanceEvidence) : latest.acceptanceEvidence,
|
|
926
|
+
executionId: "",
|
|
927
|
+
executedAgreementId: "",
|
|
933
928
|
metadata: changes.metadata !== void 0 ? JSON.stringify(changes.metadata) : latest.metadata
|
|
934
929
|
});
|
|
935
930
|
}
|
|
@@ -2516,6 +2511,134 @@ var AttributionService = class AttributionService {
|
|
|
2516
2511
|
}
|
|
2517
2512
|
};
|
|
2518
2513
|
//#endregion
|
|
2514
|
+
//#region src/referrals/services/ReferralAgreementExecutionService.ts
|
|
2515
|
+
var REFERRAL_AGREEMENT_SOURCE_KIND = "referral_agreement";
|
|
2516
|
+
var ReferralAgreementExecutionService = class {
|
|
2517
|
+
constructor(deps) {
|
|
2518
|
+
this.deps = deps;
|
|
2519
|
+
this.now = deps.now ?? (() => /* @__PURE__ */ new Date());
|
|
2520
|
+
}
|
|
2521
|
+
deps;
|
|
2522
|
+
now;
|
|
2523
|
+
async requestSignature(input) {
|
|
2524
|
+
this.assertTenant(input.tenantId);
|
|
2525
|
+
const agreement = await this.requireAgreement(input.agreementId);
|
|
2526
|
+
this.assertAgreementTenant(agreement, input.tenantId);
|
|
2527
|
+
if (!agreement.id || agreement.status !== "draft") throw new Error("Only a persisted draft ReferralAgreement can be sent");
|
|
2528
|
+
if (agreement.executedAgreementId) throw new Error("ReferralAgreement already has immutable executed evidence");
|
|
2529
|
+
const prior = await this.findPriorActive(agreement);
|
|
2530
|
+
const idempotencyKey = `${input.tenantId}:${REFERRAL_AGREEMENT_SOURCE_KIND}:${agreement.id}:v${agreement.version}`;
|
|
2531
|
+
let result;
|
|
2532
|
+
try {
|
|
2533
|
+
result = await this.deps.executionService.createExecution({
|
|
2534
|
+
tenantId: input.tenantId,
|
|
2535
|
+
idempotencyKey,
|
|
2536
|
+
sourceKind: REFERRAL_AGREEMENT_SOURCE_KIND,
|
|
2537
|
+
sourceId: agreement.id,
|
|
2538
|
+
sourceVersion: agreement.version,
|
|
2539
|
+
title: input.title ?? `Referral Agreement v${agreement.version}`,
|
|
2540
|
+
document: input.document,
|
|
2541
|
+
signers: input.signers,
|
|
2542
|
+
...input.message ? { message: input.message } : {},
|
|
2543
|
+
...input.signingOrder !== void 0 ? { signingOrder: input.signingOrder } : {},
|
|
2544
|
+
...input.expiresInDays !== void 0 ? { expiresInDays: input.expiresInDays } : {},
|
|
2545
|
+
...input.providerAccountRef ? { providerAccountRef: input.providerAccountRef } : {},
|
|
2546
|
+
...input.credentialRef ? { credentialRef: input.credentialRef } : {},
|
|
2547
|
+
effectiveFrom: agreement.effectiveFrom,
|
|
2548
|
+
effectiveTo: agreement.effectiveTo,
|
|
2549
|
+
supersedesExecutedAgreementId: prior?.executedAgreementId ?? "",
|
|
2550
|
+
metadata: {
|
|
2551
|
+
referralAgreementId: agreement.id,
|
|
2552
|
+
referralAgreementVersion: String(agreement.version),
|
|
2553
|
+
referrerId: agreement.referrerId,
|
|
2554
|
+
programId: agreement.programId
|
|
2555
|
+
},
|
|
2556
|
+
...input.signal ? { signal: input.signal } : {}
|
|
2557
|
+
});
|
|
2558
|
+
} catch (error) {
|
|
2559
|
+
const persisted = await this.deps.executions.findByIdempotencyKey(idempotencyKey);
|
|
2560
|
+
if (persisted?.id) {
|
|
2561
|
+
agreement.bindExecution(persisted.id);
|
|
2562
|
+
await agreement.save();
|
|
2563
|
+
}
|
|
2564
|
+
throw error;
|
|
2565
|
+
}
|
|
2566
|
+
agreement.bindExecution(result.executionId);
|
|
2567
|
+
await agreement.save();
|
|
2568
|
+
return result;
|
|
2569
|
+
}
|
|
2570
|
+
/**
|
|
2571
|
+
* Bind completed immutable evidence, activate the signed version, and end
|
|
2572
|
+
* the prior active version only when the new effective date has arrived.
|
|
2573
|
+
*/
|
|
2574
|
+
async applyExecutedAgreement(input) {
|
|
2575
|
+
this.assertTenant(input.tenantId);
|
|
2576
|
+
const loaded = await this.requireAgreement(input.agreementId);
|
|
2577
|
+
this.assertAgreementTenant(loaded, input.tenantId);
|
|
2578
|
+
if (!loaded.executionId) throw new Error("ReferralAgreement has no AgreementExecution");
|
|
2579
|
+
const executed = input.executedAgreementId ? await this.deps.executedAgreements.get({ id: input.executedAgreementId }) : await this.deps.executedAgreements.findByExecution(loaded.executionId);
|
|
2580
|
+
if (!executed?.id) throw new Error("Completed immutable ExecutedAgreement evidence was not found");
|
|
2581
|
+
const executedId = executed.id;
|
|
2582
|
+
if (executed.executionId !== loaded.executionId || executed.sourceKind !== "referral_agreement" || executed.sourceId !== loaded.id || executed.sourceVersion !== loaded.version || executed.tenantId !== input.tenantId) throw new Error("ExecutedAgreement does not belong to this ReferralAgreement version");
|
|
2583
|
+
const at = input.at ?? this.now();
|
|
2584
|
+
const agreementId = await this.runTransaction(async (agreements) => {
|
|
2585
|
+
const agreement = await agreements.get({ id: input.agreementId });
|
|
2586
|
+
if (!agreement) throw new Error("ReferralAgreement disappeared");
|
|
2587
|
+
if (agreement.status === "active" && agreement.executedAgreementId === executedId) return agreement.id;
|
|
2588
|
+
if (agreement.status !== "draft") throw new Error(`ReferralAgreement cannot accept executed evidence from status '${agreement.status}'`);
|
|
2589
|
+
agreement.bindExecutedAgreement(executedId);
|
|
2590
|
+
agreement.effectiveFrom ??= executed.effectiveFrom;
|
|
2591
|
+
agreement.activate();
|
|
2592
|
+
await agreement.save();
|
|
2593
|
+
if (!agreement.effectiveFrom || agreement.effectiveFrom <= at) await this.supersedePriors(agreements, agreement, at);
|
|
2594
|
+
return agreement.id;
|
|
2595
|
+
});
|
|
2596
|
+
return await this.requireAgreement(agreementId);
|
|
2597
|
+
}
|
|
2598
|
+
/** Scheduled/reconciliation hook for future-dated signed amendments. */
|
|
2599
|
+
async supersedePriorIfEffective(input) {
|
|
2600
|
+
this.assertTenant(input.tenantId);
|
|
2601
|
+
const at = input.at ?? this.now();
|
|
2602
|
+
const agreementId = await this.runTransaction(async (agreements) => {
|
|
2603
|
+
const agreement = await agreements.get({ id: input.agreementId });
|
|
2604
|
+
if (agreement?.status !== "active") throw new Error("Signed active ReferralAgreement was not found");
|
|
2605
|
+
this.assertAgreementTenant(agreement, input.tenantId);
|
|
2606
|
+
if (agreement.effectiveFrom && agreement.effectiveFrom > at) return agreement.id;
|
|
2607
|
+
await this.supersedePriors(agreements, agreement, at);
|
|
2608
|
+
return agreement.id;
|
|
2609
|
+
});
|
|
2610
|
+
return await this.requireAgreement(agreementId);
|
|
2611
|
+
}
|
|
2612
|
+
async supersedePriors(agreements, agreement, at) {
|
|
2613
|
+
const priors = (await agreements.findByReferrerAndProgram(agreement.referrerId, agreement.programId)).filter((candidate) => candidate.id !== agreement.id && candidate.status === "active" && candidate.version < agreement.version);
|
|
2614
|
+
for (const prior of priors) {
|
|
2615
|
+
const supersededAt = agreement.effectiveFrom ?? at;
|
|
2616
|
+
if (!prior.effectiveTo || prior.effectiveTo > supersededAt) prior.effectiveTo = supersededAt;
|
|
2617
|
+
prior.supersede();
|
|
2618
|
+
await prior.save();
|
|
2619
|
+
}
|
|
2620
|
+
}
|
|
2621
|
+
async findPriorActive(agreement) {
|
|
2622
|
+
return (await this.deps.agreements.findByReferrerAndProgram(agreement.referrerId, agreement.programId)).find((candidate) => candidate.id !== agreement.id && candidate.status === "active" && candidate.version < agreement.version) ?? null;
|
|
2623
|
+
}
|
|
2624
|
+
async requireAgreement(id) {
|
|
2625
|
+
const agreement = await this.deps.agreements.get({ id });
|
|
2626
|
+
if (!agreement) throw new Error(`ReferralAgreement '${id}' was not found`);
|
|
2627
|
+
return agreement;
|
|
2628
|
+
}
|
|
2629
|
+
async runTransaction(fn) {
|
|
2630
|
+
const db = this.deps.agreements.db;
|
|
2631
|
+
if (typeof db.transaction !== "function") return await fn(this.deps.agreements);
|
|
2632
|
+
return await db.transaction(async (tx) => fn(await ReferralAgreementCollection.create({ db: tx })));
|
|
2633
|
+
}
|
|
2634
|
+
assertTenant(tenantId) {
|
|
2635
|
+
if (requireTenantId() !== tenantId) throw new Error("ReferralAgreement execution tenant mismatch");
|
|
2636
|
+
}
|
|
2637
|
+
assertAgreementTenant(agreement, tenantId) {
|
|
2638
|
+
if (agreement.tenantId !== tenantId) throw new Error("ReferralAgreement does not belong to the active tenant");
|
|
2639
|
+
}
|
|
2640
|
+
};
|
|
2641
|
+
//#endregion
|
|
2519
2642
|
//#region src/referrals/services/ReferralCommissionService.ts
|
|
2520
2643
|
var REFERRAL_TERMS_SNAPSHOT_KIND = "referral_term_snapshot";
|
|
2521
2644
|
var ReferralCommissionService = class ReferralCommissionService {
|
|
@@ -2875,6 +2998,6 @@ var ReferralQualificationService = class ReferralQualificationService {
|
|
|
2875
2998
|
}
|
|
2876
2999
|
};
|
|
2877
3000
|
//#endregion
|
|
2878
|
-
export {
|
|
3001
|
+
export { ATTRIBUTION_CONFLICT_BEHAVIORS as A, REFERRAL_TOUCH_KINDS as B, ReferralCollection as C, AttributionPolicyCollection as D, ReferralAgreement as E, REFERRAL_AGREEMENT_APPROVAL_MODES as F, AttributionExceptionCollection as H, REFERRAL_AGREEMENT_STATUSES as I, REFERRAL_LINK_STATUSES as L, ATTRIBUTION_EXCEPTION_STATUSES as M, ATTRIBUTION_POLICY_STATUSES as N, AttributionPolicy as O, ATTRIBUTION_RESOLUTION_MODES as P, REFERRAL_PROGRAM_STATUSES as R, assertHttpTargetUrl as S, ReferralAgreementCollection as T, AttributionException as U, REFERRER_STATUSES as V, ReferralLinkCollection as _, ReferralAgreementExecutionService as a, ReferralTouch as b, ReferrerCollection as c, ReferralTermSnapshot as d, ReferralProgramCollection as f, REFERRAL_CODE_LENGTH as g, REFERRAL_CODE_ALPHABET as h, REFERRAL_AGREEMENT_SOURCE_KIND as i, ATTRIBUTION_CREDIT_MODES as j, validateAttributionPolicyTerms as k, Referrer as l, MAX_CODE_GENERATION_ATTEMPTS as m, REFERRAL_TERMS_SNAPSHOT_KIND as n, AttributionService as o, ReferralProgram as p, ReferralCommissionService as r, QualifiedReferralOverrideError as s, ReferralQualificationService as t, ReferralTermSnapshotCollection as u, generateReferralCode as v, Referral as w, ReferralLink as x, ReferralTouchCollection as y, REFERRAL_STATUSES as z };
|
|
2879
3002
|
|
|
2880
|
-
//# sourceMappingURL=referrals-
|
|
3003
|
+
//# sourceMappingURL=referrals-cYYg4YZw.js.map
|