SPB Git forge
3commits 1branches 0releases
417.0 KBsize
maindefault branch
10 days agolast push
TypeScript 66.5% Python 30.9% JavaScript 1.4% CSS 0.7%
19.5 KB · 561 lines typescript
Raw Blame History
1/** API contract (FastAPI /api/v1). Numbers coming from Postgres aggregates may arrive as strings — use `num()` from format.ts. */23export type Num = number | string | null;45export interface Meta {6  request_id: string;7  generated_at: string;8  [k: string]: unknown;9}10export interface Envelope<T> {11  data: T;12  meta: Meta;13}14export interface Paginated<T> {15  data: T[];16  pagination: { page: number; page_size: number; total: number; pages: number };17  meta: Meta;18  [k: string]: unknown;19}20export interface Problem {21  title: string;22  detail?: string | null;23  status: number;24}2526export type OrbitClass = 'LEO' | 'MEO' | 'GEO' | 'HEO' | 'OTHER';27export type ObjectType = 'PAYLOAD' | 'ROCKET_BODY' | 'DEBRIS' | 'STATION' | 'UNKNOWN' | 'CREWED';28export type SatStatus = 'ACTIVE' | 'INACTIVE' | 'DECAYED' | 'LOST' | 'FAILED' | 'UNKNOWN' | 'PLANNED';2930export interface SatelliteRow {31  id: string;32  slug: string;33  name: string;34  norad_id: number | null;35  cospar_id: string | null;36  object_type: ObjectType;37  status: SatStatus;38  ops_status_code: string | null;39  mission_type: string | null;40  orbit_class: OrbitClass | null;41  period_minutes: Num;42  inclination_deg: Num;43  apogee_km: Num;44  perigee_km: Num;45  rcs_m2: Num;46  launch_date: string | null;47  decay_date: string | null;48  launch_site_code: string | null;49  has_gp: boolean;50  latest_epoch: string | null;51  country_code: string | null;52  country_name: string | null;53  country_slug: string | null;54  owner_code: string | null;55  owner_name: string | null;56  operator_id: string | null;57  operator_name: string | null;58  operator_slug: string | null;59  constellation_id: string | null;60  constellation_name: string | null;61  constellation_slug: string | null;62  launch_id: string | null;63  cospar_launch_id: string | null;64  launch_site_name: string | null;65  launch_site_slug: string | null;66  first_seen_at: string;67  last_seen_at: string;68  updated_at: string;69}7071export interface OrbitalState {72  epoch: string;73  mean_motion: number;74  eccentricity: number;75  inclination: number;76  raan: number;77  arg_of_perigee: number;78  mean_anomaly: number;79  bstar: number | null;80  mean_motion_dot: number | null;81  semi_major_axis_km: number | null;82  perigee_km: number | null;83  apogee_km: number | null;84  period_minutes: number | null;85  orbit_class: OrbitClass | null;86  source_id: string;87  updated_at: string;88}8990export interface LivePosition {91  lat: number;92  lon: number;93  altitude_km: number;94  velocity_km_s: number;95  timestamp: string;96  source_epoch: string;97  epoch_age_hours?: number;98  error?: string | null;99}100101export interface Freshness {102  orbit: { updated_at: string | null; epoch: string | null; status: 'fresh' | 'aging' | 'stale' | 'unavailable' };103  metadata: { updated_at: string | null; status: 'fresh' | 'aging' | 'stale' | 'unavailable' };104}105106export interface SatelliteDetail extends SatelliteRow {107  redirected_from?: string;108  orbital_state: OrbitalState | null;109  live: LivePosition | null;110  aliases: { alias: string; source_id: string | null }[];111  tags: { tag: string; source_id: string | null; last_seen_at: string }[];112  identifiers: { identifier_type: string; identifier_value: string; source_id: string | null; verified: boolean }[];113  history: { field: string; old_value: string | null; new_value: string | null; source_id: string | null; changed_at: string }[];114  constellation_memberships: { constellation_id: string; slug: string; name: string; method: string; since: string; until: string | null }[];115  provenance: { field_name: string; source_id: string; source_name: string; observed_at: string; confidence: number }[];116  events: EventRow[];117  quality_flags: { flag: string; detail: string | null; created_at: string }[];118  launch_siblings: Pick<SatelliteRow, 'id' | 'slug' | 'name' | 'norad_id' | 'object_type' | 'status'>[];119  related: Pick<SatelliteRow, 'id' | 'slug' | 'name' | 'norad_id' | 'status' | 'perigee_km'>[];120  sources: { id: string; name: string; official: boolean; attribution_text: string | null; last_success_at: string | null }[];121  freshness: Freshness;122}123124export interface TrackPoint {125  t: string;126  lat: number;127  lon: number;128  alt: number;129  future: boolean;130}131export interface Track {132  t0: string;133  points: TrackPoint[];134  source_epoch: string;135}136137export interface OrbitalElementRow {138  epoch: string;139  mean_motion: number;140  eccentricity: number;141  inclination: number;142  raan: number;143  arg_of_perigee: number;144  mean_anomaly: number;145  bstar: number | null;146  semi_major_axis_km: number | null;147  perigee_km: number | null;148  apogee_km: number | null;149  period_minutes: number | null;150  source_id: string;151  received_at: string;152}153154export interface SatelliteHistory {155  changes: { field: string; old_value: string | null; new_value: string | null; source_id: string | null; changed_at: string }[];156  altitude_series: { day: string; perigee_km: Num; apogee_km: Num; period_minutes: Num; inclination: Num }[];157}158159export interface FacetValue {160  value: string;161  count: Num;162  label?: string;163  slug?: string;164}165export interface Facets {166  status: FacetValue[];167  object_type: FacetValue[];168  orbit_class: FacetValue[];169  mission_type: FacetValue[];170  country: FacetValue[];171  constellation: FacetValue[];172}173174export interface ConstellationRow {175  id: string;176  slug: string;177  name: string;178  service_type: string | null;179  orbit_class: string | null;180  lifecycle_stage: string;181  description: string | null;182  official_url: string | null;183  planned_count: number | null;184  authorized_count: number | null;185  country_code: string | null;186  country_name: string | null;187  country_slug: string | null;188  operator_id: string | null;189  operator_name: string | null;190  operator_slug: string | null;191  active: Num;192  inactive: Num;193  decayed: Num;194  on_orbit: Num;195  total: Num;196  launched_last_365d: Num;197  launched_last_30d: Num;198  launches: Num;199  first_launch: string | null;200  last_launch: string | null;201  median_perigee_km: Num;202  median_inclination_deg: Num;203  activity_score: Num;204}205206export interface ConstellationDetail extends ConstellationRow {207  status_distribution: { status: string; count: Num }[];208  growth: { month: string; launched: Num; cumulative: Num }[];209  shells: { perigee_km: Num; inclination_deg: Num; satellites: Num }[];210  altitude_histogram: { alt_km: Num; satellites: Num }[];211  inclination_histogram: { incl_deg: Num; satellites: Num }[];212  launches_list: { id: string; cospar_launch_id: string; launch_date: string | null; site_name: string | null; site_slug: string | null; satellites: Num; active: Num }[];213  launch_sites: { code: string; name: string; slug: string; country_code: string | null; launches: Num; satellites: Num }[];214  countries: { code: string; name: string; slug: string; satellites: Num }[];215  recent_satellites: { id: string; slug: string; name: string; norad_id: number | null; status: string; launch_date: string | null; perigee_km: Num; apogee_km: Num; inclination_deg: Num }[];216  events: EventRow[];217  decays_by_month: { month: string; decayed: Num }[];218  membership_methods: { method: string; satellites: Num }[];219  match_patterns: string[];220  celestrak_groups: string[];221}222223export interface OperatorRow {224  id: string;225  slug: string;226  name: string;227  kind: string;228  official_url: string | null;229  description: string | null;230  country_code: string | null;231  country_name: string | null;232  country_slug: string | null;233  active_payloads: Num;234  on_orbit_payloads: Num;235  total_payloads: Num;236  decayed: Num;237  constellations: Num;238  launches: Num;239  payloads_last_365d: Num;240  first_launch: string | null;241  last_launch: string | null;242}243244export interface OperatorDetail extends OperatorRow {245  aliases: string[];246  constellations_list: { id: string; slug: string; name: string; service_type: string | null; orbit_class: string | null; active: Num; total: Num; launched_last_365d: Num }[];247  launches_list: { id: string; cospar_launch_id: string; launch_date: string | null; site_name: string | null; site_slug: string | null; satellites: Num }[];248  status_distribution: { status: string; count: Num }[];249  orbit_distribution: { orbit_class: string; count: Num }[];250  mission_distribution: { mission_type: string; count: Num }[];251  growth: { year: number; launched: Num; still_active: Num }[];252  fleet_sample: { id: string; slug: string; name: string; norad_id: number | null; status: string; orbit_class: string | null; launch_date: string | null; perigee_km: Num; mission_type: string | null }[];253  events: EventRow[];254  launch_sites: { code: string; name: string; slug: string; country_code: string | null; launches: Num }[];255}256257export interface CountryRow {258  code: string;259  name: string;260  slug: string;261  iso3?: string | null;262  region?: string | null;263  active_payloads: Num;264  on_orbit_payloads: Num;265  total_payloads: Num;266  debris_on_orbit: Num;267  rocket_bodies_on_orbit: Num;268  objects_on_orbit: Num;269  total_objects: Num;270  launches: Num;271  operators: Num;272  payloads_last_365d: Num;273  rank_active?: Num;274}275276export interface CountryDetail extends CountryRow {277  rank_objects: Num;278  rank_debris: Num;279  operators_list: { id: string; slug: string; name: string; kind: string; active_payloads: Num; total_payloads: Num; payloads_last_365d: Num }[];280  constellations_list: { id: string; slug: string; name: string; service_type: string | null; orbit_class: string | null; active: Num; total: Num }[];281  owner_codes: { code: string; name: string; kind: string }[];282  orbit_distribution: { orbit_class: string; count: Num }[];283  mission_distribution: { mission_type: string; count: Num }[];284  object_type_distribution: { object_type: string; on_orbit: Num; total: Num }[];285  growth: { year: number; payloads: Num; still_active: Num; launches: Num }[];286  launch_sites: { code: string; name: string; slug: string; latitude: number | null; longitude: number | null; launches: Num; last_launch: string | null }[];287  recent_satellites: { id: string; slug: string; name: string; norad_id: number | null; status: string; object_type: string; orbit_class: string | null; launch_date: string | null }[];288  recent_launches: LaunchRow[];289  events: EventRow[];290}291292export interface LaunchRow {293  id: string;294  cospar_launch_id: string;295  launch_date: string | null;296  launch_year?: number | null;297  payload_count: Num;298  object_count?: Num;299  on_orbit_count?: Num;300  primary_name: string | null;301  owner_codes?: string[];302  site_code?: string | null;303  site_name: string | null;304  site_slug: string | null;305  site_country?: string | null;306  site_lat?: number | null;307  site_lon?: number | null;308}309310export interface LaunchDetail extends LaunchRow {311  objects: (Pick<SatelliteRow, 'id' | 'slug' | 'name' | 'norad_id' | 'cospar_id' | 'object_type' | 'status' | 'orbit_class' | 'perigee_km' | 'apogee_km' | 'inclination_deg' | 'decay_date' | 'country_code' | 'operator_name' | 'operator_slug' | 'constellation_name' | 'constellation_slug'>)[];312  owners: { code: string; name: string; kind: string; country_code: string | null }[];313  events: EventRow[];314}315316export interface LaunchSiteRow {317  code: string;318  name: string;319  slug: string;320  country_code: string | null;321  country_name?: string | null;322  latitude: number | null;323  longitude: number | null;324  launches: Num;325  launches_last_365d: Num;326  payloads?: Num;327  first_launch?: string | null;328  last_launch: string | null;329}330331export interface EventEntity {332  type: string;333  id: string;334  relationship?: string;335  slug: string | null;336  name: string | null;337  norad_id?: number | null;338}339export interface EventRow {340  id: string;341  type: string;342  title: string;343  summary: string | null;344  event_time: string;345  detected_at?: string;346  confidence: number;347  source_id: string | null;348  source_name?: string | null;349  source_url?: string | null;350  metadata?: Record<string, unknown>;351  entities?: EventEntity[] | null;352}353354export interface GlobalStats {355  active_satellites: Num;356  objects_on_orbit: Num;357  objects_catalogued: Num;358  payloads_total: Num;359  payloads_on_orbit: Num;360  debris_on_orbit: Num;361  rocket_bodies_on_orbit: Num;362  decayed_objects: Num;363  decayed_last_30d: Num;364  decayed_last_365d: Num;365  with_elements: Num;366  payloads_launched_30d: Num;367  payloads_launched_365d: Num;368  payloads_launched_ytd: Num;369  active_operators: Num;370  active_countries: Num;371  active_constellations: Num;372  latest_epoch: string | null;373}374export interface LaunchTotals {375  total: Num;376  last_365d: Num;377  ytd: Num;378  last_30d: Num;379}380export interface BucketStat {381  bucket: string;382  objects: Num;383  active_payloads: Num;384  payloads: Num;385  debris: Num;386  rocket_bodies: Num;387}388export interface StatsSnapshot {389  computed_at: string;390  global: GlobalStats;391  launches: LaunchTotals;392  by_orbit_class: { orbit_class: string; active: Num; on_orbit: Num }[];393  by_object_type: { object_type: string; on_orbit: Num; total: Num }[];394  by_mission_type: { mission_type: string; active: Num }[];395  launches_by_year: { year: number; launches: Num; payloads: Num }[];396  payloads_by_launch_year: { year: number; payloads: Num; still_active: Num }[];397  decays_by_year: { year: number; decayed: Num }[];398  top_countries: CountryRow[];399  top_operators: { id: string; slug: string; name: string; country_code: string | null; active_payloads: Num; total_payloads: Num; payloads_last_365d: Num }[];400  top_constellations: { id: string; slug: string; name: string; operator_id: string | null; service_type: string | null; orbit_class: string | null; active: Num; on_orbit: Num; total: Num; launched_last_365d: Num; launched_last_30d: Num }[];401  orbital_buckets: BucketStat[];402  connectors: { name: string; source_id: string; last_success_at: string | null; last_attempt_at: string | null; interval_seconds: number; enabled: boolean; circuit_open_until: string | null; consecutive_failures: number }[];403}404405export interface HomePayload {406  stats: GlobalStats;407  launches: LaunchTotals;408  by_orbit_class: StatsSnapshot['by_orbit_class'];409  top_constellations: StatsSnapshot['top_constellations'];410  top_countries: CountryRow[];411  top_operators: StatsSnapshot['top_operators'];412  orbital_buckets: BucketStat[];413  latest_launches: LaunchRow[];414  events: EventRow[];415  reentries: { id: string; slug: string; name: string; norad_id: number | null; object_type: string; decay_date: string; country_code: string | null; country_name: string | null }[];416  trending: { id: string; slug: string; name: string; norad_id: number | null; status: string; orbit_class: string | null; perigee_km: Num; constellation_name: string | null; operator_name: string | null; views: Num }[];417  sources: { id: string; name: string; official: boolean; attribution_text: string | null; connector: string | null; last_success_at: string | null; interval_seconds: number | null; enabled: boolean }[];418  computed_at: string;419}420421export interface PositionsSnapshot {422  t0: string;423  t1: string;424  step_s: number;425  count: number;426  total_tracked: number;427  fields: string[];428  norad: number[];429  cls: number[];430  mission: number[];431  active: number[];432  pos: number[]; // lat0, lon0, alt0, lat1, lon1, alt1 per object433  vel: number[];434  legend: { cls: string[]; mission: string[] };435}436437export interface SearchResult {438  entity_type: 'satellite' | 'operator' | 'constellation' | 'country' | 'launch' | 'launch_site';439  entity_id: string;440  slug: string;441  title: string;442  subtitle: string | null;443  norad_id?: number | null;444  score: number;445  href: string;446}447export interface SearchPayload {448  query: string;449  results: SearchResult[];450  shortcuts: { label: string; href: string; filter: Record<string, string> }[];451}452453export interface SourceRow {454  id: string;455  name: string;456  type: string;457  base_url: string | null;458  official: boolean;459  country_code: string | null;460  authority_type: string | null;461  license: string | null;462  attribution_required: boolean;463  attribution_text: string | null;464  update_frequency_seconds: number | null;465  enabled: boolean;466  priority: number;467  connectors: { name: string; description: string | null; interval_seconds: number; enabled: boolean; last_success_at: string | null; last_attempt_at: string | null; last_duration_ms: number | null; consecutive_failures: number; circuit_open_until: string | null; next_run_at: string | null }[] | null;468  provenance_rows: Num;469  raw_snapshots: Num;470  last_snapshot_at: string | null;471  freshness: 'fresh' | 'aging' | 'stale' | 'unavailable' | 'not_enabled';472}473474export interface ConnectorStatus {475  name: string;476  source_id: string;477  source_name: string;478  enabled: boolean;479  interval_seconds: number;480  last_success_at: string | null;481  last_attempt_at: string | null;482  last_duration_ms: number | null;483  consecutive_failures: number;484  circuit_open_until: string | null;485  next_run_at: string | null;486  last_status: string | null;487  last_error: string | null;488  freshness: string;489}490export interface SourcesStatus {491  connectors: ConnectorStatus[];492  orbit: { latest_epoch: string | null; median_element_age_hours: number | null; propagator_objects: number };493}494495export interface HealthPayload {496  status: string;497  version: string;498  time: string;499  components: Record<string, { status: string; [k: string]: unknown }>;500}501502export interface MethodologyPayload {503  metrics: { key: string; name: string; version: string; methodology: string; inputs: string[]; updated_at: string }[];504  constellation_rules: { slug: string; name: string; match_patterns: string[]; celestrak_groups: string[]; service_type: string | null }[];505  owner_codes: { code: string; name: string; kind: string; country_code: string | null }[];506}507508export interface DensityPayload {509  buckets: BucketStat[];510  leo_profile_25km: { alt_km: Num; objects: Num; active_payloads: Num; debris: Num; rocket_bodies: Num }[];511  inclination_profile_5deg: { incl_deg: Num; objects: Num; active_payloads: Num }[];512  methodology: string;513}514515export interface DebrisPayload {516  totals: { debris: Num; rocket_bodies: Num; unknown: Num; inactive_payloads: Num };517  by_country: { code: string; name: string; slug: string; debris: Num; rocket_bodies: Num }[];518  by_altitude: { alt_km: Num; debris: Num; rocket_bodies: Num }[];519  by_launch: { cospar_launch_id: string; launch_date: string | null; primary_name: string | null; site_name: string | null; debris_on_orbit: Num; owner_codes: string[] }[];520  debris_growth: { year: number; debris_catalogued: Num; debris_still_on_orbit: Num }[];521  decays_by_year: { year: number; debris: Num; rocket_bodies: Num; payloads: Num }[];522  largest_objects: { id: string; slug: string; name: string; norad_id: number | null; object_type: string; rcs_m2: Num; perigee_km: Num; apogee_km: Num; launch_date: string | null; country_code: string | null }[];523  disclaimer: string;524}525526export interface ReentryRow {527  id: string;528  slug: string;529  name: string;530  norad_id: number | null;531  cospar_id: string | null;532  object_type: string;533  decay_date: string;534  launch_date: string | null;535  country_code: string | null;536  country_name: string | null;537  rcs_m2: Num;538  perigee_km: Num;539  apogee_km: Num;540  operator_name: string | null;541  constellation_name: string | null;542  constellation_slug: string | null;543}544export interface ReentriesPayload extends Paginated<ReentryRow> {545  summary: { last_7d: Num; last_30d: Num; last_365d: Num };546  monthly: { month: string; decayed: Num; payloads: Num; debris: Num; rocket_bodies: Num }[];547  low_perigee_watch: { id: string; slug: string; name: string; norad_id: number | null; object_type: string; perigee_km: Num; apogee_km: Num; epoch: string; country_code: string | null; constellation_name: string | null }[];548  disclaimer: string;549}550551export interface LaunchTimeline {552  years: { year: number; launches: Num; payloads: Num; us: Num; russia_cis: Num; china: Num; other: Num }[];553  months: { month: string; launches: Num; payloads: Num }[];554  sites: LaunchSiteRow[];555}556557export interface RankingsPayload {558  metric: string;559  rows: Record<string, unknown>[];560}561