import { Locales } from '@localazy/languages'; export declare type AccessToken = string; export declare type AnalyticsTrackRequest = { event: string; category?: string; data: { userId: string; orgId: string; [key: string]: any; }; }; export declare type AnalyticsTrackResponse = { success: boolean; }; export declare class ApiAnalytics extends ApiBase { track(request: AnalyticsTrackRequest, config?: RequestConfig): Promise; } export declare abstract class ApiBase { protected api: GenericConnectorClient; constructor(api: GenericConnectorClient); } export declare class ApiOAuth extends ApiBase { poll(request: OAuthPollRequest, config?: RequestConfig): Promise; /** * Polls the OAuth server continuously until the sign in process is completed * Polls for 3 minutes by default * @throws Error if polling times out */ continuousPoll(request: OAuthContinuousPollRequest, config?: RequestConfig): Promise; } export declare class ApiPublic extends ApiBase { /** * Get generated {@link GeneratedKeys keys} for OAuth polling process * * @param config Request config */ keys(config?: RequestConfig): Promise; } export declare class FetchHttpAdapter implements IHttpAdapter { protected genericConnectorUrl: string; protected pluginId: Services; constructor(options: GenericConnectorClientOptions); get(url: string, config?: RequestConfig): Promise; post(url: string, data: unknown, config?: RequestConfig): Promise; put(url: string, data: unknown, config?: RequestConfig): Promise; delete(url: string, config?: RequestConfig): Promise; protected urlFactory(url: string): string; protected configFactory(method: string, config?: RequestConfig, data?: unknown): RequestInit; protected makeRequest(method: string, url: string, config?: RequestConfig, data?: unknown): Promise; } export declare type GeneratedKeys = { writeKey: string; readKey: string; }; export declare class GenericConnectorClient { client: IHttpAdapter; public: ApiPublic; oauth: ApiOAuth; analytics: ApiAnalytics; constructor(options: GenericConnectorClientOptions); } export declare type GenericConnectorClientOptions = { pluginId: Services; genericConnectorUrl?: string; }; /** * Get OAuth authorization URL for the given request * @param query OAuth authorization URL request * @param baseUrl Base URL (can be with path), if passed, it will be used instead of `https://localazy.com` * @returns OAuth authorization URL */ export declare function getOAuthAuthorizationUrl(query: OAuthAuthorizationUrlRequest, baseUrl?: string): string; export declare interface IHttpAdapter { get: (url: string, config?: T) => Promise; post: (url: string, data: unknown, config?: T) => Promise; put: (url: string, data: unknown, config?: T) => Promise; delete: (url: string, config?: T) => Promise; } export declare type MinimalRole = 'reviewer' | 'manager' | 'owner'; export declare type OAuthAccessTokenResponse = { accessToken: AccessToken; scope: Scope; user?: User; project?: Project; org?: Org; }; export declare type OAuthAuthorizationUrlRequest = { /** * Identifier of the oauth application. */ clientId: string; /** * Default: as defined by app * Redirect URI must have the same host, protocol and path prefix as redirect URI defined in the app. */ redirectUri?: string; /** * Optional custom identifier; will be passed to the redirect URI after authorization. */ customId?: string; /** * Optional state, will be passed to the redirect URI after authorization. */ state?: string; /** * Default: as defined by app * Allow to overwrite the scope defined by the app. */ scope?: Scope; /** * Default: false * If set to true, it allows for creating a new app in authorization dialog. */ allowCreate?: boolean; /** * Default: `private` * The type of the project to be create if `allowCreate` is enabled */ createType?: ProjectType; /** * Default: `en` * The source locale of the project to be create if `allowCreate` is enabled. */ createLocale?: Locales; /** * Default: `none` * The minimal user role for the project. */ minimalRole?: MinimalRole; }; export declare type OAuthContinuousPollRequest = OAuthPollRequest & { pollingMaxAttempts?: number; pollingIntervalMs?: number; }; export declare type OAuthPollRequest = { readKey: string; }; export declare type Org = { id: string; name: string; }; export declare type PollResponse = PollResponsePending | PollResponseCompleted; export declare type PollResponseCompleted = { completed: true; data: OAuthAccessTokenResponse; }; export declare type PollResponsePending = { completed: false; data: Record; }; export declare type Project = { id: string; name: string; url: string; image: string; orgId: string; }; export declare type ProjectType = 'public' | 'private' | 'secret'; export declare type RequestConfig = { headers?: Record; params?: Record; responseType?: 'json' | 'text' | 'blob'; }; export declare type Scope = 'login' | 'read_project' | 'write_project' | 'read_organization' | 'write_organization' | 'full_access' | 'none'; export declare enum Services { 'UNKNOWN_SERVICE' = -1, 'FIGMA' = 0, 'STRAPI' = 1, 'ZAPIER' = 2, 'STORYBLOK' = 3, 'INTERCOM' = 4, 'DIRECTUS' = 5, 'ZENDESK' = 6, 'IN_CONTEXT_EDITOR' = 7 } export declare type User = { id: string; name: string; email?: string; }; export { }