import {ObjectTreesApplicationInterface} from '../../application.interface';
import {ExtensionProvider} from '../../integration/extension.provider';
import {LocationProvider} from '../location/location.provider';
import {ActionFileService} from './action-file.service';
import {
  CONTENT_FILE_PROVIDER,
  FILES_DIRECTORY_FILES_DIRECTORY_SUBTYPE,
  FILES_DIRECTORY_TYPE,
  FILE_DIRECTORIES_FILES_DIRECTORY_SUBTYPE,
  FILE_DIRECTORIES_TYPE,
  FILE_DIRECTORY_FILE_SUBTYPE,
  FILE_DIRECTORY_REFERRER_TYPE,
  FILE_DIRECTORY_SELECTOR_TYPE,
  FILE_TYPE,
} from './content-file.const';
import {
  ContentFile,
  ContentFileRepository,
  ContentFileService,
  File,
} from './content-file.definition';
import {InterceptFileService} from './intercept-file.service';
import {TransientFileService} from './transient-file.service';

export class ContentFileProvider extends ExtensionProvider {
  constructor(protected app: ObjectTreesApplicationInterface) {
    super(CONTENT_FILE_PROVIDER, app);

    this.requiredProviders.push(LocationProvider);

    this.models.push(File, ContentFile);
    this.repositories.push({repoClass: ContentFileRepository});

    this.services.push(
      {cls: ContentFileService},
      {cls: TransientFileService},
      {cls: InterceptFileService},
      {cls: ActionFileService},
    );

    this.objectTypes.push(
      FILES_DIRECTORY_TYPE,
      FILES_DIRECTORY_TYPE,
      FILE_DIRECTORIES_TYPE,
      FILE_DIRECTORY_REFERRER_TYPE,
      FILE_TYPE,
      FILE_DIRECTORY_SELECTOR_TYPE,
    );

    this.objectSubTypes.push(
      FILE_DIRECTORIES_FILES_DIRECTORY_SUBTYPE,
      FILE_DIRECTORY_FILE_SUBTYPE,
      FILES_DIRECTORY_FILES_DIRECTORY_SUBTYPE,
    );
  }
}
