@adobe/aio-commerce-lib-admin-ui 1.1.0-beta-20260820174436 → 1.2.0-beta-20260930143021

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 (34) hide show
  1. package/CHANGELOG.md +23 -1
  2. package/dist/cjs/acl-resource-id-Bha1pOIk.d.cts +85 -0
  3. package/dist/cjs/acl-resource-id-nCj_Kne2.cjs +141 -0
  4. package/dist/cjs/api/index.cjs +4 -2
  5. package/dist/cjs/api/index.d.cts +10 -10
  6. package/dist/cjs/grid-columns/index.cjs +7 -7
  7. package/dist/cjs/grid-columns/index.d.cts +14 -10
  8. package/dist/cjs/mass-actions/index.cjs +3 -7
  9. package/dist/cjs/mass-actions/index.d.cts +10 -10
  10. package/dist/cjs/menu/index.cjs +1 -1
  11. package/dist/cjs/menu/index.d.cts +13 -14
  12. package/dist/cjs/order-view-buttons/index.cjs +1 -1
  13. package/dist/cjs/order-view-buttons/index.d.cts +6 -6
  14. package/dist/cjs/web/index.cjs +4 -4
  15. package/dist/cjs/web/index.d.cts +8 -8
  16. package/dist/es/acl-resource-id-Bha1pOIk.d.mts +85 -0
  17. package/dist/es/acl-resource-id-CHw95qd2.mjs +112 -0
  18. package/dist/es/api/index.d.mts +10 -10
  19. package/dist/es/api/index.mjs +2 -2
  20. package/dist/es/grid-columns/index.d.mts +14 -10
  21. package/dist/es/grid-columns/index.mjs +7 -7
  22. package/dist/es/mass-actions/index.d.mts +10 -10
  23. package/dist/es/mass-actions/index.mjs +3 -7
  24. package/dist/es/menu/index.d.mts +13 -14
  25. package/dist/es/menu/index.mjs +1 -1
  26. package/dist/es/order-view-buttons/index.d.mts +6 -6
  27. package/dist/es/order-view-buttons/index.mjs +1 -1
  28. package/dist/es/web/index.d.mts +8 -8
  29. package/dist/es/web/index.mjs +1 -1
  30. package/package.json +12 -12
  31. package/dist/cjs/acl-resource-id-DBlYU0DE.d.cts +0 -39
  32. package/dist/cjs/acl-resource-id-R52pR3gG.cjs +0 -68
  33. package/dist/es/acl-resource-id-DBlYU0DE.d.mts +0 -39
  34. package/dist/es/acl-resource-id-pryVxI_c.mjs +0 -57
@@ -34,30 +34,29 @@
34
34
  * @returns The full Commerce ACL resource id for the menu leaf node, or an empty string
35
35
  * when `metadataId` is blank.
36
36
  */
37
- declare function getMenuAclResourceId(metadataId: string, menuId: string): string;
37
+ export declare function getMenuAclResourceId(metadataId: string, menuId: string): string;
38
38
  //#endregion
39
39
  //#region source/menu/paths.d.ts
40
40
  /** Menu ID for "Catalog" in the Adobe Commerce admin */
41
- declare const MENU_CATALOG = "catalog";
41
+ export declare const MENU_CATALOG = "catalog";
42
42
  /** Menu ID for "Customers" in the Adobe Commerce admin */
43
- declare const MENU_CUSTOMERS = "customers";
43
+ export declare const MENU_CUSTOMERS = "customers";
44
44
  /** Menu ID for "Marketing" in the Adobe Commerce admin */
45
- declare const MENU_MARKETING = "marketing";
45
+ export declare const MENU_MARKETING = "marketing";
46
46
  /** Menu ID for "Content" in the Adobe Commerce admin */
47
- declare const MENU_CONTENT = "content";
47
+ export declare const MENU_CONTENT = "content";
48
48
  /** Menu ID for "Reports" in the Adobe Commerce admin */
49
- declare const MENU_REPORTS = "reports";
49
+ export declare const MENU_REPORTS = "reports";
50
50
  /** Menu ID for "Sales" in the Adobe Commerce admin */
51
- declare const MENU_SALES = "sales";
51
+ export declare const MENU_SALES = "sales";
52
52
  /** Menu ID for "Stores" in the Adobe Commerce admin */
53
- declare const MENU_STORES = "stores";
53
+ export declare const MENU_STORES = "stores";
54
54
  /** Menu ID for "System" in the Adobe Commerce admin */
55
- declare const MENU_SYSTEM = "system";
55
+ export declare const MENU_SYSTEM = "system";
56
56
  /** All Commerce Admin menus available for app attachment. */
57
- declare const COMMERCE_MENUS: readonly ["sales", "catalog", "customers", "marketing", "content", "reports", "stores", "system"];
57
+ export declare const COMMERCE_MENUS: readonly ["sales", "catalog", "customers", "marketing", "content", "reports", "stores", "system"];
58
58
  /** A union type of all known supported Commerce Admin menu IDs. */
59
- type CommerceMenu = (typeof COMMERCE_MENUS)[number];
59
+ export type CommerceMenu = (typeof COMMERCE_MENUS)[number];
60
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 };
61
+ export declare function isCommerceMenu(menu: string): menu is CommerceMenu;
62
+ //#endregion
@@ -12,7 +12,7 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
- import { n as sanitizeSegment, t as getAclResourceId } from "../acl-resource-id-pryVxI_c.mjs";
15
+ import { a as sanitizeSegment, r as getAclResourceId } from "../acl-resource-id-CHw95qd2.mjs";
16
16
 
17
17
  //#region source/menu/acl-resource-id.ts
18
18
  /**
@@ -37,7 +37,7 @@ import { ErrorResponse, SuccessResponse } from "@adobe/aio-commerce-lib-core/res
37
37
  * @returns The full Commerce ACL resource id for the view-button leaf node, or an empty string
38
38
  * when `metadataId` is blank.
39
39
  */
40
- declare function getOrderViewButtonAclResourceId(metadataId: string, buttonId: string): string;
40
+ export declare function getOrderViewButtonAclResourceId(metadataId: string, buttonId: string): string;
41
41
  //#endregion
42
42
  //#region source/order-view-buttons/schema.d.ts
43
43
  /**
@@ -47,7 +47,7 @@ declare function getOrderViewButtonAclResourceId(metadataId: string, buttonId: s
47
47
  * handler serve multiple buttons by branching on it. `orderId` is the
48
48
  * single order currently being viewed.
49
49
  */
50
- declare const OrderViewButtonRequestSchema: v.ObjectSchema<{
50
+ export declare const OrderViewButtonRequestSchema: v.ObjectSchema<{
51
51
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
52
52
  readonly orderId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
53
53
  readonly requestId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
@@ -81,7 +81,7 @@ type OrderViewButtonErrorBody = {
81
81
  * }
82
82
  * ```
83
83
  */
84
- declare function parseOrderViewButtonRequest(input: unknown): OrderViewButtonRequest;
84
+ export declare function parseOrderViewButtonRequest(input: unknown): OrderViewButtonRequest;
85
85
  /**
86
86
  * Builds an HTTP 200 success response for an order view button handler.
87
87
  *
@@ -93,7 +93,7 @@ declare function parseOrderViewButtonRequest(input: unknown): OrderViewButtonReq
93
93
  * return okOrderViewButtonResponse();
94
94
  * ```
95
95
  */
96
- declare function okOrderViewButtonResponse(): SuccessResponse<OrderViewButtonSuccessBody>;
96
+ export declare function okOrderViewButtonResponse(): SuccessResponse<OrderViewButtonSuccessBody>;
97
97
  /**
98
98
  * Builds an error response for a worker order view button handler with the given HTTP status code.
99
99
  *
@@ -107,6 +107,6 @@ declare function okOrderViewButtonResponse(): SuccessResponse<OrderViewButtonSuc
107
107
  * return orderViewButtonErrorResponse(500, "Could not reach inventory service");
108
108
  * ```
109
109
  */
110
- declare function orderViewButtonErrorResponse(statusCode: number, errorMessage: string): ErrorResponse<OrderViewButtonErrorBody>;
110
+ export declare function orderViewButtonErrorResponse(statusCode: number, errorMessage: string): ErrorResponse<OrderViewButtonErrorBody>;
111
111
  //#endregion
112
- export { type OrderViewButtonErrorBody, type OrderViewButtonRequest, OrderViewButtonRequestSchema, type OrderViewButtonSuccessBody, getOrderViewButtonAclResourceId, okOrderViewButtonResponse, orderViewButtonErrorResponse, parseOrderViewButtonRequest };
112
+ export type { OrderViewButtonErrorBody, OrderViewButtonRequest, OrderViewButtonSuccessBody };
@@ -12,7 +12,7 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
- import { n as sanitizeSegment, t as getAclResourceId } from "../acl-resource-id-pryVxI_c.mjs";
15
+ import { a as sanitizeSegment, r as getAclResourceId } from "../acl-resource-id-CHw95qd2.mjs";
16
16
  import { t as nonEmptyStringValueSchema } from "../schemas-BFT8ys8P.mjs";
17
17
  import { t as parseOrThrow } from "../utils-COPGW1HO.mjs";
18
18
  import * as v from "valibot";
@@ -50,7 +50,7 @@ type ActionsResult<T extends ActionMap, E = Error> = {
50
50
  *
51
51
  * Returns an error when no host provides credentials.
52
52
  */
53
- declare function useIms(): Result<ImsContext>;
53
+ export declare function useIms(): Result<ImsContext>;
54
54
  //#endregion
55
55
  //#region source/web/react/commerce/types.d.ts
56
56
  /** The guest connection that shares the context between the extension and the Admin UI host. */
@@ -106,7 +106,7 @@ type OrderViewButtonContext = {
106
106
  * }
107
107
  * ```
108
108
  */
109
- declare function useSharedContext(): Result<SharedContext>;
109
+ export declare function useSharedContext(): Result<SharedContext>;
110
110
  //#endregion
111
111
  //#region source/web/react/commerce/hooks/use-commerce.d.ts
112
112
  type CommerceData = {
@@ -119,7 +119,7 @@ type CommerceData = {
119
119
  * Returns an error when used outside a Commerce Admin UI frame, when the host does not expose the
120
120
  * Commerce integration API, or when resolving the host fails.
121
121
  */
122
- declare function useCommerce(): Result<CommerceData>;
122
+ export declare function useCommerce(): Result<CommerceData>;
123
123
  //#endregion
124
124
  //#region source/web/react/commerce/hooks/use-extension-context.d.ts
125
125
  /**
@@ -129,14 +129,14 @@ declare function useCommerce(): Result<CommerceData>;
129
129
  * Returns an error outside the Commerce shared context, or when the mass-action selection is
130
130
  * missing, empty, or contains a non-string row ID.
131
131
  */
132
- declare function useMassActionContext(): Result<MassActionContext>;
132
+ export declare function useMassActionContext(): Result<MassActionContext>;
133
133
  /**
134
134
  * Returns the context for an order view-button extension point: the order ID the button was
135
135
  * triggered from.
136
136
  *
137
137
  * Returns an error when no order ID is present in the page URL.
138
138
  */
139
- declare function useOrderViewButtonContext(): Result<OrderViewButtonContext>;
139
+ export declare function useOrderViewButtonContext(): Result<OrderViewButtonContext>;
140
140
  //#endregion
141
141
  //#region source/web/react/commerce/hooks/use-host-connection.d.ts
142
142
  /**
@@ -153,7 +153,7 @@ declare function useOrderViewButtonContext(): Result<OrderViewButtonContext>;
153
153
  * }
154
154
  * ```
155
155
  */
156
- declare function useHostConnection(): ActionsResult<HostConnection>;
156
+ export declare function useHostConnection(): ActionsResult<HostConnection>;
157
157
  //#endregion
158
158
  //#region source/web/react/routing/types.d.ts
159
159
  declare module "@react-spectrum/s2/Provider" {
@@ -208,6 +208,6 @@ type CreateExtensionAppOptions = {
208
208
  * });
209
209
  * ```
210
210
  */
211
- declare function createExtensionApp({ menu, metadata, routes, root: customRoot }: CreateExtensionAppOptions): void;
211
+ export declare function createExtensionApp({ menu, metadata, routes, root: customRoot }: CreateExtensionAppOptions): void;
212
212
  //#endregion
213
- export { type CreateExtensionAppOptions, type ExtensionRoute, type HostConnection, type ImsContext, type MassActionContext, type OrderViewButtonContext, type SharedContext, createExtensionApp, useCommerce, useHostConnection, useIms, useMassActionContext, useOrderViewButtonContext, useSharedContext };
213
+ export type { CreateExtensionAppOptions, ExtensionRoute, HostConnection, ImsContext, MassActionContext, OrderViewButtonContext, SharedContext };
@@ -15,7 +15,7 @@
15
15
  import { StrictMode, Suspense, createContext, use, useCallback, useEffect, useMemo, useState, useSyncExternalStore } from "react";
16
16
  import { jsx, jsxs } from "react/jsx-runtime";
17
17
  import Runtime, { init } from "@adobe/exc-app";
18
- import page from "@adobe/exc-app/page.js";
18
+ import page from "@adobe/exc-app/page";
19
19
  import { Outlet, RouterProvider, createHashHistory, createRootRoute, createRoute, createRouter, useCanGoBack, useRouter, useRouterState } from "@tanstack/react-router";
20
20
  import { createRoot } from "react-dom/client";
21
21
  import { attach, register } from "@adobe/uix-guest";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/aio-commerce-lib-admin-ui",
3
- "version": "1.1.0-beta-20260820174436",
3
+ "version": "1.2.0-beta-20260930143021",
4
4
  "private": false,
5
5
  "description": "A library to interact with the Adobe Commerce Admin UI SDK API",
6
6
  "keywords": [
@@ -101,29 +101,29 @@
101
101
  "README.md"
102
102
  ],
103
103
  "dependencies": {
104
+ "@adobe/aio-commerce-lib-api": "1.4.1-beta-20260930143021",
105
+ "@adobe/aio-commerce-lib-core": "1.2.0",
104
106
  "@adobe/exc-app": "^1.4.20",
105
107
  "@adobe/uix-guest": "^1.0.3",
106
108
  "@tanstack/react-router": "^1.170.15",
107
109
  "ky": "^1.9.0",
108
110
  "react-error-boundary": "^6.1.2",
109
- "valibot": "^1.1.0",
110
- "@adobe/aio-commerce-lib-api": "1.3.1",
111
- "@adobe/aio-commerce-lib-core": "1.2.0"
111
+ "valibot": "^1.1.0"
112
112
  },
113
113
  "devDependencies": {
114
- "@react-spectrum/s2": "^1.5.1",
115
- "@types/react": "^19.2.17",
116
- "@types/react-dom": "^19.2.3",
117
- "react": "^19.2.7",
118
- "react-dom": "^19.2.7",
119
- "typescript": "^6.0.0",
114
+ "@aio-commerce-sdk/common-utils": "0.2.6",
120
115
  "@aio-commerce-sdk/config-tsdown": "1.0.1",
121
116
  "@aio-commerce-sdk/config-typedoc": "1.0.0",
122
- "@aio-commerce-sdk/common-utils": "0.2.6",
123
117
  "@aio-commerce-sdk/config-typescript": "1.0.0",
124
118
  "@aio-commerce-sdk/config-vitest": "1.0.0",
125
119
  "@aio-commerce-sdk/scripting-utils": "0.3.5",
126
- "@aio-commerce-sdk/scripts": "0.1.1"
120
+ "@aio-commerce-sdk/scripts": "0.1.1",
121
+ "@react-spectrum/s2": "^1.5.1",
122
+ "@types/react": "^19.2.17",
123
+ "@types/react-dom": "^19.2.3",
124
+ "react": "^19.2.7",
125
+ "react-dom": "^19.2.7",
126
+ "typescript": "^6.0.0"
127
127
  },
128
128
  "peerDependencies": {
129
129
  "@react-spectrum/s2": "^1.5.1",
@@ -1,39 +0,0 @@
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/api/lib/acl-resource-id.d.ts
16
- /**
17
- * Derives the deterministic Commerce ACL resource id for an app from its metadata id.
18
- *
19
- * The id is assembled as {@link PREFIX} + sanitized `metadataId`, where sanitization trims
20
- * whitespace, lowercases, and replaces every character outside `[a-z0-9_]` with `_`.
21
- * `"Magento_CommerceBackendUix::adminuisdk_app_"` is that fixed constant prefix — not a
22
- * placeholder — so the example below is fully reproducible from the given argument:
23
- *
24
- * @example
25
- * ```
26
- * getAclResourceId("approval-dashboard-app")
27
- * // PREFIX + sanitize("approval-dashboard-app")
28
- * // "Magento_CommerceBackendUix::adminuisdk_app_" + "approval_dashboard_app"
29
- * // → "Magento_CommerceBackendUix::adminuisdk_app_approval_dashboard_app"
30
- * ```
31
- *
32
- * @param metadataId - The application's `metadata.id` value (e.g. `"approval-dashboard-app"`).
33
- * @returns The full Commerce ACL resource id, or an empty string when `metadataId` is blank.
34
- */
35
- declare function getAclResourceId(metadataId: string): string;
36
- /** Commerce entity an Admin UI component is attached to. */
37
- type AdminUiEntity = "order" | "product" | "customer";
38
- //#endregion
39
- export { getAclResourceId as n, AdminUiEntity as t };
@@ -1,68 +0,0 @@
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/api/lib/acl-resource-id.ts
16
- /**
17
- * Fixed, constant prefix that every Admin UI SDK ACL resource id starts with.
18
- * It is owned by Commerce and is a stable part of the cross-repo id contract.
19
- *
20
- * @internal Exported for use by domain ACL helpers only — not part of the public API.
21
- */
22
- const PREFIX = "Magento_CommerceBackendUix::adminuisdk_app_";
23
- /**
24
- * Sanitizes a single ACL id segment: trims whitespace, lowercases, and replaces every
25
- * character outside [a-z0-9_] with an underscore.
26
- *
27
- * @internal Exported for use by domain ACL helpers only — not part of the public API.
28
- */
29
- function sanitizeSegment(segment) {
30
- return segment.trim().toLowerCase().replace(/[^a-z0-9_]/g, "_");
31
- }
32
- /**
33
- * Derives the deterministic Commerce ACL resource id for an app from its metadata id.
34
- *
35
- * The id is assembled as {@link PREFIX} + sanitized `metadataId`, where sanitization trims
36
- * whitespace, lowercases, and replaces every character outside `[a-z0-9_]` with `_`.
37
- * `"Magento_CommerceBackendUix::adminuisdk_app_"` is that fixed constant prefix — not a
38
- * placeholder — so the example below is fully reproducible from the given argument:
39
- *
40
- * @example
41
- * ```
42
- * getAclResourceId("approval-dashboard-app")
43
- * // PREFIX + sanitize("approval-dashboard-app")
44
- * // "Magento_CommerceBackendUix::adminuisdk_app_" + "approval_dashboard_app"
45
- * // → "Magento_CommerceBackendUix::adminuisdk_app_approval_dashboard_app"
46
- * ```
47
- *
48
- * @param metadataId - The application's `metadata.id` value (e.g. `"approval-dashboard-app"`).
49
- * @returns The full Commerce ACL resource id, or an empty string when `metadataId` is blank.
50
- */
51
- function getAclResourceId(metadataId) {
52
- if (metadataId.trim() === "") return "";
53
- return `${PREFIX}${sanitizeSegment(metadataId)}`;
54
- }
55
-
56
- //#endregion
57
- Object.defineProperty(exports, 'getAclResourceId', {
58
- enumerable: true,
59
- get: function () {
60
- return getAclResourceId;
61
- }
62
- });
63
- Object.defineProperty(exports, 'sanitizeSegment', {
64
- enumerable: true,
65
- get: function () {
66
- return sanitizeSegment;
67
- }
68
- });
@@ -1,39 +0,0 @@
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/api/lib/acl-resource-id.d.ts
16
- /**
17
- * Derives the deterministic Commerce ACL resource id for an app from its metadata id.
18
- *
19
- * The id is assembled as {@link PREFIX} + sanitized `metadataId`, where sanitization trims
20
- * whitespace, lowercases, and replaces every character outside `[a-z0-9_]` with `_`.
21
- * `"Magento_CommerceBackendUix::adminuisdk_app_"` is that fixed constant prefix — not a
22
- * placeholder — so the example below is fully reproducible from the given argument:
23
- *
24
- * @example
25
- * ```
26
- * getAclResourceId("approval-dashboard-app")
27
- * // PREFIX + sanitize("approval-dashboard-app")
28
- * // "Magento_CommerceBackendUix::adminuisdk_app_" + "approval_dashboard_app"
29
- * // → "Magento_CommerceBackendUix::adminuisdk_app_approval_dashboard_app"
30
- * ```
31
- *
32
- * @param metadataId - The application's `metadata.id` value (e.g. `"approval-dashboard-app"`).
33
- * @returns The full Commerce ACL resource id, or an empty string when `metadataId` is blank.
34
- */
35
- declare function getAclResourceId(metadataId: string): string;
36
- /** Commerce entity an Admin UI component is attached to. */
37
- type AdminUiEntity = "order" | "product" | "customer";
38
- //#endregion
39
- export { getAclResourceId as n, AdminUiEntity as t };
@@ -1,57 +0,0 @@
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/api/lib/acl-resource-id.ts
16
- /**
17
- * Fixed, constant prefix that every Admin UI SDK ACL resource id starts with.
18
- * It is owned by Commerce and is a stable part of the cross-repo id contract.
19
- *
20
- * @internal Exported for use by domain ACL helpers only — not part of the public API.
21
- */
22
- const PREFIX = "Magento_CommerceBackendUix::adminuisdk_app_";
23
- /**
24
- * Sanitizes a single ACL id segment: trims whitespace, lowercases, and replaces every
25
- * character outside [a-z0-9_] with an underscore.
26
- *
27
- * @internal Exported for use by domain ACL helpers only — not part of the public API.
28
- */
29
- function sanitizeSegment(segment) {
30
- return segment.trim().toLowerCase().replace(/[^a-z0-9_]/g, "_");
31
- }
32
- /**
33
- * Derives the deterministic Commerce ACL resource id for an app from its metadata id.
34
- *
35
- * The id is assembled as {@link PREFIX} + sanitized `metadataId`, where sanitization trims
36
- * whitespace, lowercases, and replaces every character outside `[a-z0-9_]` with `_`.
37
- * `"Magento_CommerceBackendUix::adminuisdk_app_"` is that fixed constant prefix — not a
38
- * placeholder — so the example below is fully reproducible from the given argument:
39
- *
40
- * @example
41
- * ```
42
- * getAclResourceId("approval-dashboard-app")
43
- * // PREFIX + sanitize("approval-dashboard-app")
44
- * // "Magento_CommerceBackendUix::adminuisdk_app_" + "approval_dashboard_app"
45
- * // → "Magento_CommerceBackendUix::adminuisdk_app_approval_dashboard_app"
46
- * ```
47
- *
48
- * @param metadataId - The application's `metadata.id` value (e.g. `"approval-dashboard-app"`).
49
- * @returns The full Commerce ACL resource id, or an empty string when `metadataId` is blank.
50
- */
51
- function getAclResourceId(metadataId) {
52
- if (metadataId.trim() === "") return "";
53
- return `${PREFIX}${sanitizeSegment(metadataId)}`;
54
- }
55
-
56
- //#endregion
57
- export { sanitizeSegment as n, getAclResourceId as t };