celestrak 1.0.4
celestrak: ^1.0.4 copied to clipboard
A pure-Dart client for fetching, parsing, and caching satellite TLE and OMM orbital data from CelesTrak and Space-Track. No Flutter dependency.
Changelog #
All notable changes to this project are documented here. The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
1.0.4 - 2026-06-10 #
Fixed #
- Completed WASM compatibility. Removed all unconditional
dart:ioimports from the public API chain:celestrak_client.dart— replacedimport 'dart:io' show DirectoryandFileCacheStore(Directory(cacheDir))with a conditional-import factory (default_cache_store_io.dart/default_cache_store_stub.dart). On web/WASM,cacheDiris ignored and aMemoryCacheStoreis used; on native, behaviour is unchanged.spacetrack_data_source.dart— replacedimport 'dart:io' show SocketExceptionwith the same conditional-import shim introduced in v1.0.3 (socket_exception_io.dart/socket_exception_stub.dart).- The package now passes pub.dev WASM compatibility checks across the full public API surface.
1.0.3 - 2026-06-09 #
Fixed #
- Fixed WASM incompatibility in
http_transport.dart. The unconditionalimport 'dart:io'(used only forSocketException) is replaced with a conditional import:dart:iois loaded on native platforms, a no-op stub on web/WASM.SocketExceptionhandling is preserved on native; the package now passes WASM compatibility checks on pub.dev.
1.0.2 - 2026-06-09 #
Fixed #
- Removed
dart:ioimport fromfailures.dart— it was only referenced in a doc comment. The package now passes WASM compatibility checks on pub.dev.
1.0.1 - 2026-06-09 #
Added #
example/main.dart— runnable CLI script demonstrating every public API:fetchByNoradId,fetchCategory,fetchCategoryByGroup,fetchByName,fetchByIntlDesignator,cacheAge,clearCache,isStale, and all cache control parameters (allowStale,forceCache,ttl).
0.1.0 UNRELEASED #
Added #
Domain models
SatelliteTle— immutable orbital record carryingnoradId,name, verbatimline1/line2strings,epoch,fetchedAt,source, and an optionalOmmpayload. Providesage,ageAt(DateTime),isStale,classification,copyWith, and value equality.Omm— full CCSDS Orbit Mean-Elements Message mapping all mandatory OMM keywords plus CelesTrak header fields.nullobjectName/objectIdare tolerated for analyst (80000-series) objects.TleSourceenum —celestrak,spacetrack,local; stamps everySatelliteTlewith its data provenance.CelestrakFormatenum —omm(recommended default, supports 9-digit catalog numbers) andtle(legacy 3-line format).SatelliteCategoryenum — named CelesTrak groups:stations,starlink,weather,amateur,visual,gps,galileo,glonass,cosmos2251Debris,active,lastThirtyDays. Each value exposes a.groupstring for theGROUP=query parameter.
Parsers
OmmParser— stateless, reusable parser for CelesTrak OMM JSON. Supports single-recordparse()and lazyparseAllLazy()for large category responses. All failures surface asOmmParseException.- TLE parser (internal) — splits 3-line records, validates mod-10 checksum (toggle-able), decodes 2-digit-year + fractional-DOY epoch, and handles 1–9-digit NORAD catalog IDs.
- Dual-format stitch — when fetching in OMM format the pipeline issues a
companion
FORMAT=TLErequest to obtain verbatim TLE lines required by SGP4 propagators. Objects with catalog numbers ≥ 100 000 (alpha-5 encoding) gracefully receive emptyline1/line2when absent from the TLE response.
Cache pipeline
CacheStore— abstract interface for key-value byte caching withread,write,age, andclearoperations.MemoryCacheStore— in-memoryCacheStoreimplementation for testing and web targets (where file I/O is unavailable).FileCacheStore(internal) —dart:io-backed store with write-temp-then- rename atomicity and sidecar timestamp files for age tracking. Corrupt or truncated files are treated as cache misses.CacheKeyBuilder(internal) — builds filename-safe, path-traversal-free cache keys encoding{queryType, queryValue, format, source}.Clock/SystemClock— injectable time source used throughout the pipeline for TTL checks, age calculations, and staleness classification.StalenessChecker— classifies orbital data against a configurablestaleThreshold(default 3 days).isFresh(cacheAge, ttl:)determines cache validity;isStale(epoch)determines orbital data accuracy.defaultStaleThresholdconstant —Duration(days: 3); LEO-conservative default; override for highly elliptical orbits or debris with fast decay.
Cache policies: allowStale and forceCache
allowStaleparameter (all fetch methods) — whentrueand the network request fails, the repository returns a stale cached entry (if present) rather than re-throwing. The returned record carriesTleSource.localand itsisStaleflag reflects the orbital epoch age. Whenfalse(default), any network failure with no fresh cache raisesNetworkException.forceCacheparameter (all fetch methods) — whentrue, the network is never contacted. If no cached entry exists aCacheMissExceptionis thrown immediately. When bothforceCache: trueandallowStale: trueare supplied,forceCachetakes unconditional priority.- Stale-while-revalidate — TTL-expired entries trigger a remote fetch; if
the fetch succeeds the cache is refreshed. If the fetch fails and
allowStale: true, the expired entry is returned withTleSource.local.
isStale on SatelliteTle
SatelliteTle.isStale({DateTime? now, Duration staleThreshold})— checks whether the orbital epoch has aged paststaleThreshold(default 3 days). Accepts an optional pinnednowfor deterministic tests.CelestrakClient.isStale(SatelliteTle)— convenience method on the facade that uses the client's configuredstaleThreshold.
Repository and client facades
TleRepository— abstract interface describing the cache → TTL → fetch → parse → stamp pipeline. SupportsfetchByNoradId,fetchCategory,fetchCategoryByGroup,fetchByName,fetchByIntlDesignator, per-method cache-age queries (cacheAge,categoryAge,groupAge,nameAge,intlDesignatorAge), andclearCache.CelestrakClient— high-level facade overTleRepository.- Default constructor: supply a
cacheDirpath; the client owns an internalhttp.Clientand aFileCacheStore. Calldisposewhen done. CelestrakClient.withStore: inject a customCacheStoreandhttp.Client; lifecycle remains the caller's responsibility.- Configuration parameters:
defaultTtl,defaultFormat,timeout,maxAttempts,staleThreshold,clock,useIsolate. fetchByNoradId(int noradId, ...)— single-object lookup viaCATNR=<id>.fetchCategory(SatelliteCategory, ...)— group lookup viaGROUP=<category.group>.fetchCategoryByGroup(String group, ...)— arbitrary group string passthrough.fetchByName(String name, ...)— name substring search viaNAME=<name>; returns an empty list on no match (never throws).fetchByIntlDesignator(String, ...)— international designator lookup viaINTDES=<designator>; returns an empty list on no match.cacheAge,categoryAge,groupAge,nameAge,intlDesignatorAge— per-key cache-age inspection.clearCache({String? keyPrefix})— removes all cache entries or those matching a prefix.isStale(SatelliteTle)— staleness convenience using the client's configured threshold.dispose()— closes the ownedhttp.Client(no-op forwithStore).
- Default constructor: supply a
HttpTransport(internal) — bounded retry with exponential backoff (5xx /TimeoutException/SocketExceptiononly; 4xx never retried), HTTPS enforcement, and injectablehttp.Client.
Space-Track support
SpaceTrackClient— credentialed facade for Space-Track.org GP API.- Performs POST-based login and holds the session cookie in memory only; credentials are never written to disk.
SpaceTrackClient.withClientconstructor for test injection.- Credential gating: pass
nullor empty credentials to construct a disabled client;isEnabledreturnsfalseandfetchByQuerythrowsStateErrorrather than an authentication error. fetchByQuery(SpaceTrackQuery)— fetches and parses a single GP record; stamps result withTleSource.spacetrack.- Enforces a configurable minimum inter-request interval (
minRequestInterval, default 2 s) as a courtesy to Space-Track rate limits. - Idempotent
dispose().
SpaceTrackQuery— immutable value object for Space-Track queries. Currently supportsSpaceTrackQuery.byNoradId(int).AuthenticationException— raised on HTTP 401/403 from Space-Track.RateLimitException— raised on HTTP 429; carries optionalretryAfter.
Error hierarchy
CelestrakException(sealed base) — all library exceptions share a commonmessagefield and are exhaustively matchable in aswitch.NetworkException— transport failure; carries optionalstatusCode,uri, andcause.SatelliteNotFoundException— CelesTrak returned the "No GP data found" sentinel.noradIdis0for group/category queries.OmmParseException— OMM JSON parse failure; optionalfieldnames the offending keyword.TleParseException— TLE text parse failure; optionalfieldnames the offending line.CacheMissException—forceCache: truewith no cached entry;keyidentifies the absent cache key.AuthenticationException— Space-Track 401/403; carriesstatusCode.RateLimitException— Space-Track 429; carries optionalretryAfter.
Benchmark extension point
ParseBenchmarkHook/NullParseBenchmarkHook— interface for measuring parse duration in multi-record category responses. Inject intoOmmParserto collect timing signals without modifying the production code path.
Configuration constants
kDefaultTtl—Duration(hours: 2).kDefaultMaxAttempts—5(1 initial + 4 retries).kDefaultTimeout—Duration(seconds: 30).
Public API surface
- Frozen public API surface: every symbol exported from
package:celestrakis intentional and documented. Internal types (HttpTransport,CacheKeyBuilder,TleOmmStitcher,FileCacheStore, backoff constants) are not part of the public contract.