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
Extend the CSAPI helpers with client-side validation functions that check resource documents against OGC Connected Systems Part 1 and Part 2 requirements before sending requests or after parsing responses.
Add validation utility functions for Part 1 resources, Part 2 resources, and cross-reference integrity
src/ogc-api/csapi/helpers.spec.ts
Create
~200-400
Tests for all validation functions — focused on rejecting invalid inputs
Blueprint Reference
Follow the existing error pattern in src/shared/errors.ts (157 lines) — EndpointError for endpoint-level errors. The validation functions should throw EndpointError or return structured validation results following the existing library error conventions. Follow the resource availability validation pattern in the Guide §5 Resource Validation Strategy (lines 538-570) — throw new EndpointError(...) with descriptive messages including what was expected vs. what was found.
EDR blueprint: src/ogc-api/edr/helpers.ts — pure utility functions, no class dependencies.
Scope — What to Implement
Part 1 Resource Validation Functions
Add validation functions to helpers.ts that check GeoJSON-encoded resource documents against the OGC Part 1 OpenAPI spec required fields. Each validator takes a parsed resource object and returns validation errors.
Base Feature Validation (shared by all Part 1 GeoJSON resources):
featureType — required string (from base feature schema)
uid — required string, URI format
name — required string, minLength 1
Systems:
Base feature requirements (featureType, uid, name)
featureType must be from SystemTypeUris enum (sosa:Sensor, sosa:Actuator, sosa:Platform, sosa:Sampler, sosa:System, or full URI equivalents)
Deployments:
Base feature requirements (featureType, uid, name)
featureType must be from DeploymentTypeUris enum (sosa:Deployment or full URI)
validTime — required timePeriod object
Procedures:
Base feature requirements (featureType, uid, name)
featureType must be from ProcedureTypeUris enum
Sampling Features:
Base feature requirements (featureType, uid, name)
sampledFeature@link — required link object (must have valid href)
Task
Extend the CSAPI helpers with client-side validation functions that check resource documents against OGC Connected Systems Part 1 and Part 2 requirements before sending requests or after parsing responses.
ROADMAP Reference: Phase 3, Task 3 — Validator Extensions (~3-4 hours, Medium complexity)
Files to Create or Modify
src/ogc-api/csapi/helpers.tssrc/ogc-api/csapi/helpers.spec.tsBlueprint Reference
Follow the existing error pattern in
src/shared/errors.ts(157 lines) —EndpointErrorfor endpoint-level errors. The validation functions should throwEndpointErroror return structured validation results following the existing library error conventions. Follow the resource availability validation pattern in the Guide §5 Resource Validation Strategy (lines 538-570) —throw new EndpointError(...)with descriptive messages including what was expected vs. what was found.EDR blueprint:
src/ogc-api/edr/helpers.ts— pure utility functions, no class dependencies.Scope — What to Implement
Part 1 Resource Validation Functions
Add validation functions to
helpers.tsthat check GeoJSON-encoded resource documents against the OGC Part 1 OpenAPI spec required fields. Each validator takes a parsed resource object and returns validation errors.Base Feature Validation (shared by all Part 1 GeoJSON resources):
featureType— required string (from basefeatureschema)uid— required string, URI formatname— required string, minLength 1Systems:
featureType,uid,name)featureTypemust be fromSystemTypeUrisenum (sosa:Sensor,sosa:Actuator,sosa:Platform,sosa:Sampler,sosa:System, or full URI equivalents)Deployments:
featureType,uid,name)featureTypemust be fromDeploymentTypeUrisenum (sosa:Deploymentor full URI)validTime— requiredtimePeriodobjectProcedures:
featureType,uid,name)featureTypemust be fromProcedureTypeUrisenumSampling Features:
featureType,uid,name)sampledFeature@link— required link object (must have validhref)Properties (non-GeoJSON,
DerivedPropertyschema):uniqueId— required string, URI formatlabel— required stringbaseProperty— required string, URI formatPart 2 Resource Validation Functions
resultSchemais present and is a valid SWE Common DataComponent structure (structural check only — deep SWE validation is Issue Phase 3.4: SWE Common Types #17/Phase 3, Task 11: SWE Common Simple Components Parser #24-Phase 3, Task 15: SWE Common Index #28)phenomenonTimeis present, result structure existsCross-Reference Validation Functions
href(non-empty string, valid URI format), validrelstringValidation Error Reporting
Follow the Guide's error reporting pattern:
JSDoc Requirements
@seelinks to OGC Part 1 (23-001) for Part 1 validators, Part 2 (23-002) for Part 2 validators@seelink to RFC 8141 for URI validationsrc/shared/errors.tsTesting Requirements
src/ogc-api/csapi/helpers.spec.ts(~200-400 lines)uid→ error)featureType(e.g., System withfeatureType: "invalid"→ error)uid: "not a uri"→ error)validTime.start > validTime.end→ error)resultSchema→ error)phenomenonTime→ error)href→ error)src/shared/errors.spec.ts(202 lines)Scope — What NOT to Touch
src/shared/errors.ts— use the existingEndpointErrorclass as-issrc/ogc-api/csapi/url_builder.ts— the QueryBuilder's resource availability validation (Issue Phase 1.3: Create Stub QueryBuilder (csapi/url_builder.ts) #3) is separate from document content validationsrc/ogc-api/csapi/model.ts— type definitions are Issue Phase 1.1: Create Type System (csapi/model.ts) #1's scopeAcceptance Criteria
helpers.tsexports validation functions for all 5 Part 1 resource types (Systems, Deployments, Procedures, Sampling Features, Properties)helpers.tsexports validation functions for all 4 Part 2 resource types (DataStreams, Observations, Control Streams, Commands)helpers.tsexports cross-reference validation utilities (link validation, URI format, temporal format)featurerequirements (featureType,uid,name) plus resource-specific requirements@seespec referenceshelpers.spec.tsexists with tests that verify validators correctly reject invalid inputsnpm test)Dependencies
Blocked by: Issue #1 (Type System — provides
CsapiSystem,CsapiDeployment, etc. interfaces that validators type-check against), Issue #2 (Helper Utilities —helpers.tsmust exist before extending it)Blocks: Issue #31 (Integration Tests — uses validators), Issue #32 (Unit Tests Completion — validator coverage)
Operational Constraints
Key constraints for this task:
References
Read these documents before starting implementation. They are ordered by priority.
Primary References (must read)
docs/planning/csapi-implementation-guide.mddocs/planning/csapi-implementation-guide.mdEndpointErrorthrow pattern for validation failuressrc/shared/errors.tsEndpointErrorclass definition andServiceExceptionErrorpatternsrc/shared/errors.spec.tssrc/ogc-api/edr/helpers.tsUpstream Type/Import References (files this task imports from)
src/shared/errors.tsEndpointErrorclass for validation error throwingsrc/ogc-api/csapi/model.ts(Issue #1)Research References (context, not required reading)
docs/planning/ROADMAP.md(Lines 369-380)docs/planning/csapi-implementation-guide.md(Lines 2061-2065)helpers.tslocationSpecification References (for
@seelinks and field accuracy)docs/research/standards/ogcapi-connectedsystems-1.bundled.oas31.yamlfeatureschema (line 1835):featureType,uid,namerequired;SystemTypeUris(line 1876);DeploymentTypeUris(line 4555);ProcedureTypeUris;samplingFeature(line 4756);DerivedProperty/property(lines 4789-4840)docs/research/standards/ogcapi-connectedsystems-2.bundled.oas31.yamlConvention Quick Reference
.jsextension for relative importsimport { X } from './file.js'import typefor interfaces/typesimport type { Y } from './model.js'export function validateSystem(...) { ... }globalThis.fetch = jest.fn()