shared-types.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /**
  2. * A recursive implementation of the Partial<T> type.
  3. */
  4. export type DeepPartial<T> = { [K in keyof T]?: DeepPartial<T[K]> };
  5. // tslint:disable:ban-types
  6. /**
  7. * A type representing the type rather than instance of a class.
  8. */
  9. export type Type<T> = {
  10. new (...args: any[]): T;
  11. } & Function;
  12. /**
  13. * A type describing the shape of a paginated list response
  14. */
  15. export type PaginatedList<T> = {
  16. items: T[];
  17. totalItems: number;
  18. };
  19. /**
  20. * An entity ID
  21. */
  22. export type ID = string | number;
  23. export type CustomFieldType = 'string' | 'localeString' | 'int' | 'float' | 'boolean' | 'datetime';
  24. export interface CustomFieldConfig {
  25. name: string;
  26. type: CustomFieldType;
  27. }
  28. export interface CustomFields {
  29. Address?: CustomFieldConfig[];
  30. Customer?: CustomFieldConfig[];
  31. Product?: CustomFieldConfig[];
  32. ProductOption?: CustomFieldConfig[];
  33. ProductOptionGroup?: CustomFieldConfig[];
  34. ProductVariant?: CustomFieldConfig[];
  35. User?: CustomFieldConfig[];
  36. }
  37. /**
  38. * This interface should be implemented by any entity which can be extended
  39. * with custom fields.
  40. */
  41. export interface HasCustomFields {
  42. customFields: CustomFieldsObject;
  43. }
  44. export type MayHaveCustomFields = Partial<HasCustomFields>;
  45. export type CustomFieldsObject = { [key: string]: any; };