export interface NexusExchangeSettings { guildId: string; channelId: string | null; title: string; description: string; colour: number; buttonLabel: string; managedResourceId: string | null; messageChannelId: string | null; messageId: string | null; postStatus: "unpublished" | "posted" | "missing"; messageVersion: number; inventoryVisibility: "private" | "public"; revision: number; updatedAt: Date | null; } export type NexusEconomyItemType = "role" | "collectible" | "custom_request"; export type NexusEconomyItemState = "draft" | "enabled" | "archived"; export type NexusEconomyLimitType = "none" | "lifetime" | "window"; export type NexusEconomyRoleRuleEffect = "allow" | "required" | "exclude"; export interface NexusEconomyRoleRule { effect: NexusEconomyRoleRuleEffect; roleId: string; position: number; } export interface NexusEconomyItemDraft { name: string; description: string; emoji: string | null; colour: number; itemType: NexusEconomyItemType; price: number; stockRemaining: number | null; limitType: NexusEconomyLimitType; limitValue: number | null; limitWindowSeconds: number | null; cooldownSeconds: number | null; roleId: string | null; collectibleMode: "unique" | "stackable" | null; customPrompt: string | null; customResponseRequired: boolean; availableFrom: Date | null; availableUntil: Date | null; position: number; roleRules: readonly NexusEconomyRoleRule[]; } export interface NexusEconomyManagedItem extends NexusEconomyItemDraft { itemId: string; guildId: string; state: NexusEconomyItemState; stockInitial: number | null; revision: number; updatedAt: Date; } export interface NexusEconomyManagedItemPage { items: readonly NexusEconomyManagedItem[]; total: number; } export interface NexusExchangeItemView { itemId: string; name: string; description: string; emoji: string | null; colour: number; itemType: NexusEconomyItemType; oneAtATime: boolean; price: string; stockRemaining: number | null; limitRemaining: number | null; limitWindowSeconds: number | null; customPrompt: string | null; customResponseRequired: boolean; availableUntil: Date | null; revision: number; } export interface NexusExchangeItemPage { items: readonly NexusExchangeItemView[]; total: number; offset: number; } export interface NexusInventoryEntry { itemId: string; itemName: string; itemType: "role" | "collectible"; quantity: number; acquiredAt: Date; } export interface NexusCustomRequestView { redemptionId: string; itemId: string; itemName: string; quantity: number; totalAmount: string; status: NexusRedemptionStatus; customResponse: string | null; requestedAt: Date; updatedAt: Date; revision: number; } export type NexusCustomRequestAction = "approve" | "deny" | "cancel" | "fulfil"; export interface NexusCustomRequestDecisionInput { guildId: string; redemptionId: string; expectedRevision: number; action: NexusCustomRequestAction; actor: "member" | "manager"; actorUserId: string; } export interface NexusCustomRequestDecisionResult { redemptionId: string; status: NexusRedemptionStatus; revision: number; refundTransactionId: string | null; replayed: boolean; } export interface NexusManagedRedemptionSummary { redemptionId: string; memberId: string | null; itemId: string; itemName: string; itemType: NexusEconomyItemType; quantity: number; totalAmount: string; status: NexusRedemptionStatus; reviewerUserId: string | null; decisionCode: string | null; fulfilmentCode: string | null; requestedAt: Date; updatedAt: Date; revision: number; } export interface NexusManagedRedemptionDetail extends NexusManagedRedemptionSummary { unitPrice: string; customResponse: string | null; chargeTransactionId: string; refundTransactionId: string | null; reviewedAt: Date | null; fulfilledAt: Date | null; cancelledAt: Date | null; refundedAt: Date | null; } export interface NexusManagedRedemptionPage { items: readonly NexusManagedRedemptionSummary[]; total: number; } export interface NexusManagedInventoryEntry { inventoryId: string; memberId: string | null; itemId: string; itemName: string; itemType: "role" | "collectible"; quantity: number; firstSourceRedemptionId: string; latestSourceRedemptionId: string; roleId: string | null; roleGrantState: "pending" | "granted" | "observed" | "failed" | "refunded" | null; roleGrantResultCode: string | null; acquiredAt: Date; latestAcquiredAt: Date; revision: number; } export interface NexusManagedInventoryPage { items: readonly NexusManagedInventoryEntry[]; total: number; } export type NexusRedemptionStatus = "accepted" | "fulfilling" | "pending_review" | "fulfilled" | "denied" | "cancelled" | "refund_pending" | "refunded" | "review"; export interface NexusRedeemInput { guildId: string; memberId: string; itemId: string; quantity: number; requestKey: string; memberRoleIds: readonly string[]; memberIsBot: boolean; customResponse?: string; expectedItemRevision?: number; } export interface NexusRedeemResult { redemptionId: string; itemId: string; itemName: string; itemType: NexusEconomyItemType; quantity: number; totalAmount: string; status: NexusRedemptionStatus; balance: string; replayed: boolean; } export type NexusFulfilmentWorkType = "role_grant" | "custom_notification" | "refund" | "post_refresh"; export interface NexusFulfilmentWork { workId: string; redemptionId: string | null; guildId: string; memberId: string | null; itemId: string | null; roleId: string | null; workType: NexusFulfilmentWorkType; attemptCount: number; leaseGeneration: number; } export interface NexusFulfilmentLeaseInput { workId: string; owner: string; leaseGeneration: number; } export interface NexusEconomyService { getSettings(guildId: string): Promise; getPublicItemCount(guildId: string): Promise; listAvailableItems(input: { guildId: string; memberId: string; memberRoleIds: readonly string[]; search?: string; limit: number; offset: number; }): Promise; getAvailableItem(input: { guildId: string; memberId: string; memberRoleIds: readonly string[]; itemId: string; }): Promise; listInventory(input: { guildId: string; memberId: string; limit: number; }): Promise; listRequests(input: { guildId: string; memberId: string; limit: number; }): Promise; decideCustomRequest(input: NexusCustomRequestDecisionInput): Promise; listManagedRedemptions(input: { guildId: string; search?: string; status?: NexusRedemptionStatus; limit: number; offset: number; }): Promise; getManagedRedemption(input: { guildId: string; redemptionId: string; }): Promise; listManagedInventory(input: { guildId: string; search?: string; itemType?: "role" | "collectible"; roleGrantState?: "pending" | "granted" | "observed" | "failed" | "refunded"; limit: number; offset: number; }): Promise; getManagedInventoryEntry(input: { guildId: string; inventoryId: string; }): Promise; listManagedItems(input: { guildId: string; search?: string; state?: NexusEconomyItemState; limit: number; offset: number; }): Promise; getManagedItem(input: { guildId: string; itemId: string; }): Promise; createManagedItem(input: { guildId: string; actorUserId: string; state: "draft" | "enabled"; draft: NexusEconomyItemDraft; }): Promise; updateManagedItem(input: { guildId: string; itemId: string; actorUserId: string; expectedRevision: number; draft: NexusEconomyItemDraft; }): Promise; setManagedItemState(input: { guildId: string; itemId: string; actorUserId: string; expectedRevision: number; state: NexusEconomyItemState; }): Promise; duplicateManagedItem(input: { guildId: string; itemId: string; actorUserId: string; expectedRevision: number; }): Promise; redeem(input: NexusRedeemInput): Promise; claimFulfilment(input: { owner: string; limit: number; leaseMs: number; }): Promise; completeRoleFulfilment(input: NexusFulfilmentLeaseInput & { outcome: "granted" | "observed"; }): Promise; completeFulfilment(input: NexusFulfilmentLeaseInput): Promise; retryFulfilment(input: NexusFulfilmentLeaseInput & { safeCode: string; delayMs: number; attemptLimit: number; }): Promise<{ requiresReview: boolean; }>; refundFulfilment(input: NexusFulfilmentLeaseInput & { safeCode: string; }): Promise<{ transactionId: string; replayed: boolean; }>; } export type NexusEconomyErrorCode = "invalid_input" | "module_disabled" | "item_unavailable" | "ineligible" | "insufficient_stock" | "limit_reached" | "cooldown_active" | "already_owned" | "insufficient_balance" | "operation_conflict" | "privacy_erased" | "data_invariant"; export declare class NexusEconomyError extends Error { readonly code: NexusEconomyErrorCode; constructor(code: NexusEconomyErrorCode, message: string); }