Skip to content

P6 Task 6: Modify endpoint.ts — Remove CSAPI Coupling #122

@Sam-Bolling

Description

@Sam-Bolling

Task

Modify src/ogc-api/endpoint.ts to remove all CSAPI imports, the CSAPI builder cache, the csapi() method, and extractRootResourceUrls(). Change root and getCollectionDocument from private to public so the factory function (created in Task 5) can access them. After this task, endpoint.ts has zero imports from csapi/.

ROADMAP Reference: Phase 6, Task 6 — Modify endpoint.ts (~0.5–1 hours, Medium complexity)
Implementation Branch: phase-6


Files to Create or Modify

File Action Lines Removed Lines Added Net Purpose
src/ogc-api/endpoint.ts Modify ~65 ~2 −63 Remove CSAPI coupling, change visibility

Total: 1 file modified, 896 → ~833 lines

Blueprint Reference

  • src/ogc-api/endpoint.ts current state — the file being modified
  • EDR pattern on endpoint — hasConnectedSystems and csapiCollections follow the same pattern as EDR getters that jahow approved
  • P6 Implementation Guide §7.1 — Complete modification specification with line references

Scope — What to Implement

Removals (5 items, ~67 lines removed)

What Location Lines
import CSAPIQueryBuilder from './csapi/url_builder.js' Line 52 1
import { scanCsapiLinks } from './csapi/helpers.js' Line 53 1
private collection_id_to_csapi_builder_: Map<...> Lines 70–71 2
csapi() method + JSDoc ~Lines 363–411 ~49
extractRootResourceUrls() + JSDoc ~Lines 424–437 ~14

Visibility Changes (2 items, 1-word changes)

What Before After
Root accessor private get root() public get root()
Collection doc method private getCollectionDocument( public getCollectionDocument(

These are 1-word changes each. The method implementations are completely unchanged.

JSDoc Update (1 item)

What Before After
hasConnectedSystems JSDoc @see @see {@link csapi} to create a query builder @see Import createCSAPIBuilder from '@camptocamp/ogc-client/csapi'

What Stays (Confirmed Safe — Zero CSAPI Imports)

  • hasConnectedSystems getter — uses info.ts checkHasConnectedSystems() with conformance URI strings only. Zero CSAPI imports.
  • csapiCollections getter — filters collections by link relations. Zero CSAPI imports.
  • All other endpoint functionality — Features, EDR, Tiles, Records, Maps, Styles, etc. are completely unaffected.

Verification

# Endpoint compiles without errors
npx tsc --noEmit

# Zero CSAPI imports remain in endpoint.ts
git grep "from.*csapi" src/ogc-api/endpoint.ts
# Expected: 0 matches

# All existing tests pass (endpoint tests that remain should still work)
npm run test:browser

Testing Requirements

  • Run npm run test:browser — existing endpoint tests for hasConnectedSystems and csapiCollections must still pass
  • The 3 CSAPI method tests (can produce a CSAPI query builder, caches the CSAPI query builder, throws an error when calling csapi()) will fail after this change — that's expected; they are removed in Task 7
  • Run npx tsc --noEmit — TypeScript must compile cleanly after removals and visibility changes

Scope — What NOT to Touch

  • ❌ Do NOT modify src/index.ts — that belongs to Task 7
  • ❌ Do NOT modify endpoint.spec.ts — that belongs to Task 7 (removes the 3 now-failing tests)
  • ❌ Do NOT modify factory.ts or factory.spec.ts — those were created in Task 5
  • ❌ Do NOT modify the barrel file csapi/index.ts — that was created in Task 4b
  • ❌ Do NOT modify package.json — that belongs to Task 8
  • ❌ Do NOT remove hasConnectedSystems or csapiCollections — they have zero CSAPI imports and stay on endpoint
  • ❌ Do NOT modify info.ts — it has zero CSAPI imports
  • ❌ Do NOT change any CSAPI business logic (types, builders, parsers, tests)
  • ❌ Do NOT refactor existing code beyond the specified removals and visibility changes

Acceptance Criteria

  • 2 CSAPI import lines removed (lines 52–53)
  • CSAPI builder cache map removed (lines 70–71)
  • csapi() method and its JSDoc removed (~49 lines)
  • extractRootResourceUrls() and its JSDoc removed (~14 lines)
  • root accessor changed from private to public
  • getCollectionDocument changed from private to public
  • hasConnectedSystems JSDoc @see updated to reference new import path
  • git grep "from.*csapi" src/ogc-api/endpoint.ts returns 0 matches
  • npx tsc --noEmit passes
  • hasConnectedSystems and csapiCollections getters unchanged and functional
  • npm run test:browser — all non-CSAPI-method tests pass (3 CSAPI method tests expected to fail until Task 7)

Dependencies

Blocked by: Task 5 — Create Factory Function (factory must exist as the replacement before the method is removed)
Blocks: Task 7 — Modify index.ts + endpoint.spec.ts (removes old exports and migrated tests)


Operational Constraints

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

For Phase 6 issues: Review the P6 Implementation Guide §7.1 for the complete endpoint modification specification.

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
  • Zero business logic changes: Phase 6 touches the integration boundary only

Phase 6 Architectural Constraints

  • Factory function replaces endpoint.csapi(): The method is removed here; its logic now lives in factory.ts (Task 5).
  • hasConnectedSystems and csapiCollections stay on endpoint: These have zero CSAPI imports. They use info.ts functions. They follow the EDR pattern that jahow approved.
  • root and getCollectionDocument visibility change: privatepublic is a 1-word change. The methods are unchanged in implementation.
  • No new dependencies: Zero new imports added to endpoint.ts.

Phase 6 Task-Specific Scope Boundaries

  • Task 6 (this task) must NOT modify index.ts or endpoint.spec.ts — modifies endpoint.ts only
  • Task 5 must NOT modify endpoint.ts — creates factory.ts and factory.spec.ts only
  • Task 7 must NOT modify endpoint.ts or factory.ts — modifies index.ts and endpoint.spec.ts only

References

Primary References (must read)

# Document What It Provides
1 P6 Implementation Guide §7.1 Complete removal list, visibility changes, what stays
2 P6 ROADMAP Task 6 Task definition, deliverables, dependencies
3 P6 Contribution Goal Criteria A3 (zero imports from csapi/ outside csapi/), B1/B2 (hasConnectedSystems/csapiCollections preserved)
4 Design Decision Resolution Report Visibility decision, caching removal decision, hasConnectedSystems retention decision

Convention Quick Reference

Rule Example
Visibility change private get root()public get root()
Removal verification git grep "from.*csapi" src/ogc-api/endpoint.ts → 0 matches
JSDoc @see update @see Import createCSAPIBuilder from '@camptocamp/ogc-client/csapi'
Preserve EDR pattern hasConnectedSystems and csapiCollections stay — zero CSAPI imports

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