@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,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 };
@@ -0,0 +1,119 @@
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/order-view-buttons/acl-resource-id.ts
22
+ /**
23
+ * Derives the deterministic Commerce ACL resource id for an order view button.
24
+ *
25
+ * View buttons exist only on the order entity, so no entity discriminator is needed.
26
+ * The id is assembled as: `getAclResourceId(metadataId)` + `"_order_viewbuttons_"` +
27
+ * sanitized `buttonId`. The `buttonId` is sanitized (trimmed, lowercased, non-`[a-z0-9_]` → `_`).
28
+ * `"Magento_CommerceBackendUix::adminuisdk_app_"` in the example is the fixed constant prefix
29
+ * (not a placeholder), and `"_order_viewbuttons_"` is the literal keyword separator for this component:
30
+ *
31
+ * @example
32
+ * ```
33
+ * getOrderViewButtonAclResourceId("approval-dashboard-app", "approve-order")
34
+ * // getAclResourceId("approval-dashboard-app") + "_order_viewbuttons_" + sanitize("approve-order")
35
+ * // "Magento_CommerceBackendUix::adminuisdk_app_approval_dashboard_app" + "_order_viewbuttons_" + "approve_order"
36
+ * // → "Magento_CommerceBackendUix::adminuisdk_app_approval_dashboard_app_order_viewbuttons_approve_order"
37
+ * ```
38
+ *
39
+ * @param metadataId - The application's `metadata.id` value (e.g. `"approval-dashboard-app"`).
40
+ * @param buttonId - The button's `id` value from `adminUi.order.viewButtons[].id`.
41
+ * @returns The full Commerce ACL resource id for the view-button leaf node, or an empty string
42
+ * when `metadataId` is blank.
43
+ */
44
+ function getOrderViewButtonAclResourceId(metadataId, buttonId) {
45
+ const appRoot = getAclResourceId(metadataId);
46
+ if (appRoot === "") return "";
47
+ return `${appRoot}_order_viewbuttons_${sanitizeSegment(buttonId)}`;
48
+ }
49
+
50
+ //#endregion
51
+ //#region source/order-view-buttons/schema.ts
52
+ /**
53
+ * Schema for the JSON body Commerce POSTs to an order view button handler.
54
+ *
55
+ * `id` identifies the specific button that was clicked, letting a single
56
+ * handler serve multiple buttons by branching on it. `orderId` is the
57
+ * single order currently being viewed.
58
+ */
59
+ const OrderViewButtonRequestSchema = v.object({
60
+ id: nonEmptyStringValueSchema("id"),
61
+ orderId: nonEmptyStringValueSchema("orderId"),
62
+ requestId: nonEmptyStringValueSchema("requestId")
63
+ });
64
+
65
+ //#endregion
66
+ //#region source/order-view-buttons/presets.ts
67
+ /**
68
+ * Parses and validates the JSON body Commerce POSTs to an order view button handler.
69
+ *
70
+ * Throws a `CommerceSdkValidationError` if the input is malformed.
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * import { parseOrderViewButtonRequest } from "@adobe/aio-commerce-lib-admin-ui/order-view-buttons";
75
+ *
76
+ * export async function main(params: unknown) {
77
+ * const { requestId, id, orderId } = parseOrderViewButtonRequest(params);
78
+ * // id identifies which button was clicked
79
+ * // orderId is the order currently being viewed
80
+ * // ...
81
+ * }
82
+ * ```
83
+ */
84
+ function parseOrderViewButtonRequest(input) {
85
+ return parseOrThrow(OrderViewButtonRequestSchema, input, "Invalid order view button request");
86
+ }
87
+ /**
88
+ * Builds an HTTP 200 success response for an order view button handler.
89
+ *
90
+ * Commerce renders `notifications.success` from the registration as the
91
+ * toast body when present, and a default success toast otherwise.
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * return okOrderViewButtonResponse();
96
+ * ```
97
+ */
98
+ function okOrderViewButtonResponse() {
99
+ return ok({ body: {} });
100
+ }
101
+ /**
102
+ * Builds an error response for a worker order view button handler with the given HTTP status code.
103
+ *
104
+ * Commerce uses the HTTP status code to distinguish success from failure.
105
+ *
106
+ * @param statusCode - The HTTP status code to return.
107
+ * @param errorMessage - Error message included in the response body as `{ message }`.
108
+ *
109
+ * @example
110
+ * ```ts
111
+ * return orderViewButtonErrorResponse(500, "Could not reach inventory service");
112
+ * ```
113
+ */
114
+ function orderViewButtonErrorResponse(statusCode, errorMessage) {
115
+ return buildErrorResponse(statusCode, { body: { message: errorMessage } });
116
+ }
117
+
118
+ //#endregion
119
+ export { OrderViewButtonRequestSchema, getOrderViewButtonAclResourceId, okOrderViewButtonResponse, orderViewButtonErrorResponse, parseOrderViewButtonRequest };
@@ -0,0 +1,34 @@
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
+
17
+ //#region ../../packages-private/common-utils/source/valibot/schemas.ts
18
+ /**
19
+ * A schema for a string value.
20
+ * @param name The name of the field this schema refers to.
21
+ */
22
+ function stringValueSchema(name) {
23
+ return v.string(`Expected a string value for '${name}'`);
24
+ }
25
+ /**
26
+ * A schema for a non-empty string value.
27
+ * @param name The name of the field this schema refers to.
28
+ */
29
+ function nonEmptyStringValueSchema(name) {
30
+ return v.pipe(stringValueSchema(name), v.nonEmpty(`The value of "${name}" must not be empty`));
31
+ }
32
+
33
+ //#endregion
34
+ export { nonEmptyStringValueSchema as t };
@@ -0,0 +1,32 @@
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 { CommerceSdkValidationError } from "@adobe/aio-commerce-lib-core/error";
16
+ import * as v from "valibot";
17
+
18
+ //#region ../../packages-private/common-utils/source/valibot/utils.ts
19
+ /**
20
+ * Parses the input using the provided schema and throws a {@link CommerceSdkValidationError} error if the input is invalid.
21
+ * @param schema - The schema to use for parsing.
22
+ * @param input - The input to parse.
23
+ * @param message - Optional custom error message for the validation error.
24
+ */
25
+ function parseOrThrow(schema, input, message) {
26
+ const result = v.safeParse(schema, input);
27
+ if (!result.success) throw new CommerceSdkValidationError(message ?? "Invalid input", { issues: result.issues });
28
+ return result.output;
29
+ }
30
+
31
+ //#endregion
32
+ export { parseOrThrow as t };
@@ -0,0 +1,192 @@
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 { ReactNode } from "react";
16
+ import { NavigateOptions, ToOptions } from "@tanstack/react-router";
17
+ import { attach } from "@adobe/uix-guest";
18
+
19
+ //#region source/web/react/auth/types.d.ts
20
+ /** The IMS credentials provided by the host (Commerce Admin or Experience Cloud shell). */
21
+ type ImsContext = {
22
+ imsToken: string;
23
+ imsOrgId: string;
24
+ };
25
+ //#endregion
26
+ //#region source/web/react/auth/context/ims-context.d.ts
27
+ /**
28
+ * Returns the IMS credentials provided by the host. Works inside the Commerce Admin and the
29
+ * Experience Cloud shell.
30
+ *
31
+ * @throws If no host provides credentials (e.g. the app is running standalone, outside both the
32
+ * Commerce Admin and the Experience Cloud shell).
33
+ */
34
+ declare function useIms(): ImsContext;
35
+ //#endregion
36
+ //#region source/web/react/commerce/types.d.ts
37
+ /** The guest connection that shares the context between the extension and the Admin UI host. */
38
+ type GuestConnection = Awaited<ReturnType<typeof attach>>;
39
+ /**
40
+ * The Commerce shared context for a mounted Admin UI iframe app.
41
+ *
42
+ * This only exists when the app runs inside the Commerce Admin: it is provided by the Commerce UIX
43
+ * host over the guest connection. It is distinct from the IMS credentials ({@link ImsContext}),
44
+ * which are also available in the Experience Cloud shell.
45
+ */
46
+ type SharedContext = {
47
+ /** The extension ID of the app. */extensionId: string; /** The live `sharedContext` object provided by the host. */
48
+ sharedContext: NonNullable<GuestConnection["sharedContext"]>; /** The host proxy, used by `useHostConnection` to invoke host-frame actions (close/onError). */
49
+ host: NonNullable<GuestConnection["host"]>;
50
+ };
51
+ /** Actions for closing the extension iframe and returning control to the Commerce Admin. */
52
+ type HostConnection = {
53
+ /** Closes the iframe and navigates back to the originating grid or order. */close: () => Promise<void>; /** Closes the iframe and navigates back, flagging the originating page that an error occurred. */
54
+ closeWithError: () => Promise<void>;
55
+ };
56
+ /** The context shared with mass-action extension points. */
57
+ type MassActionContext = {
58
+ selectedIds: string[];
59
+ };
60
+ /** The context shared with order view-button extension points. */
61
+ type OrderViewButtonContext = {
62
+ orderId: string;
63
+ };
64
+ //#endregion
65
+ //#region source/web/react/commerce/context/shared-context.d.ts
66
+ /**
67
+ * Returns the current Commerce shared context. The guest connection is already established by
68
+ * the time this can be called (see {@link SharedContextProvider}).
69
+ *
70
+ * This is a low-level escape hatch that exposes the raw `sharedContext` and `host` objects.
71
+ * Prefer a purpose-built hook ({@link useCommerce}, {@link useMassActionContext},
72
+ * {@link useOrderViewButtonContext}) when one covers what you need.
73
+ *
74
+ * @throws If used outside a {@link SharedContextProvider}.
75
+ *
76
+ * @example
77
+ * ```tsx
78
+ * import { useSharedContext } from "@adobe/aio-commerce-lib-admin-ui/web";
79
+ *
80
+ * function ImsTokenLabel() {
81
+ * const { sharedContext } = useSharedContext();
82
+ * return <span>{sharedContext.get("imsToken")}</span>;
83
+ * }
84
+ * ```
85
+ */
86
+ declare function useSharedContext(): SharedContext;
87
+ //#endregion
88
+ //#region source/web/react/commerce/hooks/use-commerce.d.ts
89
+ /**
90
+ * Returns the host (domain) of the Commerce Admin the extension is embedded in, resolving it over
91
+ * the guest connection.
92
+ *
93
+ * @throws If used outside a Commerce Admin UI frame, or when the host does not expose the
94
+ * Commerce integration API.
95
+ */
96
+ declare function useCommerce(): {
97
+ commerceHost: string;
98
+ };
99
+ //#endregion
100
+ //#region source/web/react/commerce/hooks/use-extension-context.d.ts
101
+ /**
102
+ * Returns the context for a mass-action extension point: the selected row IDs the action was
103
+ * triggered with. The value is read from the host-provided Commerce context.
104
+ *
105
+ * @throws If used outside the Commerce shared context, or when that context does not include a
106
+ * mass-action selection.
107
+ */
108
+ declare function useMassActionContext(): MassActionContext;
109
+ /**
110
+ * Returns the context for an order view-button extension point: the order ID the button was
111
+ * triggered from.
112
+ *
113
+ * @throws If no order ID is present in the page URL.
114
+ */
115
+ declare function useOrderViewButtonContext(): OrderViewButtonContext;
116
+ //#endregion
117
+ //#region source/web/react/commerce/hooks/use-host-connection.d.ts
118
+ /**
119
+ * Returns typed helpers for interacting with the Commerce Admin host.
120
+ *
121
+ * @throws If called before the guest connection is established, or when the host frame actions
122
+ * are unavailable.
123
+ *
124
+ * @example
125
+ * ```tsx
126
+ * import { useHostConnection } from "@adobe/aio-commerce-lib-admin-ui/web";
127
+ *
128
+ * function DoneButton() {
129
+ * const { close } = useHostConnection();
130
+ * return <button onClick={() => void close()}>Done</button>;
131
+ * }
132
+ * ```
133
+ */
134
+ declare function useHostConnection(): HostConnection;
135
+ //#endregion
136
+ //#region source/web/react/routing/types.d.ts
137
+ declare module "@react-spectrum/s2/Provider" {
138
+ interface RouterConfig {
139
+ href: ToOptions;
140
+ routerOptions: Omit<NavigateOptions, keyof ToOptions>;
141
+ }
142
+ }
143
+ /** Defines a route that is marked as the index (entrypoint) */
144
+ type IndexRoute = {
145
+ index: true; /** The React element to render for the index route. */
146
+ element: ReactNode;
147
+ };
148
+ /** Defines a route that exists at a given path. */
149
+ type ExtensionRoute = {
150
+ /** The path for the route. */path: string; /** The React element to render for the route. */
151
+ element: ReactNode;
152
+ };
153
+ /** Defines the routes for an extension app, which must include at least one index route (first item). */
154
+ type ExtensionAppRoutes = [IndexRoute, ...ExtensionRoute[]];
155
+ //#endregion
156
+ //#region source/web/react/extension/create-app.d.ts
157
+ /** Configuration options when instantiating an extension app. */
158
+ type CreateExtensionAppOptions = {
159
+ /** General metadata about the extension app. */metadata: {
160
+ /** The unique identifier for the extension app. */extensionId: string;
161
+ }; /** Optional root element where the app will be mounted. */
162
+ root?: HTMLElement; /** A list of routes for the extension app, specifying an index route is mandatory. */
163
+ routes: ExtensionAppRoutes;
164
+ };
165
+ /**
166
+ * Mounts a Commerce Admin UI iframe app and handles Experience Cloud Shell, UIX
167
+ * registration, shared-context attachment, routing, and Spectrum setup.
168
+ *
169
+ * The app is wrapped in React's `<StrictMode>`, so in development builds (e.g. when
170
+ * served via `aio app dev` or `aio app run`) components render twice and effects run
171
+ * an extra setup + cleanup cycle on mount. Production builds are unaffected.
172
+ *
173
+ * @param options - App bootstrap options.
174
+ *
175
+ * @example
176
+ * ```tsx
177
+ * import { createExtensionApp } from "@adobe/aio-commerce-lib-admin-ui/web";
178
+ * import { MainPage } from "./pages/main-page.jsx";
179
+ *
180
+ * createExtensionApp({
181
+ * metadata: { extensionId: "my-extension-id" },
182
+ * routes: [{ index: true, element: <MainPage /> }],
183
+ * });
184
+ * ```
185
+ */
186
+ declare function createExtensionApp({
187
+ metadata,
188
+ routes,
189
+ root: customRoot
190
+ }: CreateExtensionAppOptions): void;
191
+ //#endregion
192
+ export { type CreateExtensionAppOptions, type ExtensionAppRoutes, type ExtensionRoute, type HostConnection, type ImsContext, type IndexRoute, type MassActionContext, type OrderViewButtonContext, type SharedContext, createExtensionApp, useCommerce, useHostConnection, useIms, useMassActionContext, useOrderViewButtonContext, useSharedContext };