11import type { Snapshot , SnapshotField , SnapshotRelation } from '@directus/api/dist/types' ;
22import type { ApiExtensionContext } from '@directus/extensions' ;
3- import { Collection } from '@directus/types' ;
3+ import type { Collection , ExtensionsServices } from '@directus/types' ;
44import { mkdir , readFile , rm , writeFile } from 'fs/promises' ;
55import { glob } from 'glob' ;
66import { condenseAction } from './condenseAction.js' ;
@@ -10,16 +10,14 @@ import { ExportHelper } from './utils.js';
1010
1111export class SchemaExporter implements IExporter {
1212 protected _filePath : string ;
13- protected _getSchemaService : ( ) => Promise < any > ;
1413 protected _exportHandler = condenseAction ( ( ) => this . createAndSaveSnapshot ( ) ) ;
1514
1615 // Directus SchemaService, database and getSchema
1716 constructor (
18- getSchemaService : ( ) => Promise < any > ,
17+ protected getSchemaService : ( ) => Promise < InstanceType < ExtensionsServices [ 'SchemaService' ] > > ,
1918 protected logger : ApiExtensionContext [ 'logger' ] ,
2019 protected options = { split : true }
2120 ) {
22- this . _getSchemaService = ( ) => getSchemaService ( ) ;
2321 this . _filePath = `${ ExportHelper . dataDir } /schema.json` ;
2422 }
2523
@@ -47,7 +45,7 @@ export class SchemaExporter implements IExporter {
4745 * Import the schema from file to the database
4846 */
4947 public load = async ( ) => {
50- const svc = await this . _getSchemaService ( ) ;
48+ const svc = await this . getSchemaService ( ) ;
5149 let json ;
5250 try {
5351 json = await readFile ( this . _filePath , { encoding : 'utf8' } ) ;
@@ -128,7 +126,7 @@ export class SchemaExporter implements IExporter {
128126 * Create and save the schema snapshot to file
129127 */
130128 protected createAndSaveSnapshot = async ( ) => {
131- const svc = this . _getSchemaService ( ) ;
129+ const svc = await this . getSchemaService ( ) ;
132130 let snapshot = ( await svc . snapshot ( ) ) as Snapshot ;
133131 snapshot = exportHook ( snapshot ) ;
134132 let hash = svc . getHashedSnapshot ( snapshot ) . hash ;
0 commit comments