This repository has been archived by the owner on Feb 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
203 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { CleanService } from 'src'; | ||
|
||
const run = async () => { | ||
const cleanService = new CleanService({ | ||
onDelete: item => { | ||
// called when any content is deleted | ||
console.log(`Deleted: ${item.title} | ${item.type}`); | ||
}, | ||
projectId: 'targetProjectId', | ||
apiKey: 'targetProjectApiKey' | ||
}); | ||
|
||
await cleanService.cleanAllAsync(); | ||
}; | ||
|
||
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { ZipService } from 'src/zip'; | ||
|
||
import { ExportService } from '../export'; | ||
|
||
const run = async () => { | ||
const exportService = new ExportService({ | ||
apiKey: 'sourceProjectApiKey', | ||
projectId: 'sourceProjectId', | ||
onExport: item => { | ||
// called when any content is exported | ||
console.log(`Exported: ${item.title} | ${item.type}`); | ||
} | ||
}); | ||
|
||
// data contains entire project content | ||
const data = await exportService.exportAllAsync(); | ||
|
||
// you can also save backup in file with ZipService | ||
const zipService = new ZipService({ | ||
filename: 'file', | ||
enableLog: true | ||
}); | ||
|
||
await zipService.createZipAsync(data); | ||
}; | ||
|
||
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { ImportService } from 'src'; | ||
import { ZipService } from 'src/zip'; | ||
|
||
const run = async () => { | ||
const zipService = new ZipService({ | ||
filename: 'xxx', | ||
enableLog: true | ||
}); | ||
|
||
const importService = new ImportService({ | ||
onImport: item => { | ||
// called when any content is imported | ||
console.log(`Imported: ${item.title} | ${item.type}`); | ||
}, | ||
projectId: 'targetProjectId', | ||
apiKey: 'targetProjectId', | ||
enableLog: true, | ||
workflowIdForImportedItems: '00000000-0000-0000-0000-000000000000' // id that items are assigned | ||
}); | ||
|
||
// read export data from zip | ||
const data = await zipService.extractZipAsync(); | ||
|
||
// restore into target project | ||
await importService.importFromSourceAsync(data); | ||
}; | ||
|
||
run(); |