Skip to content

DX: 12 nested builder methods accept base QueryOptions instead of type-specific options #107

Closed

Description

@Sam-Bolling

Task

Narrow the options parameter type on 13 nested builder methods in url_builder.ts from the base QueryOptions to the child resource's specific query options interface (e.g., DatastreamQueryOptions, SystemQueryOptions). Zero runtime change — TypeScript type annotations only.

Finding Reference: Demo app finding from ogc-csapi-explorer#35
Severity: Low (Cosmetic / DX)
Category: Design gap
Ownership: Ours


Problem Statement

12 nested-resource methods in url_builder.ts accept QueryOptions (the base type) instead of the child resource's specific query options type. TypeScript callers get no autocomplete for type-specific filters (e.g., phenomenonTime, observedPropertyId, recursive) when querying nested endpoints. A 13th method (getControlStreamSystems) was identified during the findings report verification.

Evidence:

The explorer demo app's bridge layer (csapi-bridge.ts) needed explicit casts like options as DatastreamQueryOptions when calling nested builder methods. Two methods (getDataStreamObservations, getControlStreamCommands) are already correctly typed, demonstrating the intended pattern — the remaining 13 methods were not brought to the same standard.

// Before — no autocomplete for DatastreamQueryOptions fields
getSystemDataStreams(id: string, options?: QueryOptions): string

// After — full autocomplete for phenomenonTime, resultTime, foiId, etc.
getSystemDataStreams(id: string, options?: DatastreamQueryOptions): string

Impact: Callers lack type-safe access to resource-specific query parameters on nested endpoints. No runtime behavior is affected — buildQueryString() serializes any property via Object.entries() regardless of the static type.

Files to Create or Modify

File Action Est. Lines Purpose
src/ogc-api/csapi/url_builder.ts Modify ~13 (one-word changes) Narrow options parameter types on 13 method signatures

Proposed Fix

Single-token replacement on each affected method signature — change QueryOptions to the appropriate child type:

# Method Change To
1 getSystemDataStreams DatastreamQueryOptions
2 getSystemControlStreams ControlStreamQueryOptions
3 getSystemDeployments DeploymentQueryOptions
4 getDeploymentSystems SystemQueryOptions
5 getProcedureSystems SystemQueryOptions
6 getProcedureDataStreams DatastreamQueryOptions
7 getSamplingFeatureSystems SystemQueryOptions
8 getSamplingFeatureObservations ObservationQueryOptions
9 getPropertySystems SystemQueryOptions
10 getPropertyDataStreams DatastreamQueryOptions
11 getPropertyControlStreams ControlStreamQueryOptions
12 getDataStreamSystems SystemQueryOptions
13 getControlStreamSystems SystemQueryOptions

All required types are already imported on line 2 of url_builder.ts. No new imports needed.

Scope — What NOT to Touch

  • ❌ Do NOT change getSystemSamplingFeatures — SamplingFeatureQueryOptions is a type alias for QueryOptions (zero benefit)
  • ❌ Do NOT change getSystemProcedures — ProcedureQueryOptions is a type alias for QueryOptions (zero benefit)
  • ❌ Do NOT change getDataStreamProcedures — ProcedureQueryOptions is a type alias for QueryOptions (zero benefit)
  • ❌ Do NOT change getControlStreamProcedures — ProcedureQueryOptions is a type alias for QueryOptions (zero benefit)
  • ❌ Do NOT change getObservationSamplingFeature — singular navigation method, base QueryOptions is sufficient
  • ❌ Do NOT change getObservationSystem — singular navigation method, base QueryOptions is sufficient
  • ❌ Do NOT modify buildResourceUrl() or buildQueryString() — internal plumbing is correct
  • ❌ Do NOT modify files outside the "Files to Create or Modify" table above
  • ❌ Do NOT refactor existing code or add new abstractions

Acceptance Criteria

  • All 13 methods have their options parameter narrowed to the correct child type
  • No new imports added (all types already imported)
  • Zero runtime behavior change — transpiled JavaScript output is identical
  • Existing tests still pass (npm test) — no test modifications needed
  • No lint errors

Dependencies

Blocked by: #106 — Missing Part 2 query option fields (Resolved ✅)
Blocks: Nothing


Operational Constraints

⚠️ MANDATORY: Before starting work on this issue, review
docs/governance/AI_OPERATIONAL_CONSTRAINTS.md.

Key constraints:

  • Precedence: OGC specifications → AI Collaboration Agreement → This issue description → Existing code → Conversational context
  • No scope expansion: Fix the finding, nothing more
  • Minimal diffs: Prefer the smallest change that satisfies the acceptance criteria
  • No runtime changes: This is a type-annotation-only fix

References

# Document What It Provides
1 Findings Report Full verification of all 14 claims, risk assessment, DO NOT change list
2 docs/governance/AI_OPERATIONAL_CONSTRAINTS.md Mandatory operational constraints — §2.1 (scope), §2.2 (architectural alignment), §2.3 (minimal diffs)
3 src/ogc-api/csapi/url_builder.ts Source file containing all affected methods
4 src/ogc-api/csapi/model.ts QueryOptions type hierarchy
5 ogc-csapi-explorer#35 Demo app issue where the typing gap was discovered
6 Issue #106 — Missing Part 2 query option fields Related: recently added fields that callers would want autocomplete for

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions