Skip to content

feat(core): data model + trace parser + event normalizer - #33

Merged
sepehr-safari merged 1 commit into
mainfrom
feat/core-parser-normalizer
Jul 7, 2026
Merged

feat(core): data model + trace parser + event normalizer#33
sepehr-safari merged 1 commit into
mainfrom
feat/core-parser-normalizer

Conversation

@sepehr-safari

Copy link
Copy Markdown
Member

Summary

Implements the core data model with Zod schemas, the parseTrace() function accepting JSON Object / JSONL / bare array formats, and normalizeEvents() that classifies message types, directions, and timestamps.

Closes #20

Changes

New files

  • packages/core/src/schemas.ts — Zod schemas for Trace, TraceEventInput, TraceMetadata, RawOcppMessage (prototype pollution protection)
  • packages/core/src/normalizer.tsnormalizeEvents(), direction inference (ADR-0004), timestamp normalization (ADR-0005)
  • packages/core/src/parser.tsparseTrace() accepting JSON Object, JSONL, and bare array
  • packages/core/src/normalizer.test.ts — 46 tests
  • packages/core/src/parser.test.ts — 32 tests

Updated files

  • packages/core/src/types.ts — added Failure, FailureCode, FailureSeverity, Scenario, SessionSummary, ValidationResult types
  • packages/core/src/index.ts — updated barrel exports
  • packages/core/package.json — added zod dependency
  • CURRENT_STATE.md — updated to reflect v0.1.0 milestone progress

Security Checklist

  • No hardcoded secrets, tokens, API keys, or credentials
  • No personal or sensitive information in committed artifacts
  • No eval(), Function(), or dynamic code execution on untrusted input
  • Safe JSON parsing — try/catch + size guard (10 MB)
  • No prototype pollution — Zod validation on all input
  • Path safety in CLI — N/A (no CLI in this PR)
  • No ReDoS-vulnerable regex patterns
  • File-size and event-count limits enforced (10 MB, 10,000 events)
  • Safe rendering — N/A (no UI in this PR)
  • No console.log of sensitive data in production paths
  • Input validation on all external entry points
  • Non-sensitive error messages
  • .env files gitignored

Verification

  • pnpm lint — ✅
  • pnpm typecheck — ✅
  • pnpm test — ✅ (107 tests, all passing)
  • pnpm build — ✅
  • pnpm format:check — ✅

- parseTrace() accepts JSON Object, JSONL, and bare array trace formats
- normalizeEvents() classifies message types, infers directions (ADR-0004),
  and normalizes timestamps to epoch milliseconds (ADR-0005)
- Zod schemas validate all untrusted input, preventing prototype pollution
- Input size limit (10 MB) and event count limit (10,000) enforced
- Malformed individual events are skipped with ParseWarning (ADR-0007)
- Added Failure, Scenario, SessionSummary, ValidationResult types
- 78 new unit tests (46 normalizer + 32 parser)

Closes #20
@sepehr-safari sepehr-safari added this to the v0.1.0 — Inspector MVP milestone Jul 7, 2026
@sepehr-safari sepehr-safari added type:feature New feature or enhancement package:core @ocpp-debugkit/core labels Jul 7, 2026
@sepehr-safari
sepehr-safari merged commit 9543d50 into main Jul 7, 2026
1 check passed
@sepehr-safari
sepehr-safari deleted the feat/core-parser-normalizer branch July 7, 2026 22:08
sepehr-safari added a commit that referenced this pull request Jul 8, 2026
The changeset with a minor bump would trigger auto-publish of
@ocpp-debugkit/toolkit when PR #55 merges via the release workflow.
We don't want to publish until all v0.2.0 work is complete.
The changeset will be added as part of the release issue (#33).
sepehr-safari added a commit that referenced this pull request Jul 8, 2026
…subpath exports (#55)

* feat(toolkit): consolidate packages into @ocpp-debugkit/toolkit with subpath exports

- Create packages/toolkit/ with single @ocpp-debugkit/toolkit package
- Move core, scenarios, reporter, CLI code into src/ internal modules
- Add src/replay/ and src/react/ stub modules
- Configure subpath exports: /core, /scenarios, /reporter, /replay, /react, /cli, /fixtures
- Configure ESM build with TypeScript declarations, tree-shaking (sideEffects: false)
- CLI binary ocpp-debugkit via package.json#bin
- Update web app to consume @ocpp-debugkit/toolkit
- Delete old package directories (core, scenarios, reporter, cli)
- All 196 existing tests pass from new locations
- Update AGENTS.md and CURRENT_STATE.md
- Add changeset (minor bump)

Closes #54

* chore: remove changeset from consolidation PR - will add at release time

The changeset with a minor bump would trigger auto-publish of
@ocpp-debugkit/toolkit when PR #55 merges via the release workflow.
We don't want to publish until all v0.2.0 work is complete.
The changeset will be added as part of the release issue (#33).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package:core @ocpp-debugkit/core type:feature New feature or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(core): data model + trace parser + event normalizer

1 participant