core.tsx 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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 type {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. * These are very similar to the plural types of DATA_CATEGORY_INFO.
  60. * DATA_CATEGORY_INFO and DataCategoryExact have additional categories
  61. * that are used in stats but not other places like billing.
  62. */
  63. export enum DataCategory {
  64. ERRORS = 'errors',
  65. TRANSACTIONS = 'transactions',
  66. ATTACHMENTS = 'attachments',
  67. PROFILES = 'profiles',
  68. REPLAYS = 'replays',
  69. MONITOR_SEATS = 'monitorSeats',
  70. PROFILE_DURATION = 'profileDuration',
  71. SPANS = 'spans',
  72. METRIC_SECONDS = 'metricSeconds',
  73. }
  74. /**
  75. * https://github.com/getsentry/relay/blob/master/relay-base-schema/src/data_category.rs
  76. * Matches the backend singular backend enum directly.
  77. * For display variations, refer to `DATA_CATEGORY_INFO` rather than manipulating these strings
  78. */
  79. export enum DataCategoryExact {
  80. ERROR = 'error',
  81. TRANSACTION = 'transaction',
  82. ATTACHMENT = 'attachment',
  83. PROFILE = 'profile',
  84. REPLAY = 'replay',
  85. TRANSACTION_PROCESSED = 'transaction_processed',
  86. TRANSACTION_INDEXED = 'transaction_indexed',
  87. MONITOR = 'monitor',
  88. MONITOR_SEAT = 'monitorSeat',
  89. PROFILE_DURATION = 'profileDuration',
  90. SPAN = 'span',
  91. METRIC_SECOND = 'metricSecond',
  92. }
  93. export interface DataCategoryInfo {
  94. apiName: string;
  95. displayName: string;
  96. name: DataCategoryExact;
  97. plural: string;
  98. titleName: string;
  99. uid: number;
  100. }
  101. export type EventType = 'error' | 'transaction' | 'attachment';
  102. export enum Outcome {
  103. ACCEPTED = 'accepted',
  104. FILTERED = 'filtered',
  105. INVALID = 'invalid',
  106. DROPPED = 'dropped', // this is not a real outcome coming from the server
  107. RATE_LIMITED = 'rate_limited',
  108. CLIENT_DISCARD = 'client_discard',
  109. CARDINALITY_LIMITED = 'cardinality_limited',
  110. }
  111. export type IntervalPeriod = ReturnType<typeof getInterval>;
  112. /**
  113. * Represents a pinned page filter sentinel value
  114. */
  115. export type PinnedPageFilter = 'projects' | 'environments' | 'datetime';
  116. export type PageFilters = {
  117. /**
  118. * Currently selected time filter
  119. */
  120. datetime: {
  121. end: DateString | null;
  122. period: string | null;
  123. start: DateString | null;
  124. utc: boolean | null;
  125. };
  126. /**
  127. * Currently selected environment names
  128. */
  129. environments: string[];
  130. /**
  131. * Currently selected Project IDs
  132. */
  133. projects: number[];
  134. };
  135. type InitialState = {type: 'initial'};
  136. type LoadingState = {type: 'loading'};
  137. type ResolvedState<T> = {
  138. data: T;
  139. type: 'resolved';
  140. };
  141. type ErroredState = {
  142. error: string;
  143. type: 'errored';
  144. };
  145. export type RequestState<T> =
  146. | InitialState
  147. | LoadingState
  148. | ResolvedState<T>
  149. | ErroredState;