Packages@robojs/mock
DIRECTORY
API reference for @robojs/mock
@robojs/mock
API reference documentation for @robojs/mock.
Classes
ActionRecorder- ActionRecorder manages recorded actions for a session with memory management.ApiKeyAuthProvider- API key-based auth provider stub.GatewayServer- Discord Gateway WebSocket server.InMemoryStorage- In-memory session storage implementation.MemoryAttachmentStorage- In-memory attachment storage implementation.MockServerState- Centralized state management for a mock session.NoOpAuthProvider- No-op auth provider that allows all requests.RecordingPlayer- RecordingPlayer - Replays recorded sessions with timing and validation.SessionManager- Manages session lifecycle and storage.Session- Represents an isolated test session with its own state.TestInteractions- Test helper for user interactions.TestUsers- Test helper for managing multiple users in a session.
Interfaces
AssertionResult- Result of a single assertion (for UI persistence).AttachmentPayload- Attachment metadata from payload_json (used during upload).AttachmentStorage- Abstract interface for attachment storage backends.AuthProvider- Authentication provider interface for hosted deployments.AuthResult- Result of authentication validation.AutocompleteInteractionPayloadOptions- Options for building an autocomplete INTERACTION_CREATE payload.BufferedStageEvent- Buffered event for reconnection replay.ButtonInteractionPayloadOptions- Options for building a button INTERACTION_CREATE payload.ConnectionState- WebSocket connection state.ContextMenuInteractionPayloadOptions- Options for building a context menu INTERACTION_CREATE payload.CreateSessionOptions- Options for creating a new session.CreateTestSessionConfig- Configuration for creating a test session.DispatchAutocompleteOptions- Options for dispatching an autocomplete interaction.DispatchButtonClickOptions- Options for dispatching a button click.DispatchContextMenuOptions- Options for dispatching a context menu interaction.DispatchEventData- Discord event data for dispatch.DispatchGuildMemberAddOptions- Options for dispatching guild member add event.DispatchGuildMemberRemoveOptions- Options for dispatching guild member remove event.DispatchGuildMemberUpdateOptions- Options for dispatching guild member update event.DispatchModalSubmitOptions- Options for dispatching a modal submit interaction.DispatchRoleCreateOptions- Options for dispatching role create event.DispatchRoleDeleteOptions- Options for dispatching role delete event.DispatchRoleUpdateOptions- Options for dispatching role update event.DispatchSelectMenuOptions- Options for dispatching a select menu interaction.DispatchSlashCommandOptions- Options for dispatching a slash command.DispatchThreadCreateOptions- Options for dispatching a thread create event.EnforcePermissionsOptions- Options for enforcing permissions on an endpoint.EnforcementContext- Extended context for enforcement checks.EnforcementOptions- Options for permission enforcement.ExpectActionOptions- Options for expectAction helper.GatewayPayload- Gateway payload structure.GuildMemberAddPayloadOptions- Options for building a GUILD_MEMBER_ADD payload.GuildMemberRemovePayloadOptions- Options for building a GUILD_MEMBER_REMOVE payload.GuildMemberUpdatePayloadOptions- Options for building a GUILD_MEMBER_UPDATE payload.GuildRoleCreatePayloadOptions- Options for building a GUILD_ROLE_CREATE payload.GuildRoleDeletePayloadOptions- Options for building a GUILD_ROLE_DELETE payload.GuildRoleUpdatePayloadOptions- Options for building a GUILD_ROLE_UPDATE payload.HelloPayloadData- HELLO payload data.ISession- Represents an isolated test session with its own state.IdentifyPayloadData- IDENTIFY payload data (op 2).InteractionCreatePayloadOptions- Options for building an INTERACTION_CREATE payload.InteractionData- Interaction dispatch data.MockAttachment- Attachment metadata as returned in API responses.MockChannelConfig- Configuration for creating a mock channel.MockChannelOverwrite- Channel permission overwrite.MockChannel- Mock channel data.MockConfig- Mock server configuration.MockDefaultReaction- Default reaction emoji for forum posts.MockForumChannelConfig- Configuration for creating a mock forum channel.MockForumChannel- Forum channel data (type 15) or Media channel data (type 16).MockForumPostConfig- Configuration for creating a forum post (thread with initial message).MockForumTag- Forum tag definition (available_tags on forum channels).MockForumThread- Forum thread (post) - extends thread with applied_tags.MockGuildConfig- Configuration for creating a mock guild.MockGuildMemberConfig- Configuration for creating/updating a guild member.MockGuildMember- Guild member data.MockGuild- Mock guild data.MockInteractionOption- Interaction option value.MockInteraction- Mock interaction data (slash commands, buttons, modals, etc.).MockMessageConfig- Configuration for creating a mock message.MockMessage- Mock message data.MockModeState- Global state for mock mode.MockPluginConfig- Configuration options for the @robojs/mock plugin.MockRoboHandle- Result of starting a mock Robo.MockRoleConfig- Configuration for creating a role.MockRoleTags- Role tags for special roles.MockRole- Full role object.MockThreadConfig- Configuration for creating a mock thread.MockThreadMember- Thread member representation.MockThreadMetadata- Thread metadata (nested in thread channel).MockThread- Thread channel data (extends MockChannel).MockUserConfig- Configuration for creating a mock user.MockUser- Mock user data.MockWebhookConfig- Configuration for creating a webhook.MockWebhook- Full webhook object.ModalSubmitInteractionPayloadOptions- Options for building a modal submit INTERACTION_CREATE payload.PermissionCheckResult- Result of a permission check.PermissionContext- Context for permission checking.PersistedSession- Persisted session data structure.RecordActionOptions- Options for recording an action.RecordedAction- Recorded action from bot (for test assertions).RecordingMetadata- Metadata for a session recording.ReplayOptions- Options for replaying a recorded session.ReplayResult- Result of a replay operation.ReplayState- Real-time playback state for UI binding.SeedMessageConfig- Configuration for seed messages.SelectMenuInteractionPayloadOptions- Options for building a select menu INTERACTION_CREATE payload.SerializedMockChannelSerializedMockForumChannel- Serialized forum/media channel.SerializedMockForumTag- Serialized forum tag.SerializedMockForumThread- Serialized forum thread/post.SerializedMockGuildMember- Serialized guild member for API responses.SerializedMockGuildSerializedMockInteractionSerializedMockMessageSerializedMockRole- Serialized role for API responses.SerializedMockThreadSerializedMockUserSerializedMockWebhook- Serialized webhook for API responses.SerializedSessionState- Serialized session state for API responses.SessionConfig- Configuration for session initial state.SessionManagerOptions- Options for SessionManager.SessionRecording- Complete session recording with metadata for replay.SessionResponse- Response from creating a session via Control API.SessionState- Isolated state for a session.SessionStorage- Storage interface for session persistence.SessionSummary- Summary statistics for a mock session.StageAddReactionData- Data for add_reaction command.StageBotDisconnectedData- Data payload for bot_disconnected events.StageBotErrorData- Data payload for bot_error events.StageBotReadyData- Data payload for bot_ready events.StageChannel- Simplified channel data for stage clients.StageClickButtonData- Data for click_button command.StageCommandResponseData- Data payload for command_response events.StageCommand- Command envelope sent from stage client to server.StageConnectionState- State for a connected stage client.StageEvent- Event envelope sent from server to stage client.StageGuild- Simplified guild data for stage clients.StageInteractionResponseData- Data payload for interaction_response events.StageInvokeCommandData- Data for invoke_command command.StageMember- Simplified member data for stage clients.StageMessageCreateData- Data payload for message_create events.StageMessage- Simplified message data for stage clients.StageRestCallData- Data payload for rest_call events.StageSelectOptionData- Data for select_option command.StageSendMessageData- Data for send_message command.StageServerConfig- Configuration for the Stage WebSocket server.StageStartTypingData- Data for start_typing command.StageSubmitModalData- Data for submit_modal command.StageSubscribeChannelData- Data for subscribe_channel command.StageUser- Simplified user data for stage clients.StartMockRoboOptions- Options for starting a mock Robo.StateOptions- Options for creating a MockServerState.StateSyncPayload- Full state sync payload sent on connection.StorageConfig- Configuration for creating storage backends.StorageStats- Storage statistics for monitoring and debugging.StoredAttachment- Attachment data stored in session state (includes binary data).TestFileEntry- Entry for a single test file.TestResult- Result for a single test case.TestSessionRegistry- Registry for a single test run.TestSession- Test session wrapper with convenience methods.TestUtils- Combined test utilities for a session.ThreadCreatePayloadOptions- Options for building a THREAD_CREATE payload.ThreadDeletePayloadOptions- Options for building a THREAD_DELETE payload.ThreadListSyncPayloadOptions- Options for building a THREAD_LIST_SYNC payload.ThreadMemberUpdatePayloadOptions- Options for building a THREAD_MEMBER_UPDATE payload.ThreadMembersUpdatePayloadOptions- Options for building a THREAD_MEMBERS_UPDATE payload.ThreadUpdatePayloadOptions- Options for building a THREAD_UPDATE payload.ValidationMismatch- Details of a single validation mismatch.ValidationResult- Results of validating bot responses during replay.WaitForActionOptions- Options for waiting for an action.WebhooksUpdatePayloadOptions- Options for building a WEBHOOKS_UPDATE payload.
Type Aliases
ActionType- Action type classification for recorded actions.PermissionEnforcementLevel- Permission enforcement level.StageCommandType- Command types sent from stage clients to server.StageEventType- Event types sent from server to stage clients.StageMessageSource- Message source indicator for stage events.ValidationMode- Validation mode for comparing bot responses during replay.
Enumerations
ForumLayoutType- Forum layout types.ForumSortOrderType- Forum sort order types.OverwriteType- Overwrite type enum.WebhookType- Webhook type enum.
Functions
BuildContextMenuInteractionPayload- Build an INTERACTION_CREATE payload for context menu commands (op 0, t: "INTERACTION_CREATE").ClearSessionActions- Clear recorded actions for a session.CloseGatewayServer- Close and reset the gateway server singleton.ComputePermissions- Compute permissions for a member in a specific channel.ConfigureMock- Configure the mock server URLs.ControlApi- Make a request to the control API.CreateAuthMiddleware- Create an authentication middleware for the control API.CreateDefaultGuildWithChannel- Create a default guild with a general channel and add it to the session state.CreateMockChannel- Create a mock channel from config.CreateMockForumChannel- Create a mock forum/media channel from config.CreateMockGuildMember- Create a mock guild member from config.CreateMockGuild- Create a mock guild from config.CreateMockMessage- Create a mock message from config.CreateMockRole- Create a mock role from config.CreateMockThread- Create a mock thread from config.CreateMockUser- Create a mock user from config.CreateSessionState- Create an empty session state.CreateSession- Create a new test session.CreateStorage- Factory function to create a storage backend from configuration.CreateTestSession- Create a test session with automatic registry tracking.CreateTestUtilsDeepEquals- Deep equality check for assertion comparison.DeleteSession- Delete a session.DispatchEvent- Dispatch a Discord event to a session.DispatchInteraction- Dispatch an interaction to a session.ExpectAction- Wait for an action and assert it matches expected data.ExpectNoAction- Assert that no action of a type was recorded.GenerateDiff- Generate a diff string for UI display.GenerateSnowflake- Generate a Discord-compatible snowflake ID.GetChannelMessages- Get messages from a channel.GetGatewayServer- Get or create the gateway server singleton.GetHistoricalActions- Get all historical actions from a session (including those from before test started).GetMockConfig- Get current mock configuration.GetMockModeSession- Gets the current mock mode session (if any).GetMockModeState- Gets the current mock mode state.GetMockRestApiUrl- Gets the REST API URL for the mock server.GetMockServerUrl- Gets the base URL for the mock server (without any path).GetPermissionNames- Get human-readable permission names from a bitfield.GetSessionActions- Get recorded actions for a session.GetSessionState- Get session state.GetStageUiUrl- Gets the Stage UI URL for a given session token.HasAllPermissions- Check if a permission bitfield has all of the specified permissions.HasAnyPermission- Check if a permission bitfield has any of the specified permissions.HasPermission- Check if a permission bitfield has a specific permission.MockRestApi- Make a request to the mock server REST API.RecordAssertion- Record an assertion for UI persistence.ResetMockConfig- Reset mock configuration to defaults.ResetSession- Reset a session to its initial state.SerializeMockChannel- Serialize a mock channel.SerializeMockGuild- Serialize a mock guild.SerializeMockInteraction- Serialize a mock interaction.SerializeMockMessage- Serialize a mock message.SerializeMockUser- Serialize a mock user.SerializeSessionState- Serialize session state for API responses.Sleep- Sleep for a number of milliseconds.SnowflakeToTimestamp- Extract timestamp from a snowflake ID.StartMockRobo- Start a Robo connected to the mock server.TimestampToSnowflake- Create a snowflake from a specific timestamp.WaitForAction- Wait for a specific action to be recorded.WaitForAnyAction- Wait for any action matching a filter.WaitForInteractionResponse- Wait for an interaction response.WaitForMessage- Wait for a message to be sent by the bot.WaitForMockServer- Wait for the mock server to be ready.
Variables
AttachmentFlags- Discord attachment flags (bitfield).AttachmentLimits- Validation constants for attachments.Default_heartbeat_interval- Default heartbeat interval in milliseconds (same as Discord).Default_mock_config- Default mock server configuration.Default_mock_plugin_config- Default plugin configuration values.DiscordErrorCodes- Discord error codes for permission-related issues.Gateway_version- Supported Gateway API version.MockLogger- Shared logger for @robojs/mock plugin.RoleLimits- Validation constants for roles.SessionManager- Convenience accessor for the session manager singleton.WebhookLimits- Validation constants for webhooks.
