feat: add core types, defineConfig, and resolvePlan#2
Merged
Conversation
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.
What
Implements the config schema layer: types,
defineConfig, andresolvePlan.New files:
src/types.ts—Period,Limit,PlanInput,ConfigInput,ResolvedPlan, and the genericConfig<TPlanName, TFeature, TLimitKey>type used by downstream PRssrc/config.ts—defineConfig<const T extends ConfigInput>(config: T): Tidentity function withconsttype parameter for full literal inferencesrc/resolve.ts—resolvePlan(config, planName)that walks theextendschain, accumulates features (deduplicated), merges limits (descendant wins), and throws typed errors on circular or unknownextendsUpdated:
src/index.ts— exportsdefineConfigand all public typessrc/index.test.ts— updated from stub to verify public export surfacevitest.config.ts— addstypecheck.includefortests/**/*.test-d.tsTests:
src/config.test.ts— 4 tests covering identity return, limits, extends, null quotasrc/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 messagestests/types.test-d.ts— 3 type tests verifying literal plan name inference, extends field typing, quotanumber | nulltypeWhy
Implements v1 scope items 1 and 5: the declarative plan/feature/limit schema with
extendssingle-inheritance and full TypeScript literal-type inference from static config.How to verify
Out of scope
createAccess, error classes, override logic — those are PR 3overrides.limitsruntime API — deferred to v1.1