(profile: ProviderSettings, allowList: OrganizationAllowList)
| 2 | |
| 3 | export class ProfileValidator { |
| 4 | public static isProfileAllowed(profile: ProviderSettings, allowList: OrganizationAllowList): boolean { |
| 5 | if (allowList.allowAll) { |
| 6 | return true |
| 7 | } |
| 8 | |
| 9 | if (!profile.apiProvider) { |
| 10 | return false |
| 11 | } |
| 12 | |
| 13 | if (!this.isProviderAllowed(profile.apiProvider, allowList)) { |
| 14 | return false |
| 15 | } |
| 16 | |
| 17 | const modelId = this.getModelIdFromProfile(profile) |
| 18 | |
| 19 | if (!modelId) { |
| 20 | return allowList.providers[profile.apiProvider]?.allowAll === true |
| 21 | } |
| 22 | |
| 23 | return this.isModelAllowed(profile.apiProvider, modelId, allowList) |
| 24 | } |
| 25 | |
| 26 | private static isProviderAllowed(providerName: string, allowList: OrganizationAllowList): boolean { |
| 27 | if (allowList.allowAll) { |
no test coverage detected