import * as _sinclair_typebox from '@sinclair/typebox';
import { TObject, Static, TProperties, TSchema, TOptional, TString } from '@sinclair/typebox';
import { z } from 'zod';

interface AppCredential<Data extends {}> {
    credentialKey: string;
    data: Data;
}
interface AnyAppCredential extends AppCredential<any> {
}

declare const zAutomationTrigger: z.ZodObject<{
    appKey: z.ZodString;
    triggerKey: z.ZodString;
    credentialKey: z.ZodString;
    inputParams: z.ZodRecord<z.ZodString, z.ZodAny>;
    subscription: z.ZodOptional<z.ZodObject<{
        createdAt: z.ZodString;
        refreshedAt: z.ZodOptional<z.ZodString>;
        data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
    }, "strip", z.ZodTypeAny, {
        createdAt: string;
        refreshedAt?: string | undefined;
        data?: Record<string, any> | undefined;
    }, {
        createdAt: string;
        refreshedAt?: string | undefined;
        data?: Record<string, any> | undefined;
    }>>;
}, "strip", z.ZodTypeAny, {
    appKey: string;
    triggerKey: string;
    credentialKey: string;
    inputParams: Record<string, any>;
    subscription?: {
        createdAt: string;
        refreshedAt?: string | undefined;
        data?: Record<string, any> | undefined;
    } | undefined;
}, {
    appKey: string;
    triggerKey: string;
    credentialKey: string;
    inputParams: Record<string, any>;
    subscription?: {
        createdAt: string;
        refreshedAt?: string | undefined;
        data?: Record<string, any> | undefined;
    } | undefined;
}>;
type AutomationTrigger = z.infer<typeof zAutomationTrigger>;

interface Consumer {
    consumerKey: string;
}
declare const zConsumerTokenData: z.ZodObject<{
    iss: z.ZodString;
    sub: z.ZodString;
    iat: z.ZodNumber;
    exp: z.ZodNumber;
    "rollout.com": z.ZodOptional<z.ZodObject<{
        authData: z.ZodAny;
        dev: z.ZodOptional<z.ZodBoolean>;
    }, "strip", z.ZodTypeAny, {
        authData?: any;
        dev?: boolean | undefined;
    }, {
        authData?: any;
        dev?: boolean | undefined;
    }>>;
}, "strip", z.ZodTypeAny, {
    iss: string;
    sub: string;
    iat: number;
    exp: number;
    "rollout.com"?: {
        authData?: any;
        dev?: boolean | undefined;
    } | undefined;
}, {
    iss: string;
    sub: string;
    iat: number;
    exp: number;
    "rollout.com"?: {
        authData?: any;
        dev?: boolean | undefined;
    } | undefined;
}>;
interface ConsumerTokenData extends z.infer<typeof zConsumerTokenData> {
}

type ExecuteActionFunction<InputParamsSchema extends TObject, AppCredential extends AnyAppCredential> = (props: {
    /**
     * Consumer the automation being executed belongs to.
     */
    consumer: Consumer;
    /**
     * Credential that was used to set up the action.
     */
    credential: AppCredential;
    /**
     * @internal
     * @deprecated
     * Use `triggerPayload` instead.
     */
    inputVariableValues: Record<string, any>;
    /**
     * Contains trigger event payload for this action execution.
     */
    triggerPayload: Record<string, any>;
    rawInputParams: Static<InputParamsSchema>;
    resolvedInputParams: Static<InputParamsSchema>;
    triggerRef: AutomationTrigger;
}) => Promise<any>;
/**
 * Describes a Connector Action.
 */
type ActionDefinition<Name extends string, InputParamsSchema extends TObject, Credential extends AnyAppCredential> = {
    /**
     * Name of the Action that will be displayed in UI.
     **/
    name: Name;
    /**
     * Type schema for the input params.
     * Use the {@link defineActionInputParamsSchema} function to describe the types.
     */
    inputParamsSchema: InputParamsSchema;
    /**
     * Function which executes the Action.
     */
    execute: ExecuteActionFunction<InputParamsSchema, Credential>;
};
type AnyActionDefinition = ActionDefinition<string, TObject, AnyAppCredential>;
/**
 * Used to define a Connector Action.
 * @example
 * ```ts
 * import { defineAction } from "@rollout/framework";
 * import { MyAppCredential } from "./auth";
 *
 * const inputParamsSchema: z.object({
 *   name: z.string()
 * });
 *
 * export const action = defineAction<MyAppCredential>()({
 *   name: "My Action",
 *   inputParamsSchema,
 *   async execute({ credential, resolvedInputParams }) {
 *     // Execute the action here.
 *     // Return the output.
 *     return {};
 *   }
 * });
 * ```
 */
declare function defineAction<CredentialType extends AnyAppCredential>(): <Name extends string, InputParamsSchema extends TObject<_sinclair_typebox.TProperties>>(definition: ActionDefinition<Name, InputParamsSchema, CredentialType>) => ActionDefinition<Name, InputParamsSchema, CredentialType>;
declare class UserError extends Error {
}

declare const types$2: {
    array: <T extends _sinclair_typebox.TSchema>(schema: T, options?: _sinclair_typebox.ArrayOptions | undefined) => _sinclair_typebox.TArray<T>;
    boolean: (options?: _sinclair_typebox.SchemaOptions | undefined) => _sinclair_typebox.TBoolean;
    literal: <T_1 extends _sinclair_typebox.TLiteralValue>(value: T_1, options?: _sinclair_typebox.SchemaOptions | undefined) => _sinclair_typebox.TLiteral<T_1>;
    object: <T_2 extends TProperties>(properties: T_2, options?: _sinclair_typebox.ObjectOptions | undefined) => TObject<T_2>;
    optional: <T_3 extends _sinclair_typebox.TSchema>(schema: T_3) => _sinclair_typebox.TOptional<T_3>;
    record: <K extends _sinclair_typebox.TSchema, T_4 extends _sinclair_typebox.TSchema>(key: K, schema: T_4, options?: _sinclair_typebox.ObjectOptions | undefined) => _sinclair_typebox.TRecordResolve<K, T_4>;
    string: (options?: _sinclair_typebox.StringOptions | undefined) => _sinclair_typebox.TString;
    union: {
        (anyOf: [], options?: _sinclair_typebox.SchemaOptions | undefined): _sinclair_typebox.TNever;
        <T_5 extends [_sinclair_typebox.TSchema]>(anyOf: [...T_5], options?: _sinclair_typebox.SchemaOptions | undefined): T_5[0];
        <T_6 extends _sinclair_typebox.TSchema[]>(anyOf: [...T_6], options?: _sinclair_typebox.SchemaOptions | undefined): _sinclair_typebox.TUnion<T_6>;
        <T_7 extends _sinclair_typebox.TTemplateLiteral<_sinclair_typebox.TTemplateLiteralKind[]>>(template: T_7): _sinclair_typebox.Ensure<_sinclair_typebox.UnionType<_sinclair_typebox.Assert<_sinclair_typebox.UnionToTuple<{ [K_1 in Static<T_7, []>]: _sinclair_typebox.TLiteral<K_1>; }[Static<T_7, []>], _sinclair_typebox.UnionLast<{ [K_1 in Static<T_7, []>]: _sinclair_typebox.TLiteral<K_1>; }[Static<T_7, []>]>>, _sinclair_typebox.TLiteral<_sinclair_typebox.TLiteralValue>[]>>>;
    };
};
type InferActionInputParamsSchema<T extends TObject> = Static<T>;
/**
 * Used to define the `inputParams` schema for an Action.
 * @example
 * ```ts
 * import { defineActionInputParamsSchema } from "@rollout/framework";
 *
 * export const inputParamsSchema = defineActionInputParamsSchema((t) => ({
 *   workspace: t.string(),
 *   project: t.string({ description: "Which project?" }),
 *   taskId: t.optional(t.string({ title: "Task" })),
 *   type: t.union([t.literal("A"), t.literal("B")], {
 *     title: "Task Type",
 *   }),,
 * }));
 * ```
 */
declare function defineActionInputParamsSchema<Params extends TProperties>(definer: (t: typeof types$2) => Params): TObject<Params>;

type GetCredentialOptionResult = {
    label: string;
    avatar?: string;
};
type GetCredentialOptionFnOpts<Cred extends AnyAppCredential> = {
    credential: Cred;
};
type GetCredentialOptionFn<Cred extends AnyAppCredential> = (opts: GetCredentialOptionFnOpts<Cred>) => GetCredentialOptionResult | Promise<GetCredentialOptionResult>;
type GetAuthorizeURLFnOpts$1 = {
    appKey: string;
    consumerKey: string;
    state: string;
    codeChallenge: string | undefined;
    customParams: Record<string, any> | undefined;
    redirectUri: string;
};
type GetAuthorizeURLFn = (opts: GetAuthorizeURLFnOpts$1) => string | Promise<string>;
type CommonOAuthGetTokenFromCodeFnOpts = {
    query: Record<string, string>;
    consumerKey: string;
    state: string;
    requestUrl: string;
    redirectUri: string;
    customParams: Record<string, any> | undefined;
};
type PKCEFunction = () => {
    codeChallenge: string;
    codeVerifier: string;
};
declare const zAuthCustomParamInputDefinition: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
    type: z.ZodLiteral<"textfield">;
    key: z.ZodString;
    label: z.ZodString;
    placeholder: z.ZodOptional<z.ZodString>;
    infoHTML: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
    type: "textfield";
    key: string;
    label: string;
    placeholder?: string | undefined;
    infoHTML?: string | undefined;
}, {
    type: "textfield";
    key: string;
    label: string;
    placeholder?: string | undefined;
    infoHTML?: string | undefined;
}>, z.ZodObject<{
    type: z.ZodLiteral<"dropdown">;
    key: z.ZodString;
    label: z.ZodString;
    options: z.ZodArray<z.ZodObject<{
        id: z.ZodString;
        name: z.ZodString;
    }, "strip", z.ZodTypeAny, {
        id: string;
        name: string;
    }, {
        id: string;
        name: string;
    }>, "many">;
    placeholder: z.ZodOptional<z.ZodString>;
    infoHTML: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
    options: {
        id: string;
        name: string;
    }[];
    type: "dropdown";
    key: string;
    label: string;
    placeholder?: string | undefined;
    infoHTML?: string | undefined;
}, {
    options: {
        id: string;
        name: string;
    }[];
    type: "dropdown";
    key: string;
    label: string;
    placeholder?: string | undefined;
    infoHTML?: string | undefined;
}>, z.ZodObject<{
    key: z.ZodString;
    label: z.ZodString;
    type: z.ZodLiteral<"subdomain">;
    placeholder: z.ZodOptional<z.ZodString>;
    domain: z.ZodOptional<z.ZodString>;
    infoHTML: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
    type: "subdomain";
    key: string;
    label: string;
    placeholder?: string | undefined;
    domain?: string | undefined;
    infoHTML?: string | undefined;
}, {
    type: "subdomain";
    key: string;
    label: string;
    placeholder?: string | undefined;
    domain?: string | undefined;
    infoHTML?: string | undefined;
}>]>;
type AuthCustomParamInputDefinition = z.infer<typeof zAuthCustomParamInputDefinition>;
declare class OAuthScopeError extends Error {
    constructor(msg: string);
}

interface ApiTokenAuthDefinitionInput<Credential extends AnyAppCredential> {
    /**
     * If true, it's assumed there will be always one credential only at most,
     * therefore UI for selecting credential won't not rendered.
     * @default false
     */
    singleCredentialOnly?: boolean;
    /**
     * List of parameters to render inputs for when adding a new credential in UI.
     */
    customParams: AuthCustomParamInputDefinition[];
    /**
     * Receives a Credential and should return the avatar and label for this credential.
     * It's called every time a credential is rendered in UI.
     */
    getCredentialOption: GetCredentialOptionFn<Credential>;
    /**
     * Receives Credential data, as specified by `Credential` type and
     * should return `true`/`false` depending on whether the credential works.
     */
    testConnection: (apiToken: Credential["data"]) => Promise<boolean>;
}
type ApiTokenAuthDefinition<Credential extends AnyAppCredential> = ApiTokenAuthDefinitionInput<Credential> & {
    type: "apiToken";
};
/**
 * Used to define a Connector API Token Auth
 * @see [Auth](https://docs.rollout.com/documentation/building-connectors/auth)
 * @example
 * ```ts
 * import { AppCredential, defineApiTokenAuth } from "@rollout/framework";
 *
 * export type MyAppCredential = AppCredential<{
 *   apiKey: string;
 * }>;
 *
 * export const auth = defineApiTokenAuth<MyAppCredential>({
 *   customParams: [
 *     {
 *       type: "textfield",
 *       key: "apiKey",
 *       label: "API Key",
 *       placeholder: "Enter your API key",
 *       infoHTML:
 *         "You can generate a token navigating to Settings > Integrations > API.",
 *     },
 *   ],
 *
 *   async getCredentialOption({ credential }) {
 *     const { label, avatar } = await getUser(credential.data.apiKey);
 *     return { label, avatar };
 *   },
 *
 *   async testConnection(credentialData) {
 *     try {
 *       await getUser(credentialData.apiKey);
 *       return true;
 *     } catch (error) {
 *       return false;
 *     }
 *   },
 * });
 * ```
 */
declare function defineApiTokenAuth<Credential extends AnyAppCredential>(definition: ApiTokenAuthDefinitionInput<Credential>): ApiTokenAuthDefinition<Credential>;

type JWTAuthDefinitionInput<Cred extends AnyAppCredential> = {
    /**
     * If true, it's assumed there will be always one credential only at most,
     * therefore UI for selecting credential won't not rendered.
     * @default false
     */
    singleCredentialOnly?: boolean;
    /**
     * Receives a Credential and should return the avatar and label for this credential.
     * It's called every time a credential is rendered in UI.
     */
    getCredentialOption: GetCredentialOptionFn<Cred>;
    /**
     * Called on every incoming Consumer request.
     * Receives the `authData` from the consumer JWT token
     * and should return the credential to be stored.
     */
    getCredentialFromJWT: (ctx: {
        authData: unknown;
        consumer: Consumer;
    }) => Cred | Promise<Cred>;
    /**
     * Called every time Rollout is about to use a credential and can be used
     * to refresh the credential, if needed.
     * Receives the stored credential and should return a valid credential,
     * whether it's the received one, or a fresh one.
     * Can be set to `false` to never refresh.
     */
    refreshTokens: false | ((ctx: {
        credential: Cred;
    }) => Promise<Cred["data"]>);
};
type JWTAuthDefinition<Cred extends AnyAppCredential> = JWTAuthDefinitionInput<Cred> & {
    type: "JWT";
};
/**
 * Used to define a Connector JWT Token Auth
 * @see [Auth](https://docs.rollout.com/documentation/building-connectors/auth)
 * @example
 * ```ts
 * import { AppCredential, defineJWTAuth } from "@rollout/framework";
 *
 * export type MyAppCredential = AppCredential<{
 *   accessToken: string;
 *   refreshToken: string;
 *   expiresAt: string;
 * }>;
 *
 * export const auth = defineJWTAuth<MyAppCredential>({
 *   async getCredentialFromJWT({ consumer, authData }) {
 *     // validate/transform/parse authData if needed
 *    const credentialData = authData as MyAppCredential["data"];
 *     return {
 *       // we assume there is only one credential per consumer,
 *       // so we just use `consumerKey` as `credentialKey`.
 *       credentialKey: consumer.consumerKey,
 *       data: credentialData,
 *     };
 *   },
 *
 *   async refreshTokens({ credential }) {
 *     if (!needsRefresh(new Date(credential.data.expiresAt))) {
 *       // No refresh needed
 *       return credential.data;
 *     }
 *
 *     // Token needs refreshing
 *     const newTokens = await refreshMyTokens({ credential });
 *     return newTokens;
 *   },
 *
 *   async getCredentialOption({ credential }) {
 *     // Fetch user name and avatar
 *     return { label, avatar };
 *   },
 * });
 * ```
 */
declare function defineJWTAuth<Cred extends AnyAppCredential>(definition: JWTAuthDefinitionInput<Cred>): JWTAuthDefinition<Cred>;

type ProjectOAuth1DefinitionInput<Cred extends AnyAppCredential> = {
    singleCredentialOnly?: true;
    getAuthorizeUrl: GetAuthorizeURLFn;
    getTokenFromCode: (props: CommonOAuthGetTokenFromCodeFnOpts & {
        oauthToken: string;
        oauthVerifier: string;
    }) => Promise<Cred>;
    getCredentialOption: GetCredentialOptionFn<Cred>;
    refreshTokens: false | ((opts: {
        credential: Cred;
        consumerKey: string;
        redirectUri: string;
    }) => Promise<Cred["data"]>);
    customParams?: AuthCustomParamInputDefinition[];
};
type ProjectOAuth1Definition<Cred extends AnyAppCredential> = ProjectOAuth1DefinitionInput<Cred> & {
    type: "project-oauth1";
};
declare function defineProjectOAuth1<Cred extends AnyAppCredential>(): (definition: ProjectOAuth1DefinitionInput<Cred>) => ProjectOAuth1Definition<Cred>;

type ProjectOAuth2DefinitionInput<Cred extends AnyAppCredential> = {
    singleCredentialOnly?: true;
    pkce: boolean | PKCEFunction;
    getAuthorizeUrl: GetAuthorizeURLFn;
    getTokenFromCode: (opts: CommonOAuthGetTokenFromCodeFnOpts & {
        code: string;
        codeVerifier: string | undefined;
    }) => Promise<Cred>;
    refreshTokens: false | ((opts: {
        credential: Cred;
        consumerKey: string;
        redirectUri: string;
    }) => Promise<Cred["data"]>);
    getCredentialOption: GetCredentialOptionFn<Cred>;
    customParams?: AuthCustomParamInputDefinition[];
};
type ProjectOAuth2Definition<Cred extends AnyAppCredential> = ProjectOAuth2DefinitionInput<Cred> & {
    type: "project-oauth2";
};
declare function defineProjectOAuth2<Cred extends AnyAppCredential>(): (definition: ProjectOAuth2DefinitionInput<Cred>) => ProjectOAuth2Definition<Cred>;

type OmitIndexSignature<ObjectType> = {
    [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType];
};

type GetAuthorizeURLFnOpts<Env extends TObject> = {
    appKey: string;
    consumerKey: string;
    state: string;
    codeChallenge: string | undefined;
    customParams: Record<string, any> | undefined;
    env: Static<Env>;
    redirectUri: string;
};
declare const SNoWhitelabeling: unique symbol;
type NoWhitelabeling<T extends TSchema> = TOptional<T> & {
    [SNoWhitelabeling]: true;
};
type EnvStringOpts = {
    title?: string;
};
type EnvString<Opts extends EnvStringOpts = EnvStringOpts> = OmitIndexSignature<TString>;
type EnvObjectProperties = {
    [key: string]: EnvString | NoWhitelabeling<EnvString>;
};
type EnvObject<T extends EnvObjectProperties = EnvObjectProperties> = OmitIndexSignature<TObject<T>>;
type RolloutOAuth2ServiceDefinitionInput<Cred extends AnyAppCredential, Env extends EnvObject> = {
    env: Env;
    requiresWhitelabelingReturnUri?: true;
    pkce: boolean | PKCEFunction;
    getAuthorizeUrl: (opts: Omit<GetAuthorizeURLFnOpts<Env>, "consumerKey"> & {
        consumerId: string;
    }) => string | Promise<string>;
    getTokenFromCode: (opts: {
        query: Record<string, string>;
        state: string;
        requestUrl: string;
        redirectUri: string;
        customParams: Record<string, any> | undefined;
        env: Static<Env>;
        consumerId: string;
        code: string;
        codeVerifier: string | undefined;
    }) => Promise<Cred>;
    refreshTokens: false | ((opts: {
        env: Static<Env>;
        credential: Cred;
        consumerId: string;
        redirectUri: string;
    }) => Promise<Cred["data"]>);
};
type RolloutOAuth2ServiceDefinition<Cred extends AnyAppCredential, Env extends EnvObject> = RolloutOAuth2ServiceDefinitionInput<Cred, Env> & {
    type: "rollout-oauth2";
};
type RolloutOAuth2DefinitionInput<Cred extends AnyAppCredential, OAuthService extends RolloutOAuth2ServiceDefinition<Cred, any>> = {
    singleCredentialOnly?: true;
    getCredentialOption: GetCredentialOptionFn<Cred>;
    customParams?: AuthCustomParamInputDefinition[];
};
type RolloutOAuth2Definition<Cred extends AnyAppCredential, OAuthService extends RolloutOAuth2ServiceDefinition<Cred, any>> = RolloutOAuth2DefinitionInput<Cred, OAuthService> & {
    type: "rollout-oauth2";
};

type RolloutOAuth1ServiceDefinitionInput<Cred extends AnyAppCredential, Env extends EnvObject> = {
    env: Env;
    requiresWhitelabelingReturnUri?: true;
    getAuthorizeUrl: (opts: {
        appKey: string;
        state: string;
        codeChallenge: string | undefined;
        customParams: Record<string, any> | undefined;
        env: Static<Env>;
        redirectUri: string;
        consumerId: string;
    }) => string | Promise<string>;
    getTokenFromCode: (props: {
        query: Record<string, string>;
        state: string;
        requestUrl: string;
        redirectUri: string;
        customParams: Record<string, any> | undefined;
        env: Static<Env>;
        consumerId: string;
        oauthToken: string;
        oauthVerifier: string;
    }) => Promise<Cred>;
    refreshTokens: false | ((opts: {
        env: Static<Env>;
        credential: Cred;
        consumerId: string;
        redirectUri: string;
    }) => Promise<Cred["data"]>);
};
type RolloutOAuth1ServiceDefinition<Cred extends AnyAppCredential, Env extends EnvObject> = RolloutOAuth1ServiceDefinitionInput<Cred, Env> & {
    type: "rollout-oauth1";
};
type RolloutOAuth1DefinitionInput<Cred extends AnyAppCredential, OAuthService extends RolloutOAuth1ServiceDefinition<Cred, any>> = {
    singleCredentialOnly?: true;
    getCredentialOption: GetCredentialOptionFn<Cred>;
    customParams?: AuthCustomParamInputDefinition[];
};
type RolloutOAuth1Definition<Cred extends AnyAppCredential, OAuthService extends RolloutOAuth1ServiceDefinition<Cred, any>> = RolloutOAuth1DefinitionInput<Cred, OAuthService> & {
    type: "rollout-oauth1";
};

type AnyAuthDefinition<Cred extends AnyAppCredential> = ApiTokenAuthDefinition<Cred> | ProjectOAuth1Definition<Cred> | ProjectOAuth2Definition<Cred> | RolloutOAuth1Definition<Cred, RolloutOAuth1ServiceDefinition<Cred, EnvObject>> | RolloutOAuth2Definition<Cred, RolloutOAuth2ServiceDefinition<Cred, EnvObject>> | JWTAuthDefinition<Cred> | false;

declare const zAutomation: z.ZodObject<{
    id: z.ZodString;
    createdAt: z.ZodDate;
    updatedAt: z.ZodDate;
    status: z.ZodEnum<["INVALID", "READY"]>;
    active: z.ZodBoolean;
    live: z.ZodBoolean;
    name: z.ZodString;
    consumerKey: z.ZodString;
    blueprintKey: z.ZodNullable<z.ZodString>;
    trigger: z.ZodObject<{
        appKey: z.ZodString;
        triggerKey: z.ZodString;
        credentialKey: z.ZodString;
        inputParams: z.ZodRecord<z.ZodString, z.ZodAny>;
        subscription: z.ZodOptional<z.ZodObject<{
            createdAt: z.ZodString;
            refreshedAt: z.ZodOptional<z.ZodString>;
            data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
        }, "strip", z.ZodTypeAny, {
            createdAt: string;
            refreshedAt?: string | undefined;
            data?: Record<string, any> | undefined;
        }, {
            createdAt: string;
            refreshedAt?: string | undefined;
            data?: Record<string, any> | undefined;
        }>>;
    }, "strip", z.ZodTypeAny, {
        appKey: string;
        triggerKey: string;
        credentialKey: string;
        inputParams: Record<string, any>;
        subscription?: {
            createdAt: string;
            refreshedAt?: string | undefined;
            data?: Record<string, any> | undefined;
        } | undefined;
    }, {
        appKey: string;
        triggerKey: string;
        credentialKey: string;
        inputParams: Record<string, any>;
        subscription?: {
            createdAt: string;
            refreshedAt?: string | undefined;
            data?: Record<string, any> | undefined;
        } | undefined;
    }>;
    action: z.ZodObject<{
        appKey: z.ZodString;
        actionKey: z.ZodString;
        credentialKey: z.ZodString;
        inputParams: z.ZodRecord<z.ZodString, z.ZodAny>;
    }, "strip", z.ZodTypeAny, {
        appKey: string;
        credentialKey: string;
        inputParams: Record<string, any>;
        actionKey: string;
    }, {
        appKey: string;
        credentialKey: string;
        inputParams: Record<string, any>;
        actionKey: string;
    }>;
    customData: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>;
}, "strip", z.ZodTypeAny, {
    status: "INVALID" | "READY";
    createdAt: Date;
    id: string;
    name: string;
    consumerKey: string;
    updatedAt: Date;
    active: boolean;
    live: boolean;
    blueprintKey: string | null;
    trigger: {
        appKey: string;
        triggerKey: string;
        credentialKey: string;
        inputParams: Record<string, any>;
        subscription?: {
            createdAt: string;
            refreshedAt?: string | undefined;
            data?: Record<string, any> | undefined;
        } | undefined;
    };
    action: {
        appKey: string;
        credentialKey: string;
        inputParams: Record<string, any>;
        actionKey: string;
    };
    customData: Record<string, any> | null;
}, {
    status: "INVALID" | "READY";
    createdAt: Date;
    id: string;
    name: string;
    consumerKey: string;
    updatedAt: Date;
    active: boolean;
    live: boolean;
    blueprintKey: string | null;
    trigger: {
        appKey: string;
        triggerKey: string;
        credentialKey: string;
        inputParams: Record<string, any>;
        subscription?: {
            createdAt: string;
            refreshedAt?: string | undefined;
            data?: Record<string, any> | undefined;
        } | undefined;
    };
    action: {
        appKey: string;
        credentialKey: string;
        inputParams: Record<string, any>;
        actionKey: string;
    };
    customData: Record<string, any> | null;
}>;
interface Automation extends z.infer<typeof zAutomation> {
}

declare const zAutomationOutput: z.ZodObject<{
    status: z.ZodEnum<["INVALID", "READY"]>;
    createdAt: z.ZodDate;
    id: z.ZodString;
    name: z.ZodString;
    consumerKey: z.ZodString;
    updatedAt: z.ZodDate;
    active: z.ZodBoolean;
    live: z.ZodBoolean;
    blueprintKey: z.ZodNullable<z.ZodString>;
    action: z.ZodObject<{
        appKey: z.ZodString;
        actionKey: z.ZodString;
        credentialKey: z.ZodString;
        inputParams: z.ZodRecord<z.ZodString, z.ZodAny>;
    }, "strip", z.ZodTypeAny, {
        appKey: string;
        credentialKey: string;
        inputParams: Record<string, any>;
        actionKey: string;
    }, {
        appKey: string;
        credentialKey: string;
        inputParams: Record<string, any>;
        actionKey: string;
    }>;
    customData: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>;
    trigger: z.ZodObject<Omit<{
        appKey: z.ZodString;
        triggerKey: z.ZodString;
        credentialKey: z.ZodString;
        inputParams: z.ZodRecord<z.ZodString, z.ZodAny>;
        subscription: z.ZodOptional<z.ZodObject<{
            createdAt: z.ZodString;
            refreshedAt: z.ZodOptional<z.ZodString>;
            data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
        }, "strip", z.ZodTypeAny, {
            createdAt: string;
            refreshedAt?: string | undefined;
            data?: Record<string, any> | undefined;
        }, {
            createdAt: string;
            refreshedAt?: string | undefined;
            data?: Record<string, any> | undefined;
        }>>;
    }, "subscription">, "strip", z.ZodTypeAny, {
        appKey: string;
        triggerKey: string;
        credentialKey: string;
        inputParams: Record<string, any>;
    }, {
        appKey: string;
        triggerKey: string;
        credentialKey: string;
        inputParams: Record<string, any>;
    }>;
}, "strip", z.ZodTypeAny, {
    status: "INVALID" | "READY";
    createdAt: Date;
    id: string;
    name: string;
    consumerKey: string;
    updatedAt: Date;
    active: boolean;
    live: boolean;
    blueprintKey: string | null;
    trigger: {
        appKey: string;
        triggerKey: string;
        credentialKey: string;
        inputParams: Record<string, any>;
    };
    action: {
        appKey: string;
        credentialKey: string;
        inputParams: Record<string, any>;
        actionKey: string;
    };
    customData: Record<string, any> | null;
}, {
    status: "INVALID" | "READY";
    createdAt: Date;
    id: string;
    name: string;
    consumerKey: string;
    updatedAt: Date;
    active: boolean;
    live: boolean;
    blueprintKey: string | null;
    trigger: {
        appKey: string;
        triggerKey: string;
        credentialKey: string;
        inputParams: Record<string, any>;
    };
    action: {
        appKey: string;
        credentialKey: string;
        inputParams: Record<string, any>;
        actionKey: string;
    };
    customData: Record<string, any> | null;
}>;
type AutomationOutput = z.infer<typeof zAutomationOutput>;

declare const zAutomationRunExecution: z.ZodObject<{
    startedAt: z.ZodUnion<[z.ZodDate, z.ZodEffects<z.ZodString, Date, string>]>;
    endedAt: z.ZodUnion<[z.ZodDate, z.ZodEffects<z.ZodString, Date, string>]>;
    output: z.ZodDiscriminatedUnion<"status", [z.ZodObject<{
        status: z.ZodLiteral<"USER_ERROR">;
        error: z.ZodAny;
    }, "strip", z.ZodTypeAny, {
        status: "USER_ERROR";
        error?: any;
    }, {
        status: "USER_ERROR";
        error?: any;
    }>, z.ZodObject<{
        status: z.ZodLiteral<"SERVER_ERROR">;
        error: z.ZodAny;
    }, "strip", z.ZodTypeAny, {
        status: "SERVER_ERROR";
        error?: any;
    }, {
        status: "SERVER_ERROR";
        error?: any;
    }>, z.ZodObject<{
        status: z.ZodLiteral<"SUCCESS">;
        data: z.ZodAny;
    }, "strip", z.ZodTypeAny, {
        status: "SUCCESS";
        data?: any;
    }, {
        status: "SUCCESS";
        data?: any;
    }>]>;
}, "strip", z.ZodTypeAny, {
    startedAt: Date;
    endedAt: Date;
    output: {
        status: "USER_ERROR";
        error?: any;
    } | {
        status: "SERVER_ERROR";
        error?: any;
    } | {
        status: "SUCCESS";
        data?: any;
    };
}, {
    startedAt: (string | Date) & (string | Date | undefined);
    endedAt: (string | Date) & (string | Date | undefined);
    output: {
        status: "USER_ERROR";
        error?: any;
    } | {
        status: "SERVER_ERROR";
        error?: any;
    } | {
        status: "SUCCESS";
        data?: any;
    };
}>;
interface AutomationRunExecution extends z.infer<typeof zAutomationRunExecution> {
}

declare const types$1: {
    array: <T extends TSchema>(schema: T, options?: _sinclair_typebox.ArrayOptions | undefined) => _sinclair_typebox.TArray<T>;
    boolean: (options?: _sinclair_typebox.SchemaOptions | undefined) => _sinclair_typebox.TBoolean;
    nullable: <T_1 extends TSchema>(schema: T_1) => _sinclair_typebox.TUnion<[T_1, _sinclair_typebox.TNull]>;
    number: (options?: _sinclair_typebox.NumericOptions<number> | undefined) => _sinclair_typebox.TNumber;
    object: <T_2 extends TProperties>(properties: T_2, options?: _sinclair_typebox.ObjectOptions | undefined) => TObject<T_2>;
    string: (options?: _sinclair_typebox.StringOptions | undefined) => _sinclair_typebox.TString;
};
type Types = typeof types$1;
type AnyPayloadType = ReturnType<Types[keyof Types]>;
type AnyTriggerPayloadSchemaShape = TObject<Record<string, AnyPayloadType>>;
type InferTriggerPayloadSchema<T extends TObject> = Static<T>;
type TriggerPayloadSchemaFn<Cred extends AnyAppCredential, InputParamsSchema extends TObject> = (opts: {
    credential: Cred;
    inputParams: Partial<Static<InputParamsSchema>>;
    consumer: Consumer;
}) => Promise<AnyTriggerPayloadSchemaShape>;
type AnyTriggerPayloadSchemaFn = TriggerPayloadSchemaFn<AnyAppCredential, TObject>;
declare function defineTriggerPayloadSchema<Params extends TProperties>(definer: (t: typeof types$1) => Params): TObject<Params>;

type PollingTriggerPollFn<Cred extends AnyAppCredential, State extends any, InputParamsSchema extends TObject, PayloadSchema extends AnyTriggerPayloadSchemaShape | TriggerPayloadSchemaFn<Cred, InputParamsSchema>> = (props: {
    credential: Cred;
    prevState: State | null;
    inputParams: Static<InputParamsSchema>;
}) => Promise<{
    newState: State;
    events: InferTriggerPayloadSchema<PayloadSchema extends (...args: any) => any ? Awaited<ReturnType<PayloadSchema>> : PayloadSchema>[];
}>;
/**
 * Describes a Polling Trigger.
 */
type PollingTriggerDefinitionInput<Name extends string, Cred extends AnyAppCredential, State extends any, InputParamsSchema extends TObject, PayloadSchema extends AnyTriggerPayloadSchemaShape | TriggerPayloadSchemaFn<Cred, InputParamsSchema>> = {
    /**
     * Name of the Trigger that will be displayed in UI.
     **/
    name: Name;
    /**
     * Type schema for the input params.
     * Use the {@link defineTriggerInputParamsSchema} function to describe the types.
     */
    inputParamsSchema: InputParamsSchema;
    /**
     * Type schema for the payload.
     * Use the {@link defineTriggerPayloadSchema} function to describe the types.
     */
    payloadSchema: PayloadSchema;
    /**
     * The polling function will be called at regular intervals (CRON expression configurable per project environment).
     * It receives state returned from last invocation and should return the new state
     * and list of new events since the last invocation, sorted from oldest to newest.
     * State will be serialized with [`superjson`](https://www.npmjs.com/package/superjson) and stored in database.
     */
    poll: PollingTriggerPollFn<Cred, State, InputParamsSchema, PayloadSchema>;
};
type PollingTriggerDefinition<Name extends string = string, Cred extends AnyAppCredential = AnyAppCredential, State extends any = any, InputParamsSchema extends TObject = TObject, PayloadSchema extends AnyTriggerPayloadSchemaShape | TriggerPayloadSchemaFn<Cred, InputParamsSchema> = AnyTriggerPayloadSchemaShape | TriggerPayloadSchemaFn<Cred, InputParamsSchema>> = PollingTriggerDefinitionInput<Name, Cred, State, InputParamsSchema, PayloadSchema> & {
    type: "POLLING";
};
type AnyPollingTriggerDefinition = PollingTriggerDefinition<string, AnyAppCredential, any, TObject, AnyTriggerPayloadSchemaShape | AnyTriggerPayloadSchemaFn>;
/**
 * Used to define a Connector Polling Trigger.
 * @see [Triggers](https://docs.rollout.com/documentation/building-connectors/triggers)
 * @example
 * ```ts
 * import { definePollingTrigger } from "@rollout/framework";
 * import { MyAppCredential } from "./auth";
 * import { inputParamsSchema } from "./input";
 * import { payloadSchema } from "./payload";
 *
 * // State represents the value we want to store in between pollings.
 * // Here, we will be storing Set of string IDs.
 * type State = Set<string>;
 *
 * export const trigger = definePollingTrigger<MyAppCredential, State>()({
 *   name: "My Polling Trigger",
 *   inputParamsSchema,
 *   payloadSchema,
 *   async poll({ credential, prevState }) {
 *     const allItems = await getAllItems({ credential, order: "createdAt-asc" });
 *     const newState = new Set(allItems.map((c) => c.id));
 *     const newItemIds = diffIdSet(newState, prevState);
 *     const events = allItems.filter((c) => newItemIds.has(c.id))
 *
 *     return { newState, events };
 *   },
 * });
 * ```
 */
declare function definePollingTrigger<Cred extends AnyAppCredential, State extends any>(): <Name extends string, InputParamsSchema extends TObject<_sinclair_typebox.TProperties>, PayloadSchema extends AnyTriggerPayloadSchemaShape | TriggerPayloadSchemaFn<Cred, InputParamsSchema>>(definitionInput: PollingTriggerDefinitionInput<Name, Cred, State, InputParamsSchema, PayloadSchema>) => PollingTriggerDefinition<Name, Cred, State, InputParamsSchema, PayloadSchema>;

type WebhookTriggerSubscribeFunction<CredentialType extends AnyAppCredential, InputParamsSchema extends TObject, SubscriptionData extends {}> = (props: {
    consumer: Consumer;
    inputParams: Static<InputParamsSchema>;
    automation: Automation;
    credential: CredentialType;
}) => Promise<SubscriptionData>;
type WebhookTriggerRefreshFunction<CredentialType extends AnyAppCredential, InputParamsSchema extends TObject, SubscriptionData extends {}> = (props: {
    consumer: Consumer;
    inputParams: Static<InputParamsSchema>;
    automation: Automation;
    credential: CredentialType;
    subscription: {
        createdAt: string;
        data: SubscriptionData;
    };
}) => Promise<SubscriptionData>;
type WebhookTriggerUnsubscribeFn<CredentialType extends AnyAppCredential, InputParamsSchema extends TObject, SubscriptionData extends {}> = (props: {
    credential: CredentialType;
    subscription: {
        createdAt: string;
        data: SubscriptionData;
    };
    inputParams: Static<InputParamsSchema>;
}) => Promise<void>;
type WebhookTriggerHandleEventFn<Cred extends AnyAppCredential, InputParamsSchema extends TObject, PayloadSchema extends AnyTriggerPayloadSchemaShape | TriggerPayloadSchemaFn<Cred, InputParamsSchema>, RequestPayload extends any> = (opts: {
    requestPayload: RequestPayload;
}) => Promise<{
    automationId: string;
    event: {
        payload: InferTriggerPayloadSchema<PayloadSchema extends (...args: any) => any ? Awaited<ReturnType<PayloadSchema>> : PayloadSchema>;
    };
}[]>;
type AnyWebhookTriggerHandleEventFn = WebhookTriggerHandleEventFn<AnyAppCredential, TObject, AnyTriggerPayloadSchemaShape, any>;
type WebhookTriggerDefinitionInput<Name extends string, Cred extends AnyAppCredential, InputParamsSchema extends TObject, PayloadSchema extends AnyTriggerPayloadSchemaShape | TriggerPayloadSchemaFn<Cred, InputParamsSchema>, RequestPayload extends any, SubscriptionData extends {}> = {
    /**
     * Name of the Trigger that will be displayed in UI.
     **/
    name: Name;
    /**
     * Type schema for the input params.
     * Use the {@link defineTriggerInputParamsSchema} function to describe the types.
     */
    inputParamsSchema: InputParamsSchema;
    /**
     * Type schema for the payload.
     * Use the {@link defineTriggerPayloadSchema} function to describe the types.
     */
    payloadSchema: PayloadSchema;
    /**
     * Will be called to create a new subscription.
     * Receives the related context and should return the _subscription_ to be stored.
     */
    subscribe: WebhookTriggerSubscribeFunction<Cred, InputParamsSchema, SubscriptionData>;
    /**
     * Some webhook implementations require periodical refreshing to keep them alive.
     * This can be used to set up the interval and the callback to execute to refresh subscriptions.
     */
    refresh?: {
        interval: number;
        refresh: WebhookTriggerRefreshFunction<Cred, InputParamsSchema, SubscriptionData>;
    };
    /**
     * Will be called when subscription is no longer needed.
     * Receives the _subscription_ returned from `subscribe`
     * and should perform neccessary calls to destroy the subscription.
     */
    unsubscribe: WebhookTriggerUnsubscribeFn<Cred, InputParamsSchema, SubscriptionData>;
    /**
     * This will be called via {@link `handleWebhookRequestJob`} when a new webhook request is incoming
     * and should return the new events related to the webhook request.
     * @see {handleWebhookRequestJob}
     */
    handleEvent: WebhookTriggerHandleEventFn<Cred, InputParamsSchema, PayloadSchema, RequestPayload>;
};
type WebhookTriggerDefinition<Name extends string = string, Credential extends AnyAppCredential = AnyAppCredential, InputParamsSchema extends TObject = TObject, PayloadSchema extends AnyTriggerPayloadSchemaShape | TriggerPayloadSchemaFn<Credential, InputParamsSchema> = AnyTriggerPayloadSchemaShape | TriggerPayloadSchemaFn<Credential, InputParamsSchema>, RequestPayload extends any = any, SubscriptionData extends {} = {}> = WebhookTriggerDefinitionInput<Name, Credential, InputParamsSchema, PayloadSchema, RequestPayload, SubscriptionData> & {
    type: "WEBHOOK";
};
type AnyWebhookTriggerDefinition = WebhookTriggerDefinition<string, AnyAppCredential, any, AnyTriggerPayloadSchemaShape | AnyTriggerPayloadSchemaFn, any, any>;
/**
 * Used to define a Connector Webhook Trigger.
 * @see [Triggers](https://docs.rollout.com/documentation/building-connectors/triggers)
 * @see {@link handleWebhookRequestJob}
 * @example
 * ```ts
 * import {
 *   defineTriggerPayloadSchema,
 *   defineWebhookTrigger,
 *   z,
 * } from "@rollout/framework";
 * import { MyAppCredential } from "./auth";
 * import { inputParamsSchema } from "./input";
 * import { payloadSchema } from "./payload";
 *
 * type RequestPayload = {
 *   webhookId: string;
 *   body: unknown;
 * };
 *
 * export const trigger = defineWebhookTrigger<MyAppCredential, RequestPayload>()({
 *   name: "My Webhook Trigger",
 *   inputParamsSchema,
 *   payloadSchema,
 *
 *   async subscribe({ credential, inputParams }) {
 *     // subscribe and return the `subscription`
 *   },
 *
 *   async unsubscribe({ credential, subscription }) {
 *     // `subscription.data` is whatever was returned from `subscribe()` above
 *     // unsubscribe from the webhook
 *   },
 *
 *   async handleEvent({ requestPayload }) {
 *     // `handleEvent` is called from Connector's `http` handler
 *     // via the `handleWebhookRequestJob()` function.
 *     return {};
 *   },
 * });
 * ```
 */
declare function defineWebhookTrigger<Credential extends AnyAppCredential, RequestPayload extends any>(): <Name extends string, InputParamsSchema extends TObject<_sinclair_typebox.TProperties>, PayloadSchema extends AnyTriggerPayloadSchemaShape | TriggerPayloadSchemaFn<Credential, InputParamsSchema>, SubscriptionData extends {}>(definitionInput: WebhookTriggerDefinitionInput<Name, Credential, InputParamsSchema, PayloadSchema, RequestPayload, SubscriptionData>) => WebhookTriggerDefinition<Name, Credential, InputParamsSchema, PayloadSchema, RequestPayload, SubscriptionData>;

/**
 * WHATWG Fetch compatible HTTP Request handler.
 * Takes a [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request)
 * and returns a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) instance.
 */
type RequestHandler = (request: Request) => Response | Promise<Response>;
type DefineHTTPHandler = (handler: RequestHandler) => RequestHandler;
/**
 * Used to define a Connector HTTP handler.
 * Accepts a handler fuction which takes a single [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request)
 * parameter and should return a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) instance.
 * @see [Handling HTTP Requests](https://docs.rollout.com/documentation/building-connectors/handling-http-requests)
 * @example
 * ```ts
 * import { defineHTTPHandler } from "@rollout/framework";
 *
 * export const http = defineHTTPHandler((request) => {
 *   return Response.json(`Hello from ${request.url}!`);
 * });
 * ```
 */
declare const defineHTTPHandler: DefineHTTPHandler;

type TaskTriggerExecuteFunction<InputParamsSchema extends TObject, PayloadSchema extends AnyTriggerPayloadSchemaShape, AC extends AnyAppCredential> = (opts: {
    consumer: Consumer;
    credential: AC;
    inputParams: Static<InputParamsSchema>;
}) => Promise<{
    payload: InferTriggerPayloadSchema<PayloadSchema>;
}>;
type TaskTriggerDefinition<Name extends string = string, CredentialType extends AnyAppCredential = AnyAppCredential, InputParamsSchema extends TObject = TObject, PayloadSchema extends AnyTriggerPayloadSchemaShape = AnyTriggerPayloadSchemaShape> = {
    name: Name;
    inputParamsSchema: InputParamsSchema;
    payloadSchema: PayloadSchema;
    start: TaskTriggerExecuteFunction<InputParamsSchema, PayloadSchema, CredentialType>;
};
type AnyTaskTriggerDefinition = TaskTriggerDefinition<string, AnyAppCredential, TObject, AnyTriggerPayloadSchemaShape>;
declare function defineTaskTrigger<CredentialType extends AnyAppCredential>(): <Name extends string, InputParamsSchema extends TObject<_sinclair_typebox.TProperties>, PayloadSchema extends AnyTriggerPayloadSchemaShape>(definition: {
    name: Name;
    inputParamsSchema: InputParamsSchema;
    payloadSchema: PayloadSchema;
    start: TaskTriggerExecuteFunction<InputParamsSchema, PayloadSchema, CredentialType>;
}) => {
    name: Name;
    inputParamsSchema: InputParamsSchema;
    payloadSchema: PayloadSchema;
    start: TaskTriggerExecuteFunction<InputParamsSchema, PayloadSchema, CredentialType>;
};

type PushTriggerDefinitionInput<Name extends string, Creds extends AnyAppCredential | AnyAppCredential, InputParamsSchema extends TObject, PayloadSchema extends AnyTriggerPayloadSchemaShape | TriggerPayloadSchemaFn<Creds, InputParamsSchema>> = {
    name: Name;
    inputParamsSchema: InputParamsSchema;
    payloadSchema: PayloadSchema;
};
type PushTriggerDefinition<Name extends string = string, Creds extends AnyAppCredential = AnyAppCredential, InputParamsSchema extends TObject = TObject, PayloadSchema extends AnyTriggerPayloadSchemaShape | TriggerPayloadSchemaFn<Creds, InputParamsSchema> = AnyTriggerPayloadSchemaShape | TriggerPayloadSchemaFn<Creds, InputParamsSchema>> = PushTriggerDefinitionInput<Name, Creds, InputParamsSchema, PayloadSchema> & {
    type: "PUSH";
};
type AnyPushTriggerDefinition = PushTriggerDefinition<string, AnyAppCredential | AnyAppCredential, TObject, AnyTriggerPayloadSchemaShape | AnyTriggerPayloadSchemaFn>;
/**
 * Used to define a Connector Push Trigger.
 * Push triggers can be triggered either via POSTing to the `/trigger-push-event` endpoint,
 * or by calling the {@link handlePushTriggerEvent} function.
 * @see [Triggers](https://docs.rollout.com/documentation/building-connectors/triggers)
 * @example
 * ```ts
 * import { definePushTrigger } from "@rollout/framework";
 * import { MyAppCredential } from "./auth";
 * import { inputParamsSchema } from "./input";
 * import { payloadSchema } from "./payload";
 *
 * export const trigger = definePushTrigger<MyAppCredential>()({
 *   name: "My Push Trigger",
 *   inputParamsSchema,
 *   payloadSchema,
 * });
 * ```
 */
declare function definePushTrigger<Creds extends AnyAppCredential | AnyAppCredential>(): <Name extends string, InputParamsSchema extends TObject<_sinclair_typebox.TProperties>, PayloadSchema extends AnyTriggerPayloadSchemaShape | TriggerPayloadSchemaFn<Creds, InputParamsSchema>>(definitionInput: PushTriggerDefinitionInput<Name, Creds, InputParamsSchema, PayloadSchema>) => PushTriggerDefinition<Name, Creds, InputParamsSchema, PayloadSchema>;

type AnyTriggerDefinition = AnyPollingTriggerDefinition | AnyPushTriggerDefinition | AnyWebhookTriggerDefinition;

/**
 * Describes a Connector.
 */
interface AppDefinition<Name extends string = string, Credential extends AnyAppCredential = AnyAppCredential, Actions extends Record<string, ActionDefinition<string, any, Credential>> | undefined = Record<string, ActionDefinition<string, any, Credential>> | undefined, Triggers extends Record<string, PollingTriggerDefinition<string, Credential, any, any, any> | PushTriggerDefinition<string, Credential, any, any> | WebhookTriggerDefinition<string, Credential, any, any, any, any>> | undefined = Record<string, PollingTriggerDefinition<string, Credential, any, any, any> | PushTriggerDefinition<string, Credential, any, any> | WebhookTriggerDefinition<string, Credential, any, any, any, any>> | undefined, TaskTriggers extends Record<string, TaskTriggerDefinition<string, Credential, any, any>> | undefined = Record<string, TaskTriggerDefinition<string, Credential, any, any>> | undefined> {
    /**
     * Name of the App that will be displayed in UI
     */
    name: Name;
    /**
     * Authorization definition for this Connector, or `false` if no auth is required.
     * @see [Auth](https://docs.rollout.com/documentation/building-connectors/auth)
     */
    auth: AnyAuthDefinition<Credential>;
    /**
     * HTTP handler for this Connector.
     * @see [Handling HTTP Requests](https://docs.rollout.com/documentation/building-connectors/handling-http-requests)
     */
    http?: RequestHandler;
    /**
     * @internal
     * @deprecated
     */
    router?: any;
    /**
     * An object containing Actions for this Connector,
     * where keys correspond to `actionKey`
     * and values are action definitions returned from {@link defineAction} function.
     * @see [Actions](https://docs.rollout.com/documentation/building-connectors/actions)
     */
    actions?: Actions;
    /**
     * An object containing Triggers for this Connector,
     * where keys correspond to `triggerKey`
     * and values are trigger definitions returned from {@link defineWebhookTrigger},
     * {@link definePollingTrigger}, or {@link definePushTrigger} function.
     * @see [Triggers](https://docs.rollout.com/documentation/building-connectors/triggers)
     */
    triggers?: Triggers;
    /**
     * @internal
     * @deprecated
     */
    taskTriggers?: TaskTriggers;
}
interface AnyAppDefinition extends AppDefinition<string, AnyAppCredential, Record<string, AnyActionDefinition> | undefined, Record<string, AnyTriggerDefinition> | undefined, Record<string, AnyTaskTriggerDefinition> | undefined> {
}
/**
 * Used to define a Connector.
 * @see [Defining Connectors](https://docs.rollout.com/documentation/rollout-project#defining-connectors)
 * @example
 * ```ts
 * import { defineApp } from "@rollout/framework";
 * import { auth } from "./auth";
 * import { http } from "./http";
 * import { triggers } from "./triggers";
 * import { actions } from "./actions";
 *
 * export const app = defineApp({
 *   name: "My App",
 *   auth,
 *   http,
 *   triggers,
 *   actions,
 * });
 * ```
 */
declare function defineApp<Definition extends AppDefinition>(definition: Definition): Definition;

type HandlePushTriggerEventOpts = {
    automationId: string;
    payload: Record<string, any>;
};
type HandlePushTriggerEvent = (opts: HandlePushTriggerEventOpts) => Promise<void>;
declare const handlePushTriggerEvent: HandlePushTriggerEvent;

type GetAutomationWhere = {
    id: string;
};
type GetAutomationOpts = {
    where: GetAutomationWhere;
};
type GetAutomation = (opts: GetAutomationOpts) => Promise<Automation>;
declare const getAutomation: GetAutomation;

type GetAutomationsWhere = {
    name?: string;
    active?: boolean;
    status?: Automation["status"];
    blueprintKey?: string;
    consumerKey?: string;
    trigger?: {
        appKey?: string;
        triggerKey?: string;
        credentialKey?: string;
    };
    action?: {
        appKey?: string;
        actionKey?: string;
        credentialKey?: string;
    };
};
type GetAutomationsOpts = {
    where?: GetAutomationsWhere;
};
type GetAutomations = (opts?: GetAutomationsOpts) => Promise<Automation[]>;
declare const getAutomations: GetAutomations;

type GetLiveAutomationsWhere = Omit<GetAutomationsWhere, "active" | "status">;
type GetLiveAutomationsOpts = {
    where?: GetLiveAutomationsWhere;
};
type GetLiveAutomations = (opts?: GetLiveAutomationsOpts) => Promise<Automation[]>;
declare const getLiveAutomations: GetLiveAutomations;

type GetCredentialOpts = {
    where: {
        appKey: string;
        credentialKey: string;
        consumerKey: string;
    };
};
type GetCredential = (opts: GetCredentialOpts) => Promise<AppCredential<any>>;
declare const getCredential: GetCredential;

type HandleConsumerRequestOpts = {
    token: string;
};
type HandleConsumerRequest = (opts: HandleConsumerRequestOpts) => Promise<{
    ok: false;
    error: string;
} | {
    ok: true;
    consumer: Consumer;
    tokenData: ConsumerTokenData;
}>;
/**
 * Parses and validates consumer JWT token.
 * @returns If token is invalid, unsuccessful validation result is returned.
 * Otherwise, successful validation result is returned,
 * which contains the Consumer for which the token was signed for (the sub claim)
 * and also the parsed token data.
 *
 * @example
 * ```ts
 * import { defineHTTPHandler, handleConsumerRequest } from "@rollout/framework";
 *
 * export const http = defineHTTPHandler((request) => {
 *   const requestValidation = await handleConsumerRequest({
 *     token: request.headers.get("authorization")?.replace("Bearer ", "") ?? "",
 *   });
 *
 *   if (!requestValidation.ok) {
 *     return Response.json(requestValidation.error, { status: 401 });
 *   }
 *
 *   const consumerKey = requestValidation.consumer.consumerKey;
 *   const tokenData = requestValidation.tokenData;
 * });
 * ```
 */
declare const handleConsumerRequest: HandleConsumerRequest;

type HandleWebhookRequestJobOpts<RequestPayload extends any> = {
    triggerDef: WebhookTriggerDefinition<string, AppCredential<any>, any, any, RequestPayload, any>;
    requestPayload: RequestPayload;
};
type HandleWebhookRequestJob = <RequestPayload extends any>(opts: HandleWebhookRequestJobOpts<RequestPayload>) => Promise<void>;
/**
 * Used to call Webhook Trigger event handler.
 * @see [Handling HTTP Requests](https://docs.rollout.com/documentation/building-connectors/handling-http-requests)
 * @see {@link defineWebhookTrigger}
 * @example
 * ```ts
 * import {
 *   defineHTTPHandler,
 *   handleWebhookRequestJob,
 * } from "@rollout/framework";
 * import { Hono } from "hono";
 * import { trigger } from "./triggers/my-webhook-trigger";
 *
 * export const router = new Hono().post("/webhooks/:webhookId", async (c) => {
 *   const body = await c.req.json();
 *   const webhookId = c.req.param("webhookId");
 *
 *   handleWebhookRequestJob({
 *     triggerDef: trigger,
 *     requestPayload: {
 *       webhookId,
 *       body,
 *     },
 *   });
 * });
 *
 * export const http = defineHTTPHandler(router.fetch);
 * ```
 */
declare const handleWebhookRequestJob: HandleWebhookRequestJob;

declare const zOnAutomationRunResultsCtx: z.ZodObject<{
    /** See {@link Automation} */
    automation: z.ZodObject<{
        id: z.ZodString;
        createdAt: z.ZodDate;
        updatedAt: z.ZodDate;
        status: z.ZodEnum<["INVALID", "READY"]>;
        active: z.ZodBoolean;
        live: z.ZodBoolean;
        name: z.ZodString; /** See {@link TriggerEvent} */
        consumerKey: z.ZodString;
        blueprintKey: z.ZodNullable<z.ZodString>; /** See {@link AutomationRunExecution} */
        trigger: z.ZodObject<{
            appKey: z.ZodString;
            triggerKey: z.ZodString;
            credentialKey: z.ZodString;
            inputParams: z.ZodRecord<z.ZodString, z.ZodAny>;
            subscription: z.ZodOptional<z.ZodObject<{
                createdAt: z.ZodString;
                refreshedAt: z.ZodOptional<z.ZodString>;
                data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
            }, "strip", z.ZodTypeAny, {
                createdAt: string;
                refreshedAt?: string | undefined;
                data?: Record<string, any> | undefined;
            }, {
                createdAt: string;
                refreshedAt?: string | undefined;
                data?: Record<string, any> | undefined;
            }>>;
        }, "strip", z.ZodTypeAny, {
            appKey: string;
            triggerKey: string;
            credentialKey: string;
            inputParams: Record<string, any>;
            subscription?: {
                createdAt: string;
                refreshedAt?: string | undefined;
                data?: Record<string, any> | undefined;
            } | undefined;
        }, {
            appKey: string;
            triggerKey: string;
            credentialKey: string;
            inputParams: Record<string, any>;
            subscription?: {
                createdAt: string;
                refreshedAt?: string | undefined;
                data?: Record<string, any> | undefined;
            } | undefined;
        }>;
        action: z.ZodObject<{
            appKey: z.ZodString;
            actionKey: z.ZodString;
            credentialKey: z.ZodString;
            inputParams: z.ZodRecord<z.ZodString, z.ZodAny>;
        }, "strip", z.ZodTypeAny, {
            appKey: string;
            credentialKey: string;
            inputParams: Record<string, any>;
            actionKey: string;
        }, {
            appKey: string;
            credentialKey: string;
            inputParams: Record<string, any>;
            actionKey: string;
        }>;
        customData: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>;
    }, "strip", z.ZodTypeAny, {
        status: "INVALID" | "READY";
        createdAt: Date;
        id: string;
        name: string;
        consumerKey: string;
        updatedAt: Date;
        active: boolean;
        live: boolean;
        blueprintKey: string | null;
        trigger: {
            appKey: string;
            triggerKey: string;
            credentialKey: string;
            inputParams: Record<string, any>;
            subscription?: {
                createdAt: string;
                refreshedAt?: string | undefined;
                data?: Record<string, any> | undefined;
            } | undefined;
        };
        action: {
            appKey: string;
            credentialKey: string;
            inputParams: Record<string, any>;
            actionKey: string;
        };
        customData: Record<string, any> | null;
    }, {
        status: "INVALID" | "READY";
        createdAt: Date;
        id: string;
        name: string;
        consumerKey: string;
        updatedAt: Date;
        active: boolean;
        live: boolean;
        blueprintKey: string | null;
        trigger: {
            appKey: string;
            triggerKey: string;
            credentialKey: string;
            inputParams: Record<string, any>;
            subscription?: {
                createdAt: string;
                refreshedAt?: string | undefined;
                data?: Record<string, any> | undefined;
            } | undefined;
        };
        action: {
            appKey: string;
            credentialKey: string;
            inputParams: Record<string, any>;
            actionKey: string;
        };
        customData: Record<string, any> | null;
    }>;
    /** See {@link TriggerEvent} */
    triggerEvent: z.ZodObject<{
        id: z.ZodString;
        createdAt: z.ZodDate;
        updatedAt: z.ZodDate;
        consumerKey: z.ZodString;
        status: z.ZodEnum<["HANDLED", "ERROR"]>;
        source: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
            type: z.ZodLiteral<"PUSH_TRIGGER">;
        }, "strip", z.ZodTypeAny, {
            type: "PUSH_TRIGGER";
        }, {
            type: "PUSH_TRIGGER";
        }>, z.ZodObject<{
            type: z.ZodLiteral<"WEBHOOK">; /** See {@link TriggerEvent} */
            automationId: z.ZodString;
        }, "strip", z.ZodTypeAny, {
            type: "WEBHOOK";
            automationId: string;
        }, {
            type: "WEBHOOK";
            automationId: string;
        }>, z.ZodObject<{
            /** See {@link AutomationRunExecution} */
            type: z.ZodLiteral<"POLLING">;
            automationId: z.ZodString;
        }, "strip", z.ZodTypeAny, {
            type: "POLLING";
            automationId: string;
        }, {
            type: "POLLING";
            automationId: string;
        }>]>;
        trigger: z.ZodObject<{
            appKey: z.ZodString;
            triggerKey: z.ZodString;
        }, "strip", z.ZodTypeAny, {
            appKey: string;
            triggerKey: string;
        }, {
            appKey: string;
            triggerKey: string;
        }>;
        payload: z.ZodAny;
    }, "strip", z.ZodTypeAny, {
        status: "HANDLED" | "ERROR";
        createdAt: Date;
        id: string;
        consumerKey: string;
        updatedAt: Date;
        trigger: {
            appKey: string;
            triggerKey: string;
        };
        source: {
            type: "PUSH_TRIGGER";
        } | {
            type: "WEBHOOK";
            automationId: string;
        } | {
            type: "POLLING";
            automationId: string;
        };
        payload?: any;
    }, {
        status: "HANDLED" | "ERROR";
        createdAt: Date;
        id: string;
        consumerKey: string;
        updatedAt: Date;
        trigger: {
            appKey: string;
            triggerKey: string;
        };
        source: {
            type: "PUSH_TRIGGER";
        } | {
            type: "WEBHOOK";
            automationId: string;
        } | {
            type: "POLLING";
            automationId: string;
        };
        payload?: any;
    }>;
    /** See {@link AutomationRunExecution} */
    execution: z.ZodObject<{
        startedAt: z.ZodUnion<[z.ZodDate, z.ZodEffects<z.ZodString, Date, string>]>;
        endedAt: z.ZodUnion<[z.ZodDate, z.ZodEffects<z.ZodString, Date, string>]>;
        output: z.ZodDiscriminatedUnion<"status", [z.ZodObject<{
            status: z.ZodLiteral<"USER_ERROR">;
            error: z.ZodAny;
        }, "strip", z.ZodTypeAny, {
            status: "USER_ERROR";
            error?: any;
        }, {
            status: "USER_ERROR";
            error?: any;
        }>, z.ZodObject<{
            status: z.ZodLiteral<"SERVER_ERROR">;
            error: z.ZodAny;
        }, "strip", z.ZodTypeAny, {
            status: "SERVER_ERROR";
            error?: any;
        }, {
            status: "SERVER_ERROR";
            error?: any;
        }>, z.ZodObject<{
            status: z.ZodLiteral<"SUCCESS">;
            data: z.ZodAny;
        }, "strip", z.ZodTypeAny, {
            status: "SUCCESS";
            data?: any;
        }, {
            status: "SUCCESS";
            data?: any;
        }>]>;
    }, "strip", z.ZodTypeAny, {
        startedAt: Date;
        endedAt: Date;
        output: {
            status: "USER_ERROR";
            error?: any;
        } | {
            status: "SERVER_ERROR";
            error?: any;
        } | {
            status: "SUCCESS";
            data?: any;
        };
    }, {
        startedAt: (string | Date) & (string | Date | undefined);
        endedAt: (string | Date) & (string | Date | undefined);
        output: {
            status: "USER_ERROR";
            error?: any;
        } | {
            status: "SERVER_ERROR";
            error?: any;
        } | {
            status: "SUCCESS";
            data?: any;
        };
    }>;
}, "strip", z.ZodTypeAny, {
    automation: {
        status: "INVALID" | "READY";
        createdAt: Date;
        id: string;
        name: string;
        consumerKey: string;
        updatedAt: Date;
        active: boolean;
        live: boolean;
        blueprintKey: string | null;
        trigger: {
            appKey: string;
            triggerKey: string;
            credentialKey: string;
            inputParams: Record<string, any>;
            subscription?: {
                createdAt: string;
                refreshedAt?: string | undefined;
                data?: Record<string, any> | undefined;
            } | undefined;
        };
        action: {
            appKey: string;
            credentialKey: string;
            inputParams: Record<string, any>;
            actionKey: string;
        };
        customData: Record<string, any> | null;
    };
    triggerEvent: {
        status: "HANDLED" | "ERROR";
        createdAt: Date;
        id: string;
        consumerKey: string;
        updatedAt: Date;
        trigger: {
            appKey: string;
            triggerKey: string;
        };
        source: {
            type: "PUSH_TRIGGER";
        } | {
            type: "WEBHOOK";
            automationId: string;
        } | {
            type: "POLLING";
            automationId: string;
        };
        payload?: any;
    };
    execution: {
        startedAt: Date;
        endedAt: Date;
        output: {
            status: "USER_ERROR";
            error?: any;
        } | {
            status: "SERVER_ERROR";
            error?: any;
        } | {
            status: "SUCCESS";
            data?: any;
        };
    };
}, {
    automation: {
        status: "INVALID" | "READY";
        createdAt: Date;
        id: string;
        name: string;
        consumerKey: string;
        updatedAt: Date;
        active: boolean;
        live: boolean;
        blueprintKey: string | null;
        trigger: {
            appKey: string;
            triggerKey: string;
            credentialKey: string;
            inputParams: Record<string, any>;
            subscription?: {
                createdAt: string;
                refreshedAt?: string | undefined;
                data?: Record<string, any> | undefined;
            } | undefined;
        };
        action: {
            appKey: string;
            credentialKey: string;
            inputParams: Record<string, any>;
            actionKey: string;
        };
        customData: Record<string, any> | null;
    };
    triggerEvent: {
        status: "HANDLED" | "ERROR";
        createdAt: Date;
        id: string;
        consumerKey: string;
        updatedAt: Date;
        trigger: {
            appKey: string;
            triggerKey: string;
        };
        source: {
            type: "PUSH_TRIGGER";
        } | {
            type: "WEBHOOK";
            automationId: string;
        } | {
            type: "POLLING";
            automationId: string;
        };
        payload?: any;
    };
    execution: {
        startedAt: (string | Date) & (string | Date | undefined);
        endedAt: (string | Date) & (string | Date | undefined);
        output: {
            status: "USER_ERROR";
            error?: any;
        } | {
            status: "SERVER_ERROR";
            error?: any;
        } | {
            status: "SUCCESS";
            data?: any;
        };
    };
}>;
interface OnAutomationRunResultsCtx extends z.infer<typeof zOnAutomationRunResultsCtx> {
}
type OnAutomationRunResultsFunction = (ctx: OnAutomationRunResultsCtx) => void | Promise<void>;
type OnAutomationCreatedFunction = (ctx: {
    automation: Automation;
}) => void | Promise<void>;
type OnAutomationUpdatedFunction = (ctx: {
    oldAutomation: Automation;
    newAutomation: Automation;
}) => void | Promise<void>;
type OnAutomationDeletedFunction = (ctx: {
    automation: Automation;
}) => void | Promise<void>;
declare const zRolloutConfig: z.ZodObject<{
    apps: z.ZodUnion<[z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodAny>, Record<string, AnyAppDefinition>, Record<string, any>>, z.ZodFunction<z.ZodTuple<[z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodAny>, Record<string, AnyAppDefinition>, Record<string, any>>], z.ZodUnknown>, z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodAny>, Record<string, AnyAppDefinition>, Record<string, any>>>]>;
    onAutomationRunResults: z.ZodOptional<z.ZodEffects<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>, OnAutomationRunResultsFunction, (...args: unknown[]) => unknown>>;
    onAutomationCreated: z.ZodOptional<z.ZodEffects<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>, OnAutomationCreatedFunction, (...args: unknown[]) => unknown>>;
    onAutomationUpdated: z.ZodOptional<z.ZodEffects<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>, OnAutomationUpdatedFunction, (...args: unknown[]) => unknown>>;
    onAutomationDeleted: z.ZodOptional<z.ZodEffects<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>, OnAutomationDeletedFunction, (...args: unknown[]) => unknown>>;
}, "strip", z.ZodTypeAny, {
    apps: (Record<string, AnyAppDefinition> | ((args_0: Record<string, any>, ...args_1: unknown[]) => Record<string, AnyAppDefinition>)) & (Record<string, AnyAppDefinition> | ((args_0: Record<string, any>, ...args_1: unknown[]) => Record<string, AnyAppDefinition>) | undefined);
    onAutomationRunResults?: OnAutomationRunResultsFunction | undefined;
    onAutomationCreated?: OnAutomationCreatedFunction | undefined;
    onAutomationUpdated?: OnAutomationUpdatedFunction | undefined;
    onAutomationDeleted?: OnAutomationDeletedFunction | undefined;
}, {
    apps: (Record<string, any> | ((args_0: Record<string, AnyAppDefinition>, ...args_1: unknown[]) => Record<string, any>)) & (Record<string, any> | ((args_0: Record<string, AnyAppDefinition>, ...args_1: unknown[]) => Record<string, any>) | undefined);
    onAutomationRunResults?: ((...args: unknown[]) => unknown) | undefined;
    onAutomationCreated?: ((...args: unknown[]) => unknown) | undefined;
    onAutomationUpdated?: ((...args: unknown[]) => unknown) | undefined;
    onAutomationDeleted?: ((...args: unknown[]) => unknown) | undefined;
}>;
interface RolloutConfig extends z.infer<typeof zRolloutConfig> {
}
/**
 * Used to define config for a Rollout Project.
 * @param config The config object, see {@link RolloutConfig}
 */
declare function setupRollout<Config extends RolloutConfig>(config: Config): Config;

declare const zTriggerEvent: z.ZodObject<{
    id: z.ZodString;
    createdAt: z.ZodDate;
    updatedAt: z.ZodDate;
    consumerKey: z.ZodString;
    status: z.ZodEnum<["HANDLED", "ERROR"]>;
    source: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
        type: z.ZodLiteral<"PUSH_TRIGGER">;
    }, "strip", z.ZodTypeAny, {
        type: "PUSH_TRIGGER";
    }, {
        type: "PUSH_TRIGGER";
    }>, z.ZodObject<{
        type: z.ZodLiteral<"WEBHOOK">;
        automationId: z.ZodString;
    }, "strip", z.ZodTypeAny, {
        type: "WEBHOOK";
        automationId: string;
    }, {
        type: "WEBHOOK";
        automationId: string;
    }>, z.ZodObject<{
        type: z.ZodLiteral<"POLLING">;
        automationId: z.ZodString;
    }, "strip", z.ZodTypeAny, {
        type: "POLLING";
        automationId: string;
    }, {
        type: "POLLING";
        automationId: string;
    }>]>;
    trigger: z.ZodObject<{
        appKey: z.ZodString;
        triggerKey: z.ZodString;
    }, "strip", z.ZodTypeAny, {
        appKey: string;
        triggerKey: string;
    }, {
        appKey: string;
        triggerKey: string;
    }>;
    payload: z.ZodAny;
}, "strip", z.ZodTypeAny, {
    status: "HANDLED" | "ERROR";
    createdAt: Date;
    id: string;
    consumerKey: string;
    updatedAt: Date;
    trigger: {
        appKey: string;
        triggerKey: string;
    };
    source: {
        type: "PUSH_TRIGGER";
    } | {
        type: "WEBHOOK";
        automationId: string;
    } | {
        type: "POLLING";
        automationId: string;
    };
    payload?: any;
}, {
    status: "HANDLED" | "ERROR";
    createdAt: Date;
    id: string;
    consumerKey: string;
    updatedAt: Date;
    trigger: {
        appKey: string;
        triggerKey: string;
    };
    source: {
        type: "PUSH_TRIGGER";
    } | {
        type: "WEBHOOK";
        automationId: string;
    } | {
        type: "POLLING";
        automationId: string;
    };
    payload?: any;
}>;
interface TriggerEvent extends z.infer<typeof zTriggerEvent> {
}

type GetTriggerPayloadSchemaOpts = {
    appKey: string;
    triggerKey: string;
    credentialKey: string;
    inputParams: Record<string, any>;
    consumerKey: string;
};
type GetTriggerPayloadSchema = (opts: GetTriggerPayloadSchemaOpts) => Promise<AnyTriggerPayloadSchemaShape>;
declare const getTriggerPayloadSchema: GetTriggerPayloadSchema;

declare const types: {
    array: <T extends _sinclair_typebox.TSchema>(schema: T, options?: _sinclair_typebox.ArrayOptions | undefined) => _sinclair_typebox.TArray<T>;
    boolean: (options?: _sinclair_typebox.SchemaOptions | undefined) => _sinclair_typebox.TBoolean;
    literal: <T_1 extends _sinclair_typebox.TLiteralValue>(value: T_1, options?: _sinclair_typebox.SchemaOptions | undefined) => _sinclair_typebox.TLiteral<T_1>;
    object: <T_2 extends TProperties>(properties: T_2, options?: _sinclair_typebox.ObjectOptions | undefined) => TObject<T_2>;
    optional: <T_3 extends _sinclair_typebox.TSchema>(schema: T_3) => _sinclair_typebox.TOptional<T_3>;
    record: <K extends _sinclair_typebox.TSchema, T_4 extends _sinclair_typebox.TSchema>(key: K, schema: T_4, options?: _sinclair_typebox.ObjectOptions | undefined) => _sinclair_typebox.TRecordResolve<K, T_4>;
    string: (options?: _sinclair_typebox.StringOptions | undefined) => _sinclair_typebox.TString;
    union: {
        (anyOf: [], options?: _sinclair_typebox.SchemaOptions | undefined): _sinclair_typebox.TNever;
        <T_5 extends [_sinclair_typebox.TSchema]>(anyOf: [...T_5], options?: _sinclair_typebox.SchemaOptions | undefined): T_5[0];
        <T_6 extends _sinclair_typebox.TSchema[]>(anyOf: [...T_6], options?: _sinclair_typebox.SchemaOptions | undefined): _sinclair_typebox.TUnion<T_6>;
        <T_7 extends _sinclair_typebox.TTemplateLiteral<_sinclair_typebox.TTemplateLiteralKind[]>>(template: T_7): _sinclair_typebox.Ensure<_sinclair_typebox.UnionType<_sinclair_typebox.Assert<_sinclair_typebox.UnionToTuple<{ [K_1 in Static<T_7, []>]: _sinclair_typebox.TLiteral<K_1>; }[Static<T_7, []>], _sinclair_typebox.UnionLast<{ [K_1 in Static<T_7, []>]: _sinclair_typebox.TLiteral<K_1>; }[Static<T_7, []>]>>, _sinclair_typebox.TLiteral<_sinclair_typebox.TLiteralValue>[]>>>;
    };
};
type InferTriggerInputParamsSchema<T extends TObject> = Static<T>;
/**
 * Used to define the `inputParams` schema for a Trigger.
 * @example
 * ```ts
 * import { defineTriggerInputParamsSchema } from "@rollout/framework";
 *
 * export const inputParamsSchema = defineTriggerInputParamsSchema((t) => ({
 *   workspace: t.string(),
 *   project: t.string({ description: "Which project?" }),
 *   taskId: t.optional(t.string({ title: "Task" })),
 *   type: t.union([t.literal("A"), t.literal("B")], {
 *     title: "Task Type",
 *   }),,
 * }));
 * ```
 */
declare function defineTriggerInputParamsSchema<Params extends TProperties>(definer: (t: typeof types) => Params): TObject<Params>;

type UpdateAutomationTriggerSubscriptionDataWhere = {
    id: string;
};
type UpdateAutomationTriggerSubscriptionDataOpts = {
    where: UpdateAutomationTriggerSubscriptionDataWhere;
    data: any | ((currentData: any) => any);
};
type UpdateAutomationTriggerSubscriptionData = (opts: UpdateAutomationTriggerSubscriptionDataOpts) => Promise<void>;
declare const updateAutomationTriggerSubscriptionData: UpdateAutomationTriggerSubscriptionData;

type UpsertCredentialOpts = {
    appKey: string;
    credentialKey: string;
    credentialGroupKey?: string;
    credentialType?: string;
    data: Record<string, any>;
    consumerKeys: string[];
};
type UpsertCredential = (opts: UpsertCredentialOpts) => Promise<AppCredential<any>>;
declare const upsertCredential: UpsertCredential;

type GetPublicRolloutServiceUrl = () => string;
declare const getPublicRolloutServiceUrl: GetPublicRolloutServiceUrl;

export { ActionDefinition, AnyActionDefinition, AnyAppCredential, AnyAppDefinition, AnyAuthDefinition, AnyPollingTriggerDefinition, AnyPushTriggerDefinition, AnyTriggerDefinition, AnyTriggerPayloadSchemaFn, AnyTriggerPayloadSchemaShape, AnyWebhookTriggerDefinition, AnyWebhookTriggerHandleEventFn, ApiTokenAuthDefinitionInput, AppCredential, AppDefinition, Automation, AutomationOutput, AutomationRunExecution, Consumer, ExecuteActionFunction, GetAutomation, GetAutomationOpts, GetAutomationWhere, GetAutomations, GetAutomationsOpts, GetAutomationsWhere, GetCredentialOptionResult, GetCredentialOpts, GetLiveAutomations, GetLiveAutomationsOpts, GetLiveAutomationsWhere, GetPublicRolloutServiceUrl, GetTriggerPayloadSchemaOpts, HandleConsumerRequestOpts, HandlePushTriggerEvent, HandlePushTriggerEventOpts, HandleWebhookRequestJobOpts, InferActionInputParamsSchema, InferTriggerInputParamsSchema, InferTriggerPayloadSchema, JWTAuthDefinitionInput, OAuthScopeError, OnAutomationCreatedFunction, OnAutomationDeletedFunction, OnAutomationRunResultsCtx, OnAutomationRunResultsFunction, OnAutomationUpdatedFunction, PushTriggerDefinition, RequestHandler, RolloutConfig, TriggerEvent, UpdateAutomationTriggerSubscriptionData, UpdateAutomationTriggerSubscriptionDataOpts, UpdateAutomationTriggerSubscriptionDataWhere, UpsertCredential, UpsertCredentialOpts, UserError, defineAction, defineActionInputParamsSchema, defineApiTokenAuth, defineApp, defineHTTPHandler, defineJWTAuth, defineProjectOAuth1 as defineOAuth1, defineProjectOAuth2 as defineOAuth2, definePollingTrigger, definePushTrigger, defineTaskTrigger, defineTriggerInputParamsSchema, defineTriggerPayloadSchema, defineWebhookTrigger, getAutomation, getAutomations, getCredential, getLiveAutomations, getPublicRolloutServiceUrl, getTriggerPayloadSchema, handleConsumerRequest, handlePushTriggerEvent, handleWebhookRequestJob, setupRollout, updateAutomationTriggerSubscriptionData, upsertCredential };
