/** * Redirect operations for Managed Runtime. * * Handles listing, creating, updating, and deleting redirects for MRT environments. * * @module operations/mrt/redirect */ import type { AuthStrategy } from '../../auth/types.js'; import type { components } from '../../clients/mrt.js'; /** * Redirect type from API. */ export type MrtRedirect = components['schemas']['APIRedirectV2CreateUpdate']; /** * Patched redirect for updates. */ export type PatchedMrtRedirect = components['schemas']['PatchedAPIRedirectV2CreateUpdate']; /** * HTTP status code for redirects (301 or 302). */ export type RedirectHttpStatusCode = 301 | 302; /** * Options for listing redirects. */ export interface ListRedirectsOptions { /** * The project slug. */ projectSlug: string; /** * The target/environment slug. */ targetSlug: string; /** * Maximum number of results to return. */ limit?: number; /** * Offset for pagination. */ offset?: number; /** * Search term for filtering. */ search?: string; /** * Field to order results by. */ ordering?: string; /** * MRT API origin URL. * @default "https://cloud.mobify.com" */ origin?: string; } /** * Result of listing redirects. */ export interface ListRedirectsResult { /** * Total count of redirects. */ count: number; /** * URL for next page of results. */ next: string | null; /** * URL for previous page of results. */ previous: string | null; /** * Array of redirects. */ redirects: MrtRedirect[]; } /** * Lists redirects for an MRT environment. * * @param options - List options * @param auth - Authentication strategy (ApiKeyStrategy) * @returns Paginated list of redirects * @throws Error if request fails * * @example * ```typescript * import { ApiKeyStrategy } from '@salesforce/b2c-tooling-sdk/auth'; * import { listRedirects } from '@salesforce/b2c-tooling-sdk/operations/mrt'; * * const auth = new ApiKeyStrategy(process.env.MRT_API_KEY!, 'Authorization'); * * const result = await listRedirects({ * projectSlug: 'my-storefront', * targetSlug: 'staging' * }, auth); * * for (const redirect of result.redirects) { * console.log(`${redirect.from_path} -> ${redirect.to_url}`); * } * ``` */ export declare function listRedirects(options: ListRedirectsOptions, auth: AuthStrategy): Promise; /** * Options for creating a redirect. */ export interface CreateRedirectOptions { /** * The project slug. */ projectSlug: string; /** * The target/environment slug. */ targetSlug: string; /** * The source path to redirect from. */ fromPath: string; /** * The destination URL to redirect to. */ toUrl: string; /** * HTTP status code (301 or 302). * @default 301 */ httpStatusCode?: RedirectHttpStatusCode; /** * Forward query string parameters. */ forwardQuerystring?: boolean; /** * Forward wildcard path. */ forwardWildcard?: boolean; /** * MRT API origin URL. * @default "https://cloud.mobify.com" */ origin?: string; } /** * Creates a redirect for an MRT environment. * * @param options - Create redirect options * @param auth - Authentication strategy (ApiKeyStrategy) * @returns The created redirect * @throws Error if request fails * * @example * ```typescript * import { ApiKeyStrategy } from '@salesforce/b2c-tooling-sdk/auth'; * import { createRedirect } from '@salesforce/b2c-tooling-sdk/operations/mrt'; * * const auth = new ApiKeyStrategy(process.env.MRT_API_KEY!, 'Authorization'); * * const redirect = await createRedirect({ * projectSlug: 'my-storefront', * targetSlug: 'staging', * fromPath: '/old-page', * toUrl: '/new-page', * httpStatusCode: 301 * }, auth); * ``` */ export declare function createRedirect(options: CreateRedirectOptions, auth: AuthStrategy): Promise; /** * Options for getting a redirect. */ export interface GetRedirectOptions { /** * The project slug. */ projectSlug: string; /** * The target/environment slug. */ targetSlug: string; /** * The from_path of the redirect. */ fromPath: string; /** * MRT API origin URL. * @default "https://cloud.mobify.com" */ origin?: string; } /** * Gets a redirect from an MRT environment. * * @param options - Get redirect options * @param auth - Authentication strategy (ApiKeyStrategy) * @returns The redirect * @throws Error if request fails */ export declare function getRedirect(options: GetRedirectOptions, auth: AuthStrategy): Promise; /** * Options for updating a redirect. */ export interface UpdateRedirectOptions { /** * The project slug. */ projectSlug: string; /** * The target/environment slug. */ targetSlug: string; /** * The from_path of the redirect to update. */ fromPath: string; /** * New destination URL. */ toUrl?: string; /** * HTTP status code (301 or 302). */ httpStatusCode?: RedirectHttpStatusCode; /** * Forward query string parameters. */ forwardQuerystring?: boolean; /** * Forward wildcard path. */ forwardWildcard?: boolean; /** * MRT API origin URL. * @default "https://cloud.mobify.com" */ origin?: string; } /** * Updates a redirect in an MRT environment. * * @param options - Update redirect options * @param auth - Authentication strategy (ApiKeyStrategy) * @returns The updated redirect * @throws Error if request fails */ export declare function updateRedirect(options: UpdateRedirectOptions, auth: AuthStrategy): Promise; /** * Options for deleting a redirect. */ export interface DeleteRedirectOptions { /** * The project slug. */ projectSlug: string; /** * The target/environment slug. */ targetSlug: string; /** * The from_path of the redirect to delete. */ fromPath: string; /** * MRT API origin URL. * @default "https://cloud.mobify.com" */ origin?: string; } /** * Deletes a redirect from an MRT environment. * * @param options - Delete redirect options * @param auth - Authentication strategy (ApiKeyStrategy) * @throws Error if request fails */ export declare function deleteRedirect(options: DeleteRedirectOptions, auth: AuthStrategy): Promise; /** * Options for cloning redirects. */ export interface CloneRedirectsOptions { /** * The project slug. */ projectSlug: string; /** * The source target/environment slug to clone from. */ fromTargetSlug: string; /** * The destination target/environment slug to clone to. */ toTargetSlug: string; /** * MRT API origin URL. * @default "https://cloud.mobify.com" */ origin?: string; } /** * Result of cloning redirects. */ export interface CloneRedirectsResult { /** * Number of redirects cloned. */ count: number; /** * The cloned redirects. */ redirects: MrtRedirect[]; } /** * Clones redirects from one target to another. * * Important: When you clone redirects, you're replacing all redirects * in the destination target with all redirects from the source target. * * @param options - Clone redirects options * @param auth - Authentication strategy (ApiKeyStrategy) * @returns Result with cloned redirects * @throws Error if request fails * * @example * ```typescript * import { ApiKeyStrategy } from '@salesforce/b2c-tooling-sdk/auth'; * import { cloneRedirects } from '@salesforce/b2c-tooling-sdk/operations/mrt'; * * const auth = new ApiKeyStrategy(process.env.MRT_API_KEY!, 'Authorization'); * * const result = await cloneRedirects({ * projectSlug: 'my-storefront', * fromTargetSlug: 'staging', * toTargetSlug: 'production' * }, auth); * * console.log(`Cloned ${result.count} redirects`); * ``` */ export declare function cloneRedirects(options: CloneRedirectsOptions, auth: AuthStrategy): Promise;