import { LogContext } from '@balena/jellyfish-logger'; import { AutumnDBSession, Contract, JsonSchema, QueryOptions } from 'autumndb'; import { Operation } from 'fast-json-patch'; import { OauthProviderContract } from '../contracts/oauth-provider'; import type { WorkerContext } from '../types'; export type SyncActionContext = ReturnType; /** * @name getActionContext * @description This function generates a "context" object that provides a common interface for use by sync integrations. * * @param provider - the name of the integration e.g. 'github', 'discourse' * @param workerContext - context object provided to action functions by the jellyfish worker * @param logContext - log context * @param session - session token used to interact with Jellyfish * * @returns action context * * @example * * const handler = async (session, logContext, contract, request) => { * const syncContext = context.sync.getActionContext(request.arguments.provider, * context, request.context, context.privilegedSession) * ) * ..... * } */ export declare const getActionContext: (provider: string, workerContext: WorkerContext, logContext: LogContext, session: AutumnDBSession) => { logContext: LogContext; log: { warn: (message: string, data: any) => void; error: (message: string, data: any) => void; debug: (message: string, data: any) => void; info: (message: string, data: any) => void; exception: (message: string, error: any) => void; }; getLocalUsername: (username: string) => string; getRemoteUsername: (username: string) => string; upsertElement: (type: string, object: Partial[]; }>> | { id: string; type: string; patch: Operation[]; }, options: { actor?: string; timestamp?: Date; originator?: string; }) => Promise; getContactByEmail: (email: string) => Promise; getElementBySlug: (slug: string, usePrivilegedSession?: boolean) => Promise[]; }> | null>; getElementById: (id: string) => Promise[]; }> | null>; getOauthProviderByIntegration: (integration: string) => Promise; query: (query: JsonSchema, options?: QueryOptions) => Promise[]; }>[]>; getElementByMirrorId: (type: string, mirrorId: string, options?: { usePattern?: boolean; }) => Promise[]; }>>; getElementByMirrorIds: (type: string, mirrorIds: string[]) => Promise[]; }>>; };