Skip to content

feat: add core types, defineConfig, and resolvePlan#2

Merged
Apetuezekiel merged 1 commit into
mainfrom
feat/config-schema
May 16, 2026
Merged

feat: add core types, defineConfig, and resolvePlan#2
Apetuezekiel merged 1 commit into
mainfrom
feat/config-schema

Conversation

@Apetuezekiel

Copy link
Copy Markdown
Owner

What

Implements the config schema layer: types, defineConfig, and resolvePlan.

New files:

  • src/types.tsPeriod, Limit, PlanInput, ConfigInput, ResolvedPlan, and the generic Config<TPlanName, TFeature, TLimitKey> type used by downstream PRs
  • src/config.tsdefineConfig<const T extends ConfigInput>(config: T): T identity function with const type parameter for full literal inference
  • src/resolve.tsresolvePlan(config, planName) that walks the extends chain, accumulates features (deduplicated), merges limits (descendant wins), and throws typed errors on circular or unknown extends

Updated:

  • src/index.ts — exports defineConfig and all public types
  • src/index.test.ts — updated from stub to verify public export surface
  • vitest.config.ts — adds typecheck.include for tests/**/*.test-d.ts

Tests:

  • src/config.test.ts — 4 tests covering identity return, limits, extends, null quota
  • src/resolve.test.ts — 17 tests: feature accumulation at depth 0/1/2/3, dedup, limit inheritance, limit override, deepest-wins, null quota round-trip, unknown root plan, unknown extends target, circular self-reference, indirect cycle, error messages
  • tests/types.test-d.ts — 3 type tests verifying literal plan name inference, extends field typing, quota number | null type

Why

Implements v1 scope items 1 and 5: the declarative plan/feature/limit schema with extends single-inheritance and full TypeScript literal-type inference from static config.

How to verify

npm run lint       # clean
npm run typecheck  # clean
npm run test       # 25 tests pass, 100% coverage on config.ts, index.ts, resolve.ts
npm run build      # dist/ emitted with ESM + CJS + types

Out of scope

  • createAccess, error classes, override logic — those are PR 3
  • JSON Schema generation — PR 4
  • overrides.limits runtime API — deferred to v1.1

@Apetuezekiel Apetuezekiel merged commit 2a53d2f into main May 16, 2026
5 checks passed
@Apetuezekiel Apetuezekiel deleted the feat/config-schema branch May 16, 2026 17:41
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.

1 participant