@@ -23,12 +23,12 @@ type ConfigDefinitionExtensionParams<T extends Z.ZodRawShape, P extends Z.ZodRaw
2323 createUpgrader : (
2424 config : Z . infer < Z . ZodObject < P > > ,
2525 schema : Z . ZodObject < T > ,
26- defaultValue : Z . infer < Z . ZodObject < T > >
26+ defaultValue : Z . infer < Z . ZodObject < T > > ,
2727 ) => Z . infer < Z . ZodObject < T > > ;
2828} ;
2929const extendConfigDefinition = < T extends Z . ZodRawShape , P extends Z . ZodRawShape > (
3030 definition : ConfigDefinition < P , any > ,
31- params : ConfigDefinitionExtensionParams < T , P >
31+ params : ConfigDefinitionExtensionParams < T , P > ,
3232) => {
3333 const schema = params . createSchema ( definition . schema ) ;
3434 const defaultValue = params . createDefaultValue ( definition . defaultValue ) ;
@@ -120,7 +120,7 @@ export const configV1_1Definition = extendConfigDefinition(configV1Definition, {
120120 Z . object ( {
121121 include : Z . array ( Z . string ( ) ) . default ( [ ] ) ,
122122 exclude : Z . array ( Z . string ( ) ) . default ( [ ] ) . optional ( ) ,
123- } )
123+ } ) ,
124124 ) . default ( { } ) ,
125125 } ) ,
126126 createDefaultValue : ( baseDefaultValue ) => ( {
@@ -188,7 +188,7 @@ export const configV1_3Definition = extendConfigDefinition(configV1_2Definition,
188188 . default ( [ ] )
189189 . optional ( ) ,
190190 injectLocale : Z . array ( Z . string ( ) ) . optional ( ) ,
191- } )
191+ } ) ,
192192 ) . default ( { } ) ,
193193 } ) ,
194194 createDefaultValue : ( baseDefaultValue ) => ( {
@@ -222,8 +222,47 @@ export const configV1_4Definition = extendConfigDefinition(configV1_3Definition,
222222 } ) ,
223223} ) ;
224224
225+ // v1.4 -> v1.5
226+ // Changes: add "provider" field to the config
227+ const commonProviderSchema = Z . object ( {
228+ id : Z . string ( ) ,
229+ model : Z . string ( ) ,
230+ prompt : Z . string ( ) ,
231+ baseUrl : Z . string ( ) . optional ( ) ,
232+ } ) ;
233+ const providerSchema = Z . union ( [
234+ commonProviderSchema . extend ( {
235+ id : Z . literal ( "lingo" ) ,
236+ model : Z . literal ( "best" ) ,
237+ } ) ,
238+ commonProviderSchema . extend ( {
239+ id : Z . enum ( [ "openai" , "anthropic" ] ) ,
240+ } ) ,
241+ ] ) ;
242+ export const configV1_5Definition = extendConfigDefinition ( configV1_4Definition , {
243+ createSchema : ( baseSchema ) =>
244+ baseSchema . extend ( {
245+ provider : providerSchema
246+ . default ( {
247+ id : "lingo" ,
248+ model : "best" ,
249+ baseUrl : "https://engine.lingo.dev" ,
250+ prompt : "" ,
251+ } )
252+ . optional ( ) ,
253+ } ) ,
254+ createDefaultValue : ( baseDefaultValue ) => ( {
255+ ...baseDefaultValue ,
256+ version : 1.5 ,
257+ } ) ,
258+ createUpgrader : ( oldConfig ) => ( {
259+ ...oldConfig ,
260+ version : 1.5 ,
261+ } ) ,
262+ } ) ;
263+
225264// exports
226- export const LATEST_CONFIG_DEFINITION = configV1_4Definition ;
265+ export const LATEST_CONFIG_DEFINITION = configV1_5Definition ;
227266
228267export type I18nConfig = Z . infer < ( typeof LATEST_CONFIG_DEFINITION ) [ "schema" ] > ;
229268
0 commit comments