/** * @license * * Copyright 2026 Adobe. All rights reserved. * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy * of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS * OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ import { t as AdminUiEntity } from "../acl-resource-id-DBlYU0DE.mjs"; import * as v from "valibot"; import { ErrorResponse, SuccessResponse } from "@adobe/aio-commerce-lib-core/responses"; //#region source/mass-actions/acl-resource-id.d.ts /** * Derives the deterministic Commerce ACL resource id for a mass action. * * The id is assembled as: `getAclResourceId(metadataId)` + `"__massactions_"` + * sanitized `actionId`. The `entity` value is used verbatim; the `actionId` is sanitized * (trimmed, lowercased, non-`[a-z0-9_]` → `_`). `"Magento_CommerceBackendUix::adminuisdk_app_"` * in the example is the fixed constant prefix (not a placeholder), and `"_massactions_"` is the * literal keyword separator for this component: * * @example * ``` * getMassActionAclResourceId("approval-dashboard-app", "order", "bulk-approve") * // getAclResourceId("approval-dashboard-app") + "_order_massactions_" + sanitize("bulk-approve") * // "Magento_CommerceBackendUix::adminuisdk_app_approval_dashboard_app" + "_order_massactions_" + "bulk_approve" * // → "Magento_CommerceBackendUix::adminuisdk_app_approval_dashboard_app_order_massactions_bulk_approve" * ``` * * @param metadataId - The application's `metadata.id` value (e.g. `"approval-dashboard-app"`). * @param entity - The grid's Commerce entity (`"order"`, `"product"`, or `"customer"`). * @param actionId - The action's `id` value from `adminUi..massActions[].id`. * @returns The full Commerce ACL resource id for the mass-action leaf node, or an empty string * when `metadataId` is blank. */ declare function getMassActionAclResourceId(metadataId: string, entity: AdminUiEntity, actionId: string): string; //#endregion //#region source/mass-actions/worker/schema.d.ts /** * Grid identifier sent by Commerce on the `commerce/backend-ui/2` wire contract * for worker mass actions. */ declare const MassActionGridTypeSchema: v.PicklistSchema<["order", "product", "customer"], undefined>; /** * Schema for the JSON body Commerce POSTs to a worker mass action handler. * * Commerce sends one request per chunk of selected IDs (currently up to 1000 * IDs per request). The upper bound is the Commerce side's contract and is not * enforced here. */ declare const MassActionRequestSchema: v.ObjectSchema<{ readonly gridType: v.PicklistSchema<["order", "product", "customer"], undefined>; readonly requestId: v.SchemaWithPipe, v.NonEmptyAction]>; readonly selectedIds: v.SchemaWithPipe, v.NonEmptyAction]>, undefined>, v.MinLengthAction]>; }, undefined>; //#endregion //#region source/mass-actions/worker/types.d.ts /** Grid identifier sent on the wire by a worker mass action request. */ type MassActionGridType = v.InferOutput; /** Parsed request body sent by Commerce to a worker mass action handler. */ type MassActionRequest = v.InferOutput; /** Response body returned to Commerce after a worker mass action completes. */ type MassActionResponseBody = Record; /** Error body returned to Commerce when a worker mass action fails. */ type MassActionErrorBody = { message: string; }; //#endregion //#region source/mass-actions/worker/presets.d.ts /** * Parses and validates the JSON body Commerce POSTs to a worker mass action handler. * * Throws a `CommerceSdkValidationError` if the input is malformed. * * @example * ```ts * import { parseMassActionRequest } from "@adobe/aio-commerce-lib-admin-ui/mass-actions"; * * export async function main(params: unknown) { * const { requestId, gridType, selectedIds } = parseMassActionRequest(params); * // process selectedIds... * } * ``` */ declare function parseMassActionRequest(input: unknown): MassActionRequest; /** * Builds an HTTP 200 success response for a worker mass action. * * Commerce determines success from the HTTP status code. You may optionally * include any fields in `body` for your own logging or auditing purposes. * * @example * ```ts * return okMassActionResponse(); * return okMassActionResponse({ exported: selectedIds.length }); * ``` */ declare function okMassActionResponse(body?: MassActionResponseBody): SuccessResponse; /** * Builds an error response for a worker mass action with the given HTTP status code. * * @param statusCode - The HTTP status code to return. * @param errorMessage - Error message included in the response body as `{ message }`. * * @example * ```ts * return massActionErrorResponse(422, "Request entity is unprocessable"); * ``` */ declare function massActionErrorResponse(statusCode: number, errorMessage: string): ErrorResponse; //#endregion export { type AdminUiEntity, type MassActionErrorBody, type MassActionGridType, MassActionGridTypeSchema, type MassActionRequest, MassActionRequestSchema, type MassActionResponseBody, getMassActionAclResourceId, massActionErrorResponse, okMassActionResponse, parseMassActionRequest };