@adobe/aio-commerce-lib-admin-ui 0.1.0 → 0.2.0-alpha-20260722091448

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 +872 -0
  19. package/dist/cjs/web/index.d.cts +206 -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 +206 -0
  35. package/dist/es/web/index.mjs +861 -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,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.mjs";
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 };
@@ -0,0 +1,178 @@
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 { n as sanitizeSegment, t as getAclResourceId } from "../acl-resource-id-pryVxI_c.mjs";
16
+ import { t as nonEmptyStringValueSchema } from "../schemas-BFT8ys8P.mjs";
17
+ import { t as parseOrThrow } from "../utils-COPGW1HO.mjs";
18
+ import * as v from "valibot";
19
+ import { buildErrorResponse, ok } from "@adobe/aio-commerce-lib-core/responses";
20
+
21
+ //#region source/mass-actions/acl-resource-id.ts
22
+ /**
23
+ * Derives the deterministic Commerce ACL resource id for a mass action.
24
+ *
25
+ * The id is assembled as: `getAclResourceId(metadataId)` + `"_<entity>_massactions_"` +
26
+ * sanitized `actionId`. The `entity` value is used verbatim; the `actionId` is sanitized
27
+ * (trimmed, lowercased, non-`[a-z0-9_]` → `_`). `"Magento_CommerceBackendUix::adminuisdk_app_"`
28
+ * in the example is the fixed constant prefix (not a placeholder), and `"_massactions_"` is the
29
+ * literal keyword separator for this component:
30
+ *
31
+ * @example
32
+ * ```
33
+ * getMassActionAclResourceId("approval-dashboard-app", "order", "bulk-approve")
34
+ * // getAclResourceId("approval-dashboard-app") + "_order_massactions_" + sanitize("bulk-approve")
35
+ * // "Magento_CommerceBackendUix::adminuisdk_app_approval_dashboard_app" + "_order_massactions_" + "bulk_approve"
36
+ * // → "Magento_CommerceBackendUix::adminuisdk_app_approval_dashboard_app_order_massactions_bulk_approve"
37
+ * ```
38
+ *
39
+ * @param metadataId - The application's `metadata.id` value (e.g. `"approval-dashboard-app"`).
40
+ * @param entity - The grid's Commerce entity (`"order"`, `"product"`, or `"customer"`).
41
+ * @param actionId - The action's `id` value from `adminUi.<entity>.massActions[].id`.
42
+ * @returns The full Commerce ACL resource id for the mass-action leaf node, or an empty string
43
+ * when `metadataId` is blank.
44
+ */
45
+ function getMassActionAclResourceId(metadataId, entity, actionId) {
46
+ const appRoot = getAclResourceId(metadataId);
47
+ if (appRoot === "") return "";
48
+ return `${appRoot}_${entity}_massactions_${sanitizeSegment(actionId)}`;
49
+ }
50
+
51
+ //#endregion
52
+ //#region source/mass-actions/view/schema.ts
53
+ /**
54
+ * Schema for the `selection` query parameter Commerce appends to the iframe URL
55
+ * of a view mass action.
56
+ *
57
+ * Commerce serializes the selection as a JSON-encoded string:
58
+ * `?selection={"ids":["000000001"],"gridType":"customer"}`
59
+ */
60
+ const MassActionSelectionSchema = v.object({
61
+ gridType: v.picklist([
62
+ "order",
63
+ "product",
64
+ "customer"
65
+ ]),
66
+ ids: v.pipe(v.array(nonEmptyStringValueSchema("id")), v.minLength(1, "The value of \"ids\" must contain at least one entry"))
67
+ });
68
+
69
+ //#endregion
70
+ //#region source/mass-actions/view/presets.ts
71
+ /**
72
+ * Parses the `selection` query parameter Commerce appends to the iframe URL of
73
+ * a view mass action.
74
+ *
75
+ * Commerce serializes the selection as a JSON string:
76
+ * `?selection={"ids":["000000001","000000002"],"gridType":"customer"}`
77
+ *
78
+ * Throws a `CommerceSdkValidationError` if the input is missing, not valid
79
+ * JSON, or does not match the expected shape.
80
+ *
81
+ * @param rawSelection - The raw string value of the `selection` query parameter.
82
+ *
83
+ * @example
84
+ * ```ts
85
+ * import { parseMassActionSelection } from "@adobe/aio-commerce-lib-admin-ui/mass-actions";
86
+ *
87
+ * // In your SPA route handler:
88
+ * const raw = new URLSearchParams(window.location.search).get("selection");
89
+ * const { ids, gridType } = parseMassActionSelection(raw);
90
+ * ```
91
+ */
92
+ function parseMassActionSelection(rawSelection) {
93
+ if (rawSelection === null || rawSelection === void 0) throw new Error("Invalid mass action selection: the selection query parameter is missing.");
94
+ let parsed;
95
+ try {
96
+ parsed = JSON.parse(String(rawSelection));
97
+ } catch (error) {
98
+ throw new Error(`Invalid mass action selection: expected a JSON string, got: ${String(rawSelection)}`, { cause: error });
99
+ }
100
+ return parseOrThrow(MassActionSelectionSchema, parsed, "Invalid mass action selection");
101
+ }
102
+
103
+ //#endregion
104
+ //#region source/mass-actions/worker/schema.ts
105
+ /**
106
+ * Grid identifier sent by Commerce on the `commerce/backend-ui/2` wire contract
107
+ * for worker mass actions.
108
+ */
109
+ const MassActionGridTypeSchema = v.picklist([
110
+ "order",
111
+ "product",
112
+ "customer"
113
+ ]);
114
+ /**
115
+ * Schema for the JSON body Commerce POSTs to a worker mass action handler.
116
+ *
117
+ * Commerce sends one request per chunk of selected IDs (currently up to 1000
118
+ * IDs per request). The upper bound is the Commerce side's contract and is not
119
+ * enforced here.
120
+ */
121
+ const MassActionRequestSchema = v.object({
122
+ gridType: MassActionGridTypeSchema,
123
+ requestId: nonEmptyStringValueSchema("requestId"),
124
+ selectedIds: v.pipe(v.array(nonEmptyStringValueSchema("id")), v.minLength(1, "The value of \"selectedIds\" must contain at least one entry"))
125
+ });
126
+
127
+ //#endregion
128
+ //#region source/mass-actions/worker/presets.ts
129
+ /**
130
+ * Parses and validates the JSON body Commerce POSTs to a worker mass action handler.
131
+ *
132
+ * Throws a `CommerceSdkValidationError` if the input is malformed.
133
+ *
134
+ * @example
135
+ * ```ts
136
+ * import { parseMassActionRequest } from "@adobe/aio-commerce-lib-admin-ui/mass-actions";
137
+ *
138
+ * export async function main(params: unknown) {
139
+ * const { requestId, gridType, selectedIds } = parseMassActionRequest(params);
140
+ * // process selectedIds...
141
+ * }
142
+ * ```
143
+ */
144
+ function parseMassActionRequest(input) {
145
+ return parseOrThrow(MassActionRequestSchema, input, "Invalid mass action request");
146
+ }
147
+ /**
148
+ * Builds an HTTP 200 success response for a worker mass action.
149
+ *
150
+ * Commerce determines success from the HTTP status code. You may optionally
151
+ * include any fields in `body` for your own logging or auditing purposes.
152
+ *
153
+ * @example
154
+ * ```ts
155
+ * return okMassActionResponse();
156
+ * return okMassActionResponse({ exported: selectedIds.length });
157
+ * ```
158
+ */
159
+ function okMassActionResponse(body = {}) {
160
+ return ok({ body });
161
+ }
162
+ /**
163
+ * Builds an error response for a worker mass action with the given HTTP status code.
164
+ *
165
+ * @param statusCode - The HTTP status code to return.
166
+ * @param errorMessage - Error message included in the response body as `{ message }`.
167
+ *
168
+ * @example
169
+ * ```ts
170
+ * return massActionErrorResponse(422, "Request entity is unprocessable");
171
+ * ```
172
+ */
173
+ function massActionErrorResponse(statusCode, errorMessage) {
174
+ return buildErrorResponse(statusCode, { body: { message: errorMessage } });
175
+ }
176
+
177
+ //#endregion
178
+ export { MassActionGridTypeSchema, MassActionRequestSchema, MassActionSelectionSchema, getMassActionAclResourceId, massActionErrorResponse, okMassActionResponse, parseMassActionRequest, parseMassActionSelection };
@@ -0,0 +1,63 @@
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
+ //#region source/menu/acl-resource-id.d.ts
16
+ /**
17
+ * Derives the deterministic Commerce ACL resource id for a specific menu item.
18
+ *
19
+ * The id is assembled as: `getAclResourceId(metadataId)` + `"_menu_"` + sanitized `menuId`.
20
+ * Each segment is sanitized independently (trimmed, lowercased, non-`[a-z0-9_]` → `_`).
21
+ * `"Magento_CommerceBackendUix::adminuisdk_app_"` in the example is the fixed constant prefix
22
+ * (not a placeholder), and `"_menu_"` is the literal keyword separator for this component:
23
+ *
24
+ * @example
25
+ * ```
26
+ * getMenuAclResourceId("approval-dashboard-app", "approval_dashboard")
27
+ * // getAclResourceId("approval-dashboard-app") + "_menu_" + sanitize("approval_dashboard")
28
+ * // "Magento_CommerceBackendUix::adminuisdk_app_approval_dashboard_app" + "_menu_" + "approval_dashboard"
29
+ * // → "Magento_CommerceBackendUix::adminuisdk_app_approval_dashboard_app_menu_approval_dashboard"
30
+ * ```
31
+ *
32
+ * @param metadataId - The application's `metadata.id` value (e.g. `"approval-dashboard-app"`).
33
+ * @param menuId - The menu item's `id` value from `adminUi.menu.id` (e.g. `"approval_dashboard"`).
34
+ * @returns The full Commerce ACL resource id for the menu leaf node, or an empty string
35
+ * when `metadataId` is blank.
36
+ */
37
+ declare function getMenuAclResourceId(metadataId: string, menuId: string): string;
38
+ //#endregion
39
+ //#region source/menu/paths.d.ts
40
+ /** Menu ID for "Catalog" in the Adobe Commerce admin */
41
+ declare const MENU_CATALOG = "catalog";
42
+ /** Menu ID for "Customers" in the Adobe Commerce admin */
43
+ declare const MENU_CUSTOMERS = "customers";
44
+ /** Menu ID for "Marketing" in the Adobe Commerce admin */
45
+ declare const MENU_MARKETING = "marketing";
46
+ /** Menu ID for "Content" in the Adobe Commerce admin */
47
+ declare const MENU_CONTENT = "content";
48
+ /** Menu ID for "Reports" in the Adobe Commerce admin */
49
+ declare const MENU_REPORTS = "reports";
50
+ /** Menu ID for "Sales" in the Adobe Commerce admin */
51
+ declare const MENU_SALES = "sales";
52
+ /** Menu ID for "Stores" in the Adobe Commerce admin */
53
+ declare const MENU_STORES = "stores";
54
+ /** Menu ID for "System" in the Adobe Commerce admin */
55
+ declare const MENU_SYSTEM = "system";
56
+ /** All Commerce Admin menus available for app attachment. */
57
+ declare const COMMERCE_MENUS: readonly ["sales", "catalog", "customers", "marketing", "content", "reports", "stores", "system"];
58
+ /** A union type of all known supported Commerce Admin menu IDs. */
59
+ type CommerceMenu = (typeof COMMERCE_MENUS)[number];
60
+ /** Returns true if the given string is a known Commerce Admin menu ID. */
61
+ declare function isCommerceMenu(menu: string): menu is CommerceMenu;
62
+ //#endregion
63
+ export { COMMERCE_MENUS, CommerceMenu, MENU_CATALOG, MENU_CONTENT, MENU_CUSTOMERS, MENU_MARKETING, MENU_REPORTS, MENU_SALES, MENU_STORES, MENU_SYSTEM, getMenuAclResourceId, isCommerceMenu };
@@ -0,0 +1,80 @@
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 { n as sanitizeSegment, t as getAclResourceId } from "../acl-resource-id-pryVxI_c.mjs";
16
+
17
+ //#region source/menu/acl-resource-id.ts
18
+ /**
19
+ * Derives the deterministic Commerce ACL resource id for a specific menu item.
20
+ *
21
+ * The id is assembled as: `getAclResourceId(metadataId)` + `"_menu_"` + sanitized `menuId`.
22
+ * Each segment is sanitized independently (trimmed, lowercased, non-`[a-z0-9_]` → `_`).
23
+ * `"Magento_CommerceBackendUix::adminuisdk_app_"` in the example is the fixed constant prefix
24
+ * (not a placeholder), and `"_menu_"` is the literal keyword separator for this component:
25
+ *
26
+ * @example
27
+ * ```
28
+ * getMenuAclResourceId("approval-dashboard-app", "approval_dashboard")
29
+ * // getAclResourceId("approval-dashboard-app") + "_menu_" + sanitize("approval_dashboard")
30
+ * // "Magento_CommerceBackendUix::adminuisdk_app_approval_dashboard_app" + "_menu_" + "approval_dashboard"
31
+ * // → "Magento_CommerceBackendUix::adminuisdk_app_approval_dashboard_app_menu_approval_dashboard"
32
+ * ```
33
+ *
34
+ * @param metadataId - The application's `metadata.id` value (e.g. `"approval-dashboard-app"`).
35
+ * @param menuId - The menu item's `id` value from `adminUi.menu.id` (e.g. `"approval_dashboard"`).
36
+ * @returns The full Commerce ACL resource id for the menu leaf node, or an empty string
37
+ * when `metadataId` is blank.
38
+ */
39
+ function getMenuAclResourceId(metadataId, menuId) {
40
+ const appRoot = getAclResourceId(metadataId);
41
+ if (appRoot === "") return "";
42
+ return `${appRoot}_menu_${sanitizeSegment(menuId)}`;
43
+ }
44
+
45
+ //#endregion
46
+ //#region source/menu/paths.ts
47
+ /** Menu ID for "Catalog" in the Adobe Commerce admin */
48
+ const MENU_CATALOG = "catalog";
49
+ /** Menu ID for "Customers" in the Adobe Commerce admin */
50
+ const MENU_CUSTOMERS = "customers";
51
+ /** Menu ID for "Marketing" in the Adobe Commerce admin */
52
+ const MENU_MARKETING = "marketing";
53
+ /** Menu ID for "Content" in the Adobe Commerce admin */
54
+ const MENU_CONTENT = "content";
55
+ /** Menu ID for "Reports" in the Adobe Commerce admin */
56
+ const MENU_REPORTS = "reports";
57
+ /** Menu ID for "Sales" in the Adobe Commerce admin */
58
+ const MENU_SALES = "sales";
59
+ /** Menu ID for "Stores" in the Adobe Commerce admin */
60
+ const MENU_STORES = "stores";
61
+ /** Menu ID for "System" in the Adobe Commerce admin */
62
+ const MENU_SYSTEM = "system";
63
+ /** All Commerce Admin menus available for app attachment. */
64
+ const COMMERCE_MENUS = [
65
+ MENU_SALES,
66
+ MENU_CATALOG,
67
+ MENU_CUSTOMERS,
68
+ MENU_MARKETING,
69
+ MENU_CONTENT,
70
+ MENU_REPORTS,
71
+ MENU_STORES,
72
+ MENU_SYSTEM
73
+ ];
74
+ /** Returns true if the given string is a known Commerce Admin menu ID. */
75
+ function isCommerceMenu(menu) {
76
+ return COMMERCE_MENUS.includes(menu);
77
+ }
78
+
79
+ //#endregion
80
+ export { COMMERCE_MENUS, MENU_CATALOG, MENU_CONTENT, MENU_CUSTOMERS, MENU_MARKETING, MENU_REPORTS, MENU_SALES, MENU_STORES, MENU_SYSTEM, getMenuAclResourceId, isCommerceMenu };
@@ -0,0 +1,113 @@
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 * as v from "valibot";
16
+ import { ErrorResponse, SuccessResponse } from "@adobe/aio-commerce-lib-core/responses";
17
+
18
+ //#region source/order-view-buttons/acl-resource-id.d.ts
19
+ /**
20
+ * Derives the deterministic Commerce ACL resource id for an order view button.
21
+ *
22
+ * View buttons exist only on the order entity, so no entity discriminator is needed.
23
+ * The id is assembled as: `getAclResourceId(metadataId)` + `"_order_viewbuttons_"` +
24
+ * sanitized `buttonId`. The `buttonId` is sanitized (trimmed, lowercased, non-`[a-z0-9_]` → `_`).
25
+ * `"Magento_CommerceBackendUix::adminuisdk_app_"` in the example is the fixed constant prefix
26
+ * (not a placeholder), and `"_order_viewbuttons_"` is the literal keyword separator for this component:
27
+ *
28
+ * @example
29
+ * ```
30
+ * getOrderViewButtonAclResourceId("approval-dashboard-app", "approve-order")
31
+ * // getAclResourceId("approval-dashboard-app") + "_order_viewbuttons_" + sanitize("approve-order")
32
+ * // "Magento_CommerceBackendUix::adminuisdk_app_approval_dashboard_app" + "_order_viewbuttons_" + "approve_order"
33
+ * // → "Magento_CommerceBackendUix::adminuisdk_app_approval_dashboard_app_order_viewbuttons_approve_order"
34
+ * ```
35
+ *
36
+ * @param metadataId - The application's `metadata.id` value (e.g. `"approval-dashboard-app"`).
37
+ * @param buttonId - The button's `id` value from `adminUi.order.viewButtons[].id`.
38
+ * @returns The full Commerce ACL resource id for the view-button leaf node, or an empty string
39
+ * when `metadataId` is blank.
40
+ */
41
+ declare function getOrderViewButtonAclResourceId(metadataId: string, buttonId: string): string;
42
+ //#endregion
43
+ //#region source/order-view-buttons/schema.d.ts
44
+ /**
45
+ * Schema for the JSON body Commerce POSTs to an order view button handler.
46
+ *
47
+ * `id` identifies the specific button that was clicked, letting a single
48
+ * handler serve multiple buttons by branching on it. `orderId` is the
49
+ * single order currently being viewed.
50
+ */
51
+ declare const OrderViewButtonRequestSchema: v.ObjectSchema<{
52
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
53
+ readonly orderId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
54
+ readonly requestId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
55
+ }, undefined>;
56
+ //#endregion
57
+ //#region source/order-view-buttons/types.d.ts
58
+ /** Parsed request body sent by Commerce to an order view button handler. */
59
+ type OrderViewButtonRequest = v.InferOutput<typeof OrderViewButtonRequestSchema>;
60
+ /** Success body returned to Commerce — an empty object signals success. */
61
+ type OrderViewButtonSuccessBody = Record<string, never>;
62
+ /** Failure body returned to Commerce when a worker order view button handler fails. */
63
+ type OrderViewButtonErrorBody = {
64
+ message: string;
65
+ };
66
+ //#endregion
67
+ //#region source/order-view-buttons/presets.d.ts
68
+ /**
69
+ * Parses and validates the JSON body Commerce POSTs to an order view button handler.
70
+ *
71
+ * Throws a `CommerceSdkValidationError` if the input is malformed.
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * import { parseOrderViewButtonRequest } from "@adobe/aio-commerce-lib-admin-ui/order-view-buttons";
76
+ *
77
+ * export async function main(params: unknown) {
78
+ * const { requestId, id, orderId } = parseOrderViewButtonRequest(params);
79
+ * // id identifies which button was clicked
80
+ * // orderId is the order currently being viewed
81
+ * // ...
82
+ * }
83
+ * ```
84
+ */
85
+ declare function parseOrderViewButtonRequest(input: unknown): OrderViewButtonRequest;
86
+ /**
87
+ * Builds an HTTP 200 success response for an order view button handler.
88
+ *
89
+ * Commerce renders `notifications.success` from the registration as the
90
+ * toast body when present, and a default success toast otherwise.
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * return okOrderViewButtonResponse();
95
+ * ```
96
+ */
97
+ declare function okOrderViewButtonResponse(): SuccessResponse<OrderViewButtonSuccessBody>;
98
+ /**
99
+ * Builds an error response for a worker order view button handler with the given HTTP status code.
100
+ *
101
+ * Commerce uses the HTTP status code to distinguish success from failure.
102
+ *
103
+ * @param statusCode - The HTTP status code to return.
104
+ * @param errorMessage - Error message included in the response body as `{ message }`.
105
+ *
106
+ * @example
107
+ * ```ts
108
+ * return orderViewButtonErrorResponse(500, "Could not reach inventory service");
109
+ * ```
110
+ */
111
+ declare function orderViewButtonErrorResponse(statusCode: number, errorMessage: string): ErrorResponse<OrderViewButtonErrorBody>;
112
+ //#endregion
113
+ export { type OrderViewButtonErrorBody, type OrderViewButtonRequest, OrderViewButtonRequestSchema, type OrderViewButtonSuccessBody, getOrderViewButtonAclResourceId, okOrderViewButtonResponse, orderViewButtonErrorResponse, parseOrderViewButtonRequest };