Skip to content

Commit 660100b

Browse files
moving prop defs so defaults get set as part of userpreferences
1 parent 1182707 commit 660100b

File tree

1 file changed

+38
-50
lines changed

1 file changed

+38
-50
lines changed

packages/compass-preferences-model/src/preferences-schema.ts

Lines changed: 38 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ export type InternalUserPreferences = {
9393

9494
// UserPreferences contains all preferences stored to disk.
9595
export type UserPreferences = UserConfigurablePreferences &
96-
InternalUserPreferences;
96+
InternalUserPreferences &
97+
AtlasOrgPreferences &
98+
AtlasProjectPreferences;
9799

98100
export type CliOnlyPreferences = {
99101
exportConnections?: string;
@@ -116,9 +118,7 @@ export type NonUserPreferences = {
116118
export type AllPreferences = UserPreferences &
117119
CliOnlyPreferences &
118120
NonUserPreferences &
119-
PermanentFeatureFlags &
120-
AtlasProjectPreferences &
121-
AtlasOrgPreferences;
121+
PermanentFeatureFlags;
122122

123123
// Types related to PreferenceDefinition
124124
type PostProcessFunction<T> = (
@@ -214,12 +214,12 @@ export type StoredPreferencesValidator = ReturnType<
214214
export type StoredPreferences = z.output<StoredPreferencesValidator>;
215215

216216
export type AtlasProjectPreferences = {
217-
enableGenAIFeaturesAtlasProject?: boolean;
218-
enableGenAISampleDocumentPassingOnAtlasProject?: boolean;
217+
enableGenAIFeaturesAtlasProject: boolean;
218+
enableGenAISampleDocumentPassingOnAtlasProject: boolean;
219219
};
220220

221221
export type AtlasOrgPreferences = {
222-
enableGenAIFeaturesAtlasOrg?: boolean;
222+
enableGenAIFeaturesAtlasOrg: boolean;
223223
};
224224

225225
// Preference definitions
@@ -886,6 +886,36 @@ export const storedUserPreferencesProps: Required<{
886886
validator: z.boolean().default(false),
887887
type: 'boolean',
888888
},
889+
enableGenAIFeaturesAtlasProject: {
890+
ui: false,
891+
cli: true,
892+
global: true,
893+
description: {
894+
short: 'Enable Gen AI Features on Atlas Project Level',
895+
},
896+
validator: z.boolean().default(true),
897+
type: 'boolean',
898+
},
899+
enableGenAISampleDocumentPassingOnAtlasProject: {
900+
ui: false,
901+
cli: true,
902+
global: true,
903+
description: {
904+
short: 'Enable Gen AI Sample Document Passing on Atlas Project Level',
905+
},
906+
validator: z.boolean().default(true),
907+
type: 'boolean',
908+
},
909+
enableGenAIFeaturesAtlasOrg: {
910+
ui: false,
911+
cli: true,
912+
global: true,
913+
description: {
914+
short: 'Enable Gen AI Features on Atlas Org Level',
915+
},
916+
validator: z.boolean().default(true),
917+
type: 'boolean',
918+
},
889919

890920
...allFeatureFlagsProps,
891921
};
@@ -1032,54 +1062,12 @@ const nonUserPreferences: Required<{
10321062
},
10331063
};
10341064

1035-
const atlasProjectPreferencesProps: Required<{
1036-
[K in keyof AtlasProjectPreferences]: PreferenceDefinition<K>;
1037-
}> = {
1038-
enableGenAIFeaturesAtlasProject: {
1039-
ui: false,
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: false,
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 AtlasOrgPreferences]: PreferenceDefinition<K>;
1062-
}> = {
1063-
enableGenAIFeaturesAtlasOrg: {
1064-
ui: false,
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-
10751065
export const allPreferencesProps: Required<{
10761066
[K in keyof AllPreferences]: PreferenceDefinition<K>;
10771067
}> = {
10781068
...storedUserPreferencesProps,
10791069
...cliOnlyPreferencesProps,
10801070
...nonUserPreferences,
1081-
...atlasProjectPreferencesProps,
1082-
...atlasOrgPreferencesProps,
10831071
};
10841072

10851073
/** Helper for defining how to derive value/state for networkTraffic-affected preferences */
@@ -1099,7 +1087,7 @@ function deriveValueFromOtherPreferencesAsLogicalAnd<
10991087
K extends keyof AllPreferences
11001088
>(property: K, preferencesToDeriveFrom: K[]): DeriveValueFunction<boolean> {
11011089
return (v, s) => ({
1102-
value: preferencesToDeriveFrom.every((p) => v(p)),
1090+
value: v(property) && preferencesToDeriveFrom.every((p) => v(p)),
11031091
state:
11041092
s(property) ??
11051093
(preferencesToDeriveFrom.every((p) => v(p))

0 commit comments

Comments
 (0)