-
Notifications
You must be signed in to change notification settings - Fork 5
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
feat: add version to apiUrl #45
Conversation
WalkthroughThe recent changes to the Changes
Sequence Diagram(s) (Beta)sequenceDiagram
participant User
participant FlatfileClient
participant API
User->>FlatfileClient: Initialize with environment URL
FlatfileClient->>FlatfileClient: resolveEnvironment(options)
FlatfileClient->>API: Append /v1 to URL and make request
API-->>FlatfileClient: Respond to request
FlatfileClient-->>User: Return response
Assessment against linked issues
Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (1)
Additional context usedBiome
Additional comments not posted (1)
TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 2
Outside diff range and nitpick comments (1)
src/wrapper/FlatfileClient.ts (1)
Line range hint
56-56
: Use strict equality for undefined checks.- if (token == undefined) { + if (token === undefined) { throw new Error("FLATFILE_BEARER_TOKEN is not undefined"); }
@@ -24,7 +24,7 @@ export class FlatfileClient extends FernClient { | |||
|
|||
constructor(options: FlatfileClient.Options = {}) { | |||
super({ | |||
environment: (options.environment || options.apiUrl) ?? environmentSupplier, | |||
environment: resolveEnvironment(options), |
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.
Resolve the static analysis error regarding assignment in an expression.
- return (this._records ??= new Records(this._options));
+ if (!this._records) {
+ this._records = new Records(this._options);
+ }
+ return this._records;
Committable suggestion was skipped due low confidence.
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.
Actionable comments posted: 2
Outside diff range and nitpick comments (1)
src/wrapper/FlatfileClient.ts (1)
Line range hint
35-35
: Resolve the static analysis error regarding assignment in an expression.- return (this._records ??= new Records(this._options)); + if (!this._records) { + this._records = new Records(this._options); + } + return this._records;
@@ -47,7 +54,7 @@ const environmentSupplier = () => { | |||
const tokenSupplier = () => { | |||
const token = CrossEnvConfig.get("FLATFILE_BEARER_TOKEN"); | |||
if (token == undefined) { |
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.
Use strict equality for checking undefined.
- if (token == undefined) {
+ if (token === undefined) {
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
if (token == undefined) { | |
if (token === undefined) { |
Tools
Biome
[error] 56-56: Use === instead of ==.
== is only allowed when comparing againstnull
const resolveEnvironment = (options: FlatfileClient.Options) => { | ||
if (options.apiUrl && !options.apiUrl.endsWith("/v1")) { | ||
return urlJoin(options.apiUrl, "v1"); | ||
} | ||
return options.environment || options.apiUrl || environmentSupplier(); | ||
}; |
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.
Ensure apiUrl
is not undefined before manipulating it.
- if (options.apiUrl && !options.apiUrl.endsWith("/v1")) {
+ if (options.apiUrl !== undefined && !options.apiUrl.endsWith("/v1")) {
return urlJoin(options.apiUrl, "v1");
}
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
const resolveEnvironment = (options: FlatfileClient.Options) => { | |
if (options.apiUrl && !options.apiUrl.endsWith("/v1")) { | |
return urlJoin(options.apiUrl, "v1"); | |
} | |
return options.environment || options.apiUrl || environmentSupplier(); | |
}; | |
const resolveEnvironment = (options: FlatfileClient.Options) => { | |
if (options.apiUrl !== undefined && !options.apiUrl.endsWith("/v1")) { | |
return urlJoin(options.apiUrl, "v1"); | |
} | |
return options.environment || options.apiUrl || environmentSupplier(); | |
}; |
Closes https://github.com/FlatFilers/support-triage/issues/1339