@rustrak/client 0.18.0 → 0.19.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.
Files changed (119) hide show
  1. package/README.md +312 -123
  2. package/dist/_virtual/_rolldown/runtime.cjs +23 -0
  3. package/dist/client.cjs +86 -0
  4. package/dist/client.cjs.map +1 -0
  5. package/dist/client.d.cts +18 -0
  6. package/dist/client.d.cts.map +1 -0
  7. package/dist/client.d.mts +18 -0
  8. package/dist/client.d.mts.map +1 -0
  9. package/dist/client.mjs +86 -0
  10. package/dist/client.mjs.map +1 -0
  11. package/dist/config.d.cts +10 -0
  12. package/dist/config.d.cts.map +1 -0
  13. package/dist/config.d.mts +10 -0
  14. package/dist/config.d.mts.map +1 -0
  15. package/dist/errors.cjs +52 -0
  16. package/dist/errors.cjs.map +1 -0
  17. package/dist/errors.d.cts +77 -0
  18. package/dist/errors.d.cts.map +1 -0
  19. package/dist/errors.d.mts +77 -0
  20. package/dist/errors.d.mts.map +1 -0
  21. package/dist/errors.mjs +48 -0
  22. package/dist/errors.mjs.map +1 -0
  23. package/dist/generated/client/client.gen.cjs +174 -0
  24. package/dist/generated/client/client.gen.cjs.map +1 -0
  25. package/dist/generated/client/client.gen.mjs +174 -0
  26. package/dist/generated/client/client.gen.mjs.map +1 -0
  27. package/dist/generated/client/types.gen.d.cts +71 -0
  28. package/dist/generated/client/types.gen.d.cts.map +1 -0
  29. package/dist/generated/client/types.gen.d.mts +71 -0
  30. package/dist/generated/client/types.gen.d.mts.map +1 -0
  31. package/dist/generated/client/utils.gen.cjs +184 -0
  32. package/dist/generated/client/utils.gen.cjs.map +1 -0
  33. package/dist/generated/client/utils.gen.d.cts +21 -0
  34. package/dist/generated/client/utils.gen.d.cts.map +1 -0
  35. package/dist/generated/client/utils.gen.d.mts +21 -0
  36. package/dist/generated/client/utils.gen.d.mts.map +1 -0
  37. package/dist/generated/client/utils.gen.mjs +177 -0
  38. package/dist/generated/client/utils.gen.mjs.map +1 -0
  39. package/dist/generated/client.gen.cjs +7 -0
  40. package/dist/generated/client.gen.cjs.map +1 -0
  41. package/dist/generated/client.gen.mjs +8 -0
  42. package/dist/generated/client.gen.mjs.map +1 -0
  43. package/dist/generated/core/auth.gen.cjs +12 -0
  44. package/dist/generated/core/auth.gen.cjs.map +1 -0
  45. package/dist/generated/core/auth.gen.d.cts +11 -0
  46. package/dist/generated/core/auth.gen.d.cts.map +1 -0
  47. package/dist/generated/core/auth.gen.d.mts +11 -0
  48. package/dist/generated/core/auth.gen.d.mts.map +1 -0
  49. package/dist/generated/core/auth.gen.mjs +12 -0
  50. package/dist/generated/core/auth.gen.mjs.map +1 -0
  51. package/dist/generated/core/bodySerializer.gen.cjs +21 -0
  52. package/dist/generated/core/bodySerializer.gen.cjs.map +1 -0
  53. package/dist/generated/core/bodySerializer.gen.d.cts +15 -0
  54. package/dist/generated/core/bodySerializer.gen.d.cts.map +1 -0
  55. package/dist/generated/core/bodySerializer.gen.d.mts +15 -0
  56. package/dist/generated/core/bodySerializer.gen.d.mts.map +1 -0
  57. package/dist/generated/core/bodySerializer.gen.mjs +20 -0
  58. package/dist/generated/core/bodySerializer.gen.mjs.map +1 -0
  59. package/dist/generated/core/pathSerializer.gen.cjs +87 -0
  60. package/dist/generated/core/pathSerializer.gen.cjs.map +1 -0
  61. package/dist/generated/core/pathSerializer.gen.d.cts +9 -0
  62. package/dist/generated/core/pathSerializer.gen.d.cts.map +1 -0
  63. package/dist/generated/core/pathSerializer.gen.d.mts +9 -0
  64. package/dist/generated/core/pathSerializer.gen.d.mts.map +1 -0
  65. package/dist/generated/core/pathSerializer.gen.mjs +82 -0
  66. package/dist/generated/core/pathSerializer.gen.mjs.map +1 -0
  67. package/dist/generated/core/serverSentEvents.gen.cjs +96 -0
  68. package/dist/generated/core/serverSentEvents.gen.cjs.map +1 -0
  69. package/dist/generated/core/serverSentEvents.gen.d.cts +25 -0
  70. package/dist/generated/core/serverSentEvents.gen.d.cts.map +1 -0
  71. package/dist/generated/core/serverSentEvents.gen.d.mts +25 -0
  72. package/dist/generated/core/serverSentEvents.gen.d.mts.map +1 -0
  73. package/dist/generated/core/serverSentEvents.gen.mjs +96 -0
  74. package/dist/generated/core/serverSentEvents.gen.mjs.map +1 -0
  75. package/dist/generated/core/types.gen.d.cts +27 -0
  76. package/dist/generated/core/types.gen.d.cts.map +1 -0
  77. package/dist/generated/core/types.gen.d.mts +27 -0
  78. package/dist/generated/core/types.gen.d.mts.map +1 -0
  79. package/dist/generated/core/utils.gen.cjs +81 -0
  80. package/dist/generated/core/utils.gen.cjs.map +1 -0
  81. package/dist/generated/core/utils.gen.mjs +78 -0
  82. package/dist/generated/core/utils.gen.mjs.map +1 -0
  83. package/dist/generated/sdk.gen.cjs +3138 -0
  84. package/dist/generated/sdk.gen.cjs.map +1 -0
  85. package/dist/generated/sdk.gen.d.cts +276 -0
  86. package/dist/generated/sdk.gen.d.cts.map +1 -0
  87. package/dist/generated/sdk.gen.d.mts +276 -0
  88. package/dist/generated/sdk.gen.d.mts.map +1 -0
  89. package/dist/generated/sdk.gen.mjs +3110 -0
  90. package/dist/generated/sdk.gen.mjs.map +1 -0
  91. package/dist/generated/types.gen.d.cts +3679 -0
  92. package/dist/generated/types.gen.d.cts.map +1 -0
  93. package/dist/generated/types.gen.d.mts +3679 -0
  94. package/dist/generated/types.gen.d.mts.map +1 -0
  95. package/dist/generated/zod.gen.cjs +3076 -0
  96. package/dist/generated/zod.gen.cjs.map +1 -0
  97. package/dist/generated/zod.gen.mjs +2618 -0
  98. package/dist/generated/zod.gen.mjs.map +1 -0
  99. package/dist/index.cjs +15 -3248
  100. package/dist/index.d.cts +6 -2037
  101. package/dist/index.d.mts +6 -0
  102. package/dist/index.mjs +4 -0
  103. package/dist/result.cjs +59 -0
  104. package/dist/result.cjs.map +1 -0
  105. package/dist/result.d.cts +15 -0
  106. package/dist/result.d.cts.map +1 -0
  107. package/dist/result.d.mts +15 -0
  108. package/dist/result.d.mts.map +1 -0
  109. package/dist/result.mjs +55 -0
  110. package/dist/result.mjs.map +1 -0
  111. package/dist/utils/http.cjs +339 -0
  112. package/dist/utils/http.cjs.map +1 -0
  113. package/dist/utils/http.mjs +336 -0
  114. package/dist/utils/http.mjs.map +1 -0
  115. package/package.json +17 -12
  116. package/dist/index.cjs.map +0 -1
  117. package/dist/index.d.ts +0 -2037
  118. package/dist/index.js +0 -3232
  119. package/dist/index.js.map +0 -1
@@ -0,0 +1,6 @@
1
+ import { ClientConfig } from "./config.mjs";
2
+ import { FIELD_ERROR_CODES, FieldError, FieldErrorCode, NETWORK_ERROR_MESSAGE, RustrakError, RustrakErrorKind, SERVER_ERROR_MESSAGE, TIMEOUT_ERROR_MESSAGE, isRetryable } from "./errors.mjs";
3
+ import { AcceptInvitation, ActivityEntry, AgentDurationPoint, AgentModelRow, AgentSummary, AgentTimeseriesPoint, AgentToolRow, AgentTraceSummary, AgentsDurationData, AgentsDurationError, AgentsDurationErrors, AgentsDurationResponse, AgentsDurationResponses, AgentsEnvironmentsData, AgentsEnvironmentsError, AgentsEnvironmentsErrors, AgentsEnvironmentsResponse, AgentsEnvironmentsResponses, AgentsModelsCallsData, AgentsModelsCallsError, AgentsModelsCallsErrors, AgentsModelsCallsResponse, AgentsModelsCallsResponses, AgentsModelsTableData, AgentsModelsTableError, AgentsModelsTableErrors, AgentsModelsTableResponse, AgentsModelsTableResponses, AgentsModelsTokensData, AgentsModelsTokensError, AgentsModelsTokensErrors, AgentsModelsTokensResponse, AgentsModelsTokensResponses, AgentsRunsData, AgentsRunsError, AgentsRunsErrors, AgentsRunsResponse, AgentsRunsResponses, AgentsSummaryData, AgentsSummaryError, AgentsSummaryErrors, AgentsSummaryResponse, AgentsSummaryResponses, AgentsToolsData, AgentsToolsError, AgentsToolsErrors, AgentsToolsResponse, AgentsToolsResponses, AgentsToolsTableData, AgentsToolsTableError, AgentsToolsTableErrors, AgentsToolsTableResponse, AgentsToolsTableResponses, AgentsTracesData, AgentsTracesError, AgentsTracesErrors, AgentsTracesResponse, AgentsTracesResponses, AlertChannelsCreateData, AlertChannelsCreateError, AlertChannelsCreateErrors, AlertChannelsCreateResponse, AlertChannelsCreateResponses, AlertChannelsDeleteData, AlertChannelsDeleteError, AlertChannelsDeleteErrors, AlertChannelsDeleteResponse, AlertChannelsDeleteResponses, AlertChannelsGetData, AlertChannelsGetError, AlertChannelsGetErrors, AlertChannelsGetResponse, AlertChannelsGetResponses, AlertChannelsListData, AlertChannelsListError, AlertChannelsListErrors, AlertChannelsListResponse, AlertChannelsListResponses, AlertChannelsPreviewTemplateData, AlertChannelsPreviewTemplateError, AlertChannelsPreviewTemplateErrors, AlertChannelsPreviewTemplateResponse, AlertChannelsPreviewTemplateResponses, AlertChannelsTestData, AlertChannelsTestError, AlertChannelsTestErrors, AlertChannelsTestResponse, AlertChannelsTestResponses, AlertChannelsUpdateData, AlertChannelsUpdateError, AlertChannelsUpdateErrors, AlertChannelsUpdateResponse, AlertChannelsUpdateResponses, AlertHistory, AlertIntegration, AlertRuleChannelInput, AlertRuleResponse, AlertRulesCreateData, AlertRulesCreateError, AlertRulesCreateErrors, AlertRulesCreateResponse, AlertRulesCreateResponses, AlertRulesDeleteData, AlertRulesDeleteError, AlertRulesDeleteErrors, AlertRulesDeleteResponse, AlertRulesDeleteResponses, AlertRulesGetData, AlertRulesGetError, AlertRulesGetErrors, AlertRulesGetResponse, AlertRulesGetResponses, AlertRulesListData, AlertRulesListError, AlertRulesListErrors, AlertRulesListHistoryData, AlertRulesListHistoryError, AlertRulesListHistoryErrors, AlertRulesListHistoryResponse, AlertRulesListHistoryResponses, AlertRulesListResponse, AlertRulesListResponses, AlertRulesUpdateData, AlertRulesUpdateError, AlertRulesUpdateErrors, AlertRulesUpdateResponse, AlertRulesUpdateResponses, AlertStatus, AlertType, AssembleBody, AssembleResponse, AuthAcceptInvitationData, AuthAcceptInvitationError, AuthAcceptInvitationErrors, AuthAcceptInvitationResponse, AuthAcceptInvitationResponses, AuthChangePasswordData, AuthChangePasswordError, AuthChangePasswordErrors, AuthChangePasswordResponse, AuthChangePasswordResponses, AuthConfirmSsoLinkData, AuthConfirmSsoLinkError, AuthConfirmSsoLinkErrors, AuthConfirmSsoLinkResponse, AuthConfirmSsoLinkResponses, AuthGetCurrentUserData, AuthGetCurrentUserError, AuthGetCurrentUserErrors, AuthGetCurrentUserResponse, AuthGetCurrentUserResponses, AuthGetInvitationData, AuthGetInvitationError, AuthGetInvitationErrors, AuthGetInvitationResponse, AuthGetInvitationResponses, AuthLoginData, AuthLoginError, AuthLoginErrors, AuthLoginResponse, AuthLoginResponses, AuthLogoutData, AuthLogoutResponse, AuthLogoutResponses, AuthRegisterData, AuthRegisterError, AuthRegisterErrors, AuthResponse, AuthSsoCallbackData, AuthSsoCallbackError, AuthSsoCallbackErrors, AuthSsoCallbackResponse, AuthSsoCallbackResponses, AuthSsoConfigData, AuthSsoConfigResponse, AuthSsoConfigResponses, AuthSsoLinkData, AuthSsoLinkError, AuthSsoLinkErrors, AuthSsoLinkResponse, AuthSsoLinkResponses, AuthSsoStartData, AuthSsoStartError, AuthSsoStartErrors, AuthSsoStartResponse, AuthSsoStartResponses, AuthTokenCreatedResponse, AuthTokenResponse, AuthUpdateCurrentUserData, AuthUpdateCurrentUserError, AuthUpdateCurrentUserErrors, AuthUpdateCurrentUserResponse, AuthUpdateCurrentUserResponses, AuthorizationDecision, AuthorizationInfo, AuthorizationRedirect, AuthorizationRequest, BookmarkResponse, BulkDeleteIssues, BulkDeleteResponse, BulkUpdateIssues, BulkUpdateResponse, ChangePasswordRequest, CheckInResponse, CheckInStatus, ChunkUploadBody, ChunkUploadOptions, CleanupCounts, CleanupFrequency, CleanupRequest, CleanupState, CleanupStatus, ClientOptions, CodeMapping, CommentRequest, ConfirmSsoLinkRequest, CreateAlertIntegration, CreateAlertRule, CreateAuthToken, CreateGitHubIssue, CreateInvitation, CreateMonitor, CreateProject, CreateRelease, CreateUserRequest, ErrorDetail, ErrorResponse, EventDetailResponse, EventResponse, EventTimeseriesPoint, EventsGetBySentryIdData, EventsGetBySentryIdError, EventsGetBySentryIdErrors, EventsGetBySentryIdResponse, EventsGetBySentryIdResponses, EventsGetData, EventsGetError, EventsGetErrors, EventsGetResponse, EventsGetResponses, EventsListData, EventsListError, EventsListErrors, EventsListResponse, EventsListResponses, GenAiBreakdownRow, GitHubAppInfo, GitHubInstallation, GitHubLogin, GitHubRepository, GitHubStatus, GithubCallbackData, GithubCallbackError, GithubCallbackErrors, GithubCreateIssueData, GithubCreateIssueError, GithubCreateIssueErrors, GithubCreateIssueResponse, GithubCreateIssueResponses, GithubDeleteProjectRepositoryData, GithubDeleteProjectRepositoryError, GithubDeleteProjectRepositoryErrors, GithubDeleteProjectRepositoryResponse, GithubDeleteProjectRepositoryResponses, GithubDisconnectData, GithubDisconnectError, GithubDisconnectErrors, GithubDisconnectResponse, GithubDisconnectResponses, GithubGetMyLoginData, GithubGetMyLoginError, GithubGetMyLoginErrors, GithubGetMyLoginResponse, GithubGetMyLoginResponses, GithubGetProjectRepositoryData, GithubGetProjectRepositoryError, GithubGetProjectRepositoryErrors, GithubGetProjectRepositoryResponse, GithubGetProjectRepositoryResponses, GithubInstalledData, GithubInstalledError, GithubInstalledErrors, GithubIssueData, GithubIssueError, GithubIssueErrors, GithubIssueResponse, GithubIssueResponses, GithubLinkIssueData, GithubLinkIssueError, GithubLinkIssueErrors, GithubLinkIssueResponse, GithubLinkIssueResponses, GithubManifestData, GithubManifestError, GithubManifestErrors, GithubManifestResponse, GithubManifestResponses, GithubPutMyLoginData, GithubPutMyLoginError, GithubPutMyLoginErrors, GithubPutMyLoginResponse, GithubPutMyLoginResponses, GithubPutProjectRepositoryData, GithubPutProjectRepositoryError, GithubPutProjectRepositoryErrors, GithubPutProjectRepositoryResponse, GithubPutProjectRepositoryResponses, GithubRepositoriesData, GithubRepositoriesError, GithubRepositoriesErrors, GithubRepositoriesResponse, GithubRepositoriesResponses, GithubStatusData, GithubStatusError, GithubStatusErrors, GithubStatusResponse, GithubStatusResponses, GithubSyncCodeownersData, GithubSyncCodeownersError, GithubSyncCodeownersErrors, GithubSyncCodeownersResponse, GithubSyncCodeownersResponses, GithubUnlinkIssueData, GithubUnlinkIssueError, GithubUnlinkIssueErrors, GithubUnlinkIssueResponse, GithubUnlinkIssueResponses, GithubWebhookData, GithubWebhookError, GithubWebhookErrors, GithubWebhookResponse, GithubWebhookResponses, Grouping, HealthLivenessData, HealthLivenessResponse, HealthLivenessResponses, HealthReadinessData, HealthReadinessError, HealthReadinessErrors, HealthReadinessResponse, HealthReadinessResponses, HealthVersionData, HealthVersionError, HealthVersionErrors, HealthVersionResponse, HealthVersionResponses, IntervalUnit, InvitationInfoResponse, InvitationResponse, InvitationsCreateData, InvitationsCreateError, InvitationsCreateErrors, InvitationsCreateResponse, InvitationsCreateResponses, InvitationsListData, InvitationsListError, InvitationsListErrors, InvitationsListResponse, InvitationsListResponses, InvitationsRevokeData, InvitationsRevokeError, InvitationsRevokeErrors, InvitationsRevokeResponse, InvitationsRevokeResponses, IssueAggregates, IssueFilter, IssueGitHub, IssueLink, IssuePriority, IssueResponse, IssueSort, IssueStatsResponse, IssueStatsWindow, IssueStatus, IssueStatusUpdate, IssueTagValue, IssuesBulkDeleteData, IssuesBulkDeleteError, IssuesBulkDeleteErrors, IssuesBulkDeleteResponse, IssuesBulkDeleteResponses, IssuesBulkUpdateData, IssuesBulkUpdateError, IssuesBulkUpdateErrors, IssuesBulkUpdateResponse, IssuesBulkUpdateResponses, IssuesCreateCommentData, IssuesCreateCommentError, IssuesCreateCommentErrors, IssuesCreateCommentResponse, IssuesCreateCommentResponses, IssuesCreateUserReportData, IssuesCreateUserReportError, IssuesCreateUserReportErrors, IssuesCreateUserReportResponse, IssuesCreateUserReportResponses, IssuesDeleteData, IssuesDeleteError, IssuesDeleteErrors, IssuesDeleteResponse, IssuesDeleteResponses, IssuesGetActivityData, IssuesGetActivityError, IssuesGetActivityErrors, IssuesGetActivityResponse, IssuesGetActivityResponses, IssuesGetAggregatesData, IssuesGetAggregatesError, IssuesGetAggregatesErrors, IssuesGetAggregatesResponse, IssuesGetAggregatesResponses, IssuesGetData, IssuesGetError, IssuesGetErrors, IssuesGetHashesData, IssuesGetHashesError, IssuesGetHashesErrors, IssuesGetHashesResponse, IssuesGetHashesResponses, IssuesGetResponse, IssuesGetResponses, IssuesGetStatsData, IssuesGetStatsError, IssuesGetStatsErrors, IssuesGetStatsResponse, IssuesGetStatsResponses, IssuesGetTagValuesData, IssuesGetTagValuesError, IssuesGetTagValuesErrors, IssuesGetTagValuesResponse, IssuesGetTagValuesResponses, IssuesListData, IssuesListError, IssuesListErrors, IssuesListResponse, IssuesListResponses, IssuesListUserReportsData, IssuesListUserReportsError, IssuesListUserReportsErrors, IssuesListUserReportsResponse, IssuesListUserReportsResponses, IssuesMarkSeenData, IssuesMarkSeenError, IssuesMarkSeenErrors, IssuesMarkSeenResponse, IssuesMarkSeenResponses, IssuesSetBookmarkData, IssuesSetBookmarkError, IssuesSetBookmarkErrors, IssuesSetBookmarkResponse, IssuesSetBookmarkResponses, IssuesSetSubscriptionData, IssuesSetSubscriptionError, IssuesSetSubscriptionErrors, IssuesSetSubscriptionResponse, IssuesSetSubscriptionResponses, IssuesUpdateData, IssuesUpdateError, IssuesUpdateErrors, IssuesUpdateResponse, IssuesUpdateResponses, KindAge, LinkGitHubIssue, LivenessResponse, LogResponse, LoginRequest, LogsListData, LogsListError, LogsListErrors, LogsListResponse, LogsListResponses, ManifestRequest, ManifestResponse, McpSettings, McpStatus, MembersListData, MembersListError, MembersListErrors, MembersListResponse, MembersListResponses, MembersRemoveData, MembersRemoveError, MembersRemoveErrors, MembersRemoveResponse, MembersRemoveResponses, MembersUpsertData, MembersUpsertError, MembersUpsertErrors, MembersUpsertResponse, MembersUpsertResponses, MetricDelta, MonitorConfig, MonitorConfigInput, MonitorEnvironmentResponse, MonitorEnvironmentStatus, MonitorResponse, MonitorsCreateData, MonitorsCreateError, MonitorsCreateErrors, MonitorsCreateResponse, MonitorsCreateResponses, MonitorsDeleteData, MonitorsDeleteError, MonitorsDeleteErrors, MonitorsDeleteResponse, MonitorsDeleteResponses, MonitorsGetData, MonitorsGetError, MonitorsGetErrors, MonitorsGetResponse, MonitorsGetResponses, MonitorsListCheckinsData, MonitorsListCheckinsError, MonitorsListCheckinsErrors, MonitorsListCheckinsResponse, MonitorsListCheckinsResponses, MonitorsListData, MonitorsListError, MonitorsListErrors, MonitorsListResponse, MonitorsListResponses, MonitorsUpdateData, MonitorsUpdateError, MonitorsUpdateErrors, MonitorsUpdateResponse, MonitorsUpdateResponses, OAuthGrant, OauthDecideAuthorizationData, OauthDecideAuthorizationError, OauthDecideAuthorizationErrors, OauthDecideAuthorizationResponse, OauthDecideAuthorizationResponses, OauthGetAuthorizationData, OauthGetAuthorizationError, OauthGetAuthorizationErrors, OauthGetAuthorizationResponse, OauthGetAuthorizationResponses, OauthListGrantsData, OauthListGrantsError, OauthListGrantsErrors, OauthListGrantsResponse, OauthListGrantsResponses, OauthRevokeGrantData, OauthRevokeGrantError, OauthRevokeGrantErrors, OauthRevokeGrantResponse, OauthRevokeGrantResponses, OrgDetails, PreviewSchedule, PreviewTemplateBody, PreviewTemplateResponse, ProjectAge, ProjectListStats, ProjectMember, ProjectMemberResponse, ProjectRepository, ProjectResponse, ProjectRetention, ProjectRole, ProjectStatsSummary, ProjectStorage, ProjectsCreateData, ProjectsCreateError, ProjectsCreateErrors, ProjectsCreateResponse, ProjectsCreateResponses, ProjectsDeleteData, ProjectsDeleteError, ProjectsDeleteErrors, ProjectsDeleteResponse, ProjectsDeleteResponses, ProjectsGetData, ProjectsGetError, ProjectsGetErrors, ProjectsGetRateLimitsData, ProjectsGetRateLimitsError, ProjectsGetRateLimitsErrors, ProjectsGetRateLimitsResponse, ProjectsGetRateLimitsResponses, ProjectsGetResponse, ProjectsGetResponses, ProjectsListData, ProjectsListError, ProjectsListErrors, ProjectsListResponse, ProjectsListResponses, ProjectsUpdateData, ProjectsUpdateError, ProjectsUpdateErrors, ProjectsUpdateResponse, ProjectsUpdateResponses, ProviderType, RateLimitsResponse, ReadinessChecks, ReadinessResponse, ReleaseHealthRow, ReleaseResponse, ReleasesCreateData, ReleasesCreateError, ReleasesCreateErrors, ReleasesCreateResponse, ReleasesCreateResponses, ReleasesFinalizeData, ReleasesFinalizeError, ReleasesFinalizeErrors, ReleasesFinalizeResponse, ReleasesFinalizeResponses, ReleasesNewIssuesData, ReleasesNewIssuesErrors, ReleasesNewIssuesResponse, ReleasesNewIssuesResponses, RepoCommit, RetentionResponse, RetentionRun, RetentionSettings, RetentionWindows, Schedule, SchedulePreview, SchedulesPreviewData, SchedulesPreviewError, SchedulesPreviewErrors, SchedulesPreviewResponse, SchedulesPreviewResponses, SeenResponse, SessionSummary, SessionTimeseriesPoint, SessionsGetStatsData, SessionsGetStatsErrors, SessionsGetStatsResponse, SessionsGetStatsResponses, SessionsGetSummaryData, SessionsGetSummaryErrors, SessionsGetSummaryResponse, SessionsGetSummaryResponses, SessionsGetTimeseriesData, SessionsGetTimeseriesErrors, SessionsGetTimeseriesResponse, SessionsGetTimeseriesResponses, SettingsGetMcpData, SettingsGetMcpError, SettingsGetMcpErrors, SettingsGetMcpResponse, SettingsGetMcpResponses, SettingsUpdateMcpData, SettingsUpdateMcpError, SettingsUpdateMcpErrors, SettingsUpdateMcpResponse, SettingsUpdateMcpResponses, SortOrder, SourceMapFile, SourceMapGcResult, SourceMapList, SourceMapStorage, SourceMapsArtifactBundleAssembleData, SourceMapsArtifactBundleAssembleError, SourceMapsArtifactBundleAssembleErrors, SourceMapsArtifactBundleAssembleResponse, SourceMapsArtifactBundleAssembleResponses, SourceMapsChunkUploadCapabilityData, SourceMapsChunkUploadCapabilityError, SourceMapsChunkUploadCapabilityErrors, SourceMapsChunkUploadCapabilityResponse, SourceMapsChunkUploadCapabilityResponses, SourceMapsChunkUploadData, SourceMapsChunkUploadError, SourceMapsChunkUploadErrors, SourceMapsChunkUploadResponses, SourceMapsListData, SourceMapsListError, SourceMapsListErrors, SourceMapsListResponse, SourceMapsListResponses, SourceMapsOrgDetailsData, SourceMapsOrgDetailsResponse, SourceMapsOrgDetailsResponses, SpanDetailResponse, SpanResponse, SpansGetData, SpansGetError, SpansGetErrors, SpansGetResponse, SpansGetResponses, SpansListData, SpansListError, SpansListErrors, SpansListResponse, SpansListResponses, SsoConfigResponse, SsoLinkResponse, SsoStartResponse, StatsGetEventTimeseriesData, StatsGetEventTimeseriesErrors, StatsGetEventTimeseriesResponse, StatsGetEventTimeseriesResponses, StatsGetSummaryData, StatsGetSummaryErrors, StatsGetSummaryResponse, StatsGetSummaryResponses, StorageAge, StorageExecuteCleanupData, StorageExecuteCleanupError, StorageExecuteCleanupErrors, StorageExecuteCleanupResponse, StorageExecuteCleanupResponses, StorageGcSourceMapsData, StorageGcSourceMapsError, StorageGcSourceMapsErrors, StorageGcSourceMapsResponse, StorageGcSourceMapsResponses, StorageGetAgeData, StorageGetAgeError, StorageGetAgeErrors, StorageGetAgeResponse, StorageGetAgeResponses, StorageGetCleanupStatusData, StorageGetCleanupStatusError, StorageGetCleanupStatusErrors, StorageGetCleanupStatusResponse, StorageGetCleanupStatusResponses, StorageGetProjectsData, StorageGetProjectsError, StorageGetProjectsErrors, StorageGetProjectsResponse, StorageGetProjectsResponses, StorageGetRetentionData, StorageGetRetentionError, StorageGetRetentionErrors, StorageGetRetentionResponse, StorageGetRetentionResponses, StorageGetSummaryData, StorageGetSummaryError, StorageGetSummaryErrors, StorageGetSummaryResponse, StorageGetSummaryResponses, StoragePreviewCleanupData, StoragePreviewCleanupError, StoragePreviewCleanupErrors, StoragePreviewCleanupResponse, StoragePreviewCleanupResponses, StoragePreviewRetentionData, StoragePreviewRetentionError, StoragePreviewRetentionErrors, StoragePreviewRetentionResponse, StoragePreviewRetentionResponses, StoragePreviewSourceMapGcData, StoragePreviewSourceMapGcError, StoragePreviewSourceMapGcErrors, StoragePreviewSourceMapGcResponse, StoragePreviewSourceMapGcResponses, StorageRunRetentionData, StorageRunRetentionError, StorageRunRetentionErrors, StorageRunRetentionResponse, StorageRunRetentionResponses, StorageSummary, StorageUpdateRetentionData, StorageUpdateRetentionError, StorageUpdateRetentionErrors, StorageUpdateRetentionResponse, StorageUpdateRetentionResponses, SubscriptionResponse, TagSummary, TagValueCount, TeamDeleteUserData, TeamDeleteUserError, TeamDeleteUserErrors, TeamDeleteUserResponse, TeamDeleteUserResponses, TeamListData, TeamListError, TeamListErrors, TeamListResponse, TeamListResponses, TeamMemberResponse, TeamUpdateRoleData, TeamUpdateRoleError, TeamUpdateRoleErrors, TeamUpdateRoleResponse, TeamUpdateRoleResponses, TelemetryPreview, TelemetryPreviewData, TelemetryPreviewError, TelemetryPreviewErrors, TelemetryPreviewResponse, TelemetryPreviewResponses, TestChannelResponse, TestIntegrationBody, ToggleRequest, TokensCreateData, TokensCreateError, TokensCreateErrors, TokensCreateResponse, TokensCreateResponses, TokensDeleteData, TokensDeleteError, TokensDeleteErrors, TokensDeleteResponse, TokensDeleteResponses, TokensGetData, TokensGetError, TokensGetErrors, TokensGetResponse, TokensGetResponses, TokensListData, TokensListError, TokensListErrors, TokensListResponse, TokensListResponses, TransactionDetailResponse, TransactionResponse, TransactionStatsResponse, TransactionsGetData, TransactionsGetError, TransactionsGetErrors, TransactionsGetResponse, TransactionsGetResponses, TransactionsGetSpansData, TransactionsGetSpansError, TransactionsGetSpansErrors, TransactionsGetSpansResponse, TransactionsGetSpansResponses, TransactionsGetStatGroupData, TransactionsGetStatGroupError, TransactionsGetStatGroupErrors, TransactionsGetStatGroupResponse, TransactionsGetStatGroupResponses, TransactionsGetStatsData, TransactionsGetStatsError, TransactionsGetStatsErrors, TransactionsGetStatsResponse, TransactionsGetStatsResponses, TransactionsListData, TransactionsListError, TransactionsListErrors, TransactionsListResponse, TransactionsListResponses, UpdateAlertIntegration, UpdateAlertRule, UpdateIssueState, UpdateMonitor, UpdatePreferencesRequest, UpdateProject, UpdateProjectRepository, UpdateRelease, UpdateUserRole, UpsertProjectMember, UserReport, UserReportRequest, UserResponse, UserRole, VersionResponse } from "./generated/types.gen.mjs";
4
+ import { Err, Ok, Result, mapResult, unwrap, unwrapOr } from "./result.mjs";
5
+ import { RustrakClient } from "./client.mjs";
6
+ export { type AcceptInvitation, type ActivityEntry, type AgentDurationPoint, type AgentModelRow, type AgentSummary, type AgentTimeseriesPoint, type AgentToolRow, type AgentTraceSummary, type AgentsDurationData, type AgentsDurationError, type AgentsDurationErrors, type AgentsDurationResponse, type AgentsDurationResponses, type AgentsEnvironmentsData, type AgentsEnvironmentsError, type AgentsEnvironmentsErrors, type AgentsEnvironmentsResponse, type AgentsEnvironmentsResponses, type AgentsModelsCallsData, type AgentsModelsCallsError, type AgentsModelsCallsErrors, type AgentsModelsCallsResponse, type AgentsModelsCallsResponses, type AgentsModelsTableData, type AgentsModelsTableError, type AgentsModelsTableErrors, type AgentsModelsTableResponse, type AgentsModelsTableResponses, type AgentsModelsTokensData, type AgentsModelsTokensError, type AgentsModelsTokensErrors, type AgentsModelsTokensResponse, type AgentsModelsTokensResponses, type AgentsRunsData, type AgentsRunsError, type AgentsRunsErrors, type AgentsRunsResponse, type AgentsRunsResponses, type AgentsSummaryData, type AgentsSummaryError, type AgentsSummaryErrors, type AgentsSummaryResponse, type AgentsSummaryResponses, type AgentsToolsData, type AgentsToolsError, type AgentsToolsErrors, type AgentsToolsResponse, type AgentsToolsResponses, type AgentsToolsTableData, type AgentsToolsTableError, type AgentsToolsTableErrors, type AgentsToolsTableResponse, type AgentsToolsTableResponses, type AgentsTracesData, type AgentsTracesError, type AgentsTracesErrors, type AgentsTracesResponse, type AgentsTracesResponses, type AlertChannelsCreateData, type AlertChannelsCreateError, type AlertChannelsCreateErrors, type AlertChannelsCreateResponse, type AlertChannelsCreateResponses, type AlertChannelsDeleteData, type AlertChannelsDeleteError, type AlertChannelsDeleteErrors, type AlertChannelsDeleteResponse, type AlertChannelsDeleteResponses, type AlertChannelsGetData, type AlertChannelsGetError, type AlertChannelsGetErrors, type AlertChannelsGetResponse, type AlertChannelsGetResponses, type AlertChannelsListData, type AlertChannelsListError, type AlertChannelsListErrors, type AlertChannelsListResponse, type AlertChannelsListResponses, type AlertChannelsPreviewTemplateData, type AlertChannelsPreviewTemplateError, type AlertChannelsPreviewTemplateErrors, type AlertChannelsPreviewTemplateResponse, type AlertChannelsPreviewTemplateResponses, type AlertChannelsTestData, type AlertChannelsTestError, type AlertChannelsTestErrors, type AlertChannelsTestResponse, type AlertChannelsTestResponses, type AlertChannelsUpdateData, type AlertChannelsUpdateError, type AlertChannelsUpdateErrors, type AlertChannelsUpdateResponse, type AlertChannelsUpdateResponses, type AlertHistory, type AlertIntegration, type AlertRuleChannelInput, type AlertRuleResponse, type AlertRulesCreateData, type AlertRulesCreateError, type AlertRulesCreateErrors, type AlertRulesCreateResponse, type AlertRulesCreateResponses, type AlertRulesDeleteData, type AlertRulesDeleteError, type AlertRulesDeleteErrors, type AlertRulesDeleteResponse, type AlertRulesDeleteResponses, type AlertRulesGetData, type AlertRulesGetError, type AlertRulesGetErrors, type AlertRulesGetResponse, type AlertRulesGetResponses, type AlertRulesListData, type AlertRulesListError, type AlertRulesListErrors, type AlertRulesListHistoryData, type AlertRulesListHistoryError, type AlertRulesListHistoryErrors, type AlertRulesListHistoryResponse, type AlertRulesListHistoryResponses, type AlertRulesListResponse, type AlertRulesListResponses, type AlertRulesUpdateData, type AlertRulesUpdateError, type AlertRulesUpdateErrors, type AlertRulesUpdateResponse, type AlertRulesUpdateResponses, type AlertStatus, type AlertType, type AssembleBody, type AssembleResponse, type AuthAcceptInvitationData, type AuthAcceptInvitationError, type AuthAcceptInvitationErrors, type AuthAcceptInvitationResponse, type AuthAcceptInvitationResponses, type AuthChangePasswordData, type AuthChangePasswordError, type AuthChangePasswordErrors, type AuthChangePasswordResponse, type AuthChangePasswordResponses, type AuthConfirmSsoLinkData, type AuthConfirmSsoLinkError, type AuthConfirmSsoLinkErrors, type AuthConfirmSsoLinkResponse, type AuthConfirmSsoLinkResponses, type AuthGetCurrentUserData, type AuthGetCurrentUserError, type AuthGetCurrentUserErrors, type AuthGetCurrentUserResponse, type AuthGetCurrentUserResponses, type AuthGetInvitationData, type AuthGetInvitationError, type AuthGetInvitationErrors, type AuthGetInvitationResponse, type AuthGetInvitationResponses, type AuthLoginData, type AuthLoginError, type AuthLoginErrors, type AuthLoginResponse, type AuthLoginResponses, type AuthLogoutData, type AuthLogoutResponse, type AuthLogoutResponses, type AuthRegisterData, type AuthRegisterError, type AuthRegisterErrors, type AuthResponse, type AuthSsoCallbackData, type AuthSsoCallbackError, type AuthSsoCallbackErrors, type AuthSsoCallbackResponse, type AuthSsoCallbackResponses, type AuthSsoConfigData, type AuthSsoConfigResponse, type AuthSsoConfigResponses, type AuthSsoLinkData, type AuthSsoLinkError, type AuthSsoLinkErrors, type AuthSsoLinkResponse, type AuthSsoLinkResponses, type AuthSsoStartData, type AuthSsoStartError, type AuthSsoStartErrors, type AuthSsoStartResponse, type AuthSsoStartResponses, type AuthTokenCreatedResponse, type AuthTokenResponse, type AuthUpdateCurrentUserData, type AuthUpdateCurrentUserError, type AuthUpdateCurrentUserErrors, type AuthUpdateCurrentUserResponse, type AuthUpdateCurrentUserResponses, type AuthorizationDecision, type AuthorizationInfo, type AuthorizationRedirect, type AuthorizationRequest, type BookmarkResponse, type BulkDeleteIssues, type BulkDeleteResponse, type BulkUpdateIssues, type BulkUpdateResponse, type ChangePasswordRequest, type CheckInResponse, type CheckInStatus, type ChunkUploadBody, type ChunkUploadOptions, type CleanupCounts, type CleanupFrequency, type CleanupRequest, type CleanupState, type CleanupStatus, type ClientConfig, type ClientOptions, type CodeMapping, type CommentRequest, type ConfirmSsoLinkRequest, type CreateAlertIntegration, type CreateAlertRule, type CreateAuthToken, type CreateGitHubIssue, type CreateInvitation, type CreateMonitor, type CreateProject, type CreateRelease, type CreateUserRequest, Err, type ErrorDetail, type ErrorResponse, type EventDetailResponse, type EventResponse, type EventTimeseriesPoint, type EventsGetBySentryIdData, type EventsGetBySentryIdError, type EventsGetBySentryIdErrors, type EventsGetBySentryIdResponse, type EventsGetBySentryIdResponses, type EventsGetData, type EventsGetError, type EventsGetErrors, type EventsGetResponse, type EventsGetResponses, type EventsListData, type EventsListError, type EventsListErrors, type EventsListResponse, type EventsListResponses, FIELD_ERROR_CODES, type FieldError, type FieldErrorCode, type GenAiBreakdownRow, type GitHubAppInfo, type GitHubInstallation, type GitHubLogin, type GitHubRepository, type GitHubStatus, type GithubCallbackData, type GithubCallbackError, type GithubCallbackErrors, type GithubCreateIssueData, type GithubCreateIssueError, type GithubCreateIssueErrors, type GithubCreateIssueResponse, type GithubCreateIssueResponses, type GithubDeleteProjectRepositoryData, type GithubDeleteProjectRepositoryError, type GithubDeleteProjectRepositoryErrors, type GithubDeleteProjectRepositoryResponse, type GithubDeleteProjectRepositoryResponses, type GithubDisconnectData, type GithubDisconnectError, type GithubDisconnectErrors, type GithubDisconnectResponse, type GithubDisconnectResponses, type GithubGetMyLoginData, type GithubGetMyLoginError, type GithubGetMyLoginErrors, type GithubGetMyLoginResponse, type GithubGetMyLoginResponses, type GithubGetProjectRepositoryData, type GithubGetProjectRepositoryError, type GithubGetProjectRepositoryErrors, type GithubGetProjectRepositoryResponse, type GithubGetProjectRepositoryResponses, type GithubInstalledData, type GithubInstalledError, type GithubInstalledErrors, type GithubIssueData, type GithubIssueError, type GithubIssueErrors, type GithubIssueResponse, type GithubIssueResponses, type GithubLinkIssueData, type GithubLinkIssueError, type GithubLinkIssueErrors, type GithubLinkIssueResponse, type GithubLinkIssueResponses, type GithubManifestData, type GithubManifestError, type GithubManifestErrors, type GithubManifestResponse, type GithubManifestResponses, type GithubPutMyLoginData, type GithubPutMyLoginError, type GithubPutMyLoginErrors, type GithubPutMyLoginResponse, type GithubPutMyLoginResponses, type GithubPutProjectRepositoryData, type GithubPutProjectRepositoryError, type GithubPutProjectRepositoryErrors, type GithubPutProjectRepositoryResponse, type GithubPutProjectRepositoryResponses, type GithubRepositoriesData, type GithubRepositoriesError, type GithubRepositoriesErrors, type GithubRepositoriesResponse, type GithubRepositoriesResponses, type GithubStatusData, type GithubStatusError, type GithubStatusErrors, type GithubStatusResponse, type GithubStatusResponses, type GithubSyncCodeownersData, type GithubSyncCodeownersError, type GithubSyncCodeownersErrors, type GithubSyncCodeownersResponse, type GithubSyncCodeownersResponses, type GithubUnlinkIssueData, type GithubUnlinkIssueError, type GithubUnlinkIssueErrors, type GithubUnlinkIssueResponse, type GithubUnlinkIssueResponses, type GithubWebhookData, type GithubWebhookError, type GithubWebhookErrors, type GithubWebhookResponse, type GithubWebhookResponses, type Grouping, type HealthLivenessData, type HealthLivenessResponse, type HealthLivenessResponses, type HealthReadinessData, type HealthReadinessError, type HealthReadinessErrors, type HealthReadinessResponse, type HealthReadinessResponses, type HealthVersionData, type HealthVersionError, type HealthVersionErrors, type HealthVersionResponse, type HealthVersionResponses, type IntervalUnit, type InvitationInfoResponse, type InvitationResponse, type InvitationsCreateData, type InvitationsCreateError, type InvitationsCreateErrors, type InvitationsCreateResponse, type InvitationsCreateResponses, type InvitationsListData, type InvitationsListError, type InvitationsListErrors, type InvitationsListResponse, type InvitationsListResponses, type InvitationsRevokeData, type InvitationsRevokeError, type InvitationsRevokeErrors, type InvitationsRevokeResponse, type InvitationsRevokeResponses, type IssueAggregates, type IssueFilter, type IssueGitHub, type IssueLink, type IssuePriority, type IssueResponse, type IssueSort, type IssueStatsResponse, type IssueStatsWindow, type IssueStatus, type IssueStatusUpdate, type IssueTagValue, type IssuesBulkDeleteData, type IssuesBulkDeleteError, type IssuesBulkDeleteErrors, type IssuesBulkDeleteResponse, type IssuesBulkDeleteResponses, type IssuesBulkUpdateData, type IssuesBulkUpdateError, type IssuesBulkUpdateErrors, type IssuesBulkUpdateResponse, type IssuesBulkUpdateResponses, type IssuesCreateCommentData, type IssuesCreateCommentError, type IssuesCreateCommentErrors, type IssuesCreateCommentResponse, type IssuesCreateCommentResponses, type IssuesCreateUserReportData, type IssuesCreateUserReportError, type IssuesCreateUserReportErrors, type IssuesCreateUserReportResponse, type IssuesCreateUserReportResponses, type IssuesDeleteData, type IssuesDeleteError, type IssuesDeleteErrors, type IssuesDeleteResponse, type IssuesDeleteResponses, type IssuesGetActivityData, type IssuesGetActivityError, type IssuesGetActivityErrors, type IssuesGetActivityResponse, type IssuesGetActivityResponses, type IssuesGetAggregatesData, type IssuesGetAggregatesError, type IssuesGetAggregatesErrors, type IssuesGetAggregatesResponse, type IssuesGetAggregatesResponses, type IssuesGetData, type IssuesGetError, type IssuesGetErrors, type IssuesGetHashesData, type IssuesGetHashesError, type IssuesGetHashesErrors, type IssuesGetHashesResponse, type IssuesGetHashesResponses, type IssuesGetResponse, type IssuesGetResponses, type IssuesGetStatsData, type IssuesGetStatsError, type IssuesGetStatsErrors, type IssuesGetStatsResponse, type IssuesGetStatsResponses, type IssuesGetTagValuesData, type IssuesGetTagValuesError, type IssuesGetTagValuesErrors, type IssuesGetTagValuesResponse, type IssuesGetTagValuesResponses, type IssuesListData, type IssuesListError, type IssuesListErrors, type IssuesListResponse, type IssuesListResponses, type IssuesListUserReportsData, type IssuesListUserReportsError, type IssuesListUserReportsErrors, type IssuesListUserReportsResponse, type IssuesListUserReportsResponses, type IssuesMarkSeenData, type IssuesMarkSeenError, type IssuesMarkSeenErrors, type IssuesMarkSeenResponse, type IssuesMarkSeenResponses, type IssuesSetBookmarkData, type IssuesSetBookmarkError, type IssuesSetBookmarkErrors, type IssuesSetBookmarkResponse, type IssuesSetBookmarkResponses, type IssuesSetSubscriptionData, type IssuesSetSubscriptionError, type IssuesSetSubscriptionErrors, type IssuesSetSubscriptionResponse, type IssuesSetSubscriptionResponses, type IssuesUpdateData, type IssuesUpdateError, type IssuesUpdateErrors, type IssuesUpdateResponse, type IssuesUpdateResponses, type KindAge, type LinkGitHubIssue, type LivenessResponse, type LogResponse, type LoginRequest, type LogsListData, type LogsListError, type LogsListErrors, type LogsListResponse, type LogsListResponses, type ManifestRequest, type ManifestResponse, type McpSettings, type McpStatus, type MembersListData, type MembersListError, type MembersListErrors, type MembersListResponse, type MembersListResponses, type MembersRemoveData, type MembersRemoveError, type MembersRemoveErrors, type MembersRemoveResponse, type MembersRemoveResponses, type MembersUpsertData, type MembersUpsertError, type MembersUpsertErrors, type MembersUpsertResponse, type MembersUpsertResponses, type MetricDelta, type MonitorConfig, type MonitorConfigInput, type MonitorEnvironmentResponse, type MonitorEnvironmentStatus, type MonitorResponse, type MonitorsCreateData, type MonitorsCreateError, type MonitorsCreateErrors, type MonitorsCreateResponse, type MonitorsCreateResponses, type MonitorsDeleteData, type MonitorsDeleteError, type MonitorsDeleteErrors, type MonitorsDeleteResponse, type MonitorsDeleteResponses, type MonitorsGetData, type MonitorsGetError, type MonitorsGetErrors, type MonitorsGetResponse, type MonitorsGetResponses, type MonitorsListCheckinsData, type MonitorsListCheckinsError, type MonitorsListCheckinsErrors, type MonitorsListCheckinsResponse, type MonitorsListCheckinsResponses, type MonitorsListData, type MonitorsListError, type MonitorsListErrors, type MonitorsListResponse, type MonitorsListResponses, type MonitorsUpdateData, type MonitorsUpdateError, type MonitorsUpdateErrors, type MonitorsUpdateResponse, type MonitorsUpdateResponses, NETWORK_ERROR_MESSAGE, type OAuthGrant, type OauthDecideAuthorizationData, type OauthDecideAuthorizationError, type OauthDecideAuthorizationErrors, type OauthDecideAuthorizationResponse, type OauthDecideAuthorizationResponses, type OauthGetAuthorizationData, type OauthGetAuthorizationError, type OauthGetAuthorizationErrors, type OauthGetAuthorizationResponse, type OauthGetAuthorizationResponses, type OauthListGrantsData, type OauthListGrantsError, type OauthListGrantsErrors, type OauthListGrantsResponse, type OauthListGrantsResponses, type OauthRevokeGrantData, type OauthRevokeGrantError, type OauthRevokeGrantErrors, type OauthRevokeGrantResponse, type OauthRevokeGrantResponses, Ok, type OrgDetails, type PreviewSchedule, type PreviewTemplateBody, type PreviewTemplateResponse, type ProjectAge, type ProjectListStats, type ProjectMember, type ProjectMemberResponse, type ProjectRepository, type ProjectResponse, type ProjectRetention, type ProjectRole, type ProjectStatsSummary, type ProjectStorage, type ProjectsCreateData, type ProjectsCreateError, type ProjectsCreateErrors, type ProjectsCreateResponse, type ProjectsCreateResponses, type ProjectsDeleteData, type ProjectsDeleteError, type ProjectsDeleteErrors, type ProjectsDeleteResponse, type ProjectsDeleteResponses, type ProjectsGetData, type ProjectsGetError, type ProjectsGetErrors, type ProjectsGetRateLimitsData, type ProjectsGetRateLimitsError, type ProjectsGetRateLimitsErrors, type ProjectsGetRateLimitsResponse, type ProjectsGetRateLimitsResponses, type ProjectsGetResponse, type ProjectsGetResponses, type ProjectsListData, type ProjectsListError, type ProjectsListErrors, type ProjectsListResponse, type ProjectsListResponses, type ProjectsUpdateData, type ProjectsUpdateError, type ProjectsUpdateErrors, type ProjectsUpdateResponse, type ProjectsUpdateResponses, type ProviderType, type RateLimitsResponse, type ReadinessChecks, type ReadinessResponse, type ReleaseHealthRow, type ReleaseResponse, type ReleasesCreateData, type ReleasesCreateError, type ReleasesCreateErrors, type ReleasesCreateResponse, type ReleasesCreateResponses, type ReleasesFinalizeData, type ReleasesFinalizeError, type ReleasesFinalizeErrors, type ReleasesFinalizeResponse, type ReleasesFinalizeResponses, type ReleasesNewIssuesData, type ReleasesNewIssuesErrors, type ReleasesNewIssuesResponse, type ReleasesNewIssuesResponses, type RepoCommit, type Result, type RetentionResponse, type RetentionRun, type RetentionSettings, type RetentionWindows, RustrakClient, type RustrakError, type RustrakErrorKind, SERVER_ERROR_MESSAGE, type Schedule, type SchedulePreview, type SchedulesPreviewData, type SchedulesPreviewError, type SchedulesPreviewErrors, type SchedulesPreviewResponse, type SchedulesPreviewResponses, type SeenResponse, type SessionSummary, type SessionTimeseriesPoint, type SessionsGetStatsData, type SessionsGetStatsErrors, type SessionsGetStatsResponse, type SessionsGetStatsResponses, type SessionsGetSummaryData, type SessionsGetSummaryErrors, type SessionsGetSummaryResponse, type SessionsGetSummaryResponses, type SessionsGetTimeseriesData, type SessionsGetTimeseriesErrors, type SessionsGetTimeseriesResponse, type SessionsGetTimeseriesResponses, type SettingsGetMcpData, type SettingsGetMcpError, type SettingsGetMcpErrors, type SettingsGetMcpResponse, type SettingsGetMcpResponses, type SettingsUpdateMcpData, type SettingsUpdateMcpError, type SettingsUpdateMcpErrors, type SettingsUpdateMcpResponse, type SettingsUpdateMcpResponses, type SortOrder, type SourceMapFile, type SourceMapGcResult, type SourceMapList, type SourceMapStorage, type SourceMapsArtifactBundleAssembleData, type SourceMapsArtifactBundleAssembleError, type SourceMapsArtifactBundleAssembleErrors, type SourceMapsArtifactBundleAssembleResponse, type SourceMapsArtifactBundleAssembleResponses, type SourceMapsChunkUploadCapabilityData, type SourceMapsChunkUploadCapabilityError, type SourceMapsChunkUploadCapabilityErrors, type SourceMapsChunkUploadCapabilityResponse, type SourceMapsChunkUploadCapabilityResponses, type SourceMapsChunkUploadData, type SourceMapsChunkUploadError, type SourceMapsChunkUploadErrors, type SourceMapsChunkUploadResponses, type SourceMapsListData, type SourceMapsListError, type SourceMapsListErrors, type SourceMapsListResponse, type SourceMapsListResponses, type SourceMapsOrgDetailsData, type SourceMapsOrgDetailsResponse, type SourceMapsOrgDetailsResponses, type SpanDetailResponse, type SpanResponse, type SpansGetData, type SpansGetError, type SpansGetErrors, type SpansGetResponse, type SpansGetResponses, type SpansListData, type SpansListError, type SpansListErrors, type SpansListResponse, type SpansListResponses, type SsoConfigResponse, type SsoLinkResponse, type SsoStartResponse, type StatsGetEventTimeseriesData, type StatsGetEventTimeseriesErrors, type StatsGetEventTimeseriesResponse, type StatsGetEventTimeseriesResponses, type StatsGetSummaryData, type StatsGetSummaryErrors, type StatsGetSummaryResponse, type StatsGetSummaryResponses, type StorageAge, type StorageExecuteCleanupData, type StorageExecuteCleanupError, type StorageExecuteCleanupErrors, type StorageExecuteCleanupResponse, type StorageExecuteCleanupResponses, type StorageGcSourceMapsData, type StorageGcSourceMapsError, type StorageGcSourceMapsErrors, type StorageGcSourceMapsResponse, type StorageGcSourceMapsResponses, type StorageGetAgeData, type StorageGetAgeError, type StorageGetAgeErrors, type StorageGetAgeResponse, type StorageGetAgeResponses, type StorageGetCleanupStatusData, type StorageGetCleanupStatusError, type StorageGetCleanupStatusErrors, type StorageGetCleanupStatusResponse, type StorageGetCleanupStatusResponses, type StorageGetProjectsData, type StorageGetProjectsError, type StorageGetProjectsErrors, type StorageGetProjectsResponse, type StorageGetProjectsResponses, type StorageGetRetentionData, type StorageGetRetentionError, type StorageGetRetentionErrors, type StorageGetRetentionResponse, type StorageGetRetentionResponses, type StorageGetSummaryData, type StorageGetSummaryError, type StorageGetSummaryErrors, type StorageGetSummaryResponse, type StorageGetSummaryResponses, type StoragePreviewCleanupData, type StoragePreviewCleanupError, type StoragePreviewCleanupErrors, type StoragePreviewCleanupResponse, type StoragePreviewCleanupResponses, type StoragePreviewRetentionData, type StoragePreviewRetentionError, type StoragePreviewRetentionErrors, type StoragePreviewRetentionResponse, type StoragePreviewRetentionResponses, type StoragePreviewSourceMapGcData, type StoragePreviewSourceMapGcError, type StoragePreviewSourceMapGcErrors, type StoragePreviewSourceMapGcResponse, type StoragePreviewSourceMapGcResponses, type StorageRunRetentionData, type StorageRunRetentionError, type StorageRunRetentionErrors, type StorageRunRetentionResponse, type StorageRunRetentionResponses, type StorageSummary, type StorageUpdateRetentionData, type StorageUpdateRetentionError, type StorageUpdateRetentionErrors, type StorageUpdateRetentionResponse, type StorageUpdateRetentionResponses, type SubscriptionResponse, TIMEOUT_ERROR_MESSAGE, type TagSummary, type TagValueCount, type TeamDeleteUserData, type TeamDeleteUserError, type TeamDeleteUserErrors, type TeamDeleteUserResponse, type TeamDeleteUserResponses, type TeamListData, type TeamListError, type TeamListErrors, type TeamListResponse, type TeamListResponses, type TeamMemberResponse, type TeamUpdateRoleData, type TeamUpdateRoleError, type TeamUpdateRoleErrors, type TeamUpdateRoleResponse, type TeamUpdateRoleResponses, type TelemetryPreview, type TelemetryPreviewData, type TelemetryPreviewError, type TelemetryPreviewErrors, type TelemetryPreviewResponse, type TelemetryPreviewResponses, type TestChannelResponse, type TestIntegrationBody, type ToggleRequest, type TokensCreateData, type TokensCreateError, type TokensCreateErrors, type TokensCreateResponse, type TokensCreateResponses, type TokensDeleteData, type TokensDeleteError, type TokensDeleteErrors, type TokensDeleteResponse, type TokensDeleteResponses, type TokensGetData, type TokensGetError, type TokensGetErrors, type TokensGetResponse, type TokensGetResponses, type TokensListData, type TokensListError, type TokensListErrors, type TokensListResponse, type TokensListResponses, type TransactionDetailResponse, type TransactionResponse, type TransactionStatsResponse, type TransactionsGetData, type TransactionsGetError, type TransactionsGetErrors, type TransactionsGetResponse, type TransactionsGetResponses, type TransactionsGetSpansData, type TransactionsGetSpansError, type TransactionsGetSpansErrors, type TransactionsGetSpansResponse, type TransactionsGetSpansResponses, type TransactionsGetStatGroupData, type TransactionsGetStatGroupError, type TransactionsGetStatGroupErrors, type TransactionsGetStatGroupResponse, type TransactionsGetStatGroupResponses, type TransactionsGetStatsData, type TransactionsGetStatsError, type TransactionsGetStatsErrors, type TransactionsGetStatsResponse, type TransactionsGetStatsResponses, type TransactionsListData, type TransactionsListError, type TransactionsListErrors, type TransactionsListResponse, type TransactionsListResponses, type UpdateAlertIntegration, type UpdateAlertRule, type UpdateIssueState, type UpdateMonitor, type UpdatePreferencesRequest, type UpdateProject, type UpdateProjectRepository, type UpdateRelease, type UpdateUserRole, type UpsertProjectMember, type UserReport, type UserReportRequest, type UserResponse, type UserRole, type VersionResponse, isRetryable, mapResult, unwrap, unwrapOr };
package/dist/index.mjs ADDED
@@ -0,0 +1,4 @@
1
+ import { Err, Ok, mapResult, unwrap, unwrapOr } from "./result.mjs";
2
+ import { FIELD_ERROR_CODES, NETWORK_ERROR_MESSAGE, SERVER_ERROR_MESSAGE, TIMEOUT_ERROR_MESSAGE, isRetryable } from "./errors.mjs";
3
+ import { RustrakClient } from "./client.mjs";
4
+ export { Err, FIELD_ERROR_CODES, NETWORK_ERROR_MESSAGE, Ok, RustrakClient, SERVER_ERROR_MESSAGE, TIMEOUT_ERROR_MESSAGE, isRetryable, mapResult, unwrap, unwrapOr };
@@ -0,0 +1,59 @@
1
+ //#region src/result.ts
2
+ /** Wrap a value as a successful `Result`. */
3
+ function Ok(data) {
4
+ return {
5
+ success: true,
6
+ data
7
+ };
8
+ }
9
+ /** Wrap an error as a failed `Result`. */
10
+ function Err(error) {
11
+ return {
12
+ success: false,
13
+ error
14
+ };
15
+ }
16
+ /**
17
+ * Get the value, throwing if the `Result` is a failure.
18
+ *
19
+ * This is the caller explicitly opting back into exceptions. Nothing inside the
20
+ * client calls it.
21
+ */
22
+ function unwrap(result) {
23
+ if (result.success) return result.data;
24
+ throw new Error(`unwrap() called on a failed Result: ${describe(result.error)}`);
25
+ }
26
+ /**
27
+ * Get the value, or `fallback` if the `Result` is a failure.
28
+ *
29
+ * **Do not use this to render a UI.** `unwrapOr(await client.projects.list(),
30
+ * [])` collapses "this account has no projects" and "the server is unreachable"
31
+ * into the same empty state, which is exactly the regression the `Result` API
32
+ * exists to make impossible: the failure is discarded one line after it was
33
+ * produced, and nothing downstream can tell there was one.
34
+ *
35
+ * It is appropriate where the fallback is genuinely correct regardless of why
36
+ * the call failed: a cached-count optimisation, a best-effort telemetry read, a
37
+ * script that already logged the error. Anywhere a human sees the outcome,
38
+ * branch on `result.success` and read `error.kind`.
39
+ */
40
+ function unwrapOr(result, fallback) {
41
+ return result.success ? result.data : fallback;
42
+ }
43
+ /** Apply `fn` to the value of a successful `Result`, passing failures through. */
44
+ function mapResult(result, fn) {
45
+ return result.success ? Ok(fn(result.data)) : result;
46
+ }
47
+ /** Best-effort rendering of an unknown error value for `unwrap`'s message. */
48
+ function describe(error) {
49
+ if (typeof error === "object" && error !== null && "message" in error && typeof error.message === "string") return error.message;
50
+ return String(error);
51
+ }
52
+ //#endregion
53
+ exports.Err = Err;
54
+ exports.Ok = Ok;
55
+ exports.mapResult = mapResult;
56
+ exports.unwrap = unwrap;
57
+ exports.unwrapOr = unwrapOr;
58
+
59
+ //# sourceMappingURL=result.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.cjs","names":[],"sources":["../src/result.ts"],"sourcesContent":["/**\n * `Result` is how `@rustrak/client` reports an expected failure.\n *\n * The shape deliberately mirrors Zod's `safeParse`: discriminant `success`,\n * payload `data`. Everything inside is a plain object with `Object.prototype`,\n * no class instances and no methods, because React's Flight serializer refuses\n * to send anything else across the server/client boundary. Operations are\n * standalone functions for the same reason.\n */\nexport type Result<T, E> =\n | { readonly success: true; readonly data: T }\n | { readonly success: false; readonly error: E };\n\n/** Wrap a value as a successful `Result`. */\nexport function Ok<T>(data: T): Result<T, never> {\n return { success: true, data };\n}\n\n/** Wrap an error as a failed `Result`. */\nexport function Err<E>(error: E): Result<never, E> {\n return { success: false, error };\n}\n\n/**\n * Get the value, throwing if the `Result` is a failure.\n *\n * This is the caller explicitly opting back into exceptions. Nothing inside the\n * client calls it.\n */\nexport function unwrap<T, E>(result: Result<T, E>): T {\n if (result.success) {\n return result.data;\n }\n throw new Error(\n `unwrap() called on a failed Result: ${describe(result.error)}`,\n );\n}\n\n/**\n * Get the value, or `fallback` if the `Result` is a failure.\n *\n * **Do not use this to render a UI.** `unwrapOr(await client.projects.list(),\n * [])` collapses \"this account has no projects\" and \"the server is unreachable\"\n * into the same empty state, which is exactly the regression the `Result` API\n * exists to make impossible: the failure is discarded one line after it was\n * produced, and nothing downstream can tell there was one.\n *\n * It is appropriate where the fallback is genuinely correct regardless of why\n * the call failed: a cached-count optimisation, a best-effort telemetry read, a\n * script that already logged the error. Anywhere a human sees the outcome,\n * branch on `result.success` and read `error.kind`.\n */\nexport function unwrapOr<T, E>(result: Result<T, E>, fallback: T): T {\n return result.success ? result.data : fallback;\n}\n\n/** Apply `fn` to the value of a successful `Result`, passing failures through. */\nexport function mapResult<T, U, E>(\n result: Result<T, E>,\n fn: (value: T) => U,\n): Result<U, E> {\n return result.success ? Ok(fn(result.data)) : result;\n}\n\n/** Best-effort rendering of an unknown error value for `unwrap`'s message. */\nfunction describe(error: unknown): string {\n if (\n typeof error === 'object' &&\n error !== null &&\n 'message' in error &&\n typeof (error as { message: unknown }).message === 'string'\n ) {\n return (error as { message: string }).message;\n }\n return String(error);\n}\n"],"mappings":";;AAcA,SAAgB,GAAM,MAA2B;CAC/C,OAAO;EAAE,SAAS;EAAM;CAAK;AAC/B;;AAGA,SAAgB,IAAO,OAA4B;CACjD,OAAO;EAAE,SAAS;EAAO;CAAM;AACjC;;;;;;;AAQA,SAAgB,OAAa,QAAyB;CACpD,IAAI,OAAO,SACT,OAAO,OAAO;CAEhB,MAAM,IAAI,MACR,uCAAuC,SAAS,OAAO,KAAK,GAC9D;AACF;;;;;;;;;;;;;;;AAgBA,SAAgB,SAAe,QAAsB,UAAgB;CACnE,OAAO,OAAO,UAAU,OAAO,OAAO;AACxC;;AAGA,SAAgB,UACd,QACA,IACc;CACd,OAAO,OAAO,UAAU,GAAG,GAAG,OAAO,IAAI,CAAC,IAAI;AAChD;;AAGA,SAAS,SAAS,OAAwB;CACxC,IACE,OAAO,UAAU,YACjB,UAAU,QACV,aAAa,SACb,OAAQ,MAA+B,YAAY,UAEnD,OAAQ,MAA8B;CAExC,OAAO,OAAO,KAAK;AACrB"}
@@ -0,0 +1,15 @@
1
+ //#region src/result.d.ts
2
+ export type Result<T, E> = {
3
+ readonly success: true;
4
+ readonly data: T;
5
+ } | {
6
+ readonly success: false;
7
+ readonly error: E;
8
+ };
9
+ export declare function Ok<T>(data: T): Result<T, never>;
10
+ export declare function Err<E>(error: E): Result<never, E>;
11
+ export declare function unwrap<T, E>(result: Result<T, E>): T;
12
+ export declare function unwrapOr<T, E>(result: Result<T, E>, fallback: T): T;
13
+ export declare function mapResult<T, U, E>(result: Result<T, E>, fn: (value: T) => U): Result<U, E>;
14
+ //#endregion
15
+ //# sourceMappingURL=result.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.d.cts","names":[],"sources":["../src/result.ts"],"mappings":";YASY,OAAO,GAAG;WACP;WAAwB,MAAM;;WAC9B;WAAyB,OAAO;;wBAG/B,GAAG,GAAG,MAAM,IAAI,OAAO;wBAKvB,IAAI,GAAG,OAAO,IAAI,cAAc;wBAUhC,OAAO,GAAG,GAAG,QAAQ,OAAO,GAAG,KAAK;wBAuBpC,SAAS,GAAG,GAAG,QAAQ,OAAO,GAAG,IAAI,UAAU,IAAI;wBAKnD,UAAU,GAAG,GAAG,GAC9B,QAAQ,OAAO,GAAG,IAClB,KAAK,OAAO,MAAM,IACjB,OAAO,GAAG"}
@@ -0,0 +1,15 @@
1
+ //#region src/result.d.ts
2
+ export type Result<T, E> = {
3
+ readonly success: true;
4
+ readonly data: T;
5
+ } | {
6
+ readonly success: false;
7
+ readonly error: E;
8
+ };
9
+ export declare function Ok<T>(data: T): Result<T, never>;
10
+ export declare function Err<E>(error: E): Result<never, E>;
11
+ export declare function unwrap<T, E>(result: Result<T, E>): T;
12
+ export declare function unwrapOr<T, E>(result: Result<T, E>, fallback: T): T;
13
+ export declare function mapResult<T, U, E>(result: Result<T, E>, fn: (value: T) => U): Result<U, E>;
14
+ //#endregion
15
+ //# sourceMappingURL=result.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.d.mts","names":[],"sources":["../src/result.ts"],"mappings":";YASY,OAAO,GAAG;WACP;WAAwB,MAAM;;WAC9B;WAAyB,OAAO;;wBAG/B,GAAG,GAAG,MAAM,IAAI,OAAO;wBAKvB,IAAI,GAAG,OAAO,IAAI,cAAc;wBAUhC,OAAO,GAAG,GAAG,QAAQ,OAAO,GAAG,KAAK;wBAuBpC,SAAS,GAAG,GAAG,QAAQ,OAAO,GAAG,IAAI,UAAU,IAAI;wBAKnD,UAAU,GAAG,GAAG,GAC9B,QAAQ,OAAO,GAAG,IAClB,KAAK,OAAO,MAAM,IACjB,OAAO,GAAG"}
@@ -0,0 +1,55 @@
1
+ //#region src/result.ts
2
+ /** Wrap a value as a successful `Result`. */
3
+ function Ok(data) {
4
+ return {
5
+ success: true,
6
+ data
7
+ };
8
+ }
9
+ /** Wrap an error as a failed `Result`. */
10
+ function Err(error) {
11
+ return {
12
+ success: false,
13
+ error
14
+ };
15
+ }
16
+ /**
17
+ * Get the value, throwing if the `Result` is a failure.
18
+ *
19
+ * This is the caller explicitly opting back into exceptions. Nothing inside the
20
+ * client calls it.
21
+ */
22
+ function unwrap(result) {
23
+ if (result.success) return result.data;
24
+ throw new Error(`unwrap() called on a failed Result: ${describe(result.error)}`);
25
+ }
26
+ /**
27
+ * Get the value, or `fallback` if the `Result` is a failure.
28
+ *
29
+ * **Do not use this to render a UI.** `unwrapOr(await client.projects.list(),
30
+ * [])` collapses "this account has no projects" and "the server is unreachable"
31
+ * into the same empty state, which is exactly the regression the `Result` API
32
+ * exists to make impossible: the failure is discarded one line after it was
33
+ * produced, and nothing downstream can tell there was one.
34
+ *
35
+ * It is appropriate where the fallback is genuinely correct regardless of why
36
+ * the call failed: a cached-count optimisation, a best-effort telemetry read, a
37
+ * script that already logged the error. Anywhere a human sees the outcome,
38
+ * branch on `result.success` and read `error.kind`.
39
+ */
40
+ function unwrapOr(result, fallback) {
41
+ return result.success ? result.data : fallback;
42
+ }
43
+ /** Apply `fn` to the value of a successful `Result`, passing failures through. */
44
+ function mapResult(result, fn) {
45
+ return result.success ? Ok(fn(result.data)) : result;
46
+ }
47
+ /** Best-effort rendering of an unknown error value for `unwrap`'s message. */
48
+ function describe(error) {
49
+ if (typeof error === "object" && error !== null && "message" in error && typeof error.message === "string") return error.message;
50
+ return String(error);
51
+ }
52
+ //#endregion
53
+ export { Err, Ok, mapResult, unwrap, unwrapOr };
54
+
55
+ //# sourceMappingURL=result.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.mjs","names":[],"sources":["../src/result.ts"],"sourcesContent":["/**\n * `Result` is how `@rustrak/client` reports an expected failure.\n *\n * The shape deliberately mirrors Zod's `safeParse`: discriminant `success`,\n * payload `data`. Everything inside is a plain object with `Object.prototype`,\n * no class instances and no methods, because React's Flight serializer refuses\n * to send anything else across the server/client boundary. Operations are\n * standalone functions for the same reason.\n */\nexport type Result<T, E> =\n | { readonly success: true; readonly data: T }\n | { readonly success: false; readonly error: E };\n\n/** Wrap a value as a successful `Result`. */\nexport function Ok<T>(data: T): Result<T, never> {\n return { success: true, data };\n}\n\n/** Wrap an error as a failed `Result`. */\nexport function Err<E>(error: E): Result<never, E> {\n return { success: false, error };\n}\n\n/**\n * Get the value, throwing if the `Result` is a failure.\n *\n * This is the caller explicitly opting back into exceptions. Nothing inside the\n * client calls it.\n */\nexport function unwrap<T, E>(result: Result<T, E>): T {\n if (result.success) {\n return result.data;\n }\n throw new Error(\n `unwrap() called on a failed Result: ${describe(result.error)}`,\n );\n}\n\n/**\n * Get the value, or `fallback` if the `Result` is a failure.\n *\n * **Do not use this to render a UI.** `unwrapOr(await client.projects.list(),\n * [])` collapses \"this account has no projects\" and \"the server is unreachable\"\n * into the same empty state, which is exactly the regression the `Result` API\n * exists to make impossible: the failure is discarded one line after it was\n * produced, and nothing downstream can tell there was one.\n *\n * It is appropriate where the fallback is genuinely correct regardless of why\n * the call failed: a cached-count optimisation, a best-effort telemetry read, a\n * script that already logged the error. Anywhere a human sees the outcome,\n * branch on `result.success` and read `error.kind`.\n */\nexport function unwrapOr<T, E>(result: Result<T, E>, fallback: T): T {\n return result.success ? result.data : fallback;\n}\n\n/** Apply `fn` to the value of a successful `Result`, passing failures through. */\nexport function mapResult<T, U, E>(\n result: Result<T, E>,\n fn: (value: T) => U,\n): Result<U, E> {\n return result.success ? Ok(fn(result.data)) : result;\n}\n\n/** Best-effort rendering of an unknown error value for `unwrap`'s message. */\nfunction describe(error: unknown): string {\n if (\n typeof error === 'object' &&\n error !== null &&\n 'message' in error &&\n typeof (error as { message: unknown }).message === 'string'\n ) {\n return (error as { message: string }).message;\n }\n return String(error);\n}\n"],"mappings":";;AAcA,SAAgB,GAAM,MAA2B;CAC/C,OAAO;EAAE,SAAS;EAAM;CAAK;AAC/B;;AAGA,SAAgB,IAAO,OAA4B;CACjD,OAAO;EAAE,SAAS;EAAO;CAAM;AACjC;;;;;;;AAQA,SAAgB,OAAa,QAAyB;CACpD,IAAI,OAAO,SACT,OAAO,OAAO;CAEhB,MAAM,IAAI,MACR,uCAAuC,SAAS,OAAO,KAAK,GAC9D;AACF;;;;;;;;;;;;;;;AAgBA,SAAgB,SAAe,QAAsB,UAAgB;CACnE,OAAO,OAAO,UAAU,OAAO,OAAO;AACxC;;AAGA,SAAgB,UACd,QACA,IACc;CACd,OAAO,OAAO,UAAU,GAAG,GAAG,OAAO,IAAI,CAAC,IAAI;AAChD;;AAGA,SAAS,SAAS,OAAwB;CACxC,IACE,OAAO,UAAU,YACjB,UAAU,QACV,aAAa,SACb,OAAQ,MAA+B,YAAY,UAEnD,OAAQ,MAA8B;CAExC,OAAO,OAAO,KAAK;AACrB"}
@@ -0,0 +1,339 @@
1
+ const require_errors = require("../errors.cjs");
2
+ //#region src/utils/http.ts
3
+ /**
4
+ * Internal carrier for a transport failure travelling out of `fetch`.
5
+ *
6
+ * `fetch` signals "no response" by rejecting with a `TypeError`, which is also
7
+ * what a genuine bug throws. {@link createFetch} wraps the rejections it
8
+ * recognises in this class so the `Result` boundary in `client.ts` can tell
9
+ * the two apart: this becomes an `Err`, anything else keeps propagating.
10
+ *
11
+ * Never exported from `src/index.ts`.
12
+ */
13
+ var RustrakTransportFailure = class extends Error {
14
+ rustrakError;
15
+ constructor(error) {
16
+ super(error.message);
17
+ this.name = "RustrakTransportFailure";
18
+ this.rustrakError = error;
19
+ }
20
+ };
21
+ /** Narrow a caught value to the internal carrier. */
22
+ function isTransportFailure(value) {
23
+ return value instanceof RustrakTransportFailure;
24
+ }
25
+ /**
26
+ * Read the human-readable message out of an error body.
27
+ *
28
+ * Two shapes are live: every `AppError` sends `{error: {type, message}}` while
29
+ * the ingest rate limiter sends a flat `{error: "..."}`. Reading only the flat
30
+ * one turned every structured error into "[object Object]". See #204.
31
+ */
32
+ function readErrorMessage(body, status) {
33
+ const fallback = `HTTP ${status} error`;
34
+ if (body && typeof body === "object") {
35
+ const { error, message } = body;
36
+ return (typeof error === "object" ? error?.message : error) || message || fallback;
37
+ }
38
+ return fallback;
39
+ }
40
+ const KNOWN_FIELD_ERROR_CODES = new Set(require_errors.FIELD_ERROR_CODES);
41
+ function isFieldErrorCode(value) {
42
+ return typeof value === "string" && KNOWN_FIELD_ERROR_CODES.has(value);
43
+ }
44
+ /**
45
+ * Codes already reported by {@link warnUnknownFieldErrorCode}.
46
+ *
47
+ * Module-scoped so a list page rendering fifty rows against a newer server
48
+ * logs once per unknown code rather than once per row. Version skew does not
49
+ * change within a process, so once is the whole signal.
50
+ */
51
+ const warnedFieldErrorCodes = /* @__PURE__ */ new Set();
52
+ /**
53
+ * Make an unrecognised `code` visible without admitting it into the union.
54
+ *
55
+ * Dropping the entry is correct (see {@link readFieldErrors}), but a silent
56
+ * drop is indistinguishable from "the server named no field": a client one
57
+ * release behind a server that added a code loses every inline form error
58
+ * site-wide with nothing anywhere to explain it.
59
+ *
60
+ * `console.warn` is the least intrusive mechanism that a support engineer can
61
+ * actually act on. It needs no change to the public type, so no consumer has
62
+ * to opt in to see it; it lands in the browser devtools console in a client
63
+ * component and on stdout of the Node process (and therefore in whatever log
64
+ * aggregation already exists) in a Server Component. The alternatives were
65
+ * worse: throwing turns a cosmetic degradation into an outage, admitting the
66
+ * code breaks the closed union this drop exists to protect, and a new
67
+ * `fieldsDropped` flag on the union is invisible until somebody thinks to read
68
+ * it, which is the same silence in a new place.
69
+ */
70
+ function warnUnknownFieldErrorCode(code, field) {
71
+ if (warnedFieldErrorCodes.has(code)) return;
72
+ warnedFieldErrorCodes.add(code);
73
+ console.warn(`[@rustrak/client] Dropped a field error with an unrecognised code "${code}" (field "${field}"). This client build does not know that code, so the affected inputs degrade to a form-level error. The server is most likely newer than @rustrak/client; upgrade the client to match the server version.`);
74
+ }
75
+ /**
76
+ * Read `error.fields` out of an `AppError` body.
77
+ *
78
+ * Returns `undefined` rather than `[]` when there is nothing usable, so the
79
+ * key stays absent on the `RustrakError` and a consumer can test for it.
80
+ *
81
+ * Entries are validated one by one and a malformed or unrecognised one is
82
+ * dropped, never coerced. `FieldErrorCode` is a closed union: admitting a code
83
+ * this build has never heard of would hand a consumer a value its own
84
+ * exhaustive `switch` cannot see. A newer server adding a code therefore
85
+ * degrades to a form-level error here, which is the same place an older client
86
+ * already lands, and is announced once via
87
+ * {@link warnUnknownFieldErrorCode} so the skew is not silent.
88
+ *
89
+ * `message` survives only alongside `code: 'custom'`. The server enforces the
90
+ * same rule at construction, but the docs on both sides tell consumers to
91
+ * select translated copy from `(field, code)` for every other code, so a
92
+ * `message` that reaches them there is untranslatable English a careless
93
+ * consumer would render. Dropping it here makes the rule true of the value, not
94
+ * only of its producer.
95
+ */
96
+ /**
97
+ * Read `error.incident_id` out of a 5xx `AppError` body.
98
+ *
99
+ * The one thing a 500 is willing to say about itself. `error_response` replaced
100
+ * its `Display` with a fixed string so a `sqlx::Error`'s constraint and column
101
+ * names stay off the wire (gh-233), and logged the detail under this id; a user
102
+ * quoting it is what lets an operator find that line.
103
+ *
104
+ * Returns `undefined`, never `null` or `''`, for the three bodies that carry no
105
+ * id: a proxy-generated 502/503, a server older than gh-233, and a 500 whose
106
+ * body is not JSON at all. The caller omits the key entirely in that case, so
107
+ * `'incidentId' in error` stays an honest test.
108
+ */
109
+ function readIncidentId(body) {
110
+ const raw = body && typeof body === "object" ? body.error?.incident_id : void 0;
111
+ return typeof raw === "string" && raw.length > 0 ? raw : void 0;
112
+ }
113
+ function readFieldErrors(body) {
114
+ const raw = body && typeof body === "object" ? body.error?.fields : void 0;
115
+ if (!Array.isArray(raw)) return;
116
+ const fields = raw.flatMap((entry) => readFieldError(entry) ?? []);
117
+ return fields.length > 0 ? fields : void 0;
118
+ }
119
+ /** One entry of `error.fields`, or `undefined` when it is unusable. */
120
+ function readFieldError(entry) {
121
+ if (typeof entry !== "object" || entry === null) return void 0;
122
+ const { field, code, message } = entry;
123
+ if (typeof field !== "string") return void 0;
124
+ if (!isFieldErrorCode(code)) {
125
+ if (typeof code === "string") warnUnknownFieldErrorCode(code, field);
126
+ return;
127
+ }
128
+ return code === "custom" && typeof message === "string" ? {
129
+ field,
130
+ code,
131
+ message
132
+ } : {
133
+ field,
134
+ code
135
+ };
136
+ }
137
+ /**
138
+ * `Retry-After` in seconds, when the server sent a parseable one.
139
+ *
140
+ * RFC 9110 §10.2.3 allows two forms and a proxy in front of the Rust process
141
+ * may send either. `Number.parseInt` read only the first, and read it too
142
+ * loosely: it dropped the HTTP-date form entirely as `NaN`, and it returned
143
+ * `-5` from `-5` and `3` from `3abc`, both of which a consumer would pass
144
+ * straight to `setTimeout`.
145
+ *
146
+ * A date already in the past yields `0`, meaning "retry now", which is the
147
+ * literal reading of the header.
148
+ */
149
+ function readRetryAfter(response) {
150
+ const header = response.headers.get("Retry-After")?.trim();
151
+ if (!header) return;
152
+ if (/^\d+$/.test(header)) return Number.parseInt(header, 10);
153
+ if (/^[+-]\d+$/.test(header)) return;
154
+ const date = Date.parse(header);
155
+ if (Number.isNaN(date)) return;
156
+ return Math.max(0, Math.ceil((date - Date.now()) / 1e3));
157
+ }
158
+ /**
159
+ * Attach `fields` to an error, or leave the key off entirely.
160
+ *
161
+ * The key is omitted rather than set to `undefined` so `'fields' in error`
162
+ * stays an honest test and the object round-trips through `structuredClone`
163
+ * with the same shape it was built with.
164
+ */
165
+ function annotate(base, fields) {
166
+ return fields === void 0 ? base : {
167
+ ...base,
168
+ fields
169
+ };
170
+ }
171
+ /**
172
+ * Map an HTTP status onto a `RustrakError` kind.
173
+ *
174
+ * Total by construction: every 5xx redacts, every other unanticipated status
175
+ * lands on `client_error`, so no status is unrepresentable.
176
+ */
177
+ function transformHttpError(response, body) {
178
+ const status = response.status;
179
+ if (status >= 500) {
180
+ const base = {
181
+ kind: "server_error",
182
+ status,
183
+ message: require_errors.SERVER_ERROR_MESSAGE
184
+ };
185
+ const incidentId = readIncidentId(body);
186
+ return incidentId === void 0 ? base : {
187
+ ...base,
188
+ incidentId
189
+ };
190
+ }
191
+ const message = readErrorMessage(body, status);
192
+ const fields = readFieldErrors(body);
193
+ switch (status) {
194
+ case 400: return annotate({
195
+ kind: "validation",
196
+ status,
197
+ message
198
+ }, fields);
199
+ case 401: return annotate({
200
+ kind: "unauthenticated",
201
+ status,
202
+ message
203
+ }, fields);
204
+ case 403: return annotate({
205
+ kind: "forbidden",
206
+ status,
207
+ message
208
+ }, fields);
209
+ case 404: return annotate({
210
+ kind: "not_found",
211
+ status,
212
+ message
213
+ }, fields);
214
+ case 409: return annotate({
215
+ kind: "conflict",
216
+ status,
217
+ message
218
+ }, fields);
219
+ case 410: return annotate({
220
+ kind: "gone",
221
+ status,
222
+ message
223
+ }, fields);
224
+ case 413: return annotate({
225
+ kind: "payload_too_large",
226
+ status,
227
+ message
228
+ }, fields);
229
+ case 429: {
230
+ const retryAfter = readRetryAfter(response);
231
+ return annotate(retryAfter === void 0 ? {
232
+ kind: "rate_limited",
233
+ status,
234
+ message
235
+ } : {
236
+ kind: "rate_limited",
237
+ status,
238
+ message,
239
+ retryAfter
240
+ }, fields);
241
+ }
242
+ default: return annotate({
243
+ kind: "client_error",
244
+ status,
245
+ message
246
+ }, fields);
247
+ }
248
+ }
249
+ /** Statuses a `Response` may not be constructed with a body for. */
250
+ const NULL_BODY = /* @__PURE__ */ new Set([
251
+ 101,
252
+ 103,
253
+ 204,
254
+ 205,
255
+ 304
256
+ ]);
257
+ /** Statuses worth repeating: the request may well succeed a moment later. */
258
+ const RETRY_STATUSES = /* @__PURE__ */ new Set([
259
+ 408,
260
+ 500,
261
+ 502,
262
+ 503,
263
+ 504
264
+ ]);
265
+ /**
266
+ * Only methods that are safe to send twice. A `POST` that timed out at the
267
+ * proxy may still have created the row, and a second one creates another.
268
+ */
269
+ const RETRY_METHODS = /* @__PURE__ */ new Set([
270
+ "GET",
271
+ "HEAD",
272
+ "PUT",
273
+ "DELETE"
274
+ ]);
275
+ /**
276
+ * The `fetch` every request goes through: timeout, retries, and the line
277
+ * between a transport failure and a bug.
278
+ *
279
+ * The body is read here, inside the same `try` as the request, so a
280
+ * connection that dies halfway through a body is a transport failure like
281
+ * one that never connected, not an error the generated client half-parses.
282
+ *
283
+ * Retries wait 300ms, then 600ms, and so on. A caller's own `AbortSignal`
284
+ * aborting is not a transport failure: it rethrows as the `AbortError` the
285
+ * caller asked for.
286
+ */
287
+ function createFetch(config) {
288
+ const timeout = config.timeout ?? 3e4;
289
+ const maxRetries = config.maxRetries ?? 2;
290
+ return async (input, init) => {
291
+ const request = new Request(input, init);
292
+ const retries = RETRY_METHODS.has(request.method) ? maxRetries : 0;
293
+ for (let n = 0;; n++) {
294
+ const outcome = await attempt(request, timeout);
295
+ const retryable = outcome instanceof Response ? RETRY_STATUSES.has(outcome.status) : outcome.reason === "unreachable";
296
+ if (n < retries && retryable) {
297
+ await sleep(n);
298
+ continue;
299
+ }
300
+ if (outcome instanceof Response) return outcome;
301
+ throw new RustrakTransportFailure(outcome);
302
+ }
303
+ };
304
+ }
305
+ /** One try: the response with its body read, or the failure it ended in. */
306
+ async function attempt(request, timeout) {
307
+ try {
308
+ const response = await fetch(request.clone(), { signal: AbortSignal.any([request.signal, AbortSignal.timeout(timeout)]) });
309
+ const body = await response.arrayBuffer();
310
+ const headers = new Headers(response.headers);
311
+ headers.delete("Content-Length");
312
+ return new Response(NULL_BODY.has(response.status) ? null : body, {
313
+ status: response.status,
314
+ statusText: response.statusText,
315
+ headers
316
+ });
317
+ } catch (error) {
318
+ if (request.signal.aborted) throw error;
319
+ return error instanceof DOMException && error.name === "TimeoutError" ? {
320
+ kind: "network",
321
+ message: require_errors.TIMEOUT_ERROR_MESSAGE,
322
+ reason: "timeout"
323
+ } : {
324
+ kind: "network",
325
+ message: require_errors.NETWORK_ERROR_MESSAGE,
326
+ reason: "unreachable"
327
+ };
328
+ }
329
+ }
330
+ function sleep(attempt) {
331
+ return new Promise((resolve) => setTimeout(resolve, 300 * 2 ** attempt));
332
+ }
333
+ //#endregion
334
+ exports.RustrakTransportFailure = RustrakTransportFailure;
335
+ exports.createFetch = createFetch;
336
+ exports.isTransportFailure = isTransportFailure;
337
+ exports.transformHttpError = transformHttpError;
338
+
339
+ //# sourceMappingURL=http.cjs.map