-
Notifications
You must be signed in to change notification settings - Fork 5
feat(bundler-plugins): Add braintrust{Bundler}Plugin aliases for bundler plugins and deprecate rest
#2032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat(bundler-plugins): Add braintrust{Bundler}Plugin aliases for bundler plugins and deprecate rest
#2032
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
91bb347
feat(bundler-plugins): Add `braintrust{Bundler}Plugin` aliases for bu…
lforst 89bb543
cs
lforst 3b7fbe0
clean
lforst 5968690
fix
lforst cad5d4a
cassette version rm
lforst 203906c
update cl message
lforst 6a5d12c
rm unnecessary note
lforst c88abdf
fix build
lforst d48f096
Merge remote-tracking branch 'origin/main' into lforst/bundler-plugin…
lforst File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "braintrust": minor | ||
| --- | ||
|
|
||
| feat(bundler-plugins): Add `braintrustVitePlugin`, `braintrustWebpackPlugin`, `braintrustEsbuildPlugin`, `braintrustRollupPlugin` aliases for bundler plugins and deprecate old ones |
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,72 +1,21 @@ | ||
| /** | ||
| * Versioned cassette format dispatcher. | ||
| * | ||
| * `parseCassette` reads the `version` field and routes to the appropriate | ||
| * schema. Unknown fields at entry level are preserved via `.passthrough()` in | ||
| * each version schema so minor additions within a major version survive | ||
| * round-trips. | ||
| * | ||
| * Rule for bumping versions: | ||
| * - New optional fields in an existing version: add to the schema with | ||
| * `.optional()`; no version bump needed (passthrough preserves them for | ||
| * older readers too). | ||
| * - Breaking / required changes: add a `v2.ts` schema, add a migration in | ||
| * `migrateV1ToV2`, and bump `CURRENT_FORMAT_VERSION` there. | ||
| */ | ||
|
|
||
| import type { CassetteFile } from "../cassette"; | ||
| import { CassetteFormatError, CassetteVersionError } from "../errors"; | ||
| import { CURRENT_FORMAT_VERSION, cassetteSchema } from "./v1"; | ||
|
|
||
| export { CURRENT_FORMAT_VERSION } from "./v1"; | ||
| import { CassetteFormatError } from "../errors"; | ||
| import { cassetteSchema } from "./v1"; | ||
|
|
||
| /** | ||
| * Parse a raw (JSON-deserialized) cassette object, dispatching to the correct | ||
| * version schema. Throws `CassetteVersionError` for unsupported versions and | ||
| * `CassetteFormatError` for schema mismatches. | ||
| * version schema. Throws `CassetteFormatError` for schema mismatches. | ||
| */ | ||
| export function parseCassette( | ||
| raw: unknown, | ||
| cassetteName: string, | ||
| ): CassetteFile { | ||
| if ( | ||
| typeof raw !== "object" || | ||
| raw === null || | ||
| !("version" in raw) || | ||
| typeof raw.version !== "number" | ||
| ) { | ||
| const result = cassetteSchema.safeParse(raw); | ||
| if (!result.success) { | ||
| throw new CassetteFormatError({ | ||
| cassetteName, | ||
| message: 'Missing or invalid "version" field', | ||
| }); | ||
| } | ||
|
|
||
| const version = (raw as { version: number }).version; | ||
|
|
||
| if (version > CURRENT_FORMAT_VERSION) { | ||
| throw new CassetteVersionError({ | ||
| cassetteName, | ||
| foundVersion: version, | ||
| supportedVersion: CURRENT_FORMAT_VERSION, | ||
| message: result.error.message, | ||
| }); | ||
| } | ||
|
|
||
| // Route to version-specific schema. When v2 is added, add another branch. | ||
| if (version === 1) { | ||
| const result = cassetteSchema.safeParse(raw); | ||
| if (!result.success) { | ||
| throw new CassetteFormatError({ | ||
| cassetteName, | ||
| message: result.error.message, | ||
| }); | ||
| } | ||
| return result.data; | ||
| } | ||
|
|
||
| // version < 1 — too old, no migration available | ||
| throw new CassetteVersionError({ | ||
| cassetteName, | ||
| foundVersion: version, | ||
| supportedVersion: CURRENT_FORMAT_VERSION, | ||
| }); | ||
| return result.data; | ||
| } |
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,5 @@ | ||
| { | ||
| "name": "@braintrust/js-e2e-tests", | ||
| "version": "0.0.0", | ||
| "private": true, | ||
| "type": "module", | ||
| "scripts": { | ||
|
|
||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we also gotta update
dev-packages/seinfeld/src/format/v1.tsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, the rabbit hole went even deeper cad5d4a