types.ts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import { ID } from '@vendure/common/lib/shared-types';
  2. import { CustomFields } from '@vendure/core';
  3. import { EntityDataMapper } from './entity-data-mapper/entity-data-mapper.interface';
  4. import { SearchIndexingStrategy } from './search-index/search-indexing.strategy';
  5. /**
  6. * @description
  7. * Configuration options for the {@link DashboardPlugin}.
  8. *
  9. * @docsCategory core plugins/DashboardPlugin
  10. */
  11. export interface DashboardPluginOptions {
  12. /**
  13. * @description
  14. * The route to the Dashboard UI.
  15. *
  16. * @default 'dashboard'
  17. */
  18. route: string;
  19. /**
  20. * @description
  21. * The path to the dashboard UI app dist directory. By default, the built-in dashboard UI
  22. * will be served. This can be overridden with a custom build of the dashboard.
  23. */
  24. appDir: string;
  25. /**
  26. * @description
  27. * Configuration of the global search feature in the dashboard UI
  28. */
  29. globalSearch?: {
  30. indexingStrategy?: SearchIndexingStrategy;
  31. entityDataMappers?: Map<keyof CustomFields | string, EntityDataMapper>;
  32. };
  33. }
  34. export type MetricSummary = {
  35. interval: MetricInterval;
  36. type: MetricType;
  37. title: string;
  38. entries: MetricSummaryEntry[];
  39. };
  40. export enum MetricType {
  41. OrderCount = 'OrderCount',
  42. OrderTotal = 'OrderTotal',
  43. AverageOrderValue = 'AverageOrderValue',
  44. }
  45. export enum MetricInterval {
  46. Daily = 'Daily',
  47. }
  48. export type MetricSummaryEntry = {
  49. label: string;
  50. value: number;
  51. };
  52. export interface MetricSummaryInput {
  53. interval: MetricInterval;
  54. types: MetricType[];
  55. refresh?: boolean;
  56. }
  57. export enum SearchIndexItemType {
  58. Entity = 'entity',
  59. Plugin = 'plugin',
  60. Docs = 'docs',
  61. Article = 'article',
  62. }
  63. export interface SearchIndexItem {
  64. id?: string;
  65. title: string;
  66. type: SearchIndexItemType;
  67. subtitle?: string;
  68. description?: string;
  69. thumbnailUrl?: string;
  70. metadata?: Record<string, any>;
  71. lastModified?: Date | string;
  72. }
  73. /**
  74. * @description The index items for custom and built-in Vendure entities
  75. */
  76. export interface EntitySearchIndexItem extends SearchIndexItem {
  77. entityId: ID;
  78. entityName: string;
  79. }
  80. /**
  81. * @description The index items for external urls like blog articles, docs or plugins.
  82. */
  83. export interface ExternalUrlSearchIndexItem extends SearchIndexItem {
  84. externalId: string;
  85. url: string;
  86. }