@tolinax/ayoune-interfaces 2026.21.0 → 2026.23.0

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.
@@ -20,7 +20,9 @@ export declare enum aMN {
20
20
  AdvertiserWeeklyDomainKPIsByIndustries = "AdvertiserWeeklyDomainKPIsByIndustries",
21
21
  AdwordsLogs = "AdwordsLogs",
22
22
  AffClicks = "AffClicks",
23
+ AffiliateAttributions = "AffiliateAttributions",
23
24
  AffiliateCampaigns = "AffiliateCampaigns",
25
+ AffiliatePayouts = "AffiliatePayouts",
24
26
  Affiliates = "Affiliates",
25
27
  AffViews = "AffViews",
26
28
  Agencies = "Agencies",
@@ -299,6 +301,7 @@ export declare enum aMN {
299
301
  FormSubmissions = "FormSubmissions",
300
302
  FormViews = "FormViews",
301
303
  FractureMessages = "FractureMessages",
304
+ FXRates = "FXRates",
302
305
  Generations = "Generations",
303
306
  GlobalChecks = "GlobalChecks",
304
307
  GlobalKPIs = "GlobalKPIs",
@@ -630,6 +633,7 @@ export declare enum aMN {
630
633
  Websites = "Websites",
631
634
  WebsiteTemplates = "WebsiteTemplates",
632
635
  WhatsappLogs = "WhatsappLogs",
636
+ WidgetEmbedSites = "WidgetEmbedSites",
633
637
  Widgets = "Widgets",
634
638
  WikiPages = "WikiPages",
635
639
  Wizards = "Wizards",
@@ -24,7 +24,9 @@ var aMN;
24
24
  aMN["AdvertiserWeeklyDomainKPIsByIndustries"] = "AdvertiserWeeklyDomainKPIsByIndustries";
25
25
  aMN["AdwordsLogs"] = "AdwordsLogs";
26
26
  aMN["AffClicks"] = "AffClicks";
27
+ aMN["AffiliateAttributions"] = "AffiliateAttributions";
27
28
  aMN["AffiliateCampaigns"] = "AffiliateCampaigns";
29
+ aMN["AffiliatePayouts"] = "AffiliatePayouts";
28
30
  aMN["Affiliates"] = "Affiliates";
29
31
  aMN["AffViews"] = "AffViews";
30
32
  aMN["Agencies"] = "Agencies";
@@ -303,6 +305,7 @@ var aMN;
303
305
  aMN["FormSubmissions"] = "FormSubmissions";
304
306
  aMN["FormViews"] = "FormViews";
305
307
  aMN["FractureMessages"] = "FractureMessages";
308
+ aMN["FXRates"] = "FXRates";
306
309
  aMN["Generations"] = "Generations";
307
310
  aMN["GlobalChecks"] = "GlobalChecks";
308
311
  aMN["GlobalKPIs"] = "GlobalKPIs";
@@ -634,6 +637,7 @@ var aMN;
634
637
  aMN["Websites"] = "Websites";
635
638
  aMN["WebsiteTemplates"] = "WebsiteTemplates";
636
639
  aMN["WhatsappLogs"] = "WhatsappLogs";
640
+ aMN["WidgetEmbedSites"] = "WidgetEmbedSites";
637
641
  aMN["Widgets"] = "Widgets";
638
642
  aMN["WikiPages"] = "WikiPages";
639
643
  aMN["Wizards"] = "Wizards";
@@ -762,6 +762,16 @@ const modelsAndRights = [
762
762
  allowDuplicate: false,
763
763
  updateBy: "_id",
764
764
  },
765
+ {
766
+ plural: "AffiliateAttributions",
767
+ singular: "AffiliateAttribution",
768
+ module: "affiliate",
769
+ right: "affiliate.attributions",
770
+ readOnly: true,
771
+ importable: false,
772
+ allowDuplicate: false,
773
+ updateBy: "_id",
774
+ },
765
775
  {
766
776
  plural: "AffiliateCampaigns",
767
777
  singular: "AffiliateCampaign",
@@ -772,6 +782,16 @@ const modelsAndRights = [
772
782
  allowDuplicate: true,
773
783
  updateBy: "_id",
774
784
  },
785
+ {
786
+ plural: "AffiliatePayouts",
787
+ singular: "AffiliatePayout",
788
+ module: "affiliate",
789
+ right: "affiliate.payouts",
790
+ readOnly: false,
791
+ importable: false,
792
+ allowDuplicate: false,
793
+ updateBy: "_id",
794
+ },
775
795
  {
776
796
  plural: "Affiliates",
777
797
  singular: "Affiliate",
@@ -3269,6 +3289,16 @@ const modelsAndRights = [
3269
3289
  allowDuplicate: false,
3270
3290
  updateBy: "_id",
3271
3291
  },
3292
+ {
3293
+ plural: "FXRates",
3294
+ singular: "FXRate",
3295
+ module: "accounting",
3296
+ right: "accounting.fxrates",
3297
+ readOnly: true,
3298
+ importable: false,
3299
+ allowDuplicate: false,
3300
+ updateBy: "_id",
3301
+ },
3272
3302
  {
3273
3303
  plural: "Generations",
3274
3304
  singular: "Generation",
@@ -6383,6 +6413,16 @@ const modelsAndRights = [
6383
6413
  allowDuplicate: false,
6384
6414
  updateBy: "_id",
6385
6415
  },
6416
+ {
6417
+ plural: "WidgetEmbedSites",
6418
+ singular: "WidgetEmbedSite",
6419
+ module: "marketing",
6420
+ right: "marketing.widgetembedsites",
6421
+ readOnly: true,
6422
+ importable: false,
6423
+ allowDuplicate: false,
6424
+ updateBy: "_id",
6425
+ },
6386
6426
  {
6387
6427
  plural: "Widgets",
6388
6428
  singular: "Widget",
@@ -11,6 +11,7 @@ export interface IAICostTracker extends IDefaultFields {
11
11
  _clientID?: ObjectId[];
12
12
  _subID?: ObjectId[];
13
13
  _agent?: ObjectId;
14
+ _user?: ObjectId;
14
15
  period: 'daily' | 'weekly' | 'monthly';
15
16
  periodStart: Date;
16
17
  periodEnd: Date;
@@ -13,6 +13,7 @@ export interface IAICronJob extends IDefaultFields {
13
13
  _workflow?: ObjectId;
14
14
  _command?: ObjectId;
15
15
  taskPrompt?: string;
16
+ payload?: any;
16
17
  maxDurationMs?: number;
17
18
  retryOnFailure?: boolean;
18
19
  maxRetries?: number;
@@ -17,6 +17,10 @@ export interface IAIKnowledgePack extends IDefaultFields {
17
17
  description?: string;
18
18
  status?: 'active' | 'inactive' | 'draft';
19
19
  version?: number;
20
+ category?: 'brand-voice' | 'company-info' | 'faq' | 'sop' | 'pricing' | 'product-catalog' | 'policies' | 'glossary' | 'contacts' | 'custom';
21
+ priority?: number;
22
+ scope?: 'private' | 'team' | 'customer' | 'global';
23
+ departments?: string[];
20
24
  entries?: IAIKnowledgePackEntry[];
21
25
  _agents?: ObjectId[];
22
26
  autoInject?: boolean;
@@ -26,4 +26,5 @@ export interface IAIPlugin extends IDefaultFields {
26
26
  };
27
27
  initOnStartup?: boolean;
28
28
  global?: boolean;
29
+ isTemplate?: boolean;
29
30
  }
@@ -37,4 +37,5 @@ export interface IAITool extends IDefaultFields {
37
37
  rateLimitPerDay?: number;
38
38
  deferredLoading?: boolean;
39
39
  global?: boolean;
40
+ isTemplate?: boolean;
40
41
  }
@@ -13,4 +13,14 @@ export interface IAffClick extends IaYOUneTrackingParams, IGeoIPLocationTracking
13
13
  cust_id?: string;
14
14
  cust_id2?: string;
15
15
  datetime?: Date;
16
+ /**
17
+ * Settlement that consumed this click. Set by `worker-payouts` to make
18
+ * settlement runs idempotent — a click already stamped is skipped on re-runs.
19
+ */
20
+ _settlementID?: ObjectId;
21
+ /**
22
+ * ISO 4217 currency snapshot at click time. Locked even if the customer
23
+ * changes their default currency later.
24
+ */
25
+ currency?: string;
16
26
  }
@@ -1,11 +1,139 @@
1
1
  import { IDefaultFields } from "./IDefaultFields";
2
+ /**
3
+ * Payout configuration on the affiliate. The affiliate picks one method on signup;
4
+ * admins may override during approval. The payments domain `worker-payouts` reads
5
+ * this subdoc to decide whether to enqueue a SEPA CSV row or a Stripe Connect transfer.
6
+ */
7
+ export interface IAffiliatePayoutConfig {
8
+ /** Picked execution path */
9
+ method?: "sepa-csv" | "stripe-connect";
10
+ iban?: string;
11
+ bic?: string;
12
+ accountholder?: string;
13
+ stripeConnectAccountId?: string;
14
+ paypalEmail?: string;
15
+ /** Minimum amount before a payout is generated (in `currency`) */
16
+ threshold?: number;
17
+ /** Payout currency (ISO 4217) — may differ from the click/conversion currency */
18
+ currency?: string;
19
+ /** When automatic settlements are generated for this affiliate */
20
+ schedule?: "weekly" | "monthly" | "quarterly" | "manual";
21
+ taxid?: string;
22
+ ustid?: string;
23
+ ustidValid?: boolean;
24
+ }
25
+ /**
26
+ * KYC subdoc on the affiliate. Documents themselves live in the platform's existing
27
+ * `Documents` collection (`IDocument`) and are uploaded via `platform/uploads/` with
28
+ * state `affiliate.kyc.upload`. The IDs are stored here for fast access; the reviewer
29
+ * UI in the SDUI admin loads the actual files via the existing media pipeline.
30
+ */
31
+ export interface IAffiliateKYCConfig {
32
+ status?: "not-started" | "submitted" | "in-review" | "approved" | "rejected";
33
+ /** References into the `Documents` collection (IDocument._id) */
34
+ documents?: ObjectId[];
35
+ submittedAt?: Date;
36
+ reviewedAt?: Date;
37
+ /** Reviewer (User who approved/rejected) */
38
+ reviewedBy?: ObjectId;
39
+ /** Free-form reason captured when status === "rejected" */
40
+ rejectionReason?: string;
41
+ }
42
+ /**
43
+ * Affiliate / Partner profile.
44
+ *
45
+ * Polymorphic identity: an affiliate row references one of three subject types via
46
+ * `subjectType` + `_subjectID`. The default is `consumer` — affiliate login is the
47
+ * existing consumer login flow (`Consumers.getAuthenticated`). The other two values
48
+ * exist to mirror the `IaYOUneTrackingParams.ayoune_aff_type` enum the tracking
49
+ * system already emits, so staff-affiliate and B2B-tenant-affiliate scenarios are
50
+ * supported without schema duplication.
51
+ *
52
+ * MLM hierarchy: up to 7 levels deep. `parent_affiliate` points at the recruiter,
53
+ * `tier_level` is the depth from the root (1..7), `ancestors[]` is a materialized
54
+ * path for fast tree queries (no recursive lookups at commission-cascade time).
55
+ *
56
+ * All legacy fields (`name`, `type`, `key`, `token`, `created`) remain optional so
57
+ * pre-existing rows continue to read without migration. New rows should populate
58
+ * the structured fields instead.
59
+ */
2
60
  export interface IAffiliate extends IDefaultFields {
3
61
  _customerID: ObjectId;
4
62
  _clientID?: ObjectId[];
5
63
  _subID?: ObjectId[];
64
+ /** Which collection `_subjectID` points at. Defaults to "consumer" for new rows. */
65
+ subjectType?: "consumer" | "user" | "customer";
66
+ /** Reference into Consumers | Users | aYOUneCustomers depending on subjectType */
67
+ _subjectID?: ObjectId;
68
+ /** Auto-generated slug; affiliate may customize once. Unique per `_customerID`. */
69
+ code?: string;
70
+ /** Set to true after the affiliate's first manual customization of `code`. */
71
+ codeLocked?: boolean;
72
+ /** Lifecycle. Two-step approval: pending-email → pending-approval → active */
73
+ status?: "pending-email" | "pending-approval" | "active" | "suspended" | "terminated";
74
+ /** Free-form tier label for display. Real commission tiers live on `_commissionGroupID`. */
75
+ tier?: string;
76
+ /** The affiliate that recruited this one. Null for root affiliates. */
77
+ parent_affiliate?: ObjectId;
78
+ /** Depth from the root (1..7). Computed at create/move time. */
79
+ tier_level?: number;
80
+ /**
81
+ * Materialized ancestor path for O(1) MLM cascade lookups. Order: closest
82
+ * ancestor first. Length matches `tier_level - 1`. Capped at 7.
83
+ */
84
+ ancestors?: ObjectId[];
85
+ email?: string;
86
+ phone?: string;
87
+ company?: string;
88
+ website?: string;
89
+ /** Affiliate's preferred display + payout currency (ISO 4217) */
90
+ preferredCurrency?: string;
91
+ /**
92
+ * "consumer" = portal login via consumer-app session cookie (default).
93
+ * "apiKey" = server-to-server access via `key`+`token` (the legacy fields below).
94
+ * "both" = either is accepted.
95
+ */
96
+ authMethod?: "consumer" | "apiKey" | "both";
97
+ /** Reference into CommissionGroups (kept in `config` module per CLAUDE.md). */
98
+ _commissionGroupID?: ObjectId;
99
+ /** Default sub_id stamped onto the affiliate's tracking links if not overridden */
100
+ defaultSubId?: string;
101
+ /** Default ad placement label */
102
+ defaultAdplace?: string;
103
+ /** Where the affiliate's tracking links land if no campaign override is present */
104
+ landingUrl?: string;
105
+ /** Extra query params to append to landing URLs */
106
+ landingParams?: any;
107
+ /** Domains the affiliate is allowed to embed widgets on */
108
+ allowedEmbedDomains?: string[];
109
+ payout?: IAffiliatePayoutConfig;
110
+ kyc?: IAffiliateKYCConfig;
111
+ approvedAt?: Date;
112
+ /** User._id of the admin who approved the application */
113
+ approvedBy?: ObjectId;
114
+ lastActiveAt?: Date;
115
+ emailVerifiedAt?: Date;
116
+ /** Hashed verification token (never store the raw token) */
117
+ emailVerificationToken?: string;
118
+ /** When the current verification token expires */
119
+ emailVerificationExpiresAt?: Date;
120
+ /**
121
+ * Free-form name for legacy rows. New rows should use the affiliate's email/code/profile
122
+ * fields instead. Kept optional for back-compat with pre-2026 documents.
123
+ */
6
124
  name?: string;
125
+ /**
126
+ * Legacy type field. Original STOREFire installs default this to the literal
127
+ * string "STOREFire"; new rows leave it blank. Retained for back-compat with
128
+ * existing reads.
129
+ *
130
+ * @deprecated Use `subjectType` instead — `type` carries no behaviour in the new system.
131
+ */
7
132
  type?: string;
133
+ /** Legacy API key for server-to-server access (paired with `token`) */
8
134
  key?: string;
135
+ /** Legacy API secret for server-to-server access (paired with `key`) */
9
136
  token?: string;
137
+ /** Legacy creation timestamp; new rows use IDefaultFields.createdAt */
10
138
  created?: Date;
11
139
  }
@@ -0,0 +1,48 @@
1
+ import { IDefaultFields } from "./IDefaultFields";
2
+ /**
3
+ * Per-visitor affiliate attribution record. Created when a visitor lands on a
4
+ * customer's site via an affiliate tracking link (`?ayoune_aff=XYZ`) and an
5
+ * `ayoune_aff_attribution` cookie is dropped.
6
+ *
7
+ * The cookie carries the random `cookieToken`; the server resolves it back to
8
+ * this row when a conversion fires. Idempotency-friendly: TTL-indexed on
9
+ * `expiresAt` so MongoDB cleans up stale rows automatically.
10
+ *
11
+ * Behaviour by `attributionMode`:
12
+ * - `last-click`: a new affiliate click overwrites the existing attribution (latest wins).
13
+ * - `first-click`: an existing non-expired attribution is preserved (first wins).
14
+ * - `session`: typically not persisted (session-only cookie), but may be stored
15
+ * for analytics with a very short `expiresAt`.
16
+ *
17
+ * Resolution priority comes from `IWebsite.partnerProgram.attribution*` plus
18
+ * any per-campaign override on `IAffiliateCampaign.attribution*`.
19
+ */
20
+ export interface IAffiliateAttribution extends IDefaultFields {
21
+ _customerID: ObjectId;
22
+ _clientID?: ObjectId[];
23
+ _subID?: ObjectId[];
24
+ /** Affiliate that gets credited for the eventual conversion */
25
+ _affiliateID: ObjectId;
26
+ /** Optional campaign context if the click carried `ayoune_campaign` */
27
+ _campaignID?: ObjectId;
28
+ /**
29
+ * Visitor identifier. Typically the value of `ayoune_fp` (FingerprintJS visitor ID)
30
+ * or another stable per-browser fingerprint.
31
+ */
32
+ visitorId: string;
33
+ /**
34
+ * Random server-issued token also stored in the `ayoune_aff_attribution`
35
+ * cookie. Used as the lookup key at conversion time.
36
+ */
37
+ cookieToken: string;
38
+ /** Attribution behaviour at the time the row was created */
39
+ attributionMode: "last-click" | "first-click" | "session";
40
+ /** TTL field — MongoDB drops the row after this date */
41
+ expiresAt: Date;
42
+ /** When the attribution was first established for this visitor */
43
+ firstSeenAt?: Date;
44
+ /** Most recent click that touched this attribution (last-click mode bumps this) */
45
+ lastTouchAt?: Date;
46
+ /** When a conversion claimed this attribution (null until consumed) */
47
+ consumedAt?: Date;
48
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -31,4 +31,8 @@ export interface IAffiliateCampaign extends IDefaultFields {
31
31
  banner_15?: string;
32
32
  banner_16?: string;
33
33
  banner_17?: string;
34
+ /** Override the attribution window (days) for this specific campaign */
35
+ attributionWindow?: number;
36
+ /** Override the attribution mode for this specific campaign */
37
+ attributionMode?: "last-click" | "first-click" | "session";
34
38
  }
@@ -0,0 +1,51 @@
1
+ import { IDefaultFields } from "./IDefaultFields";
2
+ /**
3
+ * An outgoing payment attempt for a single approved CommissionSettlement.
4
+ *
5
+ * Created by the payments domain `worker-payouts` when a settlement is approved.
6
+ * Carries multi-currency state captured at payout time so the payment is reproducible
7
+ * even if FX rates change later.
8
+ *
9
+ * Method-specific fields:
10
+ * - `sepa-csv`: payouts are batched into a daily CSV; `exportBatchId` links them.
11
+ * - `stripe-connect`: `transactionRef` holds the Stripe Transfer ID; webhook updates status.
12
+ */
13
+ export interface IAffiliatePayout extends IDefaultFields {
14
+ _customerID: ObjectId;
15
+ _clientID?: ObjectId[];
16
+ _subID?: ObjectId[];
17
+ _affiliateID: ObjectId;
18
+ /** Settlement this payout is paying out (1:1) */
19
+ _settlementID: ObjectId;
20
+ /** Amount paid in the payout currency */
21
+ amount: number;
22
+ /** Payout currency (ISO 4217) — affiliate's preferred currency */
23
+ currency: string;
24
+ /** Original commission amount before FX conversion */
25
+ sourceAmount?: number;
26
+ /** Original currency (the click/conversion currency) */
27
+ sourceCurrency?: string;
28
+ /** Applied FX conversion rate (1 sourceCurrency = fxRate × currency) */
29
+ fxRate?: number;
30
+ /** Date of the FX rate snapshot used for conversion */
31
+ fxRateDate?: Date;
32
+ /** Payment method picked from the affiliate's payout config */
33
+ method: "sepa-csv" | "stripe-connect";
34
+ /** Lifecycle status */
35
+ status: "queued" | "sent" | "failed" | "completed";
36
+ /** Provider-specific reference: Stripe Transfer ID, SEPA end-to-end ID, etc. */
37
+ transactionRef?: string;
38
+ /** When the worker first attempted the payout */
39
+ attemptedAt?: Date;
40
+ /** When the payout reached terminal completion (or failure) */
41
+ completedAt?: Date;
42
+ /** Raw provider response captured for debugging */
43
+ providerResponse?: any;
44
+ /** Error message when status === "failed" */
45
+ error?: string;
46
+ /**
47
+ * For sepa-csv method: identifier of the daily export batch this payout belongs to.
48
+ * The actual CSV is stored as an IDocument with category "affiliate-payout-batch".
49
+ */
50
+ exportBatchId?: string;
51
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -3,12 +3,30 @@ export interface ICommissionGroupGroup {
3
3
  group: ObjectId;
4
4
  commission: number;
5
5
  }
6
+ /**
7
+ * Commission rules. Lives in the `config` module per CLAUDE.md (verified
8
+ * 2026-04-08); the affiliate revival reads this entity via direct DB access
9
+ * rather than moving it.
10
+ *
11
+ * MLM cascade: `commissionByLevel[i]` is the percentage paid to the affiliate
12
+ * at level `i+1` of the upline chain (index 0 = direct affiliate, index 6 = 7th
13
+ * level upline). The cascade walker in core's `walkAncestorChain.ts` is capped
14
+ * at `maxTierDepth || 7`.
15
+ *
16
+ * Legacy `commission_continuance` is retained as deprecated for back-compat
17
+ * with pre-2026 documents that used a single-percentage cascade model.
18
+ */
6
19
  export interface ICommissionGroup extends IDefaultFields {
7
20
  _customerID: ObjectId;
8
21
  _clientID?: ObjectId[];
9
22
  _subID?: ObjectId[];
10
23
  name?: string;
11
24
  commission?: number;
25
+ /**
26
+ * @deprecated Replaced by `commissionByLevel[]`. Pre-2026 rows used this single
27
+ * percentage as the cascade rate for every upline level. New code should read
28
+ * `commissionByLevel`; only fall back to this when `commissionByLevel` is empty.
29
+ */
12
30
  commission_continuance?: number;
13
31
  base?: string;
14
32
  active?: boolean;
@@ -16,4 +34,30 @@ export interface ICommissionGroup extends IDefaultFields {
16
34
  include_exclude?: string;
17
35
  groups?: ICommissionGroupGroup[];
18
36
  created?: Date;
37
+ /**
38
+ * Per-tier cascade percentages. Index 0 = the affiliate that owns the click
39
+ * (level 1 / direct), index 1..6 = levels 2..7 of the upline chain.
40
+ *
41
+ * Example: `[10, 5, 3, 2, 1, 0.5, 0.25]` pays 10% to the direct affiliate,
42
+ * 5% to their parent, 3% to grandparent, etc.
43
+ *
44
+ * If `commissionByLevel` is empty/undefined, `calculateCommission()` falls
45
+ * back to the legacy single-percentage `commission_continuance` model.
46
+ */
47
+ commissionByLevel?: number[];
48
+ /** Cap on cascade depth (default 7, hard cap 7). */
49
+ maxTierDepth?: number;
50
+ /** Human-readable label shown alongside the rate */
51
+ tierLabel?: string;
52
+ /** Hex color used in admin/portal badges */
53
+ color?: string;
54
+ /** Free-form description shown to affiliates choosing a tier */
55
+ description?: string;
56
+ /** Per-group payout thresholds and hold periods */
57
+ thresholds?: {
58
+ /** Minimum amount before a settlement is generated for an affiliate in this group */
59
+ minPayout?: number;
60
+ /** Days to hold a settlement before it can be marked approved */
61
+ holdDays?: number;
62
+ };
19
63
  }
@@ -6,12 +6,29 @@ export interface ICommissionSettlementPosition {
6
6
  commission?: number;
7
7
  payout?: number;
8
8
  }
9
+ /**
10
+ * Commission settlement (Provisionsabrechnung). Lives in the `sale` module per
11
+ * CLAUDE.md (verified 2026-04-08); the affiliate revival reads + writes this
12
+ * entity via direct DB access without moving it.
13
+ *
14
+ * The affiliate `worker-payouts` job creates one settlement per
15
+ * `(affiliate, period, currency, tierLevel)` group. Idempotency is provided by
16
+ * stamping `_settlementID` onto every consumed `IAffClick` / `IShopClick` —
17
+ * re-running for the same period skips already-stamped clicks.
18
+ *
19
+ * Status enum (extended for the affiliate revival):
20
+ * `"draft" | "pending" | "approved" | "paid" | "rejected" | "hold"`.
21
+ */
9
22
  export interface ICommissionSettlement extends IDefaultFields {
10
23
  _customerID: ObjectId;
11
24
  _clientID?: ObjectId[];
12
25
  _subID?: ObjectId[];
13
26
  shortID: any;
14
27
  agent?: ObjectId;
28
+ /**
29
+ * Lifecycle: "draft" | "pending" | "approved" | "paid" | "rejected" | "hold"
30
+ * (typed as string for back-compat with existing documents).
31
+ */
15
32
  status?: string;
16
33
  sent?: boolean;
17
34
  from?: Date;
@@ -23,4 +40,17 @@ export interface ICommissionSettlement extends IDefaultFields {
23
40
  net_total?: number;
24
41
  tax?: number;
25
42
  total?: number;
43
+ /** Affiliate this settlement belongs to (null for non-affiliate settlements) */
44
+ _affiliateID?: ObjectId;
45
+ /** MLM tier this settlement represents — 1 = direct, 2..7 = upline cascade levels */
46
+ tierLevel?: number;
47
+ /** Reporting period this settlement covers */
48
+ period?: {
49
+ year: number;
50
+ month: number;
51
+ };
52
+ /** ISO 4217 currency of all `amount`/`commission`/`payout`/`total` fields */
53
+ currency?: string;
54
+ /** How this settlement was created (worker run vs admin manual creation) */
55
+ generatedBy?: "worker" | "manual";
26
56
  }
@@ -0,0 +1,27 @@
1
+ import { IDefaultFields } from "./IDefaultFields";
2
+ /**
3
+ * Daily FX reference rate, primarily fetched from the European Central Bank
4
+ * (`https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml`) by the
5
+ * `worker-fxrates` worker in `domains/accounting/`.
6
+ *
7
+ * ECB publishes rates against EUR (`base: "EUR"`). Triangulation via EUR is used
8
+ * for non-EUR-to-non-EUR conversions in `getFXRate()`.
9
+ *
10
+ * NOT multi-tenant in the usual sense — FX rates are global. The `_customerID`
11
+ * field on IDefaultFields is unused (typically null/undefined). A rate row is
12
+ * uniquely identified by `(base, currency, date)`.
13
+ */
14
+ export interface IFXRate extends IDefaultFields {
15
+ /** Base currency the rate is published against (ECB uses "EUR") */
16
+ base: string;
17
+ /** Target currency (ISO 4217) */
18
+ currency: string;
19
+ /** 1 base = rate target */
20
+ rate: number;
21
+ /** Rate date (UTC midnight of the day the rate applies to) */
22
+ date: Date;
23
+ /** Where this rate came from */
24
+ source: "ecb" | "manual";
25
+ /** When this row was inserted */
26
+ fetchedAt?: Date;
27
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -13,4 +13,13 @@ export interface IShopClick extends IaYOUneTrackingParams, IGeoIPLocationTrackin
13
13
  revenueDefault?: number;
14
14
  revenueEstimated?: number;
15
15
  revenueApproved?: number;
16
+ /** Affiliate credited for this conversion (resolved via attribution cookie at write time) */
17
+ _affiliateID?: ObjectId;
18
+ /**
19
+ * Settlement that consumed this conversion. Set by `worker-payouts` to make
20
+ * settlement runs idempotent.
21
+ */
22
+ _settlementID?: ObjectId;
23
+ /** ISO 4217 currency snapshot at conversion time */
24
+ currency?: string;
16
25
  }
@@ -1,3 +1,10 @@
1
+ /**
2
+ * @deprecated Replaced by IAutomationWorkflow + workflow-engine. Do NOT create new
3
+ * ITrigger documents — use IAutomationWorkflow with triggers[type:'event'] instead.
4
+ * Existing ITrigger documents continue to fire via the parallel legacy pipeline in
5
+ * `domains/automation/worker-automation/src/triggers/`. Scheduled removal: Q4 2026
6
+ * after the workflow-engine migration completes.
7
+ */
1
8
  import { IDefaultFields } from "./IDefaultFields";
2
9
  import { ITriggerAction } from "./ITriggerAction";
3
10
  export interface ITriggerDataFilter {
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @deprecated Replaced by IAutomationWorkflow + workflow-engine. Do NOT create new
3
+ * ITriggerAction documents — use IAutomationWorkflow nodes/linearConfig instead.
4
+ * Scheduled removal: Q4 2026.
5
+ */
1
6
  import { IDefaultFields } from "./IDefaultFields";
2
7
  export interface ITriggerAction extends IDefaultFields {
3
8
  check_category?: string;
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @deprecated Replaced by IAutomationWorkflow + workflow-engine. Do NOT create new
3
+ * ITriggerActions documents — use IAutomationWorkflow nodes/linearConfig instead.
4
+ * Scheduled removal: Q4 2026.
5
+ */
1
6
  import { IDefaultFields } from "./IDefaultFields";
2
7
  export interface ITriggerActions extends IDefaultFields {
3
8
  name?: string;
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @deprecated Log of legacy ITrigger executions. Replaced by IAutomationExecution
3
+ * for the new IAutomationWorkflow pipeline. Scheduled removal: Q4 2026.
4
+ */
1
5
  import { IDefaultFields } from "./IDefaultFields";
2
6
  export interface ITriggerActionsLog extends IDefaultFields {
3
7
  _customerID: ObjectId;
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @deprecated Replaced by IAutomationWorkflow + workflow-engine. Trigger chains are
3
+ * expressed as edges between nodes in IAutomationWorkflow. Do NOT create new
4
+ * ITriggerChain documents. Scheduled removal: Q4 2026.
5
+ */
1
6
  import { IDefaultFields } from "./IDefaultFields";
2
7
  export interface ITriggerChainAction {
3
8
  type?: string;
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @deprecated Grouping for legacy ITrigger documents. Replaced by IAutomationWorkflow's
3
+ * `tags` and `folder` fields. Do NOT create new ITriggerGroup documents.
4
+ * Scheduled removal: Q4 2026.
5
+ */
1
6
  import { IDefaultFields } from "./IDefaultFields";
2
7
  export interface ITriggerGroup extends IDefaultFields {
3
8
  _customerID: ObjectId;
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @deprecated Log of legacy ITrigger executions. Replaced by IAutomationExecution
3
+ * for the new IAutomationWorkflow pipeline. Scheduled removal: Q4 2026.
4
+ */
1
5
  import { IDefaultFields } from "./IDefaultFields";
2
6
  export interface ITriggerLog extends IDefaultFields {
3
7
  _customerID: ObjectId;
@@ -136,4 +136,49 @@ export interface IWebsite extends IDefaultFields {
136
136
  title?: string;
137
137
  };
138
138
  };
139
+ /**
140
+ * Optional embedding allowlist/blocklist enforcement for widgets shipped by
141
+ * `platform/widget-server`. When unset, embedding is open (matches the existing
142
+ * `cors: "*"` posture). Affiliates rely on open-by-default to embed on partner sites.
143
+ */
144
+ embedding?: {
145
+ /** If set, only these hostnames may embed widgets for this customer */
146
+ allowedDomains?: string[];
147
+ /** Hostnames that are always rejected (takes priority over allowedDomains) */
148
+ blockedDomains?: string[];
149
+ /** When true, requests without a Referer header are rejected */
150
+ requireReferer?: boolean;
151
+ /**
152
+ * When true, every embed observation is logged to `WidgetEmbedSites`
153
+ * even if it doesn't match any explicit rule (default: true).
154
+ */
155
+ logAllEmbeds?: boolean;
156
+ };
157
+ /**
158
+ * Per-website partner program / affiliate portal configuration.
159
+ * The partner portal in consumer-app reads this subdoc to gate signup,
160
+ * resolve the URL slug, and apply attribution defaults.
161
+ */
162
+ partnerProgram?: {
163
+ /** Master toggle — when false the /partnerprogram routes return 404 */
164
+ enabled?: boolean;
165
+ /**
166
+ * URL slug for the portal under this website. Default "partnerprogram"
167
+ * (consumer-app also mounts an "affiliates" alias). Override to e.g.
168
+ * "partner" or "werden-sie-partner".
169
+ */
170
+ slug?: string;
171
+ /** When true, /partnerprogram/register is mounted */
172
+ allowSignup?: boolean;
173
+ /** When true, signups skip manual admin approval (default: false) */
174
+ autoApprove?: boolean;
175
+ /** When true, affiliates must complete KYC before payouts are released */
176
+ requireKyc?: boolean;
177
+ /** Default attribution window in days. Per-campaign overrides on IAffiliateCampaign. */
178
+ attributionWindow?: number;
179
+ /** Default attribution mode applied to new attributions */
180
+ attributionMode?: "last-click" | "first-click" | "session";
181
+ /** Whether attribution is scoped per-website or shared across the whole customer */
182
+ attributionScope?: "per-website" | "per-customer";
183
+ };
139
184
  }
@@ -0,0 +1,30 @@
1
+ import { IDefaultFields } from "./IDefaultFields";
2
+ /**
3
+ * Rollup of where a customer's widgets are being embedded across third-party sites.
4
+ *
5
+ * Populated by the `worker-embed-sites` rollup job (every 15 min) from `Views` documents
6
+ * that carry `ayoune_embed_domain`. One row per `(_customerID, domain)`.
7
+ *
8
+ * Powers the partner portal "sites where your widgets appear" view and the admin
9
+ * SDUI screen that lets staff tag domains as allowed/blocked or link them to a
10
+ * specific affiliate.
11
+ */
12
+ export interface IWidgetEmbedSite extends IDefaultFields {
13
+ _customerID: ObjectId;
14
+ _clientID?: ObjectId[];
15
+ _subID?: ObjectId[];
16
+ /** Hostname of the embedding page (e.g. "partner.example.com") */
17
+ domain: string;
18
+ /** When this domain was first observed embedding any widget */
19
+ firstSeenAt?: Date;
20
+ /** Most recent observation */
21
+ lastSeenAt?: Date;
22
+ /** Total view count across all widgets on this domain */
23
+ viewCount?: number;
24
+ /** Distinct widget types observed on this domain (e.g. ["cta", "form", "ratings"]) */
25
+ widgetTypes?: string[];
26
+ /** Optional link to the affiliate that owns the embedding relationship */
27
+ _affiliateID?: ObjectId;
28
+ /** Admin classification: observed (default), allowed (allowlisted), blocked (blocklisted) */
29
+ status?: "observed" | "allowed" | "blocked";
30
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -213,6 +213,14 @@ export interface IaYOUneTrackingParams extends IFingerprintData {
213
213
  ayoune_partner?: string;
214
214
  ayoune_aff?: string;
215
215
  ayoune_aff_type?: "user" | "customer" | "consumer";
216
+ /** Hostname of the third-party page that embedded the widget firing this hit */
217
+ ayoune_embed_domain?: string;
218
+ /** Full URL of the embedding page (when accessible) */
219
+ ayoune_embed_url?: string;
220
+ /** document.title of the embedding page (when accessible) */
221
+ ayoune_embed_title?: string;
222
+ /** Referrer at the embedding page level (separate from the in-iframe referrer) */
223
+ ayoune_embed_referrer?: string;
216
224
  ayoune_actions?: any[];
217
225
  ayoune_params?: any[];
218
226
  ayoune_ref?: string;
@@ -18,7 +18,9 @@ export * from "./IAdvertiserAPI";
18
18
  export * from "./IAdwordsLog";
19
19
  export * from "./IAffClick";
20
20
  export * from "./IAffiliate";
21
+ export * from "./IAffiliateAttribution";
21
22
  export * from "./IAffiliateCampaign";
23
+ export * from "./IAffiliatePayout";
22
24
  export * from "./IAffView";
23
25
  export * from "./IAgency";
24
26
  export * from "./IAgendaJob";
@@ -318,6 +320,7 @@ export * from "./IFormSubmission";
318
320
  export * from "./IFormView";
319
321
  export * from "./IFractureMessage";
320
322
  export * from "./IFreeFields";
323
+ export * from "./IFXRate";
321
324
  export * from "./IGeneration";
322
325
  export * from "./IGeoIPLocationTracking";
323
326
  export * from "./IGlobalCheck";
@@ -679,6 +682,7 @@ export * from "./IWebsiteTemplate";
679
682
  export * from "./IPageBlock";
680
683
  export * from "./IWhatsappLog";
681
684
  export * from "./IWidget";
685
+ export * from "./IWidgetEmbedSite";
682
686
  export * from "./IWikiPage";
683
687
  export * from "./IWizard";
684
688
  export * from "./IWorkCenter";
@@ -34,7 +34,9 @@ __exportStar(require("./IAdvertiserAPI"), exports);
34
34
  __exportStar(require("./IAdwordsLog"), exports);
35
35
  __exportStar(require("./IAffClick"), exports);
36
36
  __exportStar(require("./IAffiliate"), exports);
37
+ __exportStar(require("./IAffiliateAttribution"), exports);
37
38
  __exportStar(require("./IAffiliateCampaign"), exports);
39
+ __exportStar(require("./IAffiliatePayout"), exports);
38
40
  __exportStar(require("./IAffView"), exports);
39
41
  __exportStar(require("./IAgency"), exports);
40
42
  __exportStar(require("./IAgendaJob"), exports);
@@ -334,6 +336,7 @@ __exportStar(require("./IFormSubmission"), exports);
334
336
  __exportStar(require("./IFormView"), exports);
335
337
  __exportStar(require("./IFractureMessage"), exports);
336
338
  __exportStar(require("./IFreeFields"), exports);
339
+ __exportStar(require("./IFXRate"), exports);
337
340
  __exportStar(require("./IGeneration"), exports);
338
341
  __exportStar(require("./IGeoIPLocationTracking"), exports);
339
342
  __exportStar(require("./IGlobalCheck"), exports);
@@ -695,6 +698,7 @@ __exportStar(require("./IWebsiteTemplate"), exports);
695
698
  __exportStar(require("./IPageBlock"), exports);
696
699
  __exportStar(require("./IWhatsappLog"), exports);
697
700
  __exportStar(require("./IWidget"), exports);
701
+ __exportStar(require("./IWidgetEmbedSite"), exports);
698
702
  __exportStar(require("./IWikiPage"), exports);
699
703
  __exportStar(require("./IWizard"), exports);
700
704
  __exportStar(require("./IWorkCenter"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tolinax/ayoune-interfaces",
3
- "version": "2026.21.0",
3
+ "version": "2026.23.0",
4
4
  "description": "Houses TypeScript interfaces for aYOUne",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",