/** * Push operations for Managed Runtime. * * Handles uploading bundles to MRT projects and optionally deploying them. * * @module operations/mrt/push */ import type { AuthStrategy } from '../../auth/types.js'; import type { MrtClient, components } from '../../clients/mrt.js'; import type { CreateBundleOptions, Bundle } from './bundle.js'; /** * Options for pushing a bundle to MRT. */ export interface PushOptions extends CreateBundleOptions { /** * Target environment to deploy to after push. * If not provided, bundle is uploaded but not deployed. */ target?: string; /** * MRT API origin URL. * @default "https://cloud.mobify.com" */ origin?: string; } /** * Result of a push operation. */ export interface PushResult { /** * The bundle ID assigned by MRT. */ bundleId: number; /** * The project slug the bundle was pushed to. */ projectSlug: string; /** * The target environment if deployed. */ target?: string; /** * Whether the bundle was deployed to the target. */ deployed: boolean; /** * The bundle message. */ message: string; /** * Non-blocking warnings returned by MRT for this push/deploy (e.g. x86 deprecation). */ warnings?: string[]; } /** * Pushes a bundle to a Managed Runtime project. * * This function creates a bundle from the build directory and uploads it * to the specified MRT project. Optionally, it can also deploy the bundle * to a target environment. * * @param options - Push configuration options * @param auth - Authentication strategy (ApiKeyStrategy) * @returns Result of the push operation * @throws Error if push fails * * @example * ```typescript * import { ApiKeyStrategy } from '@salesforce/b2c-tooling-sdk/auth'; * import { pushBundle } from '@salesforce/b2c-tooling-sdk/operations/mrt'; * * const auth = new ApiKeyStrategy(process.env.MRT_API_KEY!, 'Authorization'); * * const result = await pushBundle({ * projectSlug: 'my-storefront', * ssrOnly: ['ssr.js'], * ssrShared: ['**\/*.js', 'static/**\/*'], * buildDirectory: './build', * message: 'Release v1.0.0', * target: 'staging' // Optional: deploy after push * }, auth); * * console.log(`Bundle ${result.bundleId} pushed to ${result.projectSlug}`); * if (result.deployed) { * console.log(`Deployed to ${result.target}`); * } * ``` */ export declare function pushBundle(options: PushOptions, auth: AuthStrategy): Promise; /** * Uploads a pre-created bundle to MRT. * * Use this if you've already created a bundle and want to upload it separately. * * @param client - MRT client instance * @param projectSlug - Project to upload to * @param bundle - Bundle to upload * @param target - Optional target to deploy to * @returns Result of the upload */ export declare function uploadBundle(client: MrtClient, projectSlug: string, bundle: Bundle, target?: string): Promise; /** * Bundle list item from API. */ export type MrtBundle = components['schemas']['BundleList']; /** * Options for listing bundles. */ export interface ListBundlesOptions { /** * The project slug. */ projectSlug: string; /** * Maximum number of results to return. */ limit?: number; /** * Offset for pagination. */ offset?: number; /** * MRT API origin URL. * @default "https://cloud.mobify.com" */ origin?: string; } /** * Result of listing bundles. */ export interface ListBundlesResult { /** * Total count of bundles. */ count: number; /** * URL for next page of results. */ next: string | null; /** * URL for previous page of results. */ previous: string | null; /** * Array of bundles. */ bundles: MrtBundle[]; } /** * Lists bundles for an MRT project. * * @param options - List options including project slug * @param auth - Authentication strategy (ApiKeyStrategy) * @returns Paginated list of bundles * @throws Error if request fails * * @example * ```typescript * import { ApiKeyStrategy } from '@salesforce/b2c-tooling-sdk/auth'; * import { listBundles } from '@salesforce/b2c-tooling-sdk/operations/mrt'; * * const auth = new ApiKeyStrategy(process.env.MRT_API_KEY!, 'Authorization'); * * const result = await listBundles({ * projectSlug: 'my-storefront' * }, auth); * * for (const bundle of result.bundles) { * console.log(`Bundle ${bundle.id}: ${bundle.message}`); * } * ``` */ export declare function listBundles(options: ListBundlesOptions, auth: AuthStrategy): Promise; /** * Options for downloading a bundle. */ export interface DownloadBundleOptions { /** * The project slug. */ projectSlug: string; /** * The bundle ID to download. */ bundleId: number; /** * MRT API origin URL. * @default "https://cloud.mobify.com" */ origin?: string; } /** * Result of getting a bundle download URL. */ export interface DownloadBundleResult { /** * Presigned URL for downloading the bundle archive. * Valid for one hour. */ downloadUrl: string; } /** * Gets a presigned URL to download a bundle archive. * * The returned URL is valid for one hour. * * @param options - Download options * @param auth - Authentication strategy (ApiKeyStrategy) * @returns Download URL result * @throws Error if request fails * * @example * ```typescript * import { ApiKeyStrategy } from '@salesforce/b2c-tooling-sdk/auth'; * import { downloadBundle } from '@salesforce/b2c-tooling-sdk/operations/mrt'; * * const auth = new ApiKeyStrategy(process.env.MRT_API_KEY!, 'Authorization'); * * const result = await downloadBundle({ * projectSlug: 'my-storefront', * bundleId: 12345 * }, auth); * * console.log(`Download URL: ${result.downloadUrl}`); * ``` */ export declare function downloadBundle(options: DownloadBundleOptions, auth: AuthStrategy): Promise; /** * Options for deleting a single bundle. */ export interface DeleteBundleOptions { /** The project slug containing the bundle. */ projectSlug: string; /** The bundle ID to delete. */ bundleId: number; /** * MRT API origin URL. * @default "https://cloud.mobify.com" */ origin?: string; } /** * Requests deletion of a single bundle. Bundles are deleted asynchronously. * Only project admins can perform this operation. * * @param options - Delete options * @param auth - Authentication strategy * @throws Error if the request fails */ export declare function deleteBundle(options: DeleteBundleOptions, auth: AuthStrategy): Promise; /** * Options for bulk-deleting bundles. */ export interface BulkDeleteBundlesOptions { /** The project slug containing the bundles. */ projectSlug: string; /** Bundle IDs to delete. */ bundleIds: number[]; /** * MRT API origin URL. * @default "https://cloud.mobify.com" */ origin?: string; } /** * A bundle that the server rejected during a bulk-delete request. */ export interface BulkDeleteRejectedBundle { /** Bundle ID that was rejected. May be null when the server returned a batch error without a specific id. */ bundleId?: number; /** Reason the bundle was rejected. */ reason: string; } /** * Result of a bulk-delete request. */ export interface BulkDeleteBundlesResult { /** Bundle IDs that were queued for asynchronous deletion. */ queued: number[]; /** Bundles the server rejected, with reasons. */ rejected: BulkDeleteRejectedBundle[]; } /** * Requests deletion of multiple bundles in a single call. * * The response indicates which bundles were queued and which were rejected. * Only project admins can perform this operation. * * @param options - Bulk delete options * @param auth - Authentication strategy * @returns Lists of queued and rejected bundle IDs * @throws Error if the request itself fails */ export declare function bulkDeleteBundles(options: BulkDeleteBundlesOptions, auth: AuthStrategy): Promise;