@@ -161,6 +161,20 @@ pub enum SchemaLocation {
161
161
Directory ( PathBuf ) ,
162
162
}
163
163
164
+ pub struct ExtraArtifactsConfig {
165
+ pub filename_for_artifact : Box < dyn ( Fn ( SourceLocationKey , StringKey ) -> String ) + Send + Sync > ,
166
+ pub skip_types_for_artifact : Box < dyn ( Fn ( SourceLocationKey ) -> bool ) + Send + Sync > ,
167
+ }
168
+
169
+ impl Debug for ExtraArtifactsConfig {
170
+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
171
+ f. debug_struct ( "ExtraArtifactsConfig" )
172
+ . field ( "filename_for_artifact" , & "Fn" )
173
+ . field ( "skip_types_for_artifact" , & "Fn" )
174
+ . finish ( )
175
+ }
176
+ }
177
+
164
178
#[ derive( Debug , Serialize , Deserialize ) ]
165
179
#[ serde( rename_all = "camelCase" ) ]
166
180
pub struct SchemaConfig {
@@ -214,8 +228,9 @@ impl Default for SchemaConfig {
214
228
pub struct ProjectConfig {
215
229
pub name : ProjectName ,
216
230
pub base : Option < ProjectName > ,
217
- pub output : Option < PathBuf > ,
218
231
pub extra_artifacts_output : Option < PathBuf > ,
232
+ pub extra_artifacts_config : Option < ExtraArtifactsConfig > ,
233
+ pub output : Option < PathBuf > ,
219
234
pub shard_output : bool ,
220
235
pub shard_strip_regex : Option < Regex > ,
221
236
pub schema_extensions : Vec < PathBuf > ,
@@ -228,9 +243,6 @@ pub struct ProjectConfig {
228
243
pub extra : serde_json:: Value ,
229
244
pub feature_flags : Arc < FeatureFlags > ,
230
245
pub test_path_regex : Option < Regex > ,
231
- pub filename_for_artifact :
232
- Option < Box < dyn ( Fn ( SourceLocationKey , StringKey ) -> String ) + Send + Sync > > ,
233
- pub skip_types_for_artifact : Option < Box < dyn ( Fn ( SourceLocationKey ) -> bool ) + Send + Sync > > ,
234
246
pub rollout : Rollout ,
235
247
pub js_module_format : JsModuleFormat ,
236
248
pub module_import_config : ModuleImportConfig ,
@@ -244,8 +256,9 @@ impl Default for ProjectConfig {
244
256
name : ProjectName :: default ( ) ,
245
257
feature_flags : Default :: default ( ) ,
246
258
base : None ,
247
- output : None ,
248
259
extra_artifacts_output : None ,
260
+ extra_artifacts_config : None ,
261
+ output : None ,
249
262
shard_output : false ,
250
263
shard_strip_regex : None ,
251
264
schema_extensions : vec ! [ ] ,
@@ -257,8 +270,6 @@ impl Default for ProjectConfig {
257
270
variable_names_comment : false ,
258
271
extra : Default :: default ( ) ,
259
272
test_path_regex : None ,
260
- filename_for_artifact : None ,
261
- skip_types_for_artifact : None ,
262
273
rollout : Default :: default ( ) ,
263
274
js_module_format : Default :: default ( ) ,
264
275
module_import_config : Default :: default ( ) ,
@@ -273,8 +284,9 @@ impl Debug for ProjectConfig {
273
284
let ProjectConfig {
274
285
name,
275
286
base,
276
- output,
277
287
extra_artifacts_output,
288
+ extra_artifacts_config,
289
+ output,
278
290
shard_output,
279
291
shard_strip_regex,
280
292
schema_extensions,
@@ -287,8 +299,6 @@ impl Debug for ProjectConfig {
287
299
extra,
288
300
feature_flags,
289
301
test_path_regex,
290
- filename_for_artifact,
291
- skip_types_for_artifact,
292
302
rollout,
293
303
js_module_format,
294
304
module_import_config,
@@ -299,6 +309,7 @@ impl Debug for ProjectConfig {
299
309
. field ( "name" , name)
300
310
. field ( "base" , base)
301
311
. field ( "output" , output)
312
+ . field ( "extra_artifacts_config" , extra_artifacts_config)
302
313
. field ( "extra_artifacts_output" , extra_artifacts_output)
303
314
. field ( "shard_output" , shard_output)
304
315
. field ( "shard_strip_regex" , shard_strip_regex)
@@ -312,22 +323,6 @@ impl Debug for ProjectConfig {
312
323
. field ( "extra" , extra)
313
324
. field ( "feature_flags" , feature_flags)
314
325
. field ( "test_path_regex" , test_path_regex)
315
- . field (
316
- "filename_for_artifact" ,
317
- & if filename_for_artifact. is_some ( ) {
318
- "Some<Fn>"
319
- } else {
320
- "None"
321
- } ,
322
- )
323
- . field (
324
- "skip_types_for_artifact" ,
325
- & if skip_types_for_artifact. is_some ( ) {
326
- "Some<Fn>"
327
- } else {
328
- "None"
329
- } ,
330
- )
331
326
. field ( "rollout" , rollout)
332
327
. field ( "js_module_format" , js_module_format)
333
328
. field ( "module_import_config" , module_import_config)
@@ -374,8 +369,8 @@ impl ProjectConfig {
374
369
) -> PathBuf {
375
370
let source_location = definition_name. location . source_location ( ) ;
376
371
let artifact_name = definition_name. item . into ( ) ;
377
- let filename = if let Some ( filename_for_artifact ) = & self . filename_for_artifact {
378
- filename_for_artifact ( source_location, artifact_name)
372
+ let filename = if let Some ( extra_artifacts_config ) = & self . extra_artifacts_config {
373
+ ( extra_artifacts_config . filename_for_artifact ) ( source_location, artifact_name)
379
374
} else {
380
375
match & self . typegen_config . language {
381
376
TypegenLanguage :: Flow | TypegenLanguage :: JavaScript => {
0 commit comments