core.tsx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /**
  2. * Basic types that are required to build types in other type modules.
  3. *
  4. * Before a type is put here it should be required in multiple other types.
  5. * or used in multiple views.
  6. */
  7. import type {getInterval} from 'sentry/components/charts/utils';
  8. import {MenuListItemProps} from 'sentry/components/menuListItem';
  9. import type {ALLOWED_SCOPES} from 'sentry/constants';
  10. /**
  11. * Visual representation of a project/team/organization/user
  12. */
  13. export type Avatar = {
  14. avatarType: 'letter_avatar' | 'upload' | 'gravatar' | 'background' | 'default';
  15. avatarUuid: string | null;
  16. avatarUrl?: string | null;
  17. color?: boolean;
  18. };
  19. export type ObjectStatus =
  20. | 'active'
  21. | 'disabled'
  22. | 'pending_deletion'
  23. | 'deletion_in_progress';
  24. export type Actor = {
  25. id: string;
  26. name: string;
  27. type: 'user' | 'team';
  28. email?: string;
  29. };
  30. export type Scope = (typeof ALLOWED_SCOPES)[number];
  31. export type DateString = Date | string | null;
  32. /**
  33. * Simple timeseries data used in groups, projects and release health.
  34. */
  35. export type TimeseriesValue = [timestamp: number, value: number];
  36. // taken from https://stackoverflow.com/questions/46634876/how-can-i-change-a-readonly-property-in-typescript
  37. export type Writable<T> = {-readonly [K in keyof T]: T[K]};
  38. /**
  39. * The option format used by react-select based components
  40. */
  41. export interface SelectValue<T> extends MenuListItemProps {
  42. value: T;
  43. /**
  44. * In scenarios where you're using a react element as the label react-select
  45. * will be unable to filter to that label. Use this to specify the plain text of
  46. * the label.
  47. */
  48. textValue?: string;
  49. }
  50. /**
  51. * The 'other' option format used by checkboxes, radios and more.
  52. */
  53. export type Choice = [
  54. value: string | number,
  55. label: string | number | React.ReactElement,
  56. ];
  57. export type Choices = Choice[];
  58. /**
  59. * @deprecated in favour of `DataCategoryExact` and `DATA_CATEGORY_INFO`.
  60. * This legacy type used plurals which will cause compatibility issues when categories
  61. * become more complex, e.g. processed transactions, session replays. Instead, access these values
  62. * with `DATA_CATEGORY_INFO[category].plural`, where category is the `DataCategoryExact` enum value.
  63. */
  64. export enum DataCategory {
  65. DEFAULT = 'default',
  66. ERRORS = 'errors',
  67. TRANSACTIONS = 'transactions',
  68. ATTACHMENTS = 'attachments',
  69. PROFILES = 'profiles',
  70. REPLAYS = 'replays',
  71. }
  72. /**
  73. * https://github.com/getsentry/relay/blob/master/relay-common/src/constants.rs
  74. * Matches the backend singular backend enum directly.
  75. * For display variations, refer to `DATA_CATEGORY_INFO` rather than manipulating these strings
  76. */
  77. export enum DataCategoryExact {
  78. ERROR = 'error',
  79. TRANSACTION = 'transaction',
  80. ATTACHMENT = 'attachment',
  81. PROFILE = 'profile',
  82. REPLAY = 'replay',
  83. TRANSACTION_PROCESSED = 'transaction_processed',
  84. TRANSACTION_INDEXED = 'transaction_indexed',
  85. }
  86. export interface DataCategoryInfo {
  87. apiName: string;
  88. displayName: string;
  89. name: DataCategoryExact;
  90. plural: string;
  91. titleName: string;
  92. uid: number;
  93. }
  94. export type EventType = 'error' | 'transaction' | 'attachment';
  95. export enum Outcome {
  96. ACCEPTED = 'accepted',
  97. FILTERED = 'filtered',
  98. INVALID = 'invalid',
  99. DROPPED = 'dropped', // this is not a real outcome coming from the server
  100. RATE_LIMITED = 'rate_limited',
  101. CLIENT_DISCARD = 'client_discard',
  102. }
  103. export type IntervalPeriod = ReturnType<typeof getInterval>;
  104. /**
  105. * Represents a pinned page filter sentinel value
  106. */
  107. export type PinnedPageFilter = 'projects' | 'environments' | 'datetime';
  108. export type PageFilters = {
  109. /**
  110. * Currently selected time filter
  111. */
  112. datetime: {
  113. end: DateString | null;
  114. period: string | null;
  115. start: DateString | null;
  116. utc: boolean | null;
  117. };
  118. /**
  119. * Currently selected environment names
  120. */
  121. environments: string[];
  122. /**
  123. * Currently selected Project IDs
  124. */
  125. projects: number[];
  126. };
  127. type InitialState = {type: 'initial'};
  128. type LoadingState = {type: 'loading'};
  129. type ResolvedState<T> = {
  130. data: T;
  131. type: 'resolved';
  132. };
  133. type ErroredState = {
  134. error: string;
  135. type: 'errored';
  136. };
  137. export type RequestState<T> =
  138. | InitialState
  139. | LoadingState
  140. | ResolvedState<T>
  141. | ErroredState;