types.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import { Model } from '@converse/skeletor';
  2. // Types for mixins.
  3. // -----------------
  4. // Represents the class that will be extended via a mixin.
  5. type Constructor<T = {}> = new (...args: any[]) => T;
  6. export type ModelExtender = Constructor<Model>;
  7. type EncryptionPayloadAttrs = {
  8. prekey?: boolean;
  9. device_id: string;
  10. };
  11. export type EncryptionAttrs = {
  12. encrypted?: EncryptionPayloadAttrs; // XEP-0384 encryption payload attributes
  13. is_encrypted: boolean;
  14. encryption_namespace: string;
  15. };
  16. export type XFormReportedField = {
  17. var: string;
  18. label: string;
  19. };
  20. export type XFormResultItemField = {
  21. var: string;
  22. value: string;
  23. };
  24. export type XFormOption = {
  25. value: string;
  26. label: string;
  27. selected: boolean;
  28. required: boolean;
  29. };
  30. export type XFormCaptchaURI = {
  31. type: string;
  32. data: string;
  33. };
  34. type XFormListTypes = 'list-single' | 'list-multi';
  35. type XFormJIDTypes = 'jid-single' | 'jid-multi';
  36. type XFormTextTypes = 'text-multi' | 'text-private' | 'text-single';
  37. type XFormDateTypes = 'date' | 'datetime';
  38. type XFormFieldTypes =
  39. | XFormListTypes
  40. | XFormJIDTypes
  41. | XFormTextTypes
  42. | XFormDateTypes
  43. | 'fixed'
  44. | 'boolean'
  45. | 'url'
  46. | 'hidden';
  47. export type XFormField = {
  48. var: string;
  49. label: string;
  50. type?: XFormFieldTypes;
  51. text?: string;
  52. value?: string;
  53. required?: boolean;
  54. checked?: boolean;
  55. options?: XFormOption[];
  56. uri?: XFormCaptchaURI;
  57. readonly: boolean;
  58. };
  59. export type XFormResponseType = 'result' | 'form';
  60. export type XForm = {
  61. type: XFormResponseType;
  62. title?: string;
  63. instructions?: string;
  64. reported?: XFormReportedField[];
  65. items?: XFormResultItemField[][];
  66. fields?: XFormField[];
  67. };
  68. // An object representing XEP-0372 reference data
  69. export type XEP372Reference = {
  70. begin: number;
  71. end: number;
  72. type: string;
  73. value: string;
  74. uri: string;
  75. };