Repository navigation
Description
Task
Integrate the CSAPIQueryBuilder with the existing OgcApiEndpoint class by adding a conformance check, collections getter, and factory method — following the exact EDR integration pattern (PR #114). Total: 64 lines across 3 existing files.
ROADMAP Reference: Phase 1, Task 4 — Integrate with OgcApiEndpoint (~3-4 hours, Low complexity)
Files to Create or Modify
| File | Action | Est. Lines Added | Purpose |
|---|---|---|---|
src/ogc-api/endpoint.ts |
Modify | +35 | Import CSAPIQueryBuilder, add cache field, csapiCollections getter, hasConnectedSystems getter, csapi() factory method |
src/ogc-api/info.ts |
Modify | +12 | Add checkHasConnectedSystems() conformance detection function |
src/index.ts |
Modify | +17 | Export CSAPIQueryBuilder class and all CSAPI types from model.ts |
src/ogc-api/endpoint.spec.ts |
Modify | +100-150 | Add CSAPI conformance and factory method integration tests |
Path correction: The ROADMAP references
src/ogc-api/shared/info.ts, but the actual conformance check functions live insrc/ogc-api/info.ts(e.g.,checkHasEnvironmentalDataRetrievalis at line 96 ofsrc/ogc-api/info.ts). Follow the actual file path.
Blueprint Reference
Follow the EDR integration pattern exactly as established in PR #114. The three integration points each have a direct EDR equivalent to copy:
| Integration Point | EDR Blueprint (copy this) | CSAPI Equivalent (create this) |
|---|---|---|
| Cache field | collection_id_to_edr_builder_ (endpoint.ts line 63) |
collection_id_to_csapi_builder_ |
| Collections getter | edrCollections (endpoint.ts line 200) |
csapiCollections |
| Conformance getter | hasEnvironmentalDataRetrieval (endpoint.ts line 274) |
hasConnectedSystems |
| Factory method | edr() (endpoint.ts line 283) |
csapi() |
| Conformance check | checkHasEnvironmentalDataRetrieval (info.ts line 96) |
checkHasConnectedSystems |
| Exports | export * from './ogc-api/model.js' (index.ts line 45) |
Named type exports from ./ogc-api/csapi/model.js |
Scope — What to Implement
endpoint.ts Changes (+35 lines)
1. Import (1 line):
import CSAPIQueryBuilder from './csapi/url_builder.js';2. Import update — add to existing ./info.js import (1 line):
checkHasConnectedSystems, // Add to existing import block from './info.js'3. Cache field (2 lines):
private collection_id_to_csapi_builder_: Map<string, CSAPIQueryBuilder> = new Map();4. csapiCollections getter (6 lines):
- Follow the exact pattern of
edrCollectionsgetter (line 200) - Filter collections that have CSAPI resources
- Return
Promise<string[]>of collection names
5. hasConnectedSystems getter (6 lines):
- Follow the exact pattern of
hasEnvironmentalDataRetrievalgetter (line 274) - Delegates to
checkHasConnectedSystems()from info.ts - Return
Promise<boolean>
6. csapi() factory method (17 lines):
- Follow the exact pattern of
edr()method (line 283) - Check
hasConnectedSystemsconformance first - Use
collection_id_to_csapi_builder_cache for performance - Instantiate
CSAPIQueryBuilderwith collection info - Return
Promise<CSAPIQueryBuilder>
info.ts Changes (+12 lines)
checkHasConnectedSystems() function:
- Follow the exact pattern of
checkHasEnvironmentalDataRetrieval(line 96) - Check for CSAPI Part 1 Core conformance class:
http://www.opengis.net/spec/ogcapi-connectedsystems-1/1.0/conf/core - OR CSAPI Part 2 Dynamic Data conformance class:
http://www.opengis.net/spec/ogcapi-connectedsystems-2/1.0/conf/dynamic-data - Return
boolean
index.ts Changes (+17 lines)
Export CSAPIQueryBuilder class:
export { default as CSAPIQueryBuilder } from './ogc-api/csapi/url_builder.js';Export CSAPI types (named type exports):
export type {
System,
Deployment,
SamplingFeature,
Procedure,
Property,
Datastream,
Observation,
Control,
ControlStream,
Command,
QueryOptions,
SystemQueryOptions,
ObservationQueryOptions,
} from './ogc-api/csapi/model.js';JSDoc Requirements
- Document
hasConnectedSystemsgetter matching the JSDoc style ofhasEnvironmentalDataRetrieval(endpoint.ts line 271-273) - Document
csapiCollectionsgetter matching the JSDoc style ofedrCollections - Document
csapi()factory method matching the JSDoc style ofedr()(endpoint.ts line 280-282) - Document
checkHasConnectedSystems()with parameter description and@seelink to CSAPI Part 1 conformance class specification - Follow the JSDoc style already used in
src/ogc-api/endpoint.ts
Testing Requirements
- Extend
src/ogc-api/endpoint.spec.ts(+100-150 lines) - Follow the exact pattern of the "OgcApiEndpoint with EDR" test block (line 2543+)
- Conformance tests:
- Server with CSAPI Part 1 conformance →
hasConnectedSystemsresolves totrue - Server with CSAPI Part 2 conformance →
hasConnectedSystemsresolves totrue - Server without CSAPI conformance →
hasConnectedSystemsresolves tofalse - Existing
hasEnvironmentalDataRetrievalstill works (regression check)
- Server with CSAPI Part 1 conformance →
- Collections getter tests:
csapiCollectionsreturns array of collection names that support CSAPIcsapiCollectionsreturns empty array when no CSAPI support
- Factory method tests:
csapi(collectionId)returns aCSAPIQueryBuilderinstance- Factory method caches builders (same instance returned for same collectionId)
- Factory method throws
EndpointErrorwhen endpoint has no CSAPI conformance
- Test fixtures: Create minimal CSAPI conformance fixture(s) in
fixtures/ogc-api/if needed, following existing fixture patterns (e.g.,fixtures/ogc-api/sample-data.json)
Scope — What NOT to Touch
- ❌ Do NOT create or modify
model.ts— that belongs to Phase 1.1 (issue Phase 1.1: Create Type System (csapi/model.ts) #1) - ❌ Do NOT create or modify
helpers.ts— that belongs to Phase 1.2 (issue Phase 1.2: Create Helper Utilities (csapi/helpers.ts) #2) - ❌ Do NOT create or modify
url_builder.ts— that belongs to Phase 1.3 (issue Phase 1.3: Create Stub QueryBuilder (csapi/url_builder.ts) #3) - ❌ Do NOT implement any QueryBuilder methods beyond what issue Phase 1.3: Create Stub QueryBuilder (csapi/url_builder.ts) #3 provides — those belong to Phase 2 (issues Phase 2.1: Systems Methods #5-Phase 2.9: Commands Methods #13)
- ❌ Do NOT add format parsers or format detection — those belong to Phase 3 (issues Phase 3.1: GeoJSON Handler Extensions #14-Phase 3, Task 17: Format Index #30)
- ❌ Do NOT modify the EDR integration code (cache, getter, factory method) — preserve existing behavior exactly
- ❌ Do NOT refactor or reorganize existing imports in endpoint.ts beyond what's needed for CSAPI
- ❌ 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
-
src/ogc-api/endpoint.tshascsapi()factory method following EDR pattern exactly -
src/ogc-api/endpoint.tshashasConnectedSystemsgetter -
src/ogc-api/endpoint.tshascsapiCollectionsgetter -
src/ogc-api/endpoint.tshas cache fieldcollection_id_to_csapi_builder_ -
src/ogc-api/endpoint.tsimportsCSAPIQueryBuilderandcheckHasConnectedSystems -
src/ogc-api/info.tshascheckHasConnectedSystems()function checking both Part 1 and Part 2 conformance URIs -
src/index.tsexportsCSAPIQueryBuilderclass and all CSAPI types - All new code has complete JSDoc documentation matching existing style
-
src/ogc-api/endpoint.spec.tshas CSAPI conformance, collections, and factory method tests - Existing tests still pass (
npm test) — no regressions to EDR or other API detection - No lint errors
- Total integration code is ~64 lines (35 + 12 + 17) — minimal footprint
Dependencies
Blocked by: #1 — Phase 1.1: Create Type System (index.ts exports types from model.ts), #2 — Phase 1.2: Create Helper Utilities, #3 — Phase 1.3: Create Stub QueryBuilder (endpoint.ts imports and instantiates CSAPIQueryBuilder)
Blocks: #5-#13 — Phase 2: All QueryBuilder method implementations (they rely on the factory method being available for end-to-end testing)
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/planning/csapi-implementation-guide.md §5: "OgcApiEndpoint Integration" |
Lines 370-470 | Complete integration code — exact code blocks for all 3 files (endpoint.ts, info.ts, index.ts) with line-by-line breakdown. Copy-pasteable. |
| 2 | docs/planning/csapi-implementation-guide.md §5: "Conformance Reader" |
Lines 330-370 | Conformance class URIs — all 10 CSAPI conformance classes to detect (Part 1 Core + Part 2 Dynamic Data used in checkHasConnectedSystems) |
| 3 | src/ogc-api/endpoint.ts |
Lines 55-300 | EDR integration blueprint — the exact pattern to follow for cache field (line 63), collections getter (line 200), conformance getter (line 274), and factory method (line 283) |
| 4 | src/ogc-api/info.ts |
Lines 96-107 | Conformance check blueprint — checkHasEnvironmentalDataRetrieval function to copy for checkHasConnectedSystems |
| 5 | src/ogc-api/endpoint.spec.ts |
Lines 2543-2650 | Test blueprint — "OgcApiEndpoint with EDR" test block to follow for CSAPI integration tests |
Upstream Type/Import References (files this task imports from)
| # | Document | What to Import |
|---|---|---|
| 6 | src/ogc-api/csapi/url_builder.ts (created in issue #3) |
CSAPIQueryBuilder (default export) |
| 7 | src/ogc-api/csapi/model.ts (created in issue #1) |
All CSAPI type exports for re-export in index.ts |
| 8 | src/ogc-api/model.ts |
OgcApiCollectionInfo (already imported in endpoint.ts) |
| 9 | src/shared/errors.ts |
EndpointError (already imported in endpoint.ts) |
Research References (context, not required reading)
| # | Document | What It Provides |
|---|---|---|
| 10 | docs/research/upstream/pr114-analysis.md |
PRIMARY blueprint — Complete analysis of how EDR was integrated (PR #114), factory method lifecycle, caching strategy |
| 11 | docs/research/upstream/integration-analysis.md |
Line-by-line integration requirements for all 3 files |
| 12 | docs/research/upstream/querybuilder-pattern-analysis.md |
Factory method lifecycle, caching strategy, state management |
| 13 | docs/research/requirements/csapi-conformance-capabilities.md |
All conformance classes and detection mechanisms |
| 14 | docs/planning/ROADMAP.md Phase 1, Task 4 |
Lines 105-120 — task description with time estimates |
Specification References (for @see links in JSDoc)
| # | Document | Use |
|---|---|---|
| 15 | OGC API - Connected Systems Part 1 (23-001) | Conformance class URIs for Part 1 Core detection |
| 16 | OGC API - Connected Systems Part 2 (23-002) | Conformance class URIs for Part 2 Dynamic Data detection |
| 17 | docs/research/standards/ogcapi-connectedsystems-1.bundled.oas31.yaml |
Part 1 OpenAPI schema — conformance endpoint definition |
| 18 | docs/research/standards/ogcapi-connectedsystems-2.bundled.oas31.yaml |
Part 2 OpenAPI schema — conformance endpoint definition |
Convention Quick Reference
| Rule | Example |
|---|---|
Use .js extension for relative imports |
import CSAPIQueryBuilder from './csapi/url_builder.js' |
Use import type for interfaces/types |
import type { System } from './ogc-api/csapi/model.js' |
| Default export for QueryBuilder class | export { default as CSAPIQueryBuilder } from '...' |
| Follow existing getter JSDoc style | Match hasEnvironmentalDataRetrieval JSDoc block |
| Follow existing factory method style | Match edr() method signature, error handling, caching |
HTTP mocking in tests: globalThis.fetch = jest.fn() |
Follow endpoint.spec.ts existing patterns |
Test fixtures in fixtures/ogc-api/ |
Create minimal CSAPI fixture matching existing fixture structure |
| Meaningful tests only | Verify conformance detection, caching behavior, error messages — not just that methods exist |
Activity
feat(csapi): integrate CSAPIQueryBuilder with OgcApiEndpoint (Issue #4)
research(phase-9): fold in evidence from ogc-csapi-explorer/docs/impl…
research(phase-9): fold in evidence from OSHConnect-Python/docs/research
research(phase-9): reframe doc with #188 as input to existing research
research(phase-9): add Courses of Action section with recommendation
research(phase-9): rework COAs around actual donation workflow
research(phase-9): add full-scope live-testing experiment plan