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
Create parsers for all SWE Common 3.0 simple component types in components.ts, covering the 6 scalar components (Quantity, Count, Text, Boolean, Time, Category) and the 4 range components (QuantityRange, CountRange, TimeRange, CategoryRange), with UOM parsing, constraint handling, NilValues support, and quality indicators.
ROADMAP Reference: Phase 3, Task 11 — SWE Common Simple Components Parser (~2-3 hours, Medium-High complexity)
Files to Create or Modify
File
Action
Est. Lines
Purpose
src/ogc-api/csapi/formats/swecommon/components.ts
Create
~300-400
Parsers for all 10 simple component types (6 scalar + 4 range)
Component parser tests — each type, constraints, UOM, NilValues
Blueprint Reference
Follow the EDR pattern in src/ogc-api/edr/model.ts (126 lines) for file structure and src/ogc-api/edr/model.spec.ts (42 lines) for test patterns.
Scope — What to Implement
Scalar Component Parsers
Each parser takes a raw JSON object and returns a typed interface value. All scalar components extend AbstractSimpleComponent which provides shared optional properties: id, label, description, definition (URI), nilValues, quality.
Validate: uom should be present (UCUM code like "Cel", "m/s", "%")
OGC spec description: "Scalar component with decimal representation and a unit of measure used to store value of a continuous quantity"
parseCount(json: unknown): Count
Parse: type: 'Count', value (integer), constraint (AllowedValues), quality, nilValues
No uom — counts are dimensionless integers
OGC spec description: "Scalar component with integer representation used for a discrete counting value"
parseBoolean(json: unknown): Boolean
Parse: type: 'Boolean', value (boolean)
Simplest scalar component — no constraints, no UOM
OGC spec description: "Scalar component used to express truth: True or False, 0 or 1"
parseText(json: unknown): Text
Parse: type: 'Text', value (string), constraint (AllowedTokens — enumeration list or regex pattern)
OGC spec description: "Free text component used to store comments or any other type of textual statement"
parseTime(json: unknown): Time
Parse: type: 'Time', value (ISO 8601 string or number), uom (UnitOfMeasure), constraint (AllowedTimes — time range or enumerated times), referenceFrame (temporal CRS URI), referenceTime (ISO 8601 epoch)
OGC spec description: "Scalar component used to represent a time quantity either as ISO 8601 (e.g., 2004-04-18T12:03:04.6Z) or as a duration relative to a time of reference"
parseCategory(json: unknown): Category
Parse: type: 'Category', value (string token), constraint (AllowedTokens), codeSpace (URI to controlled vocabulary)
OGC spec description: "Scalar component used to represent a categorical value as a simple token identifying a term in a code space"
Range Component Parsers
Range components represent pairs of values (min/max). Each extends the corresponding scalar type's constraint structure.
❌ 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
components.ts exists with individual parse functions for all 6 scalar types (Quantity, Count, Boolean, Text, Time, Category)
components.ts includes individual parse functions for all 4 range types (QuantityRange, CountRange, TimeRange, CategoryRange)
parseSimpleComponent discriminator function dispatches by type field to the correct parser
UOM parsing handles both code (UCUM) and href (URI) formats
Constraint parsing covers AllowedValues, AllowedTokens, and AllowedTimes
NilValues and Quality indicator parsing implemented
All new code has complete JSDoc documentation with @see spec references
components.spec.ts exists with tests for each component type, constraints, UOM, and error handling
Existing tests still pass (npm test)
No lint errors
Dependencies
Blocked by: Issue #17 — SWE Common Types (must have interfaces to return) Blocks: Issue #27 — SWE Common Main Parser (imports parseSimpleComponent for type discrimination)
Task
Create parsers for all SWE Common 3.0 simple component types in
components.ts, covering the 6 scalar components (Quantity, Count, Text, Boolean, Time, Category) and the 4 range components (QuantityRange, CountRange, TimeRange, CategoryRange), with UOM parsing, constraint handling, NilValues support, and quality indicators.ROADMAP Reference: Phase 3, Task 11 — SWE Common Simple Components Parser (~2-3 hours, Medium-High complexity)
Files to Create or Modify
src/ogc-api/csapi/formats/swecommon/components.tssrc/ogc-api/csapi/formats/swecommon/components.spec.tsBlueprint Reference
Follow the EDR pattern in
src/ogc-api/edr/model.ts(126 lines) for file structure andsrc/ogc-api/edr/model.spec.ts(42 lines) for test patterns.Scope — What to Implement
Scalar Component Parsers
Each parser takes a raw JSON object and returns a typed interface value. All scalar components extend
AbstractSimpleComponentwhich provides shared optional properties:id,label,description,definition(URI),nilValues,quality.parseQuantity(json: unknown): Quantitytype: 'Quantity',uom(UnitOfMeasure —codeand/orhref),value(number),constraint(AllowedValues),quality(Quality[]),nilValues(NilValues[])uomshould be present (UCUM code like"Cel","m/s","%")parseCount(json: unknown): Counttype: 'Count',value(integer),constraint(AllowedValues),quality,nilValuesuom— counts are dimensionless integersparseBoolean(json: unknown): Booleantype: 'Boolean',value(boolean)parseText(json: unknown): Texttype: 'Text',value(string),constraint(AllowedTokens — enumeration list or regex pattern)parseTime(json: unknown): Timetype: 'Time',value(ISO 8601 string or number),uom(UnitOfMeasure),constraint(AllowedTimes — time range or enumerated times),referenceFrame(temporal CRS URI),referenceTime(ISO 8601 epoch)parseCategory(json: unknown): Categorytype: 'Category',value(string token),constraint(AllowedTokens),codeSpace(URI to controlled vocabulary)Range Component Parsers
Range components represent pairs of values (min/max). Each extends the corresponding scalar type's constraint structure.
parseQuantityRange(json: unknown): QuantityRangetype: 'QuantityRange',uom(UnitOfMeasure),value([number, number] pair),constraint(AllowedValues)parseCountRange(json: unknown): CountRangetype: 'CountRange',value([integer, integer] pair),constraint(AllowedValues)parseTimeRange(json: unknown): TimeRangetype: 'TimeRange',value([string, string] ISO 8601 pair),uom,constraint(AllowedTimes),referenceFrame,referenceTimeparseCategoryRange(json: unknown): CategoryRangetype: 'CategoryRange',value([string, string] token pair),constraint(AllowedTokens),codeSpaceShared Helpers
parseUnitOfMeasure(json: unknown): UnitOfMeasurecode(UCUM code string) and/orhref(URI to unit definition)parseAllowedValues(json: unknown): AllowedValuesvalueslist and/orintervals(inclusive ranges)parseAllowedTokens(json: unknown): AllowedTokensvalueslist orpattern(regex)parseAllowedTimes(json: unknown): AllowedTimesparseNilValues(json: unknown): NilValues[]parseQuality(json: unknown): Quality[]Discriminator Function
parseSimpleComponent(json: unknown): AnySimpleComponenttypefield and dispatch to the correct parserAnySimpleComponentunion of all 10 simple typesJSDoc Requirements
@param,@returns, and a usage example@seelinks to OGC SWE Common 3.0 (24-014) for each component typesrc/ogc-api/edr/model.tsTesting Requirements
src/ogc-api/csapi/formats/swecommon/components.spec.ts(~200-300 lines)"Cel","m/s","%")src/ogc-api/edr/model.spec.tsScope — What NOT to Touch
types.ts— that belongs to Issue Phase 3.4: SWE Common Types #17 (SWE Common Types)parser.ts— that belongs to Issue Phase 3, Task 14: SWE Common Main Parser #27 (SWE Common Main Parser)data-record.ts— that belongs to Issue Phase 3, Task 12: SWE Common DataRecord Parser #25 (SWE Common DataRecord Parser)data-array.ts— that belongs to Issue Phase 3, Task 13: SWE Common DataArray Parser #26 (SWE Common DataArray Parser)index.ts— that belongs to Issue Phase 3, Task 15: SWE Common Index #28 (SWE Common Index)Acceptance Criteria
components.tsexists with individual parse functions for all 6 scalar types (Quantity, Count, Boolean, Text, Time, Category)components.tsincludes individual parse functions for all 4 range types (QuantityRange, CountRange, TimeRange, CategoryRange)parseSimpleComponentdiscriminator function dispatches bytypefield to the correct parsercode(UCUM) andhref(URI) formats@seespec referencescomponents.spec.tsexists with tests for each component type, constraints, UOM, and error handlingnpm test)Dependencies
Blocked by: Issue #17 — SWE Common Types (must have interfaces to return)
Blocks: Issue #27 — SWE Common Main Parser (imports
parseSimpleComponentfor type discrimination)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.mdcomponents.ts(~300-400 lines)docs/planning/csapi-implementation-guide.mdSWEDataComponentunion,Quantityinterface,UnitOfMeasure,AllowedValues, encodingssrc/ogc-api/edr/model.tssrc/ogc-api/edr/model.spec.tsUpstream Type/Import References (files this task imports from)
src/ogc-api/csapi/formats/swecommon/types.tsQuantity,Count,Boolean,Text,Time,Category,QuantityRange,CountRange,TimeRange,CategoryRange,AnySimpleComponent,UnitOfMeasure,AllowedValues,AllowedTokens,AllowedTimes,NilValues,QualityResearch References (context, not required reading)
docs/research/requirements/csapi-datatype-schema-requirements.mddocs/research/testing/findings/04-implementation-guide-testing-requirements.mdSpecification References (for
@seelinks and field accuracy)docs/research/standards/ogcapi-connectedsystems-2.bundled.oas31.yamlQuantity(L7530),Count(L7516),Boolean(L7500),Text(L7564),Time(L7546),Category(L7559),QuantityRange(L7576),CountRange(L7571),TimeRange(L7581),CategoryRange(L7586),AnySimpleComponent(L7591),AllowedValues(L7510),AllowedTokens(L7555),AllowedTimes(L7543)Convention Quick Reference
.jsextension for relative importsimport { X } from './file.js'import typefor interfaces/typesimport type { Y } from './model.js'export interface Z { ... }as constarrays for enum-like valuesexport const XTypes = [...] as constglobalThis.fetch = jest.fn()