types.ts 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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?: Record<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 interface SearchIndexItem {
  58. id?: string;
  59. title: string;
  60. type: 'entity' | 'plugin' | 'docs' | 'article';
  61. subtitle?: string;
  62. description?: string;
  63. thumbnailUrl?: string;
  64. metadata?: Record<string, any>;
  65. lastModified?: Date | string;
  66. }
  67. /**
  68. * @description The index items for custom and built-in Vendure entities
  69. */
  70. export interface EntitySearchIndexItem extends SearchIndexItem {
  71. entityId: ID;
  72. entityName: string;
  73. }
  74. /**
  75. * @description The index items for external urls like blog articles, docs or plugins.
  76. */
  77. export interface ExternalUrlSearchIndexItem extends SearchIndexItem {
  78. externalId: string;
  79. url: string;
  80. }