Split entry points, generate types from schema, humanize errors - #11
Merged
Conversation
The emitted ESM in 0.1.0-alpha.0 worked under bundler resolution but
broke under Node's native ESM resolver (used by vitest in consumer
repos). Three fixes:
- Append .js extensions to all relative imports in src/. tsc preserves
source paths verbatim, so the emitted .js needs the extensions to
match Node ESM's strict resolution rules.
- Add `with { type: "json" }` import attributes to the schema import
and re-export so Node accepts JSON modules under ESM.
- Add .js to the ajv subpath import (`ajv/dist/2020.js`).
- Bump tsconfig `module` from ES2022 to ESNext so TypeScript accepts
import attributes.
Adds five new entry points so consumers only pay for what they use: - `/helpers` and `/schema` import no Ajv at runtime - `/standalone` ships precompiled validators (Workers-friendly) - `/types` re-exports TypeScript types generated from the JSON schema Other changes: - AJV errors now use `blocks[N].field` paths and collapse the oneOf cascade by re-validating each block against its discriminator-matched branch (a malformed section block drops from ~80 errors to 2) - Property-based tests via fast-check caught a null-pointer crash in check-response-url-enabled-context.ts (fixed) - Benchmarks via tinybench in bench/ - CI matrix expanded: Node 20/22/24, Bun, Deno smoke, Cloudflare Workers build smoke, plus a check that the committed types stay in sync with the schema - tsconfig.test.json so tests/scripts/bench are type-checked too Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Resolved: - ci.yml: kept new Bun/Deno/Workers smoke jobs and the types-in-sync check alongside main's Codecov upload on the test job - package.json: took main's 0.1.1-alpha.1 release-please bump - src/index.ts: kept the new /helpers barrel (drops the now-redundant per-file re-exports main added) - src/validate-block-kit.ts: kept the FocusValidators wiring - pnpm-lock.yaml: regenerated against the merged package.json Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
scripts/smoke-deno.ts and scripts/smoke-worker.ts validate the *built* artifacts, so they import from ../dist/*.js. The Typecheck CI job runs without first building, which made tsc fail to resolve those imports. Their own CI jobs (Smoke Deno, Smoke Workers) run after a build, so the exclusion doesn't reduce coverage — it just stops Typecheck from needing a build step that's irrelevant to it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
zhawtof
added a commit
that referenced
this pull request
May 16, 2026
Resolve conflicts in package.json, src/index.ts, and src/validate-block-kit.ts by taking the main branch versions — this branch's only intended change is the new .github/pull_request_template.md, and the conflicts were purely from the branch being based on an older commit before #11 landed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
zhawtof
added a commit
that referenced
this pull request
May 16, 2026
Resolve conflicts by taking main's version of package.json, src/index.ts, and src/validate-block-kit.ts (all changed by PR #11's entry-point split and version bump; this branch only touches README + MAINTAINING.md). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds five new entry points so consumers only pay for what they use, generates TypeScript types directly from the JSON Schema, and collapses AJV's oneOf-branch cascade into focused per-block errors.
New entry points
@tightknitai/slack-block-kit-validator/helpers/schemaslackBlockKitSchemaas a JS module./schema.json/standalonevalidateBlocks/validateModal/validateHomefor Workers/Deno deploy. No runtime deps — Ajv usage is fully inlined at build time via esbuild./typesBlock,SectionBlock,ModalView, etc. generated from the schema.Error humanization
/0/textpaths now render asblocks[0].text, matching the helper-emitted format.expected "actions",expected "alert", … one per block kind) to 2 errors (missing required property 'text',missing required property 'fields').BLOCK_TYPE_TO_DEFand re-validating each offending block against just its discriminator-matched branch. UmbrellaoneOf/anyOf/notmessages are suppressed when underlying errors say the same thing.type.Tests
fast-checkfor the recursive walkers andstripUndefined. Caught a real bug:check-response-url-enabled-context.tscrashed onnullblock slots (which appear after normalization). Fixed.test/types.test-d.ts) exercises the most easily-broken generated shapes so the types can't silently regress.tsconfig.test.jsonsotsc --noEmitactually checks them (the original config excludedtest/).Benchmarks
bench/index.tsvia tinybench. Baseline numbers (M-class laptop, Node 22):CI
bun --bun.scripts/smoke-deno.ts) imports every entry point and runs basic round-trip checks.scripts/smoke-worker.tsvia esbuild in worker mode; any unbundledrequire()or Node-only API surfaces as a build failure.src/types.generated.tsdrifts from the schema.Notes for the reviewer
src/types.generated.tsis committed (so types are greppable on GitHub). The new CI job +pnpm run generate:typeschained intobuildkeeps it honest.pnpm dlx ajv compile ...snippet removed.Test plan
pnpm typecheck— src + test + bench + scripts all type-checkedpnpm lint— biome clean (42 files)pnpm test— 428 passingpnpm run build:clean— full pipeline (generate:types→tsc→compile:standalone) greennpm pack --dry-run— 66 files, 91.5 KB/,/helpers,/schema,/standalone) — all 11 assertions passdist/types.js— exports usable in strict TS🤖 Generated with Claude Code