import { Nango } from '@nangohq/node'; import type { AxiosInstance, AxiosInterceptorManager, AxiosRequestConfig, AxiosResponse } from 'axios'; import { AxiosError } from 'axios'; import type { ApiEndUser, DBSyncConfig, DBTeam, GetPublicIntegration, RunnerFlags } from '@nangohq/types'; export declare const oldLevelToNewLevel: { readonly debug: "debug"; readonly info: "info"; readonly warn: "warn"; readonly error: "error"; readonly verbose: "debug"; readonly silly: "debug"; readonly http: "info"; }; type LogLevel = 'info' | 'debug' | 'error' | 'warn' | 'http' | 'verbose' | 'silly'; type ParamEncoder = (value: any, defaultEncoder: (value: any) => any) => any; interface GenericFormData { append(name: string, value: any, options?: any): any; } type SerializerVisitor = (this: GenericFormData, value: any, key: string | number, path: null | (string | number)[], helpers: FormDataVisitorHelpers) => boolean; type CustomParamsSerializer = (params: Record, options?: ParamsSerializerOptions) => string; interface FormDataVisitorHelpers { defaultVisitor: SerializerVisitor; convertValue: (value: any) => any; isVisitable: (value: any) => boolean; } interface SerializerOptions { visitor?: SerializerVisitor; dots?: boolean; metaTokens?: boolean; indexes?: boolean | null; } interface ParamsSerializerOptions extends SerializerOptions { encode?: ParamEncoder; serialize?: CustomParamsSerializer; } interface Pagination { type: string; limit?: number; response_path?: string; limit_name_in_request: string; } interface CursorPagination extends Pagination { cursor_path_in_response: string; cursor_name_in_request: string; } interface LinkPagination extends Pagination { link_rel_in_response_header?: string; link_path_in_response_body?: string; } interface OffsetPagination extends Pagination { offset_name_in_request: string; offset_start_value?: number; offset_calculation_method?: 'per-page' | 'by-response-size'; } interface RetryHeaderConfig { at?: string; after?: string; } export interface ProxyConfiguration { endpoint: string; providerConfigKey?: string; connectionId?: string; method?: 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE' | 'get' | 'post' | 'patch' | 'put' | 'delete'; headers?: Record; params?: string | Record; paramsSerializer?: ParamsSerializerOptions; data?: unknown; retries?: number; baseUrlOverride?: string; paginate?: Partial | Partial | Partial; retryHeader?: RetryHeaderConfig; responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'; retryOn?: number[] | null; } export interface AuthModes { OAuth1: 'OAUTH1'; OAuth2: 'OAUTH2'; OAuth2CC: 'OAUTH2_CC'; Basic: 'BASIC'; ApiKey: 'API_KEY'; AppStore: 'APP_STORE'; Custom: 'CUSTOM'; App: 'APP'; None: 'NONE'; TBA: 'TBA'; Tableau: 'TABLEAU'; Jwt: 'JWT'; Bill: 'BILL'; TwoStep: 'TWO_STEP'; Signature: 'SIGNATURE'; } export type AuthModeType = AuthModes[keyof AuthModes]; interface OAuth1Token { oAuthToken: string; oAuthTokenSecret: string; } interface AppCredentials { type: AuthModes['App']; access_token: string; expires_at?: Date | undefined; raw: Record; } interface AppStoreCredentials { type?: AuthModes['AppStore']; access_token: string; expires_at?: Date | undefined; raw: Record; private_key: string; } interface BasicApiCredentials { type: AuthModes['Basic']; username: string; password: string; } interface ApiKeyCredentials { type: AuthModes['ApiKey']; apiKey: string; } interface CredentialsCommon> { type: AuthModeType; raw: T; } interface OAuth2Credentials extends CredentialsCommon { type: AuthModes['OAuth2']; access_token: string; refresh_token?: string; expires_at?: Date | undefined; } interface OAuth2ClientCredentials extends CredentialsCommon { type: AuthModes['OAuth2CC']; token: string; expires_at?: Date | undefined; client_id: string; client_secret: string; } interface OAuth1Credentials extends CredentialsCommon { type: AuthModes['OAuth1']; oauth_token: string; oauth_token_secret: string; } interface TbaCredentials { type: AuthModes['TBA']; token_id: string; token_secret: string; config_override: { client_id?: string; client_secret?: string; }; } interface TableauCredentials extends CredentialsCommon { type: AuthModes['Tableau']; pat_name: string; pat_secret: string; content_url?: string; token?: string; expires_at?: Date | undefined; } interface JwtCredentials { type: AuthModes['Jwt']; privateKeyId?: string; issuerId?: string; privateKey: { id: string; secret: string; } | string; token?: string; expires_at?: Date | undefined; } interface BillCredentials extends CredentialsCommon { type: AuthModes['Bill']; username: string; password: string; organization_id: string; dev_key: string; session_id?: string; user_id?: string; expires_at?: Date | undefined; } interface TwoStepCredentials extends CredentialsCommon { type: AuthModes['TwoStep']; [key: string]: any; token?: string; expires_at?: Date | undefined; } interface SignatureCredentials { type: AuthModes['Signature']; username: string; password: string; token?: string; expires_at?: Date | undefined; } interface CustomCredentials extends CredentialsCommon { type: AuthModes['Custom']; } type UnauthCredentials = Record; type AuthCredentials = OAuth2Credentials | OAuth2ClientCredentials | OAuth1Credentials | BasicApiCredentials | ApiKeyCredentials | AppCredentials | AppStoreCredentials | UnauthCredentials | TbaCredentials | TableauCredentials | JwtCredentials | BillCredentials | TwoStepCredentials | SignatureCredentials | CustomCredentials; type Metadata = Record; interface MetadataChangeResponse { metadata: Metadata; provider_config_key: string; connection_id: string | string[]; } interface Connection { id: number; provider_config_key: string; connection_id: string; connection_config: Record; created_at: string; updated_at: string; last_fetched_at: string; metadata: Record | null; provider: string; errors: { type: string; log_id: string; }[]; end_user: ApiEndUser | null; credentials: AuthCredentials; } export declare class ActionError> extends Error { type: string; payload?: Record; constructor(payload?: T); } interface RunArgs { sync: string; connectionId: string; lastSyncDate?: string; useServerLastSyncDate?: boolean; input?: object; metadata?: Metadata; autoConfirm: boolean; debug: boolean; optionalEnvironment?: string; optionalProviderConfigKey?: string; } export interface DryRunServiceInterface { run: (options: RunArgs, debug?: boolean) => Promise; } export interface NangoProps { scriptType: 'sync' | 'action' | 'webhook' | 'on-event'; host?: string; secretKey: string; team?: Pick; connectionId: string; environmentId: number; environmentName?: string; activityLogId?: string | undefined; providerConfigKey: string; provider: string; lastSyncDate?: Date; syncId?: string | undefined; nangoConnectionId?: number; syncJobId?: number | undefined; dryRun?: boolean; track_deletes?: boolean; attributes?: object | undefined; logMessages?: { counts: { updated: number; added: number; deleted: number; }; messages: unknown[]; } | undefined; rawSaveOutput?: Map | undefined; rawDeleteOutput?: Map | undefined; stubbedMetadata?: Metadata | undefined; abortSignal?: AbortSignal; dryRunService?: DryRunServiceInterface; syncConfig: DBSyncConfig; runnerFlags: RunnerFlags; debug: boolean; startedAt: Date; endUser: { id: number; endUserId: string | null; orgId: string | null; } | null; axios?: { request?: AxiosInterceptorManager; response?: { onFulfilled: (value: AxiosResponse) => AxiosResponse | Promise; onRejected: (value: unknown) => AxiosError | Promise; }; }; } export interface EnvironmentVariable { name: string; value: string; } export declare const defaultPersistApi: AxiosInstance; export declare class NangoAction { protected nango: Nango; private attributes; protected persistApi: AxiosInstance; activityLogId?: string | undefined; syncId?: string; nangoConnectionId?: number; environmentId: number; environmentName?: string; syncJobId?: number; dryRun?: boolean; abortSignal?: AbortSignal; dryRunService?: DryRunServiceInterface; syncConfig?: DBSyncConfig; runnerFlags: RunnerFlags; connectionId: string; providerConfigKey: string; provider?: string; ActionError: typeof ActionError; private memoizedConnections; private memoizedIntegration; constructor(config: NangoProps, { persistApi }?: { persistApi: AxiosInstance; }); protected stringify(): string; private proxyConfig; protected throwIfAborted(): void; proxy(config: ProxyConfiguration): Promise>; get(config: Omit): Promise>; post(config: Omit): Promise>; put(config: Omit): Promise>; patch(config: Omit): Promise>; delete(config: Omit): Promise>; getToken(): Promise; /** * Get current integration */ getIntegration(queries?: GetPublicIntegration['Querystring']): Promise; getConnection(providerConfigKeyOverride?: string, connectionIdOverride?: string): Promise; setMetadata(metadata: Metadata): Promise>; updateMetadata(metadata: Metadata): Promise>; /** * @deprecated please use setMetadata instead. */ setFieldMapping(fieldMapping: Record): Promise>; getMetadata(): Promise; getWebhookURL(): Promise; /** * @deprecated please use getMetadata instead. */ getFieldMapping(): Promise; /** * Log * @desc Log a message to the activity log which shows up in the Nango Dashboard * note that the last argument can be an object with a level property to specify the log level * @example * ```ts * await nango.log('This is a log message', { level: 'error' }) * ``` */ log(message: any, options?: { level?: LogLevel; } | { [key: string]: any; level?: never; }): Promise; log(message: string, ...args: [any, { level?: LogLevel; }]): Promise; getEnvironmentVariables(): Promise; getFlowAttributes(): A | null; paginate(config: ProxyConfiguration): AsyncGenerator; triggerAction(providerConfigKey: string, connectionId: string, actionName: string, input?: In): Promise; triggerSync(providerConfigKey: string, connectionId: string, syncName: string, fullResync?: boolean): Promise; private sendLogToPersist; private logAPICall; } export declare class NangoSync extends NangoAction { lastSyncDate?: Date; track_deletes: boolean; logMessages?: { counts: { updated: number; added: number; deleted: number; }; messages: unknown[]; } | undefined; rawSaveOutput?: Map; rawDeleteOutput?: Map; stubbedMetadata?: Metadata | undefined; private batchSize; constructor(config: NangoProps); /** * @deprecated please use batchSave */ batchSend(results: T[], model: string): Promise; batchSave(results: T[], model: string): Promise; batchDelete(results: T[], model: string): Promise; batchUpdate(results: T[], model: string): Promise; getMetadata(): Promise; } /** * @internal * * This function will enable tracing on the SDK * It has been split from the actual code to avoid making the code too dirty and to easily enable/disable tracing if there is an issue with it */ export declare function instrumentSDK(rawNango: NangoAction | NangoSync): NangoAction | NangoSync; export {};