@adobe/aio-commerce-lib-admin-ui 0.1.0 → 0.2.0-beta-20260714082406

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/README.md +1 -1
  3. package/dist/cjs/acl-resource-id-DBlYU0DE.d.cts +39 -0
  4. package/dist/cjs/acl-resource-id-D_hCU1Qg.cjs +69 -0
  5. package/dist/cjs/api/index.cjs +252 -0
  6. package/dist/cjs/api/index.d.cts +126 -0
  7. package/dist/cjs/grid-columns/index.cjs +151 -0
  8. package/dist/cjs/grid-columns/index.d.cts +146 -0
  9. package/dist/cjs/mass-actions/index.cjs +188 -0
  10. package/dist/cjs/mass-actions/index.d.cts +160 -0
  11. package/dist/cjs/menu/index.cjs +91 -0
  12. package/dist/cjs/menu/index.d.cts +63 -0
  13. package/dist/cjs/order-view-buttons/index.cjs +126 -0
  14. package/dist/cjs/order-view-buttons/index.d.cts +113 -0
  15. package/dist/cjs/rolldown-runtime-Cx6hovH8.cjs +67 -0
  16. package/dist/cjs/schemas-Ce10uBzN.cjs +41 -0
  17. package/dist/cjs/utils-B59fjd_w.cjs +39 -0
  18. package/dist/cjs/web/index.cjs +830 -0
  19. package/dist/cjs/web/index.d.cts +192 -0
  20. package/dist/es/acl-resource-id-DBlYU0DE.d.mts +39 -0
  21. package/dist/es/acl-resource-id-pryVxI_c.mjs +57 -0
  22. package/dist/es/api/index.d.mts +126 -0
  23. package/dist/es/api/index.mjs +262 -0
  24. package/dist/es/grid-columns/index.d.mts +146 -0
  25. package/dist/es/grid-columns/index.mjs +143 -0
  26. package/dist/es/mass-actions/index.d.mts +160 -0
  27. package/dist/es/mass-actions/index.mjs +178 -0
  28. package/dist/es/menu/index.d.mts +63 -0
  29. package/dist/es/menu/index.mjs +80 -0
  30. package/dist/es/order-view-buttons/index.d.mts +113 -0
  31. package/dist/es/order-view-buttons/index.mjs +119 -0
  32. package/dist/es/schemas-BFT8ys8P.mjs +34 -0
  33. package/dist/es/utils-COPGW1HO.mjs +32 -0
  34. package/dist/es/web/index.d.mts +192 -0
  35. package/dist/es/web/index.mjs +819 -0
  36. package/package.json +87 -10
  37. package/dist/cjs/index.cjs +0 -139
  38. package/dist/cjs/index.d.cts +0 -56
  39. package/dist/es/index.d.mts +0 -56
  40. package/dist/es/index.mjs +0 -114
@@ -0,0 +1,151 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright 2026 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+
15
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
16
+ const require_rolldown_runtime = require('../rolldown-runtime-Cx6hovH8.cjs');
17
+ const require_acl_resource_id = require('../acl-resource-id-D_hCU1Qg.cjs');
18
+ const require_schemas = require('../schemas-Ce10uBzN.cjs');
19
+ const require_utils = require('../utils-B59fjd_w.cjs');
20
+ let valibot = require("valibot");
21
+ valibot = require_rolldown_runtime.__toESM(valibot, 1);
22
+ let _adobe_aio_commerce_lib_core_responses = require("@adobe/aio-commerce-lib-core/responses");
23
+
24
+ //#region source/grid-columns/acl-resource-id.ts
25
+ /**
26
+ * Derives the deterministic Commerce ACL resource id for a grid column.
27
+ *
28
+ * The id is assembled as: `getAclResourceId(metadataId)` + `"_<entity>_gridcolumns_"` +
29
+ * sanitized `columnId`. The `entity` value is used verbatim (it is already `[a-z]`); the
30
+ * `columnId` is sanitized (trimmed, lowercased, non-`[a-z0-9_]` → `_`). `"Magento_CommerceBackendUix::adminuisdk_app_"`
31
+ * in the example is the fixed constant prefix (not a placeholder), and `"_gridcolumns_"` is the
32
+ * literal keyword separator for this component:
33
+ *
34
+ * @example
35
+ * ```
36
+ * getGridColumnAclResourceId("approval-dashboard-app", "order", "order_status")
37
+ * // getAclResourceId("approval-dashboard-app") + "_order_gridcolumns_" + sanitize("order_status")
38
+ * // "Magento_CommerceBackendUix::adminuisdk_app_approval_dashboard_app" + "_order_gridcolumns_" + "order_status"
39
+ * // → "Magento_CommerceBackendUix::adminuisdk_app_approval_dashboard_app_order_gridcolumns_order_status"
40
+ * ```
41
+ *
42
+ * @param metadataId - The application's `metadata.id` value (e.g. `"approval-dashboard-app"`).
43
+ * @param entity - The grid's Commerce entity (`"order"`, `"product"`, or `"customer"`).
44
+ * @param columnId - The column's `id` value from `adminUi.<entity>.gridColumns.columns[].id`.
45
+ * @returns The full Commerce ACL resource id for the grid-column leaf node, or an empty string
46
+ * when `metadataId` is blank.
47
+ */
48
+ function getGridColumnAclResourceId(metadataId, entity, columnId) {
49
+ const appRoot = require_acl_resource_id.getAclResourceId(metadataId);
50
+ if (appRoot === "") return "";
51
+ return `${appRoot}_${entity}_gridcolumns_${require_acl_resource_id.sanitizeSegment(columnId)}`;
52
+ }
53
+
54
+ //#endregion
55
+ //#region source/grid-columns/requests/schema.ts
56
+ /**
57
+ * Grid identifier sent by Commerce on the `commerce/backend-ui/2` wire contract.
58
+ *
59
+ * @see {@link https://github.com/magento-commerce/adobe-commerce-backend-uix Magento module reference}
60
+ */
61
+ const GridTypeSchema = valibot.picklist([
62
+ "order",
63
+ "product",
64
+ "customer"
65
+ ]);
66
+ /**
67
+ * Schema for the JSON body Commerce POSTs to a grid column handler.
68
+ *
69
+ * Commerce sends one request per chunk of grid rows (currently up to 1000 IDs
70
+ * per request). The upper bound is the Commerce side's contract and is not
71
+ * enforced here.
72
+ */
73
+ const GridRequestSchema = valibot.object({
74
+ gridType: GridTypeSchema,
75
+ ids: valibot.pipe(valibot.array(require_schemas.nonEmptyStringValueSchema("id")), valibot.minLength(1, "The value of \"ids\" must contain at least one entry")),
76
+ requestId: require_schemas.nonEmptyStringValueSchema("requestId")
77
+ });
78
+
79
+ //#endregion
80
+ //#region source/grid-columns/requests/presets.ts
81
+ /**
82
+ * Parses and validates the JSON body Commerce POSTs to a grid column handler.
83
+ *
84
+ * Throws a `CommerceSdkValidationError` if the input is malformed.
85
+ *
86
+ * @example
87
+ * ```ts
88
+ * import { parseGridRequest } from "@adobe/aio-commerce-lib-admin-ui/grid-columns";
89
+ *
90
+ * export async function main(params: unknown) {
91
+ * const { requestId, gridType, ids } = parseGridRequest(params);
92
+ * // ...
93
+ * }
94
+ * ```
95
+ */
96
+ function parseGridRequest(input) {
97
+ return require_utils.parseOrThrow(GridRequestSchema, input, "Invalid grid column request");
98
+ }
99
+
100
+ //#endregion
101
+ //#region source/grid-columns/responses/presets.ts
102
+ /**
103
+ * Builds an HTTP 200 success response carrying the grid column data envelope
104
+ * Commerce expects on the `commerce/backend-ui/2` wire contract.
105
+ *
106
+ * @param data - Per-row cell values, keyed by entity ID.
107
+ * @param defaults - Default cell values applied by Commerce to IDs missing from
108
+ * `data` and to cells whose value does not satisfy the declared `type` on the
109
+ * registration.
110
+ *
111
+ * @example
112
+ * ```ts
113
+ * return okGridResponse(
114
+ * {
115
+ * "000000001": { fulfillment_status: "shipped", risk_score: 12 },
116
+ * "000000002": { fulfillment_status: "pending", risk_score: 47 },
117
+ * },
118
+ * { fulfillment_status: "unknown", risk_score: 0 },
119
+ * );
120
+ * ```
121
+ */
122
+ function okGridResponse(data, defaults) {
123
+ return (0, _adobe_aio_commerce_lib_core_responses.ok)({ body: { data: defaults ? {
124
+ ...data,
125
+ "*": defaults
126
+ } : data } });
127
+ }
128
+ /**
129
+ * Builds an error response for a grid column handler with the given HTTP status code.
130
+ *
131
+ * Commerce uses the HTTP status code to distinguish success from failure.
132
+ *
133
+ * @param statusCode - The HTTP status code to return.
134
+ * @param errorMessage - Error message included in the response body as `{ message }`.
135
+ *
136
+ * @example
137
+ * ```ts
138
+ * return errorGridResponse(500, "Could not reach inventory service");
139
+ * ```
140
+ */
141
+ function errorGridResponse(statusCode, errorMessage) {
142
+ return (0, _adobe_aio_commerce_lib_core_responses.buildErrorResponse)(statusCode, { body: { message: errorMessage } });
143
+ }
144
+
145
+ //#endregion
146
+ exports.GridRequestSchema = GridRequestSchema;
147
+ exports.GridTypeSchema = GridTypeSchema;
148
+ exports.errorGridResponse = errorGridResponse;
149
+ exports.getGridColumnAclResourceId = getGridColumnAclResourceId;
150
+ exports.okGridResponse = okGridResponse;
151
+ exports.parseGridRequest = parseGridRequest;
@@ -0,0 +1,146 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright 2026 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+
15
+ import { t as AdminUiEntity } from "../acl-resource-id-DBlYU0DE.cjs";
16
+ import * as v from "valibot";
17
+ import { ErrorResponse, SuccessResponse } from "@adobe/aio-commerce-lib-core/responses";
18
+
19
+ //#region source/grid-columns/acl-resource-id.d.ts
20
+ /**
21
+ * Derives the deterministic Commerce ACL resource id for a grid column.
22
+ *
23
+ * The id is assembled as: `getAclResourceId(metadataId)` + `"_<entity>_gridcolumns_"` +
24
+ * sanitized `columnId`. The `entity` value is used verbatim (it is already `[a-z]`); the
25
+ * `columnId` is sanitized (trimmed, lowercased, non-`[a-z0-9_]` → `_`). `"Magento_CommerceBackendUix::adminuisdk_app_"`
26
+ * in the example is the fixed constant prefix (not a placeholder), and `"_gridcolumns_"` is the
27
+ * literal keyword separator for this component:
28
+ *
29
+ * @example
30
+ * ```
31
+ * getGridColumnAclResourceId("approval-dashboard-app", "order", "order_status")
32
+ * // getAclResourceId("approval-dashboard-app") + "_order_gridcolumns_" + sanitize("order_status")
33
+ * // "Magento_CommerceBackendUix::adminuisdk_app_approval_dashboard_app" + "_order_gridcolumns_" + "order_status"
34
+ * // → "Magento_CommerceBackendUix::adminuisdk_app_approval_dashboard_app_order_gridcolumns_order_status"
35
+ * ```
36
+ *
37
+ * @param metadataId - The application's `metadata.id` value (e.g. `"approval-dashboard-app"`).
38
+ * @param entity - The grid's Commerce entity (`"order"`, `"product"`, or `"customer"`).
39
+ * @param columnId - The column's `id` value from `adminUi.<entity>.gridColumns.columns[].id`.
40
+ * @returns The full Commerce ACL resource id for the grid-column leaf node, or an empty string
41
+ * when `metadataId` is blank.
42
+ */
43
+ declare function getGridColumnAclResourceId(metadataId: string, entity: AdminUiEntity, columnId: string): string;
44
+ //#endregion
45
+ //#region source/grid-columns/requests/schema.d.ts
46
+ /**
47
+ * Grid identifier sent by Commerce on the `commerce/backend-ui/2` wire contract.
48
+ *
49
+ * @see {@link https://github.com/magento-commerce/adobe-commerce-backend-uix Magento module reference}
50
+ */
51
+ declare const GridTypeSchema: v.PicklistSchema<["order", "product", "customer"], undefined>;
52
+ /**
53
+ * Schema for the JSON body Commerce POSTs to a grid column handler.
54
+ *
55
+ * Commerce sends one request per chunk of grid rows (currently up to 1000 IDs
56
+ * per request). The upper bound is the Commerce side's contract and is not
57
+ * enforced here.
58
+ */
59
+ declare const GridRequestSchema: v.ObjectSchema<{
60
+ readonly gridType: v.PicklistSchema<["order", "product", "customer"], undefined>;
61
+ readonly ids: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>, undefined>, v.MinLengthAction<string[], 1, "The value of \"ids\" must contain at least one entry">]>;
62
+ readonly requestId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
63
+ }, undefined>;
64
+ //#endregion
65
+ //#region source/grid-columns/requests/types.d.ts
66
+ /** Grid identifier sent on the wire. */
67
+ type GridType = v.InferOutput<typeof GridTypeSchema>;
68
+ /** Parsed request body sent by Commerce to a grid column handler. */
69
+ type GridRequest = v.InferOutput<typeof GridRequestSchema>;
70
+ //#endregion
71
+ //#region source/grid-columns/requests/presets.d.ts
72
+ /**
73
+ * Parses and validates the JSON body Commerce POSTs to a grid column handler.
74
+ *
75
+ * Throws a `CommerceSdkValidationError` if the input is malformed.
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * import { parseGridRequest } from "@adobe/aio-commerce-lib-admin-ui/grid-columns";
80
+ *
81
+ * export async function main(params: unknown) {
82
+ * const { requestId, gridType, ids } = parseGridRequest(params);
83
+ * // ...
84
+ * }
85
+ * ```
86
+ */
87
+ declare function parseGridRequest(input: unknown): GridRequest;
88
+ //#endregion
89
+ //#region source/grid-columns/responses/types.d.ts
90
+ /** Cell values returned for a single row, keyed by `id`. */
91
+ type GridRow = Record<string, unknown>;
92
+ /**
93
+ * Success body returned to Commerce.
94
+ *
95
+ * The `"*"` entry supplies default cell values that Commerce applies to IDs
96
+ * missing from `data` and to cells whose returned value does not satisfy the
97
+ * declared `type` on the registration.
98
+ */
99
+ type GridSuccessBody = {
100
+ data: Record<string, GridRow> & {
101
+ "*"?: GridRow;
102
+ };
103
+ };
104
+ /** Failure body returned to Commerce. */
105
+ type GridErrorBody = {
106
+ message: string;
107
+ };
108
+ //#endregion
109
+ //#region source/grid-columns/responses/presets.d.ts
110
+ /**
111
+ * Builds an HTTP 200 success response carrying the grid column data envelope
112
+ * Commerce expects on the `commerce/backend-ui/2` wire contract.
113
+ *
114
+ * @param data - Per-row cell values, keyed by entity ID.
115
+ * @param defaults - Default cell values applied by Commerce to IDs missing from
116
+ * `data` and to cells whose value does not satisfy the declared `type` on the
117
+ * registration.
118
+ *
119
+ * @example
120
+ * ```ts
121
+ * return okGridResponse(
122
+ * {
123
+ * "000000001": { fulfillment_status: "shipped", risk_score: 12 },
124
+ * "000000002": { fulfillment_status: "pending", risk_score: 47 },
125
+ * },
126
+ * { fulfillment_status: "unknown", risk_score: 0 },
127
+ * );
128
+ * ```
129
+ */
130
+ declare function okGridResponse(data: Record<string, GridRow>, defaults?: GridRow): SuccessResponse<GridSuccessBody>;
131
+ /**
132
+ * Builds an error response for a grid column handler with the given HTTP status code.
133
+ *
134
+ * Commerce uses the HTTP status code to distinguish success from failure.
135
+ *
136
+ * @param statusCode - The HTTP status code to return.
137
+ * @param errorMessage - Error message included in the response body as `{ message }`.
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * return errorGridResponse(500, "Could not reach inventory service");
142
+ * ```
143
+ */
144
+ declare function errorGridResponse(statusCode: number, errorMessage: string): ErrorResponse<GridErrorBody>;
145
+ //#endregion
146
+ export { type AdminUiEntity, type GridErrorBody, type GridRequest, GridRequestSchema, type GridRow, type GridSuccessBody, type GridType, GridTypeSchema, errorGridResponse, getGridColumnAclResourceId, okGridResponse, parseGridRequest };
@@ -0,0 +1,188 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright 2026 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+
15
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
16
+ const require_rolldown_runtime = require('../rolldown-runtime-Cx6hovH8.cjs');
17
+ const require_acl_resource_id = require('../acl-resource-id-D_hCU1Qg.cjs');
18
+ const require_schemas = require('../schemas-Ce10uBzN.cjs');
19
+ const require_utils = require('../utils-B59fjd_w.cjs');
20
+ let valibot = require("valibot");
21
+ valibot = require_rolldown_runtime.__toESM(valibot, 1);
22
+ let _adobe_aio_commerce_lib_core_responses = require("@adobe/aio-commerce-lib-core/responses");
23
+
24
+ //#region source/mass-actions/acl-resource-id.ts
25
+ /**
26
+ * Derives the deterministic Commerce ACL resource id for a mass action.
27
+ *
28
+ * The id is assembled as: `getAclResourceId(metadataId)` + `"_<entity>_massactions_"` +
29
+ * sanitized `actionId`. The `entity` value is used verbatim; the `actionId` is sanitized
30
+ * (trimmed, lowercased, non-`[a-z0-9_]` → `_`). `"Magento_CommerceBackendUix::adminuisdk_app_"`
31
+ * in the example is the fixed constant prefix (not a placeholder), and `"_massactions_"` is the
32
+ * literal keyword separator for this component:
33
+ *
34
+ * @example
35
+ * ```
36
+ * getMassActionAclResourceId("approval-dashboard-app", "order", "bulk-approve")
37
+ * // getAclResourceId("approval-dashboard-app") + "_order_massactions_" + sanitize("bulk-approve")
38
+ * // "Magento_CommerceBackendUix::adminuisdk_app_approval_dashboard_app" + "_order_massactions_" + "bulk_approve"
39
+ * // → "Magento_CommerceBackendUix::adminuisdk_app_approval_dashboard_app_order_massactions_bulk_approve"
40
+ * ```
41
+ *
42
+ * @param metadataId - The application's `metadata.id` value (e.g. `"approval-dashboard-app"`).
43
+ * @param entity - The grid's Commerce entity (`"order"`, `"product"`, or `"customer"`).
44
+ * @param actionId - The action's `id` value from `adminUi.<entity>.massActions[].id`.
45
+ * @returns The full Commerce ACL resource id for the mass-action leaf node, or an empty string
46
+ * when `metadataId` is blank.
47
+ */
48
+ function getMassActionAclResourceId(metadataId, entity, actionId) {
49
+ const appRoot = require_acl_resource_id.getAclResourceId(metadataId);
50
+ if (appRoot === "") return "";
51
+ return `${appRoot}_${entity}_massactions_${require_acl_resource_id.sanitizeSegment(actionId)}`;
52
+ }
53
+
54
+ //#endregion
55
+ //#region source/mass-actions/view/schema.ts
56
+ /**
57
+ * Schema for the `selection` query parameter Commerce appends to the iframe URL
58
+ * of a view mass action.
59
+ *
60
+ * Commerce serializes the selection as a JSON-encoded string:
61
+ * `?selection={"ids":["000000001"],"gridType":"customer"}`
62
+ */
63
+ const MassActionSelectionSchema = valibot.object({
64
+ gridType: valibot.picklist([
65
+ "order",
66
+ "product",
67
+ "customer"
68
+ ]),
69
+ ids: valibot.pipe(valibot.array(require_schemas.nonEmptyStringValueSchema("id")), valibot.minLength(1, "The value of \"ids\" must contain at least one entry"))
70
+ });
71
+
72
+ //#endregion
73
+ //#region source/mass-actions/view/presets.ts
74
+ /**
75
+ * Parses the `selection` query parameter Commerce appends to the iframe URL of
76
+ * a view mass action.
77
+ *
78
+ * Commerce serializes the selection as a JSON string:
79
+ * `?selection={"ids":["000000001","000000002"],"gridType":"customer"}`
80
+ *
81
+ * Throws a `CommerceSdkValidationError` if the input is missing, not valid
82
+ * JSON, or does not match the expected shape.
83
+ *
84
+ * @param rawSelection - The raw string value of the `selection` query parameter.
85
+ *
86
+ * @example
87
+ * ```ts
88
+ * import { parseMassActionSelection } from "@adobe/aio-commerce-lib-admin-ui/mass-actions";
89
+ *
90
+ * // In your SPA route handler:
91
+ * const raw = new URLSearchParams(window.location.search).get("selection");
92
+ * const { ids, gridType } = parseMassActionSelection(raw);
93
+ * ```
94
+ */
95
+ function parseMassActionSelection(rawSelection) {
96
+ if (rawSelection === null || rawSelection === void 0) throw new Error("Invalid mass action selection: the selection query parameter is missing.");
97
+ let parsed;
98
+ try {
99
+ parsed = JSON.parse(String(rawSelection));
100
+ } catch (error) {
101
+ throw new Error(`Invalid mass action selection: expected a JSON string, got: ${String(rawSelection)}`, { cause: error });
102
+ }
103
+ return require_utils.parseOrThrow(MassActionSelectionSchema, parsed, "Invalid mass action selection");
104
+ }
105
+
106
+ //#endregion
107
+ //#region source/mass-actions/worker/schema.ts
108
+ /**
109
+ * Grid identifier sent by Commerce on the `commerce/backend-ui/2` wire contract
110
+ * for worker mass actions.
111
+ */
112
+ const MassActionGridTypeSchema = valibot.picklist([
113
+ "order",
114
+ "product",
115
+ "customer"
116
+ ]);
117
+ /**
118
+ * Schema for the JSON body Commerce POSTs to a worker mass action handler.
119
+ *
120
+ * Commerce sends one request per chunk of selected IDs (currently up to 1000
121
+ * IDs per request). The upper bound is the Commerce side's contract and is not
122
+ * enforced here.
123
+ */
124
+ const MassActionRequestSchema = valibot.object({
125
+ gridType: MassActionGridTypeSchema,
126
+ requestId: require_schemas.nonEmptyStringValueSchema("requestId"),
127
+ selectedIds: valibot.pipe(valibot.array(require_schemas.nonEmptyStringValueSchema("id")), valibot.minLength(1, "The value of \"selectedIds\" must contain at least one entry"))
128
+ });
129
+
130
+ //#endregion
131
+ //#region source/mass-actions/worker/presets.ts
132
+ /**
133
+ * Parses and validates the JSON body Commerce POSTs to a worker mass action handler.
134
+ *
135
+ * Throws a `CommerceSdkValidationError` if the input is malformed.
136
+ *
137
+ * @example
138
+ * ```ts
139
+ * import { parseMassActionRequest } from "@adobe/aio-commerce-lib-admin-ui/mass-actions";
140
+ *
141
+ * export async function main(params: unknown) {
142
+ * const { requestId, gridType, selectedIds } = parseMassActionRequest(params);
143
+ * // process selectedIds...
144
+ * }
145
+ * ```
146
+ */
147
+ function parseMassActionRequest(input) {
148
+ return require_utils.parseOrThrow(MassActionRequestSchema, input, "Invalid mass action request");
149
+ }
150
+ /**
151
+ * Builds an HTTP 200 success response for a worker mass action.
152
+ *
153
+ * Commerce determines success from the HTTP status code. You may optionally
154
+ * include any fields in `body` for your own logging or auditing purposes.
155
+ *
156
+ * @example
157
+ * ```ts
158
+ * return okMassActionResponse();
159
+ * return okMassActionResponse({ exported: selectedIds.length });
160
+ * ```
161
+ */
162
+ function okMassActionResponse(body = {}) {
163
+ return (0, _adobe_aio_commerce_lib_core_responses.ok)({ body });
164
+ }
165
+ /**
166
+ * Builds an error response for a worker mass action with the given HTTP status code.
167
+ *
168
+ * @param statusCode - The HTTP status code to return.
169
+ * @param errorMessage - Error message included in the response body as `{ message }`.
170
+ *
171
+ * @example
172
+ * ```ts
173
+ * return massActionErrorResponse(422, "Request entity is unprocessable");
174
+ * ```
175
+ */
176
+ function massActionErrorResponse(statusCode, errorMessage) {
177
+ return (0, _adobe_aio_commerce_lib_core_responses.buildErrorResponse)(statusCode, { body: { message: errorMessage } });
178
+ }
179
+
180
+ //#endregion
181
+ exports.MassActionGridTypeSchema = MassActionGridTypeSchema;
182
+ exports.MassActionRequestSchema = MassActionRequestSchema;
183
+ exports.MassActionSelectionSchema = MassActionSelectionSchema;
184
+ exports.getMassActionAclResourceId = getMassActionAclResourceId;
185
+ exports.massActionErrorResponse = massActionErrorResponse;
186
+ exports.okMassActionResponse = okMassActionResponse;
187
+ exports.parseMassActionRequest = parseMassActionRequest;
188
+ exports.parseMassActionSelection = parseMassActionSelection;
@@ -0,0 +1,160 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright 2026 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+
15
+ import { t as AdminUiEntity } from "../acl-resource-id-DBlYU0DE.cjs";
16
+ import * as v from "valibot";
17
+ import { ErrorResponse, SuccessResponse } from "@adobe/aio-commerce-lib-core/responses";
18
+
19
+ //#region source/mass-actions/acl-resource-id.d.ts
20
+ /**
21
+ * Derives the deterministic Commerce ACL resource id for a mass action.
22
+ *
23
+ * The id is assembled as: `getAclResourceId(metadataId)` + `"_<entity>_massactions_"` +
24
+ * sanitized `actionId`. The `entity` value is used verbatim; the `actionId` is sanitized
25
+ * (trimmed, lowercased, non-`[a-z0-9_]` → `_`). `"Magento_CommerceBackendUix::adminuisdk_app_"`
26
+ * in the example is the fixed constant prefix (not a placeholder), and `"_massactions_"` is the
27
+ * literal keyword separator for this component:
28
+ *
29
+ * @example
30
+ * ```
31
+ * getMassActionAclResourceId("approval-dashboard-app", "order", "bulk-approve")
32
+ * // getAclResourceId("approval-dashboard-app") + "_order_massactions_" + sanitize("bulk-approve")
33
+ * // "Magento_CommerceBackendUix::adminuisdk_app_approval_dashboard_app" + "_order_massactions_" + "bulk_approve"
34
+ * // → "Magento_CommerceBackendUix::adminuisdk_app_approval_dashboard_app_order_massactions_bulk_approve"
35
+ * ```
36
+ *
37
+ * @param metadataId - The application's `metadata.id` value (e.g. `"approval-dashboard-app"`).
38
+ * @param entity - The grid's Commerce entity (`"order"`, `"product"`, or `"customer"`).
39
+ * @param actionId - The action's `id` value from `adminUi.<entity>.massActions[].id`.
40
+ * @returns The full Commerce ACL resource id for the mass-action leaf node, or an empty string
41
+ * when `metadataId` is blank.
42
+ */
43
+ declare function getMassActionAclResourceId(metadataId: string, entity: AdminUiEntity, actionId: string): string;
44
+ //#endregion
45
+ //#region source/mass-actions/view/schema.d.ts
46
+ /**
47
+ * Schema for the `selection` query parameter Commerce appends to the iframe URL
48
+ * of a view mass action.
49
+ *
50
+ * Commerce serializes the selection as a JSON-encoded string:
51
+ * `?selection={"ids":["000000001"],"gridType":"customer"}`
52
+ */
53
+ declare const MassActionSelectionSchema: v.ObjectSchema<{
54
+ readonly gridType: v.PicklistSchema<["order", "product", "customer"], undefined>;
55
+ readonly ids: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>, undefined>, v.MinLengthAction<string[], 1, "The value of \"ids\" must contain at least one entry">]>;
56
+ }, undefined>;
57
+ //#endregion
58
+ //#region source/mass-actions/view/types.d.ts
59
+ /** Parsed `selection` query parameter appended by Commerce to the iframe URL. */
60
+ type MassActionSelection = v.InferOutput<typeof MassActionSelectionSchema>;
61
+ //#endregion
62
+ //#region source/mass-actions/view/presets.d.ts
63
+ /**
64
+ * Parses the `selection` query parameter Commerce appends to the iframe URL of
65
+ * a view mass action.
66
+ *
67
+ * Commerce serializes the selection as a JSON string:
68
+ * `?selection={"ids":["000000001","000000002"],"gridType":"customer"}`
69
+ *
70
+ * Throws a `CommerceSdkValidationError` if the input is missing, not valid
71
+ * JSON, or does not match the expected shape.
72
+ *
73
+ * @param rawSelection - The raw string value of the `selection` query parameter.
74
+ *
75
+ * @example
76
+ * ```ts
77
+ * import { parseMassActionSelection } from "@adobe/aio-commerce-lib-admin-ui/mass-actions";
78
+ *
79
+ * // In your SPA route handler:
80
+ * const raw = new URLSearchParams(window.location.search).get("selection");
81
+ * const { ids, gridType } = parseMassActionSelection(raw);
82
+ * ```
83
+ */
84
+ declare function parseMassActionSelection(rawSelection: unknown): MassActionSelection;
85
+ //#endregion
86
+ //#region source/mass-actions/worker/schema.d.ts
87
+ /**
88
+ * Grid identifier sent by Commerce on the `commerce/backend-ui/2` wire contract
89
+ * for worker mass actions.
90
+ */
91
+ declare const MassActionGridTypeSchema: v.PicklistSchema<["order", "product", "customer"], undefined>;
92
+ /**
93
+ * Schema for the JSON body Commerce POSTs to a worker mass action handler.
94
+ *
95
+ * Commerce sends one request per chunk of selected IDs (currently up to 1000
96
+ * IDs per request). The upper bound is the Commerce side's contract and is not
97
+ * enforced here.
98
+ */
99
+ declare const MassActionRequestSchema: v.ObjectSchema<{
100
+ readonly gridType: v.PicklistSchema<["order", "product", "customer"], undefined>;
101
+ readonly requestId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
102
+ readonly selectedIds: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>, undefined>, v.MinLengthAction<string[], 1, "The value of \"selectedIds\" must contain at least one entry">]>;
103
+ }, undefined>;
104
+ //#endregion
105
+ //#region source/mass-actions/worker/types.d.ts
106
+ /** Grid identifier sent on the wire by a worker mass action request. */
107
+ type MassActionGridType = v.InferOutput<typeof MassActionGridTypeSchema>;
108
+ /** Parsed request body sent by Commerce to a worker mass action handler. */
109
+ type MassActionRequest = v.InferOutput<typeof MassActionRequestSchema>;
110
+ /** Response body returned to Commerce after a worker mass action completes. */
111
+ type MassActionResponseBody = Record<string, unknown>;
112
+ /** Error body returned to Commerce when a worker mass action fails. */
113
+ type MassActionErrorBody = {
114
+ message: string;
115
+ };
116
+ //#endregion
117
+ //#region source/mass-actions/worker/presets.d.ts
118
+ /**
119
+ * Parses and validates the JSON body Commerce POSTs to a worker mass action handler.
120
+ *
121
+ * Throws a `CommerceSdkValidationError` if the input is malformed.
122
+ *
123
+ * @example
124
+ * ```ts
125
+ * import { parseMassActionRequest } from "@adobe/aio-commerce-lib-admin-ui/mass-actions";
126
+ *
127
+ * export async function main(params: unknown) {
128
+ * const { requestId, gridType, selectedIds } = parseMassActionRequest(params);
129
+ * // process selectedIds...
130
+ * }
131
+ * ```
132
+ */
133
+ declare function parseMassActionRequest(input: unknown): MassActionRequest;
134
+ /**
135
+ * Builds an HTTP 200 success response for a worker mass action.
136
+ *
137
+ * Commerce determines success from the HTTP status code. You may optionally
138
+ * include any fields in `body` for your own logging or auditing purposes.
139
+ *
140
+ * @example
141
+ * ```ts
142
+ * return okMassActionResponse();
143
+ * return okMassActionResponse({ exported: selectedIds.length });
144
+ * ```
145
+ */
146
+ declare function okMassActionResponse(body?: MassActionResponseBody): SuccessResponse<MassActionResponseBody>;
147
+ /**
148
+ * Builds an error response for a worker mass action with the given HTTP status code.
149
+ *
150
+ * @param statusCode - The HTTP status code to return.
151
+ * @param errorMessage - Error message included in the response body as `{ message }`.
152
+ *
153
+ * @example
154
+ * ```ts
155
+ * return massActionErrorResponse(422, "Request entity is unprocessable");
156
+ * ```
157
+ */
158
+ declare function massActionErrorResponse(statusCode: number, errorMessage: string): ErrorResponse<MassActionErrorBody>;
159
+ //#endregion
160
+ export { type AdminUiEntity, type MassActionErrorBody, type MassActionGridType, MassActionGridTypeSchema, type MassActionRequest, MassActionRequestSchema, type MassActionResponseBody, type MassActionSelection, MassActionSelectionSchema, getMassActionAclResourceId, massActionErrorResponse, okMassActionResponse, parseMassActionRequest, parseMassActionSelection };