Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

3.4 KB
Raw Blame
export type Display = 'modal' | 'banner' | 'toast';
export type Severity = 'info' | 'warn' | 'critical';

export type NoticeCondition =
  | { kind: 'firstLogin' }
  | { kind: 'always' }
  | { kind: 'noTrips' }
  | { kind: 'existingUserBeforeVersion'; version: string }
  | { kind: 'dateWindow'; startsAt: string; endsAt?: string }
  | { kind: 'role'; roles: Array<'admin' | 'user'> }
  | { kind: 'addonEnabled'; addonId: string }
  // Whether the operator of this install owns its configuration. A notice that
  // asks the reader to update, to check a log or to fund the project assumes
  // they run it themselves.
  | { kind: 'managed'; is: boolean }
  | { kind: 'custom'; id: string };

export interface NoticeMedia {
  src: string;
  srcDark?: string;
  altKey: string;
  placement?: 'hero' | 'inline';
  aspectRatio?: string;
}

export type NoticeCta =
  | { kind: 'nav'; labelKey: string; href: string }
  | { kind: 'link'; labelKey: string; href: string } // external URL, opens in a new tab
  | { kind: 'action'; labelKey: string; actionId: string; dismissOnAction?: boolean };

export interface NoticeReleaseFeature {
  iconName: string;
  /** A small illustration the client draws on the card; unknown names fall back to the icon. */
  visual?: string;
  /** `wide` spans the row, picture beside the text; the default is an upright card. */
  layout?: 'card' | 'wide';
  titleKey: string;
  bodyKey: string;
}

/**
 * The release layout: the release on the left, a note from the maintainer on
 * the right. A notice carrying this renders through the dedicated two-column
 * modal instead of the generic notice body.
 */
export interface NoticeRelease {
  version: string;
  eyebrowKey: string;
  headlineKey: string;
  introKey: string;
  featuresLabelKey: string;
  featuresAsideKey?: string;
  features: NoticeReleaseFeature[];
  /** A tile across the release column with the app store cards and their QR codes. */
  apps?: { titleKey: string };
  notes?: { labelKey: string; href: string };
  footnoteKey?: string;
  note: {
    eyebrowKey: string;
    titleKey: string;
    bodyKey: string;
    promiseLabelKey: string;
    promiseLeadKey: string;
    promiseTextKey: string;
    bodyAfterKey: string;
    closingKey: string;
  };
  /** Labels the support footer as a card like the promise; without it the footer is a plain line. */
  supportLabelKey?: string;
  supportLeadKey: string;
  supportTextKey: string;
}

export interface SystemNotice {
  id: string;
  display: Display;
  severity: Severity;
  titleKey: string;
  bodyKey: string;
  bodyParams?: Record<string, string>;
  icon?: string;
  media?: NoticeMedia;
  highlights?: Array<{ labelKey: string; iconName?: string }>;
  cta?: NoticeCta;
  secondaryCta?: NoticeCta;
  tertiaryCta?: NoticeCta;
  /** Set to render the two-column release modal rather than the generic body. */
  release?: NoticeRelease;
  // Hide this notice on small/mobile viewports (evaluated client-side).
  desktopOnly?: boolean;
  dismissible: boolean;
  conditions: NoticeCondition[];
  publishedAt: string;
  minVersion?: string;
  maxVersion?: string;
  priority?: number;
  // 'per-version': re-show on every app version bump (each install + upgrade) instead of
  // the default permanent one-time dismissal.
  recurring?: 'per-version';
}

// DTO sent to client (same shape minus the conditions — server evaluates those)
export type SystemNoticeDTO = Omit<
  SystemNotice,
  'conditions' | 'publishedAt' | 'minVersion' | 'maxVersion' | 'priority' | 'recurring'
>;