2021-12-06 08:07:13 -05:00
|
|
|
import { File } from "../utils/file";
|
2021-09-24 07:53:46 -04:00
|
|
|
import Logger from "../utils/logger";
|
|
|
|
import { getEmptyLogger } from "../utils/logger-utils";
|
|
|
|
import PublisherTarget from "./publisher-target";
|
|
|
|
|
|
|
|
export default abstract class Publisher<TOptions> {
|
|
|
|
protected readonly logger: Logger;
|
|
|
|
|
2021-09-30 10:01:53 -04:00
|
|
|
public constructor(logger?: Logger) {
|
2021-09-24 07:53:46 -04:00
|
|
|
this.logger = logger || getEmptyLogger();
|
|
|
|
}
|
|
|
|
|
|
|
|
public abstract get target(): PublisherTarget;
|
|
|
|
|
2021-09-30 10:01:53 -04:00
|
|
|
public abstract publish(files: File[], options: TOptions): Promise<void>;
|
|
|
|
|
|
|
|
protected validateOptions(options: TOptions): void | never {
|
|
|
|
if (!options || typeof options !== "object") {
|
|
|
|
throw new Error(`Expected options to be an object, got ${options ? typeof options : options}`);
|
|
|
|
}
|
|
|
|
}
|
2021-09-24 07:53:46 -04:00
|
|
|
}
|