cerca 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.ignore +2 -0
- data/CHANGELOG.md +17 -0
- data/README.md +275 -0
- data/SECURITY.md +27 -0
- data/lib/cerca/client.rb +144 -0
- data/lib/cerca/errors.rb +228 -0
- data/lib/cerca/file_part.rb +58 -0
- data/lib/cerca/internal/agents_cursor_page.rb +92 -0
- data/lib/cerca/internal/approval_requests_cursor_page.rb +92 -0
- data/lib/cerca/internal/connections_cursor_page.rb +92 -0
- data/lib/cerca/internal/entries_cursor_page.rb +92 -0
- data/lib/cerca/internal/events_cursor_page.rb +92 -0
- data/lib/cerca/internal/fleets_cursor_page.rb +92 -0
- data/lib/cerca/internal/grants_cursor_page.rb +92 -0
- data/lib/cerca/internal/results_cursor_page.rb +92 -0
- data/lib/cerca/internal/sources_cursor_page.rb +92 -0
- data/lib/cerca/internal/stream.rb +55 -0
- data/lib/cerca/internal/subscriptions_cursor_page.rb +92 -0
- data/lib/cerca/internal/threads_cursor_page.rb +92 -0
- data/lib/cerca/internal/transport/base_client.rb +570 -0
- data/lib/cerca/internal/transport/pooled_net_requester.rb +210 -0
- data/lib/cerca/internal/type/array_of.rb +168 -0
- data/lib/cerca/internal/type/base_model.rb +530 -0
- data/lib/cerca/internal/type/base_page.rb +55 -0
- data/lib/cerca/internal/type/base_stream.rb +83 -0
- data/lib/cerca/internal/type/boolean.rb +77 -0
- data/lib/cerca/internal/type/converter.rb +327 -0
- data/lib/cerca/internal/type/enum.rb +152 -0
- data/lib/cerca/internal/type/file_input.rb +110 -0
- data/lib/cerca/internal/type/hash_of.rb +188 -0
- data/lib/cerca/internal/type/request_parameters.rb +42 -0
- data/lib/cerca/internal/type/union.rb +258 -0
- data/lib/cerca/internal/type/unknown.rb +81 -0
- data/lib/cerca/internal/util.rb +966 -0
- data/lib/cerca/internal.rb +20 -0
- data/lib/cerca/models/agent.rb +87 -0
- data/lib/cerca/models/agent_create_params.rb +47 -0
- data/lib/cerca/models/agent_delete_params.rb +20 -0
- data/lib/cerca/models/agent_delete_response.rb +16 -0
- data/lib/cerca/models/agent_list_params.rb +61 -0
- data/lib/cerca/models/agent_list_tools_params.rb +20 -0
- data/lib/cerca/models/agent_list_tools_response.rb +29 -0
- data/lib/cerca/models/agent_retrieve_config_params.rb +20 -0
- data/lib/cerca/models/agent_retrieve_params.rb +20 -0
- data/lib/cerca/models/agent_summary.rb +84 -0
- data/lib/cerca/models/agent_update_metadata_params.rb +33 -0
- data/lib/cerca/models/agent_update_params.rb +26 -0
- data/lib/cerca/models/api_key_tool_source_auth.rb +34 -0
- data/lib/cerca/models/approval_grant.rb +57 -0
- data/lib/cerca/models/approval_grant_delete_for_thread_params.rb +32 -0
- data/lib/cerca/models/approval_grant_delete_for_thread_response.rb +16 -0
- data/lib/cerca/models/approval_grant_delete_params.rb +26 -0
- data/lib/cerca/models/approval_grant_delete_response.rb +16 -0
- data/lib/cerca/models/approval_grant_list_for_thread_params.rb +26 -0
- data/lib/cerca/models/approval_grant_list_for_thread_response.rb +8 -0
- data/lib/cerca/models/approval_grant_list_params.rb +41 -0
- data/lib/cerca/models/approval_mode.rb +15 -0
- data/lib/cerca/models/approval_policy.rb +21 -0
- data/lib/cerca/models/approval_request.rb +133 -0
- data/lib/cerca/models/approval_request_list_params.rb +49 -0
- data/lib/cerca/models/approval_request_resolve_params.rb +65 -0
- data/lib/cerca/models/attached_connection.rb +22 -0
- data/lib/cerca/models/auth_context_params.rb +14 -0
- data/lib/cerca/models/auth_context_response.rb +22 -0
- data/lib/cerca/models/auth_fleets_response.rb +27 -0
- data/lib/cerca/models/auth_injection.rb +65 -0
- data/lib/cerca/models/auth_list_fleets_params.rb +34 -0
- data/lib/cerca/models/compiled_context.rb +30 -0
- data/lib/cerca/models/configuration.rb +41 -0
- data/lib/cerca/models/configuration_field_name.rb +17 -0
- data/lib/cerca/models/connection.rb +70 -0
- data/lib/cerca/models/connection_attach_params.rb +32 -0
- data/lib/cerca/models/connection_create_params.rb +50 -0
- data/lib/cerca/models/connection_delete_params.rb +48 -0
- data/lib/cerca/models/connection_delete_response.rb +16 -0
- data/lib/cerca/models/connection_detach_params.rb +26 -0
- data/lib/cerca/models/connection_detach_response.rb +16 -0
- data/lib/cerca/models/connection_list_for_agent_params.rb +20 -0
- data/lib/cerca/models/connection_list_for_agent_response.rb +28 -0
- data/lib/cerca/models/connection_list_params.rb +61 -0
- data/lib/cerca/models/connection_owner.rb +46 -0
- data/lib/cerca/models/content_block.rb +209 -0
- data/lib/cerca/models/context_delete_params.rb +29 -0
- data/lib/cerca/models/context_delete_response.rb +16 -0
- data/lib/cerca/models/context_list_params.rb +49 -0
- data/lib/cerca/models/context_retrieve_params.rb +29 -0
- data/lib/cerca/models/context_search_params.rb +57 -0
- data/lib/cerca/models/context_write_params.rb +44 -0
- data/lib/cerca/models/credential_provider.rb +20 -0
- data/lib/cerca/models/credential_type.rb +15 -0
- data/lib/cerca/models/discovered_tool.rb +119 -0
- data/lib/cerca/models/effective_configuration.rb +86 -0
- data/lib/cerca/models/entry.rb +40 -0
- data/lib/cerca/models/entry_summary.rb +40 -0
- data/lib/cerca/models/error_response.rb +23 -0
- data/lib/cerca/models/event_list_for_agent_params.rb +68 -0
- data/lib/cerca/models/event_list_for_fleet_params.rb +68 -0
- data/lib/cerca/models/event_list_for_thread_params.rb +75 -0
- data/lib/cerca/models/event_stream_for_agent_params.rb +64 -0
- data/lib/cerca/models/event_stream_for_fleet_params.rb +64 -0
- data/lib/cerca/models/event_stream_for_thread_events_params.rb +71 -0
- data/lib/cerca/models/event_stream_for_thread_params.rb +26 -0
- data/lib/cerca/models/exec_result.rb +63 -0
- data/lib/cerca/models/execution_principal.rb +56 -0
- data/lib/cerca/models/fleet.rb +39 -0
- data/lib/cerca/models/http_endpoint.rb +71 -0
- data/lib/cerca/models/http_tool_definition.rb +65 -0
- data/lib/cerca/models/http_tool_execution_policy.rb +47 -0
- data/lib/cerca/models/http_tool_source.rb +98 -0
- data/lib/cerca/models/json_object.rb +8 -0
- data/lib/cerca/models/mcp_tool_execution_policy.rb +47 -0
- data/lib/cerca/models/mcp_tool_source.rb +98 -0
- data/lib/cerca/models/message.rb +44 -0
- data/lib/cerca/models/metadata.rb +8 -0
- data/lib/cerca/models/model_descriptor.rb +64 -0
- data/lib/cerca/models/model_list_params.rb +14 -0
- data/lib/cerca/models/model_list_response.rb +16 -0
- data/lib/cerca/models/no_tool_source_auth.rb +15 -0
- data/lib/cerca/models/oauth_connect_params.rb +49 -0
- data/lib/cerca/models/oauth_connect_response.rb +41 -0
- data/lib/cerca/models/oauth_connection_tool_source_auth.rb +41 -0
- data/lib/cerca/models/oauth_exchange_config.rb +118 -0
- data/lib/cerca/models/oauth_exchange_tool_source_auth.rb +36 -0
- data/lib/cerca/models/read_response.rb +22 -0
- data/lib/cerca/models/response_normalization_hint.rb +30 -0
- data/lib/cerca/models/runtime_webhook_event.rb +1884 -0
- data/lib/cerca/models/sandbox_exec_params.rb +51 -0
- data/lib/cerca/models/sandbox_read_params.rb +38 -0
- data/lib/cerca/models/sandbox_write_params.rb +32 -0
- data/lib/cerca/models/sandbox_write_response.rb +16 -0
- data/lib/cerca/models/schedule.rb +105 -0
- data/lib/cerca/models/schedule_create_params.rb +82 -0
- data/lib/cerca/models/schedule_delete_params.rb +26 -0
- data/lib/cerca/models/schedule_delete_response.rb +16 -0
- data/lib/cerca/models/schedule_list_params.rb +20 -0
- data/lib/cerca/models/schedule_list_response.rb +16 -0
- data/lib/cerca/models/schedule_trigger_params.rb +26 -0
- data/lib/cerca/models/schedule_trigger_response.rb +16 -0
- data/lib/cerca/models/schedule_update_params.rb +96 -0
- data/lib/cerca/models/search_result.rb +52 -0
- data/lib/cerca/models/source_warning.rb +27 -0
- data/lib/cerca/models/status.rb +20 -0
- data/lib/cerca/models/steer_result.rb +47 -0
- data/lib/cerca/models/sub_thread_summary.rb +114 -0
- data/lib/cerca/models/subscription_event.rb +22 -0
- data/lib/cerca/models/thread.rb +202 -0
- data/lib/cerca/models/thread_cancel_params.rb +26 -0
- data/lib/cerca/models/thread_close_params.rb +26 -0
- data/lib/cerca/models/thread_compact_params.rb +26 -0
- data/lib/cerca/models/thread_create_params.rb +63 -0
- data/lib/cerca/models/thread_list_params.rb +57 -0
- data/lib/cerca/models/thread_retrieve_params.rb +66 -0
- data/lib/cerca/models/thread_start_turn_params.rb +55 -0
- data/lib/cerca/models/thread_steer_params.rb +32 -0
- data/lib/cerca/models/thread_stream_event.rb +888 -0
- data/lib/cerca/models/thread_summary.rb +92 -0
- data/lib/cerca/models/token_usage.rb +21 -0
- data/lib/cerca/models/tool.rb +22 -0
- data/lib/cerca/models/tool_approval_mode.rb +15 -0
- data/lib/cerca/models/tool_connection_metadata.rb +8 -0
- data/lib/cerca/models/tool_create_params.rb +157 -0
- data/lib/cerca/models/tool_delete_params.rb +26 -0
- data/lib/cerca/models/tool_descriptor.rb +78 -0
- data/lib/cerca/models/tool_list_params.rb +41 -0
- data/lib/cerca/models/tool_name.rb +50 -0
- data/lib/cerca/models/tool_retrieve_params.rb +26 -0
- data/lib/cerca/models/tool_source.rb +19 -0
- data/lib/cerca/models/tool_source_auth.rb +24 -0
- data/lib/cerca/models/tool_spec.rb +7 -0
- data/lib/cerca/models/tool_update_params.rb +163 -0
- data/lib/cerca/models/turn.rb +94 -0
- data/lib/cerca/models/webhook_create_params.rb +37 -0
- data/lib/cerca/models/webhook_delete_params.rb +26 -0
- data/lib/cerca/models/webhook_event_type.rb +33 -0
- data/lib/cerca/models/webhook_list_params.rb +41 -0
- data/lib/cerca/models/webhook_retrieve_params.rb +26 -0
- data/lib/cerca/models/webhook_rotate_params.rb +26 -0
- data/lib/cerca/models/webhook_subscription.rb +55 -0
- data/lib/cerca/models/webhook_subscription_created.rb +73 -0
- data/lib/cerca/models/webhook_subscription_event_type.rb +33 -0
- data/lib/cerca/models/webhook_test_params.rb +26 -0
- data/lib/cerca/models/webhook_test_response.rb +28 -0
- data/lib/cerca/models/webhook_update_params.rb +52 -0
- data/lib/cerca/models.rb +310 -0
- data/lib/cerca/request_options.rb +77 -0
- data/lib/cerca/resources/agents.rb +197 -0
- data/lib/cerca/resources/approval_grants.rb +106 -0
- data/lib/cerca/resources/approval_requests.rb +72 -0
- data/lib/cerca/resources/auth.rb +61 -0
- data/lib/cerca/resources/connections.rb +167 -0
- data/lib/cerca/resources/context.rb +157 -0
- data/lib/cerca/resources/events.rb +269 -0
- data/lib/cerca/resources/fleets.rb +14 -0
- data/lib/cerca/resources/models.rb +32 -0
- data/lib/cerca/resources/oauth.rb +45 -0
- data/lib/cerca/resources/sandbox.rb +91 -0
- data/lib/cerca/resources/schedules.rb +159 -0
- data/lib/cerca/resources/threads.rb +233 -0
- data/lib/cerca/resources/tools.rb +130 -0
- data/lib/cerca/resources/webhooks.rb +181 -0
- data/lib/cerca/version.rb +5 -0
- data/lib/cerca.rb +231 -0
- data/manifest.yaml +17 -0
- data/rbi/cerca/client.rbi +91 -0
- data/rbi/cerca/errors.rbi +205 -0
- data/rbi/cerca/file_part.rbi +37 -0
- data/rbi/cerca/internal/agents_cursor_page.rbi +25 -0
- data/rbi/cerca/internal/approval_requests_cursor_page.rbi +25 -0
- data/rbi/cerca/internal/connections_cursor_page.rbi +25 -0
- data/rbi/cerca/internal/entries_cursor_page.rbi +25 -0
- data/rbi/cerca/internal/events_cursor_page.rbi +25 -0
- data/rbi/cerca/internal/fleets_cursor_page.rbi +25 -0
- data/rbi/cerca/internal/grants_cursor_page.rbi +25 -0
- data/rbi/cerca/internal/results_cursor_page.rbi +25 -0
- data/rbi/cerca/internal/sources_cursor_page.rbi +25 -0
- data/rbi/cerca/internal/stream.rbi +18 -0
- data/rbi/cerca/internal/subscriptions_cursor_page.rbi +25 -0
- data/rbi/cerca/internal/threads_cursor_page.rbi +25 -0
- data/rbi/cerca/internal/transport/base_client.rbi +313 -0
- data/rbi/cerca/internal/transport/pooled_net_requester.rbi +82 -0
- data/rbi/cerca/internal/type/array_of.rbi +104 -0
- data/rbi/cerca/internal/type/base_model.rbi +299 -0
- data/rbi/cerca/internal/type/base_page.rbi +42 -0
- data/rbi/cerca/internal/type/base_stream.rbi +75 -0
- data/rbi/cerca/internal/type/boolean.rbi +58 -0
- data/rbi/cerca/internal/type/converter.rbi +204 -0
- data/rbi/cerca/internal/type/enum.rbi +82 -0
- data/rbi/cerca/internal/type/file_input.rbi +58 -0
- data/rbi/cerca/internal/type/hash_of.rbi +104 -0
- data/rbi/cerca/internal/type/request_parameters.rbi +29 -0
- data/rbi/cerca/internal/type/union.rbi +126 -0
- data/rbi/cerca/internal/type/unknown.rbi +58 -0
- data/rbi/cerca/internal/util.rbi +506 -0
- data/rbi/cerca/internal.rbi +16 -0
- data/rbi/cerca/models/agent.rbi +102 -0
- data/rbi/cerca/models/agent_create_params.rbi +75 -0
- data/rbi/cerca/models/agent_delete_params.rbi +35 -0
- data/rbi/cerca/models/agent_delete_response.rbi +23 -0
- data/rbi/cerca/models/agent_list_params.rbi +99 -0
- data/rbi/cerca/models/agent_list_tools_params.rbi +35 -0
- data/rbi/cerca/models/agent_list_tools_response.rbi +56 -0
- data/rbi/cerca/models/agent_retrieve_config_params.rbi +35 -0
- data/rbi/cerca/models/agent_retrieve_params.rbi +35 -0
- data/rbi/cerca/models/agent_summary.rbi +91 -0
- data/rbi/cerca/models/agent_update_metadata_params.rbi +51 -0
- data/rbi/cerca/models/agent_update_params.rbi +46 -0
- data/rbi/cerca/models/api_key_tool_source_auth.rbi +66 -0
- data/rbi/cerca/models/approval_grant.rbi +80 -0
- data/rbi/cerca/models/approval_grant_delete_for_thread_params.rbi +51 -0
- data/rbi/cerca/models/approval_grant_delete_for_thread_response.rbi +26 -0
- data/rbi/cerca/models/approval_grant_delete_params.rbi +43 -0
- data/rbi/cerca/models/approval_grant_delete_response.rbi +26 -0
- data/rbi/cerca/models/approval_grant_list_for_thread_params.rbi +46 -0
- data/rbi/cerca/models/approval_grant_list_for_thread_response.rbi +11 -0
- data/rbi/cerca/models/approval_grant_list_params.rbi +65 -0
- data/rbi/cerca/models/approval_mode.rbi +19 -0
- data/rbi/cerca/models/approval_policy.rbi +42 -0
- data/rbi/cerca/models/approval_request.rbi +152 -0
- data/rbi/cerca/models/approval_request_list_params.rbi +76 -0
- data/rbi/cerca/models/approval_request_resolve_params.rbi +137 -0
- data/rbi/cerca/models/attached_connection.rbi +37 -0
- data/rbi/cerca/models/auth_context_params.rbi +27 -0
- data/rbi/cerca/models/auth_context_response.rbi +26 -0
- data/rbi/cerca/models/auth_fleets_response.rbi +43 -0
- data/rbi/cerca/models/auth_injection.rbi +91 -0
- data/rbi/cerca/models/auth_list_fleets_params.rbi +59 -0
- data/rbi/cerca/models/compiled_context.rbi +41 -0
- data/rbi/cerca/models/configuration.rbi +67 -0
- data/rbi/cerca/models/configuration_field_name.rbi +26 -0
- data/rbi/cerca/models/connection.rbi +83 -0
- data/rbi/cerca/models/connection_attach_params.rbi +56 -0
- data/rbi/cerca/models/connection_create_params.rbi +87 -0
- data/rbi/cerca/models/connection_delete_params.rbi +87 -0
- data/rbi/cerca/models/connection_delete_response.rbi +26 -0
- data/rbi/cerca/models/connection_detach_params.rbi +43 -0
- data/rbi/cerca/models/connection_detach_response.rbi +26 -0
- data/rbi/cerca/models/connection_list_for_agent_params.rbi +35 -0
- data/rbi/cerca/models/connection_list_for_agent_response.rbi +46 -0
- data/rbi/cerca/models/connection_list_params.rbi +103 -0
- data/rbi/cerca/models/connection_owner.rbi +68 -0
- data/rbi/cerca/models/content_block.rbi +324 -0
- data/rbi/cerca/models/context_delete_params.rbi +49 -0
- data/rbi/cerca/models/context_delete_response.rbi +23 -0
- data/rbi/cerca/models/context_list_params.rbi +76 -0
- data/rbi/cerca/models/context_retrieve_params.rbi +49 -0
- data/rbi/cerca/models/context_search_params.rbi +84 -0
- data/rbi/cerca/models/context_write_params.rbi +71 -0
- data/rbi/cerca/models/credential_provider.rbi +26 -0
- data/rbi/cerca/models/credential_type.rbi +19 -0
- data/rbi/cerca/models/discovered_tool.rbi +156 -0
- data/rbi/cerca/models/effective_configuration.rbi +122 -0
- data/rbi/cerca/models/entry.rbi +53 -0
- data/rbi/cerca/models/entry_summary.rbi +54 -0
- data/rbi/cerca/models/error_response.rbi +32 -0
- data/rbi/cerca/models/event_list_for_agent_params.rbi +115 -0
- data/rbi/cerca/models/event_list_for_fleet_params.rbi +115 -0
- data/rbi/cerca/models/event_list_for_thread_params.rbi +121 -0
- data/rbi/cerca/models/event_stream_for_agent_params.rbi +115 -0
- data/rbi/cerca/models/event_stream_for_fleet_params.rbi +115 -0
- data/rbi/cerca/models/event_stream_for_thread_events_params.rbi +134 -0
- data/rbi/cerca/models/event_stream_for_thread_params.rbi +43 -0
- data/rbi/cerca/models/exec_result.rbi +85 -0
- data/rbi/cerca/models/execution_principal.rbi +82 -0
- data/rbi/cerca/models/fleet.rbi +50 -0
- data/rbi/cerca/models/http_endpoint.rbi +112 -0
- data/rbi/cerca/models/http_tool_definition.rbi +92 -0
- data/rbi/cerca/models/http_tool_execution_policy.rbi +106 -0
- data/rbi/cerca/models/http_tool_source.rbi +117 -0
- data/rbi/cerca/models/json_object.rbi +11 -0
- data/rbi/cerca/models/mcp_tool_execution_policy.rbi +106 -0
- data/rbi/cerca/models/mcp_tool_source.rbi +117 -0
- data/rbi/cerca/models/message.rbi +68 -0
- data/rbi/cerca/models/metadata.rbi +11 -0
- data/rbi/cerca/models/model_descriptor.rbi +92 -0
- data/rbi/cerca/models/model_list_params.rbi +25 -0
- data/rbi/cerca/models/model_list_response.rbi +27 -0
- data/rbi/cerca/models/no_tool_source_auth.rbi +23 -0
- data/rbi/cerca/models/oauth_connect_params.rbi +85 -0
- data/rbi/cerca/models/oauth_connect_response.rbi +67 -0
- data/rbi/cerca/models/oauth_connection_tool_source_auth.rbi +88 -0
- data/rbi/cerca/models/oauth_exchange_config.rbi +185 -0
- data/rbi/cerca/models/oauth_exchange_tool_source_auth.rbi +85 -0
- data/rbi/cerca/models/read_response.rbi +26 -0
- data/rbi/cerca/models/response_normalization_hint.rbi +57 -0
- data/rbi/cerca/models/runtime_webhook_event.rbi +3178 -0
- data/rbi/cerca/models/sandbox_exec_params.rbi +75 -0
- data/rbi/cerca/models/sandbox_read_params.rbi +65 -0
- data/rbi/cerca/models/sandbox_write_params.rbi +48 -0
- data/rbi/cerca/models/sandbox_write_response.rbi +23 -0
- data/rbi/cerca/models/schedule.rbi +123 -0
- data/rbi/cerca/models/schedule_create_params.rbi +111 -0
- data/rbi/cerca/models/schedule_delete_params.rbi +43 -0
- data/rbi/cerca/models/schedule_delete_response.rbi +23 -0
- data/rbi/cerca/models/schedule_list_params.rbi +35 -0
- data/rbi/cerca/models/schedule_list_response.rbi +27 -0
- data/rbi/cerca/models/schedule_trigger_params.rbi +43 -0
- data/rbi/cerca/models/schedule_trigger_response.rbi +26 -0
- data/rbi/cerca/models/schedule_update_params.rbi +132 -0
- data/rbi/cerca/models/search_result.rbi +72 -0
- data/rbi/cerca/models/source_warning.rbi +36 -0
- data/rbi/cerca/models/status.rbi +24 -0
- data/rbi/cerca/models/steer_result.rbi +69 -0
- data/rbi/cerca/models/sub_thread_summary.rbi +130 -0
- data/rbi/cerca/models/subscription_event.rbi +57 -0
- data/rbi/cerca/models/thread.rbi +218 -0
- data/rbi/cerca/models/thread_cancel_params.rbi +43 -0
- data/rbi/cerca/models/thread_close_params.rbi +43 -0
- data/rbi/cerca/models/thread_compact_params.rbi +43 -0
- data/rbi/cerca/models/thread_create_params.rbi +94 -0
- data/rbi/cerca/models/thread_list_params.rbi +87 -0
- data/rbi/cerca/models/thread_retrieve_params.rbi +130 -0
- data/rbi/cerca/models/thread_start_turn_params.rbi +77 -0
- data/rbi/cerca/models/thread_steer_params.rbi +48 -0
- data/rbi/cerca/models/thread_stream_event.rbi +1507 -0
- data/rbi/cerca/models/thread_summary.rbi +99 -0
- data/rbi/cerca/models/token_usage.rbi +28 -0
- data/rbi/cerca/models/tool.rbi +18 -0
- data/rbi/cerca/models/tool_approval_mode.rbi +19 -0
- data/rbi/cerca/models/tool_connection_metadata.rbi +11 -0
- data/rbi/cerca/models/tool_create_params.rbi +286 -0
- data/rbi/cerca/models/tool_delete_params.rbi +43 -0
- data/rbi/cerca/models/tool_descriptor.rbi +110 -0
- data/rbi/cerca/models/tool_list_params.rbi +63 -0
- data/rbi/cerca/models/tool_name.rbi +70 -0
- data/rbi/cerca/models/tool_retrieve_params.rbi +43 -0
- data/rbi/cerca/models/tool_source.rbi +16 -0
- data/rbi/cerca/models/tool_source_auth.rbi +25 -0
- data/rbi/cerca/models/tool_spec.rbi +7 -0
- data/rbi/cerca/models/tool_update_params.rbi +291 -0
- data/rbi/cerca/models/turn.rbi +116 -0
- data/rbi/cerca/models/webhook_create_params.rbi +68 -0
- data/rbi/cerca/models/webhook_delete_params.rbi +43 -0
- data/rbi/cerca/models/webhook_event_type.rbi +56 -0
- data/rbi/cerca/models/webhook_list_params.rbi +65 -0
- data/rbi/cerca/models/webhook_retrieve_params.rbi +43 -0
- data/rbi/cerca/models/webhook_rotate_params.rbi +43 -0
- data/rbi/cerca/models/webhook_subscription.rbi +73 -0
- data/rbi/cerca/models/webhook_subscription_created.rbi +83 -0
- data/rbi/cerca/models/webhook_subscription_event_type.rbi +115 -0
- data/rbi/cerca/models/webhook_test_params.rbi +43 -0
- data/rbi/cerca/models/webhook_test_response.rbi +43 -0
- data/rbi/cerca/models/webhook_update_params.rbi +88 -0
- data/rbi/cerca/models.rbi +277 -0
- data/rbi/cerca/request_options.rbi +55 -0
- data/rbi/cerca/resources/agents.rbi +125 -0
- data/rbi/cerca/resources/approval_grants.rbi +66 -0
- data/rbi/cerca/resources/approval_requests.rbi +58 -0
- data/rbi/cerca/resources/auth.rbi +39 -0
- data/rbi/cerca/resources/connections.rbi +116 -0
- data/rbi/cerca/resources/context.rbi +114 -0
- data/rbi/cerca/resources/events.rbi +188 -0
- data/rbi/cerca/resources/fleets.rbi +12 -0
- data/rbi/cerca/resources/models.rbi +21 -0
- data/rbi/cerca/resources/oauth.rbi +39 -0
- data/rbi/cerca/resources/sandbox.rbi +60 -0
- data/rbi/cerca/resources/schedules.rbi +110 -0
- data/rbi/cerca/resources/threads.rbi +160 -0
- data/rbi/cerca/resources/tools.rbi +87 -0
- data/rbi/cerca/resources/webhooks.rbi +121 -0
- data/rbi/cerca/version.rbi +5 -0
- data/sig/cerca/client.rbs +54 -0
- data/sig/cerca/errors.rbs +117 -0
- data/sig/cerca/file_part.rbs +21 -0
- data/sig/cerca/internal/agents_cursor_page.rbs +15 -0
- data/sig/cerca/internal/approval_requests_cursor_page.rbs +15 -0
- data/sig/cerca/internal/connections_cursor_page.rbs +15 -0
- data/sig/cerca/internal/entries_cursor_page.rbs +15 -0
- data/sig/cerca/internal/events_cursor_page.rbs +15 -0
- data/sig/cerca/internal/fleets_cursor_page.rbs +15 -0
- data/sig/cerca/internal/grants_cursor_page.rbs +15 -0
- data/sig/cerca/internal/results_cursor_page.rbs +15 -0
- data/sig/cerca/internal/sources_cursor_page.rbs +15 -0
- data/sig/cerca/internal/stream.rbs +9 -0
- data/sig/cerca/internal/subscriptions_cursor_page.rbs +15 -0
- data/sig/cerca/internal/threads_cursor_page.rbs +15 -0
- data/sig/cerca/internal/transport/base_client.rbs +133 -0
- data/sig/cerca/internal/transport/pooled_net_requester.rbs +48 -0
- data/sig/cerca/internal/type/array_of.rbs +48 -0
- data/sig/cerca/internal/type/base_model.rbs +102 -0
- data/sig/cerca/internal/type/base_page.rbs +24 -0
- data/sig/cerca/internal/type/base_stream.rbs +38 -0
- data/sig/cerca/internal/type/boolean.rbs +26 -0
- data/sig/cerca/internal/type/converter.rbs +79 -0
- data/sig/cerca/internal/type/enum.rbs +32 -0
- data/sig/cerca/internal/type/file_input.rbs +25 -0
- data/sig/cerca/internal/type/hash_of.rbs +48 -0
- data/sig/cerca/internal/type/request_parameters.rbs +17 -0
- data/sig/cerca/internal/type/union.rbs +52 -0
- data/sig/cerca/internal/type/unknown.rbs +26 -0
- data/sig/cerca/internal/util.rbs +199 -0
- data/sig/cerca/internal.rbs +9 -0
- data/sig/cerca/models/agent.rbs +69 -0
- data/sig/cerca/models/agent_create_params.rbs +49 -0
- data/sig/cerca/models/agent_delete_params.rbs +23 -0
- data/sig/cerca/models/agent_delete_response.rbs +13 -0
- data/sig/cerca/models/agent_list_params.rbs +62 -0
- data/sig/cerca/models/agent_list_tools_params.rbs +23 -0
- data/sig/cerca/models/agent_list_tools_response.rbs +29 -0
- data/sig/cerca/models/agent_retrieve_config_params.rbs +23 -0
- data/sig/cerca/models/agent_retrieve_params.rbs +23 -0
- data/sig/cerca/models/agent_summary.rbs +65 -0
- data/sig/cerca/models/agent_update_metadata_params.rbs +28 -0
- data/sig/cerca/models/agent_update_params.rbs +28 -0
- data/sig/cerca/models/api_key_tool_source_auth.rbs +30 -0
- data/sig/cerca/models/approval_grant.rbs +56 -0
- data/sig/cerca/models/approval_grant_delete_for_thread_params.rbs +32 -0
- data/sig/cerca/models/approval_grant_delete_for_thread_response.rbs +13 -0
- data/sig/cerca/models/approval_grant_delete_params.rbs +28 -0
- data/sig/cerca/models/approval_grant_delete_response.rbs +13 -0
- data/sig/cerca/models/approval_grant_list_for_thread_params.rbs +28 -0
- data/sig/cerca/models/approval_grant_list_for_thread_response.rbs +7 -0
- data/sig/cerca/models/approval_grant_list_params.rbs +36 -0
- data/sig/cerca/models/approval_mode.rbs +14 -0
- data/sig/cerca/models/approval_policy.rbs +28 -0
- data/sig/cerca/models/approval_request.rbs +108 -0
- data/sig/cerca/models/approval_request_list_params.rbs +42 -0
- data/sig/cerca/models/approval_request_resolve_params.rbs +73 -0
- data/sig/cerca/models/attached_connection.rbs +28 -0
- data/sig/cerca/models/auth_context_params.rbs +14 -0
- data/sig/cerca/models/auth_context_response.rbs +15 -0
- data/sig/cerca/models/auth_fleets_response.rbs +26 -0
- data/sig/cerca/models/auth_injection.rbs +46 -0
- data/sig/cerca/models/auth_list_fleets_params.rbs +32 -0
- data/sig/cerca/models/compiled_context.rbs +30 -0
- data/sig/cerca/models/configuration.rbs +43 -0
- data/sig/cerca/models/configuration_field_name.rbs +17 -0
- data/sig/cerca/models/connection.rbs +55 -0
- data/sig/cerca/models/connection_attach_params.rbs +40 -0
- data/sig/cerca/models/connection_create_params.rbs +43 -0
- data/sig/cerca/models/connection_delete_params.rbs +49 -0
- data/sig/cerca/models/connection_delete_response.rbs +13 -0
- data/sig/cerca/models/connection_detach_params.rbs +28 -0
- data/sig/cerca/models/connection_detach_response.rbs +13 -0
- data/sig/cerca/models/connection_list_for_agent_params.rbs +23 -0
- data/sig/cerca/models/connection_list_for_agent_response.rbs +30 -0
- data/sig/cerca/models/connection_list_params.rbs +58 -0
- data/sig/cerca/models/connection_owner.rbs +35 -0
- data/sig/cerca/models/content_block.rbs +200 -0
- data/sig/cerca/models/context_delete_params.rbs +28 -0
- data/sig/cerca/models/context_delete_response.rbs +13 -0
- data/sig/cerca/models/context_list_params.rbs +42 -0
- data/sig/cerca/models/context_retrieve_params.rbs +28 -0
- data/sig/cerca/models/context_search_params.rbs +52 -0
- data/sig/cerca/models/context_write_params.rbs +50 -0
- data/sig/cerca/models/credential_provider.rbs +20 -0
- data/sig/cerca/models/credential_type.rbs +14 -0
- data/sig/cerca/models/discovered_tool.rbs +109 -0
- data/sig/cerca/models/effective_configuration.rbs +74 -0
- data/sig/cerca/models/entry.rbs +42 -0
- data/sig/cerca/models/entry_summary.rbs +42 -0
- data/sig/cerca/models/error_response.rbs +17 -0
- data/sig/cerca/models/event_list_for_agent_params.rbs +67 -0
- data/sig/cerca/models/event_list_for_fleet_params.rbs +67 -0
- data/sig/cerca/models/event_list_for_thread_params.rbs +72 -0
- data/sig/cerca/models/event_stream_for_agent_params.rbs +67 -0
- data/sig/cerca/models/event_stream_for_fleet_params.rbs +67 -0
- data/sig/cerca/models/event_stream_for_thread_events_params.rbs +72 -0
- data/sig/cerca/models/event_stream_for_thread_params.rbs +28 -0
- data/sig/cerca/models/exec_result.rbs +61 -0
- data/sig/cerca/models/execution_principal.rbs +44 -0
- data/sig/cerca/models/fleet.rbs +40 -0
- data/sig/cerca/models/http_endpoint.rbs +79 -0
- data/sig/cerca/models/http_tool_definition.rbs +62 -0
- data/sig/cerca/models/http_tool_execution_policy.rbs +57 -0
- data/sig/cerca/models/http_tool_source.rbs +83 -0
- data/sig/cerca/models/json_object.rbs +7 -0
- data/sig/cerca/models/mcp_tool_execution_policy.rbs +57 -0
- data/sig/cerca/models/mcp_tool_source.rbs +83 -0
- data/sig/cerca/models/message.rbs +46 -0
- data/sig/cerca/models/metadata.rbs +7 -0
- data/sig/cerca/models/model_descriptor.rbs +63 -0
- data/sig/cerca/models/model_list_params.rbs +14 -0
- data/sig/cerca/models/model_list_response.rbs +13 -0
- data/sig/cerca/models/no_tool_source_auth.rbs +13 -0
- data/sig/cerca/models/oauth_connect_params.rbs +43 -0
- data/sig/cerca/models/oauth_connect_response.rbs +39 -0
- data/sig/cerca/models/oauth_connection_tool_source_auth.rbs +41 -0
- data/sig/cerca/models/oauth_exchange_config.rbs +124 -0
- data/sig/cerca/models/oauth_exchange_tool_source_auth.rbs +30 -0
- data/sig/cerca/models/read_response.rbs +15 -0
- data/sig/cerca/models/response_normalization_hint.rbs +29 -0
- data/sig/cerca/models/runtime_webhook_event.rbs +1803 -0
- data/sig/cerca/models/sandbox_exec_params.rbs +50 -0
- data/sig/cerca/models/sandbox_read_params.rbs +40 -0
- data/sig/cerca/models/sandbox_write_params.rbs +32 -0
- data/sig/cerca/models/sandbox_write_response.rbs +13 -0
- data/sig/cerca/models/schedule.rbs +90 -0
- data/sig/cerca/models/schedule_create_params.rbs +78 -0
- data/sig/cerca/models/schedule_delete_params.rbs +28 -0
- data/sig/cerca/models/schedule_delete_response.rbs +13 -0
- data/sig/cerca/models/schedule_list_params.rbs +23 -0
- data/sig/cerca/models/schedule_list_response.rbs +13 -0
- data/sig/cerca/models/schedule_trigger_params.rbs +28 -0
- data/sig/cerca/models/schedule_trigger_response.rbs +13 -0
- data/sig/cerca/models/schedule_update_params.rbs +94 -0
- data/sig/cerca/models/search_result.rbs +52 -0
- data/sig/cerca/models/source_warning.rbs +23 -0
- data/sig/cerca/models/status.rbs +16 -0
- data/sig/cerca/models/steer_result.rbs +41 -0
- data/sig/cerca/models/sub_thread_summary.rbs +89 -0
- data/sig/cerca/models/subscription_event.rbs +22 -0
- data/sig/cerca/models/thread.rbs +150 -0
- data/sig/cerca/models/thread_cancel_params.rbs +28 -0
- data/sig/cerca/models/thread_close_params.rbs +28 -0
- data/sig/cerca/models/thread_compact_params.rbs +28 -0
- data/sig/cerca/models/thread_create_params.rbs +61 -0
- data/sig/cerca/models/thread_list_params.rbs +54 -0
- data/sig/cerca/models/thread_retrieve_params.rbs +71 -0
- data/sig/cerca/models/thread_start_turn_params.rbs +50 -0
- data/sig/cerca/models/thread_steer_params.rbs +32 -0
- data/sig/cerca/models/thread_stream_event.rbs +855 -0
- data/sig/cerca/models/thread_summary.rbs +70 -0
- data/sig/cerca/models/token_usage.rbs +15 -0
- data/sig/cerca/models/tool.rbs +11 -0
- data/sig/cerca/models/tool_approval_mode.rbs +14 -0
- data/sig/cerca/models/tool_connection_metadata.rbs +7 -0
- data/sig/cerca/models/tool_create_params.rbs +152 -0
- data/sig/cerca/models/tool_delete_params.rbs +28 -0
- data/sig/cerca/models/tool_descriptor.rbs +68 -0
- data/sig/cerca/models/tool_list_params.rbs +36 -0
- data/sig/cerca/models/tool_name.rbs +86 -0
- data/sig/cerca/models/tool_retrieve_params.rbs +28 -0
- data/sig/cerca/models/tool_source.rbs +11 -0
- data/sig/cerca/models/tool_source_auth.rbs +15 -0
- data/sig/cerca/models/tool_spec.rbs +5 -0
- data/sig/cerca/models/tool_update_params.rbs +160 -0
- data/sig/cerca/models/turn.rbs +87 -0
- data/sig/cerca/models/webhook_create_params.rbs +40 -0
- data/sig/cerca/models/webhook_delete_params.rbs +28 -0
- data/sig/cerca/models/webhook_event_type.rbs +52 -0
- data/sig/cerca/models/webhook_list_params.rbs +36 -0
- data/sig/cerca/models/webhook_retrieve_params.rbs +28 -0
- data/sig/cerca/models/webhook_rotate_params.rbs +28 -0
- data/sig/cerca/models/webhook_subscription.rbs +50 -0
- data/sig/cerca/models/webhook_subscription_created.rbs +55 -0
- data/sig/cerca/models/webhook_subscription_event_type.rbs +50 -0
- data/sig/cerca/models/webhook_test_params.rbs +28 -0
- data/sig/cerca/models/webhook_test_response.rbs +22 -0
- data/sig/cerca/models/webhook_update_params.rbs +54 -0
- data/sig/cerca/models.rbs +267 -0
- data/sig/cerca/request_options.rbs +34 -0
- data/sig/cerca/resources/agents.rbs +55 -0
- data/sig/cerca/resources/approval_grants.rbs +33 -0
- data/sig/cerca/resources/approval_requests.rbs +24 -0
- data/sig/cerca/resources/auth.rbs +17 -0
- data/sig/cerca/resources/connections.rbs +48 -0
- data/sig/cerca/resources/context.rbs +45 -0
- data/sig/cerca/resources/events.rbs +69 -0
- data/sig/cerca/resources/fleets.rbs +7 -0
- data/sig/cerca/resources/models.rbs +11 -0
- data/sig/cerca/resources/oauth.rbs +15 -0
- data/sig/cerca/resources/sandbox.rbs +31 -0
- data/sig/cerca/resources/schedules.rbs +52 -0
- data/sig/cerca/resources/threads.rbs +68 -0
- data/sig/cerca/resources/tools.rbs +39 -0
- data/sig/cerca/resources/webhooks.rbs +54 -0
- data/sig/cerca/version.rbs +3 -0
- metadata +666 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Cerca
|
|
4
|
+
module Internal
|
|
5
|
+
module Type
|
|
6
|
+
# @api private
|
|
7
|
+
#
|
|
8
|
+
# @abstract
|
|
9
|
+
#
|
|
10
|
+
# @generic Elem
|
|
11
|
+
#
|
|
12
|
+
# Hash of items of a given type.
|
|
13
|
+
class HashOf
|
|
14
|
+
include Cerca::Internal::Type::Converter
|
|
15
|
+
include Cerca::Internal::Util::SorbetRuntimeSupport
|
|
16
|
+
|
|
17
|
+
private_class_method :new
|
|
18
|
+
|
|
19
|
+
# @overload [](type_info, spec = {})
|
|
20
|
+
#
|
|
21
|
+
# @param type_info [Hash{Symbol=>Object}, Proc, Cerca::Internal::Type::Converter, Class]
|
|
22
|
+
#
|
|
23
|
+
# @param spec [Hash{Symbol=>Object}] .
|
|
24
|
+
#
|
|
25
|
+
# @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
|
|
26
|
+
#
|
|
27
|
+
# @option spec [Proc] :enum
|
|
28
|
+
#
|
|
29
|
+
# @option spec [Proc] :union
|
|
30
|
+
#
|
|
31
|
+
# @option spec [Boolean] :"nil?"
|
|
32
|
+
#
|
|
33
|
+
# @return [self]
|
|
34
|
+
def self.[](...) = new(...)
|
|
35
|
+
|
|
36
|
+
# @api public
|
|
37
|
+
#
|
|
38
|
+
# @param other [Object]
|
|
39
|
+
#
|
|
40
|
+
# @return [Boolean]
|
|
41
|
+
def ===(other)
|
|
42
|
+
type = item_type
|
|
43
|
+
case other
|
|
44
|
+
in Hash
|
|
45
|
+
other.all? do |key, val|
|
|
46
|
+
case [key, val]
|
|
47
|
+
in [Symbol | String, ^type]
|
|
48
|
+
true
|
|
49
|
+
else
|
|
50
|
+
false
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
else
|
|
54
|
+
false
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# @api public
|
|
59
|
+
#
|
|
60
|
+
# @param other [Object]
|
|
61
|
+
#
|
|
62
|
+
# @return [Boolean]
|
|
63
|
+
def ==(other)
|
|
64
|
+
# rubocop:disable Layout/LineLength
|
|
65
|
+
other.is_a?(Cerca::Internal::Type::HashOf) && other.nilable? == nilable? && other.item_type == item_type
|
|
66
|
+
# rubocop:enable Layout/LineLength
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# @api public
|
|
70
|
+
#
|
|
71
|
+
# @return [Integer]
|
|
72
|
+
def hash = [self.class, item_type].hash
|
|
73
|
+
|
|
74
|
+
# @api private
|
|
75
|
+
#
|
|
76
|
+
# @param value [Hash{Object=>Object}, Object]
|
|
77
|
+
#
|
|
78
|
+
# @param state [Hash{Symbol=>Object}] .
|
|
79
|
+
#
|
|
80
|
+
# @option state [Boolean] :translate_names
|
|
81
|
+
#
|
|
82
|
+
# @option state [Boolean] :strictness
|
|
83
|
+
#
|
|
84
|
+
# @option state [Hash{Symbol=>Object}] :exactness
|
|
85
|
+
#
|
|
86
|
+
# @option state [Class<StandardError>] :error
|
|
87
|
+
#
|
|
88
|
+
# @option state [Integer] :branched
|
|
89
|
+
#
|
|
90
|
+
# @return [Hash{Symbol=>Object}, Object]
|
|
91
|
+
def coerce(value, state:)
|
|
92
|
+
exactness = state.fetch(:exactness)
|
|
93
|
+
|
|
94
|
+
unless value.is_a?(Hash)
|
|
95
|
+
exactness[:no] += 1
|
|
96
|
+
state[:error] = TypeError.new("#{value.class} can't be coerced into #{Hash}")
|
|
97
|
+
return value
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
target = item_type
|
|
101
|
+
exactness[:yes] += 1
|
|
102
|
+
value
|
|
103
|
+
.to_h do |key, val|
|
|
104
|
+
k = key.is_a?(String) ? key.to_sym : key
|
|
105
|
+
v =
|
|
106
|
+
case [nilable?, val]
|
|
107
|
+
in [true, nil]
|
|
108
|
+
exactness[:yes] += 1
|
|
109
|
+
nil
|
|
110
|
+
else
|
|
111
|
+
Cerca::Internal::Type::Converter.coerce(target, val, state: state)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
exactness[:no] += 1 unless k.is_a?(Symbol)
|
|
115
|
+
[k, v]
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# @api private
|
|
120
|
+
#
|
|
121
|
+
# @param value [Hash{Object=>Object}, Object]
|
|
122
|
+
#
|
|
123
|
+
# @param state [Hash{Symbol=>Object}] .
|
|
124
|
+
#
|
|
125
|
+
# @option state [Boolean] :can_retry
|
|
126
|
+
#
|
|
127
|
+
# @return [Hash{Symbol=>Object}, Object]
|
|
128
|
+
def dump(value, state:)
|
|
129
|
+
target = item_type
|
|
130
|
+
if value.is_a?(Hash)
|
|
131
|
+
value.transform_values do
|
|
132
|
+
Cerca::Internal::Type::Converter.dump(target, _1, state: state)
|
|
133
|
+
end
|
|
134
|
+
else
|
|
135
|
+
super
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# @api private
|
|
140
|
+
#
|
|
141
|
+
# @return [Object]
|
|
142
|
+
def to_sorbet_type
|
|
143
|
+
T::Hash[Cerca::Internal::Util::SorbetRuntimeSupport.to_sorbet_type(item_type)]
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# @api private
|
|
147
|
+
#
|
|
148
|
+
# @return [generic<Elem>]
|
|
149
|
+
protected def item_type = @item_type_fn.call
|
|
150
|
+
|
|
151
|
+
# @api private
|
|
152
|
+
#
|
|
153
|
+
# @return [Boolean]
|
|
154
|
+
protected def nilable? = @nilable
|
|
155
|
+
|
|
156
|
+
# @api private
|
|
157
|
+
#
|
|
158
|
+
# @param type_info [Hash{Symbol=>Object}, Proc, Cerca::Internal::Type::Converter, Class]
|
|
159
|
+
#
|
|
160
|
+
# @param spec [Hash{Symbol=>Object}] .
|
|
161
|
+
#
|
|
162
|
+
# @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
|
|
163
|
+
#
|
|
164
|
+
# @option spec [Proc] :enum
|
|
165
|
+
#
|
|
166
|
+
# @option spec [Proc] :union
|
|
167
|
+
#
|
|
168
|
+
# @option spec [Boolean] :"nil?"
|
|
169
|
+
def initialize(type_info, spec = {})
|
|
170
|
+
@item_type_fn = Cerca::Internal::Type::Converter.type_info(type_info || spec)
|
|
171
|
+
@meta = Cerca::Internal::Type::Converter.meta_info(type_info, spec)
|
|
172
|
+
@nilable = spec.fetch(:nil?, false)
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
# @api private
|
|
176
|
+
#
|
|
177
|
+
# @param depth [Integer]
|
|
178
|
+
#
|
|
179
|
+
# @return [String]
|
|
180
|
+
def inspect(depth: 0)
|
|
181
|
+
items = Cerca::Internal::Type::Converter.inspect(item_type, depth: depth.succ)
|
|
182
|
+
|
|
183
|
+
"#{self.class}[#{[items, nilable? ? 'nil' : nil].compact.join(' | ')}]"
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Cerca
|
|
4
|
+
module Internal
|
|
5
|
+
module Type
|
|
6
|
+
# @api private
|
|
7
|
+
module RequestParameters
|
|
8
|
+
# @!attribute request_options
|
|
9
|
+
# Options to specify HTTP behaviour for this request.
|
|
10
|
+
#
|
|
11
|
+
# @return [Cerca::RequestOptions, Hash{Symbol=>Object}]
|
|
12
|
+
|
|
13
|
+
# @param mod [Module]
|
|
14
|
+
def self.included(mod)
|
|
15
|
+
raise ArgumentError.new(mod) unless mod <= Cerca::Internal::Type::BaseModel
|
|
16
|
+
|
|
17
|
+
mod.optional(:request_options, Cerca::RequestOptions)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# @api private
|
|
21
|
+
module Converter
|
|
22
|
+
# @api private
|
|
23
|
+
#
|
|
24
|
+
# @param params [Object]
|
|
25
|
+
#
|
|
26
|
+
# @return [Array(Object, Hash{Symbol=>Object})]
|
|
27
|
+
def dump_request(params)
|
|
28
|
+
state = {can_retry: true}
|
|
29
|
+
case (dumped = dump(params, state: state))
|
|
30
|
+
in Hash
|
|
31
|
+
options = Cerca::Internal::Util.coerce_hash!(dumped[:request_options]).to_h
|
|
32
|
+
request_options = state.fetch(:can_retry) ? options : {**options, max_retries: 0}
|
|
33
|
+
[dumped.except(:request_options), request_options]
|
|
34
|
+
else
|
|
35
|
+
[dumped, nil]
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Cerca
|
|
4
|
+
module Internal
|
|
5
|
+
module Type
|
|
6
|
+
# @api private
|
|
7
|
+
#
|
|
8
|
+
# @example
|
|
9
|
+
# # `connection_owner` is a `Cerca::ConnectionOwner`
|
|
10
|
+
# case connection_owner
|
|
11
|
+
# when Cerca::ConnectionOwner::OrganizationConnectionOwner
|
|
12
|
+
# puts(connection_owner.type)
|
|
13
|
+
# when Cerca::ConnectionOwner::FleetConnectionOwner
|
|
14
|
+
# puts(connection_owner.fleet_id)
|
|
15
|
+
# else
|
|
16
|
+
# puts(connection_owner)
|
|
17
|
+
# end
|
|
18
|
+
#
|
|
19
|
+
# @example
|
|
20
|
+
# case connection_owner
|
|
21
|
+
# in {type: :organization}
|
|
22
|
+
# # ...
|
|
23
|
+
# in {type: :fleet, fleet_id: fleet_id}
|
|
24
|
+
# puts(fleet_id)
|
|
25
|
+
# else
|
|
26
|
+
# puts(connection_owner)
|
|
27
|
+
# end
|
|
28
|
+
module Union
|
|
29
|
+
include Cerca::Internal::Type::Converter
|
|
30
|
+
include Cerca::Internal::Util::SorbetRuntimeSupport
|
|
31
|
+
|
|
32
|
+
# @api private
|
|
33
|
+
#
|
|
34
|
+
# All of the specified variant info for this union.
|
|
35
|
+
#
|
|
36
|
+
# @return [Array<Array(Symbol, Proc, Hash{Symbol=>Object})>]
|
|
37
|
+
private def known_variants = (@known_variants ||= [])
|
|
38
|
+
|
|
39
|
+
# @api private
|
|
40
|
+
#
|
|
41
|
+
# @return [Array<Array(Symbol, Object, Hash{Symbol=>Object})>]
|
|
42
|
+
protected def derefed_variants
|
|
43
|
+
known_variants.map { |key, variant_fn, meta| [key, variant_fn.call, meta] }
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# All of the specified variants for this union.
|
|
47
|
+
#
|
|
48
|
+
# @return [Array<Object>]
|
|
49
|
+
def variants = derefed_variants.map { _2 }
|
|
50
|
+
|
|
51
|
+
# @api private
|
|
52
|
+
#
|
|
53
|
+
# @param property [Symbol]
|
|
54
|
+
private def discriminator(property)
|
|
55
|
+
case property
|
|
56
|
+
in Symbol
|
|
57
|
+
@discriminator = property
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# @api private
|
|
62
|
+
#
|
|
63
|
+
# @param key [Symbol, Hash{Symbol=>Object}, Proc, Cerca::Internal::Type::Converter, Class]
|
|
64
|
+
#
|
|
65
|
+
# @param spec [Hash{Symbol=>Object}, Proc, Cerca::Internal::Type::Converter, Class] .
|
|
66
|
+
#
|
|
67
|
+
# @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
|
|
68
|
+
#
|
|
69
|
+
# @option spec [Proc] :enum
|
|
70
|
+
#
|
|
71
|
+
# @option spec [Proc] :union
|
|
72
|
+
#
|
|
73
|
+
# @option spec [Boolean] :"nil?"
|
|
74
|
+
private def variant(key, spec = nil)
|
|
75
|
+
meta = Cerca::Internal::Type::Converter.meta_info(nil, spec)
|
|
76
|
+
variant_info =
|
|
77
|
+
case key
|
|
78
|
+
in Symbol
|
|
79
|
+
[key, Cerca::Internal::Type::Converter.type_info(spec), meta]
|
|
80
|
+
in Proc | Cerca::Internal::Type::Converter | Class | Hash
|
|
81
|
+
[nil, Cerca::Internal::Type::Converter.type_info(key), meta]
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
known_variants << variant_info
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# @api private
|
|
88
|
+
#
|
|
89
|
+
# @param value [Object]
|
|
90
|
+
#
|
|
91
|
+
# @return [Cerca::Internal::Type::Converter, Class, nil]
|
|
92
|
+
private def resolve_variant(value)
|
|
93
|
+
case [@discriminator, value]
|
|
94
|
+
in [_, Cerca::Internal::Type::BaseModel]
|
|
95
|
+
value.class
|
|
96
|
+
in [Symbol, Hash]
|
|
97
|
+
key = value.fetch(@discriminator) do
|
|
98
|
+
value.fetch(@discriminator.to_s, Cerca::Internal::OMIT)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
return nil if key == Cerca::Internal::OMIT
|
|
102
|
+
|
|
103
|
+
key = key.to_sym if key.is_a?(String)
|
|
104
|
+
_, found = known_variants.find { |k,| k == key }
|
|
105
|
+
found&.call
|
|
106
|
+
else
|
|
107
|
+
nil
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# rubocop:disable Style/HashEachMethods
|
|
112
|
+
# rubocop:disable Style/CaseEquality
|
|
113
|
+
|
|
114
|
+
# @api public
|
|
115
|
+
#
|
|
116
|
+
# @param other [Object]
|
|
117
|
+
#
|
|
118
|
+
# @return [Boolean]
|
|
119
|
+
def ===(other)
|
|
120
|
+
known_variants.any? do |_, variant_fn|
|
|
121
|
+
variant_fn.call === other
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# @api public
|
|
126
|
+
#
|
|
127
|
+
# @param other [Object]
|
|
128
|
+
#
|
|
129
|
+
# @return [Boolean]
|
|
130
|
+
def ==(other)
|
|
131
|
+
Cerca::Internal::Type::Union === other && other.derefed_variants == derefed_variants
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# @api public
|
|
135
|
+
#
|
|
136
|
+
# @return [Integer]
|
|
137
|
+
def hash = variants.hash
|
|
138
|
+
|
|
139
|
+
# @api private
|
|
140
|
+
#
|
|
141
|
+
# Tries to efficiently coerce the given value to one of the known variants.
|
|
142
|
+
#
|
|
143
|
+
# If the value cannot match any of the known variants, the coercion is considered
|
|
144
|
+
# non-viable and returns the original value.
|
|
145
|
+
#
|
|
146
|
+
# @param value [Object]
|
|
147
|
+
#
|
|
148
|
+
# @param state [Hash{Symbol=>Object}] .
|
|
149
|
+
#
|
|
150
|
+
# @option state [Boolean] :translate_names
|
|
151
|
+
#
|
|
152
|
+
# @option state [Boolean] :strictness
|
|
153
|
+
#
|
|
154
|
+
# @option state [Hash{Symbol=>Object}] :exactness
|
|
155
|
+
#
|
|
156
|
+
# @option state [Class<StandardError>] :error
|
|
157
|
+
#
|
|
158
|
+
# @option state [Integer] :branched
|
|
159
|
+
#
|
|
160
|
+
# @return [Object]
|
|
161
|
+
def coerce(value, state:)
|
|
162
|
+
if (target = resolve_variant(value))
|
|
163
|
+
return Cerca::Internal::Type::Converter.coerce(target, value, state: state)
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
strictness = state.fetch(:strictness)
|
|
167
|
+
exactness = state.fetch(:exactness)
|
|
168
|
+
|
|
169
|
+
alternatives = []
|
|
170
|
+
known_variants.each do |_, variant_fn|
|
|
171
|
+
target = variant_fn.call
|
|
172
|
+
exact = state[:exactness] = {yes: 0, no: 0, maybe: 0}
|
|
173
|
+
state[:branched] += 1
|
|
174
|
+
|
|
175
|
+
coerced = Cerca::Internal::Type::Converter.coerce(target, value, state: state)
|
|
176
|
+
yes, no, maybe = exact.values
|
|
177
|
+
if (no + maybe).zero? || (!strictness && yes.positive?)
|
|
178
|
+
exact.each { exactness[_1] += _2 }
|
|
179
|
+
state[:exactness] = exactness
|
|
180
|
+
return coerced
|
|
181
|
+
elsif maybe.positive?
|
|
182
|
+
alternatives << [[-yes, -maybe, no], exact, coerced]
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
case alternatives.sort_by!(&:first)
|
|
187
|
+
in []
|
|
188
|
+
exactness[:no] += 1
|
|
189
|
+
state[:error] = ArgumentError.new("no matching variant for #{value.inspect}")
|
|
190
|
+
value
|
|
191
|
+
in [[_, exact, coerced], *]
|
|
192
|
+
exact.each { exactness[_1] += _2 }
|
|
193
|
+
coerced
|
|
194
|
+
end
|
|
195
|
+
.tap { state[:exactness] = exactness }
|
|
196
|
+
ensure
|
|
197
|
+
state[:strictness] = strictness
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
# @api private
|
|
201
|
+
#
|
|
202
|
+
# @param value [Object]
|
|
203
|
+
#
|
|
204
|
+
# @param state [Hash{Symbol=>Object}] .
|
|
205
|
+
#
|
|
206
|
+
# @option state [Boolean] :can_retry
|
|
207
|
+
#
|
|
208
|
+
# @return [Object]
|
|
209
|
+
def dump(value, state:)
|
|
210
|
+
if (target = resolve_variant(value))
|
|
211
|
+
return Cerca::Internal::Type::Converter.dump(target, value, state: state)
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
known_variants.each do
|
|
215
|
+
target = _2.call
|
|
216
|
+
return Cerca::Internal::Type::Converter.dump(target, value, state: state) if target === value
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
super
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
# @api private
|
|
223
|
+
#
|
|
224
|
+
# @return [Object]
|
|
225
|
+
def to_sorbet_type
|
|
226
|
+
types = variants.map { Cerca::Internal::Util::SorbetRuntimeSupport.to_sorbet_type(_1) }.uniq
|
|
227
|
+
case types
|
|
228
|
+
in []
|
|
229
|
+
T.noreturn
|
|
230
|
+
in [type]
|
|
231
|
+
type
|
|
232
|
+
else
|
|
233
|
+
T.any(*types)
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
# rubocop:enable Style/CaseEquality
|
|
238
|
+
# rubocop:enable Style/HashEachMethods
|
|
239
|
+
|
|
240
|
+
# @api private
|
|
241
|
+
#
|
|
242
|
+
# @param depth [Integer]
|
|
243
|
+
#
|
|
244
|
+
# @return [String]
|
|
245
|
+
def inspect(depth: 0)
|
|
246
|
+
if depth.positive?
|
|
247
|
+
return is_a?(Module) ? super() : self.class.name
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
members = variants.map { Cerca::Internal::Type::Converter.inspect(_1, depth: depth.succ) }
|
|
251
|
+
prefix = is_a?(Module) ? name : self.class.name
|
|
252
|
+
|
|
253
|
+
"#{prefix}[#{members.join(' | ')}]"
|
|
254
|
+
end
|
|
255
|
+
end
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Cerca
|
|
4
|
+
module Internal
|
|
5
|
+
module Type
|
|
6
|
+
# @api private
|
|
7
|
+
#
|
|
8
|
+
# @abstract
|
|
9
|
+
#
|
|
10
|
+
# When we don't know what to expect for the value.
|
|
11
|
+
class Unknown
|
|
12
|
+
extend Cerca::Internal::Type::Converter
|
|
13
|
+
extend Cerca::Internal::Util::SorbetRuntimeSupport
|
|
14
|
+
|
|
15
|
+
# rubocop:disable Lint/UnusedMethodArgument
|
|
16
|
+
|
|
17
|
+
private_class_method :new
|
|
18
|
+
|
|
19
|
+
# @api public
|
|
20
|
+
#
|
|
21
|
+
# @param other [Object]
|
|
22
|
+
#
|
|
23
|
+
# @return [Boolean]
|
|
24
|
+
def self.===(other) = true
|
|
25
|
+
|
|
26
|
+
# @api public
|
|
27
|
+
#
|
|
28
|
+
# @param other [Object]
|
|
29
|
+
#
|
|
30
|
+
# @return [Boolean]
|
|
31
|
+
def self.==(other) = other.is_a?(Class) && other <= Cerca::Internal::Type::Unknown
|
|
32
|
+
|
|
33
|
+
class << self
|
|
34
|
+
# @api private
|
|
35
|
+
#
|
|
36
|
+
# No coercion needed for Unknown type.
|
|
37
|
+
#
|
|
38
|
+
# @param value [Object]
|
|
39
|
+
#
|
|
40
|
+
# @param state [Hash{Symbol=>Object}] .
|
|
41
|
+
#
|
|
42
|
+
# @option state [Boolean] :translate_names
|
|
43
|
+
#
|
|
44
|
+
# @option state [Boolean] :strictness
|
|
45
|
+
#
|
|
46
|
+
# @option state [Hash{Symbol=>Object}] :exactness
|
|
47
|
+
#
|
|
48
|
+
# @option state [Class<StandardError>] :error
|
|
49
|
+
#
|
|
50
|
+
# @option state [Integer] :branched
|
|
51
|
+
#
|
|
52
|
+
# @return [Object]
|
|
53
|
+
def coerce(value, state:)
|
|
54
|
+
state.fetch(:exactness)[:yes] += 1
|
|
55
|
+
value
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# @!method dump(value, state:)
|
|
59
|
+
# @api private
|
|
60
|
+
#
|
|
61
|
+
# @param value [Object]
|
|
62
|
+
#
|
|
63
|
+
# @param state [Hash{Symbol=>Object}] .
|
|
64
|
+
#
|
|
65
|
+
# @option state [Boolean] :can_retry
|
|
66
|
+
#
|
|
67
|
+
# @return [Object]
|
|
68
|
+
|
|
69
|
+
# @api private
|
|
70
|
+
#
|
|
71
|
+
# @return [Object]
|
|
72
|
+
def to_sorbet_type
|
|
73
|
+
T.anything
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# rubocop:enable Lint/UnusedMethodArgument
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|