@optizio/merchant-identity 0.5.2 → 0.7.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.
- package/dist/index.d.ts +488 -0
- package/dist/index.js +74 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -472,3 +472,491 @@ export declare const NOOP_REVENUE: RevenueClient;
|
|
|
472
472
|
* without the service bound.
|
|
473
473
|
*/
|
|
474
474
|
export declare function revenue(binding: RevenueClient | null | undefined, disabled?: boolean | string): RevenueClient;
|
|
475
|
+
/**
|
|
476
|
+
* One app's affiliate program. The only supported economics are a percentage
|
|
477
|
+
* of transaction net, lifetime; `defaultRateBps` is data, not a hard-coded
|
|
478
|
+
* calculation, and each referral snapshots the rate at claim time so a future
|
|
479
|
+
* default change does not alter existing referrals.
|
|
480
|
+
*/
|
|
481
|
+
export interface AffiliateProgram {
|
|
482
|
+
id: string;
|
|
483
|
+
/** References `partner_apps.app_gid`; unique per app in this stage. */
|
|
484
|
+
appGid: string;
|
|
485
|
+
name: string;
|
|
486
|
+
/** Percentage of transaction net in basis points. 2000 = 20%. */
|
|
487
|
+
defaultRateBps: number;
|
|
488
|
+
/** 'active' | 'inactive'. */
|
|
489
|
+
status: string;
|
|
490
|
+
createdAt: string;
|
|
491
|
+
updatedAt: string;
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* One portfolio-wide person or business receiving commission. There is
|
|
495
|
+
* deliberately no status/archive field: `payoutHold` with a reason is the only
|
|
496
|
+
* mechanism that pauses payments, and it does NOT terminate lifetime referral
|
|
497
|
+
* rights — commissions keep accruing while held. Email is searchable but is
|
|
498
|
+
* not identity.
|
|
499
|
+
*/
|
|
500
|
+
export interface Affiliate {
|
|
501
|
+
id: string;
|
|
502
|
+
name: string;
|
|
503
|
+
/** Contact email; separate from the payout destination. */
|
|
504
|
+
email: string | null;
|
|
505
|
+
payoutHold: boolean;
|
|
506
|
+
payoutHoldReason: string | null;
|
|
507
|
+
/** e.g. 'paypal' or 'external_account'; null until configured. */
|
|
508
|
+
payoutMethod: string | null;
|
|
509
|
+
/** A PayPal email or opaque external account reference. No bank secrets. */
|
|
510
|
+
payoutDestination: string | null;
|
|
511
|
+
createdAt: string;
|
|
512
|
+
updatedAt: string;
|
|
513
|
+
}
|
|
514
|
+
/** An affiliate's participation in one app's program. */
|
|
515
|
+
export interface AffiliateMembership {
|
|
516
|
+
id: string;
|
|
517
|
+
affiliateId: string;
|
|
518
|
+
programId: string;
|
|
519
|
+
/** 'active' | 'inactive'. Does not implicitly cancel existing referrals. */
|
|
520
|
+
status: string;
|
|
521
|
+
joinedAt: string | null;
|
|
522
|
+
/** Original referral codes with their source namespaces, if imported. */
|
|
523
|
+
legacyCodes: {
|
|
524
|
+
source: string;
|
|
525
|
+
code: string;
|
|
526
|
+
}[];
|
|
527
|
+
createdAt: string;
|
|
528
|
+
updatedAt: string;
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* The continuing claim: this affiliate earns commission from this shop for
|
|
532
|
+
* this app. `referredAt` is the historical referral date; `accrualFrom` is the
|
|
533
|
+
* local calculation boundary — they are not interchangeable. Uninstall,
|
|
534
|
+
* cancellation, freeze, and reinstall do not remove attribution.
|
|
535
|
+
*/
|
|
536
|
+
export interface AffiliateReferral {
|
|
537
|
+
id: string;
|
|
538
|
+
membershipId: string;
|
|
539
|
+
appGid: string;
|
|
540
|
+
/** Normalized (lowercase, protocol-less) myshopify host. */
|
|
541
|
+
shopDomain: string;
|
|
542
|
+
/** Verified Partner shop GID; null when redacted or unknown. */
|
|
543
|
+
shopGid: string | null;
|
|
544
|
+
referredAt: string | null;
|
|
545
|
+
/** Snapshot of the program rate at claim creation (2000 = 20%). */
|
|
546
|
+
rateBps: number;
|
|
547
|
+
accrualFrom: string;
|
|
548
|
+
/** 'active' | 'ended'. */
|
|
549
|
+
status: string;
|
|
550
|
+
endedAt: string | null;
|
|
551
|
+
endReason: string | null;
|
|
552
|
+
createdAt: string;
|
|
553
|
+
updatedAt: string;
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* Append-only money owed. `kind` is 'commission' | 'adjustment'; `amountMinor`
|
|
557
|
+
* is signed (adjustments may be negative). Corrections append entries — an
|
|
558
|
+
* earned amount is never edited or deleted, even before payout. All
|
|
559
|
+
* `*Minor` fields are integer minor units of `currencyCode`.
|
|
560
|
+
*/
|
|
561
|
+
export interface AffiliateLedgerEntry {
|
|
562
|
+
id: string;
|
|
563
|
+
affiliateId: string;
|
|
564
|
+
/** Null for manual adjustments, which have no program context. */
|
|
565
|
+
programId: string | null;
|
|
566
|
+
/** Null for historical/manual records. */
|
|
567
|
+
referralId: string | null;
|
|
568
|
+
kind: 'commission' | 'adjustment';
|
|
569
|
+
amountMinor: number;
|
|
570
|
+
currencyCode: string;
|
|
571
|
+
/** Business date the entry concerns; not the insert timestamp. */
|
|
572
|
+
effectiveAt: string;
|
|
573
|
+
recordedAt: string;
|
|
574
|
+
partnerTransactionGid: string | null;
|
|
575
|
+
/** Snapshots preserved for sweep change detection. */
|
|
576
|
+
netMinorSnapshot: number | null;
|
|
577
|
+
rateBpsSnapshot: number | null;
|
|
578
|
+
/** 1 = 20% of netAmount from cutover onward; null for imports. */
|
|
579
|
+
calculationVersion: number | null;
|
|
580
|
+
/** For a reversing adjustment: the commission it reverses. */
|
|
581
|
+
relatedEntryId: string | null;
|
|
582
|
+
reason: string | null;
|
|
583
|
+
actorId: string | null;
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* A historical payment or a fixed proposal for a manual payment. Payouts span
|
|
587
|
+
* apps; their items retain app-level attribution. `destinationSnapshot` is
|
|
588
|
+
* frozen at preparation so later contact changes cannot rewrite history.
|
|
589
|
+
*/
|
|
590
|
+
export interface AffiliatePayout {
|
|
591
|
+
id: string;
|
|
592
|
+
affiliateId: string;
|
|
593
|
+
currencyCode: string;
|
|
594
|
+
/** `YYYY-MM` preparation cycle, null for imported history. */
|
|
595
|
+
cycleMonth: string | null;
|
|
596
|
+
/** Liability cutoff the proposal was fixed at. */
|
|
597
|
+
cutoffAt: string | null;
|
|
598
|
+
/** 'pending' | 'processing' | 'paid' | 'cancelled'. `paid` is terminal. */
|
|
599
|
+
status: 'pending' | 'processing' | 'paid' | 'cancelled';
|
|
600
|
+
amountMinor: number;
|
|
601
|
+
paymentMethod: string | null;
|
|
602
|
+
destinationSnapshot: string | null;
|
|
603
|
+
/** Legacy invoice number or payment-provider reference, if any. */
|
|
604
|
+
externalReference: string | null;
|
|
605
|
+
preparedAt: string | null;
|
|
606
|
+
processingAt: string | null;
|
|
607
|
+
paidAt: string | null;
|
|
608
|
+
paidBy: string | null;
|
|
609
|
+
failureReason: string | null;
|
|
610
|
+
}
|
|
611
|
+
/** One payout's allocation of a ledger entry; supports imported partials. */
|
|
612
|
+
export interface AffiliatePayoutItem {
|
|
613
|
+
payoutId: string;
|
|
614
|
+
ledgerEntryId: string;
|
|
615
|
+
/** Signed: negative entries can be settled by negative allocations. */
|
|
616
|
+
allocatedMinor: number;
|
|
617
|
+
/** Null while reserved; set when a cancellation released it. */
|
|
618
|
+
releasedAt: string | null;
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Per affiliate and currency. Negative balances are valid and carry forward;
|
|
622
|
+
* nothing here is clamped to zero. Freshness is explicit so a reader can tell
|
|
623
|
+
* a genuine zero from stale or unavailable data.
|
|
624
|
+
*/
|
|
625
|
+
export interface AffiliateBalance {
|
|
626
|
+
affiliateId: string;
|
|
627
|
+
currencyCode: string;
|
|
628
|
+
earnedMinor: number;
|
|
629
|
+
adjustmentsMinor: number;
|
|
630
|
+
/** earned + adjustments − settled paid allocations. */
|
|
631
|
+
outstandingMinor: number;
|
|
632
|
+
/** Allocations in pending or processing payouts. */
|
|
633
|
+
reservedMinor: number;
|
|
634
|
+
/** outstanding − reserved. */
|
|
635
|
+
availableMinor: number;
|
|
636
|
+
/** How current the ledger behind these numbers is (last recorded_at). */
|
|
637
|
+
freshness: string | null;
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* Opaque cursor for list endpoints. Servers return the next page's cursor
|
|
641
|
+
* alongside results; clients pass it back verbatim. Null on the last page.
|
|
642
|
+
*/
|
|
643
|
+
export interface AffiliateListCursor {
|
|
644
|
+
cursor: string | null;
|
|
645
|
+
/** Hard cap on returned rows. Servers clamp to their own bound. */
|
|
646
|
+
limit?: number;
|
|
647
|
+
}
|
|
648
|
+
/** Common filters for affiliate list queries; all optional. */
|
|
649
|
+
export interface AffiliateListFilters {
|
|
650
|
+
affiliateId?: string;
|
|
651
|
+
appGid?: string;
|
|
652
|
+
status?: string;
|
|
653
|
+
/** Inclusive UTC ISO bound. */
|
|
654
|
+
from?: string;
|
|
655
|
+
/** Inclusive UTC ISO bound. */
|
|
656
|
+
to?: string;
|
|
657
|
+
}
|
|
658
|
+
export interface AffiliateListQuery extends AffiliateListCursor, AffiliateListFilters {
|
|
659
|
+
}
|
|
660
|
+
/** Page-shaped result; every list RPC returns this so pagination is uniform. */
|
|
661
|
+
export interface AffiliatePage<T> {
|
|
662
|
+
items: T[];
|
|
663
|
+
nextCursor: string | null;
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* Update an affiliate's contact and payout settings. Only the fields present
|
|
667
|
+
* are changed. Setting or clearing a hold takes effect for future payouts
|
|
668
|
+
* only; accrued obligations are unaffected.
|
|
669
|
+
*/
|
|
670
|
+
export interface AffiliateUpdateInput {
|
|
671
|
+
affiliateId: string;
|
|
672
|
+
name?: string;
|
|
673
|
+
email?: string | null;
|
|
674
|
+
payoutHold?: boolean;
|
|
675
|
+
payoutHoldReason?: string | null;
|
|
676
|
+
payoutMethod?: string | null;
|
|
677
|
+
payoutDestination?: string | null;
|
|
678
|
+
/** Required when `payoutHold` changes: why the operator moved it. */
|
|
679
|
+
reason?: string;
|
|
680
|
+
actorId: string;
|
|
681
|
+
}
|
|
682
|
+
/** Set the minimum payout amount (minor units, USD this stage). */
|
|
683
|
+
export interface AffiliatePayoutPolicyInput {
|
|
684
|
+
/** Null disables preparation until explicitly configured. */
|
|
685
|
+
minimumPayoutMinor: number | null;
|
|
686
|
+
reason: string;
|
|
687
|
+
actorId: string;
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* Stage a Shoffi/Mantle export for validation. The payload is the original
|
|
691
|
+
* records verbatim (no secrets); content is hashed server-side for
|
|
692
|
+
* repeat-import detection.
|
|
693
|
+
*/
|
|
694
|
+
export interface AffiliateImportBatchInput {
|
|
695
|
+
source: 'shoffi' | 'mantle';
|
|
696
|
+
sourceAccount: string | null;
|
|
697
|
+
/** UTC timestamp the source exported at, when known. */
|
|
698
|
+
exportedAt: string | null;
|
|
699
|
+
/** Source schema version of the export shape, when known. */
|
|
700
|
+
schemaVersion: string | null;
|
|
701
|
+
records: unknown[];
|
|
702
|
+
idempotencyKey: string;
|
|
703
|
+
actorId: string;
|
|
704
|
+
}
|
|
705
|
+
/** Activate a validated import; partial data must not leak into balances. */
|
|
706
|
+
export interface AffiliateImportActivateInput {
|
|
707
|
+
batchId: string;
|
|
708
|
+
idempotencyKey: string;
|
|
709
|
+
actorId: string;
|
|
710
|
+
}
|
|
711
|
+
/** Explicitly map one source record to a canonical entity. */
|
|
712
|
+
export interface AffiliateImportResolveInput {
|
|
713
|
+
sourceRecordId: string;
|
|
714
|
+
canonicalEntityType: string;
|
|
715
|
+
canonicalEntityId: string;
|
|
716
|
+
reason: string;
|
|
717
|
+
actorId: string;
|
|
718
|
+
}
|
|
719
|
+
/**
|
|
720
|
+
* One approved program in the first canonical relationship seed. The app
|
|
721
|
+
* must already exist in Partner data; this operation does not create apps.
|
|
722
|
+
*/
|
|
723
|
+
export interface AffiliateRelationshipSeedProgramInput {
|
|
724
|
+
id: string;
|
|
725
|
+
/** The app-local Shoffi identifier explicitly mapped to this Partner app. */
|
|
726
|
+
sourceAppId: string;
|
|
727
|
+
appGid: string;
|
|
728
|
+
name: string;
|
|
729
|
+
defaultRateBps: number;
|
|
730
|
+
status: 'active' | 'inactive';
|
|
731
|
+
/** Approved UTC commission cutover for this app's referrals. */
|
|
732
|
+
cutoverAt: string;
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* An approved canonical affiliate. Relationship migration keeps every
|
|
736
|
+
* affiliate on payout hold until payout policy and historical balances have
|
|
737
|
+
* separately been approved.
|
|
738
|
+
*/
|
|
739
|
+
export interface AffiliateRelationshipSeedAffiliateInput {
|
|
740
|
+
id: string;
|
|
741
|
+
name: string;
|
|
742
|
+
email: string | null;
|
|
743
|
+
payoutHoldReason: string;
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* Maps one app-scoped Shoffi relation identity to an approved canonical
|
|
747
|
+
* affiliate/program membership. The source identity is retained in the seed
|
|
748
|
+
* audit record and must not be inferred from display names or emails.
|
|
749
|
+
*/
|
|
750
|
+
export interface AffiliateRelationshipSeedMembershipInput {
|
|
751
|
+
id: string;
|
|
752
|
+
affiliateId: string;
|
|
753
|
+
programId: string;
|
|
754
|
+
sourceAppId: string;
|
|
755
|
+
sourceRelationId: string;
|
|
756
|
+
joinedAt: string | null;
|
|
757
|
+
status: 'active' | 'inactive';
|
|
758
|
+
legacyCodes: {
|
|
759
|
+
source: string;
|
|
760
|
+
code: string;
|
|
761
|
+
}[];
|
|
762
|
+
}
|
|
763
|
+
/** An approved continuing or ended Shoffi referral relationship. */
|
|
764
|
+
export interface AffiliateRelationshipSeedReferralInput {
|
|
765
|
+
id: string;
|
|
766
|
+
membershipId: string;
|
|
767
|
+
appGid: string;
|
|
768
|
+
shopDomain: string;
|
|
769
|
+
shopGid: string | null;
|
|
770
|
+
referredAt: string | null;
|
|
771
|
+
rateBps: number;
|
|
772
|
+
accrualFrom: string;
|
|
773
|
+
status: 'active' | 'ended';
|
|
774
|
+
endedAt: string | null;
|
|
775
|
+
endReason: string | null;
|
|
776
|
+
}
|
|
777
|
+
/**
|
|
778
|
+
* The complete operator-reviewed canonical relationship seed. It deliberately
|
|
779
|
+
* excludes historical commissions, payouts, and payout items.
|
|
780
|
+
*/
|
|
781
|
+
export interface AffiliateRelationshipSeedInput {
|
|
782
|
+
/** The reviewed Shoffi account scope that supplied the relation IDs. */
|
|
783
|
+
sourceAccount: string;
|
|
784
|
+
programs: AffiliateRelationshipSeedProgramInput[];
|
|
785
|
+
affiliates: AffiliateRelationshipSeedAffiliateInput[];
|
|
786
|
+
memberships: AffiliateRelationshipSeedMembershipInput[];
|
|
787
|
+
referrals: AffiliateRelationshipSeedReferralInput[];
|
|
788
|
+
idempotencyKey: string;
|
|
789
|
+
reason: string;
|
|
790
|
+
actorId: string;
|
|
791
|
+
}
|
|
792
|
+
export interface AffiliateRelationshipSeedResult {
|
|
793
|
+
programIds: string[];
|
|
794
|
+
affiliateIds: string[];
|
|
795
|
+
membershipIds: string[];
|
|
796
|
+
referralIds: string[];
|
|
797
|
+
}
|
|
798
|
+
/** Ask for a (catch-up) commission sweep pass; returns immediately. */
|
|
799
|
+
export interface AffiliateSweepInput {
|
|
800
|
+
/** Restrict the pass to one app, null = all. */
|
|
801
|
+
appGid: string | null;
|
|
802
|
+
reason: string;
|
|
803
|
+
actorId: string;
|
|
804
|
+
}
|
|
805
|
+
/** The month to preview/prepare payouts for; defaults to the latest cycle. */
|
|
806
|
+
export interface AffiliatePayoutCycleInput {
|
|
807
|
+
/** `YYYY-MM`. */
|
|
808
|
+
cycleMonth: string;
|
|
809
|
+
idempotencyKey: string;
|
|
810
|
+
actorId: string;
|
|
811
|
+
}
|
|
812
|
+
/** Dry-run of monthly preparation; writes nothing. */
|
|
813
|
+
export interface AffiliatePayoutPreviewInput extends AffiliatePayoutCycleInput {
|
|
814
|
+
}
|
|
815
|
+
/** Begin a manual payment for a proposed payout (pending -> processing). */
|
|
816
|
+
export interface AffiliateBeginPayoutInput {
|
|
817
|
+
payoutId: string;
|
|
818
|
+
idempotencyKey: string;
|
|
819
|
+
reason: string;
|
|
820
|
+
actorId: string;
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* Confirm a payout as paid (terminal). Requires a payment reference, actual
|
|
824
|
+
* date, and actor; duplicate identical confirmations are idempotent and
|
|
825
|
+
* conflicting ones fail.
|
|
826
|
+
*/
|
|
827
|
+
export interface AffiliateRecordPaidInput {
|
|
828
|
+
payoutId: string;
|
|
829
|
+
externalReference: string;
|
|
830
|
+
paidAt: string;
|
|
831
|
+
idempotencyKey: string;
|
|
832
|
+
reason: string;
|
|
833
|
+
actorId: string;
|
|
834
|
+
}
|
|
835
|
+
/** Record that no transfer happened (processing -> pending). */
|
|
836
|
+
export interface AffiliateRecordNotSentInput {
|
|
837
|
+
payoutId: string;
|
|
838
|
+
failureReason: string;
|
|
839
|
+
idempotencyKey: string;
|
|
840
|
+
reason: string;
|
|
841
|
+
actorId: string;
|
|
842
|
+
}
|
|
843
|
+
/** Cancel a proposed payout, releasing its reservations (pending -> cancelled). */
|
|
844
|
+
export interface AffiliateCancelPayoutInput {
|
|
845
|
+
payoutId: string;
|
|
846
|
+
idempotencyKey: string;
|
|
847
|
+
reason: string;
|
|
848
|
+
actorId: string;
|
|
849
|
+
}
|
|
850
|
+
/**
|
|
851
|
+
* Append a signed manual adjustment to an affiliate's ledger. Adjustments
|
|
852
|
+
* may be negative and may concern already-paid commissions; they affect the
|
|
853
|
+
* remaining balance, not the past payment.
|
|
854
|
+
*/
|
|
855
|
+
export interface AffiliateAdjustmentInput {
|
|
856
|
+
affiliateId: string;
|
|
857
|
+
currencyCode: string;
|
|
858
|
+
/** Signed minor units. */
|
|
859
|
+
amountMinor: number;
|
|
860
|
+
effectiveAt: string;
|
|
861
|
+
reason: string;
|
|
862
|
+
actorId: string;
|
|
863
|
+
/** Optionally link the commission entry this adjustment reverses. */
|
|
864
|
+
relatedEntryId: string | null;
|
|
865
|
+
idempotencyKey: string;
|
|
866
|
+
}
|
|
867
|
+
/** A proposed monthly payout from a preview run; writes nothing. */
|
|
868
|
+
export interface AffiliatePayoutProposal {
|
|
869
|
+
affiliateId: string;
|
|
870
|
+
currencyCode: string;
|
|
871
|
+
cycleMonth: string;
|
|
872
|
+
cutoffAt: string;
|
|
873
|
+
amountMinor: number;
|
|
874
|
+
/** Why this affiliate was skipped, when it was. */
|
|
875
|
+
skippedReason: string | null;
|
|
876
|
+
}
|
|
877
|
+
/**
|
|
878
|
+
* The read surface over affiliate data, exposed by the same Worker as
|
|
879
|
+
* `IdentityClient` and `RevenueClient` (entrypoint `MerchantAffiliates`).
|
|
880
|
+
* Reads never trigger computation or call Shopify; they read tables the
|
|
881
|
+
* sweep and import jobs have already built.
|
|
882
|
+
*/
|
|
883
|
+
export interface AffiliateClient {
|
|
884
|
+
listPrograms(): Promise<AffiliateProgram[]>;
|
|
885
|
+
listAffiliates(query?: AffiliateListQuery): Promise<AffiliatePage<Affiliate>>;
|
|
886
|
+
getAffiliate(id: string): Promise<Affiliate | null>;
|
|
887
|
+
listReferrals(query?: AffiliateListQuery): Promise<AffiliatePage<AffiliateReferral>>;
|
|
888
|
+
getAffiliateBalance(input: {
|
|
889
|
+
affiliateId: string;
|
|
890
|
+
currencyCode?: string;
|
|
891
|
+
}): Promise<AffiliateBalance[]>;
|
|
892
|
+
listLedgerEntries(query?: AffiliateListQuery): Promise<AffiliatePage<AffiliateLedgerEntry>>;
|
|
893
|
+
listPayouts(query?: AffiliateListQuery): Promise<AffiliatePage<AffiliatePayout>>;
|
|
894
|
+
getPayout(id: string): Promise<AffiliatePayout | null>;
|
|
895
|
+
getAffiliateStatus(): Promise<AffiliateDomainStatus>;
|
|
896
|
+
}
|
|
897
|
+
/** Operational summary for the affiliate domain as a whole. */
|
|
898
|
+
export interface AffiliateDomainStatus {
|
|
899
|
+
/** Whether the affiliate feature is enabled in this deployment. */
|
|
900
|
+
enabled: boolean;
|
|
901
|
+
/** False until a payout threshold has been explicitly configured. */
|
|
902
|
+
payoutThresholdConfigured: boolean;
|
|
903
|
+
/** Count of import batches not yet activated. */
|
|
904
|
+
pendingImportBatches: number;
|
|
905
|
+
/** Count of unresolved reconciliation issues across jobs. */
|
|
906
|
+
openIssues: number;
|
|
907
|
+
}
|
|
908
|
+
/**
|
|
909
|
+
* Trusted-operator write surface (entrypoint `MerchantAffiliateAdmin`).
|
|
910
|
+
* Unlike `NOOP_REVENUE`-style read clients, an unavailable admin client MUST
|
|
911
|
+
* fail rather than pretend an import or payment was recorded.
|
|
912
|
+
*/
|
|
913
|
+
export interface AffiliateAdminClient {
|
|
914
|
+
updateAffiliate(input: AffiliateUpdateInput): Promise<Affiliate>;
|
|
915
|
+
setPayoutPolicy(input: AffiliatePayoutPolicyInput): Promise<void>;
|
|
916
|
+
seedRelationship(input: AffiliateRelationshipSeedInput): Promise<AffiliateRelationshipSeedResult>;
|
|
917
|
+
stageImportBatch(input: AffiliateImportBatchInput): Promise<{
|
|
918
|
+
batchId: string;
|
|
919
|
+
}>;
|
|
920
|
+
validateImport(id: string): Promise<{
|
|
921
|
+
valid: boolean;
|
|
922
|
+
errorCount: number;
|
|
923
|
+
}>;
|
|
924
|
+
activateImport(input: AffiliateImportActivateInput): Promise<void>;
|
|
925
|
+
resolveImportRecord(input: AffiliateImportResolveInput): Promise<void>;
|
|
926
|
+
requestCommissionSweep(input: AffiliateSweepInput): Promise<void>;
|
|
927
|
+
previewMonthlyPayouts(input: AffiliatePayoutPreviewInput): Promise<AffiliatePayoutProposal[]>;
|
|
928
|
+
prepareMonthlyPayouts(input: AffiliatePayoutCycleInput): Promise<AffiliatePayout[]>;
|
|
929
|
+
beginPayout(input: AffiliateBeginPayoutInput): Promise<AffiliatePayout>;
|
|
930
|
+
recordPayoutPaid(input: AffiliateRecordPaidInput): Promise<AffiliatePayout>;
|
|
931
|
+
recordPayoutNotSent(input: AffiliateRecordNotSentInput): Promise<AffiliatePayout>;
|
|
932
|
+
cancelPayout(input: AffiliateCancelPayoutInput): Promise<AffiliatePayout>;
|
|
933
|
+
recordAdjustment(input: AffiliateAdjustmentInput): Promise<AffiliateLedgerEntry>;
|
|
934
|
+
}
|
|
935
|
+
/**
|
|
936
|
+
* Deliberately narrow import-staging surface for the Access-protected
|
|
937
|
+
* dashboard. It does not expose validation, activation, payouts, or any
|
|
938
|
+
* other affiliate administration operation.
|
|
939
|
+
*/
|
|
940
|
+
export interface AffiliateImportStagingClient {
|
|
941
|
+
stageImportBatch(input: AffiliateImportBatchInput): Promise<{
|
|
942
|
+
batchId: string;
|
|
943
|
+
}>;
|
|
944
|
+
}
|
|
945
|
+
/**
|
|
946
|
+
* The one rejection every `UNAVAILABLE_AFFILIATE_ADMIN` method throws: an
|
|
947
|
+
* unavailable affiliate write client must fail, never pretend an import,
|
|
948
|
+
* adjustment, or payment was recorded (spec §7).
|
|
949
|
+
*/
|
|
950
|
+
export declare const AFFILIATE_ADMIN_UNAVAILABLE_MESSAGE = "The affiliate admin service is unavailable; no import, adjustment, or payment was recorded";
|
|
951
|
+
/**
|
|
952
|
+
* The admin client standing in when the affiliate write binding is absent or
|
|
953
|
+
* disabled. Unlike `NOOP_IDENTITY`/`NOOP_REVENUE` (whose reads render empty),
|
|
954
|
+
* every method here REJECTS: financial writes may never silently no-op.
|
|
955
|
+
*/
|
|
956
|
+
export declare const UNAVAILABLE_AFFILIATE_ADMIN: AffiliateAdminClient;
|
|
957
|
+
/**
|
|
958
|
+
* Single seam for the affiliate admin binding, mirroring `identity()` /
|
|
959
|
+
* `revenue()` — but the fallback REJECTS rather than no-ops, because a
|
|
960
|
+
* pretended import or payment is worse than a failed call.
|
|
961
|
+
*/
|
|
962
|
+
export declare function affiliateAdmin(binding: AffiliateAdminClient | null | undefined): AffiliateAdminClient;
|
package/dist/index.js
CHANGED
|
@@ -206,3 +206,77 @@ export function revenue(binding, disabled) {
|
|
|
206
206
|
}
|
|
207
207
|
return binding;
|
|
208
208
|
}
|
|
209
|
+
/* -------------------------------------------------------------------------- */
|
|
210
|
+
/* Affiliates: unavailable admin client */
|
|
211
|
+
/* -------------------------------------------------------------------------- */
|
|
212
|
+
/**
|
|
213
|
+
* The one rejection every `UNAVAILABLE_AFFILIATE_ADMIN` method throws: an
|
|
214
|
+
* unavailable affiliate write client must fail, never pretend an import,
|
|
215
|
+
* adjustment, or payment was recorded (spec §7).
|
|
216
|
+
*/
|
|
217
|
+
export const AFFILIATE_ADMIN_UNAVAILABLE_MESSAGE = 'The affiliate admin service is unavailable; no import, adjustment, or payment was recorded';
|
|
218
|
+
function unavailable() {
|
|
219
|
+
throw new Error(AFFILIATE_ADMIN_UNAVAILABLE_MESSAGE);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* The admin client standing in when the affiliate write binding is absent or
|
|
223
|
+
* disabled. Unlike `NOOP_IDENTITY`/`NOOP_REVENUE` (whose reads render empty),
|
|
224
|
+
* every method here REJECTS: financial writes may never silently no-op.
|
|
225
|
+
*/
|
|
226
|
+
export const UNAVAILABLE_AFFILIATE_ADMIN = {
|
|
227
|
+
async updateAffiliate() {
|
|
228
|
+
unavailable();
|
|
229
|
+
},
|
|
230
|
+
async setPayoutPolicy() {
|
|
231
|
+
unavailable();
|
|
232
|
+
},
|
|
233
|
+
async seedRelationship() {
|
|
234
|
+
unavailable();
|
|
235
|
+
},
|
|
236
|
+
async stageImportBatch() {
|
|
237
|
+
unavailable();
|
|
238
|
+
},
|
|
239
|
+
async validateImport() {
|
|
240
|
+
unavailable();
|
|
241
|
+
},
|
|
242
|
+
async activateImport() {
|
|
243
|
+
unavailable();
|
|
244
|
+
},
|
|
245
|
+
async resolveImportRecord() {
|
|
246
|
+
unavailable();
|
|
247
|
+
},
|
|
248
|
+
async requestCommissionSweep() {
|
|
249
|
+
unavailable();
|
|
250
|
+
},
|
|
251
|
+
async previewMonthlyPayouts() {
|
|
252
|
+
unavailable();
|
|
253
|
+
},
|
|
254
|
+
async prepareMonthlyPayouts() {
|
|
255
|
+
unavailable();
|
|
256
|
+
},
|
|
257
|
+
async beginPayout() {
|
|
258
|
+
unavailable();
|
|
259
|
+
},
|
|
260
|
+
async recordPayoutPaid() {
|
|
261
|
+
unavailable();
|
|
262
|
+
},
|
|
263
|
+
async recordPayoutNotSent() {
|
|
264
|
+
unavailable();
|
|
265
|
+
},
|
|
266
|
+
async cancelPayout() {
|
|
267
|
+
unavailable();
|
|
268
|
+
},
|
|
269
|
+
async recordAdjustment() {
|
|
270
|
+
unavailable();
|
|
271
|
+
},
|
|
272
|
+
};
|
|
273
|
+
/**
|
|
274
|
+
* Single seam for the affiliate admin binding, mirroring `identity()` /
|
|
275
|
+
* `revenue()` — but the fallback REJECTS rather than no-ops, because a
|
|
276
|
+
* pretended import or payment is worse than a failed call.
|
|
277
|
+
*/
|
|
278
|
+
export function affiliateAdmin(binding) {
|
|
279
|
+
if (!binding)
|
|
280
|
+
return UNAVAILABLE_AFFILIATE_ADMIN;
|
|
281
|
+
return binding;
|
|
282
|
+
}
|
package/package.json
CHANGED