@@ -211,6 +211,12 @@ interface FabricateAPI {
211211 */
212212 export ( craftingSystemId : string ) : Promise < FabricateExportModel > ;
213213
214+ /**
215+ * Downloads a copy of all Fabricate data as a JSON file. This function is used for debugging and troubleshooting.
216+ * If you want to export data from Fabricate for use in another Foundry VTT world, use {@link FabricateAPI#export}
217+ */
218+ downloadData ( ) : void ;
219+
214220}
215221
216222export { FabricateAPI }
@@ -259,6 +265,18 @@ class DefaultFabricateAPI implements FabricateAPI {
259265 this . settingMigrationAPI = settingMigrationAPI ;
260266 }
261267
268+ downloadData ( ) : void {
269+ const allFabricateSettingValues = Array . from ( game . settings . storage . get ( "world" ) . values ( ) )
270+ . filter ( ( setting : any ) => setting . key . search ( new RegExp ( "fabricate" , "i" ) ) >= 0 ) ;
271+ const fileContents = JSON . stringify ( allFabricateSettingValues , null , 2 ) ;
272+ const dateTime = new Date ( ) ;
273+ const postfix = dateTime . toISOString ( )
274+ . replace ( / : \s * / g, "-" )
275+ . replace ( "." , "-" ) ;
276+ const fileName = `fabricate-data-extract-${ postfix } .json` ;
277+ saveDataToFile ( fileContents , "application/json" , fileName ) ;
278+ }
279+
262280 get documentManager ( ) : DocumentManager {
263281 return this . _documentManager ;
264282 }
@@ -448,7 +466,6 @@ class DefaultFabricateAPI implements FabricateAPI {
448466
449467 async import ( importData : FabricateExportModel ) : Promise < CraftingSystemData > {
450468
451-
452469 importData = this . upgradeV1ImportData ( importData ) ;
453470 await this . validateImportData ( importData ) ;
454471
0 commit comments