Skip to content

Fix handling of extensions and update tests - #936

Merged
VisLab merged 2 commits into
hed-standard:mainfrom
VisLab:realign_phase_3
Oct 23, 2026
Merged

VisLab merged 2 commits into
hed-standard:mainfrom
VisLab:realign_phase_3

Conversation

@VisLab

@VisLab VisLab commented Oct 23, 2026

Copy link
Copy Markdown
Member

No description provided.

VisLab and others added 2 commits October 23, 2026 10:26
Split src/schema/entries.js and src/schema/parser.js into one file per
class under src/schema/entries/ and src/schema/parser/, with the
hed-typescript file and method names. Rename Schema, Schemas and
SchemaXmlCollection to HedSchema, HedSchemas and HedSchemaXMLCollection;
the old names stay as aliases through 4.x. A schema attribute now holds
one set of properties and a recursive flag; the version rules for
extensionAllowed (before 8.2.0) and inLibrary (before 8.3.0) are part of
that computation. Every property a schema defines is registered, so
8.3.0 and later gain 13 domain/range properties; no tag, attribute,
unit or value class changes (dump of 122 schema groups). parseSchemaXML
sets the parent links, so a schema file without a HED root or schema
element fails as localSchemaLoadFailed instead of a TypeError. Schema
faults use the invalidSchema code. Memoizer and core-js-pure are gone.

Removed without a major version: SchemaProperty.isCategoryProperty,
isTypeProperty, isRoleProperty; SchemaAttribute.categoryProperty,
typeProperty, roleProperties, propertyNames; getAttributeValue (now
getSingleAttributeValue and getAttributeValues). The schema entry
classes were never exported by the package; they are reachable only
inside the object buildSchemasFromVersion returns, no known consumer
uses these members (bids-validator imports only the Schemas type, which
is kept), and the schema class declarations are to be withdrawn from
types/index.d.ts before 4.3.0 (realignment plan, phase 5). The schema
declarations now match the runtime: members that never existed, such as
getValue and SchemaTag.isUnitClass, are removed, and
SchemaUnitClass.units is declared as the Map it always was.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A "#" after an extension term or in place of one (Item/Blech/#, Item/#)
is PLACEHOLDER_INVALID in a sidecar as in an events file; Onset/# stays
TAG_EXTENSION_INVALID. An extension term must contain a letter (A-Z or
a-z, or any Unicode letter from standard schema 8.3.0), so Item/Blech/3
and Item/1-2 are TAG_EXTENSION_INVALID for every schema version
(hed-specification PR hed-standard#726). Move hed-tests to 54f137e, whose new cases
pass with no skips.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Valid Unicode extensions can be rejected, and the new schema declarations expose constructors unavailable from the package entry point.

1 open issue
What changed in this PR

This PR corrects tag-extension validation in hed-validator and reorganizes the schema layer, with corresponding declaration and test updates.

Changes:

  • Distinguishes invalid placeholders from extensions and requires extension terms to contain a letter.
  • Splits schema entries and parsers into dedicated modules, renames containers, and simplifies attribute handling.
  • Updates TypeScript declarations, regression tests, documentation, and dependencies.
File Description
types/​test.ts Updates schema API type checks.
types/​index.d.ts Revises schema names and member declarations.
tests/​otherTests/​unmergedSchemas.spec.js Uses the single-value attribute accessor.
tests/​otherTests/​schemaParser.spec.js Adds schema parsing and compatibility tests.
tests/​otherTests/​characterSets.spec.js Updates the value-class import.
tests/​jsonTests/​tagParserTests.spec.js Updates the value-tag import.
tests/​jsonTestData/​tagParserTests.data.js Revises placeholder error expectations.
tests/​jsonTestData/​stringParserTests.data.js Revises extension-placeholder expectations.
src/​utils/​xml.js Normalizes XML definitions and assigns parents during parsing.
src/​utils/​memoizer.js Removes the shared memoizer.
src/​schema/​xmlType.js Extracts XML element helpers.
src/​schema/​xmlCollection.js Renames the collection and retains an alias.
src/​schema/​specs.js Adds specification comparison and input validation.
src/​schema/​parser/​valueClass.js Extracts value-class parsing.
src/​schema/​parser/​unitModifier.js Extracts unit-modifier parsing.
src/​schema/​parser/​unitClass.js Extracts unit-class parsing and merging.
src/​schema/​parser/​tag.js Extracts tag parsing and attribute propagation.
src/​schema/​parser/​schemaParser.js Coordinates entry parsers.
src/​schema/​parser/​schemaEntry.js Extracts shared parsing and merge logic.
src/​schema/​parser/​property.js Registers schema properties.
src/​schema/​parser/​attribute.js Builds simplified attributes and recursion flags.
src/​schema/​parser.js Removes the monolithic parser module.
src/​schema/​loader.js Uses the default XML parser export.
src/​schema/​init.js Integrates renamed containers and extracted parsers.
src/​schema/​entries/​valueTag.js Extracts value-tag behavior and comparison.
src/​schema/​entries/​valueClass.js Extracts value-class validation.
src/​schema/​entries/​unitModifier.js Extracts the unit-modifier class.
src/​schema/​entries/​unitClass.js Extracts unit-class behavior.
src/​schema/​entries/​unit.js Extracts unit validation and conversion.
src/​schema/​entries/​tag.js Extracts tag behavior and ancestor caching.
src/​schema/​entries/​schemaEntryWithAttributes.js Introduces explicit single/all-value accessors.
src/​schema/​entries/​schemaEntryManager.js Extracts entry management without memoization.
src/​schema/​entries/​schemaEntry.js Extracts the base entry and adds name comparison.
src/​schema/​entries/​schemaEntries.js Extracts the schema entry container.
src/​schema/​entries/​property.js Simplifies the property class.
src/​schema/​entries/​attribute.js Stores properties and recursion status.
src/​schema/​entries.js Removes the monolithic entry module.
src/​schema/​containers.js Renames schema containers and preserves aliases.
src/​parser/​tagConverter.js Updates placeholder and extension-letter validation.
src/​parser/​parsedHedTag.js Uses the extracted value-tag module.
src/​issues/​data.js Adds the invalid-schema issue.
package.json Removes the Set polyfill dependency.
package-lock.json Records the dependency removal.
CHANGELOG.md Documents validation and schema-layer changes.
.github/​copilot-instructions.md Updates the architecture documentation.

Review effort: Balanced

Comment thread src/parser/tagConverter.js
@VisLab
VisLab merged commit aa422ba into hed-standard:main Oct 23, 2026
13 checks passed
VisLab added a commit to VisLab/hed-javascript that referenced this pull request Oct 23, 2026
The letter test of specification 3.2.5 rule 6 keyed the Unicode form on
the literal character set name nonascii, so a schema whose nameClass
declaration allows non-ASCII through the composite set name or a literal
character (honored from HED 8.5.0) would reject an extension such as
Item/ete with accents. Test /\p{L}/u for every schema: a name class
without non-ASCII characters has already rejected them, so the result on
every shipped schema is unchanged (Copilot review of PR hed-standard#936).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants