/** * External dependencies */ import type { Brand } from 'ts-brand'; /** * Internal dependencies */ import type { SocialKindName, SocialNetworkName } from './social-networks'; import type { OverwriteableQueryArg, RegularQueryArg, Url, Uuid, } from './utils'; import type { AuthorId, RoleId } from './wordpress-entities'; export type SocialProfile = { readonly id: Uuid; readonly alias?: string; readonly creationDate: string; readonly creatorId: AuthorId; readonly displayName: string; readonly email?: string; readonly isBuffer?: boolean; readonly isHootsuite?: boolean; readonly kind: SocialKindName; readonly network: SocialNetworkName; readonly publicationFrequency: number; readonly photo: Url; readonly permalinkQueryArgs: ReadonlyArray< RegularQueryArg | OverwriteableQueryArg >; readonly reshareFrequency: number; readonly status: 'valid' | 'renew'; readonly username: string; readonly link?: Url; readonly publicationStatus?: string; readonly telegramSettings?: TelegramSettings; readonly linkShortenerSettings?: LinkShortenerSettings; readonly webhookSettings?: WebhookSettings; readonly bufferSettings?: BufferSettings; readonly permissions?: | 'all-roles' | 'creator-only' | ReadonlyArray< RoleId >; }; export type SocialTargetName = Brand< string, 'SocialTargetName' >; export type SocialProfileTarget = { readonly name: SocialTargetName; readonly displayName: string; readonly image: Url; }; export type TelegramSettings = { readonly isTelegramButtonEnabled?: boolean; readonly telegramButtonLabel?: string; }; export type WebhookSettings = { readonly url: string; readonly method: 'POST' | 'GET' | 'HEAD' | 'PATCH' | 'PUT' | 'DELETE'; readonly headers: ReadonlyArray< WebhookHeader >; } & ( | { readonly bodyType: 'none' } | { readonly bodyType: 'json'; readonly bodyContent: string } | { readonly bodyType: 'form'; readonly bodyContent: ReadonlyArray< WebhookFormField >; } ); export type BufferSettings = { readonly isManagedInBuffer: boolean; }; export type WebhookHeader = { readonly key: string; readonly value: string; }; export type WebhookFormField = { readonly key: string; readonly value: string; }; export type LinkShortenerSettings = | BitlySettings | TinyUrlSettings | RebrandlySettings | YourlsSettings | ShlinkSettings | ShortioSettings | TlySettings | PolrSettings; type BitlySettings = { readonly type: 'bitly'; readonly accessToken: string; readonly domain?: string; }; type TinyUrlSettings = { readonly type: 'tinyurl'; readonly accessToken: string; readonly domain?: string; }; type YourlsSettings = { readonly type: 'yourls'; readonly apiUrl: Url; readonly signatureToken: string; }; type RebrandlySettings = { readonly type: 'rebrandly'; readonly apiKey: string; readonly domain?: string; }; type ShlinkSettings = { readonly type: 'shlink'; readonly apiUrl: Url; readonly apiKey: string; }; type ShortioSettings = { readonly type: 'shortio'; readonly apiKey: string; readonly domain: string; }; type TlySettings = { readonly type: 'tly'; readonly apiToken: string; readonly domain?: string; }; type PolrSettings = { readonly type: 'polr'; readonly apiUrl: Url; readonly apiKey: string; };