import { stripIndent } from "common-tags"; import { IFileWriter, TFileWriterConfig } from "../../types"; import { FileWriter } from "../../base"; import { GlobalHelpers } from "../../../helpers"; class HelperFileTypeDefsWriter extends FileWriter implements IFileWriter { constructor(protected config: TFileWriterConfig) { super(config); } getFileContent() { let fileContent = ''; const { strategyName,collectionNameFromList} = this.config; if (typeof collectionNameFromList === 'string') { if (collectionNameFromList.toLowerCase() === 'firestore-listeners') { fileContent = stripIndent` export type T${strategyName}Config = { onSnapshotCallBack: (snapshot: any) => void; }; `; } else { fileContent = stripIndent` export type T${strategyName}Config = {}; `; } } return fileContent; } execute() { try { this.write('wx'); } catch (error) { GlobalHelpers.showError(error); } } } export { HelperFileTypeDefsWriter };