@adobe/aio-commerce-lib-admin-ui 0.2.0 → 1.0.1-alpha-20260819113253
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.
- package/CHANGELOG.md +16 -0
- package/dist/cjs/{acl-resource-id-D_hCU1Qg.cjs → acl-resource-id-R52pR3gG.cjs} +0 -1
- package/dist/cjs/api/index.cjs +5 -4
- package/dist/cjs/api/index.d.cts +6 -4
- package/dist/cjs/grid-columns/index.cjs +4 -4
- package/dist/cjs/grid-columns/index.d.cts +0 -1
- package/dist/cjs/mass-actions/index.cjs +4 -4
- package/dist/cjs/mass-actions/index.d.cts +0 -1
- package/dist/cjs/menu/index.cjs +1 -1
- package/dist/cjs/order-view-buttons/index.cjs +4 -4
- package/dist/cjs/order-view-buttons/index.d.cts +0 -1
- package/dist/cjs/{rolldown-runtime-Cx6hovH8.cjs → rolldown-runtime-Bf2WWRga.cjs} +1 -2
- package/dist/cjs/{schemas-Ce10uBzN.cjs → schemas-DRhCF0TF.cjs} +1 -1
- package/dist/cjs/{utils-B59fjd_w.cjs → utils-CiBhSMw4.cjs} +1 -1
- package/dist/cjs/web/index.cjs +27 -15
- package/dist/cjs/web/index.d.cts +27 -20
- package/dist/es/api/index.d.mts +6 -4
- package/dist/es/api/index.mjs +2 -1
- package/dist/es/grid-columns/index.d.mts +0 -1
- package/dist/es/mass-actions/index.d.mts +0 -1
- package/dist/es/order-view-buttons/index.d.mts +0 -1
- package/dist/es/web/index.d.mts +27 -20
- package/dist/es/web/index.mjs +26 -14
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @adobe/aio-commerce-lib-admin-ui
|
|
2
2
|
|
|
3
|
+
## 1.0.1-alpha-20260819113253
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
- [#635](https://github.com/adobe/aio-commerce-sdk/pull/635) [`8a51d9b`](https://github.com/adobe/aio-commerce-sdk/commit/8a51d9b9269c4af5e8ebb400ff975b86ec1b75f2) Thanks [@iivvaannxx](https://github.com/iivvaannxx)! - StrictMode is now applied only in development builds.
|
|
9
|
+
|
|
10
|
+
- Updated dependencies []:
|
|
11
|
+
- @adobe/aio-commerce-lib-api@1.3.1-alpha-20260819113253
|
|
12
|
+
|
|
13
|
+
## 1.0.0
|
|
14
|
+
|
|
15
|
+
### Major Changes
|
|
16
|
+
|
|
17
|
+
- [#599](https://github.com/adobe/aio-commerce-sdk/pull/599) [`ac6c13b`](https://github.com/adobe/aio-commerce-sdk/commit/ac6c13b4124677820f8946c92e4cd63ab228eeae) Thanks [@obarcelonap](https://github.com/obarcelonap)! - Release the first stable version.
|
|
18
|
+
|
|
3
19
|
## 0.2.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
package/dist/cjs/api/index.cjs
CHANGED
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
16
|
-
const require_rolldown_runtime = require('../rolldown-runtime-
|
|
17
|
-
const require_acl_resource_id = require('../acl-resource-id-
|
|
18
|
-
const require_utils = require('../utils-
|
|
16
|
+
const require_rolldown_runtime = require('../rolldown-runtime-Bf2WWRga.cjs');
|
|
17
|
+
const require_acl_resource_id = require('../acl-resource-id-R52pR3gG.cjs');
|
|
18
|
+
const require_utils = require('../utils-CiBhSMw4.cjs');
|
|
19
19
|
let _adobe_aio_commerce_lib_core_error = require("@adobe/aio-commerce-lib-core/error");
|
|
20
20
|
let _adobe_aio_commerce_lib_api = require("@adobe/aio-commerce-lib-api");
|
|
21
21
|
let valibot = require("valibot");
|
|
@@ -139,7 +139,8 @@ const permissionCheckResponseSchema = valibot.object({ allowed: valibot.boolean(
|
|
|
139
139
|
* @throws {@link HTTPError} if the response status is not in the 2xx range.
|
|
140
140
|
*/
|
|
141
141
|
async function checkPermission(httpClient, params) {
|
|
142
|
-
|
|
142
|
+
const raw = await httpClient.post("adminuisdk/permission/check", { json: { resource: params.resource } }).json();
|
|
143
|
+
return require_utils.parseOrThrow(permissionCheckResponseSchema, raw);
|
|
143
144
|
}
|
|
144
145
|
|
|
145
146
|
//#endregion
|
package/dist/cjs/api/index.d.cts
CHANGED
|
@@ -16,7 +16,6 @@ import { n as getAclResourceId, t as AdminUiEntity } from "../acl-resource-id-DB
|
|
|
16
16
|
import { CommerceSdkErrorBase, CommerceSdkErrorOptions } from "@adobe/aio-commerce-lib-core/error";
|
|
17
17
|
import { AdobeCommerceHttpClient, CommerceHttpClientParams } from "@adobe/aio-commerce-lib-api";
|
|
18
18
|
import * as v from "valibot";
|
|
19
|
-
|
|
20
19
|
//#region source/errors.d.ts
|
|
21
20
|
/** Base error for Admin UI SDK permission helper failures. */
|
|
22
21
|
declare class AdminUiPermissionError extends CommerceSdkErrorBase {}
|
|
@@ -48,14 +47,17 @@ type AdminUiApiClient = ReturnType<typeof createAdminUiApiClient>;
|
|
|
48
47
|
//#region source/api/lib/permission-client.d.ts
|
|
49
48
|
/** Options used to create an Admin UI SDK permission client. */
|
|
50
49
|
type AdminUiPermissionClientOptions = {
|
|
51
|
-
/** The application's `metadata.id` value. When provided, `check()` and `require()` can be called with no resource argument. */
|
|
50
|
+
/** The application's `metadata.id` value. When provided, `check()` and `require()` can be called with no resource argument. */
|
|
51
|
+
appId?: string;
|
|
52
52
|
/**
|
|
53
53
|
* Milliseconds to cache a permission result. Default: 300_000 (5 minutes).
|
|
54
54
|
* Set to 0 to disable result caching. Note: in-flight deduplication of concurrent identical
|
|
55
55
|
* requests is independent of this setting and remains active even when caching is disabled.
|
|
56
56
|
*/
|
|
57
|
-
cacheTtlMs?: number;
|
|
58
|
-
|
|
57
|
+
cacheTtlMs?: number;
|
|
58
|
+
/** Return false instead of throwing when a network or parse error occurs. Default: true. */
|
|
59
|
+
denyOnError?: boolean;
|
|
60
|
+
/** Commerce HTTP client used to call the Admin UI SDK permission endpoint. */
|
|
59
61
|
httpClient: AdobeCommerceHttpClient;
|
|
60
62
|
};
|
|
61
63
|
/** Client for checking the current user's Admin UI SDK resource permissions. */
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
16
|
-
const require_rolldown_runtime = require('../rolldown-runtime-
|
|
17
|
-
const require_acl_resource_id = require('../acl-resource-id-
|
|
18
|
-
const require_schemas = require('../schemas-
|
|
19
|
-
const require_utils = require('../utils-
|
|
16
|
+
const require_rolldown_runtime = require('../rolldown-runtime-Bf2WWRga.cjs');
|
|
17
|
+
const require_acl_resource_id = require('../acl-resource-id-R52pR3gG.cjs');
|
|
18
|
+
const require_schemas = require('../schemas-DRhCF0TF.cjs');
|
|
19
|
+
const require_utils = require('../utils-CiBhSMw4.cjs');
|
|
20
20
|
let valibot = require("valibot");
|
|
21
21
|
valibot = require_rolldown_runtime.__toESM(valibot, 1);
|
|
22
22
|
let _adobe_aio_commerce_lib_core_responses = require("@adobe/aio-commerce-lib-core/responses");
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
import { t as AdminUiEntity } from "../acl-resource-id-DBlYU0DE.cjs";
|
|
16
16
|
import * as v from "valibot";
|
|
17
17
|
import { ErrorResponse, SuccessResponse } from "@adobe/aio-commerce-lib-core/responses";
|
|
18
|
-
|
|
19
18
|
//#region source/grid-columns/acl-resource-id.d.ts
|
|
20
19
|
/**
|
|
21
20
|
* Derives the deterministic Commerce ACL resource id for a grid column.
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
16
|
-
const require_rolldown_runtime = require('../rolldown-runtime-
|
|
17
|
-
const require_acl_resource_id = require('../acl-resource-id-
|
|
18
|
-
const require_schemas = require('../schemas-
|
|
19
|
-
const require_utils = require('../utils-
|
|
16
|
+
const require_rolldown_runtime = require('../rolldown-runtime-Bf2WWRga.cjs');
|
|
17
|
+
const require_acl_resource_id = require('../acl-resource-id-R52pR3gG.cjs');
|
|
18
|
+
const require_schemas = require('../schemas-DRhCF0TF.cjs');
|
|
19
|
+
const require_utils = require('../utils-CiBhSMw4.cjs');
|
|
20
20
|
let valibot = require("valibot");
|
|
21
21
|
valibot = require_rolldown_runtime.__toESM(valibot, 1);
|
|
22
22
|
let _adobe_aio_commerce_lib_core_responses = require("@adobe/aio-commerce-lib-core/responses");
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
import { t as AdminUiEntity } from "../acl-resource-id-DBlYU0DE.cjs";
|
|
16
16
|
import * as v from "valibot";
|
|
17
17
|
import { ErrorResponse, SuccessResponse } from "@adobe/aio-commerce-lib-core/responses";
|
|
18
|
-
|
|
19
18
|
//#region source/mass-actions/acl-resource-id.d.ts
|
|
20
19
|
/**
|
|
21
20
|
* Derives the deterministic Commerce ACL resource id for a mass action.
|
package/dist/cjs/menu/index.cjs
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
16
|
-
const require_acl_resource_id = require('../acl-resource-id-
|
|
16
|
+
const require_acl_resource_id = require('../acl-resource-id-R52pR3gG.cjs');
|
|
17
17
|
|
|
18
18
|
//#region source/menu/acl-resource-id.ts
|
|
19
19
|
/**
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
16
|
-
const require_rolldown_runtime = require('../rolldown-runtime-
|
|
17
|
-
const require_acl_resource_id = require('../acl-resource-id-
|
|
18
|
-
const require_schemas = require('../schemas-
|
|
19
|
-
const require_utils = require('../utils-
|
|
16
|
+
const require_rolldown_runtime = require('../rolldown-runtime-Bf2WWRga.cjs');
|
|
17
|
+
const require_acl_resource_id = require('../acl-resource-id-R52pR3gG.cjs');
|
|
18
|
+
const require_schemas = require('../schemas-DRhCF0TF.cjs');
|
|
19
|
+
const require_utils = require('../utils-CiBhSMw4.cjs');
|
|
20
20
|
let valibot = require("valibot");
|
|
21
21
|
valibot = require_rolldown_runtime.__toESM(valibot, 1);
|
|
22
22
|
let _adobe_aio_commerce_lib_core_responses = require("@adobe/aio-commerce-lib-core/responses");
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
|
|
15
15
|
import * as v from "valibot";
|
|
16
16
|
import { ErrorResponse, SuccessResponse } from "@adobe/aio-commerce-lib-core/responses";
|
|
17
|
-
|
|
18
17
|
//#region source/order-view-buttons/acl-resource-id.d.ts
|
|
19
18
|
/**
|
|
20
19
|
* Derives the deterministic Commerce ACL resource id for an order view button.
|
|
@@ -46,13 +46,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
46
46
|
}
|
|
47
47
|
return to;
|
|
48
48
|
};
|
|
49
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
49
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
50
50
|
value: mod,
|
|
51
51
|
enumerable: true
|
|
52
52
|
}) : target, mod));
|
|
53
53
|
|
|
54
54
|
//#endregion
|
|
55
|
-
|
|
56
55
|
Object.defineProperty(exports, '__exportAll', {
|
|
57
56
|
enumerable: true,
|
|
58
57
|
get: function () {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
const require_rolldown_runtime = require('./rolldown-runtime-
|
|
15
|
+
const require_rolldown_runtime = require('./rolldown-runtime-Bf2WWRga.cjs');
|
|
16
16
|
let valibot = require("valibot");
|
|
17
17
|
valibot = require_rolldown_runtime.__toESM(valibot, 1);
|
|
18
18
|
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
const require_rolldown_runtime = require('./rolldown-runtime-
|
|
15
|
+
const require_rolldown_runtime = require('./rolldown-runtime-Bf2WWRga.cjs');
|
|
16
16
|
let _adobe_aio_commerce_lib_core_error = require("@adobe/aio-commerce-lib-core/error");
|
|
17
17
|
let valibot = require("valibot");
|
|
18
18
|
valibot = require_rolldown_runtime.__toESM(valibot, 1);
|
package/dist/cjs/web/index.cjs
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
16
|
-
const require_rolldown_runtime = require('../rolldown-runtime-
|
|
16
|
+
const require_rolldown_runtime = require('../rolldown-runtime-Bf2WWRga.cjs');
|
|
17
17
|
let react = require("react");
|
|
18
18
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
19
19
|
let _adobe_exc_app = require("@adobe/exc-app");
|
|
@@ -163,10 +163,11 @@ function useSharedContext() {
|
|
|
163
163
|
* @param guestConnection - The established guest connection.
|
|
164
164
|
*/
|
|
165
165
|
function useLiveSharedContext(guestConnection) {
|
|
166
|
-
|
|
166
|
+
const subscribe = (0, react.useCallback)((onContextChange) => {
|
|
167
167
|
if (!guestConnection) return () => void 0;
|
|
168
168
|
return guestConnection.addEventListener("contextchange", onContextChange);
|
|
169
|
-
}, [guestConnection])
|
|
169
|
+
}, [guestConnection]);
|
|
170
|
+
return (0, react.useSyncExternalStore)(subscribe, () => guestConnection?.sharedContext ?? null);
|
|
170
171
|
}
|
|
171
172
|
/**
|
|
172
173
|
* Provides the Commerce shared context for a mounted Admin UI iframe app.
|
|
@@ -237,7 +238,8 @@ function getCommerceHostPromise(extensionId, connection) {
|
|
|
237
238
|
const { integration } = connection.host;
|
|
238
239
|
if (!integration) return error("The host does not provide the integration API needed to resolve the Commerce host.");
|
|
239
240
|
try {
|
|
240
|
-
|
|
241
|
+
const commerceHost = await integration.getCommerceHost();
|
|
242
|
+
return ok({ commerceHost });
|
|
241
243
|
} catch (cause) {
|
|
242
244
|
return error("Failed to resolve the Commerce host.", { cause });
|
|
243
245
|
}
|
|
@@ -656,9 +658,10 @@ function ControlFrameRegistration(props) {
|
|
|
656
658
|
*/
|
|
657
659
|
function CommerceGuestConnection(props) {
|
|
658
660
|
const { extensionId } = props;
|
|
661
|
+
const guestConnection = useGuestConnection(extensionId);
|
|
659
662
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SharedContextProvider, {
|
|
660
663
|
extensionId,
|
|
661
|
-
guestConnection
|
|
664
|
+
guestConnection,
|
|
662
665
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CommerceExtensionContent, {})
|
|
663
666
|
});
|
|
664
667
|
}
|
|
@@ -666,8 +669,9 @@ function CommerceGuestConnection(props) {
|
|
|
666
669
|
function CommerceExtensionContent() {
|
|
667
670
|
const { data, error } = useSharedContext();
|
|
668
671
|
if (error) throw error;
|
|
672
|
+
const credentials = resolveCommerceImsCredentials(data.sharedContext);
|
|
669
673
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImsContextProvider, {
|
|
670
|
-
credentials
|
|
674
|
+
credentials,
|
|
671
675
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_tanstack_react_router.Outlet, {})
|
|
672
676
|
});
|
|
673
677
|
}
|
|
@@ -756,13 +760,16 @@ function ExperienceShellExtensionApp(props) {
|
|
|
756
760
|
*/
|
|
757
761
|
function ShellExtensionContent(props) {
|
|
758
762
|
const { initialConfigurationPromise, runtime } = props;
|
|
759
|
-
const
|
|
763
|
+
const initialConfiguration = (0, react.use)(initialConfigurationPromise);
|
|
764
|
+
const shellConfiguration = useShellConfiguration(runtime, initialConfiguration);
|
|
760
765
|
const spectrumRouter = useSpectrumRouter();
|
|
766
|
+
const colorScheme = useExtensionColorScheme(shellConfiguration);
|
|
767
|
+
const credentials = resolveShellImsCredentials(shellConfiguration);
|
|
761
768
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_react_spectrum_s2_Provider.Provider, {
|
|
762
|
-
colorScheme
|
|
769
|
+
colorScheme,
|
|
763
770
|
router: spectrumRouter,
|
|
764
771
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ExtensionErrorBoundary, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ImsContextProvider, {
|
|
765
|
-
credentials
|
|
772
|
+
credentials,
|
|
766
773
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_tanstack_react_router.Outlet, {})
|
|
767
774
|
}) })
|
|
768
775
|
});
|
|
@@ -810,9 +817,11 @@ function Entrypoint(props) {
|
|
|
810
817
|
* Mounts a Commerce Admin UI iframe app and handles Experience Cloud Shell, UIX
|
|
811
818
|
* registration, shared-context attachment, routing, and Spectrum setup.
|
|
812
819
|
*
|
|
813
|
-
* The app is wrapped in React's `<StrictMode
|
|
814
|
-
*
|
|
815
|
-
* an extra setup + cleanup cycle on mount. Production builds
|
|
820
|
+
* The app is wrapped in React's `<StrictMode>` only in development builds
|
|
821
|
+
* (`process.env.NODE_ENV !== "production"`), so components render twice and effects
|
|
822
|
+
* run an extra setup + cleanup cycle on mount. Production builds
|
|
823
|
+
* (`process.env.NODE_ENV === "production"`) render without `<StrictMode>`, so it is
|
|
824
|
+
* stripped from the production bundle.
|
|
816
825
|
*
|
|
817
826
|
* @param options - App bootstrap options.
|
|
818
827
|
*
|
|
@@ -833,15 +842,18 @@ function createExtensionApp({ menu, metadata, routes = [], root: customRoot }) {
|
|
|
833
842
|
if (!rootElement) throw new Error("Could not find an element with id \"root\".");
|
|
834
843
|
const root = (0, react_dom_client.createRoot)(rootElement);
|
|
835
844
|
const render = (runtime, initialConfigurationPromise) => {
|
|
836
|
-
const
|
|
845
|
+
const entrypointProps = {
|
|
837
846
|
extensionId: metadata.extensionId,
|
|
838
847
|
initialConfigurationPromise,
|
|
839
848
|
runtime
|
|
840
|
-
}
|
|
849
|
+
};
|
|
850
|
+
const entrypoint = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Entrypoint, { ...entrypointProps });
|
|
851
|
+
const router = createExtensionRouter(entrypoint, menu === void 0 ? routes : [{
|
|
841
852
|
element: menu,
|
|
842
853
|
path: "/"
|
|
843
854
|
}, ...routes]);
|
|
844
|
-
|
|
855
|
+
const tree = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_tanstack_react_router.RouterProvider, { router });
|
|
856
|
+
root.render(process.env.NODE_ENV === "production" ? tree : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.StrictMode, { children: tree }));
|
|
845
857
|
};
|
|
846
858
|
try {
|
|
847
859
|
loadExperienceCloudRuntime();
|
package/dist/cjs/web/index.d.cts
CHANGED
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
import { ReactNode } from "react";
|
|
16
16
|
import { attach } from "@adobe/uix-guest";
|
|
17
17
|
import { NavigateOptions, ToOptions } from "@tanstack/react-router";
|
|
18
|
-
|
|
19
18
|
//#region source/web/react/auth/types.d.ts
|
|
20
19
|
/** The IMS credentials provided by the host (Commerce Admin or Experience Cloud shell). */
|
|
21
20
|
type ImsContext = {
|
|
@@ -64,13 +63,18 @@ type GuestConnection = Awaited<ReturnType<typeof attach>>;
|
|
|
64
63
|
* which are also available in the Experience Cloud shell.
|
|
65
64
|
*/
|
|
66
65
|
type SharedContext = {
|
|
67
|
-
/** The extension ID of the app. */
|
|
68
|
-
|
|
66
|
+
/** The extension ID of the app. */
|
|
67
|
+
extensionId: string;
|
|
68
|
+
/** The live `sharedContext` object provided by the host. */
|
|
69
|
+
sharedContext: NonNullable<GuestConnection["sharedContext"]>;
|
|
70
|
+
/** The host proxy, used by `useHostConnection` to invoke host-frame actions (close/onError). */
|
|
69
71
|
host: NonNullable<GuestConnection["host"]>;
|
|
70
72
|
};
|
|
71
73
|
/** Actions for closing the extension iframe and returning control to the Commerce Admin. */
|
|
72
74
|
type HostConnection = {
|
|
73
|
-
/** Closes the iframe and navigates back to the originating grid or order. */
|
|
75
|
+
/** Closes the iframe and navigates back to the originating grid or order. */
|
|
76
|
+
close: () => Promise<void>;
|
|
77
|
+
/** Closes the iframe and navigates back, flagging the originating page that an error occurred. */
|
|
74
78
|
closeWithError: () => Promise<void>;
|
|
75
79
|
};
|
|
76
80
|
/** The context shared with mass-action extension points. */
|
|
@@ -108,7 +112,6 @@ declare function useSharedContext(): Result<SharedContext>;
|
|
|
108
112
|
type CommerceData = {
|
|
109
113
|
commerceHost: string;
|
|
110
114
|
};
|
|
111
|
-
/** Drops a failed Commerce host resolution for `extensionId`, so a later render retries it. */
|
|
112
115
|
/**
|
|
113
116
|
* Returns the host (domain) of the Commerce Admin the extension is embedded in, resolving it over
|
|
114
117
|
* the guest connection.
|
|
@@ -161,27 +164,36 @@ declare module "@react-spectrum/s2/Provider" {
|
|
|
161
164
|
}
|
|
162
165
|
/** Defines a route that exists at a given path. */
|
|
163
166
|
type ExtensionRoute = {
|
|
164
|
-
/** The path for the route. */
|
|
167
|
+
/** The path for the route. */
|
|
168
|
+
path: string;
|
|
169
|
+
/** The React element to render for the route. */
|
|
165
170
|
element: ReactNode;
|
|
166
171
|
};
|
|
167
172
|
//#endregion
|
|
168
173
|
//#region source/web/react/extension/create-app.d.ts
|
|
169
174
|
/** Configuration options when instantiating an extension app. */
|
|
170
175
|
type CreateExtensionAppOptions = {
|
|
171
|
-
/** General metadata about the extension app. */
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
+
/** General metadata about the extension app. */
|
|
177
|
+
metadata: {
|
|
178
|
+
/** The unique identifier for the extension app. */
|
|
179
|
+
extensionId: string;
|
|
180
|
+
};
|
|
181
|
+
/** The optional app page opened from the Commerce Admin menu and by default in Experience Cloud Shell. */
|
|
182
|
+
menu?: ReactNode;
|
|
183
|
+
/** Optional root element where the app will be mounted. */
|
|
184
|
+
root?: HTMLElement;
|
|
185
|
+
/** Additional path-based routes for the extension app. */
|
|
176
186
|
routes?: ExtensionRoute[];
|
|
177
187
|
};
|
|
178
188
|
/**
|
|
179
189
|
* Mounts a Commerce Admin UI iframe app and handles Experience Cloud Shell, UIX
|
|
180
190
|
* registration, shared-context attachment, routing, and Spectrum setup.
|
|
181
191
|
*
|
|
182
|
-
* The app is wrapped in React's `<StrictMode
|
|
183
|
-
*
|
|
184
|
-
* an extra setup + cleanup cycle on mount. Production builds
|
|
192
|
+
* The app is wrapped in React's `<StrictMode>` only in development builds
|
|
193
|
+
* (`process.env.NODE_ENV !== "production"`), so components render twice and effects
|
|
194
|
+
* run an extra setup + cleanup cycle on mount. Production builds
|
|
195
|
+
* (`process.env.NODE_ENV === "production"`) render without `<StrictMode>`, so it is
|
|
196
|
+
* stripped from the production bundle.
|
|
185
197
|
*
|
|
186
198
|
* @param options - App bootstrap options.
|
|
187
199
|
*
|
|
@@ -196,11 +208,6 @@ type CreateExtensionAppOptions = {
|
|
|
196
208
|
* });
|
|
197
209
|
* ```
|
|
198
210
|
*/
|
|
199
|
-
declare function createExtensionApp({
|
|
200
|
-
menu,
|
|
201
|
-
metadata,
|
|
202
|
-
routes,
|
|
203
|
-
root: customRoot
|
|
204
|
-
}: CreateExtensionAppOptions): void;
|
|
211
|
+
declare function createExtensionApp({ menu, metadata, routes, root: customRoot }: CreateExtensionAppOptions): void;
|
|
205
212
|
//#endregion
|
|
206
213
|
export { type CreateExtensionAppOptions, type ExtensionRoute, type HostConnection, type ImsContext, type MassActionContext, type OrderViewButtonContext, type SharedContext, createExtensionApp, useCommerce, useHostConnection, useIms, useMassActionContext, useOrderViewButtonContext, useSharedContext };
|
package/dist/es/api/index.d.mts
CHANGED
|
@@ -16,7 +16,6 @@ import { n as getAclResourceId, t as AdminUiEntity } from "../acl-resource-id-DB
|
|
|
16
16
|
import { CommerceSdkErrorBase, CommerceSdkErrorOptions } from "@adobe/aio-commerce-lib-core/error";
|
|
17
17
|
import { AdobeCommerceHttpClient, CommerceHttpClientParams } from "@adobe/aio-commerce-lib-api";
|
|
18
18
|
import * as v from "valibot";
|
|
19
|
-
|
|
20
19
|
//#region source/errors.d.ts
|
|
21
20
|
/** Base error for Admin UI SDK permission helper failures. */
|
|
22
21
|
declare class AdminUiPermissionError extends CommerceSdkErrorBase {}
|
|
@@ -48,14 +47,17 @@ type AdminUiApiClient = ReturnType<typeof createAdminUiApiClient>;
|
|
|
48
47
|
//#region source/api/lib/permission-client.d.ts
|
|
49
48
|
/** Options used to create an Admin UI SDK permission client. */
|
|
50
49
|
type AdminUiPermissionClientOptions = {
|
|
51
|
-
/** The application's `metadata.id` value. When provided, `check()` and `require()` can be called with no resource argument. */
|
|
50
|
+
/** The application's `metadata.id` value. When provided, `check()` and `require()` can be called with no resource argument. */
|
|
51
|
+
appId?: string;
|
|
52
52
|
/**
|
|
53
53
|
* Milliseconds to cache a permission result. Default: 300_000 (5 minutes).
|
|
54
54
|
* Set to 0 to disable result caching. Note: in-flight deduplication of concurrent identical
|
|
55
55
|
* requests is independent of this setting and remains active even when caching is disabled.
|
|
56
56
|
*/
|
|
57
|
-
cacheTtlMs?: number;
|
|
58
|
-
|
|
57
|
+
cacheTtlMs?: number;
|
|
58
|
+
/** Return false instead of throwing when a network or parse error occurs. Default: true. */
|
|
59
|
+
denyOnError?: boolean;
|
|
60
|
+
/** Commerce HTTP client used to call the Admin UI SDK permission endpoint. */
|
|
59
61
|
httpClient: AdobeCommerceHttpClient;
|
|
60
62
|
};
|
|
61
63
|
/** Client for checking the current user's Admin UI SDK resource permissions. */
|
package/dist/es/api/index.mjs
CHANGED
|
@@ -153,7 +153,8 @@ const permissionCheckResponseSchema = v.object({ allowed: v.boolean() });
|
|
|
153
153
|
* @throws {@link HTTPError} if the response status is not in the 2xx range.
|
|
154
154
|
*/
|
|
155
155
|
async function checkPermission(httpClient, params) {
|
|
156
|
-
|
|
156
|
+
const raw = await httpClient.post("adminuisdk/permission/check", { json: { resource: params.resource } }).json();
|
|
157
|
+
return parseOrThrow(permissionCheckResponseSchema, raw);
|
|
157
158
|
}
|
|
158
159
|
|
|
159
160
|
//#endregion
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
import { t as AdminUiEntity } from "../acl-resource-id-DBlYU0DE.mjs";
|
|
16
16
|
import * as v from "valibot";
|
|
17
17
|
import { ErrorResponse, SuccessResponse } from "@adobe/aio-commerce-lib-core/responses";
|
|
18
|
-
|
|
19
18
|
//#region source/grid-columns/acl-resource-id.d.ts
|
|
20
19
|
/**
|
|
21
20
|
* Derives the deterministic Commerce ACL resource id for a grid column.
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
import { t as AdminUiEntity } from "../acl-resource-id-DBlYU0DE.mjs";
|
|
16
16
|
import * as v from "valibot";
|
|
17
17
|
import { ErrorResponse, SuccessResponse } from "@adobe/aio-commerce-lib-core/responses";
|
|
18
|
-
|
|
19
18
|
//#region source/mass-actions/acl-resource-id.d.ts
|
|
20
19
|
/**
|
|
21
20
|
* Derives the deterministic Commerce ACL resource id for a mass action.
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
|
|
15
15
|
import * as v from "valibot";
|
|
16
16
|
import { ErrorResponse, SuccessResponse } from "@adobe/aio-commerce-lib-core/responses";
|
|
17
|
-
|
|
18
17
|
//#region source/order-view-buttons/acl-resource-id.d.ts
|
|
19
18
|
/**
|
|
20
19
|
* Derives the deterministic Commerce ACL resource id for an order view button.
|
package/dist/es/web/index.d.mts
CHANGED
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
import { ReactNode } from "react";
|
|
16
16
|
import { NavigateOptions, ToOptions } from "@tanstack/react-router";
|
|
17
17
|
import { attach } from "@adobe/uix-guest";
|
|
18
|
-
|
|
19
18
|
//#region source/web/react/auth/types.d.ts
|
|
20
19
|
/** The IMS credentials provided by the host (Commerce Admin or Experience Cloud shell). */
|
|
21
20
|
type ImsContext = {
|
|
@@ -64,13 +63,18 @@ type GuestConnection = Awaited<ReturnType<typeof attach>>;
|
|
|
64
63
|
* which are also available in the Experience Cloud shell.
|
|
65
64
|
*/
|
|
66
65
|
type SharedContext = {
|
|
67
|
-
/** The extension ID of the app. */
|
|
68
|
-
|
|
66
|
+
/** The extension ID of the app. */
|
|
67
|
+
extensionId: string;
|
|
68
|
+
/** The live `sharedContext` object provided by the host. */
|
|
69
|
+
sharedContext: NonNullable<GuestConnection["sharedContext"]>;
|
|
70
|
+
/** The host proxy, used by `useHostConnection` to invoke host-frame actions (close/onError). */
|
|
69
71
|
host: NonNullable<GuestConnection["host"]>;
|
|
70
72
|
};
|
|
71
73
|
/** Actions for closing the extension iframe and returning control to the Commerce Admin. */
|
|
72
74
|
type HostConnection = {
|
|
73
|
-
/** Closes the iframe and navigates back to the originating grid or order. */
|
|
75
|
+
/** Closes the iframe and navigates back to the originating grid or order. */
|
|
76
|
+
close: () => Promise<void>;
|
|
77
|
+
/** Closes the iframe and navigates back, flagging the originating page that an error occurred. */
|
|
74
78
|
closeWithError: () => Promise<void>;
|
|
75
79
|
};
|
|
76
80
|
/** The context shared with mass-action extension points. */
|
|
@@ -108,7 +112,6 @@ declare function useSharedContext(): Result<SharedContext>;
|
|
|
108
112
|
type CommerceData = {
|
|
109
113
|
commerceHost: string;
|
|
110
114
|
};
|
|
111
|
-
/** Drops a failed Commerce host resolution for `extensionId`, so a later render retries it. */
|
|
112
115
|
/**
|
|
113
116
|
* Returns the host (domain) of the Commerce Admin the extension is embedded in, resolving it over
|
|
114
117
|
* the guest connection.
|
|
@@ -161,27 +164,36 @@ declare module "@react-spectrum/s2/Provider" {
|
|
|
161
164
|
}
|
|
162
165
|
/** Defines a route that exists at a given path. */
|
|
163
166
|
type ExtensionRoute = {
|
|
164
|
-
/** The path for the route. */
|
|
167
|
+
/** The path for the route. */
|
|
168
|
+
path: string;
|
|
169
|
+
/** The React element to render for the route. */
|
|
165
170
|
element: ReactNode;
|
|
166
171
|
};
|
|
167
172
|
//#endregion
|
|
168
173
|
//#region source/web/react/extension/create-app.d.ts
|
|
169
174
|
/** Configuration options when instantiating an extension app. */
|
|
170
175
|
type CreateExtensionAppOptions = {
|
|
171
|
-
/** General metadata about the extension app. */
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
+
/** General metadata about the extension app. */
|
|
177
|
+
metadata: {
|
|
178
|
+
/** The unique identifier for the extension app. */
|
|
179
|
+
extensionId: string;
|
|
180
|
+
};
|
|
181
|
+
/** The optional app page opened from the Commerce Admin menu and by default in Experience Cloud Shell. */
|
|
182
|
+
menu?: ReactNode;
|
|
183
|
+
/** Optional root element where the app will be mounted. */
|
|
184
|
+
root?: HTMLElement;
|
|
185
|
+
/** Additional path-based routes for the extension app. */
|
|
176
186
|
routes?: ExtensionRoute[];
|
|
177
187
|
};
|
|
178
188
|
/**
|
|
179
189
|
* Mounts a Commerce Admin UI iframe app and handles Experience Cloud Shell, UIX
|
|
180
190
|
* registration, shared-context attachment, routing, and Spectrum setup.
|
|
181
191
|
*
|
|
182
|
-
* The app is wrapped in React's `<StrictMode
|
|
183
|
-
*
|
|
184
|
-
* an extra setup + cleanup cycle on mount. Production builds
|
|
192
|
+
* The app is wrapped in React's `<StrictMode>` only in development builds
|
|
193
|
+
* (`process.env.NODE_ENV !== "production"`), so components render twice and effects
|
|
194
|
+
* run an extra setup + cleanup cycle on mount. Production builds
|
|
195
|
+
* (`process.env.NODE_ENV === "production"`) render without `<StrictMode>`, so it is
|
|
196
|
+
* stripped from the production bundle.
|
|
185
197
|
*
|
|
186
198
|
* @param options - App bootstrap options.
|
|
187
199
|
*
|
|
@@ -196,11 +208,6 @@ type CreateExtensionAppOptions = {
|
|
|
196
208
|
* });
|
|
197
209
|
* ```
|
|
198
210
|
*/
|
|
199
|
-
declare function createExtensionApp({
|
|
200
|
-
menu,
|
|
201
|
-
metadata,
|
|
202
|
-
routes,
|
|
203
|
-
root: customRoot
|
|
204
|
-
}: CreateExtensionAppOptions): void;
|
|
211
|
+
declare function createExtensionApp({ menu, metadata, routes, root: customRoot }: CreateExtensionAppOptions): void;
|
|
205
212
|
//#endregion
|
|
206
213
|
export { type CreateExtensionAppOptions, type ExtensionRoute, type HostConnection, type ImsContext, type MassActionContext, type OrderViewButtonContext, type SharedContext, createExtensionApp, useCommerce, useHostConnection, useIms, useMassActionContext, useOrderViewButtonContext, useSharedContext };
|
package/dist/es/web/index.mjs
CHANGED
|
@@ -158,10 +158,11 @@ function useSharedContext() {
|
|
|
158
158
|
* @param guestConnection - The established guest connection.
|
|
159
159
|
*/
|
|
160
160
|
function useLiveSharedContext(guestConnection) {
|
|
161
|
-
|
|
161
|
+
const subscribe = useCallback((onContextChange) => {
|
|
162
162
|
if (!guestConnection) return () => void 0;
|
|
163
163
|
return guestConnection.addEventListener("contextchange", onContextChange);
|
|
164
|
-
}, [guestConnection])
|
|
164
|
+
}, [guestConnection]);
|
|
165
|
+
return useSyncExternalStore(subscribe, () => guestConnection?.sharedContext ?? null);
|
|
165
166
|
}
|
|
166
167
|
/**
|
|
167
168
|
* Provides the Commerce shared context for a mounted Admin UI iframe app.
|
|
@@ -232,7 +233,8 @@ function getCommerceHostPromise(extensionId, connection) {
|
|
|
232
233
|
const { integration } = connection.host;
|
|
233
234
|
if (!integration) return error("The host does not provide the integration API needed to resolve the Commerce host.");
|
|
234
235
|
try {
|
|
235
|
-
|
|
236
|
+
const commerceHost = await integration.getCommerceHost();
|
|
237
|
+
return ok({ commerceHost });
|
|
236
238
|
} catch (cause) {
|
|
237
239
|
return error("Failed to resolve the Commerce host.", { cause });
|
|
238
240
|
}
|
|
@@ -651,9 +653,10 @@ function ControlFrameRegistration(props) {
|
|
|
651
653
|
*/
|
|
652
654
|
function CommerceGuestConnection(props) {
|
|
653
655
|
const { extensionId } = props;
|
|
656
|
+
const guestConnection = useGuestConnection(extensionId);
|
|
654
657
|
return /* @__PURE__ */ jsx(SharedContextProvider, {
|
|
655
658
|
extensionId,
|
|
656
|
-
guestConnection
|
|
659
|
+
guestConnection,
|
|
657
660
|
children: /* @__PURE__ */ jsx(CommerceExtensionContent, {})
|
|
658
661
|
});
|
|
659
662
|
}
|
|
@@ -661,8 +664,9 @@ function CommerceGuestConnection(props) {
|
|
|
661
664
|
function CommerceExtensionContent() {
|
|
662
665
|
const { data, error } = useSharedContext();
|
|
663
666
|
if (error) throw error;
|
|
667
|
+
const credentials = resolveCommerceImsCredentials(data.sharedContext);
|
|
664
668
|
return /* @__PURE__ */ jsx(ImsContextProvider, {
|
|
665
|
-
credentials
|
|
669
|
+
credentials,
|
|
666
670
|
children: /* @__PURE__ */ jsx(Outlet, {})
|
|
667
671
|
});
|
|
668
672
|
}
|
|
@@ -751,13 +755,16 @@ function ExperienceShellExtensionApp(props) {
|
|
|
751
755
|
*/
|
|
752
756
|
function ShellExtensionContent(props) {
|
|
753
757
|
const { initialConfigurationPromise, runtime } = props;
|
|
754
|
-
const
|
|
758
|
+
const initialConfiguration = use(initialConfigurationPromise);
|
|
759
|
+
const shellConfiguration = useShellConfiguration(runtime, initialConfiguration);
|
|
755
760
|
const spectrumRouter = useSpectrumRouter();
|
|
761
|
+
const colorScheme = useExtensionColorScheme(shellConfiguration);
|
|
762
|
+
const credentials = resolveShellImsCredentials(shellConfiguration);
|
|
756
763
|
return /* @__PURE__ */ jsx(Provider, {
|
|
757
|
-
colorScheme
|
|
764
|
+
colorScheme,
|
|
758
765
|
router: spectrumRouter,
|
|
759
766
|
children: /* @__PURE__ */ jsx(ExtensionErrorBoundary, { children: /* @__PURE__ */ jsx(ImsContextProvider, {
|
|
760
|
-
credentials
|
|
767
|
+
credentials,
|
|
761
768
|
children: /* @__PURE__ */ jsx(Outlet, {})
|
|
762
769
|
}) })
|
|
763
770
|
});
|
|
@@ -805,9 +812,11 @@ function Entrypoint(props) {
|
|
|
805
812
|
* Mounts a Commerce Admin UI iframe app and handles Experience Cloud Shell, UIX
|
|
806
813
|
* registration, shared-context attachment, routing, and Spectrum setup.
|
|
807
814
|
*
|
|
808
|
-
* The app is wrapped in React's `<StrictMode
|
|
809
|
-
*
|
|
810
|
-
* an extra setup + cleanup cycle on mount. Production builds
|
|
815
|
+
* The app is wrapped in React's `<StrictMode>` only in development builds
|
|
816
|
+
* (`process.env.NODE_ENV !== "production"`), so components render twice and effects
|
|
817
|
+
* run an extra setup + cleanup cycle on mount. Production builds
|
|
818
|
+
* (`process.env.NODE_ENV === "production"`) render without `<StrictMode>`, so it is
|
|
819
|
+
* stripped from the production bundle.
|
|
811
820
|
*
|
|
812
821
|
* @param options - App bootstrap options.
|
|
813
822
|
*
|
|
@@ -828,15 +837,18 @@ function createExtensionApp({ menu, metadata, routes = [], root: customRoot }) {
|
|
|
828
837
|
if (!rootElement) throw new Error("Could not find an element with id \"root\".");
|
|
829
838
|
const root = createRoot(rootElement);
|
|
830
839
|
const render = (runtime, initialConfigurationPromise) => {
|
|
831
|
-
const
|
|
840
|
+
const entrypointProps = {
|
|
832
841
|
extensionId: metadata.extensionId,
|
|
833
842
|
initialConfigurationPromise,
|
|
834
843
|
runtime
|
|
835
|
-
}
|
|
844
|
+
};
|
|
845
|
+
const entrypoint = /* @__PURE__ */ jsx(Entrypoint, { ...entrypointProps });
|
|
846
|
+
const router = createExtensionRouter(entrypoint, menu === void 0 ? routes : [{
|
|
836
847
|
element: menu,
|
|
837
848
|
path: "/"
|
|
838
849
|
}, ...routes]);
|
|
839
|
-
|
|
850
|
+
const tree = /* @__PURE__ */ jsx(RouterProvider, { router });
|
|
851
|
+
root.render(process.env.NODE_ENV === "production" ? tree : /* @__PURE__ */ jsx(StrictMode, { children: tree }));
|
|
840
852
|
};
|
|
841
853
|
try {
|
|
842
854
|
loadExperienceCloudRuntime();
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@adobe/aio-commerce-lib-admin-ui",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"author": "Adobe Inc.",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "1.0.1-alpha-20260819113253",
|
|
6
6
|
"private": false,
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=22 <=24"
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
"ky": "^1.9.0",
|
|
114
114
|
"react-error-boundary": "^6.1.2",
|
|
115
115
|
"valibot": "^1.1.0",
|
|
116
|
-
"@adobe/aio-commerce-lib-api": "1.3.
|
|
116
|
+
"@adobe/aio-commerce-lib-api": "1.3.1-alpha-20260819113253",
|
|
117
117
|
"@adobe/aio-commerce-lib-core": "1.2.0"
|
|
118
118
|
},
|
|
119
119
|
"peerDependencies": {
|
|
@@ -144,8 +144,8 @@
|
|
|
144
144
|
"@aio-commerce-sdk/config-typedoc": "1.0.0",
|
|
145
145
|
"@aio-commerce-sdk/config-typescript": "1.0.0",
|
|
146
146
|
"@aio-commerce-sdk/config-vitest": "1.0.0",
|
|
147
|
-
"@aio-commerce-sdk/scripting-utils": "0.3.
|
|
148
|
-
"@aio-commerce-sdk/scripts": "0.1.
|
|
147
|
+
"@aio-commerce-sdk/scripting-utils": "0.3.5-alpha-20260819113253",
|
|
148
|
+
"@aio-commerce-sdk/scripts": "0.1.1"
|
|
149
149
|
},
|
|
150
150
|
"sideEffects": false,
|
|
151
151
|
"scripts": {
|