Repository navigation
Description
Parent Issue
Split from #145 — assertResourceAvailable() + 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
- ❌ Systems, Deployments, Procedures — Part 1 (#145 Part 1: Create
build()helper + rewrite Systems, Deployments, Procedures (33 methods) #158) - ❌ SamplingFeatures, Properties, Datastreams — Part 2 (#145 Part 2: Rewrite SamplingFeatures, Properties, Datastreams to
build()(25 methods) #159) - ❌ The
build()helper itself — created in Part 1 - ❌ Public method signatures, JSDoc, test files
- ❌ Any file outside
url_builder.ts
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 manualbuildQueryString()concatenation — DEFERRED —getCommandStatus()uses string concatenation instead ofbuildResourceUrl()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 throughbuild()) - 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
- [SPLIT]
assertResourceAvailable()+buildResourceUrl()DRY violation (87 methods) → #158 + #159 + #160 #145 — parent issue with full analysis and all 38 references - #145 Part 1: Create
build()helper + rewrite Systems, Deployments, Procedures (33 methods) #158 — Part 1 (createsbuild()helper) - #145 Part 2: Rewrite SamplingFeatures, Properties, Datastreams to
build()(25 methods) #159 — Part 2 (SamplingFeatures/Properties/Datastreams) - DEFERRED —
getCommandStatus()uses string concatenation instead ofbuildResourceUrl()for query string (F45) #111 —getCommandStatus()concatenation deviation — resolved by this part - Phase 7 Scope & Split Assessment
Operational Constraints
⚠️ MANDATORY: Before starting work on this issue, reviewdocs/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.
Activity
docs: update P7 plan v1.3 — reflect issue splits (#141→#154+#155, #100→…
refactor(csapi): rewrite Observations/ControlStreams/Commands to buil…
Merge pull request #160 from camptocamp/dependabot/npm_and_yarn/babel…