-
Notifications
You must be signed in to change notification settings - Fork 11
feat: ai gateway disabled check #577
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
Conversation
packages/dev/src/main.ts
Outdated
| let aiGatewayDisabled = false | ||
| try { | ||
| const api = config.api as import('@netlify/api').NetlifyAPI | ||
| const accounts = await api.listAccountsForUser() | ||
| const account = accounts.find((acc) => acc.slug === config.siteInfo?.account_slug) | ||
| aiGatewayDisabled = | ||
| (account?.capabilities as { ai_gateway_disabled?: { included?: boolean } } | undefined)?.ai_gateway_disabled | ||
| ?.included ?? false | ||
| } catch { | ||
| // If we can't fetch accounts, proceed with AI Gateway enabled | ||
| } |
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.
🤔 This would be the first case of making API requests like this in the @netlify/dev package, which would change the current separation of responsibilities a bit. As is, @netlify/config is responsible for fetching all the account and site information needed and all the primitives packages receive what they need via @netlify/dev which is a sort of orchestrator.
tbh, I would wager that capabilities are already on the config object that's in scope here, but the types are just unfortunately incomplete.
maybe try adding a console.log of the full config and try against a real site?
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.
I logged it, but unfortunately the capabilities aren't there
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.
Added an option to include capabilities here netlify/build#6902
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.
Instead opted for passing field to site capabilities in bb API
d3db5ed to
7c5863a
Compare
serhalp
left a comment
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.
🥹 beautiful now!
Respects opt out flow for ai gateway in
@netlify/devpackage (which vite plugin depends on) by checking account capabilities.https://linear.app/netlify/issue/RUN-1883/build-an-opt-out-flow-for-account-and-sites
Tested locally with
npm linkand runningnpm run devRunning
npm run devWhen disabled, we log: