@etohq/ambassador 1.5.1-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/models/ambassador.d.ts +39 -0
- package/dist/models/ambassador.d.ts.map +1 -0
- package/dist/models/ambassador.js +67 -0
- package/dist/models/ambassador.js.map +1 -0
- package/dist/models/commission.d.ts +23 -0
- package/dist/models/commission.d.ts.map +1 -0
- package/dist/models/commission.js +93 -0
- package/dist/models/commission.js.map +1 -0
- package/dist/models/index.d.ts +8 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +18 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/partner.d.ts +38 -0
- package/dist/models/partner.d.ts.map +1 -0
- package/dist/models/partner.js +78 -0
- package/dist/models/partner.js.map +1 -0
- package/dist/models/payout.d.ts +28 -0
- package/dist/models/payout.d.ts.map +1 -0
- package/dist/models/payout.js +57 -0
- package/dist/models/payout.js.map +1 -0
- package/dist/models/program-enrollment.d.ts +26 -0
- package/dist/models/program-enrollment.d.ts.map +1 -0
- package/dist/models/program-enrollment.js +81 -0
- package/dist/models/program-enrollment.js.map +1 -0
- package/dist/models/program.d.ts +52 -0
- package/dist/models/program.d.ts.map +1 -0
- package/dist/models/program.js +106 -0
- package/dist/models/program.js.map +1 -0
- package/dist/models/revenue-share-rule.d.ts +25 -0
- package/dist/models/revenue-share-rule.d.ts.map +1 -0
- package/dist/models/revenue-share-rule.js +54 -0
- package/dist/models/revenue-share-rule.js.map +1 -0
- package/dist/models/reward.d.ts +16 -0
- package/dist/models/reward.d.ts.map +1 -0
- package/dist/models/reward.js +41 -0
- package/dist/models/reward.js.map +1 -0
- package/dist/services/ambassador-module-service.d.ts +221 -0
- package/dist/services/ambassador-module-service.d.ts.map +1 -0
- package/dist/services/ambassador-module-service.js +972 -0
- package/dist/services/ambassador-module-service.js.map +1 -0
- package/dist/services/ambassador-service.d.ts +57 -0
- package/dist/services/ambassador-service.d.ts.map +1 -0
- package/dist/services/ambassador-service.js +127 -0
- package/dist/services/ambassador-service.js.map +1 -0
- package/dist/services/commission-service.d.ts +45 -0
- package/dist/services/commission-service.d.ts.map +1 -0
- package/dist/services/commission-service.js +146 -0
- package/dist/services/commission-service.js.map +1 -0
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +9 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/payout-service.d.ts +35 -0
- package/dist/services/payout-service.d.ts.map +1 -0
- package/dist/services/payout-service.js +87 -0
- package/dist/services/payout-service.js.map +1 -0
- package/dist/services/program-enrollment-service.d.ts +39 -0
- package/dist/services/program-enrollment-service.d.ts.map +1 -0
- package/dist/services/program-enrollment-service.js +102 -0
- package/dist/services/program-enrollment-service.js.map +1 -0
- package/dist/services/program-service.d.ts +78 -0
- package/dist/services/program-service.d.ts.map +1 -0
- package/dist/services/program-service.js +180 -0
- package/dist/services/program-service.js.map +1 -0
- package/dist/services/revenue-rule-resolver.d.ts +15 -0
- package/dist/services/revenue-rule-resolver.d.ts.map +1 -0
- package/dist/services/revenue-rule-resolver.js +836 -0
- package/dist/services/revenue-rule-resolver.js.map +1 -0
- package/dist/services/revenue-share-rule-service.d.ts +5 -0
- package/dist/services/revenue-share-rule-service.d.ts.map +1 -0
- package/dist/services/revenue-share-rule-service.js +8 -0
- package/dist/services/revenue-share-rule-service.js.map +1 -0
- package/dist/services/reward-service.d.ts +31 -0
- package/dist/services/reward-service.d.ts.map +1 -0
- package/dist/services/reward-service.js +82 -0
- package/dist/services/reward-service.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/utils/analytics.d.ts +19 -0
- package/dist/utils/analytics.d.ts.map +1 -0
- package/dist/utils/analytics.js +90 -0
- package/dist/utils/analytics.js.map +1 -0
- package/dist/utils/sustainability-monitor.d.ts +20 -0
- package/dist/utils/sustainability-monitor.d.ts.map +1 -0
- package/dist/utils/sustainability-monitor.js +46 -0
- package/dist/utils/sustainability-monitor.js.map +1 -0
- package/dist/workflows/calculate-commission-workflow.d.ts +2 -0
- package/dist/workflows/calculate-commission-workflow.d.ts.map +1 -0
- package/dist/workflows/calculate-commission-workflow.js +59 -0
- package/dist/workflows/calculate-commission-workflow.js.map +1 -0
- package/dist/workflows/steps/index.d.ts +2 -0
- package/dist/workflows/steps/index.d.ts.map +1 -0
- package/dist/workflows/steps/index.js +158 -0
- package/dist/workflows/steps/index.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Context, DAL, FindConfig } from "@etohq/framework/types";
|
|
2
|
+
import { EnrollAmbassadorDTO, FilterableProgramEnrollmentProps, ProgramEnrollmentDTO, ProgramEnrollmentStatus } from "@etohq/framework/types";
|
|
3
|
+
type InjectedDependencies = {
|
|
4
|
+
programEnrollmentRepository: DAL.RepositoryService;
|
|
5
|
+
};
|
|
6
|
+
declare const ProgramEnrollmentService_base: new (container: InjectedDependencies) => import("@etohq/framework/types").IEtoInternalService<{
|
|
7
|
+
id: string;
|
|
8
|
+
ambassador_id: string;
|
|
9
|
+
program_id: string;
|
|
10
|
+
tenant_id: string | null;
|
|
11
|
+
group_id: string | null;
|
|
12
|
+
application_id: string | null;
|
|
13
|
+
click_reward_id: string | null;
|
|
14
|
+
lead_reward_id: string | null;
|
|
15
|
+
sale_reward_id: string | null;
|
|
16
|
+
access_reward_id: string | null;
|
|
17
|
+
discount_id: string | null;
|
|
18
|
+
application_message: string | null;
|
|
19
|
+
invited_by: string | null;
|
|
20
|
+
source: string | null;
|
|
21
|
+
metadata: Record<string, unknown> | null;
|
|
22
|
+
status: "pending" | "approved" | "rejected" | "invited" | "declined" | "banned" | "archived";
|
|
23
|
+
total_commissions: number;
|
|
24
|
+
banned_at: Date | null;
|
|
25
|
+
banned_reason: "tos_violation" | "inappropriate_content" | "fake_traffic" | "fraud" | "spam" | "brand_abuse" | null;
|
|
26
|
+
created_at: Date;
|
|
27
|
+
updated_at: Date;
|
|
28
|
+
deleted_at: Date | null;
|
|
29
|
+
}, InjectedDependencies>;
|
|
30
|
+
export default class ProgramEnrollmentService extends ProgramEnrollmentService_base {
|
|
31
|
+
protected readonly programEnrollmentRepository_: DAL.RepositoryService;
|
|
32
|
+
constructor(container: InjectedDependencies);
|
|
33
|
+
enrollAmbassador(data: EnrollAmbassadorDTO, autoApprove?: boolean, sharedContext?: Context): Promise<ProgramEnrollmentDTO>;
|
|
34
|
+
getEnrollmentOrThrow(ambassadorId: string, programId: string, sharedContext?: Context): Promise<ProgramEnrollmentDTO>;
|
|
35
|
+
updateEnrollmentStatus(enrollmentId: string, status: ProgramEnrollmentStatus, sharedContext?: Context): Promise<ProgramEnrollmentDTO>;
|
|
36
|
+
getEnrollmentsByProgram(programId: string, filters?: FilterableProgramEnrollmentProps, config?: FindConfig<ProgramEnrollmentDTO>, sharedContext?: Context): Promise<ProgramEnrollmentDTO[]>;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=program-enrollment-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"program-enrollment-service.d.ts","sourceRoot":"","sources":["../../src/services/program-enrollment-service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,GAAG,EACH,UAAU,EAEX,MAAM,wBAAwB,CAAA;AAS/B,OAAO,EACL,mBAAmB,EACnB,gCAAgC,EAChC,oBAAoB,EACpB,uBAAuB,EACxB,MAAM,wBAAwB,CAAA;AAI/B,KAAK,oBAAoB,GAAG;IAC1B,2BAA2B,EAAE,GAAG,CAAC,iBAAiB,CAAA;CACnD,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;AAED,MAAM,CAAC,OAAO,OAAO,wBAAyB,SAAQ,6BAGlC;IAClB,SAAS,CAAC,QAAQ,CAAC,4BAA4B,EAAE,GAAG,CAAC,iBAAiB,CAAA;gBAE1D,SAAS,EAAE,oBAAoB;IAOrC,gBAAgB,CACpB,IAAI,EAAE,mBAAmB,EACzB,WAAW,GAAE,OAAe,EACd,aAAa,GAAE,OAAY,GACxC,OAAO,CAAC,oBAAoB,CAAC;IAiC1B,oBAAoB,CACxB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,EACH,aAAa,GAAE,OAAY,GACxC,OAAO,CAAC,oBAAoB,CAAC;IAmB1B,sBAAsB,CAC1B,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,uBAAuB,EACjB,aAAa,GAAE,OAAY,GACxC,OAAO,CAAC,oBAAoB,CAAC;IAe1B,uBAAuB,CAC3B,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,gCAAqC,EAC9C,MAAM,GAAE,UAAU,CAAC,oBAAoB,CAAM,EAC/B,aAAa,GAAE,OAAY,GACxC,OAAO,CAAC,oBAAoB,EAAE,CAAC;CAUnC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const utils_1 = require("@etohq/framework/utils");
|
|
16
|
+
const _models_1 = require("../models");
|
|
17
|
+
class ProgramEnrollmentService extends utils_1.ModulesSdkUtils.EtoInternalService(_models_1.ProgramEnrollment) {
|
|
18
|
+
constructor(container) {
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
super(...arguments);
|
|
21
|
+
this.programEnrollmentRepository_ = container.programEnrollmentRepository;
|
|
22
|
+
}
|
|
23
|
+
async enrollAmbassador(data, autoApprove = false, sharedContext = {}) {
|
|
24
|
+
// Check if already enrolled
|
|
25
|
+
const existing = await this.list({
|
|
26
|
+
ambassador_id: data.ambassador_id,
|
|
27
|
+
program_id: data.program_id
|
|
28
|
+
}, {}, sharedContext);
|
|
29
|
+
if (existing.length > 0) {
|
|
30
|
+
throw new utils_1.EtoError(utils_1.EtoError.Types.DUPLICATE_ERROR, "Ambassador already enrolled in this program");
|
|
31
|
+
}
|
|
32
|
+
const enrollmentData = {
|
|
33
|
+
id: (0, utils_1.generateEntityId)("", "enr"),
|
|
34
|
+
...data,
|
|
35
|
+
status: autoApprove
|
|
36
|
+
? "approved"
|
|
37
|
+
: "pending",
|
|
38
|
+
total_commissions: 0,
|
|
39
|
+
enrolled_at: autoApprove ? new Date() : undefined,
|
|
40
|
+
};
|
|
41
|
+
const [enrollment] = await this.create([enrollmentData], sharedContext);
|
|
42
|
+
return enrollment;
|
|
43
|
+
}
|
|
44
|
+
async getEnrollmentOrThrow(ambassadorId, programId, sharedContext = {}) {
|
|
45
|
+
// Support both ID and slug lookup (Dub pattern)
|
|
46
|
+
const filters = programId.startsWith("prog_")
|
|
47
|
+
? { ambassador_id: ambassadorId, program_id: programId }
|
|
48
|
+
: { ambassador_id: ambassadorId, program: { slug: programId } };
|
|
49
|
+
const enrollments = await this.list(filters, {}, sharedContext);
|
|
50
|
+
if (enrollments.length === 0) {
|
|
51
|
+
throw new utils_1.EtoError(utils_1.EtoError.Types.NOT_FOUND, "You are not enrolled in this program. Contact your program admin to get enrolled.");
|
|
52
|
+
}
|
|
53
|
+
return enrollments[0];
|
|
54
|
+
}
|
|
55
|
+
async updateEnrollmentStatus(enrollmentId, status, sharedContext = {}) {
|
|
56
|
+
const updateData = {
|
|
57
|
+
id: enrollmentId,
|
|
58
|
+
status
|
|
59
|
+
};
|
|
60
|
+
if (status === "approved") {
|
|
61
|
+
updateData.enrolled_at = new Date();
|
|
62
|
+
}
|
|
63
|
+
const [updated] = await this.update([updateData], sharedContext);
|
|
64
|
+
return updated;
|
|
65
|
+
}
|
|
66
|
+
async getEnrollmentsByProgram(programId, filters = {}, config = {}, sharedContext = {}) {
|
|
67
|
+
return await this.list({
|
|
68
|
+
program_id: programId,
|
|
69
|
+
...filters
|
|
70
|
+
}, config, sharedContext);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.default = ProgramEnrollmentService;
|
|
74
|
+
__decorate([
|
|
75
|
+
(0, utils_1.InjectManager)("programEnrollmentRepository_"),
|
|
76
|
+
__param(2, (0, utils_1.EtoContext)()),
|
|
77
|
+
__metadata("design:type", Function),
|
|
78
|
+
__metadata("design:paramtypes", [Object, Boolean, Object]),
|
|
79
|
+
__metadata("design:returntype", Promise)
|
|
80
|
+
], ProgramEnrollmentService.prototype, "enrollAmbassador", null);
|
|
81
|
+
__decorate([
|
|
82
|
+
(0, utils_1.InjectManager)("programEnrollmentRepository_"),
|
|
83
|
+
__param(2, (0, utils_1.EtoContext)()),
|
|
84
|
+
__metadata("design:type", Function),
|
|
85
|
+
__metadata("design:paramtypes", [String, String, Object]),
|
|
86
|
+
__metadata("design:returntype", Promise)
|
|
87
|
+
], ProgramEnrollmentService.prototype, "getEnrollmentOrThrow", null);
|
|
88
|
+
__decorate([
|
|
89
|
+
(0, utils_1.InjectManager)("programEnrollmentRepository_"),
|
|
90
|
+
__param(2, (0, utils_1.EtoContext)()),
|
|
91
|
+
__metadata("design:type", Function),
|
|
92
|
+
__metadata("design:paramtypes", [String, String, Object]),
|
|
93
|
+
__metadata("design:returntype", Promise)
|
|
94
|
+
], ProgramEnrollmentService.prototype, "updateEnrollmentStatus", null);
|
|
95
|
+
__decorate([
|
|
96
|
+
(0, utils_1.InjectManager)("programEnrollmentRepository_"),
|
|
97
|
+
__param(3, (0, utils_1.EtoContext)()),
|
|
98
|
+
__metadata("design:type", Function),
|
|
99
|
+
__metadata("design:paramtypes", [String, Object, Object, Object]),
|
|
100
|
+
__metadata("design:returntype", Promise)
|
|
101
|
+
], ProgramEnrollmentService.prototype, "getEnrollmentsByProgram", null);
|
|
102
|
+
//# sourceMappingURL=program-enrollment-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"program-enrollment-service.js","sourceRoot":"","sources":["../../src/services/program-enrollment-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAMA,kDAM+B;AAS/B,qCAA2C;AAM3C,MAAqB,wBAAyB,SAAQ,uBAAe,CAAC,kBAAkB,CAGtF,2BAAiB,CAAC;IAGlB,YAAY,SAA+B;QACzC,aAAa;QACb,KAAK,CAAC,GAAG,SAAS,CAAC,CAAA;QACnB,IAAI,CAAC,4BAA4B,GAAG,SAAS,CAAC,2BAA2B,CAAA;IAC3E,CAAC;IAGK,AAAN,KAAK,CAAC,gBAAgB,CACpB,IAAyB,EACzB,cAAuB,KAAK,EACd,gBAAyB,EAAE;QAEzC,6BAA6B;QAC7B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAC9B;YACE,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,UAAU,EAAE,IAAI,CAAC,UAAU;SAC5B,EACD,EAAE,EACF,aAAa,CACd,CAAA;QAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,gBAAQ,CAChB,gBAAQ,CAAC,KAAK,CAAC,eAAe,EAC9B,6CAA6C,CAC9C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AY;YAChB,MAAM;SACP,CAAA;QAED,IAAI,MAAM,KAAK,UAAU,EAAE,CAAC;YAC1B,UAAU,CAAC,WAAW,GAAG,IAAI,IAAI,EAAE,CAAA;QACrC,CAAC;QAED,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC,CAAA;QAChE,OAAO,OAAO,CAAA;IAChB,CAAC;IAGK,AAAN,KAAK,CAAC,uBAAuB,CAC3B,SAAiB,EACjB,UAA4C,EAAE,EAC9C,SAA2C,EAAE,EAC/B,gBAAyB,EAAE;QAEzC,OAAO,MAAM,IAAI,CAAC,IAAI,CACpB;YACE,UAAU,EAAE,SAAS;YACrB,GAAG,OAAO;SACX,EACD,MAAM,EACN,aAAa,CACd,CAAA;IACH,CAAC;CACF;AA3GD,2CA2GC;AA9FO;IADL,IAAA,qBAAa,EAAC,8BAA8B,CAAC;IAI3C,WAAA,IAAA,kBAAU,GAAE,CAAA;;;;gEA+Bd;AAGK;IADL,IAAA,qBAAa,EAAC,8BAA8B,CAAC;IAI3C,WAAA,IAAA,kBAAU,GAAE,CAAA;;;;oEAiBd;AAGK;IADL,IAAA,qBAAa,EAAC,8BAA8B,CAAC;IAI3C,WAAA,IAAA,kBAAU,GAAE,CAAA;;;;sEAad;AAGK;IADL,IAAA,qBAAa,EAAC,8BAA8B,CAAC;IAK3C,WAAA,IAAA,kBAAU,GAAE,CAAA;;;;uEAUd"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Context, DAL, FindConfig, RewardDTO } from "@etohq/framework/types";
|
|
2
|
+
import { CreateProgramDTO, UpdateProgramDTO, FilterableProgramProps, ProgramDTO } from "@etohq/framework/types";
|
|
3
|
+
type InjectedDependencies = {
|
|
4
|
+
programRepository: DAL.RepositoryService;
|
|
5
|
+
};
|
|
6
|
+
declare const ProgramService_base: new (container: InjectedDependencies) => import("@etohq/framework/types").IEtoInternalService<{
|
|
7
|
+
id: string;
|
|
8
|
+
owner_id: string;
|
|
9
|
+
owner_type: string;
|
|
10
|
+
name: string;
|
|
11
|
+
slug: string;
|
|
12
|
+
description: string | null;
|
|
13
|
+
logo: string | null;
|
|
14
|
+
brand_color: string | null;
|
|
15
|
+
domain: string | null;
|
|
16
|
+
url: string | null;
|
|
17
|
+
wordmark: string | null;
|
|
18
|
+
primary_category: string;
|
|
19
|
+
commission_type: "percentage" | "fixed";
|
|
20
|
+
commission_rate: number;
|
|
21
|
+
cookie_length: number;
|
|
22
|
+
holding_period_days: number;
|
|
23
|
+
min_payout_amount: number;
|
|
24
|
+
auto_approve_ambassadors: boolean;
|
|
25
|
+
auto_approve_ambassadors_enabled_at: Date | null;
|
|
26
|
+
max_ambassador_links: number;
|
|
27
|
+
url_validation_mode: "domain" | "exact";
|
|
28
|
+
link_structure: "short" | "query" | "path";
|
|
29
|
+
link_parameter: string | null;
|
|
30
|
+
age_verification: number | null;
|
|
31
|
+
default_folder_id: string | null;
|
|
32
|
+
default_group_id: string | null;
|
|
33
|
+
lander_published_at: Date | null;
|
|
34
|
+
category: string | null;
|
|
35
|
+
tags: string[] | null;
|
|
36
|
+
target_audience: string | null;
|
|
37
|
+
commission_summary: string | null;
|
|
38
|
+
program_benefits: Record<string, unknown> | null;
|
|
39
|
+
requirements: Record<string, unknown> | null;
|
|
40
|
+
campaign_id: string | null;
|
|
41
|
+
active_promotion_ids: string[] | null;
|
|
42
|
+
promotion_integration_enabled: boolean;
|
|
43
|
+
discounts: Record<string, unknown> | null;
|
|
44
|
+
rewards: Record<string, unknown> | null;
|
|
45
|
+
discount_enabled: boolean;
|
|
46
|
+
discount_type: "percentage" | "flat";
|
|
47
|
+
discount_amount: number;
|
|
48
|
+
discount_max_duration: number | null;
|
|
49
|
+
terms_url: string | null;
|
|
50
|
+
help_url: string | null;
|
|
51
|
+
support_email: string | null;
|
|
52
|
+
revenue_sharing_mode: "default" | "custom" | "negotiated";
|
|
53
|
+
status: "active" | "inactive" | "suspended";
|
|
54
|
+
metadata: Record<string, unknown> | null;
|
|
55
|
+
raw_age_verification: Record<string, unknown> | null;
|
|
56
|
+
raw_discount_max_duration: Record<string, unknown> | null;
|
|
57
|
+
created_at: Date;
|
|
58
|
+
updated_at: Date;
|
|
59
|
+
deleted_at: Date | null;
|
|
60
|
+
} & {
|
|
61
|
+
rewards: RewardDTO[];
|
|
62
|
+
}, InjectedDependencies>;
|
|
63
|
+
export default class ProgramService extends ProgramService_base {
|
|
64
|
+
protected readonly programRepository_: DAL.RepositoryService;
|
|
65
|
+
constructor(container: InjectedDependencies);
|
|
66
|
+
createProgramWithValidation(data: CreateProgramDTO, sharedContext?: Context): Promise<ProgramDTO>;
|
|
67
|
+
getProgramOrThrow(programId: string, ownerId?: string, ownerType?: string, sharedContext?: Context): Promise<ProgramDTO>;
|
|
68
|
+
listProgramsByOwner(ownerId: string, ownerType: string, filters?: FilterableProgramProps, config?: FindConfig<ProgramDTO>, sharedContext?: Context): Promise<ProgramDTO[]>;
|
|
69
|
+
updateProgramWithValidation(data: UpdateProgramDTO, sharedContext?: Context): Promise<ProgramDTO>;
|
|
70
|
+
private validateProgramData;
|
|
71
|
+
private validateCommissionRate;
|
|
72
|
+
private validatePayoutAmount;
|
|
73
|
+
private validateHoldingPeriod;
|
|
74
|
+
private validateCookieLength;
|
|
75
|
+
private validateMaxAmbassadorLinks;
|
|
76
|
+
}
|
|
77
|
+
export {};
|
|
78
|
+
//# sourceMappingURL=program-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"program-service.d.ts","sourceRoot":"","sources":["../../src/services/program-service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,GAAG,EACH,UAAU,EAEV,SAAS,EACV,MAAM,wBAAwB,CAAA;AAS/B,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,sBAAsB,EACtB,UAAU,EACX,MAAM,wBAAwB,CAAA;AAI/B,KAAK,oBAAoB,GAAG;IAC1B,iBAAiB,EAAE,GAAG,CAAC,iBAAiB,CAAA;CACzC,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAI8C,SAAS,EAAE;;AAF1D,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,mBAGlC;IACR,SAAS,CAAC,QAAQ,CAAC,kBAAkB,EAAE,GAAG,CAAC,iBAAiB,CAAA;gBAEhD,SAAS,EAAE,oBAAoB;IAOrC,2BAA2B,CAC/B,IAAI,EAAE,gBAAgB,EACR,aAAa,GAAE,OAAY,GACxC,OAAO,CAAC,UAAU,CAAC;IA2ChB,iBAAiB,CACrB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,MAAM,EACJ,aAAa,GAAE,OAAY,GACxC,OAAO,CAAC,UAAU,CAAC;IAmBhB,mBAAmB,CACvB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,sBAA2B,EACpC,MAAM,GAAE,UAAU,CAAC,UAAU,CAAM,EACrB,aAAa,GAAE,OAAY,GACxC,OAAO,CAAC,UAAU,EAAE,CAAC;IAalB,2BAA2B,CAC/B,IAAI,EAAE,gBAAgB,EACR,aAAa,GAAE,OAAY,GACxC,OAAO,CAAC,UAAU,CAAC;IA6BtB,OAAO,CAAC,mBAAmB;IAiC3B,OAAO,CAAC,sBAAsB;IAS9B,OAAO,CAAC,oBAAoB;IAa5B,OAAO,CAAC,qBAAqB;IAa7B,OAAO,CAAC,oBAAoB;IAU5B,OAAO,CAAC,0BAA0B;CASnC"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const utils_1 = require("@etohq/framework/utils");
|
|
16
|
+
const _models_1 = require("../models");
|
|
17
|
+
class ProgramService extends utils_1.ModulesSdkUtils.EtoInternalService(_models_1.Program) {
|
|
18
|
+
constructor(container) {
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
super(...arguments);
|
|
21
|
+
this.programRepository_ = container.programRepository;
|
|
22
|
+
}
|
|
23
|
+
async createProgramWithValidation(data, sharedContext = {}) {
|
|
24
|
+
// Dub business logic validation
|
|
25
|
+
this.validateProgramData(data);
|
|
26
|
+
// Check slug uniqueness (Dub pattern)
|
|
27
|
+
const existingBySlug = await this.list({ slug: data.slug }, {}, sharedContext);
|
|
28
|
+
if (existingBySlug.length > 0) {
|
|
29
|
+
throw new utils_1.EtoError(utils_1.EtoError.Types.DUPLICATE_ERROR, `Program with slug '${data.slug}' already exists`);
|
|
30
|
+
}
|
|
31
|
+
// Create with Dub defaults
|
|
32
|
+
const programData = {
|
|
33
|
+
id: (0, utils_1.generateEntityId)("", "prog"),
|
|
34
|
+
...data,
|
|
35
|
+
// Dub defaults
|
|
36
|
+
cookie_length: data.cookie_length || 30,
|
|
37
|
+
holding_period_days: data.holding_period_days || 0,
|
|
38
|
+
min_payout_amount: data.min_payout_amount || 500000, // N5000
|
|
39
|
+
auto_approve_ambassadors: data.auto_approve_ambassadors || false,
|
|
40
|
+
max_ambassador_links: data.max_ambassador_links || 10,
|
|
41
|
+
url_validation_mode: data.url_validation_mode || "domain",
|
|
42
|
+
link_structure: data.link_structure || "short",
|
|
43
|
+
promotion_integration_enabled: data.promotion_integration_enabled !== false,
|
|
44
|
+
discount_enabled: data.discount_enabled || false,
|
|
45
|
+
discount_type: data.discount_type || "percentage",
|
|
46
|
+
discount_amount: data.discount_amount || 0,
|
|
47
|
+
status: "active",
|
|
48
|
+
};
|
|
49
|
+
const [program] = await this.create([programData], sharedContext);
|
|
50
|
+
return program;
|
|
51
|
+
}
|
|
52
|
+
async getProgramOrThrow(programId, ownerId, ownerType, sharedContext = {}) {
|
|
53
|
+
const filters = { id: programId };
|
|
54
|
+
// Owner validation (our universal owner pattern)
|
|
55
|
+
if (ownerId && ownerType) {
|
|
56
|
+
filters.owner_id = ownerId;
|
|
57
|
+
filters.owner_type = ownerType;
|
|
58
|
+
}
|
|
59
|
+
const programs = await this.list(filters, {}, sharedContext);
|
|
60
|
+
if (programs.length === 0) {
|
|
61
|
+
throw new utils_1.EtoError(utils_1.EtoError.Types.NOT_FOUND, "Program not found");
|
|
62
|
+
}
|
|
63
|
+
return programs[0];
|
|
64
|
+
}
|
|
65
|
+
async listProgramsByOwner(ownerId, ownerType, filters = {}, config = {}, sharedContext = {}) {
|
|
66
|
+
return await this.list({
|
|
67
|
+
owner_id: ownerId,
|
|
68
|
+
owner_type: ownerType,
|
|
69
|
+
...filters,
|
|
70
|
+
}, config, sharedContext);
|
|
71
|
+
}
|
|
72
|
+
async updateProgramWithValidation(data, sharedContext = {}) {
|
|
73
|
+
// Validate update data
|
|
74
|
+
if (data.commission_rate !== undefined) {
|
|
75
|
+
this.validateCommissionRate(data.commission_rate);
|
|
76
|
+
}
|
|
77
|
+
if (data.min_payout_amount !== undefined && data.min_payout_amount !== null) {
|
|
78
|
+
this.validatePayoutAmount(data.min_payout_amount);
|
|
79
|
+
}
|
|
80
|
+
if (data.holding_period_days !== undefined && data.holding_period_days !== null) {
|
|
81
|
+
this.validateHoldingPeriod(data.holding_period_days);
|
|
82
|
+
}
|
|
83
|
+
if (data.cookie_length !== undefined && data.cookie_length !== null) {
|
|
84
|
+
this.validateCookieLength(data.cookie_length);
|
|
85
|
+
}
|
|
86
|
+
if (data.max_ambassador_links !== undefined && data.max_ambassador_links !== null) {
|
|
87
|
+
this.validateMaxAmbassadorLinks(data.max_ambassador_links);
|
|
88
|
+
}
|
|
89
|
+
const [updated] = await this.update([data], sharedContext);
|
|
90
|
+
return updated;
|
|
91
|
+
}
|
|
92
|
+
// ===== VALIDATION METHODS (Dub Business Logic) =====
|
|
93
|
+
validateProgramData(data) {
|
|
94
|
+
// Commission rate validation (Dub pattern)
|
|
95
|
+
this.validateCommissionRate(data.commission_rate);
|
|
96
|
+
// Slug validation (Dub pattern)
|
|
97
|
+
if (!data.slug || data.slug.length < 3) {
|
|
98
|
+
throw new utils_1.EtoError(utils_1.EtoError.Types.INVALID_DATA, "Program slug must be at least 3 characters");
|
|
99
|
+
}
|
|
100
|
+
// Payout amount validation (Dub pattern)
|
|
101
|
+
if (data.min_payout_amount) {
|
|
102
|
+
this.validatePayoutAmount(data.min_payout_amount);
|
|
103
|
+
}
|
|
104
|
+
// Holding period validation (Dub pattern)
|
|
105
|
+
if (data.holding_period_days) {
|
|
106
|
+
this.validateHoldingPeriod(data.holding_period_days);
|
|
107
|
+
}
|
|
108
|
+
// Cookie length validation (Dub pattern)
|
|
109
|
+
if (data.cookie_length) {
|
|
110
|
+
this.validateCookieLength(data.cookie_length);
|
|
111
|
+
}
|
|
112
|
+
// Max ambassador links validation (Dub pattern)
|
|
113
|
+
if (data.max_ambassador_links) {
|
|
114
|
+
this.validateMaxAmbassadorLinks(data.max_ambassador_links);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
validateCommissionRate(rate) {
|
|
118
|
+
if (rate < 0 || rate > 100) {
|
|
119
|
+
throw new utils_1.EtoError(utils_1.EtoError.Types.INVALID_DATA, "Commission rate must be between 0 and 100");
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
validatePayoutAmount(amount) {
|
|
123
|
+
// Dub exact payout amounts (NOT withdrawal amounts)
|
|
124
|
+
const allowedPayoutAmounts = [0, 2000, 5000, 10000]; // $0, $20, $50, $100
|
|
125
|
+
if (!allowedPayoutAmounts.includes(amount)) {
|
|
126
|
+
throw new utils_1.EtoError(utils_1.EtoError.Types.INVALID_DATA, `Invalid minimum payout amount. Allowed values: ${allowedPayoutAmounts
|
|
127
|
+
.map((a) => `$${a / 100}`)
|
|
128
|
+
.join(", ")}`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
validateHoldingPeriod(days) {
|
|
132
|
+
// Dub allowed holding periods
|
|
133
|
+
const allowedHoldingPeriods = [0, 7, 14, 30, 60, 90];
|
|
134
|
+
if (!allowedHoldingPeriods.includes(days)) {
|
|
135
|
+
throw new utils_1.EtoError(utils_1.EtoError.Types.INVALID_DATA, `Invalid holding period. Allowed values: ${allowedHoldingPeriods.join(", ")} days`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
validateCookieLength(days) {
|
|
139
|
+
// Dub cookie length validation: 1-180 days
|
|
140
|
+
if (days < 1 || days > 180) {
|
|
141
|
+
throw new utils_1.EtoError(utils_1.EtoError.Types.INVALID_DATA, "Cookie length must be between 1 and 180 days");
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
validateMaxAmbassadorLinks(count) {
|
|
145
|
+
// Dub max partner links validation: 1-999
|
|
146
|
+
if (count < 1 || count > 999) {
|
|
147
|
+
throw new utils_1.EtoError(utils_1.EtoError.Types.INVALID_DATA, "Max ambassador links must be between 1 and 999");
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
exports.default = ProgramService;
|
|
152
|
+
__decorate([
|
|
153
|
+
(0, utils_1.InjectManager)("programRepository_"),
|
|
154
|
+
__param(1, (0, utils_1.EtoContext)()),
|
|
155
|
+
__metadata("design:type", Function),
|
|
156
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
157
|
+
__metadata("design:returntype", Promise)
|
|
158
|
+
], ProgramService.prototype, "createProgramWithValidation", null);
|
|
159
|
+
__decorate([
|
|
160
|
+
(0, utils_1.InjectManager)("programRepository_"),
|
|
161
|
+
__param(3, (0, utils_1.EtoContext)()),
|
|
162
|
+
__metadata("design:type", Function),
|
|
163
|
+
__metadata("design:paramtypes", [String, String, String, Object]),
|
|
164
|
+
__metadata("design:returntype", Promise)
|
|
165
|
+
], ProgramService.prototype, "getProgramOrThrow", null);
|
|
166
|
+
__decorate([
|
|
167
|
+
(0, utils_1.InjectManager)("programRepository_"),
|
|
168
|
+
__param(4, (0, utils_1.EtoContext)()),
|
|
169
|
+
__metadata("design:type", Function),
|
|
170
|
+
__metadata("design:paramtypes", [String, String, Object, Object, Object]),
|
|
171
|
+
__metadata("design:returntype", Promise)
|
|
172
|
+
], ProgramService.prototype, "listProgramsByOwner", null);
|
|
173
|
+
__decorate([
|
|
174
|
+
(0, utils_1.InjectManager)("programRepository_"),
|
|
175
|
+
__param(1, (0, utils_1.EtoContext)()),
|
|
176
|
+
__metadata("design:type", Function),
|
|
177
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
178
|
+
__metadata("design:returntype", Promise)
|
|
179
|
+
], ProgramService.prototype, "updateProgramWithValidation", null);
|
|
180
|
+
//# sourceMappingURL=program-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"program-service.js","sourceRoot":"","sources":["../../src/services/program-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAOA,kDAM+B;AAS/B,qCAAiC;AAMjC,MAAqB,cAAe,SAAQ,uBAAe,CAAC,kBAAkB,CAG5E,iBAAO,CAAC;IAGR,YAAY,SAA+B;QACzC,aAAa;QACb,KAAK,CAAC,GAAG,SAAS,CAAC,CAAA;QACnB,IAA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@@
|
|
|
1
|
+
import { Context } from "@etohq/framework/types";
|
|
2
|
+
import { RevenueEvent, RevenueDistribution } from "@etohq/framework/types";
|
|
3
|
+
export default class RevenueRuleResolver {
|
|
4
|
+
private programService_;
|
|
5
|
+
private revenueShareRuleService_;
|
|
6
|
+
constructor(dependencies: {
|
|
7
|
+
programService: any;
|
|
8
|
+
revenueShareRuleService: any;
|
|
9
|
+
});
|
|
10
|
+
resolveRevenueRules(event: RevenueEvent, sharedContext?: Context): Promise<RevenueDistribution>;
|
|
11
|
+
private applyPlanBonus;
|
|
12
|
+
private getPlatformDefault;
|
|
13
|
+
private getMaterializedRule;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=revenue-rule-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revenue-rule-resolver.d.ts","sourceRoot":"","sources":["../../src/services/revenue-rule-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAEhD,OAAO,EACL,YAAY,EACZ,mBAAmB,EAKpB,MAAM,wBAAwB,CAAA;AA6tB/B,MAAM,CAAC,OAAO,OAAO,mBAAmB;IACtC,OAAO,CAAC,eAAe,CAAK;IAC5B,OAAO,CAAC,wBAAwB,CAAK;gBAEzB,YAAY,EAAE;QACxB,cAAc,EAAE,GAAG,CAAA;QACnB,uBAAuB,EAAE,GAAG,CAAA;KAC7B;IAMK,mBAAmB,CACvB,KAAK,EAAE,YAAY,EACL,aAAa,GAAE,OAAY,GACxC,OAAO,CAAC,mBAAmB,CAAC;IA2D/B,OAAO,CAAC,cAAc;IAgBtB,OAAO,CAAC,kBAAkB;YAaZ,mBAAmB;CAsClC"}
|