@@ -56,6 +56,7 @@ export type UserConfigurablePreferences = PermanentFeatureFlags &
5656 | 'web-sandbox-atlas-local'
5757 | 'web-sandbox-atlas-dev'
5858 | 'web-sandbox-atlas' ;
59+ optInDataExplorerGenAIFeatures : boolean ;
5960 // Features that are enabled by default in Compass, but are disabled in Data
6061 // Explorer
6162 enableExplainPlan : boolean ;
@@ -115,7 +116,9 @@ export type NonUserPreferences = {
115116export type AllPreferences = UserPreferences &
116117 CliOnlyPreferences &
117118 NonUserPreferences &
118- PermanentFeatureFlags ;
119+ PermanentFeatureFlags &
120+ AtlasProjectPreferences &
121+ AtlasOrgPreferences ;
119122
120123// Types related to PreferenceDefinition
121124type PostProcessFunction < T > = (
@@ -210,6 +213,15 @@ export type StoredPreferencesValidator = ReturnType<
210213
211214export type StoredPreferences = z . output < StoredPreferencesValidator > ;
212215
216+ export type AtlasProjectPreferences = {
217+ enableGenAIFeaturesAtlasProject ?: boolean ;
218+ enableGenAISampleDocumentPassingOnAtlasProject ?: boolean ;
219+ } ;
220+
221+ export type AtlasOrgPreferences = {
222+ enableGenAIFeaturesAtlasOrg ?: boolean ;
223+ } ;
224+
213225// Preference definitions
214226const featureFlagsProps : Required < {
215227 [ K in keyof FeatureFlags ] : PreferenceDefinition < K > ;
@@ -461,7 +473,10 @@ export const storedUserPreferencesProps: Required<{
461473 short : 'Enable AI Features' ,
462474 long : 'Allow the use of AI features in Compass which make requests to 3rd party services.' ,
463475 } ,
464- deriveValue : deriveNetworkTrafficOptionState ( 'enableGenAIFeatures' ) ,
476+ deriveValue : deriveValueFromOtherPreferences ( 'enableGenAIFeatures' , [
477+ 'enableGenAIFeaturesAtlasOrg' ,
478+ 'networkTraffic' ,
479+ ] ) ,
465480 validator : z . boolean ( ) . default ( true ) ,
466481 type : 'boolean' ,
467482 } ,
@@ -679,6 +694,16 @@ export const storedUserPreferencesProps: Required<{
679694 . default ( 'atlas' ) ,
680695 type : 'string' ,
681696 } ,
697+ optInDataExplorerGenAIFeatures : {
698+ ui : true ,
699+ cli : false ,
700+ global : false ,
701+ description : {
702+ short : 'User Opt-in for Data Explorer Gen AI Features' ,
703+ } ,
704+ validator : z . boolean ( ) . default ( true ) ,
705+ type : 'boolean' ,
706+ } ,
682707
683708 enableAtlasSearchIndexes : {
684709 ui : true ,
@@ -1007,12 +1032,54 @@ const nonUserPreferences: Required<{
10071032 } ,
10081033} ;
10091034
1035+ const atlasProjectPreferencesProps : Required < {
1036+ [ K in keyof NonUserPreferences ] : PreferenceDefinition < K > ;
1037+ } > = {
1038+ enableGenAIFeaturesAtlasProject : {
1039+ ui : true ,
1040+ cli : true ,
1041+ global : true ,
1042+ description : {
1043+ short : 'Enable Gen AI Features on Atlas Project Level' ,
1044+ } ,
1045+ validator : z . boolean ( ) . default ( true ) ,
1046+ type : 'boolean' ,
1047+ } ,
1048+ enableGenAISampleDocumentPassingOnAtlasProject : {
1049+ ui : true ,
1050+ cli : true ,
1051+ global : true ,
1052+ description : {
1053+ short : 'Enable Gen AI Sample Document Passing on Atlas Project Level' ,
1054+ } ,
1055+ validator : z . boolean ( ) . default ( true ) ,
1056+ type : 'boolean' ,
1057+ } ,
1058+ } ;
1059+
1060+ const atlasOrgPreferencesProps : Required < {
1061+ [ K in keyof NonUserPreferences ] : PreferenceDefinition < K > ;
1062+ } > = {
1063+ enableGenAIFeaturesAtlasOrg : {
1064+ ui : true ,
1065+ cli : true ,
1066+ global : true ,
1067+ description : {
1068+ short : 'Enable Gen AI Features on Atlas Org Level' ,
1069+ } ,
1070+ validator : z . boolean ( ) . default ( true ) ,
1071+ type : 'boolean' ,
1072+ } ,
1073+ } ;
1074+
10101075export const allPreferencesProps : Required < {
10111076 [ K in keyof AllPreferences ] : PreferenceDefinition < K > ;
10121077} > = {
10131078 ...storedUserPreferencesProps ,
10141079 ...cliOnlyPreferencesProps ,
10151080 ...nonUserPreferences ,
1081+ ...atlasProjectPreferencesProps ,
1082+ ...atlasOrgPreferencesProps ,
10161083} ;
10171084
10181085/** Helper for defining how to derive value/state for networkTraffic-affected preferences */
@@ -1027,6 +1094,22 @@ function deriveNetworkTrafficOptionState<K extends keyof AllPreferences>(
10271094 } ) ;
10281095}
10291096
1097+ /** Helper for deriving value/state for preferences from other preferences */
1098+ function deriveValueFromOtherPreferences < K extends keyof AllPreferences > (
1099+ property : K ,
1100+ preferencesToDeriveFrom : K [ ]
1101+ ) : DeriveValueFunction < boolean > {
1102+ return ( v , s ) => ( {
1103+ value : v ( property ) && preferencesToDeriveFrom . every ( ( p ) => v ( p ) ) ,
1104+ state :
1105+ s ( property ) ??
1106+ ( preferencesToDeriveFrom . every ( ( p ) => v ( p ) )
1107+ ? preferencesToDeriveFrom . map ( ( p ) => s ( p ) ) . filter ( Boolean ) ?. [ 0 ] ??
1108+ 'derived'
1109+ : undefined ) ,
1110+ } ) ;
1111+ }
1112+
10301113/** Helper for defining how to derive value/state for feature-restricting preferences */
10311114function deriveFeatureRestrictingOptionsState < K extends keyof AllPreferences > (
10321115 property : K
0 commit comments