Skip to content

Add getLayerCapabilities - #139

Draft
ChrisLoer wants to merge 1 commit into
mainfrom
cloer/get-layer-capabilities
Draft

Add getLayerCapabilities#139
ChrisLoer wants to merge 1 commit into
mainfrom
cloer/get-layer-capabilities

Conversation

@ChrisLoer

Copy link
Copy Markdown

🤖 Description

Layers created with createLayersFromGeoJson hold their whole GeoJSON collection in the browser, so they support a different subset of the SDK than layers hosted by Felt: no server-side query endpoint, no server-computed statistics, no server persistence — but the full feature collection is available locally. felt/felt PRs #21742, #21743 and #21744 make the unsupported methods fail loudly and implement many of the ones that can be served locally.

What's still missing is discoverability (felt/felt ENG-526): a host app has no way to ask which semantics apply to a layer, so it has to guess or probe by calling a method and catching the rejection. getLayerCapabilities closes that gap so a caller can branch up front.

API

getLayerCapabilities(layerId: string): Promise<Array<LayerCapability>>;

export type LayerCapability =
  | "serverPersistence" // the layer exists server-side: duplicateLayer, persistence
  | "serverQuery"       // server-side query endpoint: getFeatures search/sort/filter/boundary, setLayerBoundary, data table
  | "serverStats"       // server-computed statistics: precomputed aggregates, jenks breaks
  | "localData";        // the full GeoJSON collection is in the browser: getFeature/getFeatures/getGeoJsonFeature/local stats

Hosted layers report the server* capabilities; layers created with createLayersFromGeoJson report localData. Each token's JSDoc names the methods that need it, and the method's JSDoc notes that calling a method without its capability rejects with an error naming the missing capability.

⚠️ The Felt-side handler lands separately

This PR is the client half only: the message schema, the controller method, the type, docs and the API spec. Felt does not handle getLayerCapabilities yet — calling it against today's app will fail as an unknown message. The handler implementation lands in felt/felt once this change is published to npm, per the usual SDK flow in DEVELOPING.md.

🧪 Test Plan

  • npm run check passes locally (client bundle, format, api-extractor + attw, knip, tsc, vitest, docs).
  • New tests/layers.test.ts covers the message round-trip: the layer id reaches the handler, the capability array comes back, a non-string layer id is reported as an invalid message and rejects, and a handler error surfaces as a promise rejection.
  • etc/js-sdk.api.md and docs/ are regenerated and committed (npm run update-api, npm run build:docs). The api spec diff is large because adding a public type rotates the bundled chunk hash and shifts every mangled export id — the only semantic change is LayerCapability.
  • Behavioral verification happens in the felt/felt PR, which adds the handler and the end-to-end test.

Layers created with createLayersFromGeoJson hold their data in the browser,
so they support a different subset of the SDK than layers hosted by Felt.
There was no way for a host app to ask which semantics apply to a layer, so
it had to guess. getLayerCapabilities reports the layer's capabilities -
serverPersistence, serverQuery, serverStats and localData - so callers can
branch instead.

The Felt-side handler lands separately.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant