Repository navigation
Description
Task
Expand extractAvailableResources() in url_builder.ts to recognize multiple link relation conventions for CSAPI resource discovery, so the builder works against real server implementations — not just our fixture data.
Origin: Live server smoke test (post Phase 2.1) — Finding F1
Smoke Test Report: docs/implementation/live-server-smoke-test-post-phase-2.1.md
Context — What We Found
Our extractAvailableResources() scans collection links for the ogc-cs: prefix (e.g., rel: "ogc-cs:systems"). This was a reasonable reading of the spec, and all 100 unit tests pass against our fixture data.
When tested against the OpenSensorHub reference implementation, we found the server uses different link relation conventions:
- Root document:
rel: "systems",rel: "datastreams"(plain resource names, no prefix) - Collection document:
rel: "items"withhref: "systems"(genericitemsrelation with resource name in the href) - Neither uses
rel: "ogc-cs:systems"
Result: availableResources is an empty Set, and every public method throws EndpointError.
Files to Create or Modify
| File | Action | Est. Lines | Purpose |
|---|---|---|---|
src/ogc-api/csapi/url_builder.ts |
Modify | ~15–25 changed | Expand extractAvailableResources() to recognize 3 link relation conventions |
src/ogc-api/csapi/url_builder.spec.ts |
Modify | ~20–30 added | Add tests for each link relation convention |
Blueprint Reference
The existing extractAvailableResources() method in url_builder.ts (current implementation scans for ogc-cs: prefix). The fix expands the same method — no new classes or files needed.
Scope — What to Implement
Expanded Resource Discovery
extractAvailableResources() must recognize resources from three link relation conventions, in priority order:
ogc-cs:prefixed (current) —rel: "ogc-cs:systems"→ resource"systems"- Plain resource name —
rel: "systems"where the rel value matches a knownCSAPIResourceType→ resource"systems" itemswith resource href —rel: "items"wherehrefends with a known resource type name → resource extracted from href
All three conventions should populate the same availableResources Set. If a resource is discovered via multiple conventions, it appears once (Set deduplication handles this).
Validation Against Known Resource Types
When matching plain rel values or href paths, validate against the CSAPIResourceTypes constant from model.ts to avoid false positives (e.g., rel: "self" should not be treated as a resource type).
JSDoc Requirements
- Update the JSDoc on
extractAvailableResources()to document all three conventions - Add
@seelinks to OGC CSAPI Part 1 specification sections for resource advertisement - Follow the JSDoc style already established in
url_builder.ts
Testing Requirements
- Extend
src/ogc-api/csapi/url_builder.spec.ts(~20–30 lines) - Test: collection with
ogc-cs:prefix links (existing — verify still works) - Test: collection with plain resource name
relvalues (e.g.,rel: "systems") - Test: collection with
rel: "items"and resource name inhref - Test: mixed conventions in same collection (all discovered)
- Test: plain
relvalues that are NOT resource types (e.g.,rel: "self") are ignored - Follow test patterns from existing
url_builder.spec.tsconstructor and resource validation blocks
Scope — What NOT to Touch
- ❌ Do NOT modify
buildResourceUrl()orbuildQueryString()— URL path construction belongs to Issue Phase 2.7: Observations Methods #11 (F2) - ❌ Do NOT modify
extractBaseUrl()— base URL resolution belongs to Issue Phase 2.7: Observations Methods #11 (F2) - ❌ Do NOT modify
endpoint.ts— endpoint integration changes belong to Issue Phase 2.7: Observations Methods #11 (F2) - ❌ Do NOT modify
model.tsorhelpers.ts— those are stable - ❌ Do NOT implement response parsing — that belongs to Phase 3
- ❌ Do NOT modify any Systems methods (getSystems, getSystem, etc.) — they're correct as-is
- ❌ Do NOT modify files outside the "Files to Create or Modify" table above
- ❌ Do NOT refactor existing code unless required to complete this task
Acceptance Criteria
-
extractAvailableResources()recognizes all three link relation conventions - Existing tests still pass (no regressions)
- New tests verify each convention independently and in combination
-
CSAPIResourceTypesfrommodel.tsis used to validate plainrelvalues (no false positives) - All new code has complete JSDoc documentation
- No lint errors
- No TypeScript errors
Dependencies
Blocked by: Nothing — can start immediately
Blocks: Issue #6 (Deployments Methods), Issue #7 (Procedures Methods), Issue #8 (Sampling Features Methods), Issue #9 (Properties Methods), and all subsequent Phase 2 resource-type tasks. Also blocks Issue #11 (F2 — top-level URLs), which depends on correct resource discovery.
Operational Constraints
⚠️ MANDATORY: Before starting work on this issue, reviewdocs/governance/AI_OPERATIONAL_CONSTRAINTS.md.
Key constraints for this task:
- Precedence: OGC specifications → AI Collaboration Agreement → This issue description → Existing code → Conversational context
- No scope expansion: Do not infer unstated requirements or add unrequested features
- No refactoring: Do not rename, restructure, or "improve" code outside this issue's scope
- Minimal diffs: Prefer the smallest change that satisfies the acceptance criteria
- Ask when unclear: If intent is ambiguous, stop and ask for clarification
References
Read these documents before starting implementation. They are ordered by priority.
Primary References (must read)
| # | Document | Section/Lines | What It Provides |
|---|---|---|---|
| 1 | docs/implementation/live-server-smoke-test-post-phase-2.1.md |
Finding F1 | Full description of the link relation mismatch with real server data |
| 2 | src/ogc-api/csapi/url_builder.ts |
extractAvailableResources() method |
Current implementation to modify |
| 3 | src/ogc-api/csapi/url_builder.spec.ts |
Constructor and Resource validation blocks | Existing test patterns to follow |
Upstream Type/Import References (files this task imports from)
| # | Document | What to Import |
|---|---|---|
| 4 | src/ogc-api/csapi/model.ts |
CSAPIResourceTypes constant (for validating plain rel values) |
Research References (context, not required reading)
| # | Document | What It Provides |
|---|---|---|
| 5 | docs/implementation/live-server-smoke-test-post-phase-2.1.md |
Full smoke test results with server response examples |
| 6 | docs/implementation/phase-2.1-overview.md |
Current state of the builder architecture |
Specification References (for @see links and field accuracy)
| # | Document | Use |
|---|---|---|
| 7 | OGC API - Connected Systems Part 1 (23-001) | How servers advertise resource endpoints via link relations |
Convention Quick Reference
| Rule | Example |
|---|---|
Use .js extension for relative imports |
import { X } from './file.js' |
Use import type for interfaces/types |
import type { Y } from './model.js' |
| Three-tier hierarchy: import from lower tiers only | shared → ogc-api → csapi |
| Named exports for types and utilities | export interface Z { ... } |
as const arrays for enum-like values |
export const XTypes = [...] as const |
HTTP mocking: globalThis.fetch = jest.fn() |
Never use nock, msw, or other libraries |
| Meaningful tests only | Verify behavior, not that code runs without throwing |
Activity
feat(csapi): support multiple link relation conventions for resource …
docs: add live server re-test report confirming #34 and #35 fixes
docs: add Phase 2.2 implementation overview\n\nCovers Issues #34 (F1 …
docs: add Phase 2 code review report\n\nCovers Issues #5, #6, #34, #35 …
docs: add live server smoke test report for Phase 2.2
research(phase-9): fold in evidence from ogc-csapi-explorer/docs/impl…
research(phase-9): reframe doc with #188 as input to existing research