base-data-processor.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { Injector } from '@vendure/core';
  2. import { Serializable } from 'node:child_process';
  3. import { DASHBOARD_PLUGIN_OPTIONS } from '../constants';
  4. import { SearchIndexingStrategy } from '../search-index/search-indexing.strategy';
  5. import { DbIndexingStrategy } from '../search-index/db-indexing.strategy';
  6. import { DashboardPluginOptions } from '../types';
  7. import { DataProcessorInterface } from './data-processor.interface';
  8. export abstract class BaseDataProcessor implements DataProcessorInterface {
  9. protected searchIndexingStrategy: SearchIndexingStrategy;
  10. init(injector: Injector) {
  11. const options = injector.get(DASHBOARD_PLUGIN_OPTIONS) as DashboardPluginOptions;
  12. this.searchIndexingStrategy = options.globalSearch?.indexingStrategy ?? new DbIndexingStrategy();
  13. }
  14. getBatchSize(): number {
  15. throw new Error('Not implemented');
  16. }
  17. getTotalResults(metadata: Record<string, Serializable> | undefined): Promise<number> {
  18. throw new Error('Not implemented');
  19. }
  20. processOne(id: string, metadata: Record<string, Serializable> | undefined): Promise<void> {
  21. throw new Error('Not implemented');
  22. }
  23. processBatch(
  24. skip: number,
  25. limit: number,
  26. metadata: Record<string, Serializable> | undefined,
  27. ): AsyncGenerator<void> {
  28. throw new Error('Not implemented');
  29. }
  30. }