Repository navigation
Description
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): stringImpact: 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—SamplingFeatureQueryOptionsis a type alias forQueryOptions(zero benefit) - ❌ Do NOT change
getSystemProcedures—ProcedureQueryOptionsis a type alias forQueryOptions(zero benefit) - ❌ Do NOT change
getDataStreamProcedures—ProcedureQueryOptionsis a type alias forQueryOptions(zero benefit) - ❌ Do NOT change
getControlStreamProcedures—ProcedureQueryOptionsis a type alias forQueryOptions(zero benefit) - ❌ Do NOT change
getObservationSamplingFeature— singular navigation method, baseQueryOptionsis sufficient - ❌ Do NOT change
getObservationSystem— singular navigation method, baseQueryOptionsis sufficient - ❌ Do NOT modify
buildResourceUrl()orbuildQueryString()— 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
optionsparameter 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 |
Activity
Add findings report for Issue #107 — nested builder method types
docs: add Phase 5.5 code review (Issues #99-#110 post-smoke-test)
fix(csapi): narrow getControlStreamProcedures option type to Procedur…
Narrow nested builder method option types (Fixes OS4CSAPI#107)
merge: sync with upstream ogc-client-CSAPI_2 (Phase 5.5/5.6)