changed some paths and included src to improve types#10
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR transitions the package from publishing built declarations in ChangesSource-first publication strategy
🎯 2 (Simple) | ⏱️ ~12 minutes
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
vasta-docs | 5c4d08d | Commit Preview URL Branch Preview URL |
May 21 2026, 07:14 PM |
8db02b8 to
914cb5a
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@package.json`:
- Around line 28-36: Update the package export/type mapping so consumers use
emitted declaration files instead of TS sources: change the "exports" mapping
keys referenced in package.json (specifically the "import.types" and
"require.types" entries and the top-level "types" field) to point to the built
.d.ts files produced in your dist output (e.g., the ESM .d.ts under dist/esm and
the CJS .d.ts under dist/cjs) rather than ./src/index.ts, and only publish src/
if you intentionally want source included.
In `@src/index.ts`:
- Around line 1-3: Replace the blanket re-exports with an explicit public API:
stop using `export *` and instead re-export the specific symbols intended to be
public (e.g., Bivariant, ModelLike, AnyModelConstructor, SelectedModel,
ExtractDB, ExtractTB, ExtractSelection, PrimaryKeyValue, RelationKeys,
WithConstraints, Builder, RelationBuilder, lifecycle types, Model, defineModel,
RequireSelected, etc.) from the `Builder` and `Model` modules so accidental
internals don't leak; also explicitly re-export the default export from the
builder module as the package default (for example via a `export { default }
from "./model/Builder.js";`) and keep the existing `StaticForwarder` named
export as-is. Ensure all referenced symbols (Builder, Model, StaticForwarder and
the listed type names) are included in the explicit export lists.
In `@src/model/Model.ts`:
- Around line 585-587: The return-cast expression at the end of the Model.ts
signature keeps the trailing Omit<> on the same line; reflow the cast so the
Omit<typeof StaticForwarder, "prototype"> begins on a new line to match
surrounding formatting. Locate the return that casts BaseModel (the expression
containing ModelConstructorArgs<Insertable<DB[TB]>, DefaultedInsertable> and
Selectable<DB[TB]>) and break the line before the final ") & Omit<typeof
StaticForwarder, \"prototype\">", ensuring indentation aligns with the rest of
the signature and preserves the existing types (BaseModel, ModelConstructorArgs,
Insertable, DB, TB, DefaultedInsertable, Selectable).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 96be8a5d-cf07-4140-a48d-3218af19eb6f
📒 Files selected for processing (4)
package.jsonsrc/index.tssrc/model/Builder.tssrc/model/Model.ts
| "import": { | ||
| "types": "./src/index.ts", | ||
| "default": "./dist/esm/index.js" | ||
| }, | ||
| "require": { | ||
| "types": "./src/index.ts", | ||
| "default": "./dist/cjs/index.js" | ||
| } | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Inventory what will actually be published from src/ and check for non-public files.
fd . src -t f | head -200
fd -e ts -e tsx . src | xargs -I {} sh -c 'echo "--- {} ---"; head -1 "{}"' | head -100
# Check whether project relies on path aliases that won't resolve for consumers
rg -nP '"paths"\s*:' tsconfig.json tsconfig.cjs.json 2>/dev/null
rg -nP 'from\s+["'\'']@' srcRepository: Smef/vasta
Length of output: 601
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== package.json (exports + files/publishConfig) ==="
node -p "JSON.stringify(require('./package.json').exports, null, 2)" 2>/dev/null || true
node -p "JSON.stringify(require('./package.json').files ?? null, null, 2)" 2>/dev/null || true
node -p "JSON.stringify(require('./package.json').publishConfig ?? null, null, 2)" 2>/dev/null || true
echo
echo "=== package.json raw lines 20-60 ==="
nl -ba package.json | sed -n '20,70p'
echo
echo "=== tsconfig.json (compilerOptions relevant bits) ==="
nl -ba tsconfig.json | sed -n '1,120p'
echo
echo "=== tsconfig.cjs.json (if present) ==="
if [ -f tsconfig.cjs.json ]; then nl -ba tsconfig.cjs.json | sed -n '1,140p'; else echo "tsconfig.cjs.json not found"; fi
echo
echo "=== Does repo include generated declaration output? (dist) ==="
if [ -d dist ]; then
fd -e d.ts . dist | head -200
else
echo "dist/ not found"
fi
echo
echo "=== rg: sources referenced by exports types/default ==="
rg -n '"(types|default)"\s*:\s*"\./' package.jsonRepository: Smef/vasta
Length of output: 441
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== package.json (exports + files/publishConfig) ==="
node -p "JSON.stringify(require('./package.json').exports, null, 2)" 2>/dev/null || true
node -p "JSON.stringify(require('./package.json').files ?? null, null, 2)" 2>/dev/null || true
node -p "JSON.stringify(require('./package.json').publishConfig ?? null, null, 2)" 2>/dev/null || true
echo
echo "=== package.json raw lines 20-80 ==="
cat -n package.json | sed -n '20,80p'
echo
echo "=== tsconfig.json (compilerOptions relevant bits) ==="
cat -n tsconfig.json | sed -n '1,160p'
echo
echo "=== tsconfig.cjs.json (if present) ==="
if [ -f tsconfig.cjs.json ]; then cat -n tsconfig.cjs.json | sed -n '1,200p'; else echo "tsconfig.cjs.json not found"; fi
echo
echo "=== Does repo include generated declaration output? (dist) ==="
if [ -d dist ]; then
fd -e d.ts . dist | head -200
echo
echo "=== dist/esm and dist/cjs top-level files ==="
find dist -maxdepth 3 -type f \( -name "*.d.ts" -o -name "index.js" -o -name "index.mjs" -o -name "index.cjs" \) | head -200
else
echo "dist/ not found"
fi
echo
echo "=== package.json: is src/ included in publish? (files array) ==="
node -p "require('./package.json').files" 2>/dev/null || true
echo
echo
echo "=== rg: sources referenced by exports types/default ==="
rg -n '"(types|default)"\s*:\s*"\./' package.json || true
echo
echo "=== rg: declaration emit settings ==="
rg -n 'declaration|emitDeclarationOnly|outDir|declarationDir|rootDir|moduleResolution|baseUrl|paths' tsconfig*.json || true
echo
echo "=== dist: sample generated index declarations if present ==="
if [ -d dist ]; then
fd 'index.d.ts' dist -a | head -20
fd -e d.ts dist/esm dist/cjs 2>/dev/null | head -50
fiRepository: Smef/vasta
Length of output: 4171
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== Any test/fixture-like files under src/ that would get published? ==="
fd -t f . src \
| rg -i '(__tests__|test|spec|fixture|fixtures|mock)' || true
echo
echo "=== List declaration outputs if present (dist may not exist in repo snapshot) ==="
if [ -d dist ]; then
fd -e d.ts dist | head -200
else
echo "dist/ not present (but build script generates dist before publish)."
fi
echo
echo "=== tsconfig.esm.json (if present) ==="
if [ -f tsconfig.esm.json ]; then
cat -n tsconfig.esm.json | sed -n '1,200p'
else
echo "tsconfig.esm.json not found"
fiRepository: Smef/vasta
Length of output: 481
Point types to emitted .d.ts instead of src/index.ts
package.json sets exports["."].import.types, exports["."].require.types, and top-level types to ./src/index.ts, and it also publishes src/. With this setup, TS consumers type-check against your source under their own compiler options rather than consuming the generated declaration files from dist (your build config has declaration: true and outputs to dist/esm + dist/cjs). This can widen the effective public surface via deep imports and can lead to type/runtime interop mismatches for require since its types still come from the ESM source.
Consider pointing import.types to the emitted ESM .d.ts and require.types to the emitted CJS .d.ts, and only publish src/ if you explicitly want sources available.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@package.json` around lines 28 - 36, Update the package export/type mapping so
consumers use emitted declaration files instead of TS sources: change the
"exports" mapping keys referenced in package.json (specifically the
"import.types" and "require.types" entries and the top-level "types" field) to
point to the built .d.ts files produced in your dist output (e.g., the ESM .d.ts
under dist/esm and the CJS .d.ts under dist/cjs) rather than ./src/index.ts, and
only publish src/ if you intentionally want source included.
There was a problem hiding this comment.
Pull request overview
This PR adjusts module paths/exports and changes the package’s published type entrypoints to come from src (instead of generated .d.ts) with the stated goal of improving consumer type quality.
Changes:
- Switched internal imports from
@src/*aliases to relative.js-suffixed paths for ESM compatibility. - Updated the root
src/index.tsto re-export themodelmodules (andStaticForwarder) via wildcard exports. - Modified
package.jsonpublish/exports configuration to includesrcin the published files and pointtypes/exports.*.typesto./src/index.ts(and bumped version to0.0.14).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/model/Model.ts | Replaces @src import with relative import; refines defineModel return static typing. |
| src/model/Builder.ts | Replaces @src import with relative import. |
| src/index.ts | Changes package entry exports to wildcard re-exports of Builder/Model plus StaticForwarder. |
| package.json | Publishes src, updates exports to conditional types targets, and points types to src/index.ts. |
Comments suppressed due to low confidence (1)
package.json:61
- "types": "src/index.ts" makes the top-level typings entry depend on TS source in the published package. If the goal is better consumer typings, prefer "types" pointing at the emitted declaration file(s) in dist so consumers don’t need to resolve/parse TS implementation files from node_modules.
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"types": "src/index.ts",
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "exports": { | ||
| ".": { | ||
| "types": "./dist/esm/index.d.ts", | ||
| "import": "./dist/esm/index.js", | ||
| "require": "./dist/cjs/index.js", | ||
| "default": "./dist/cjs/index.js" | ||
| "import": { | ||
| "types": "./src/index.ts", | ||
| "default": "./dist/esm/index.js" | ||
| }, | ||
| "require": { | ||
| "types": "./src/index.ts", | ||
| "default": "./dist/cjs/index.js" | ||
| } |
914cb5a to
5c4d08d
Compare
changed some paths and included src to improve types
Summary by CodeRabbit
New Features
StaticForwarderto the public API exports.Chores