Skip to content

refactor!: use stac-ts for types#54

Open
alukach wants to merge 2 commits into
mainfrom
chore/cleanup-collection-type
Open

refactor!: use stac-ts for types#54
alukach wants to merge 2 commits into
mainfrom
chore/cleanup-collection-type

Conversation

@alukach
Copy link
Copy Markdown
Member

@alukach alukach commented May 5, 2026

While the stac-manager uses stac-ts for types1, this project creates its own types for STAC objects. This puts a maintenance burden on the project (e.g. I initially started down this path of exploration when I realized that our Collection type was missing the required description field.

This PR add stac-ts as a peerDependency of the project.

Footnotes

  1. https://github.com/developmentseed/stac-manager/blob/c63c760829f018722198dfeecd2ba925fb4ba664/packages/client/package.json#L89

alukach and others added 2 commits May 5, 2026 11:49
stac-react was declaring its own Item, Collection, Link, ItemAsset,
Provider, Extent, etc. types that drifted from the STAC spec (and from
stac-ts, which consumers already use). The drift caused friction in
consumer code: Collection.description was optional here but required in
stac-ts, Item.collection lived at properties.collection rather than at
the top level (per spec), Item.geometry diverged from GeoJSON, and so
on.

This change adds stac-ts as a runtime dependency and rewrites
src/types/stac.d.ts so document types come from stac-ts (StacItem,
StacCollection, StacLink, StacAsset, StacProvider, StacRoles,
StacVersion, StacExtensions, StacCatalog), re-exported from stac-react
so consumers don't need a separate import surface.

Kept locally because they're stac-react-specific:
- Bbox tuple, IdList, CollectionIdList, DateRange, Sortby
- SearchPayload, SearchRequestPayload, FetchRequest, LinkBody
- Link (extends StacLink with stac-react-pagination fields like body)
- SearchResponse, CollectionsResponse (wrappers around StacItem[] /
  StacCollection[])

Internal hooks (useItem, useCollection) updated to consume StacItem and
StacCollection. Public hook return types change shape (StacItem replaces
the old Item) — alpha-window breaking change with no migration path
beyond renaming the imports.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@alukach alukach requested a review from AliceR May 5, 2026 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant