Skip to content

#145 Part 3: Rewrite Observations, ControlStreams, Commands to build() (29 methods) — resolves #111 #160

@Sam-Bolling

Description

@Sam-Bolling

Parent Issue

Split from #145assertResourceAvailable() + buildResourceUrl() two-line pattern repeated 90 times in url_builder.ts — DRY violation.

This is Part 3 of 3. See also: #158 (Part 1 — build() helper + Systems/Deployments/Procedures) and #159 (Part 2 — SamplingFeatures/Properties/Datastreams).


Scope — Part 3 Only

Rewrite Observations (8) + ControlStreams (11) + Commands (10) = 29 methods to delegate to the build() helper. This is the final batch and includes the getCommandStatus() deviation that auto-resolves #111.

Context

Parts 1 and 2 (#158, #159) rewrote 58 methods. This part completes the remaining 29 methods, finishing the refactor. After this part, ALL public URL-building methods delegate to build() and no direct assertResourceAvailable() calls remain in any public method.

Methods to Rewrite (29)

Observations (8): getObservations, getObservation, updateObservation, deleteObservation, getObservationDatastream, getObservationSamplingFeature, getObservationSystem, getObservationHistory — rewrite to this.build(...).

ControlStreams (11): getControlStreams, getControlStream, createControlStream, updateControlStream, deleteControlStream, getControlStreamSchema, getControlStreamCommands, createCommand, createCommands, plus others — rewrite to this.build(...).

Commands (10): getCommands, getCommand, updateCommand, deleteCommand, getCommandStatus, updateCommandStatus, getCommandResult, cancelCommand, plus others — rewrite to this.build(...).

Special Case: getCommandStatus() — Auto-resolves #111

getCommandStatus() (currently at ~line 2404) is the ONE method that deviates from the standard pattern by concatenating buildQueryString() separately instead of passing options through buildResourceUrl():

// Current (broken pattern — tracked in #111):
getCommandStatus(id: string, options?: CommandStatusQueryOptions): string {
  this.assertResourceAvailable('commands');
  return this.buildResourceUrl('commands', id, 'status') + this.buildQueryString(options);
}

After rewriting to build():

// Fixed (consistent with all other methods):
getCommandStatus(id: string, options?: CommandStatusQueryOptions): string {
  return this.build('commands', id, 'status', options);
}

This automatically resolves #111 because build() delegates to buildResourceUrl() which already handles options internally. The manual buildQueryString() concatenation disappears.

Pattern

Same as Parts 1 and 2:

// Before:
return this.buildResourceUrl('observations', id, undefined, options);
// After:
return this.build('observations', id, undefined, options);

File to Modify

File Action
src/ogc-api/csapi/url_builder.ts Rewrite 29 methods to delegate to build()

What NOT to Touch

Acceptance Criteria (Part 3)

  • All Observations methods (8) delegate to build()
  • All ControlStreams methods (11) delegate to build()
  • All Commands methods (10) delegate to build()
  • getCommandStatus() no longer uses manual buildQueryString() concatenation — DEFERRED — getCommandStatus() uses string concatenation instead of buildResourceUrl() for query string (F45) #111 resolved
  • Global check: Zero direct this.assertResourceAvailable() calls remain in ANY public method across the entire file
  • Global check: Zero direct this.buildResourceUrl() calls remain in ANY public method (all go through build())
  • Guard behavior preserved for list/create methods (via build()'s conditional logic)
  • tsc --noEmit — zero errors
  • npm test — all tests pass
  • npm run lint — zero errors
  • npx prettier --check src/ — all formatted

Dependencies

Blocked by: #159 (Part 2), #158 (Part 1)
Blocks: Nothing — this completes the #145 refactor
Resolves: #111 (getCommandStatus() concatenation deviation)

References


Operational Constraints

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

Upstream Isolation Constraint

Per the upstream maintainer's comment on PR #136: url_builder.ts is within src/ogc-api/csapi/ — purely internal to the isolated CSAPI module.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions