types.d.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import { Joke, JokeSubmission } from "../src/types/jokes";
  2. import { LangCode } from "../src/types/languages";
  3. //#MARKER submissions
  4. /**
  5. * A single joke submission
  6. */
  7. export interface Submission {
  8. /** The submission itself */
  9. joke: JokeSubmission & { safe: boolean };
  10. /** Unique identification of the client (usually IP hash) */
  11. client: string;
  12. /** Submission timestamp (Unix-13) */
  13. timestamp: number;
  14. errors: null | string[];
  15. lang: LangCode;
  16. /** Absolute path to the joke submission */
  17. path: string;
  18. }
  19. /**
  20. * This object contains all submissions
  21. */
  22. export type AllSubmissions = {
  23. [key in LangCode]?: Submission;
  24. };
  25. // to make "en" a required property:
  26. // & {
  27. // [key in DefaultLangCode]: Submission;
  28. // };
  29. export interface ParsedFileName {
  30. /** Unique identification of the client (usually IP hash) */
  31. client: string;
  32. timestamp: number;
  33. /** Index that gets incremented if a file name is duplicate (default = 0) */
  34. index: number;
  35. }
  36. export interface ReadSubmissionsResult {
  37. submissions: AllSubmissions;
  38. amount: number;
  39. }
  40. export type LastEditedSubmission = "accepted_safe" | "accepted_unsafe" | "edited" | "deleted";
  41. export interface Keypress {
  42. name: string;
  43. ctrl: boolean;
  44. meta: boolean;
  45. shift: boolean;
  46. sequence?: string;
  47. code?: string;
  48. }
  49. //#MARKER add-joke
  50. export type AddJoke = Joke & { formatVersion: number, lang: LangCode, safe: boolean };
  51. export type NullableObj<T> = {
  52. [P in keyof T]: (T[P] | null);
  53. };
  54. //#MARKER info
  55. export interface SubmissionInfoResult
  56. {
  57. submCount: number;
  58. submLangs: LangCode[];
  59. }