From 86cf99b325a9aaa8e2d055125c16a9be93cddd9e Mon Sep 17 00:00:00 2001 From: okjodom Date: Wed, 16 Sep 2026 11:18:55 +0300 Subject: [PATCH] feat: add PSP and accounting integrations --- README.md | 22 +- scripts/vendor-upstream.mjs | 76 ++ src/index.ts | 80 ++ test/facade.test.mjs | 31 + vendor/upstream/core/auth/api-key-policy.d.ts | 5 +- vendor/upstream/core/auth/auth-handoff.d.ts | 7 + vendor/upstream/core/auth/index.d.ts | 1 + vendor/upstream/core/auth/permissions.d.ts | 38 +- vendor/upstream/core/escrow/types.d.ts | 7 +- vendor/upstream/core/escrow/utils.d.ts | 6 +- vendor/upstream/core/types/accounting.d.ts | 229 ++++ vendor/upstream/core/types/agent.d.ts | 4 + vendor/upstream/core/types/analytics.d.ts | 84 +- vendor/upstream/core/types/billing.d.ts | 241 ++++ vendor/upstream/core/types/dispute.d.ts | 1 + vendor/upstream/core/types/events.d.ts | 42 +- .../upstream/core/types/feature-catalog.d.ts | 58 + vendor/upstream/core/types/features.d.ts | 23 +- vendor/upstream/core/types/index.d.ts | 7 +- .../core/types/mpesa-ussd-automation.d.ts | 68 -- vendor/upstream/core/types/psp.d.ts | 506 ++++++++ vendor/upstream/core/types/rates.d.ts | 39 +- vendor/upstream/core/types/referral.d.ts | 10 + vendor/upstream/core/types/swap-progress.d.ts | 13 + vendor/upstream/core/utils/swap.d.ts | 23 + vendor/upstream/core/wallet/types.d.ts | 47 + vendor/upstream/manifest.json | 4 +- vendor/upstream/runtime.d.mts | 38 + vendor/upstream/runtime.mjs | 1027 +++++++++++++++-- vendor/upstream/sdk/accounting.d.ts | 21 + vendor/upstream/sdk/auth.d.ts | 5 + vendor/upstream/sdk/disputes.d.ts | 6 + vendor/upstream/sdk/escrow.d.ts | 11 +- vendor/upstream/sdk/http.d.ts | 7 + vendor/upstream/sdk/index.d.ts | 6 + vendor/upstream/sdk/otc/swap.d.ts | 10 +- vendor/upstream/sdk/partner.d.ts | 24 +- vendor/upstream/sdk/psp.d.ts | 55 + vendor/upstream/sdk/wallet.d.ts | 5 +- 39 files changed, 2692 insertions(+), 195 deletions(-) create mode 100644 vendor/upstream/core/auth/auth-handoff.d.ts create mode 100644 vendor/upstream/core/types/accounting.d.ts create mode 100644 vendor/upstream/core/types/billing.d.ts create mode 100644 vendor/upstream/core/types/feature-catalog.d.ts delete mode 100644 vendor/upstream/core/types/mpesa-ussd-automation.d.ts create mode 100644 vendor/upstream/core/types/psp.d.ts create mode 100644 vendor/upstream/core/types/referral.d.ts create mode 100644 vendor/upstream/core/types/swap-progress.d.ts create mode 100644 vendor/upstream/sdk/accounting.d.ts create mode 100644 vendor/upstream/sdk/psp.d.ts diff --git a/README.md b/README.md index a7082f9..2b99cd0 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,8 @@ Build server-side Minmo Partner integrations in TypeScript. [Minmo](https://www.minmo.to) Partner API. It gives you one Partner-bound interface for bringing Bitcoin and local-currency workflows into your own services: quote rates, coordinate OTC swaps and agents, operate wallets and -escrow, create Minmo Pay stores and invoices, and consume live domain events. +escrow, create Minmo Pay stores and invoices, connect payment service +providers, generate accounting reports, and consume live domain events. Create a client with your Partner ID and API key, then start calling Partner-scoped resources. The production API is configured by default, so @@ -66,6 +67,8 @@ the `X-API-Key` header. Calls such as `account.get()`, `settings.get()`, and | --- | --- | --- | | Partner operations | `account`, `settings`, `analytics`, `members`, `invitations`, `apiKeys`, `referrals` | Manage the Partner account, team access, reporting, API keys, and referrals | | Minmo Pay | `integrations.pay` | Create stores and invoices, connect settlement wallets, read authoritative invoice state, and subscribe to Pay events | +| Payment service providers | `integrations.psp` | Connect providers, collect and disburse funds, inspect liquidity and statements, reconcile transactions, and subscribe to PSP events | +| Accounting | `integrations.accounting` | List accounting sources, manage reporting templates, and generate CSV reports | | OTC | `otc.rates`, `otc.swap`, `otc.agents` | Quote Bitcoin and local-currency rates, coordinate swaps, and operate an agent network | | Wallets | `wallet` | Create and manage wallets, receive or send funds, transfer balances, and inspect wallet activity | | Escrow | `escrow` | Create and reconcile escrows, verify funding, release or refund funds, and manage disputes | @@ -88,6 +91,23 @@ const [quote, stores] = await Promise.all([ ]); ``` +For payment-provider and accounting integrations, use the same Partner-bound +client: + +```ts +import { MinmoClient, SourceType } from "@minmoto/sdk"; + +const minmo = new MinmoClient({ + partnerId: process.env.MINMO_PARTNER_ID!, + apiKey: process.env.MINMO_API_KEY!, +}); + +const [providers, accountingSources] = await Promise.all([ + minmo.integrations.psp.listProviders(), + minmo.integrations.accounting.listSources(SourceType.PSP_CONNECTION), +]); +``` + ### Subscribe to live changes Domain clients expose typed subscriptions alongside their command and query diff --git a/scripts/vendor-upstream.mjs b/scripts/vendor-upstream.mjs index 7775cf8..84e6c93 100644 --- a/scripts/vendor-upstream.mjs +++ b/scripts/vendor-upstream.mjs @@ -48,19 +48,30 @@ writeFileSync( `export { ApiKeyInvalidReason, ReferralCodeScope } from ${JSON.stringify(join(sdkSource, "partner.ts"))};`, "export {", " AgentSelectionMode,", + " AccountingExportFailureCode,", + " AccountingHealthStatus,", + " AccountPurpose,", + " AccountStatus,", + " AccountType,", " AgentStatus,", " AgentTeamAssociationStatus,", " AgentTeamAssociationVisibility,", " AnalyticsBucket,", " ApiKeyCapability,", " ApiKeyResourceScope,", + " BalanceBasis,", " BitcoinNetwork,", + " BookEntityType,", " ConfirmationRole,", " Currency,", " DisputeResolution,", " EscrowEventType,", " EscrowNetwork,", + " ExecutionStatus,", + " ExportReportType,", " FxRateProvider,", + " JournalStatus,", + " NormalBalance,", " OnchainConfirmationSpeed,", " OtcEventType,", " ParticipantRole,", @@ -72,9 +83,36 @@ writeFileSync( " PaymentChannel,", " PayoutDestinationType,", " Permission,", + " PostingDirection,", + " PspAccountingTemplate,", + " PspCallbackMode,", + " PspCapability,", + " PspConnectionKind,", + " PspConnectionStatus,", + " PspDisbursementDestinationType,", + " PspEntityType,", + " PspEnvironment,", + " PspEventType,", + " PspPaymentMethod,", + " PspPaymentOperation,", + " PspProvider,", + " PspProviderBalanceStatus,", + " PspProviderSetupFieldType,", + " PspReconciliationExceptionCode,", + " PspReconciliationRecordKind,", + " PspReconciliationResolutionAction,", + " PspReconciliationStatus,", + " PspReconciliationType,", + " ReconciliationStatus,", + " SettlementStatus,", + " SourceType,", " SwapState,", " SwapType,", " TeamRole,", + " TransactionDirection,", + " TransactionOperation,", + " ValuationBasis,", + " ValuationStatus,", " WalletConnectionScope,", " WalletEventType,", " WalletProvider,", @@ -119,19 +157,30 @@ writeFileSync( 'export { ApiKeyInvalidReason, ReferralCodeScope } from "./sdk/partner.js";', "export {", " AgentSelectionMode,", + " AccountingExportFailureCode,", + " AccountingHealthStatus,", + " AccountPurpose,", + " AccountStatus,", + " AccountType,", " AgentStatus,", " AgentTeamAssociationStatus,", " AgentTeamAssociationVisibility,", " AnalyticsBucket,", " ApiKeyCapability,", " ApiKeyResourceScope,", + " BalanceBasis,", " BitcoinNetwork,", + " BookEntityType,", " ConfirmationRole,", " Currency,", " DisputeResolution,", " EscrowEventType,", " EscrowNetwork,", + " ExecutionStatus,", + " ExportReportType,", " FxRateProvider,", + " JournalStatus,", + " NormalBalance,", " OnchainConfirmationSpeed,", " OtcEventType,", " ParticipantRole,", @@ -143,9 +192,36 @@ writeFileSync( " PaymentChannel,", " PayoutDestinationType,", " Permission,", + " PostingDirection,", + " PspAccountingTemplate,", + " PspCallbackMode,", + " PspCapability,", + " PspConnectionKind,", + " PspConnectionStatus,", + " PspDisbursementDestinationType,", + " PspEntityType,", + " PspEnvironment,", + " PspEventType,", + " PspPaymentMethod,", + " PspPaymentOperation,", + " PspProvider,", + " PspProviderBalanceStatus,", + " PspProviderSetupFieldType,", + " PspReconciliationExceptionCode,", + " PspReconciliationRecordKind,", + " PspReconciliationResolutionAction,", + " PspReconciliationStatus,", + " PspReconciliationType,", + " ReconciliationStatus,", + " SettlementStatus,", + " SourceType,", " SwapState,", " SwapType,", " TeamRole,", + " TransactionDirection,", + " TransactionOperation,", + " ValuationBasis,", + " ValuationStatus,", " WalletConnectionScope,", " WalletEventType,", " WalletProvider,", diff --git a/src/index.ts b/src/index.ts index 7c62bc6..843c1a4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,9 @@ import { + AccountingExportFailureCode, + AccountingHealthStatus, + AccountPurpose, + AccountStatus, + AccountType, AgentSelectionMode, AgentStatus, AgentTeamAssociationStatus, @@ -7,14 +12,19 @@ import { ApiKeyCapability, ApiKeyInvalidReason, ApiKeyResourceScope, + BalanceBasis, BitcoinNetwork, + BookEntityType, ConfirmationRole, Currency, DisputeResolution, EscrowEventType, EscrowNetwork, EventConnectionState, + ExecutionStatus, + ExportReportType, FxRateProvider, + JournalStatus, MemoryEventCursorStore, MinmoApiError, MinmoAuthenticationError, @@ -22,6 +32,7 @@ import { MinmoRateLimitError, MinmoSdkError, MinmoTransportError, + NormalBalance, OnchainConfirmationSpeed, OtcEventType, PartnerClient, @@ -34,18 +45,50 @@ import { PaymentChannel, PayoutDestinationType, Permission, + PostingDirection, + PspAccountingTemplate, + PspCallbackMode, + PspCapability, + PspConnectionKind, + PspConnectionStatus, + PspDisbursementDestinationType, + PspEntityType, + PspEnvironment, + PspEventType, + PspPaymentMethod, + PspPaymentOperation, + PspProvider, + PspProviderBalanceStatus, + PspProviderSetupFieldType, + PspReconciliationExceptionCode, + PspReconciliationRecordKind, + PspReconciliationResolutionAction, + PspReconciliationStatus, + PspReconciliationType, + ReconciliationStatus, ReferralCodeScope, ResyncRequiredError, + SettlementStatus, + SourceType, SwapEscrowPaymentStatus, SwapState, SwapType, TeamRole, + TransactionDirection, + TransactionOperation, + ValuationBasis, + ValuationStatus, WalletConnectionScope, WalletEventType, WalletProvider, } from "../vendor/upstream/runtime.mjs"; export { + AccountingExportFailureCode, + AccountingHealthStatus, + AccountPurpose, + AccountStatus, + AccountType, AgentSelectionMode, AgentStatus, AgentTeamAssociationStatus, @@ -54,14 +97,19 @@ export { ApiKeyCapability, ApiKeyInvalidReason, ApiKeyResourceScope, + BalanceBasis, BitcoinNetwork, + BookEntityType, ConfirmationRole, Currency, DisputeResolution, EscrowEventType, EscrowNetwork, EventConnectionState, + ExecutionStatus, + ExportReportType, FxRateProvider, + JournalStatus, MemoryEventCursorStore, MinmoApiError, MinmoAuthenticationError, @@ -69,6 +117,7 @@ export { MinmoRateLimitError, MinmoSdkError, MinmoTransportError, + NormalBalance, OnchainConfirmationSpeed, OtcEventType, ParticipantRole, @@ -80,24 +129,55 @@ export { PaymentChannel, PayoutDestinationType, Permission, + PostingDirection, + PspAccountingTemplate, + PspCallbackMode, + PspCapability, + PspConnectionKind, + PspConnectionStatus, + PspDisbursementDestinationType, + PspEntityType, + PspEnvironment, + PspEventType, + PspPaymentMethod, + PspPaymentOperation, + PspProvider, + PspProviderBalanceStatus, + PspProviderSetupFieldType, + PspReconciliationExceptionCode, + PspReconciliationRecordKind, + PspReconciliationResolutionAction, + PspReconciliationStatus, + PspReconciliationType, + ReconciliationStatus, ReferralCodeScope, ResyncRequiredError, + SettlementStatus, + SourceType, SwapEscrowPaymentStatus, SwapState, SwapType, TeamRole, + TransactionDirection, + TransactionOperation, + ValuationBasis, + ValuationStatus, WalletConnectionScope, WalletEventType, WalletProvider, }; export type * from "../vendor/upstream/sdk/disputes.js"; +export type * from "../vendor/upstream/sdk/accounting.js"; export type * from "../vendor/upstream/sdk/escrow.js"; export type * from "../vendor/upstream/sdk/events.js"; export type * from "../vendor/upstream/sdk/otc/index.js"; export type * from "../vendor/upstream/sdk/partner.js"; export type * from "../vendor/upstream/sdk/pay/index.js"; +export type * from "../vendor/upstream/sdk/psp.js"; export type * from "../vendor/upstream/sdk/wallet.js"; +export type * from "../vendor/upstream/core/types/accounting.js"; +export type * from "../vendor/upstream/core/types/psp.js"; export const MINMO_PRODUCTION_BASE_URL = "https://api.minmo.to/api/v1"; diff --git a/test/facade.test.mjs b/test/facade.test.mjs index 3c66d29..84f4de7 100644 --- a/test/facade.test.mjs +++ b/test/facade.test.mjs @@ -4,6 +4,8 @@ import { afterEach, test } from "node:test"; import { MINMO_PRODUCTION_BASE_URL, MinmoClient, + PspProvider, + SourceType, } from "../dist/index.js"; const originalFetch = globalThis.fetch; @@ -70,6 +72,35 @@ test("accepts an optional deployment base URL", async () => { assert.equal(url, "https://api.staging.minmo.to/api/v1/teams/partner-1"); }); +test("binds PSP and accounting integrations to the Partner API key", async () => { + const requests = []; + globalThis.fetch = async (input, init) => { + requests.push(new Request(input, init)); + return Response.json([]); + }; + + const client = new MinmoClient({ + partnerId: "partner/1", + apiKey: "secret-key", + }); + + await client.integrations.psp.listProviders(); + await client.integrations.accounting.listSources(SourceType.PSP_CONNECTION); + + assert.deepEqual( + requests.map((request) => request.url), + [ + "https://api.minmo.to/api/v1/teams/partner%2F1/psp/providers", + "https://api.minmo.to/api/v1/teams/partner%2F1/accounting/sources?type=psp_connection", + ], + ); + assert.deepEqual( + requests.map((request) => request.headers.get("X-API-Key")), + ["secret-key", "secret-key"], + ); + assert.equal(PspProvider.SAFARICOM_DARAJA, "safaricom_daraja"); +}); + test("rejects blank Partner IDs and API keys", () => { assert.throws( () => new MinmoClient({ partnerId: " ", apiKey: "secret-key" }), diff --git a/vendor/upstream/core/auth/api-key-policy.d.ts b/vendor/upstream/core/auth/api-key-policy.d.ts index a4a01f4..9c11b64 100644 --- a/vendor/upstream/core/auth/api-key-policy.d.ts +++ b/vendor/upstream/core/auth/api-key-policy.d.ts @@ -13,7 +13,10 @@ export declare enum ApiKeyCapability { ESCROW_OPERATIONS = "escrow.operations", ESCROW_ADMIN = "escrow.admin", PAY_READONLY = "pay.readonly", - PAY_READ_WRITE = "pay.read_write" + PAY_READ_WRITE = "pay.read_write", + PSP_READONLY = "psp.readonly", + PSP_COLLECTIONS = "psp.collections", + PSP_DISBURSEMENTS = "psp.disbursements" } export declare const API_KEY_CAPABILITY_PERMISSIONS: Record; export interface ApiKeyPolicyResources { diff --git a/vendor/upstream/core/auth/auth-handoff.d.ts b/vendor/upstream/core/auth/auth-handoff.d.ts new file mode 100644 index 0000000..3d6c5d6 --- /dev/null +++ b/vendor/upstream/core/auth/auth-handoff.d.ts @@ -0,0 +1,7 @@ +export declare enum AuthHandoffClient { + CONSOLE = "console", + MOBILE = "mobile", + OPS = "ops" +} +export declare function isAuthHandoffClient(value: unknown): value is AuthHandoffClient; +//# sourceMappingURL=auth-handoff.d.ts.map \ No newline at end of file diff --git a/vendor/upstream/core/auth/index.d.ts b/vendor/upstream/core/auth/index.d.ts index c9df215..09711d0 100644 --- a/vendor/upstream/core/auth/index.d.ts +++ b/vendor/upstream/core/auth/index.d.ts @@ -2,6 +2,7 @@ * Authentication and authorization types and utilities */ export * from "./auth"; +export * from "./auth-handoff"; export * from "./api-key-policy"; export * from "./permissions"; export * from "./role-utils"; diff --git a/vendor/upstream/core/auth/permissions.d.ts b/vendor/upstream/core/auth/permissions.d.ts index c6097ca..283e178 100644 --- a/vendor/upstream/core/auth/permissions.d.ts +++ b/vendor/upstream/core/auth/permissions.d.ts @@ -157,6 +157,8 @@ export declare enum Permission { ESCROW_READ = "escrow:read", /** Verify custodial escrow funding status */ ESCROW_VERIFY_FUNDING = "escrow:verify_funding", + /** Expire an unfunded custodial escrow after its funding deadline */ + ESCROW_EXPIRE = "escrow:expire", /** Release funded custodial escrows */ ESCROW_RELEASE = "escrow:release", /** Refund funded custodial escrows */ @@ -195,6 +197,8 @@ export declare enum Permission { PARTNER_AGENTS_READ = "partner:agents_read", /** View all swap transactions for agents in this partner network */ PARTNER_SWAPS_READ = "partner:swaps_read", + /** Manage swap transactions for agents in this partner network */ + PARTNER_SWAPS_MANAGE = "partner:swaps_manage", /** View liquidity information for agents in this partner network */ PARTNER_LIQUIDITY_READ = "partner:liquidity_read", /** View metrics and analytics for this partner organization */ @@ -218,7 +222,33 @@ export declare enum Permission { /** Read the Minmo Pay stores belonging to a team */ PAY_STORE_READ = "pay:store_read", /** Provision and manage the BTCPay store bound to a team wallet */ - PAY_STORE_MANAGE = "pay:store_manage" + PAY_STORE_MANAGE = "pay:store_manage", + /** Read PSP connections and their non-secret configuration */ + PSP_CONNECTION_READ = "psp:connection_read", + /** Create, validate, and rotate PSP connections */ + PSP_CONNECTION_MANAGE = "psp:connection_manage", + /** Initiate a collection through an authorized PSP connection */ + PSP_PAYMENT_CREATE = "psp:payment_create", + /** Initiate a disbursement through an authorized PSP connection */ + PSP_DISBURSEMENT_CREATE = "psp:disbursement_create", + /** Read normalized PSP payment state */ + PSP_PAYMENT_READ = "psp:payment_read", + /** Read internal PSP accounts, attributable balances, and statements */ + PSP_ACCOUNT_READ = "psp:account_read", + /** Subscribe to Partner-scoped PSP payment events */ + PSP_EVENT_SUBSCRIBE = "psp:event_subscribe", + /** Read PSP reconciliation runs, items, and safe exception detail */ + PSP_RECONCILIATION_READ = "psp:reconciliation_read", + /** Start a PSP transaction reconciliation run */ + PSP_RECONCILIATION_RUN = "psp:reconciliation_run", + /** Resolve a PSP reconciliation exception with approved evidence */ + PSP_RECONCILIATION_RESOLVE = "psp:reconciliation_resolve", + /** Read accounting Sources and saved reporting templates */ + ACCOUNTING_READ = "accounting:read", + /** Create and delete saved reporting templates */ + ACCOUNTING_TEMPLATE_MANAGE = "accounting:template_manage", + /** Generate bounded, uncertified reports for direct delivery */ + ACCOUNTING_EXPORT = "accounting:export" } /** * Permission groups organized by business domain/service scope. @@ -235,16 +265,18 @@ export declare const PERMISSION_GROUPS: { readonly SYSTEM_OPERATIONS: readonly [Permission.SYSTEM_CONFIG, Permission.SYSTEM_MONITOR, Permission.SYSTEM_AUDIT]; readonly REFERRAL_CODE_MANAGEMENT: readonly [Permission.REFERRAL_CODE_CREATE, Permission.REFERRAL_CODE_READ]; readonly BITCOIN_OPERATIONS: readonly [Permission.BITCOIN_WALLET_READ, Permission.BITCOIN_WALLET_RECEIVE, Permission.BITCOIN_WALLET_SEND]; - readonly ESCROW_OPERATIONS: readonly [Permission.ESCROW_CREATE, Permission.ESCROW_READ, Permission.ESCROW_VERIFY_FUNDING, Permission.ESCROW_RELEASE, Permission.ESCROW_REFUND, Permission.ESCROW_RESOLVE_DISPUTE, Permission.ESCROW_DESCRIPTOR_PUBLISH]; + readonly ESCROW_OPERATIONS: readonly [Permission.ESCROW_CREATE, Permission.ESCROW_READ, Permission.ESCROW_VERIFY_FUNDING, Permission.ESCROW_EXPIRE, Permission.ESCROW_RELEASE, Permission.ESCROW_REFUND, Permission.ESCROW_RESOLVE_DISPUTE, Permission.ESCROW_DESCRIPTOR_PUBLISH]; readonly USER_MANAGEMENT: readonly [Permission.USER_READ, Permission.USER_WRITE, Permission.USER_DELETE, Permission.USER_MANAGE_ROLES]; readonly AGENT_MANAGEMENT: readonly [Permission.AGENT_REGISTER, Permission.AGENT_MANAGE_OWN, Permission.AGENT_MANAGE_ALL, Permission.AGENT_READ_ALL]; readonly SWAP_OPERATIONS: readonly [Permission.SWAP_READ_OWN, Permission.SWAP_READ_ALL, Permission.SWAP_CREATE, Permission.SWAP_CANCEL_OWN, Permission.SWAP_CANCEL_ALL, Permission.SWAP_APPROVE]; readonly LIQUIDITY_OPERATIONS: readonly [Permission.LIQUIDITY_MANAGE_OWN, Permission.LIQUIDITY_MANAGE_ALL, Permission.LIQUIDITY_READ_ALL]; readonly FX_OPERATIONS: readonly [Permission.FX_RATES_READ, Permission.FX_RATES_MANAGE]; readonly ANALYTICS: readonly [Permission.ANALYTICS_READ_OWN, Permission.ANALYTICS_READ_ALL, Permission.ANALYTICS_EXPORT]; - readonly PARTNER_OPERATIONS: readonly [Permission.PARTNER_READ_OWN, Permission.PARTNER_MANAGE_OWN, Permission.PARTNER_AGENT_INVITE, Permission.PARTNER_AGENT_REMOVE, Permission.PARTNER_AGENT_READ, Permission.PARTNER_AGENT_MANAGE, Permission.PARTNER_AGENTS_READ, Permission.PARTNER_SWAPS_READ, Permission.PARTNER_LIQUIDITY_READ, Permission.PARTNER_METRICS_READ, Permission.PARTNER_SERVICES_CREATE, Permission.PARTNER_SERVICES_MANAGE, Permission.PARTNER_SERVICES_READ, Permission.PARTNER_SERVICES_DELETE]; + readonly PARTNER_OPERATIONS: readonly [Permission.PARTNER_READ_OWN, Permission.PARTNER_MANAGE_OWN, Permission.PARTNER_AGENT_INVITE, Permission.PARTNER_AGENT_REMOVE, Permission.PARTNER_AGENT_READ, Permission.PARTNER_AGENT_MANAGE, Permission.PARTNER_AGENTS_READ, Permission.PARTNER_SWAPS_READ, Permission.PARTNER_SWAPS_MANAGE, Permission.PARTNER_LIQUIDITY_READ, Permission.PARTNER_METRICS_READ, Permission.PARTNER_SERVICES_CREATE, Permission.PARTNER_SERVICES_MANAGE, Permission.PARTNER_SERVICES_READ, Permission.PARTNER_SERVICES_DELETE]; readonly PARTNER_ADMIN_OPERATIONS: readonly [Permission.PARTNER_READ_ALL, Permission.PARTNER_MANAGE_ALL]; readonly PAY_OPERATIONS: readonly [Permission.PAY_PAYMENT_CREATE, Permission.PAY_PAYMENT_READ, Permission.PAY_PAYMENT_CANCEL, Permission.PAY_EVENT_SUBSCRIBE, Permission.PAY_STORE_READ, Permission.PAY_STORE_MANAGE]; + readonly PSP_OPERATIONS: readonly [Permission.PSP_CONNECTION_READ, Permission.PSP_CONNECTION_MANAGE, Permission.PSP_PAYMENT_CREATE, Permission.PSP_DISBURSEMENT_CREATE, Permission.PSP_PAYMENT_READ, Permission.PSP_ACCOUNT_READ, Permission.PSP_EVENT_SUBSCRIBE, Permission.PSP_RECONCILIATION_READ, Permission.PSP_RECONCILIATION_RUN, Permission.PSP_RECONCILIATION_RESOLVE]; + readonly ACCOUNTING_OPERATIONS: readonly [Permission.ACCOUNTING_READ, Permission.ACCOUNTING_TEMPLATE_MANAGE, Permission.ACCOUNTING_EXPORT]; }; /** * Role-permission mapping defining what each role can do diff --git a/vendor/upstream/core/escrow/types.d.ts b/vendor/upstream/core/escrow/types.d.ts index f4a7ca3..0017509 100644 --- a/vendor/upstream/core/escrow/types.d.ts +++ b/vendor/upstream/core/escrow/types.d.ts @@ -177,8 +177,7 @@ export declare enum EscrowStatus { RELEASED = "released", REFUNDED = "refunded", EXPIRED = "expired", - MANUAL_REVIEW = "manual_review", - FAILED = "failed" + MANUAL_REVIEW = "manual_review" } export declare enum ParticipantRole { USER = "user", @@ -326,6 +325,10 @@ export type EscrowPage = { limit: number; offset: number; }; +export type EscrowActivityResponse = { + open: EscrowPage; + history: EscrowPage; +}; export type EscrowDescriptorMetadata = { walletId?: string; label?: string; diff --git a/vendor/upstream/core/escrow/utils.d.ts b/vendor/upstream/core/escrow/utils.d.ts index 2b406ed..03638b2 100644 --- a/vendor/upstream/core/escrow/utils.d.ts +++ b/vendor/upstream/core/escrow/utils.d.ts @@ -1,5 +1,5 @@ import { DestinationType } from "../utils/destination-parser"; -import { EscrowAsset, EscrowCurrency, EscrowNetwork, PayoutDestinationType, type EscrowFeePolicy, type PayoutDestination } from "./types"; +import { EscrowAsset, EscrowCurrency, EscrowNetwork, EscrowStatus, PayoutDestinationType, type EscrowFeePolicy, type PayoutDestination } from "./types"; export declare const DEFAULT_ESCROW_FUNDING_INVOICE_EXPIRY_SECONDS: number; /** * How long a client polls for escrow funding after handing an invoice to an @@ -11,8 +11,10 @@ export declare const DEFAULT_ESCROW_FUNDING_INVOICE_EXPIRY_SECONDS: number; * backend reconciler still picks it up later if it was. */ export declare const DEFAULT_ESCROW_FOREGROUND_WATCH_SECONDS: number; -export declare const DEFAULT_ESCROW_FUNDING_RECONCILIATION_INTERVAL_SECONDS = 30; +export declare const DEFAULT_ESCROW_FUNDING_RECONCILIATION_INTERVAL_SECONDS = 60; export declare const DEFAULT_ESCROW_FUNDING_RECONCILIATION_BATCH_SIZE = 50; +export declare const TERMINAL_ESCROW_STATUSES: readonly [EscrowStatus.RELEASED, EscrowStatus.REFUNDED, EscrowStatus.EXPIRED]; +export declare function isTerminalEscrowStatus(status: EscrowStatus): boolean; export declare function defaultEscrowFeePolicy(now?: string): EscrowFeePolicy; export declare function validateEscrowFeePolicy(policy: Pick): void; export declare function calculateEscrowFeeSats(principalSats: bigint, bps: number, bounds?: Pick): bigint; diff --git a/vendor/upstream/core/types/accounting.d.ts b/vendor/upstream/core/types/accounting.d.ts new file mode 100644 index 0000000..ba3eab1 --- /dev/null +++ b/vendor/upstream/core/types/accounting.d.ts @@ -0,0 +1,229 @@ +import type { Currency } from "./currency"; +export declare enum SourceType { + WALLET = "wallet", + PSP_CONNECTION = "psp_connection" +} +export declare enum ExportReportType { + TRANSACTION_HISTORY = "transaction_history", + GENERAL_LEDGER = "general_ledger" +} +export declare enum AccountingHealthStatus { + READY = "ready", + NEEDS_ATTENTION = "needs_attention", + UNAVAILABLE = "unavailable" +} +export declare enum AccountingExportFailureCode { + SOURCE_NOT_FOUND = "source_not_found", + SOURCE_PERMISSION_DENIED = "source_permission_denied", + SOURCE_UNAVAILABLE = "source_unavailable", + UNSUPPORTED_REPORT_TYPE = "unsupported_report_type", + INVALID_PERIOD = "invalid_period", + PERIOD_TOO_LARGE = "period_too_large", + EXPORT_TOO_LARGE = "export_too_large", + VALUATION_INCOMPLETE = "valuation_incomplete", + JOURNAL_INCOMPLETE = "journal_incomplete", + JOURNAL_UNBALANCED = "journal_unbalanced", + SOURCE_PROJECTION_FAILED = "source_projection_failed", + GENERATION_TIMEOUT = "generation_timeout", + CONCURRENCY_LIMIT = "export_concurrency_limit", + DELIVERY_INTERRUPTED = "delivery_interrupted" +} +export declare enum BookEntityType { + PARTNER = "partner", + AGENT = "agent" +} +export declare enum AccountType { + ASSET = "asset", + LIABILITY = "liability", + EQUITY = "equity", + REVENUE = "revenue", + EXPENSE = "expense", + MEMORANDUM = "memorandum" +} +export declare enum AccountPurpose { + WALLET_ASSET = "wallet_asset", + WALLET_PENDING_OUTBOUND = "wallet_pending_outbound", + WALLET_UNALLOCATED_RECEIPT = "wallet_unallocated_receipt", + WALLET_UNCLASSIFIED_OUTFLOW = "wallet_unclassified_outflow", + WALLET_NETWORK_FEE_EXPENSE = "wallet_network_fee_expense", + WALLET_TRANSFER_CLEARING = "wallet_transfer_clearing", + WALLET_RECONCILIATION_SUSPENSE = "wallet_reconciliation_suspense", + PSP_CASH = "psp_cash", + PSP_CLEARING = "psp_clearing", + PSP_ENTITY_LIQUIDITY = "psp_entity_liquidity", + PSP_PENDING_FUNDS = "psp_pending_funds", + PSP_FEE_REVENUE = "psp_fee_revenue", + PSP_PROVIDER_FEE_EXPENSE = "psp_provider_fee_expense", + PSP_UNALLOCATED_FUNDS = "psp_unallocated_funds", + PSP_RECONCILIATION_SUSPENSE = "psp_reconciliation_suspense" +} +export declare enum NormalBalance { + DEBIT = "debit", + CREDIT = "credit" +} +export declare enum AccountStatus { + ACTIVE = "active", + FROZEN = "frozen", + CLOSED = "closed" +} +export declare enum BalanceBasis { + INTERNAL_POSTED = "internal_posted" +} +export declare enum JournalStatus { + PENDING = "pending", + POSTED = "posted", + VOIDED = "voided", + REVERSED = "reversed" +} +export declare enum PostingDirection { + DEBIT = "debit", + CREDIT = "credit" +} +export declare enum ExecutionStatus { + CREATED = "created", + SUBMITTED = "submitted", + PENDING = "pending", + SUCCEEDED = "succeeded", + FAILED = "failed", + OUTCOME_UNKNOWN = "outcome_unknown", + CANCELLED = "cancelled" +} +export declare enum SettlementStatus { + UNPOSTED = "unposted", + RESERVED = "reserved", + POSTED = "posted", + REVERSED = "reversed" +} +export declare enum ReconciliationStatus { + NOT_DUE = "not_due", + PENDING = "pending", + MATCHED = "matched", + EXCEPTION = "exception", + RESOLVED = "resolved" +} +export declare enum TransactionDirection { + INBOUND = "inbound", + OUTBOUND = "outbound", + INTERNAL = "internal" +} +export declare enum TransactionOperation { + RECEIVE = "receive", + SEND = "send", + COLLECTION = "collection", + DISBURSEMENT = "disbursement", + FEE = "fee", + TRANSFER = "transfer" +} +export declare enum ValuationStatus { + COMPLETE = "complete", + INCOMPLETE = "incomplete", + NOT_REQUIRED = "not_required" +} +export declare enum ValuationBasis { + EXECUTION_TIME = "execution_time", + PROVIDER_OCCURRED_TIME = "provider_occurred_time", + FIRST_OBSERVED_TIME = "first_observed_time", + HISTORICAL_BACKFILL = "historical_backfill", + IDENTITY = "identity" +} +export type SourceReference = { + type: SourceType; + id: string; +}; +export type SourceSummary = SourceReference & { + displayName: string; + status: string; + currencyOrAssetScope: string[]; + accountingHealth: AccountingHealthStatus; + earliestSupportedAt: string | null; +}; +export type ReportingTemplate = { + id: string; + partnerId: string; + displayName: string; + source: SourceReference; + reportType: ExportReportType; + createdBy: string; + createdAt: string; + updatedAt: string; +}; +export type CreateReportingTemplateRequest = { + displayName: string; + source: SourceReference; + reportType: ExportReportType; +}; +export type CreateAccountingReportRequest = { + source: SourceReference; + reportType: ExportReportType; + periodStart: string; + periodEnd: string; +}; +export type BookReference = { + entityType: BookEntityType; + entityId: string; +}; +export type Transaction = { + id: string; + partnerId: string; + source: SourceReference; + sourceRecordType: string; + sourceRecordId: string; + operation: TransactionOperation; + direction: TransactionDirection; + executionStatus: ExecutionStatus; + settlementStatus: SettlementStatus; + reconciliationStatus: ReconciliationStatus; + occurredAt: string; + effectiveAt: string; + nativeAsset: Currency; + nativeAmountAtomic: string; + nativeAssetExponent: number; + feeAsset: Currency | null; + feeAmountAtomic: string | null; + externalReference: string | null; + finalityBasis: string | null; + policyVersion: number; + createdAt: string; + updatedAt: string; +}; +export type ValuationSnapshot = { + id: string; + transactionId: string; + status: ValuationStatus; + baseCurrency: Currency; + quoteCurrency: Currency; + rate: string | null; + rateSource: string | null; + rateEffectiveAt: string | null; + rateObservedAt: string | null; + basis: ValuationBasis; + reportingAmountMinor: string | null; + reportingCurrencyExponent: number; + fxPolicyVersion: number; + failureCode: string | null; + createdAt: string; +}; +export type JournalPostingCommand = { + accountId: string; + direction: PostingDirection; + nativeAmountAtomic: string; + reportingAmountMinor: string; + dimensions?: Record; +}; +export type JournalCommand = { + partnerId: string; + book: BookReference; + source: SourceReference; + transactionId: string; + valuationSnapshotId: string; + journalType: string; + templateVersion: number; + idempotencyKey: string; + effectiveAt: string; + finalityBasis: string; + reversalOfJournalId?: string; + createdBy: string; + approvedBy?: string; + postings: JournalPostingCommand[]; +}; +//# sourceMappingURL=accounting.d.ts.map \ No newline at end of file diff --git a/vendor/upstream/core/types/agent.d.ts b/vendor/upstream/core/types/agent.d.ts index 470e9ee..f32a770 100644 --- a/vendor/upstream/core/types/agent.d.ts +++ b/vendor/upstream/core/types/agent.d.ts @@ -45,6 +45,10 @@ export declare enum SwapState { FIAT_RECEIVER_TIMEOUT = "fiat_receiver_timeout", TRANSFERRED_TO_BACKUP = "transferred_to_backup" } +export declare enum SwapListSegment { + OPEN = "open", + HISTORY = "history" +} export declare enum SwapRepairAction { ATTACH_ESCROW = "attach_escrow", CLOSE_LEGACY = "close_legacy", diff --git a/vendor/upstream/core/types/analytics.d.ts b/vendor/upstream/core/types/analytics.d.ts index eea63ef..5de603f 100644 --- a/vendor/upstream/core/types/analytics.d.ts +++ b/vendor/upstream/core/types/analytics.d.ts @@ -1,5 +1,5 @@ -import type { ConsoleFeatureId } from "./features"; -export declare enum AnalyticsDashboardScopeType { +import type { ConsoleFeatureId, FeatureAvailabilityState } from "./features"; +export declare enum AnalyticsScopeType { TEAM = "team", SYSTEM = "system" } @@ -10,8 +10,9 @@ export declare enum AnalyticsBucket { YEAR = "year", ALL = "all" } -export declare enum AnalyticsDashboardChartKind { - SWAP_ACTIVITY = "swap_activity" +export declare enum AnalyticsChartKind { + SWAP_ACTIVITY = "swap_activity", + ESCROW_ACTIVITY = "escrow_activity" } export declare enum AnalyticsMetricCardTone { PRIMARY = "primary", @@ -24,9 +25,13 @@ export declare enum AnalyticsMetricCardIcon { BITCOIN = "bitcoin", CHECK = "check", GROUPS = "groups", + KEY = "key", + RECEIPT = "receipt", SPEED = "speed", + STORE = "store", SWAP = "swap", - WALLET = "wallet" + WALLET = "wallet", + WARNING = "warning" } export declare enum AnalyticsMetricCardAmountUnit { TEAM_CURRENCY = "team_currency", @@ -55,27 +60,84 @@ export type AnalyticsActivityBucket = { offramp: number; total: number; }; -export type AnalyticsDashboardChart = { +export type AnalyticsEscrowActivityBucket = { + periodStart: string; + label: string; + activity: { + released: number; + refunded: number; + expired: number; + total: number; + }; + fees: { + earningsSats: string; + overageSats: string; + netEarningsSats: string; + }; +}; +type AnalyticsChartBase = { id: string; featureId: ConsoleFeatureId; title: string; detail: string; - kind: AnalyticsDashboardChartKind; +}; +export type AnalyticsSwapActivityChart = AnalyticsChartBase & { + kind: AnalyticsChartKind.SWAP_ACTIVITY; buckets: AnalyticsActivityBucket[]; }; -export type AnalyticsDashboardResponse = { +export type AnalyticsEscrowActivityChart = AnalyticsChartBase & { + kind: AnalyticsChartKind.ESCROW_ACTIVITY; + buckets: AnalyticsEscrowActivityBucket[]; +}; +export type AnalyticsChart = AnalyticsSwapActivityChart | AnalyticsEscrowActivityChart; +export type AnalyticsResponse = { scope: { - type: AnalyticsDashboardScopeType.TEAM; + type: AnalyticsScopeType.TEAM; teamId: string; label: string; } | { - type: AnalyticsDashboardScopeType.SYSTEM; + type: AnalyticsScopeType.SYSTEM; label: string; }; enabledFeatures: ConsoleFeatureId[]; headline: string; cards: AnalyticsMetricCard[]; - charts: AnalyticsDashboardChart[]; + charts: AnalyticsChart[]; + generatedAt: string; +}; +export declare enum PartnerOverviewReadinessStatus { + READY = "ready", + SETUP_REQUIRED = "setup_required", + NEEDS_ATTENTION = "needs_attention" +} +export declare enum PartnerOverviewAttentionSeverity { + INFO = "info", + WARNING = "warning", + ERROR = "error" +} +export type PartnerOverviewFeature = { + featureId: ConsoleFeatureId; + label: string; + description?: string; + state: FeatureAvailabilityState; + status: PartnerOverviewReadinessStatus; + detail: string; +}; +export type PartnerOverviewAttentionItem = { + id: string; + featureId: ConsoleFeatureId; + severity: PartnerOverviewAttentionSeverity; + title: string; + detail: string; +}; +export type PartnerOverviewResponse = { + partner: { + id: string; + label: string; + }; + features: PartnerOverviewFeature[]; + attention: PartnerOverviewAttentionItem[]; generatedAt: string; }; +export {}; //# sourceMappingURL=analytics.d.ts.map \ No newline at end of file diff --git a/vendor/upstream/core/types/billing.d.ts b/vendor/upstream/core/types/billing.d.ts new file mode 100644 index 0000000..0692da6 --- /dev/null +++ b/vendor/upstream/core/types/billing.d.ts @@ -0,0 +1,241 @@ +/** + * Billing, subscription, and entitlement types. + * + * Billing grants entitlements, entitlements gate features, and feature modules + * never call the billing provider directly. Team-scoped billing state lives on + * `teams.metadata.billing`; the plan catalog below is code-owned so that plan + * definitions ship and roll back with the code that reads them. + * + * See `docs/billing/README.md` and `docs/billing/storage.md`. + */ +/** Product package a team subscribes to. */ +export declare enum PlanCode { + WALLET_PARTNER = "wallet_partner", + INTEGRATION_PARTNER = "integration_partner", + OPERATING_PARTNER = "operating_partner" +} +/** How often a subscription is billed. */ +export declare enum BillingInterval { + MONTHLY = "monthly", + YEARLY = "yearly" +} +/** Billing status of a team's subscription. */ +export declare enum SubscriptionStatus { + TRIALING = "trialing", + ACTIVE = "active", + PAST_DUE = "past_due", + GRACE = "grace", + PAUSED = "paused", + CANCELED = "canceled" +} +/** + * Normalized, request-time-readable permission to use a product or capability. + * + * These strings are persisted in team metadata, so they are stable. Renaming + * one is a data migration: `EntitlementService` drops entitlement keys it does + * not recognize, so a team holding the old string silently loses that + * entitlement until its plan is re-expanded. + * + * `integration.pay` names the capability rather than its current backend. + * BTCPay Server is what implements Minmo Pay today; the entitlement outlives + * that choice, and the name matches `IntegrationId.PAY`, which is already + * persisted in team feature config. + */ +export declare enum EntitlementKey { + PRODUCT_WALLET = "product.wallet", + PRODUCT_INTEGRATIONS = "product.integrations", + INTEGRATION_API_KEY = "integration.api_key", + INTEGRATION_PAY = "integration.pay", + PRODUCT_ESCROW = "product.escrow", + PRODUCT_OTC = "product.otc" +} +/** Lifecycle state of a single entitlement record. */ +export declare enum EntitlementStatus { + ACTIVE = "active", + TRIALING = "trialing", + GRACE = "grace", + PAST_DUE = "past_due", + SUSPENDED = "suspended", + EXPIRED = "expired" +} +/** What produced an entitlement record. */ +export declare enum EntitlementSource { + PLAN = "plan", + TRIAL = "trial", + MANUAL_OVERRIDE = "manual_override", + BILLING_SYNC = "billing_sync", + INTERNAL = "internal" +} +/** Which set of operations an entitlement applies to. */ +export declare enum EntitlementScope { + TEAM_AGENTS = "team_agents", + TEAM_OPERATED_ESCROW = "team_operated_escrow", + MINMO_OPERATED_ESCROW = "minmo_operated_escrow", + PLATFORM = "platform" +} +/** Who operates escrow for a swap. */ +export declare enum EscrowOperatingMode { + TEAM_OPERATED = "team_operated", + MINMO_OPERATED = "minmo_operated" +} +/** Whether exceeding a limit blocks the operation or bills as overage. */ +export declare enum LimitMode { + HARD_CAP = "hard_cap", + OVERAGE = "overage" +} +/** Known numeric limit keys carried by entitlements. */ +export declare enum EntitlementLimitKey { + WALLET_INSTANCES = "walletInstances", + MONTHLY_SWAPS = "monthlySwaps", + MONTHLY_VOLUME_SATS = "monthlyVolumeSats", + ACTIVE_AGENTS = "activeAgents" +} +export declare const UNLIMITED: "unlimited"; +export type Unlimited = typeof UNLIMITED; +/** + * A bounded limit. `included` is a string when the quantity can exceed the + * safe integer range, as monthly satoshi volume can. + */ +export interface EntitlementLimit { + included: number | string; + mode: LimitMode; +} +export type EntitlementLimitValue = Unlimited | EntitlementLimit; +export type EntitlementLimits = Partial>; +/** Fee or revenue-share policy attached to an entitlement. */ +export type EntitlementFees = Record; +/** A single resolved entitlement, whether plan-derived or an override. */ +export interface EntitlementRecord { + status: EntitlementStatus; + source: EntitlementSource; + scope?: EntitlementScope; + mode?: EscrowOperatingMode; + limits?: EntitlementLimits; + fees?: EntitlementFees; + reason?: string; + effectiveFrom?: string; + effectiveUntil?: string; + updatedAt?: string; + updatedByUserId?: string; +} +export type EntitlementMap = Partial>; +/** Provider-neutral subscription state for a team. */ +export interface TeamSubscriptionMetadata { + status: SubscriptionStatus; + /** Defaults to monthly when absent, which is what every team predates. */ + interval?: BillingInterval; + provider?: string; + providerCustomerId?: string; + providerSubscriptionId?: string; + currentPeriodStart?: string; + currentPeriodEnd?: string; + trialEndsAt?: string; + cancelAt?: string; + canceledAt?: string; +} +/** + * Team billing state, stored at `teams.metadata.billing`. + * + * `entitlements` is rewritten wholesale by plan expansion. `overrides` is never + * touched by expansion, so an admin grant or suspension survives a plan change + * and the resolver can always explain which one decided access. + */ +export interface TeamBillingMetadata { + planCode: PlanCode; + subscription: TeamSubscriptionMetadata; + entitlements: EntitlementMap; + overrides?: EntitlementMap; + syncedAt?: string; +} +/** + * List price for a plan on one interval. + * + * Yearly is twelve times monthly: paying up front costs the same as paying as + * you go. Any discount is a commercial choice held in the catalog, not a rule + * applied here, so repricing one interval never silently moves the other. + */ +export declare function planPriceUsd(plan: BillingPlanDefinition, interval: BillingInterval): number; +/** + * The struck-through price to show beside the real one, or null when the plan + * has none. Never used for invoicing — `planPriceUsd` is what a team pays. + */ +export declare function planCompareAtUsd(plan: BillingPlanDefinition, interval: BillingInterval): number | null; +/** Entitlement grant as declared by a plan, before expansion into a record. */ +export interface PlanEntitlementDefinition { + scope?: EntitlementScope; + mode?: EscrowOperatingMode; + limits?: EntitlementLimits; + fees?: EntitlementFees; +} +export interface BillingPlanDefinition { + code: PlanCode; + name: string; + /** Monthly list price in USD. Zero for free plans. */ + monthlyPriceUsd: number; + /** + * Yearly list price in USD. Zero for free plans. + * + * Held as its own figure rather than derived from a discount rate, so a plan + * can be repriced on one interval without moving the other. + */ + yearlyPriceUsd: number; + /** + * Price shown struck through beside the monthly price, to frame it as a + * discount. Omit when there is nothing to compare against. + * + * This is presentation only: nothing is ever invoiced at this figure. + */ + monthlyCompareAtUsd?: number; + /** Yearly counterpart of `monthlyCompareAtUsd`. */ + yearlyCompareAtUsd?: number; + entitlements: Partial>; +} +/** + * Provider-neutral plan catalog. Product access is cumulative: each tier + * includes everything the tier below it grants. + */ +export declare const BILLING_PLAN_CATALOG: Record; +export declare function entitlementStatusForSubscription(status: SubscriptionStatus): EntitlementStatus; +export interface ExpandPlanOptions { + /** Billing status driving the expanded entitlement status. */ + subscriptionStatus?: SubscriptionStatus; + /** What produced this expansion. Defaults to the plan itself. */ + source?: EntitlementSource; + /** ISO timestamp stamped onto every expanded record. */ + effectiveFrom?: string; +} +/** + * Expand a plan into entitlement records. + * + * Pure: the same plan and options always produce the same map. Callers replace + * `teams.metadata.billing.entitlements` with the result and leave `overrides` + * untouched, so entitlement keys the new plan no longer grants simply disappear. + */ +export declare function expandPlanEntitlements(planCode: PlanCode, options?: ExpandPlanOptions): EntitlementMap; +/** Which map an entitlement decision came from. */ +export declare enum EntitlementOrigin { + OVERRIDE = "override", + PLAN = "plan" +} +export interface ResolvedEntitlement { + key: EntitlementKey; + record: EntitlementRecord; + origin: EntitlementOrigin; +} +/** + * Resolve one entitlement for a team, override first. + * + * Returns `null` when neither map grants the key, which callers must treat as + * denied. This is a lookup only: it does not evaluate limits, feature state, or + * whether the record's effective window has elapsed. + */ +export declare function resolveEntitlement(billing: TeamBillingMetadata | null | undefined, key: EntitlementKey): ResolvedEntitlement | null; +/** + * Whether a resolved entitlement currently permits new billable use. + * + * `past_due` is excluded: reads may still be allowed by the feature evaluator, + * but new billable writes are not permitted on this status alone. + */ +export declare function isEntitlementUsable(record: EntitlementRecord | null | undefined): boolean; +export declare function isUnlimited(value: EntitlementLimitValue | undefined): value is Unlimited; +//# sourceMappingURL=billing.d.ts.map \ No newline at end of file diff --git a/vendor/upstream/core/types/dispute.d.ts b/vendor/upstream/core/types/dispute.d.ts index fa6c4e8..748e5f1 100644 --- a/vendor/upstream/core/types/dispute.d.ts +++ b/vendor/upstream/core/types/dispute.d.ts @@ -28,6 +28,7 @@ export interface DisputeEvidenceDto { /** Per-channel evidence field definitions */ export type ChannelEvidenceConfig = Record; export interface DisputeFilters { + search?: string; status?: string; agentId?: string; startDate?: string; diff --git a/vendor/upstream/core/types/events.d.ts b/vendor/upstream/core/types/events.d.ts index 6fd5e35..3836ed6 100644 --- a/vendor/upstream/core/types/events.d.ts +++ b/vendor/upstream/core/types/events.d.ts @@ -9,6 +9,15 @@ import type { SwapResponse } from "./swap"; import type { PayInvoice, PayStore } from "./pay"; import type { AgentStatus } from "./agent"; import type { EscrowRecord } from "../escrow"; +import { PspEventType, type PspEntityType, type PspConnectionEventResponse, type PspPaymentEventResponse, type PspReconciliationEventResponse } from "./psp"; +export declare enum MinmoEventClass { + DOMAIN_EVENT = "domain_event", + PROVIDER_OBSERVATION = "provider_observation" +} +export declare enum MinmoEventVisibility { + DELIVERABLE = "deliverable", + INTERNAL = "internal" +} /** Events belonging to the over-the-counter exchange domain. */ export declare enum OtcEventType { SWAP_CREATED = "otc.swap.created", @@ -66,6 +75,9 @@ export declare enum PayEventType { } export declare enum WalletEventType { SYNCED = "wallet.synced", + DEPOSITS_DISCOVERED = "wallet.deposits.discovered", + DEPOSITS_UNCLAIMED = "wallet.deposits.unclaimed", + DEPOSITS_CLAIMED = "wallet.deposits.claimed", PAYMENT_PENDING = "wallet.payment.pending", PAYMENT_SUCCEEDED = "wallet.payment.succeeded", PAYMENT_FAILED = "wallet.payment.failed" @@ -80,7 +92,7 @@ export declare enum EscrowEventType { EXPIRED = "escrow.expired" } /** Union of all domain-scoped event types. */ -export type MinmoEventType = OtcEventType | PayEventType | WalletEventType | EscrowEventType; +export type MinmoEventType = OtcEventType | PayEventType | WalletEventType | EscrowEventType | PspEventType; /** Runtime registry useful for validation, documentation, and tests. */ export declare const MINMO_EVENT_TYPES: readonly MinmoEventType[]; type Brand = T & { @@ -100,6 +112,8 @@ export declare enum MinmoEventSourceModule { ESCROW = "escrow", PAYMENT = "payment", AUTH = "auth", + PSP = "psp", + ACCOUNTING = "accounting", SYSTEM = "system" } export type MinmoEventMetadata = { @@ -115,6 +129,13 @@ export type MinmoEventMetadata = { storeId?: string; agentId?: string; beneficiaryId?: string; + pspConnectionId?: string; + pspEntityType?: PspEntityType; + pspEntityId?: string; + pspPaymentId?: string; + pspReconciliationId?: string; + accountingDestinationId?: string; + accountingExportId?: string; }; }; export type AgentAvailabilityChangedResponse = { @@ -150,6 +171,7 @@ export type WalletSyncedResponse = { walletId: string; syncedAt: string; }; +export type WalletDepositsChangedResponse = WalletSyncedResponse; export declare enum WalletPaymentType { SEND = "send", RECEIVE = "receive" @@ -171,6 +193,7 @@ export type WalletPaymentResponse = { sentAt?: string; description?: string; txid?: string; + vout?: number; invoice?: string; paymentHash?: string; providerPaymentId?: string; @@ -234,6 +257,9 @@ export type MinmoEventPayloadMap = { [PayEventType.STORE_CONNECTED]: PayStore; [PayEventType.STORE_CONNECTION_FAILED]: PayStore; [WalletEventType.SYNCED]: WalletSyncedResponse; + [WalletEventType.DEPOSITS_DISCOVERED]: WalletDepositsChangedResponse; + [WalletEventType.DEPOSITS_UNCLAIMED]: WalletDepositsChangedResponse; + [WalletEventType.DEPOSITS_CLAIMED]: WalletDepositsChangedResponse; [WalletEventType.PAYMENT_PENDING]: WalletPaymentResponse; [WalletEventType.PAYMENT_SUCCEEDED]: WalletPaymentResponse; [WalletEventType.PAYMENT_FAILED]: WalletPaymentResponse; @@ -243,6 +269,20 @@ export type MinmoEventPayloadMap = { [EscrowEventType.RELEASED]: EscrowEventResponse; [EscrowEventType.REFUNDED]: EscrowEventResponse; [EscrowEventType.EXPIRED]: EscrowEventResponse; + [PspEventType.CONNECTION_CREATED]: PspConnectionEventResponse; + [PspEventType.CONNECTION_ACTIVATED]: PspConnectionEventResponse; + [PspEventType.CONNECTION_SUSPENDED]: PspConnectionEventResponse; + [PspEventType.CONNECTION_REVOKED]: PspConnectionEventResponse; + [PspEventType.PAYMENT_CREATED]: PspPaymentEventResponse; + [PspEventType.PAYMENT_SUBMITTED]: PspPaymentEventResponse; + [PspEventType.PAYMENT_PENDING]: PspPaymentEventResponse; + [PspEventType.PAYMENT_SUCCEEDED]: PspPaymentEventResponse; + [PspEventType.PAYMENT_FAILED]: PspPaymentEventResponse; + [PspEventType.PAYMENT_OUTCOME_UNKNOWN]: PspPaymentEventResponse; + [PspEventType.PAYMENT_CANCELLED]: PspPaymentEventResponse; + [PspEventType.RECONCILIATION_COMPLETED]: PspReconciliationEventResponse; + [PspEventType.RECONCILIATION_EXCEPTION_DETECTED]: PspReconciliationEventResponse; + [PspEventType.RECONCILIATION_EXCEPTION_RESOLVED]: PspReconciliationEventResponse; }; /** * Canonical persisted and projected event envelope. diff --git a/vendor/upstream/core/types/feature-catalog.d.ts b/vendor/upstream/core/types/feature-catalog.d.ts new file mode 100644 index 0000000..663fe24 --- /dev/null +++ b/vendor/upstream/core/types/feature-catalog.d.ts @@ -0,0 +1,58 @@ +/** + * Feature catalog: the static map from a console feature to the entitlement + * that gates it, the features it depends on, and what each action requires. + * + * This is data, not policy enforcement. `FeatureAccessService` in the API reads + * it to evaluate a request. See `docs/billing/enforcement.md`. + */ +import { EntitlementKey, PlanCode } from "./billing"; +import { ConsoleFeatureId, FeatureAvailabilityState } from "./features"; +/** + * What a caller wants to do with a feature. + * + * The split exists because billing states treat reads and writes differently: + * a past-due team may still read, but may not make new billable writes. + */ +export declare enum FeatureAction { + /** Read feature data. Permitted while past due. */ + READ = "read", + /** Create or mutate billable domain state. Blocked while past due. */ + WRITE = "write", + /** Change feature configuration. Blocked while past due. */ + CONFIGURE = "configure" +} +export interface FeatureActionPolicy { + /** Whether the team's feature state must be enabled, configured, or active. */ + requiresEnabled: boolean; + /** Whether the entitlement must permit new billable use. */ + requiresBillable: boolean; +} +export interface FeatureCatalogEntry { + id: ConsoleFeatureId; + /** The entitlement that gates this feature. */ + entitlementKey: EntitlementKey; + /** Features that must themselves be accessible before this one is. */ + dependencies: ConsoleFeatureId[]; + /** Additional entitlements a caller may hold under this feature. */ + capabilityEntitlements: EntitlementKey[]; + actions: Record; +} +export declare const FEATURE_CATALOG: Record; +/** Feature states that count as enabled for actions requiring enablement. */ +export declare const ENABLED_FEATURE_STATES: ReadonlySet; +export declare function getFeatureCatalogEntry(featureId: ConsoleFeatureId): FeatureCatalogEntry | null; +/** + * Plans cheapest first. + * + * Product access is cumulative, so the first plan in this order that grants an + * entitlement is the cheapest way to buy it. + */ +export declare const PLAN_UPGRADE_ORDER: readonly PlanCode[]; +/** + * The cheapest plan granting an entitlement, so a locked capability can name + * what to buy rather than only saying it is locked. + */ +export declare function cheapestPlanForEntitlement(key: EntitlementKey): PlanCode | null; +/** The cheapest plan granting the entitlement a console feature is gated on. */ +export declare function cheapestPlanForFeature(featureId: ConsoleFeatureId): PlanCode | null; +//# sourceMappingURL=feature-catalog.d.ts.map \ No newline at end of file diff --git a/vendor/upstream/core/types/features.d.ts b/vendor/upstream/core/types/features.d.ts index 4c36101..75dff97 100644 --- a/vendor/upstream/core/types/features.d.ts +++ b/vendor/upstream/core/types/features.d.ts @@ -1,3 +1,4 @@ +import type { PlanCode } from "./billing"; export declare enum FeatureId { FX = "fx", AGENTS = "agents", @@ -46,9 +47,29 @@ export type FeatureMetadata = { config?: Record; }; export type FeaturesMetadata = Partial>; +/** + * Whether a team's plan grants the entitlement a feature is gated on. + * + * Separate from `state`: `state` is the team's own enablement flag, which an + * admin toggles, while this is what the plan bought. A feature needs both, so + * reporting them apart lets a client say "switched on but not covered by this + * plan" rather than collapsing the two into one misleading answer. + */ +export type FeatureEntitlementSummary = { + entitled: boolean; + /** Cheapest plan that would grant it. Null once entitled, or if no plan does. */ + requiredPlanCode: PlanCode | null; +}; +/** + * Entitlement fields are optional because they are added at the API boundary, + * where billing state is reachable, rather than by the team metadata reader + * that produces the rest. Absent means unknown, and a client should read that + * as entitled: visibility fails open, and the server-side feature gate — not + * the UI — is the enforcement boundary. + */ export type FeatureSummaryDto = FeatureMetadata & { enabled: boolean; -}; +} & Partial; export type UpdateFeatureRequest = { state?: FeatureAvailabilityState; label?: string; diff --git a/vendor/upstream/core/types/index.d.ts b/vendor/upstream/core/types/index.d.ts index 5f0d068..0d172f7 100644 --- a/vendor/upstream/core/types/index.d.ts +++ b/vendor/upstream/core/types/index.d.ts @@ -1,4 +1,5 @@ export * from "./agent"; +export * from "./accounting"; export * from "./agent-currency-channels"; export * from "./analytics"; export * from "./dispute"; @@ -7,6 +8,7 @@ export * from "./notifications"; export * from "./rates"; export * from "./amounts"; export * from "../auth/auth"; +export * from "./billing"; export * from "./bitcoin"; export * from "./channels"; export * from "./common"; @@ -18,15 +20,18 @@ export * from "../utils/design-system"; export * from "./environment"; export * from "./escrow"; export * from "./escrow-status"; +export * from "./feature-catalog"; export * from "./features"; export * from "./liquidity"; export * from "./pagination"; export * from "../auth/permissions"; export * from "./phonenumber"; +export * from "./psp"; export * from "./qr-code"; +export * from "./referral"; export * from "./pay"; export * from "./swap"; +export * from "./swap-progress"; export * from "./user"; -export * from "./mpesa-ussd-automation"; export * from "./dispute"; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/vendor/upstream/core/types/mpesa-ussd-automation.d.ts b/vendor/upstream/core/types/mpesa-ussd-automation.d.ts deleted file mode 100644 index 258fd37..0000000 --- a/vendor/upstream/core/types/mpesa-ussd-automation.d.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { Currency } from "./currency"; -import { PaymentChannel } from "./channels"; -export declare enum MpesaUssdAutomationTaskStatus { - Pending = "pending", - Running = "running", - AwaitingAgentAuth = "awaiting_agent_auth", - Completed = "completed", - Failed = "failed", - Blocked = "blocked" -} -export declare enum MpesaUssdAutomationFailureReason { - UnsupportedChannel = "unsupported_channel", - UnsupportedCurrency = "unsupported_currency", - InvalidTask = "invalid_task", - AccessibilityDisabled = "accessibility_disabled", - CallPermissionDenied = "call_permission_denied", - UssdUnavailable = "ussd_unavailable", - PromptMismatch = "prompt_mismatch", - AmountMismatch = "amount_mismatch", - RecipientMismatch = "recipient_mismatch", - Timeout = "timeout", - ProviderAuthRequired = "provider_auth_required", - ResultUnreadable = "result_unreadable" -} -export declare enum MpesaUssdAutomationStepKind { - LaunchSession = "launch_session", - MatchPrompt = "match_prompt", - SubmitInput = "submit_input", - AwaitAgentAuth = "await_agent_auth", - ConfirmDetails = "confirm_details", - ReadResult = "read_result" -} -export declare enum MpesaUssdAutomationRunMode { - LivePayout = "live_payout", - Test = "test" -} -export interface MpesaUssdPayoutTask { - taskId: string; - swapId: string; - agentId: string; - deviceId: string; - amountKes: string; - phoneNumber: string; - reference: string; - runMode?: MpesaUssdAutomationRunMode; - recipientName?: string; - expiresAt?: string; - idempotencyKey?: string; -} -export interface MpesaUssdAutomationStep { - kind: MpesaUssdAutomationStepKind; - expectedPromptPattern?: string; - inputTemplate?: string; - failureReason?: MpesaUssdAutomationFailureReason; -} -export interface MpesaUssdAutomationResult { - taskId: string; - status: MpesaUssdAutomationTaskStatus; - failureReason?: MpesaUssdAutomationFailureReason; - lastPrompt?: string; - transactionCostKes?: string; - recipientName?: string; -} -export declare function isMpesaUssdAutomationEligible(params: { - currency: Currency; - paymentChannel: PaymentChannel; -}): boolean; -//# sourceMappingURL=mpesa-ussd-automation.d.ts.map \ No newline at end of file diff --git a/vendor/upstream/core/types/psp.d.ts b/vendor/upstream/core/types/psp.d.ts new file mode 100644 index 0000000..42a09b9 --- /dev/null +++ b/vendor/upstream/core/types/psp.d.ts @@ -0,0 +1,506 @@ +import { Currency } from "./currency"; +import type { AccountPurpose, AccountStatus, AccountType, BalanceBasis, ExecutionStatus, NormalBalance, PostingDirection, ReconciliationStatus, SettlementStatus } from "./accounting"; +export type PspPaymentChannelId = string; +export declare enum PspProvider { + SAFARICOM_DARAJA = "safaricom_daraja" +} +export declare enum PspEnvironment { + SANDBOX = "sandbox", + PRODUCTION = "production" +} +export declare enum PspConnectionKind { + OWNER = "owner", + DELEGATED = "delegated" +} +export declare enum PspEntityType { + PARTNER = "partner", + AGENT = "agent" +} +export declare enum PspConnectionStatus { + DRAFT = "draft", + ACTIVE = "active", + SUSPENDED = "suspended", + REVOKED = "revoked" +} +export declare enum PspCapability { + COLLECTION_CREATE = "collection_create", + DISBURSEMENT_CREATE = "disbursement_create", + PAYMENT_READ = "payment_read", + WEBHOOK_RECEIVE = "webhook_receive" +} +export declare enum PspPaymentMethod { + DARAJA_STK_PUSH = "daraja_stk_push", + DARAJA_SEND_MONEY = "daraja_send_money", + DARAJA_BUY_GOODS = "daraja_buy_goods", + DARAJA_PAYBILL = "daraja_paybill" +} +export declare enum PspCallbackMode { + OPAQUE_ENDPOINT = "opaque_endpoint" +} +export declare enum PspProviderSetupFieldType { + TEXT = "text", + SECRET = "secret" +} +export type PspProviderSetupFieldDefinition = { + key: string; + label: string; + description: string; + type: PspProviderSetupFieldType; + documentationUrl: `https://${string}`; +}; +export type PspProviderCredentialSectionDefinition = { + key: string; + title: string; + description: string; + required: boolean; + fields: readonly PspProviderSetupFieldDefinition[]; +}; +export type PspProviderPaymentMethodDefinition = { + id: PspPaymentMethod; + operation: PspPaymentOperation; + displayName: string; + description: string; + currency: Currency; + currencyExponent: number; + amountIncrementMinor: string; + paymentChannelId: PspPaymentChannelId; + paymentChannelVersion: number; + referenceMaxLength: number; + defaultReference: string; +}; +export declare enum PspAccountingTemplate { + DARAJA_COLLECTION_CLEARING_TO_PENDING_ENTITY_V1 = "daraja_collection_clearing_to_pending_entity_v1", + DARAJA_DISBURSEMENT_PENDING_ENTITY_TO_CLEARING_V1 = "daraja_disbursement_pending_entity_to_clearing_v1" +} +export type PspProviderDefinition = { + provider: PspProvider; + displayName: string; + paymentMethodName: string; + description: string; + marketLabel: string; + capabilitySummary: string; + supportedEnvironments: readonly PspEnvironment[]; + supportedCurrencies: readonly Currency[]; + capabilities: readonly PspCapability[]; + paymentMethods: readonly PspProviderPaymentMethodDefinition[]; + credentialSchemaVersion: number; + connectionConfigSchemaVersion: number; + callbackModes: readonly PspCallbackMode[]; + providerAccountReferenceField: PspProviderSetupFieldDefinition; + credentialSections: readonly PspProviderCredentialSectionDefinition[]; + requiresOptionalCredentialSection: boolean; +}; +export type CreatePspConnectionRequest = { + provider: PspProvider; + environment: PspEnvironment; + displayName: string; + providerAccountReference: string; + credentials: Record; +}; +export type RotatePspCredentialsRequest = { + credentials: Record; +}; +export type PspConnectionLimits = { + minAmountMinor?: string; + maxAmountMinor?: string; +}; +export type CreateDelegatedPspConnectionRequest = { + authorizedEntityType: PspEntityType; + authorizedEntityId: string; + displayName: string; + capabilities: PspCapability[]; + currencyScope: Currency[]; + limits?: PspConnectionLimits; + effectiveUntil?: string; +}; +export type RevokePspConnectionRequest = { + reason: string; +}; +export type CreatePspCollectionRequest = { + initiatingEntityType: PspEntityType; + initiatingEntityId: string; + amountMinor: string; + currency: Currency; + exponent: number; + paymentMethod: PspPaymentMethod; + channelData: Record; + reference: string; +}; +export declare enum PspDisbursementDestinationType { + MOBILE_WALLET = "mobile_wallet", + MERCHANT_ACCOUNT = "merchant_account", + BILL_ACCOUNT = "bill_account" +} +export type CreatePspDisbursementRequest = { + initiatingEntityType: PspEntityType; + initiatingEntityId: string; + amountMinor: string; + currency: Currency; + exponent: number; + paymentMethod: PspPaymentMethod; + channelData: Record; + reference: string; +}; +export type CreateOwnerPspConnectionCommand = CreatePspConnectionRequest & { + partnerId: string; +}; +export type RotatePspCredentialsCommand = RotatePspCredentialsRequest & { + partnerId: string; + connectionId: string; +}; +export type CreateDelegatedPspConnectionCommand = CreateDelegatedPspConnectionRequest & { + partnerId: string; + ownerConnectionId: string; + requestedBy: string; +}; +export type RevokePspConnectionCommand = RevokePspConnectionRequest & { + partnerId: string; + connectionId: string; + requestedBy: string; +}; +export type CreatePspCollectionCommand = { + partnerId: string; + connectionId: string; + initiatingEntityType: PspEntityType; + initiatingEntityId: string; + requestedBy: string; + idempotencyKey: string; + money: ExactMoney; + paymentMethod: PspPaymentMethod; + channelData: Record; + reference: string; +}; +export type CreatePspDisbursementCommand = { + partnerId: string; + connectionId: string; + initiatingEntityType: PspEntityType; + initiatingEntityId: string; + requestedBy: string; + idempotencyKey: string; + money: ExactMoney; + paymentMethod: PspPaymentMethod; + channelData: Record; + reference: string; +}; +export type PspConnectionResponse = { + id: string; + partnerId: string; + connectionKind: PspConnectionKind; + parentConnectionId: string | null; + ownerEntityType: PspEntityType; + ownerEntityId: string; + authorizedEntityType: PspEntityType; + authorizedEntityId: string; + provider: PspProvider; + environment: PspEnvironment; + status: PspConnectionStatus; + displayName: string; + providerAccountReference: string | null; + capabilities: PspCapability[]; + currencyScope: Currency[]; + limits: Record; + automationPolicy: Record; + policyVersion: number; + validationHealthCode: string | null; + lastValidatedAt: string | null; + effectiveFrom: string | null; + effectiveUntil: string | null; + approvedBy: string | null; + approvedAt: string | null; + revokedBy: string | null; + revokedAt: string | null; + revocationReason: string | null; + createdAt: string; + updatedAt: string; +}; +export declare enum PspPaymentOperation { + COLLECTION = "collection", + DISBURSEMENT = "disbursement" +} +export type PspPaymentResponse = { + id: string; + partnerId: string; + connectionId: string; + bookEntityType: PspEntityType; + bookEntityId: string; + initiatingEntityType: PspEntityType; + initiatingEntityId: string; + operation: PspPaymentOperation; + paymentMethod: PspPaymentMethod | null; + paymentChannelId: PspPaymentChannelId | null; + paymentChannelVersion: number | null; + money: ExactMoney; + executionStatus: ExecutionStatus; + settlementStatus: SettlementStatus; + reconciliationStatus: ReconciliationStatus; + providerPaymentId: string | null; + providerRequestId: string | null; + payerReference: string | null; + payeeReference: string | null; + failureCode: string | null; + submittedAt: string | null; + pendingAt: string | null; + succeededAt: string | null; + failedAt: string | null; + createdAt: string; + updatedAt: string; +}; +export type PspPaymentListQuery = { + connectionId?: string; + initiatingEntityType?: PspEntityType; + initiatingEntityId?: string; + executionStatus?: ExecutionStatus; + settlementStatus?: SettlementStatus; + reconciliationStatus?: ReconciliationStatus; + limit?: number; + offset?: number; +}; +export declare enum PspProviderBalanceStatus { + UNAVAILABLE = "unavailable" +} +/** A signed or zero point-in-time balance expressed in exact minor units. */ +export type PspBalance = { + amountMinor: string; + currency: Currency; + exponent: number; +}; +export type PspAccountResponse = { + id: string; + partnerId: string; + bookEntityType: PspEntityType; + bookEntityId: string; + counterpartyEntityType: PspEntityType | null; + counterpartyEntityId: string | null; + connectionId: string | null; + accountCode: string; + name: string; + accountType: AccountType; + purpose: AccountPurpose; + normalBalance: NormalBalance; + status: AccountStatus; + balance: PspBalance; + balanceBasis: BalanceBasis; + providerBalance: PspBalance | null; + providerBalanceStatus: PspProviderBalanceStatus; + createdAt: string; + closedAt: string | null; +}; +export type PspLiquidityResponse = { + accountId: string; + partnerId: string; + connectionId: string | null; + entityType: PspEntityType; + entityId: string; + attributedBalance: PspBalance; + availableBalance: PspBalance; + reservedBalance: PspBalance; + balanceBasis: BalanceBasis; + providerBalance: PspBalance | null; + providerBalanceStatus: PspProviderBalanceStatus; +}; +export type PspConnectionLiquidityBalance = { + attributedBalance: PspBalance; + availableBalance: PspBalance; + reservedBalance: PspBalance; + providerBalance: PspBalance | null; + providerBalanceStatus: PspProviderBalanceStatus; +}; +export type PspConnectionLiquiditySummary = { + connectionId: string; + balanceBasis: BalanceBasis; + balances: PspConnectionLiquidityBalance[]; +}; +export type PspLiquidityListQuery = { + connectionId?: string; + limit?: number; + offset?: number; +}; +export type PspLiquidityListResponse = PspPageResponse & { + connectionSummaries: PspConnectionLiquiditySummary[]; +}; +export type PspStatementEntryResponse = { + postingId: string; + journalId: string; + journalType: string; + sourceType: string; + sourceId: string; + direction: PostingDirection; + money: ExactMoney; + balanceAfter: PspBalance; + effectiveAt: string; + postedAt: string; + providerSettlementReference: string | null; + dimensions: Record; +}; +export type PspAccountStatementResponse = { + account: PspAccountResponse; + entries: PspStatementEntryResponse[]; + total: number; + limit: number; + offset: number; +}; +export declare enum PspReconciliationType { + TRANSACTION = "transaction", + BALANCE = "balance" +} +export declare enum PspReconciliationRecordKind { + RUN = "run", + ITEM = "item" +} +export declare enum PspReconciliationStatus { + PENDING = "pending", + MATCHED = "matched", + EXCEPTION = "exception", + RESOLVED = "resolved" +} +export declare enum PspReconciliationExceptionCode { + MISSING_PROVIDER_EVIDENCE = "missing_provider_evidence", + UNMATCHED_PROVIDER_TRANSACTION = "unmatched_provider_transaction", + CONFLICTING_PROVIDER_OUTCOME = "conflicting_provider_outcome", + UNRESOLVED_PROVIDER_OUTCOME = "unresolved_provider_outcome", + PAYMENT_STATUS_MISMATCH = "payment_status_mismatch", + AMOUNT_MISMATCH = "amount_mismatch", + CURRENCY_MISMATCH = "currency_mismatch", + MISSING_RECOGNITION_JOURNAL = "missing_recognition_journal", + ACCOUNTING_SCOPE_MISMATCH = "accounting_scope_mismatch" +} +export declare enum PspReconciliationResolutionAction { + CONFIRM_EXISTING_MATCH = "confirm_existing_match", + LINK_PAYMENT = "link_payment", + RECORD_ACCOUNTING_CORRECTION = "record_accounting_correction" +} +export type CreatePspReconciliationRequest = { + connectionId: string; + currency: Currency; + exponent: number; + evidencePeriodStart: string; + evidencePeriodEnd: string; +}; +export type ResolvePspReconciliationItemRequest = { + action: PspReconciliationResolutionAction; + reason: string; + evidenceReference: string; + approvalReference: string; + paymentId?: string; + resolutionJournalId?: string; +}; +export type PspReconciliationRunResponse = { + id: string; + partnerId: string; + connectionId: string; + bookEntityType: PspEntityType; + bookEntityId: string; + type: PspReconciliationType; + status: PspReconciliationStatus; + currency: Currency; + exponent: number; + providerAccountReference: string | null; + evidencePeriodStart: string; + evidencePeriodEnd: string; + sourceArtifactHash: string; + internalRecordCount: number; + externalRecordCount: number; + internalTotalMinor: string; + externalTotalMinor: string; + createdBy: string; + startedAt: string; + completedAt: string; + createdAt: string; + updatedAt: string; +}; +export type PspReconciliationItemResponse = { + id: string; + runId: string; + partnerId: string; + connectionId: string; + status: PspReconciliationStatus; + currency: Currency; + exponent: number; + paymentId: string | null; + journalId: string | null; + providerTransactionId: string | null; + providerSettlementReference: string | null; + expectedAmountMinor: string | null; + observedAmountMinor: string | null; + discrepancyAmountMinor: string | null; + matchRuleVersion: string | null; + exceptionCode: PspReconciliationExceptionCode | null; + exceptionOwner: string | null; + resolutionAction: PspReconciliationResolutionAction | null; + resolutionEvidenceReference: string | null; + resolutionReason: string | null; + approvalReference: string | null; + resolutionJournalId: string | null; + resolvedBy: string | null; + resolvedAt: string | null; + createdBy: string; + createdAt: string; + updatedAt: string; +}; +export type PspPageResponse = { + items: T[]; + total: number; + limit: number; + offset: number; +}; +export type PspReconciliationListResponse = PspPageResponse; +export declare enum PspEventType { + CONNECTION_CREATED = "psp.connection.created", + CONNECTION_ACTIVATED = "psp.connection.activated", + CONNECTION_SUSPENDED = "psp.connection.suspended", + CONNECTION_REVOKED = "psp.connection.revoked", + PAYMENT_CREATED = "psp.payment.created", + PAYMENT_SUBMITTED = "psp.payment.submitted", + PAYMENT_PENDING = "psp.payment.pending", + PAYMENT_SUCCEEDED = "psp.payment.succeeded", + PAYMENT_FAILED = "psp.payment.failed", + PAYMENT_OUTCOME_UNKNOWN = "psp.payment.outcome.unknown", + PAYMENT_CANCELLED = "psp.payment.cancelled", + RECONCILIATION_COMPLETED = "psp.reconciliation.completed", + RECONCILIATION_EXCEPTION_DETECTED = "psp.reconciliation.exception.detected", + RECONCILIATION_EXCEPTION_RESOLVED = "psp.reconciliation.exception.resolved" +} +export type MinorUnitAmount = string & { + readonly __brand: "MinorUnitAmount"; +}; +export type ExactMoney = { + amountMinor: MinorUnitAmount; + currency: Currency; + exponent: number; +}; +export declare function isMinorUnitAmount(value: unknown): value is MinorUnitAmount; +export declare function createMinorUnitAmount(value: string): MinorUnitAmount; +export declare function isExactMoney(value: unknown): value is ExactMoney; +export declare function createExactMoney(input: { + amountMinor: string; + currency: Currency; + exponent: number; +}): ExactMoney; +export type PspConnectionEventResponse = { + connectionId: string; + provider: PspProvider; + status: PspConnectionStatus; + entityType: PspEntityType; + entityId: string; +}; +export type PspPaymentEventResponse = { + paymentId: string; + connectionId: string; + entityType: PspEntityType; + entityId: string; + operation: PspPaymentOperation; + money: ExactMoney; + executionStatus: ExecutionStatus; + settlementStatus: SettlementStatus; + reconciliationStatus: ReconciliationStatus; + failureCode?: string; +}; +export type PspReconciliationEventResponse = { + reconciliationId: string; + connectionId: string; + entityType: PspEntityType; + entityId: string; + type: PspReconciliationType; + status: PspReconciliationStatus; +}; +//# sourceMappingURL=psp.d.ts.map \ No newline at end of file diff --git a/vendor/upstream/core/types/rates.d.ts b/vendor/upstream/core/types/rates.d.ts index 532b649..22dbe11 100644 --- a/vendor/upstream/core/types/rates.d.ts +++ b/vendor/upstream/core/types/rates.d.ts @@ -1,4 +1,9 @@ import type { Currency, CurrencyPair } from "./currency"; +import type { SwapType } from "./agent"; +export declare enum FxRateScope { + PARTNER = "partner", + SYSTEM = "system" +} export interface FxRate { /** Currency being priced, for example BTC. */ baseCurrency: Currency; @@ -15,6 +20,7 @@ export interface FxRateRequest { baseCurrency: Currency; targetCurrency: Currency; amount?: string; + type?: SwapType; } export interface FxRateSource { getName(): string; @@ -129,13 +135,44 @@ export interface PartnerRateResponse { agentId?: string; /** The resolved FX rate and its source/timestamp metadata. */ fxRate: FxRate; + /** Describes whether the team policy or the global market supplied the rate. */ + coverage: PartnerRateCoverage; expiresAt?: string; policyVersion?: string; } +export declare enum PartnerRateResolution { + TEAM_CONFIGURED = "team_configured", + GLOBAL_FALLBACK = "global_fallback" +} +export declare enum PartnerRateFallbackReason { + TEAM_CURRENCY_UNSUPPORTED = "team_currency_unsupported", + TEAM_RATE_UNAVAILABLE = "team_rate_unavailable" +} +export interface PartnerRateCoverage { + resolution: PartnerRateResolution; + configuredForTeam: boolean; + fallbackReason?: PartnerRateFallbackReason; +} +export interface PartnerQuoteFeeBreakdown { + teamId: string; + descriptorId: string; + enabled: boolean; + policyVersion: number; + agentMarginBps: number; + escrowFeeBps: number; + escrowFeeSats: string; + payoutNetworkFeeSats: string; + principalSats: string; + receiverPayoutSats: string; + minimumSats?: string; + maximumSats?: string; + /** Network fees remain estimates until the final payout destination is known. */ + estimated: boolean; +} export interface PartnerQuoteResponse extends PartnerRateResponse { quoteId: string; inputAmount?: string; outputAmount?: string; - fees?: string; + fees?: PartnerQuoteFeeBreakdown; } //# sourceMappingURL=rates.d.ts.map \ No newline at end of file diff --git a/vendor/upstream/core/types/referral.d.ts b/vendor/upstream/core/types/referral.d.ts new file mode 100644 index 0000000..5965efb --- /dev/null +++ b/vendor/upstream/core/types/referral.d.ts @@ -0,0 +1,10 @@ +export declare enum ReferralCodeScope { + SYSTEM = "system", + TEAM = "team" +} +export declare enum ReferralCodeUse { + AGENT_INVITE = "agent_invite", + PARTNER_MEMBER_SIGNUP = "partner_member_signup" +} +export declare const ALL_REFERRAL_CODE_USES: ReferralCodeUse[]; +//# sourceMappingURL=referral.d.ts.map \ No newline at end of file diff --git a/vendor/upstream/core/types/swap-progress.d.ts b/vendor/upstream/core/types/swap-progress.d.ts new file mode 100644 index 0000000..9a82b57 --- /dev/null +++ b/vendor/upstream/core/types/swap-progress.d.ts @@ -0,0 +1,13 @@ +/** + * User-facing milestones in the standard swap lifecycle. + * + * Exceptional states such as cancellation, disputes, and refunds do not map + * to a progress step because they branch away from this standard flow. + */ +export declare enum SwapProgress { + STARTED = "started", + ESCROW = "escrow", + FIAT_PAYMENT = "fiat_payment", + COMPLETE = "complete" +} +//# sourceMappingURL=swap-progress.d.ts.map \ No newline at end of file diff --git a/vendor/upstream/core/utils/swap.d.ts b/vendor/upstream/core/utils/swap.d.ts index 9933473..6165a29 100644 --- a/vendor/upstream/core/utils/swap.d.ts +++ b/vendor/upstream/core/utils/swap.d.ts @@ -1,5 +1,14 @@ import { SwapState, SwapType } from "../types/agent"; import type { Agent } from "../types/agent"; +import { SwapProgress } from "../types/swap-progress"; +/** Standard swap milestones in display order. */ +export declare const SWAP_PROGRESS_STEPS: readonly SwapProgress[]; +/** + * Collapse the detailed swap state machine into user-facing progress steps. + * Exceptional branches return null so consumers can present their actual + * status without implying that the standard flow is still in progress. + */ +export declare function getSwapProgress(state: SwapState): SwapProgress | null; /** Derive the enabled swap directions with a stable BUY-first order. */ export declare function getEnabledSwapTypes(agent: Agent): SwapType[]; export declare enum SwapActor { @@ -30,6 +39,12 @@ export declare const DISPUTE_STATES: Set; export declare const ACTIVE_DISPUTE_STATES: Set; export declare const DISPUTE_REVIEW_STATES: Set; export declare const PAYMENT_CONFIRMABLE_STATES: Set; +/** + * States where fiat beneficiary details may be revealed to the party that + * must send fiat. Keep these details hidden until escrow funding has been + * verified and the swap has advanced to PAYMENT_INSTRUCTED. + */ +export declare const PAYMENT_CHANNEL_DETAILS_VISIBLE_STATES: ReadonlySet; export declare const REFUND_STATES: Set; /** Refund states that still require action (excludes REFUNDED). */ export declare const ACTIVE_REFUND_STATES: Set; @@ -42,6 +57,14 @@ export declare const TIMEOUT_STATES: Set; */ export declare const ONRAMP_ESCROW_ACTIVE_STATES: SwapState[]; export declare const STATE_TRANSITIONS: Record; +/** Whether this actor is the one who must send fiat in the given swap type. */ +export declare function isFiatSender(actor: SwapActor, type: SwapType): boolean; +/** + * Actor- and type-aware next-step guidance for a swap state. Shared across + * clients so "what should I do right now" reads the same everywhere a swap + * is tracked. + */ +export declare function getSwapProgressMessage(state: SwapState, actor: SwapActor, type: SwapType, fiatCurrency: string): string; export declare function isTerminalSwapState(state: SwapState): boolean; export declare function isCancellableSwapState(state: SwapState): boolean; export declare function canCancelSwap(state: SwapState, hasUserConfirmation?: boolean, hasAgentConfirmation?: boolean): boolean; diff --git a/vendor/upstream/core/wallet/types.d.ts b/vendor/upstream/core/wallet/types.d.ts index 6cefaea..0ebf2f6 100644 --- a/vendor/upstream/core/wallet/types.d.ts +++ b/vendor/upstream/core/wallet/types.d.ts @@ -124,6 +124,7 @@ export type WalletPaymentHistoryItem = { sentAt?: string; description?: string; txid?: string; + vout?: number; invoice?: string; paymentHash?: string; providerPaymentId?: string; @@ -136,6 +137,50 @@ export type WalletPaymentHistoryItem = { destination?: string; explorerUrl?: string; }; +export declare enum WalletDepositState { + AWAITING_CONFIRMATIONS = "awaiting_confirmations", + AUTOMATIC_CLAIM_IN_PROGRESS = "automatic_claim_in_progress", + CLAIM_FEE_APPROVAL_REQUIRED = "claim_fee_approval_required", + CLAIM_FAILED = "claim_failed" +} +export declare enum WalletDepositClaimErrorCode { + MAX_DEPOSIT_CLAIM_FEE_EXCEEDED = "max_deposit_claim_fee_exceeded", + MISSING_UTXO = "missing_utxo", + GENERIC = "generic" +} +export type WalletDepositClaimError = { + code: WalletDepositClaimErrorCode; + message: string; + configuredMaxFeeRateSatPerVbyte?: number; + requiredFeeSats?: string; + requiredFeeRateSatPerVbyte?: number; +}; +export type WalletRecommendedFees = { + fastestFeeRateSatPerVbyte: number; + halfHourFeeRateSatPerVbyte: number; + hourFeeRateSatPerVbyte: number; + economyFeeRateSatPerVbyte: number; + minimumFeeRateSatPerVbyte: number; +}; +export type WalletUnclaimedDeposit = { + outpoint: string; + txid: string; + vout: number; + amountSats: string; + isMature: boolean; + state: WalletDepositState; + explorerUrl?: string; + claimError?: WalletDepositClaimError; + recommendedFees?: WalletRecommendedFees; +}; +export type WalletDepositClaimInput = { + maxFeeRateSatPerVbyte: number; + feeAccepted: boolean; +}; +export type WalletDepositClaimResult = { + payment: WalletPaymentHistoryItem; + overview: WalletOverview; +}; export type StableBalanceOverview = { enabled: boolean; active: boolean; @@ -158,6 +203,8 @@ export type WalletOverview = { identityPubkey?: string; syncedAt: string; stableBalance?: StableBalanceOverview; + /** Visible pending funds that are not included in either balance field. */ + unclaimedDeposits: WalletUnclaimedDeposit[]; history: WalletPaymentHistoryItem[]; }; export interface WalletInstanceConfig { diff --git a/vendor/upstream/manifest.json b/vendor/upstream/manifest.json index deeeb6e..c8fed4c 100644 --- a/vendor/upstream/manifest.json +++ b/vendor/upstream/manifest.json @@ -1,6 +1,6 @@ { "schemaVersion": 1, "upstreamRepository": "https://github.com/minmoto/mini", - "upstreamCommit": "4e5e473c834535699553ede6b9c4923eef443d96", - "artifactSha256": "b3aaf0bd5bc0de36312bfbb5401f7d551578c95a2264dead255492d4ce23e479" + "upstreamCommit": "e8e17d09fe26466e5ba1952592a44d9732c9f15f", + "artifactSha256": "258960138f16d27a927bb6c3095255970420e508fd2d565dbcd6487070b7be2d" } diff --git a/vendor/upstream/runtime.d.mts b/vendor/upstream/runtime.d.mts index 7eb310d..1753014 100644 --- a/vendor/upstream/runtime.d.mts +++ b/vendor/upstream/runtime.d.mts @@ -12,19 +12,30 @@ export { SwapEscrowPaymentStatus } from "./sdk/escrow.js"; export { ApiKeyInvalidReason, ReferralCodeScope } from "./sdk/partner.js"; export { AgentSelectionMode, + AccountingExportFailureCode, + AccountingHealthStatus, + AccountPurpose, + AccountStatus, + AccountType, AgentStatus, AgentTeamAssociationStatus, AgentTeamAssociationVisibility, AnalyticsBucket, ApiKeyCapability, ApiKeyResourceScope, + BalanceBasis, BitcoinNetwork, + BookEntityType, ConfirmationRole, Currency, DisputeResolution, EscrowEventType, EscrowNetwork, + ExecutionStatus, + ExportReportType, FxRateProvider, + JournalStatus, + NormalBalance, OnchainConfirmationSpeed, OtcEventType, ParticipantRole, @@ -36,9 +47,36 @@ export { PaymentChannel, PayoutDestinationType, Permission, + PostingDirection, + PspAccountingTemplate, + PspCallbackMode, + PspCapability, + PspConnectionKind, + PspConnectionStatus, + PspDisbursementDestinationType, + PspEntityType, + PspEnvironment, + PspEventType, + PspPaymentMethod, + PspPaymentOperation, + PspProvider, + PspProviderBalanceStatus, + PspProviderSetupFieldType, + PspReconciliationExceptionCode, + PspReconciliationRecordKind, + PspReconciliationResolutionAction, + PspReconciliationStatus, + PspReconciliationType, + ReconciliationStatus, + SettlementStatus, + SourceType, SwapState, SwapType, TeamRole, + TransactionDirection, + TransactionOperation, + ValuationBasis, + ValuationStatus, WalletConnectionScope, WalletEventType, WalletProvider, diff --git a/vendor/upstream/runtime.mjs b/vendor/upstream/runtime.mjs index 1ef911d..e2b9987 100644 --- a/vendor/upstream/runtime.mjs +++ b/vendor/upstream/runtime.mjs @@ -56,6 +56,7 @@ var HttpClient = class { auth; fetchFn; timeoutMs; + authInvalidationPromise = null; constructor(options) { const url = new URL(options.baseUrl); if (!/^https?:$/.test(url.protocol)) { @@ -69,69 +70,51 @@ var HttpClient = class { async request(path, init = {}) { const controller = new AbortController(); const timeout = setTimeout(() => controller.abort(), this.timeoutMs); - const headers = new Headers(init.headers); - headers.set("Accept", "application/json"); - if (init.body && !headers.has("Content-Type")) { - headers.set("Content-Type", "application/json"); + const requestSignal = init.signal; + const abortRequest = () => controller.abort(); + if (requestSignal?.aborted) { + abortRequest(); + } else { + requestSignal?.addEventListener("abort", abortRequest, { once: true }); } - for (const [name, value] of Object.entries( - await this.auth?.getHeaders() ?? {} - )) { - headers.set(name, value); + try { + return await this.requestWithAuthRetry( + path, + init, + controller.signal, + true + ); + } finally { + clearTimeout(timeout); + requestSignal?.removeEventListener("abort", abortRequest); } + } + /** Returns an unconsumed successful response for streaming/binary callers. */ + async requestResponse(path, init = {}) { + const controller = new AbortController(); + const timeout = setTimeout(() => controller.abort(), this.timeoutMs); + const requestSignal = init.signal; + const abortRequest = () => controller.abort(); + if (requestSignal?.aborted) abortRequest(); + else requestSignal?.addEventListener("abort", abortRequest, { once: true }); try { - let response; - try { - response = await this.fetchResponse(path, { - ...init, - headers, - signal: init.signal ?? controller.signal - }); - } catch (error) { - throw new MinmoTransportError( - error instanceof Error ? error.message : String(error), - error - ); - } - const text = await response.text(); - const body = text ? this.parseBody(text) : void 0; - if (!response.ok) { - const requestId = response.headers.get("x-request-id") ?? void 0; - const message = typeof body === "object" && body && "message" in body ? String(body.message) : `Minmo API request failed (${response.status})`; - if (response.status === 401) { - throw new MinmoAuthenticationError( - message, - response.status, - body, - requestId - ); - } - if (response.status === 403) { - throw new MinmoAuthorizationError( - message, - response.status, - body, - requestId - ); - } - if (response.status === 429) { - throw new MinmoRateLimitError( - message, - response.status, - body, - requestId - ); - } - throw new MinmoApiError(message, response.status, body); - } - return body; + return await this.responseWithAuthRetry( + path, + init, + controller.signal, + true + ); } finally { clearTimeout(timeout); + requestSignal?.removeEventListener("abort", abortRequest); } } async fetchResponse(path, init = {}) { const headers = new Headers(init.headers); headers.set("Accept", headers.get("Accept") ?? "application/json"); + if (init.body && !headers.has("Content-Type")) { + headers.set("Content-Type", "application/json"); + } for (const [name, value] of Object.entries( await this.auth?.getHeaders() ?? {} )) { @@ -139,6 +122,94 @@ var HttpClient = class { } return this.fetchFn(`${this.baseUrl}${path}`, { ...init, headers }); } + async requestWithAuthRetry(path, init, signal, canRetryAuthentication) { + let response; + try { + response = await this.fetchResponse(path, { + ...init, + signal + }); + } catch (error) { + throw new MinmoTransportError( + error instanceof Error ? error.message : String(error), + error + ); + } + const text = await response.text(); + const body = text ? this.parseBody(text) : void 0; + if (!response.ok) { + const responseError = this.createResponseError(response, body); + if (response.status === 401 && canRetryAuthentication && this.auth?.invalidate) { + try { + await this.invalidateAuth(); + } catch { + throw responseError; + } + return this.requestWithAuthRetry(path, init, signal, false); + } + throw responseError; + } + return body; + } + async responseWithAuthRetry(path, init, signal, canRetryAuthentication) { + let response; + try { + response = await this.fetchResponse(path, { ...init, signal }); + } catch (error) { + throw new MinmoTransportError( + error instanceof Error ? error.message : String(error), + error + ); + } + if (response.ok) return response; + const text = await response.text(); + const body = text ? this.parseBody(text) : void 0; + const responseError = this.createResponseError(response, body); + if (response.status === 401 && canRetryAuthentication && this.auth?.invalidate) { + try { + await this.invalidateAuth(); + } catch { + throw responseError; + } + return this.responseWithAuthRetry(path, init, signal, false); + } + throw responseError; + } + createResponseError(response, body) { + const requestId = response.headers.get("x-request-id") ?? void 0; + const message = typeof body === "object" && body && "message" in body ? String(body.message) : `Minmo API request failed (${response.status})`; + if (response.status === 401) { + return new MinmoAuthenticationError( + message, + response.status, + body, + requestId + ); + } + if (response.status === 403) { + return new MinmoAuthorizationError( + message, + response.status, + body, + requestId + ); + } + if (response.status === 429) { + return new MinmoRateLimitError(message, response.status, body, requestId); + } + return new MinmoApiError(message, response.status, body); + } + invalidateAuth() { + if (!this.auth?.invalidate) { + return Promise.resolve(); + } + if (!this.authInvalidationPromise) { + this.authInvalidationPromise = Promise.resolve().then(() => this.auth?.invalidate?.()).finally(() => { + this.authInvalidationPromise = null; + }); + } + return this.authInvalidationPromise; + } parseBody(text) { try { return JSON.parse(text); @@ -446,6 +517,154 @@ var SwapState = /* @__PURE__ */ ((SwapState2) => { return SwapState2; })(SwapState || {}); +// packages/core/src/types/accounting.ts +var SourceType = /* @__PURE__ */ ((SourceType2) => { + SourceType2["WALLET"] = "wallet"; + SourceType2["PSP_CONNECTION"] = "psp_connection"; + return SourceType2; +})(SourceType || {}); +var ExportReportType = /* @__PURE__ */ ((ExportReportType2) => { + ExportReportType2["TRANSACTION_HISTORY"] = "transaction_history"; + ExportReportType2["GENERAL_LEDGER"] = "general_ledger"; + return ExportReportType2; +})(ExportReportType || {}); +var AccountingHealthStatus = /* @__PURE__ */ ((AccountingHealthStatus2) => { + AccountingHealthStatus2["READY"] = "ready"; + AccountingHealthStatus2["NEEDS_ATTENTION"] = "needs_attention"; + AccountingHealthStatus2["UNAVAILABLE"] = "unavailable"; + return AccountingHealthStatus2; +})(AccountingHealthStatus || {}); +var AccountingExportFailureCode = /* @__PURE__ */ ((AccountingExportFailureCode2) => { + AccountingExportFailureCode2["SOURCE_NOT_FOUND"] = "source_not_found"; + AccountingExportFailureCode2["SOURCE_PERMISSION_DENIED"] = "source_permission_denied"; + AccountingExportFailureCode2["SOURCE_UNAVAILABLE"] = "source_unavailable"; + AccountingExportFailureCode2["UNSUPPORTED_REPORT_TYPE"] = "unsupported_report_type"; + AccountingExportFailureCode2["INVALID_PERIOD"] = "invalid_period"; + AccountingExportFailureCode2["PERIOD_TOO_LARGE"] = "period_too_large"; + AccountingExportFailureCode2["EXPORT_TOO_LARGE"] = "export_too_large"; + AccountingExportFailureCode2["VALUATION_INCOMPLETE"] = "valuation_incomplete"; + AccountingExportFailureCode2["JOURNAL_INCOMPLETE"] = "journal_incomplete"; + AccountingExportFailureCode2["JOURNAL_UNBALANCED"] = "journal_unbalanced"; + AccountingExportFailureCode2["SOURCE_PROJECTION_FAILED"] = "source_projection_failed"; + AccountingExportFailureCode2["GENERATION_TIMEOUT"] = "generation_timeout"; + AccountingExportFailureCode2["CONCURRENCY_LIMIT"] = "export_concurrency_limit"; + AccountingExportFailureCode2["DELIVERY_INTERRUPTED"] = "delivery_interrupted"; + return AccountingExportFailureCode2; +})(AccountingExportFailureCode || {}); +var BookEntityType = /* @__PURE__ */ ((BookEntityType2) => { + BookEntityType2["PARTNER"] = "partner"; + BookEntityType2["AGENT"] = "agent"; + return BookEntityType2; +})(BookEntityType || {}); +var AccountType = /* @__PURE__ */ ((AccountType2) => { + AccountType2["ASSET"] = "asset"; + AccountType2["LIABILITY"] = "liability"; + AccountType2["EQUITY"] = "equity"; + AccountType2["REVENUE"] = "revenue"; + AccountType2["EXPENSE"] = "expense"; + AccountType2["MEMORANDUM"] = "memorandum"; + return AccountType2; +})(AccountType || {}); +var AccountPurpose = /* @__PURE__ */ ((AccountPurpose2) => { + AccountPurpose2["WALLET_ASSET"] = "wallet_asset"; + AccountPurpose2["WALLET_PENDING_OUTBOUND"] = "wallet_pending_outbound"; + AccountPurpose2["WALLET_UNALLOCATED_RECEIPT"] = "wallet_unallocated_receipt"; + AccountPurpose2["WALLET_UNCLASSIFIED_OUTFLOW"] = "wallet_unclassified_outflow"; + AccountPurpose2["WALLET_NETWORK_FEE_EXPENSE"] = "wallet_network_fee_expense"; + AccountPurpose2["WALLET_TRANSFER_CLEARING"] = "wallet_transfer_clearing"; + AccountPurpose2["WALLET_RECONCILIATION_SUSPENSE"] = "wallet_reconciliation_suspense"; + AccountPurpose2["PSP_CASH"] = "psp_cash"; + AccountPurpose2["PSP_CLEARING"] = "psp_clearing"; + AccountPurpose2["PSP_ENTITY_LIQUIDITY"] = "psp_entity_liquidity"; + AccountPurpose2["PSP_PENDING_FUNDS"] = "psp_pending_funds"; + AccountPurpose2["PSP_FEE_REVENUE"] = "psp_fee_revenue"; + AccountPurpose2["PSP_PROVIDER_FEE_EXPENSE"] = "psp_provider_fee_expense"; + AccountPurpose2["PSP_UNALLOCATED_FUNDS"] = "psp_unallocated_funds"; + AccountPurpose2["PSP_RECONCILIATION_SUSPENSE"] = "psp_reconciliation_suspense"; + return AccountPurpose2; +})(AccountPurpose || {}); +var NormalBalance = /* @__PURE__ */ ((NormalBalance2) => { + NormalBalance2["DEBIT"] = "debit"; + NormalBalance2["CREDIT"] = "credit"; + return NormalBalance2; +})(NormalBalance || {}); +var AccountStatus = /* @__PURE__ */ ((AccountStatus2) => { + AccountStatus2["ACTIVE"] = "active"; + AccountStatus2["FROZEN"] = "frozen"; + AccountStatus2["CLOSED"] = "closed"; + return AccountStatus2; +})(AccountStatus || {}); +var BalanceBasis = /* @__PURE__ */ ((BalanceBasis2) => { + BalanceBasis2["INTERNAL_POSTED"] = "internal_posted"; + return BalanceBasis2; +})(BalanceBasis || {}); +var JournalStatus = /* @__PURE__ */ ((JournalStatus2) => { + JournalStatus2["PENDING"] = "pending"; + JournalStatus2["POSTED"] = "posted"; + JournalStatus2["VOIDED"] = "voided"; + JournalStatus2["REVERSED"] = "reversed"; + return JournalStatus2; +})(JournalStatus || {}); +var PostingDirection = /* @__PURE__ */ ((PostingDirection2) => { + PostingDirection2["DEBIT"] = "debit"; + PostingDirection2["CREDIT"] = "credit"; + return PostingDirection2; +})(PostingDirection || {}); +var ExecutionStatus = /* @__PURE__ */ ((ExecutionStatus2) => { + ExecutionStatus2["CREATED"] = "created"; + ExecutionStatus2["SUBMITTED"] = "submitted"; + ExecutionStatus2["PENDING"] = "pending"; + ExecutionStatus2["SUCCEEDED"] = "succeeded"; + ExecutionStatus2["FAILED"] = "failed"; + ExecutionStatus2["OUTCOME_UNKNOWN"] = "outcome_unknown"; + ExecutionStatus2["CANCELLED"] = "cancelled"; + return ExecutionStatus2; +})(ExecutionStatus || {}); +var SettlementStatus = /* @__PURE__ */ ((SettlementStatus2) => { + SettlementStatus2["UNPOSTED"] = "unposted"; + SettlementStatus2["RESERVED"] = "reserved"; + SettlementStatus2["POSTED"] = "posted"; + SettlementStatus2["REVERSED"] = "reversed"; + return SettlementStatus2; +})(SettlementStatus || {}); +var ReconciliationStatus = /* @__PURE__ */ ((ReconciliationStatus2) => { + ReconciliationStatus2["NOT_DUE"] = "not_due"; + ReconciliationStatus2["PENDING"] = "pending"; + ReconciliationStatus2["MATCHED"] = "matched"; + ReconciliationStatus2["EXCEPTION"] = "exception"; + ReconciliationStatus2["RESOLVED"] = "resolved"; + return ReconciliationStatus2; +})(ReconciliationStatus || {}); +var TransactionDirection = /* @__PURE__ */ ((TransactionDirection2) => { + TransactionDirection2["INBOUND"] = "inbound"; + TransactionDirection2["OUTBOUND"] = "outbound"; + TransactionDirection2["INTERNAL"] = "internal"; + return TransactionDirection2; +})(TransactionDirection || {}); +var TransactionOperation = /* @__PURE__ */ ((TransactionOperation2) => { + TransactionOperation2["RECEIVE"] = "receive"; + TransactionOperation2["SEND"] = "send"; + TransactionOperation2["COLLECTION"] = "collection"; + TransactionOperation2["DISBURSEMENT"] = "disbursement"; + TransactionOperation2["FEE"] = "fee"; + TransactionOperation2["TRANSFER"] = "transfer"; + return TransactionOperation2; +})(TransactionOperation || {}); +var ValuationStatus = /* @__PURE__ */ ((ValuationStatus2) => { + ValuationStatus2["COMPLETE"] = "complete"; + ValuationStatus2["INCOMPLETE"] = "incomplete"; + ValuationStatus2["NOT_REQUIRED"] = "not_required"; + return ValuationStatus2; +})(ValuationStatus || {}); +var ValuationBasis = /* @__PURE__ */ ((ValuationBasis2) => { + ValuationBasis2["EXECUTION_TIME"] = "execution_time"; + ValuationBasis2["PROVIDER_OCCURRED_TIME"] = "provider_occurred_time"; + ValuationBasis2["FIRST_OBSERVED_TIME"] = "first_observed_time"; + ValuationBasis2["HISTORICAL_BACKFILL"] = "historical_backfill"; + ValuationBasis2["IDENTITY"] = "identity"; + return ValuationBasis2; +})(ValuationBasis || {}); + // packages/core/src/types/currency.ts var Currency = /* @__PURE__ */ ((Currency2) => { Currency2["BTC"] = "BTC"; @@ -505,6 +724,129 @@ var AnalyticsBucket = /* @__PURE__ */ ((AnalyticsBucket2) => { return AnalyticsBucket2; })(AnalyticsBucket || {}); +// packages/core/src/types/psp.ts +var PspProvider = /* @__PURE__ */ ((PspProvider2) => { + PspProvider2["SAFARICOM_DARAJA"] = "safaricom_daraja"; + return PspProvider2; +})(PspProvider || {}); +var PspEnvironment = /* @__PURE__ */ ((PspEnvironment2) => { + PspEnvironment2["SANDBOX"] = "sandbox"; + PspEnvironment2["PRODUCTION"] = "production"; + return PspEnvironment2; +})(PspEnvironment || {}); +var PspConnectionKind = /* @__PURE__ */ ((PspConnectionKind2) => { + PspConnectionKind2["OWNER"] = "owner"; + PspConnectionKind2["DELEGATED"] = "delegated"; + return PspConnectionKind2; +})(PspConnectionKind || {}); +var PspEntityType = /* @__PURE__ */ ((PspEntityType2) => { + PspEntityType2["PARTNER"] = "partner"; + PspEntityType2["AGENT"] = "agent"; + return PspEntityType2; +})(PspEntityType || {}); +var PspConnectionStatus = /* @__PURE__ */ ((PspConnectionStatus2) => { + PspConnectionStatus2["DRAFT"] = "draft"; + PspConnectionStatus2["ACTIVE"] = "active"; + PspConnectionStatus2["SUSPENDED"] = "suspended"; + PspConnectionStatus2["REVOKED"] = "revoked"; + return PspConnectionStatus2; +})(PspConnectionStatus || {}); +var PspCapability = /* @__PURE__ */ ((PspCapability2) => { + PspCapability2["COLLECTION_CREATE"] = "collection_create"; + PspCapability2["DISBURSEMENT_CREATE"] = "disbursement_create"; + PspCapability2["PAYMENT_READ"] = "payment_read"; + PspCapability2["WEBHOOK_RECEIVE"] = "webhook_receive"; + return PspCapability2; +})(PspCapability || {}); +var PspPaymentMethod = /* @__PURE__ */ ((PspPaymentMethod2) => { + PspPaymentMethod2["DARAJA_STK_PUSH"] = "daraja_stk_push"; + PspPaymentMethod2["DARAJA_SEND_MONEY"] = "daraja_send_money"; + PspPaymentMethod2["DARAJA_BUY_GOODS"] = "daraja_buy_goods"; + PspPaymentMethod2["DARAJA_PAYBILL"] = "daraja_paybill"; + return PspPaymentMethod2; +})(PspPaymentMethod || {}); +var PspCallbackMode = /* @__PURE__ */ ((PspCallbackMode2) => { + PspCallbackMode2["OPAQUE_ENDPOINT"] = "opaque_endpoint"; + return PspCallbackMode2; +})(PspCallbackMode || {}); +var PspProviderSetupFieldType = /* @__PURE__ */ ((PspProviderSetupFieldType2) => { + PspProviderSetupFieldType2["TEXT"] = "text"; + PspProviderSetupFieldType2["SECRET"] = "secret"; + return PspProviderSetupFieldType2; +})(PspProviderSetupFieldType || {}); +var PspAccountingTemplate = /* @__PURE__ */ ((PspAccountingTemplate2) => { + PspAccountingTemplate2["DARAJA_COLLECTION_CLEARING_TO_PENDING_ENTITY_V1"] = "daraja_collection_clearing_to_pending_entity_v1"; + PspAccountingTemplate2["DARAJA_DISBURSEMENT_PENDING_ENTITY_TO_CLEARING_V1"] = "daraja_disbursement_pending_entity_to_clearing_v1"; + return PspAccountingTemplate2; +})(PspAccountingTemplate || {}); +var PspDisbursementDestinationType = /* @__PURE__ */ ((PspDisbursementDestinationType2) => { + PspDisbursementDestinationType2["MOBILE_WALLET"] = "mobile_wallet"; + PspDisbursementDestinationType2["MERCHANT_ACCOUNT"] = "merchant_account"; + PspDisbursementDestinationType2["BILL_ACCOUNT"] = "bill_account"; + return PspDisbursementDestinationType2; +})(PspDisbursementDestinationType || {}); +var PspPaymentOperation = /* @__PURE__ */ ((PspPaymentOperation2) => { + PspPaymentOperation2["COLLECTION"] = "collection"; + PspPaymentOperation2["DISBURSEMENT"] = "disbursement"; + return PspPaymentOperation2; +})(PspPaymentOperation || {}); +var PspProviderBalanceStatus = /* @__PURE__ */ ((PspProviderBalanceStatus2) => { + PspProviderBalanceStatus2["UNAVAILABLE"] = "unavailable"; + return PspProviderBalanceStatus2; +})(PspProviderBalanceStatus || {}); +var PspReconciliationType = /* @__PURE__ */ ((PspReconciliationType2) => { + PspReconciliationType2["TRANSACTION"] = "transaction"; + PspReconciliationType2["BALANCE"] = "balance"; + return PspReconciliationType2; +})(PspReconciliationType || {}); +var PspReconciliationRecordKind = /* @__PURE__ */ ((PspReconciliationRecordKind2) => { + PspReconciliationRecordKind2["RUN"] = "run"; + PspReconciliationRecordKind2["ITEM"] = "item"; + return PspReconciliationRecordKind2; +})(PspReconciliationRecordKind || {}); +var PspReconciliationStatus = /* @__PURE__ */ ((PspReconciliationStatus2) => { + PspReconciliationStatus2["PENDING"] = "pending"; + PspReconciliationStatus2["MATCHED"] = "matched"; + PspReconciliationStatus2["EXCEPTION"] = "exception"; + PspReconciliationStatus2["RESOLVED"] = "resolved"; + return PspReconciliationStatus2; +})(PspReconciliationStatus || {}); +var PspReconciliationExceptionCode = /* @__PURE__ */ ((PspReconciliationExceptionCode2) => { + PspReconciliationExceptionCode2["MISSING_PROVIDER_EVIDENCE"] = "missing_provider_evidence"; + PspReconciliationExceptionCode2["UNMATCHED_PROVIDER_TRANSACTION"] = "unmatched_provider_transaction"; + PspReconciliationExceptionCode2["CONFLICTING_PROVIDER_OUTCOME"] = "conflicting_provider_outcome"; + PspReconciliationExceptionCode2["UNRESOLVED_PROVIDER_OUTCOME"] = "unresolved_provider_outcome"; + PspReconciliationExceptionCode2["PAYMENT_STATUS_MISMATCH"] = "payment_status_mismatch"; + PspReconciliationExceptionCode2["AMOUNT_MISMATCH"] = "amount_mismatch"; + PspReconciliationExceptionCode2["CURRENCY_MISMATCH"] = "currency_mismatch"; + PspReconciliationExceptionCode2["MISSING_RECOGNITION_JOURNAL"] = "missing_recognition_journal"; + PspReconciliationExceptionCode2["ACCOUNTING_SCOPE_MISMATCH"] = "accounting_scope_mismatch"; + return PspReconciliationExceptionCode2; +})(PspReconciliationExceptionCode || {}); +var PspReconciliationResolutionAction = /* @__PURE__ */ ((PspReconciliationResolutionAction2) => { + PspReconciliationResolutionAction2["CONFIRM_EXISTING_MATCH"] = "confirm_existing_match"; + PspReconciliationResolutionAction2["LINK_PAYMENT"] = "link_payment"; + PspReconciliationResolutionAction2["RECORD_ACCOUNTING_CORRECTION"] = "record_accounting_correction"; + return PspReconciliationResolutionAction2; +})(PspReconciliationResolutionAction || {}); +var PspEventType = /* @__PURE__ */ ((PspEventType2) => { + PspEventType2["CONNECTION_CREATED"] = "psp.connection.created"; + PspEventType2["CONNECTION_ACTIVATED"] = "psp.connection.activated"; + PspEventType2["CONNECTION_SUSPENDED"] = "psp.connection.suspended"; + PspEventType2["CONNECTION_REVOKED"] = "psp.connection.revoked"; + PspEventType2["PAYMENT_CREATED"] = "psp.payment.created"; + PspEventType2["PAYMENT_SUBMITTED"] = "psp.payment.submitted"; + PspEventType2["PAYMENT_PENDING"] = "psp.payment.pending"; + PspEventType2["PAYMENT_SUCCEEDED"] = "psp.payment.succeeded"; + PspEventType2["PAYMENT_FAILED"] = "psp.payment.failed"; + PspEventType2["PAYMENT_OUTCOME_UNKNOWN"] = "psp.payment.outcome.unknown"; + PspEventType2["PAYMENT_CANCELLED"] = "psp.payment.cancelled"; + PspEventType2["RECONCILIATION_COMPLETED"] = "psp.reconciliation.completed"; + PspEventType2["RECONCILIATION_EXCEPTION_DETECTED"] = "psp.reconciliation.exception.detected"; + PspEventType2["RECONCILIATION_EXCEPTION_RESOLVED"] = "psp.reconciliation.exception.resolved"; + return PspEventType2; +})(PspEventType || {}); + // packages/core/src/types/events.ts var OtcEventType = /* @__PURE__ */ ((OtcEventType2) => { OtcEventType2["SWAP_CREATED"] = "otc.swap.created"; @@ -553,6 +895,9 @@ var PayEventType = /* @__PURE__ */ ((PayEventType2) => { })(PayEventType || {}); var WalletEventType = /* @__PURE__ */ ((WalletEventType2) => { WalletEventType2["SYNCED"] = "wallet.synced"; + WalletEventType2["DEPOSITS_DISCOVERED"] = "wallet.deposits.discovered"; + WalletEventType2["DEPOSITS_UNCLAIMED"] = "wallet.deposits.unclaimed"; + WalletEventType2["DEPOSITS_CLAIMED"] = "wallet.deposits.claimed"; WalletEventType2["PAYMENT_PENDING"] = "wallet.payment.pending"; WalletEventType2["PAYMENT_SUCCEEDED"] = "wallet.payment.succeeded"; WalletEventType2["PAYMENT_FAILED"] = "wallet.payment.failed"; @@ -571,7 +916,8 @@ var MINMO_EVENT_TYPES = [ ...Object.values(OtcEventType), ...Object.values(PayEventType), ...Object.values(WalletEventType), - ...Object.values(EscrowEventType) + ...Object.values(EscrowEventType), + ...Object.values(PspEventType) ]; // packages/core/src/types/rates.ts @@ -617,6 +963,7 @@ var Permission = /* @__PURE__ */ ((Permission2) => { Permission2["ESCROW_CREATE"] = "escrow:create"; Permission2["ESCROW_READ"] = "escrow:read"; Permission2["ESCROW_VERIFY_FUNDING"] = "escrow:verify_funding"; + Permission2["ESCROW_EXPIRE"] = "escrow:expire"; Permission2["ESCROW_RELEASE"] = "escrow:release"; Permission2["ESCROW_REFUND"] = "escrow:refund"; Permission2["ESCROW_RESOLVE_DISPUTE"] = "escrow:resolve_dispute"; @@ -636,6 +983,7 @@ var Permission = /* @__PURE__ */ ((Permission2) => { Permission2["PARTNER_AGENT_MANAGE"] = "partner:agent_manage"; Permission2["PARTNER_AGENTS_READ"] = "partner:agents_read"; Permission2["PARTNER_SWAPS_READ"] = "partner:swaps_read"; + Permission2["PARTNER_SWAPS_MANAGE"] = "partner:swaps_manage"; Permission2["PARTNER_LIQUIDITY_READ"] = "partner:liquidity_read"; Permission2["PARTNER_METRICS_READ"] = "partner:metrics_read"; Permission2["PARTNER_SERVICES_CREATE"] = "partner:services_create"; @@ -648,6 +996,19 @@ var Permission = /* @__PURE__ */ ((Permission2) => { Permission2["PAY_EVENT_SUBSCRIBE"] = "pay:event_subscribe"; Permission2["PAY_STORE_READ"] = "pay:store_read"; Permission2["PAY_STORE_MANAGE"] = "pay:store_manage"; + Permission2["PSP_CONNECTION_READ"] = "psp:connection_read"; + Permission2["PSP_CONNECTION_MANAGE"] = "psp:connection_manage"; + Permission2["PSP_PAYMENT_CREATE"] = "psp:payment_create"; + Permission2["PSP_DISBURSEMENT_CREATE"] = "psp:disbursement_create"; + Permission2["PSP_PAYMENT_READ"] = "psp:payment_read"; + Permission2["PSP_ACCOUNT_READ"] = "psp:account_read"; + Permission2["PSP_EVENT_SUBSCRIBE"] = "psp:event_subscribe"; + Permission2["PSP_RECONCILIATION_READ"] = "psp:reconciliation_read"; + Permission2["PSP_RECONCILIATION_RUN"] = "psp:reconciliation_run"; + Permission2["PSP_RECONCILIATION_RESOLVE"] = "psp:reconciliation_resolve"; + Permission2["ACCOUNTING_READ"] = "accounting:read"; + Permission2["ACCOUNTING_TEMPLATE_MANAGE"] = "accounting:template_manage"; + Permission2["ACCOUNTING_EXPORT"] = "accounting:export"; return Permission2; })(Permission || {}); var PERMISSION_GROUPS = { @@ -669,6 +1030,7 @@ var PERMISSION_GROUPS = { "escrow:create" /* ESCROW_CREATE */, "escrow:read" /* ESCROW_READ */, "escrow:verify_funding" /* ESCROW_VERIFY_FUNDING */, + "escrow:expire" /* ESCROW_EXPIRE */, "escrow:release" /* ESCROW_RELEASE */, "escrow:refund" /* ESCROW_REFUND */, "escrow:resolve_dispute" /* ESCROW_RESOLVE_DISPUTE */, @@ -714,6 +1076,7 @@ var PERMISSION_GROUPS = { "partner:agent_manage" /* PARTNER_AGENT_MANAGE */, "partner:agents_read" /* PARTNER_AGENTS_READ */, "partner:swaps_read" /* PARTNER_SWAPS_READ */, + "partner:swaps_manage" /* PARTNER_SWAPS_MANAGE */, "partner:liquidity_read" /* PARTNER_LIQUIDITY_READ */, "partner:metrics_read" /* PARTNER_METRICS_READ */, "partner:services_create" /* PARTNER_SERVICES_CREATE */, @@ -732,6 +1095,23 @@ var PERMISSION_GROUPS = { "pay:event_subscribe" /* PAY_EVENT_SUBSCRIBE */, "pay:store_read" /* PAY_STORE_READ */, "pay:store_manage" /* PAY_STORE_MANAGE */ + ], + PSP_OPERATIONS: [ + "psp:connection_read" /* PSP_CONNECTION_READ */, + "psp:connection_manage" /* PSP_CONNECTION_MANAGE */, + "psp:payment_create" /* PSP_PAYMENT_CREATE */, + "psp:disbursement_create" /* PSP_DISBURSEMENT_CREATE */, + "psp:payment_read" /* PSP_PAYMENT_READ */, + "psp:account_read" /* PSP_ACCOUNT_READ */, + "psp:event_subscribe" /* PSP_EVENT_SUBSCRIBE */, + "psp:reconciliation_read" /* PSP_RECONCILIATION_READ */, + "psp:reconciliation_run" /* PSP_RECONCILIATION_RUN */, + "psp:reconciliation_resolve" /* PSP_RECONCILIATION_RESOLVE */ + ], + ACCOUNTING_OPERATIONS: [ + "accounting:read" /* ACCOUNTING_READ */, + "accounting:template_manage" /* ACCOUNTING_TEMPLATE_MANAGE */, + "accounting:export" /* ACCOUNTING_EXPORT */ ] }; var ROLE_PERMISSIONS = { @@ -749,13 +1129,16 @@ var ROLE_PERMISSIONS = { ...PERMISSION_GROUPS.ANALYTICS, ...PERMISSION_GROUPS.PARTNER_OPERATIONS, ...PERMISSION_GROUPS.PARTNER_ADMIN_OPERATIONS, - ...PERMISSION_GROUPS.PAY_OPERATIONS + ...PERMISSION_GROUPS.PAY_OPERATIONS, + ...PERMISSION_GROUPS.PSP_OPERATIONS, + ...PERMISSION_GROUPS.ACCOUNTING_OPERATIONS ], // Group Roles (assigned via Hexclave team/RBAC membership) ["team_admin" /* TEAM_ADMIN */]: [ // Core agent operations "agent:register" /* AGENT_REGISTER */, "agent:manage_own" /* AGENT_MANAGE_OWN */, + "bitcoin:wallet_read" /* BITCOIN_WALLET_READ */, // Transaction operations "swap:create" /* SWAP_CREATE */, "swap:read_own" /* SWAP_READ_OWN */, @@ -767,13 +1150,17 @@ var ROLE_PERMISSIONS = { // Analytics "reports:read_all" /* ANALYTICS_READ_ALL */, // Partner-specific tenant-level permissions - ...PERMISSION_GROUPS.PARTNER_OPERATIONS + ...PERMISSION_GROUPS.PARTNER_OPERATIONS, + // Minmo Pay operations scoped to the administered team + ...PERMISSION_GROUPS.PAY_OPERATIONS, + ...PERMISSION_GROUPS.PSP_OPERATIONS, + ...PERMISSION_GROUPS.ACCOUNTING_OPERATIONS ], ["team_member" /* TEAM_MEMBER */]: [ // Console/product visibility for assigned teams "agent:register" /* AGENT_REGISTER */, "agent:manage_own" /* AGENT_MANAGE_OWN */, - "swap:create" /* SWAP_CREATE */, + "bitcoin:wallet_read" /* BITCOIN_WALLET_READ */, "swap:read_own" /* SWAP_READ_OWN */, "liquidity:manage_own" /* LIQUIDITY_MANAGE_OWN */, "fx:rates_read" /* FX_RATES_READ */, @@ -783,7 +1170,16 @@ var ROLE_PERMISSIONS = { "partner:swaps_read" /* PARTNER_SWAPS_READ */, "partner:liquidity_read" /* PARTNER_LIQUIDITY_READ */, "partner:metrics_read" /* PARTNER_METRICS_READ */, - "partner:services_read" /* PARTNER_SERVICES_READ */ + "partner:services_read" /* PARTNER_SERVICES_READ */, + "pay:store_read" /* PAY_STORE_READ */, + "pay:payment_read" /* PAY_PAYMENT_READ */, + "pay:event_subscribe" /* PAY_EVENT_SUBSCRIBE */, + "psp:connection_read" /* PSP_CONNECTION_READ */, + "psp:payment_read" /* PSP_PAYMENT_READ */, + "psp:account_read" /* PSP_ACCOUNT_READ */, + "psp:event_subscribe" /* PSP_EVENT_SUBSCRIBE */, + "psp:reconciliation_read" /* PSP_RECONCILIATION_READ */, + "accounting:read" /* ACCOUNTING_READ */ ], ["minmo_partner" /* MINMO_PARTNER */]: [ // Agent read access for dashboard visibility @@ -837,6 +1233,19 @@ var ConfirmationRole = /* @__PURE__ */ ((ConfirmationRole2) => { return ConfirmationRole2; })(ConfirmationRole || {}); +// packages/core/src/types/referral.ts +var ReferralCodeScope = /* @__PURE__ */ ((ReferralCodeScope2) => { + ReferralCodeScope2["SYSTEM"] = "system"; + ReferralCodeScope2["TEAM"] = "team"; + return ReferralCodeScope2; +})(ReferralCodeScope || {}); +var ReferralCodeUse = /* @__PURE__ */ ((ReferralCodeUse2) => { + ReferralCodeUse2["AGENT_INVITE"] = "agent_invite"; + ReferralCodeUse2["PARTNER_MEMBER_SIGNUP"] = "partner_member_signup"; + return ReferralCodeUse2; +})(ReferralCodeUse || {}); +var ALL_REFERRAL_CODE_USES = Object.values(ReferralCodeUse); + // packages/core/src/types/pay.ts var PayStoreStatus = /* @__PURE__ */ ((PayStoreStatus2) => { PayStoreStatus2["CREATED"] = "created"; @@ -894,12 +1303,16 @@ var ApiKeyCapability = /* @__PURE__ */ ((ApiKeyCapability2) => { ApiKeyCapability2["ESCROW_ADMIN"] = "escrow.admin"; ApiKeyCapability2["PAY_READONLY"] = "pay.readonly"; ApiKeyCapability2["PAY_READ_WRITE"] = "pay.read_write"; + ApiKeyCapability2["PSP_READONLY"] = "psp.readonly"; + ApiKeyCapability2["PSP_COLLECTIONS"] = "psp.collections"; + ApiKeyCapability2["PSP_DISBURSEMENTS"] = "psp.disbursements"; return ApiKeyCapability2; })(ApiKeyCapability || {}); var API_KEY_CAPABILITY_PERMISSIONS = { ["swap.readonly" /* SWAP_READONLY */]: [ "agent:read_all" /* AGENT_READ_ALL */, "swap:read_all" /* SWAP_READ_ALL */, + "partner:swaps_read" /* PARTNER_SWAPS_READ */, "fx:rates_read" /* FX_RATES_READ */ ], ["swap.read_write" /* SWAP_READ_WRITE */]: [ @@ -907,11 +1320,14 @@ var API_KEY_CAPABILITY_PERMISSIONS = { "swap:read_all" /* SWAP_READ_ALL */, "swap:create" /* SWAP_CREATE */, "swap:cancel_all" /* SWAP_CANCEL_ALL */, + "partner:swaps_read" /* PARTNER_SWAPS_READ */, + "partner:swaps_manage" /* PARTNER_SWAPS_MANAGE */, "fx:rates_read" /* FX_RATES_READ */ ], ["team.readonly" /* TEAM_READONLY */]: [ "agent:read_all" /* AGENT_READ_ALL */, "swap:read_all" /* SWAP_READ_ALL */, + "partner:swaps_read" /* PARTNER_SWAPS_READ */, "liquidity:read_all" /* LIQUIDITY_READ_ALL */, "fx:rates_read" /* FX_RATES_READ */, "reports:read_all" /* ANALYTICS_READ_ALL */ @@ -922,6 +1338,8 @@ var API_KEY_CAPABILITY_PERMISSIONS = { "swap:read_all" /* SWAP_READ_ALL */, "swap:create" /* SWAP_CREATE */, "swap:cancel_all" /* SWAP_CANCEL_ALL */, + "partner:swaps_read" /* PARTNER_SWAPS_READ */, + "partner:swaps_manage" /* PARTNER_SWAPS_MANAGE */, "liquidity:read_all" /* LIQUIDITY_READ_ALL */, "liquidity:manage_all" /* LIQUIDITY_MANAGE_ALL */, "fx:rates_read" /* FX_RATES_READ */, @@ -932,6 +1350,7 @@ var API_KEY_CAPABILITY_PERMISSIONS = { "escrow:create" /* ESCROW_CREATE */, "escrow:read" /* ESCROW_READ */, "escrow:verify_funding" /* ESCROW_VERIFY_FUNDING */, + "escrow:expire" /* ESCROW_EXPIRE */, "escrow:release" /* ESCROW_RELEASE */, "escrow:refund" /* ESCROW_REFUND */, "escrow:resolve_dispute" /* ESCROW_RESOLVE_DISPUTE */ @@ -949,6 +1368,27 @@ var API_KEY_CAPABILITY_PERMISSIONS = { "pay:payment_create" /* PAY_PAYMENT_CREATE */, "pay:payment_cancel" /* PAY_PAYMENT_CANCEL */, "pay:event_subscribe" /* PAY_EVENT_SUBSCRIBE */ + ], + ["psp.readonly" /* PSP_READONLY */]: [ + "psp:connection_read" /* PSP_CONNECTION_READ */, + "psp:payment_read" /* PSP_PAYMENT_READ */, + "psp:account_read" /* PSP_ACCOUNT_READ */, + "psp:event_subscribe" /* PSP_EVENT_SUBSCRIBE */, + "psp:reconciliation_read" /* PSP_RECONCILIATION_READ */ + ], + ["psp.collections" /* PSP_COLLECTIONS */]: [ + "psp:connection_read" /* PSP_CONNECTION_READ */, + "psp:payment_read" /* PSP_PAYMENT_READ */, + "psp:payment_create" /* PSP_PAYMENT_CREATE */, + "psp:event_subscribe" /* PSP_EVENT_SUBSCRIBE */, + "psp:reconciliation_read" /* PSP_RECONCILIATION_READ */ + ], + ["psp.disbursements" /* PSP_DISBURSEMENTS */]: [ + "psp:connection_read" /* PSP_CONNECTION_READ */, + "psp:payment_read" /* PSP_PAYMENT_READ */, + "psp:disbursement_create" /* PSP_DISBURSEMENT_CREATE */, + "psp:event_subscribe" /* PSP_EVENT_SUBSCRIBE */, + "psp:reconciliation_read" /* PSP_RECONCILIATION_READ */ ] }; @@ -1010,10 +1450,22 @@ var EscrowDisputesClient = class { list() { return this.http.request("/swap/disputed"); } + /** Lists disputes in one explicitly authorized Partner. */ + listForPartner(partnerId) { + return this.http.request( + `/teams/${segment(partnerId)}/swaps/disputed` + ); + } /** Reads the authoritative swap resource containing the dispute. */ get(swapId) { return this.http.request(`/swap/${segment(swapId)}`); } + /** Reads a dispute after enforcing access to its Partner scope. */ + getForPartner(partnerId, swapId) { + return this.http.request( + `/teams/${segment(partnerId)}/swaps/${segment(swapId)}/dispute` + ); + } /** Opens a dispute as an authorized swap participant. */ open(swapId, input) { return this.http.request(`/swap/${segment(swapId)}/dispute`, { @@ -1038,6 +1490,13 @@ var EscrowDisputesClient = class { { method: "PATCH", body: JSON.stringify(input) } ); } + /** Records a dispute decision inside one explicitly authorized Partner. */ + resolveForPartner(partnerId, swapId, input) { + return this.http.request( + `/teams/${segment(partnerId)}/swaps/${segment(swapId)}/dispute-resolution`, + { method: "PATCH", body: JSON.stringify(input) } + ); + } /** Executes the payout required after a dispute enters refund state. */ executeRefund(swapId, input) { return this.http.request( @@ -1087,13 +1546,21 @@ var EscrowClient = class { } list(teamId, query = {}) { const params = new URLSearchParams(); - if (query.limit !== void 0) params.set("limit", String(query.limit)); - if (query.offset !== void 0) params.set("offset", String(query.offset)); + appendEscrowListQuery(params, query); const suffix = params.toString() ? `?${params}` : ""; return this.http.request( `/teams/${segment2(teamId)}/escrows${suffix}` ); } + activity(teamId, query = {}) { + const params = new URLSearchParams(); + appendEscrowListQuery(params, query.open ?? {}, "open"); + appendEscrowListQuery(params, query.history ?? {}, "history"); + const suffix = params.toString() ? `?${params}` : ""; + return this.http.request( + `/teams/${segment2(teamId)}/escrows/activity${suffix}` + ); + } get(teamId, reference) { return this.http.request( `/teams/${segment2(teamId)}/escrows/${segment2(reference)}` @@ -1115,6 +1582,12 @@ var EscrowClient = class { { method: "POST" } ); } + expireUnfunded(teamId, reference) { + return this.http.request( + `/teams/${segment2(teamId)}/escrows/${segment2(reference)}/expire`, + { method: "POST" } + ); + } /** Test-only command; production deployments reject it. */ markMockFundingComplete(teamId, reference) { return this.http.request( @@ -1208,6 +1681,17 @@ var EscrowClient = class { ); } }; +function appendEscrowListQuery(params, query, prefix = "") { + const name = (field) => prefix ? `${prefix}${field[0].toUpperCase()}${field.slice(1)}` : field; + if (query.limit !== void 0) params.set(name("limit"), String(query.limit)); + if (query.offset !== void 0) + params.set(name("offset"), String(query.offset)); + if (query.statuses?.length) + params.set(name("statuses"), query.statuses.join(",")); + if (query.reference) params.set(name("reference"), query.reference); + if (query.terminal !== void 0) + params.set(name("terminal"), String(query.terminal)); +} // packages/sdk/src/otc/agents.ts function queryString2(query) { @@ -1351,7 +1835,8 @@ var RatesClient = class { agentId, baseCurrency: request.baseCurrency, fiatCurrency: request.targetCurrency, - ...request.amount ? { amount: request.amount } : {} + ...request.amount ? { fiatAmount: request.amount } : {}, + ...request.type ? { type: request.type } : {} }); return this.http.request(`/swap/quote?${params}`); } @@ -1394,6 +1879,14 @@ var SwapClient = class { constructor(http) { this.http = http; } + listPath(path, query) { + const params = new URLSearchParams(); + for (const [key, value] of Object.entries(query)) { + if (value !== void 0) params.set(key, String(value)); + } + const suffix = params.toString() ? `?${params}` : ""; + return `${path}${suffix}`; + } create(input) { return this.http.request("/swap", { method: "POST", @@ -1409,12 +1902,22 @@ var SwapClient = class { return this.http.request("/swap/disputed"); } list(query = {}) { - const params = new URLSearchParams(); - for (const [key, value] of Object.entries(query)) { - if (value !== void 0) params.set(key, String(value)); - } - const suffix = params.toString() ? `?${params}` : ""; - return this.http.request(`/swap${suffix}`); + return this.http.request(this.listPath("/swap", query)); + } + listForPartner(partnerId, query = {}) { + const path = `/teams/${encodeURIComponent(partnerId)}/swaps`; + return this.http.request(this.listPath(path, query)); + } + getForPartner(partnerId, swapId) { + return this.http.request( + `/teams/${encodeURIComponent(partnerId)}/swaps/${encodeURIComponent(swapId)}` + ); + } + cancelForPartner(partnerId, swapId, input = {}) { + return this.http.request( + `/teams/${encodeURIComponent(partnerId)}/swaps/${encodeURIComponent(swapId)}/cancel`, + { method: "PATCH", body: JSON.stringify(input) } + ); } claim(swapId, input = {}) { return this.http.request( @@ -1626,24 +2129,235 @@ var PayStoreResource = class { } }; -// packages/sdk/src/partner.ts +// packages/sdk/src/psp.ts var segment4 = (value) => encodeURIComponent(value); -var partnerPath = (partnerId, suffix = "") => `/teams/${segment4(partnerId)}${suffix}`; var requiredId = (value, label) => { const normalized = value.trim(); if (!normalized) throw new Error(`${label} is required`); return normalized; }; +var PspClient = class { + constructor(http, eventsClient, partnerId) { + this.http = http; + this.eventsClient = eventsClient; + this.partnerId = partnerId; + } + /** Subscribes to PSP lifecycle events in this Partner scope. */ + events(options) { + const { eventTypes, ...subscriptionOptions } = options; + return subscribeToDomainEvents( + this.eventsClient, + "psp", + eventTypes ?? Object.values(PspEventType), + { + ...subscriptionOptions, + partnerId: this.partnerId, + streamKey: options.streamKey ?? JSON.stringify({ + domain: "psp", + partnerId: this.partnerId, + aggregateId: options.aggregateId, + eventTypes + }) + } + ); + } + async listProviders() { + return this.http.request( + `${this.path()}/providers` + ); + } + async getProvider(provider) { + return this.http.request( + `${this.path()}/providers/${segment4(provider)}` + ); + } + async listConnections() { + return this.http.request( + `${this.path()}/connections` + ); + } + async getConnection(connectionId) { + return this.http.request( + `${this.path()}/connections/${segment4(requiredId(connectionId, "PSP connection ID"))}` + ); + } + async createConnection(input) { + return this.http.request( + `${this.path()}/connections`, + { + method: "POST", + body: JSON.stringify(input) + } + ); + } + async activateConnection(connectionId) { + return this.http.request( + `${this.path()}/connections/${segment4(requiredId(connectionId, "PSP connection ID"))}/activate`, + { method: "POST" } + ); + } + async rotateCredentials(connectionId, input) { + return this.http.request( + `${this.path()}/connections/${segment4(requiredId(connectionId, "PSP connection ID"))}/credentials`, + { method: "PUT", body: JSON.stringify(input) } + ); + } + async createDelegation(ownerConnectionId, input) { + return this.http.request( + `${this.path()}/connections/${segment4(requiredId(ownerConnectionId, "PSP owner connection ID"))}/delegations`, + { method: "POST", body: JSON.stringify(input) } + ); + } + async revokeDelegation(connectionId, input) { + return this.http.request( + `${this.path()}/connections/${segment4(requiredId(connectionId, "PSP connection ID"))}/revoke`, + { method: "POST", body: JSON.stringify(input) } + ); + } + async createCollection(connectionId, input, idempotencyKey) { + const normalizedIdempotencyKey = requiredId( + idempotencyKey, + "Idempotency key" + ); + return this.http.request( + `${this.path()}/connections/${segment4(requiredId(connectionId, "PSP connection ID"))}/collections`, + { + method: "POST", + body: JSON.stringify(input), + headers: { "Idempotency-Key": normalizedIdempotencyKey } + } + ); + } + async createDisbursement(connectionId, input, idempotencyKey) { + const normalizedIdempotencyKey = requiredId( + idempotencyKey, + "Idempotency key" + ); + return this.http.request( + `${this.path()}/connections/${segment4(requiredId(connectionId, "PSP connection ID"))}/disbursements`, + { + method: "POST", + body: JSON.stringify(input), + headers: { "Idempotency-Key": normalizedIdempotencyKey } + } + ); + } + async getPayment(paymentId) { + return this.http.request( + `${this.path()}/payments/${segment4(requiredId(paymentId, "PSP payment ID"))}` + ); + } + async listPayments(input = {}) { + return this.http.request( + `${this.path()}/payments${paymentQuery(input)}` + ); + } + async listAccounts(input = {}) { + return this.http.request( + `${this.path()}/accounts${pageQuery(input)}` + ); + } + async getAccount(accountId) { + return this.http.request( + `${this.path()}/accounts/${segment4(requiredId(accountId, "PSP account ID"))}` + ); + } + async listLiquidity(input = {}) { + return this.http.request( + `${this.path()}/liquidity${liquidityQuery(input)}` + ); + } + async getAccountStatement(accountId, input = {}) { + return this.http.request( + `${this.path()}/accounts/${segment4(requiredId(accountId, "PSP account ID"))}/statement${pageQuery(input)}` + ); + } + async createReconciliation(input) { + return this.http.request( + `${this.path()}/reconciliations`, + { method: "POST", body: JSON.stringify(input) } + ); + } + async listReconciliations(input = {}) { + return this.http.request(`${this.path()}/reconciliations${pageQuery(input)}`); + } + async getReconciliation(reconciliationId) { + return this.http.request( + `${this.path()}/reconciliations/${segment4(requiredId(reconciliationId, "PSP reconciliation ID"))}` + ); + } + async listReconciliationItems(reconciliationId, input = {}) { + return this.http.request( + `${this.path()}/reconciliations/${segment4(requiredId(reconciliationId, "PSP reconciliation ID"))}/items${pageQuery(input)}` + ); + } + async listReconciliationExceptions(reconciliationId, input = {}) { + return this.http.request( + `${this.path()}/reconciliations/${segment4(requiredId(reconciliationId, "PSP reconciliation ID"))}/exceptions${pageQuery(input)}` + ); + } + async resolveReconciliationItem(reconciliationId, itemId, input) { + return this.http.request( + `${this.path()}/reconciliations/${segment4(requiredId(reconciliationId, "PSP reconciliation ID"))}/items/${segment4(requiredId(itemId, "PSP reconciliation item ID"))}/resolve`, + { method: "POST", body: JSON.stringify(input) } + ); + } + path() { + return `/teams/${segment4(requiredId(this.partnerId ?? "", "Partner ID"))}/psp`; + } +}; +function pageQuery(input) { + const query = new URLSearchParams(); + if (input.limit !== void 0) query.set("limit", String(input.limit)); + if (input.offset !== void 0) query.set("offset", String(input.offset)); + const value = query.toString(); + return value ? `?${value}` : ""; +} +function paymentQuery(input) { + const query = new URLSearchParams(); + if (input.connectionId) query.set("connectionId", input.connectionId); + if (input.initiatingEntityType) { + query.set("initiatingEntityType", input.initiatingEntityType); + } + if (input.initiatingEntityId) { + query.set("initiatingEntityId", input.initiatingEntityId); + } + if (input.executionStatus) { + query.set("executionStatus", input.executionStatus); + } + if (input.settlementStatus) { + query.set("settlementStatus", input.settlementStatus); + } + if (input.reconciliationStatus) { + query.set("reconciliationStatus", input.reconciliationStatus); + } + if (input.limit !== void 0) query.set("limit", String(input.limit)); + if (input.offset !== void 0) query.set("offset", String(input.offset)); + const value = query.toString(); + return value ? `?${value}` : ""; +} +function liquidityQuery(input) { + const query = new URLSearchParams(); + if (input.connectionId) query.set("connectionId", input.connectionId); + if (input.limit !== void 0) query.set("limit", String(input.limit)); + if (input.offset !== void 0) query.set("offset", String(input.offset)); + const value = query.toString(); + return value ? `?${value}` : ""; +} + +// packages/sdk/src/partner.ts +var segment5 = (value) => encodeURIComponent(value); +var partnerPath = (partnerId, suffix = "") => `/teams/${segment5(partnerId)}${suffix}`; +var requiredId2 = (value, label) => { + const normalized = value.trim(); + if (!normalized) throw new Error(`${label} is required`); + return normalized; +}; var ApiKeyInvalidReason = /* @__PURE__ */ ((ApiKeyInvalidReason2) => { ApiKeyInvalidReason2["MANUALLY_REVOKED"] = "manually-revoked"; ApiKeyInvalidReason2["EXPIRED"] = "expired"; return ApiKeyInvalidReason2; })(ApiKeyInvalidReason || {}); -var ReferralCodeScope = /* @__PURE__ */ ((ReferralCodeScope2) => { - ReferralCodeScope2["SYSTEM"] = "system"; - ReferralCodeScope2["TEAM"] = "team"; - return ReferralCodeScope2; -})(ReferralCodeScope || {}); async function readPartnerDetail(http, partnerId) { return http.request(partnerPath(partnerId)); } @@ -1705,6 +2419,7 @@ var AnalyticsClient = class { async get(options = {}) { const query = new URLSearchParams(); if (options.bucket) query.set("bucket", options.bucket); + if (options.feature) query.set("feature", options.feature); const suffix = query.size ? `?${query.toString()}` : ""; return this.http.request( partnerPath(this.partnerId, `/analytics${suffix}`) @@ -1734,19 +2449,19 @@ var MembersClient = class { ); } async updateRoles(memberId, input) { - const normalizedMemberId = requiredId(memberId, "A Partner member ID"); + const normalizedMemberId = requiredId2(memberId, "A Partner member ID"); return this.http.request( partnerPath( this.partnerId, - `/members/${segment4(normalizedMemberId)}/roles` + `/members/${segment5(normalizedMemberId)}/roles` ), { method: "PATCH", body: JSON.stringify(input) } ); } async remove(memberId) { - const normalizedMemberId = requiredId(memberId, "A Partner member ID"); + const normalizedMemberId = requiredId2(memberId, "A Partner member ID"); return this.http.request( - partnerPath(this.partnerId, `/members/${segment4(normalizedMemberId)}`), + partnerPath(this.partnerId, `/members/${segment5(normalizedMemberId)}`), { method: "DELETE" } ); } @@ -1791,19 +2506,19 @@ var ApiKeysClient = class { ); } async updatePolicy(apiKeyId, policy) { - const normalizedApiKeyId = requiredId(apiKeyId, "A Partner API key ID"); + const normalizedApiKeyId = requiredId2(apiKeyId, "A Partner API key ID"); return this.http.request( partnerPath( this.partnerId, - `/api-keys/${segment4(normalizedApiKeyId)}/policy` + `/api-keys/${segment5(normalizedApiKeyId)}/policy` ), { method: "PATCH", body: JSON.stringify(policy) } ); } async revoke(apiKeyId) { - const normalizedApiKeyId = requiredId(apiKeyId, "A Partner API key ID"); + const normalizedApiKeyId = requiredId2(apiKeyId, "A Partner API key ID"); return this.http.request( - partnerPath(this.partnerId, `/api-keys/${segment4(normalizedApiKeyId)}`), + partnerPath(this.partnerId, `/api-keys/${segment5(normalizedApiKeyId)}`), { method: "DELETE" } ); } @@ -1818,17 +2533,48 @@ var ReferralsClient = class { partnerPath(this.partnerId, "/referral-code") ); } - async rotate() { + async list(options = {}) { + const query = options.includeRevoked ? "?includeRevoked=true" : ""; + return this.http.request( + partnerPath(this.partnerId, `/referral-codes${query}`) + ); + } + async create(input) { + return this.http.request( + partnerPath(this.partnerId, "/referral-codes"), + { method: "POST", body: JSON.stringify(input) } + ); + } + async revoke(referralCodeId) { + const normalizedId = requiredId2( + referralCodeId, + "A Partner referral code ID" + ); + await this.http.request( + partnerPath(this.partnerId, `/referral-codes/${segment5(normalizedId)}`), + { method: "DELETE" } + ); + } + async update(input) { + return this.http.request( + partnerPath(this.partnerId, "/referral-code"), + { method: "PATCH", body: JSON.stringify(input) } + ); + } + async rotate(input) { return this.http.request( partnerPath(this.partnerId, "/referral-code/rotate"), - { method: "POST" } + { + method: "POST", + ...input ? { body: JSON.stringify(input) } : {} + } ); } }; // packages/sdk/src/wallet.ts -var segment5 = (value) => encodeURIComponent(value); -var walletPath = (teamId, walletId) => walletId ? `/teams/${segment5(teamId)}/wallets/${segment5(walletId)}` : `/teams/${segment5(teamId)}/wallets`; +var segment6 = (value) => encodeURIComponent(value); +var walletPath = (teamId, walletId) => walletId ? `/teams/${segment6(teamId)}/wallets/${segment6(walletId)}` : `/teams/${segment6(teamId)}/wallets`; var WalletClient = class { constructor(http, events) { this.http = http; @@ -1870,6 +2616,12 @@ var WalletClient = class { `${walletPath(teamId, walletId)}/bitcoin/history` ); } + claimDeposit(teamId, walletId, txid, vout, input) { + return this.http.request( + `${walletPath(teamId, walletId)}/bitcoin/deposits/${segment6(txid)}/${vout}/claim`, + { method: "POST", body: JSON.stringify(input) } + ); + } receive(teamId, walletId, input) { return this.http.request( `${walletPath(teamId, walletId)}/bitcoin/receive`, @@ -1921,7 +2673,7 @@ var WalletClient = class { } payoutStatus(teamId, walletId, reference) { return this.http.request( - `${walletPath(teamId, walletId)}/bitcoin/payouts/${segment5(reference)}` + `${walletPath(teamId, walletId)}/bitcoin/payouts/${segment6(reference)}` ); } listConnections(teamId, walletId) { @@ -1940,7 +2692,7 @@ var WalletClient = class { } revokeConnection(teamId, walletId, connectionId) { return this.http.request( - `${walletPath(teamId, walletId)}/connections/${segment5(connectionId)}`, + `${walletPath(teamId, walletId)}/connections/${segment6(connectionId)}`, { method: "DELETE" } ); } @@ -1970,6 +2722,63 @@ var WalletClient = class { } }; +// packages/sdk/src/accounting.ts +var segment7 = (value) => encodeURIComponent(value); +function required(value, label) { + const normalized = value.trim(); + if (!normalized) throw new Error(`${label} is required`); + return normalized; +} +var AccountingClient = class { + constructor(http, partnerId) { + this.http = http; + this.partnerId = partnerId; + } + listSources(type) { + const query = type ? `?type=${segment7(type)}` : ""; + return this.http.request(`${this.path()}/sources${query}`); + } + listTemplates() { + return this.http.request(`${this.path()}/reporting-templates`); + } + createTemplate(input) { + return this.http.request(`${this.path()}/reporting-templates`, { + method: "POST", + body: JSON.stringify(input) + }); + } + async deleteTemplate(templateId) { + await this.http.request( + `${this.path()}/reporting-templates/${segment7(required(templateId, "Template ID"))}`, + { method: "DELETE" } + ); + } + async generateReport(input) { + const response = await this.http.requestResponse( + `${this.path()}/reports/generic-csv`, + { + method: "POST", + body: JSON.stringify(input), + headers: { Accept: "text/csv" } + } + ); + return { + stream: response.body, + contentType: response.headers.get("content-type") ?? "text/csv", + contentDisposition: requiredHeader(response, "content-disposition"), + certification: "uncertified" + }; + } + path() { + return `/teams/${segment7(required(this.partnerId ?? "", "Partner ID"))}/accounting`; + } +}; +function requiredHeader(response, name) { + const value = response.headers.get(name); + if (!value) throw new Error(`Accounting CSV response is missing ${name}`); + return value; +} + // packages/sdk/src/index.ts var MinmoClient = class { constructor(options, partnerId) { @@ -1985,7 +2794,9 @@ var MinmoClient = class { this.wallet = new WalletClient(this.http, this.events); this.otc = new OtcClient(this.http, this.events); this.integrations = { - pay: new PayClient(this.http, this.events, partnerId) + pay: new PayClient(this.http, this.events, partnerId), + psp: new PspClient(this.http, this.events, partnerId), + accounting: new AccountingClient(this.http, partnerId) }; } http; @@ -2028,6 +2839,11 @@ var PartnerClient = class extends MinmoClient { } }; export { + AccountPurpose, + AccountStatus, + AccountType, + AccountingExportFailureCode, + AccountingHealthStatus, AgentSelectionMode, AgentStatus, AgentTeamAssociationStatus, @@ -2036,14 +2852,19 @@ export { ApiKeyCapability, ApiKeyInvalidReason, ApiKeyResourceScope, + BalanceBasis, BitcoinNetwork, + BookEntityType, ConfirmationRole, Currency, DisputeResolution, EscrowEventType, EscrowNetwork, EventConnectionState, + ExecutionStatus, + ExportReportType, FxRateProvider, + JournalStatus, MemoryEventCursorStore, MinmoApiError, MinmoAuthenticationError, @@ -2051,6 +2872,7 @@ export { MinmoRateLimitError, MinmoSdkError, MinmoTransportError, + NormalBalance, OnchainConfirmationSpeed, OtcEventType, ParticipantRole, @@ -2063,12 +2885,39 @@ export { PaymentChannel, PayoutDestinationType, Permission, + PostingDirection, + PspAccountingTemplate, + PspCallbackMode, + PspCapability, + PspConnectionKind, + PspConnectionStatus, + PspDisbursementDestinationType, + PspEntityType, + PspEnvironment, + PspEventType, + PspPaymentMethod, + PspPaymentOperation, + PspProvider, + PspProviderBalanceStatus, + PspProviderSetupFieldType, + PspReconciliationExceptionCode, + PspReconciliationRecordKind, + PspReconciliationResolutionAction, + PspReconciliationStatus, + PspReconciliationType, + ReconciliationStatus, ReferralCodeScope, ResyncRequiredError, + SettlementStatus, + SourceType, SwapEscrowPaymentStatus, SwapState, SwapType, TeamRole, + TransactionDirection, + TransactionOperation, + ValuationBasis, + ValuationStatus, WalletConnectionScope, WalletEventType, WalletProvider diff --git a/vendor/upstream/sdk/accounting.d.ts b/vendor/upstream/sdk/accounting.d.ts new file mode 100644 index 0000000..678ad2f --- /dev/null +++ b/vendor/upstream/sdk/accounting.d.ts @@ -0,0 +1,21 @@ +import { type CreateAccountingReportRequest, type CreateReportingTemplateRequest, type ReportingTemplate, type SourceSummary, type SourceType } from "@minmo/core"; +import type { HttpClient } from "./http"; +export type AccountingCsvResponse = { + stream: ReadableStream | null; + contentType: string; + contentDisposition: string; + certification: "uncertified"; +}; +/** Partner-scoped lightweight reporting operations. */ +export declare class AccountingClient { + private readonly http; + private readonly partnerId?; + constructor(http: HttpClient, partnerId?: string | undefined); + listSources(type?: SourceType): Promise; + listTemplates(): Promise; + createTemplate(input: CreateReportingTemplateRequest): Promise; + deleteTemplate(templateId: string): Promise; + generateReport(input: CreateAccountingReportRequest): Promise; + private path; +} +//# sourceMappingURL=accounting.d.ts.map \ No newline at end of file diff --git a/vendor/upstream/sdk/auth.d.ts b/vendor/upstream/sdk/auth.d.ts index b07ce25..e57f776 100644 --- a/vendor/upstream/sdk/auth.d.ts +++ b/vendor/upstream/sdk/auth.d.ts @@ -1,5 +1,10 @@ export interface MinmoAuthProvider { + /** Return the current authentication headers for each request attempt. */ getHeaders(): Promise>; + /** + * Refresh or invalidate credentials after a 401 response. Concurrent calls + * are coalesced by HttpClient before one bounded request replay. + */ invalidate?(): Promise; } export declare const MinmoAuth: { diff --git a/vendor/upstream/sdk/disputes.d.ts b/vendor/upstream/sdk/disputes.d.ts index bc384d3..689f3be 100644 --- a/vendor/upstream/sdk/disputes.d.ts +++ b/vendor/upstream/sdk/disputes.d.ts @@ -52,8 +52,12 @@ export declare class EscrowDisputesClient { constructor(http: HttpClient); /** Lists all swaps currently requiring dispute arbitration. */ list(): Promise; + /** Lists disputes in one explicitly authorized Partner. */ + listForPartner(partnerId: string): Promise; /** Reads the authoritative swap resource containing the dispute. */ get(swapId: string): Promise; + /** Reads a dispute after enforcing access to its Partner scope. */ + getForPartner(partnerId: string, swapId: string): Promise; /** Opens a dispute as an authorized swap participant. */ open(swapId: string, input: OpenDisputeInput): Promise; /** Adds participant evidence while the dispute is collecting evidence. */ @@ -63,6 +67,8 @@ export declare class EscrowDisputesClient { * Swaps without an escrow record use the API's compatibility path. */ resolve(swapId: string, input: ResolveDisputeInput): Promise; + /** Records a dispute decision inside one explicitly authorized Partner. */ + resolveForPartner(partnerId: string, swapId: string, input: ResolveDisputeInput): Promise; /** Executes the payout required after a dispute enters refund state. */ executeRefund(swapId: string, input: ExecuteDisputeRefundInput): Promise; /** Lists dispute history for one agent. */ diff --git a/vendor/upstream/sdk/escrow.d.ts b/vendor/upstream/sdk/escrow.d.ts index d1399d2..794ad85 100644 --- a/vendor/upstream/sdk/escrow.d.ts +++ b/vendor/upstream/sdk/escrow.d.ts @@ -1,4 +1,4 @@ -import type { AuditEvent, CreateEscrowCommand, DescriptorPublishResult, DisputeResolutionCommand, EscrowDescriptorSettingsResponse, EscrowFeePolicy, EscrowPage, EscrowPayoutRecord, EscrowRecord, MoneyMovementCommand, ParticipantRole, UpdateEscrowDescriptorRequest, WalletPayoutDetails } from "@minmo/core"; +import type { AuditEvent, CreateEscrowCommand, DescriptorPublishResult, DisputeResolutionCommand, EscrowDescriptorSettingsResponse, EscrowActivityResponse, EscrowFeePolicy, EscrowPage, EscrowPayoutRecord, EscrowRecord, EscrowStatus, MoneyMovementCommand, ParticipantRole, UpdateEscrowDescriptorRequest, WalletPayoutDetails } from "@minmo/core"; import { EscrowEventType } from "@minmo/core"; import { EscrowDisputesClient } from "./disputes"; import { type DomainEventSubscriptionOptions, type EventSubscription, type EventsClient } from "./events"; @@ -10,6 +10,13 @@ export type CreateEscrowInput = Omit; list(teamId: string, query?: EscrowListQuery): Promise; + activity(teamId: string, query?: EscrowActivityQuery): Promise; get(teamId: string, reference: string): Promise; payoutStatus(teamId: string, reference: string): Promise; audit(teamId: string, reference: string): Promise; verifyFunding(teamId: string, reference: string): Promise; + expireUnfunded(teamId: string, reference: string): Promise; /** Test-only command; production deployments reject it. */ markMockFundingComplete(teamId: string, reference: string): Promise; release(teamId: string, reference: string, input: MoneyMovementCommand): Promise; diff --git a/vendor/upstream/sdk/http.d.ts b/vendor/upstream/sdk/http.d.ts index 19425a9..730a5b9 100644 --- a/vendor/upstream/sdk/http.d.ts +++ b/vendor/upstream/sdk/http.d.ts @@ -37,9 +37,16 @@ export declare class HttpClient { private readonly auth?; private readonly fetchFn; private readonly timeoutMs; + private authInvalidationPromise; constructor(options: HttpClientOptions); request(path: string, init?: RequestInit): Promise; + /** Returns an unconsumed successful response for streaming/binary callers. */ + requestResponse(path: string, init?: RequestInit): Promise; fetchResponse(path: string, init?: RequestInit): Promise; + private requestWithAuthRetry; + private responseWithAuthRetry; + private createResponseError; + private invalidateAuth; private parseBody; } //# sourceMappingURL=http.d.ts.map \ No newline at end of file diff --git a/vendor/upstream/sdk/index.d.ts b/vendor/upstream/sdk/index.d.ts index 270fd38..81aa046 100644 --- a/vendor/upstream/sdk/index.d.ts +++ b/vendor/upstream/sdk/index.d.ts @@ -7,9 +7,12 @@ import { HttpClient } from "./http"; import type { FetchLike } from "./http"; import { OtcClient } from "./otc"; import { PayClient } from "./pay"; +import { PspClient } from "./psp"; import { AccountClient, AnalyticsClient, ApiKeysClient, InvitationsClient, MembersClient, ReferralsClient, SettingsClient } from "./partner"; import { WalletClient } from "./wallet"; +import { AccountingClient } from "./accounting"; export * from "./auth"; +export * from "./accounting"; export * from "./events"; export * from "./escrow"; export * from "./disputes"; @@ -17,6 +20,7 @@ export * from "./http"; export * from "./otc"; export * from "./pay"; export * from "./partner"; +export * from "./psp"; export * from "./wallet"; export type MinmoClientOptions = { baseUrl: string; @@ -36,6 +40,8 @@ export declare class MinmoClient { readonly otc: OtcClient; readonly integrations: { readonly pay: PayClient; + readonly psp: PspClient; + readonly accounting: AccountingClient; }; constructor(options: MinmoClientOptions, partnerId?: string | undefined); /** diff --git a/vendor/upstream/sdk/otc/swap.d.ts b/vendor/upstream/sdk/otc/swap.d.ts index fb276aa..20b2cbc 100644 --- a/vendor/upstream/sdk/otc/swap.d.ts +++ b/vendor/upstream/sdk/otc/swap.d.ts @@ -1,4 +1,4 @@ -import type { AgentSelectionMode, ConfirmationRole, Currency, DisputeDetails, PaymentDetails, PaymentChannel, PaymentInstructions, SwapAgentTeamContext, SwapMetadata, SwapRepairAction, SwapState, SwapType, PartnerQuoteResponse } from "@minmo/core"; +import type { AgentSelectionMode, ConfirmationRole, Currency, DisputeDetails, PaymentDetails, PaymentChannel, PaymentInstructions, SwapAgentTeamContext, SwapMetadata, SwapRepairAction, SwapListSegment, SwapState, SwapType, PartnerQuoteResponse } from "@minmo/core"; import type { ExecuteDisputeRefundInput, OpenDisputeInput, ResolveDisputeInput, SubmitDisputeEvidenceInput } from "../disputes"; import type { SwapEscrowPaymentStatusResponse } from "../escrow"; import type { HttpClient } from "../http"; @@ -57,8 +57,11 @@ export type SwapFeeSnapshot = { escrowFeeBps: number; escrowFeeSats: string; payoutNetworkFeeSats: string; + receiverPayoutSats?: string; + principalSats?: string; receiverRole: ConfirmationRole; policyVersion: number; + estimated?: boolean; }; export type SwapAgentResource = { id: string; @@ -82,6 +85,7 @@ export type SwapResourceMetadata = SwapMetadata & Record & { export type SwapListQuery = { page?: number; limit?: number; + segment?: SwapListSegment; state?: SwapState; type?: SwapType; id?: string; @@ -124,10 +128,14 @@ export type SwapRepairInput = { export declare class SwapClient { private readonly http; constructor(http: HttpClient); + private listPath; create(input: CreateSwapInput): Promise; get(swapId: string): Promise; listDisputes(): Promise; list(query?: SwapListQuery): Promise; + listForPartner(partnerId: string, query?: SwapListQuery): Promise; + getForPartner(partnerId: string, swapId: string): Promise; + cancelForPartner(partnerId: string, swapId: string, input?: CancelSwapInput): Promise; claim(swapId: string, input?: SwapClaimInput): Promise; cancel(swapId: string, input?: CancelSwapInput): Promise; confirmPayment(swapId: string, input: ConfirmPaymentInput): Promise; diff --git a/vendor/upstream/sdk/partner.d.ts b/vendor/upstream/sdk/partner.d.ts index 642600e..80646aa 100644 --- a/vendor/upstream/sdk/partner.d.ts +++ b/vendor/upstream/sdk/partner.d.ts @@ -1,13 +1,10 @@ -import { type AnalyticsBucket, type AnalyticsDashboardResponse, type ApiKeyResourcePolicy, type PartnerCurrencySettings, type TeamRole } from "@minmo/core"; +import { type AnalyticsBucket, type AnalyticsResponse, type ApiKeyResourcePolicy, type ConsoleFeatureId, type PartnerCurrencySettings, ReferralCodeScope, type ReferralCodeUse, type TeamRole } from "@minmo/core"; import type { HttpClient } from "./http"; export declare enum ApiKeyInvalidReason { MANUALLY_REVOKED = "manually-revoked", EXPIRED = "expired" } -export declare enum ReferralCodeScope { - SYSTEM = "system", - TEAM = "team" -} +export { ReferralCodeScope } from "@minmo/core"; export interface NostrIdentity { publicKey: string | null; npub: string | null; @@ -80,12 +77,20 @@ export interface ReferralCode { code: string; scope: ReferralCodeScope; teamId: string | null; + allowedUses: ReferralCodeUse[]; isActive: boolean; usageCount: number; createdAt: string; } +export interface ConfigureReferralCodeInput { + allowedUses: ReferralCodeUse[]; +} +export interface ListReferralCodesOptions { + includeRevoked?: boolean; +} export interface AnalyticsOptions { bucket?: AnalyticsBucket; + feature?: ConsoleFeatureId; } interface PartnerDetailResponse { team: Account; @@ -122,7 +127,7 @@ export declare class AnalyticsClient { private readonly http; private readonly partnerId; constructor(http: HttpClient, partnerId: string); - get(options?: AnalyticsOptions): Promise; + get(options?: AnalyticsOptions): Promise; } export declare class MembersClient { private readonly http; @@ -157,7 +162,10 @@ export declare class ReferralsClient { private readonly partnerId; constructor(http: HttpClient, partnerId: string); get(): Promise; - rotate(): Promise; + list(options?: ListReferralCodesOptions): Promise; + create(input: ConfigureReferralCodeInput): Promise; + revoke(referralCodeId: string): Promise; + update(input: ConfigureReferralCodeInput): Promise; + rotate(input?: ConfigureReferralCodeInput): Promise; } -export {}; //# sourceMappingURL=partner.d.ts.map \ No newline at end of file diff --git a/vendor/upstream/sdk/psp.d.ts b/vendor/upstream/sdk/psp.d.ts new file mode 100644 index 0000000..fe1eac4 --- /dev/null +++ b/vendor/upstream/sdk/psp.d.ts @@ -0,0 +1,55 @@ +import { type CreatePspCollectionRequest, type CreatePspDisbursementRequest, type CreatePspConnectionRequest, type CreatePspReconciliationRequest, type CreateDelegatedPspConnectionRequest, type PspAccountResponse, type PspAccountStatementResponse, type PspConnectionResponse, PspEventType, type PspLiquidityListQuery, type PspLiquidityListResponse, type PspPageResponse, type PspPaymentListQuery, type PspPaymentResponse, type PspProvider, type PspProviderDefinition, type PspReconciliationItemResponse, type PspReconciliationListResponse, type PspReconciliationRunResponse, type ResolvePspReconciliationItemRequest, type RotatePspCredentialsRequest, type RevokePspConnectionRequest } from "@minmo/core"; +import { type DomainEventSubscriptionOptions, type EventSubscription, type EventsClient } from "./events"; +import type { HttpClient } from "./http"; +export type PspEventOptions = Omit, "partnerId"> & { + eventTypes?: readonly PspEventType[]; +}; +/** Partner-scoped payment-provider integration operations. */ +export declare class PspClient { + private readonly http; + private readonly eventsClient; + private readonly partnerId?; + constructor(http: HttpClient, eventsClient: EventsClient, partnerId?: string | undefined); + /** Subscribes to PSP lifecycle events in this Partner scope. */ + events(options: PspEventOptions): EventSubscription; + listProviders(): Promise; + getProvider(provider: PspProvider): Promise; + listConnections(): Promise; + getConnection(connectionId: string): Promise; + createConnection(input: CreatePspConnectionRequest): Promise; + activateConnection(connectionId: string): Promise; + rotateCredentials(connectionId: string, input: RotatePspCredentialsRequest): Promise; + createDelegation(ownerConnectionId: string, input: CreateDelegatedPspConnectionRequest): Promise; + revokeDelegation(connectionId: string, input: RevokePspConnectionRequest): Promise; + createCollection(connectionId: string, input: CreatePspCollectionRequest, idempotencyKey: string): Promise; + createDisbursement(connectionId: string, input: CreatePspDisbursementRequest, idempotencyKey: string): Promise; + getPayment(paymentId: string): Promise; + listPayments(input?: PspPaymentListQuery): Promise>; + listAccounts(input?: { + limit?: number; + offset?: number; + }): Promise>; + getAccount(accountId: string): Promise; + listLiquidity(input?: PspLiquidityListQuery): Promise; + getAccountStatement(accountId: string, input?: { + limit?: number; + offset?: number; + }): Promise; + createReconciliation(input: CreatePspReconciliationRequest): Promise; + listReconciliations(input?: { + limit?: number; + offset?: number; + }): Promise>; + getReconciliation(reconciliationId: string): Promise; + listReconciliationItems(reconciliationId: string, input?: { + limit?: number; + offset?: number; + }): Promise>; + listReconciliationExceptions(reconciliationId: string, input?: { + limit?: number; + offset?: number; + }): Promise>; + resolveReconciliationItem(reconciliationId: string, itemId: string, input: ResolvePspReconciliationItemRequest): Promise; + private path; +} +//# sourceMappingURL=psp.d.ts.map \ No newline at end of file diff --git a/vendor/upstream/sdk/wallet.d.ts b/vendor/upstream/sdk/wallet.d.ts index 787ae42..88e0438 100644 --- a/vendor/upstream/sdk/wallet.d.ts +++ b/vendor/upstream/sdk/wallet.d.ts @@ -1,7 +1,7 @@ -import { WalletEventType, type BitcoinNetwork, type EscrowNetwork, type OnchainConfirmationSpeed, type PayoutFeeQuote, type PayoutDestinationType, type PayoutResult, type StableBalanceConfig, type StableBalanceResult, type WalletOverview, type WalletPaymentHistoryItem, type WalletPayoutDetails, type WalletProvider, type WalletResponse, type WalletConnectionScope } from "@minmo/core"; +import { WalletEventType, type BitcoinNetwork, type EscrowNetwork, type OnchainConfirmationSpeed, type PayoutFeeQuote, type PayoutDestinationType, type PayoutResult, type StableBalanceConfig, type StableBalanceResult, type WalletOverview, type WalletDepositClaimInput, type WalletDepositClaimResult, type WalletPaymentHistoryItem, type WalletPayoutDetails, type WalletProvider, type WalletResponse, type WalletConnectionScope } from "@minmo/core"; import { type DomainEventSubscriptionOptions, type EventSubscription, type EventsClient } from "./events"; import type { HttpClient } from "./http"; -export type { PayoutFeeQuote, PayoutResult, StableBalanceConfig, StableBalanceOverview, StableBalanceResult, WalletOverview, WalletPaymentHistoryItem, WalletPayoutDetails, WalletResponse, } from "@minmo/core"; +export type { PayoutFeeQuote, PayoutResult, StableBalanceConfig, StableBalanceOverview, StableBalanceResult, WalletOverview, WalletDepositClaimInput, WalletDepositClaimResult, WalletUnclaimedDeposit, WalletPaymentHistoryItem, WalletPayoutDetails, WalletResponse, } from "@minmo/core"; export type WalletListResponse = { items: WalletResponse[]; }; @@ -103,6 +103,7 @@ export declare class WalletClient { delete(teamId: string, walletId: string): Promise; overview(teamId: string, walletId: string): Promise; history(teamId: string, walletId: string): Promise; + claimDeposit(teamId: string, walletId: string, txid: string, vout: number, input: WalletDepositClaimInput): Promise; receive(teamId: string, walletId: string, input: WalletReceiveInput): Promise; send(teamId: string, walletId: string, input: WalletSendInput): Promise; quotePayout(teamId: string, walletId: string, input: WalletPayoutQuoteInput): Promise;