shared-types.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // tslint:disable:no-shadowed-variable
  2. // prettier-ignore
  3. /**
  4. * A recursive implementation of the Partial<T> type.
  5. * Source: https://stackoverflow.com/a/49936686/772859
  6. */
  7. export type DeepPartial<T> = {
  8. [P in keyof T]?: null | (T[P] extends Array<infer U>
  9. ? Array<DeepPartial<U>>
  10. : T[P] extends ReadonlyArray<infer U>
  11. ? ReadonlyArray<DeepPartial<U>>
  12. : DeepPartial<T[P]>)
  13. };
  14. // tslint:enable:no-shadowed-variable
  15. /**
  16. * A type representing the type rather than instance of a class.
  17. */
  18. export interface Type<T> extends Function {
  19. // tslint:disable-next-line:callable-types
  20. new (...args: any[]): T;
  21. }
  22. /**
  23. * A type describing the shape of a paginated list response
  24. */
  25. export type PaginatedList<T> = {
  26. items: T[];
  27. totalItems: number;
  28. };
  29. /**
  30. * @description
  31. * An entity ID. Depending on the configured {@link EntityIdStrategy}, it will be either
  32. * a `string` or a `number`;
  33. *
  34. * @docsCategory entities
  35. * @docsWeight 0
  36. */
  37. export type ID = string | number;
  38. /**
  39. * @description
  40. * A data type for a custom field.
  41. *
  42. * @docsCategory custom-fields
  43. */
  44. export type CustomFieldType = 'string' | 'localeString' | 'int' | 'float' | 'boolean' | 'datetime';
  45. export type CustomFieldsObject = { [key: string]: any; };
  46. /**
  47. * This interface describes the shape of the JSON config file used by the Admin UI.
  48. */
  49. export interface AdminUiConfig {
  50. apiHost: string | 'auto';
  51. apiPort: number | 'auto';
  52. adminApiPath: string;
  53. }