You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sub-task of #179. Additive pass: introduce endpoint.csapi(id): Promise<CSAPIQueryBuilder> mirroring endpoint.edr(id). Does NOT re-privatize anything yet — the existing public surface stays intact so this lands as a pure addition.
Goal
Land a working endpoint.csapi(id) entry point with dynamic import and EndpointError wrapping. Tests for the new path. After this commit, both the new factory entry AND the old endpoint.root + manual factory call paths still work.
Tasks
Add csapi(id: string): Promise<CSAPIQueryBuilder> method on OgcApiEndpoint mirroring the edr(id) shape exactly (same dynamic-import pattern, same error-wrapping convention).
src/ogc-api/endpoint.ts — added public async csapi(collectionId): Promise<CSAPIQueryBuilder> mirroring edr() but with: dynamic await import(''./csapi/factory.js'') and await import(''./csapi/helpers.js'') (preserves P6 Task 6: Modify endpoint.ts — Remove CSAPI Coupling #122''s dependency-edge contract), capability gate if (!(await this.hasConnectedSystems)) (no missing-await bug), and try/catch wrapping non-EndpointError failures into EndpointError while re-throwing existing EndpointErrors as-is (no double-wrap).
src/ogc-api/csapi/factory.ts — reshaped createCSAPIBuilder from async (endpoint, collectionId) to pure (collection: CSAPICollectionRef, resourceUrls: ReadonlyMap<string,string>): CSAPIQueryBuilder. No I/O, no await, no error paths. Defensive new Map(resourceUrls) for the ReadonlyMap contract.
src/ogc-api/csapi/factory.spec.ts — full rewrite. Removed all fake-OgcApiEndpoint test doubles. 5 value-shaped tests covering availableResources extraction, ReadonlyMap defensive copy, builder independence, and pure-synchronous behavior. Net: −136 LOC + 117 LOC = −19 LOC overall (cleaner than estimated).
src/ogc-api/endpoint.spec.ts — new describe(''csapi()'') block with 5 tests: happy path (3-resource collection), empty-resources collection, no-CSAPI-support EndpointError, network-error wrapping (TypeError → EndpointError), EndpointError pass-through (no double-wrap).
Deviation from implementation guide §4.6 step 3: the guide''s snippet routes through getCollectionInfo(), but parseBaseCollectionInfo() at src/ogc-api/info.ts:130 strips links via destructuring (const { links, ...props } = doc;). CSAPIQueryBuilder.extractAvailableResources depends on collection.links, so routing through getCollectionInfo breaks availableResources. csapi() instead shapes the raw collection document into a CSAPICollectionRef directly:
Re-privatize OgcApiEndpoint.root and getCollectionDocument
Delete isCollectionInfo from factory.ts (already gone — file no longer imports OgcApiEndpoint or OgcApiCollectionInfo since the reshape; the runtime narrowing now lives at the csapi() call site as plain field-shape construction)
Migrate endpoint.spec.ts:2868''s getCollectionDocument-shape assertion onto getCollectionInfo (or re-target via csapi() since csapi() now exposes the same path)
Sub-finding for D1c: the isCollectionInfo cast is already gone as of this commit (git grep -n isCollectionInfo -- src/ returns 0 matches). D1c''s acceptance gate on that line is satisfied; D1c remains responsible for the visibility flips and the one external test-caller migration.
Activity
Sam-Bolling commentedon Apr 30, 2026
D1b shipped in commit
a41ce07.Changes:
src/ogc-api/endpoint.ts— addedpublic async csapi(collectionId): Promise<CSAPIQueryBuilder>mirroringedr()but with: dynamicawait import(''./csapi/factory.js'')andawait import(''./csapi/helpers.js'')(preserves P6 Task 6: Modify endpoint.ts — Remove CSAPI Coupling #122''s dependency-edge contract), capability gateif (!(await this.hasConnectedSystems))(no missing-awaitbug), and try/catch wrapping non-EndpointErrorfailures intoEndpointErrorwhile re-throwing existingEndpointErrors as-is (no double-wrap).src/ogc-api/csapi/factory.ts— reshapedcreateCSAPIBuilderfrom async(endpoint, collectionId)to pure(collection: CSAPICollectionRef, resourceUrls: ReadonlyMap<string,string>): CSAPIQueryBuilder. No I/O, noawait, no error paths. Defensivenew Map(resourceUrls)for the ReadonlyMap contract.src/ogc-api/csapi/factory.spec.ts— full rewrite. Removed all fake-OgcApiEndpointtest doubles. 5 value-shaped tests covering availableResources extraction, ReadonlyMap defensive copy, builder independence, and pure-synchronous behavior. Net: −136 LOC + 117 LOC = −19 LOC overall (cleaner than estimated).src/ogc-api/endpoint.spec.ts— newdescribe(''csapi()'')block with 5 tests: happy path (3-resource collection), empty-resources collection, no-CSAPI-supportEndpointError, network-error wrapping (TypeError → EndpointError),EndpointErrorpass-through (no double-wrap).Deviation from implementation guide §4.6 step 3: the guide''s snippet routes through
getCollectionInfo(), butparseBaseCollectionInfo()atsrc/ogc-api/info.ts:130stripslinksvia destructuring (const { links, ...props } = doc;).CSAPIQueryBuilder.extractAvailableResourcesdepends oncollection.links, so routing throughgetCollectionInfobreaksavailableResources.csapi()instead shapes the raw collection document into aCSAPICollectionRefdirectly:This matches the guide''s intent (typed value-shaped factory input) while preserving correctness. Documented inline at the call site.
Verification:
npx tsc --noEmit→ cleannpx eslint src/ogc-api/{endpoint,csapi/factory}{,.spec}.ts→ cleannpx prettier --check(same set) → cleannpx jest "src/ogc-api/csapi/factory.spec" "src/ogc-api/endpoint.spec"→ 94/94 passednpx jest src/ogc-api src/shared/mime-type --forceExit→ 1520/1520 passed, 36 suitesDeferred to D1c (#184):
OgcApiEndpoint.rootandgetCollectionDocumentisCollectionInfofromfactory.ts(already gone — file no longer importsOgcApiEndpointorOgcApiCollectionInfosince the reshape; the runtime narrowing now lives at thecsapi()call site as plain field-shape construction)endpoint.spec.ts:2868''sgetCollectionDocument-shape assertion ontogetCollectionInfo(or re-target viacsapi()sincecsapi()now exposes the same path)Sub-finding for D1c: the
isCollectionInfocast is already gone as of this commit (git grep -n isCollectionInfo -- src/returns 0 matches). D1c''s acceptance gate on that line is satisfied; D1c remains responsible for the visibility flips and the one external test-caller migration.Closing as completed. Proceeding to D1c/#184.
feat(endpoint): add OgcApiEndpoint.csapi(); reshape createCSAPIBuilde…