@adobe/aio-commerce-lib-admin-ui 0.1.0 → 0.2.0-alpha-20260722091448
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/README.md +1 -1
- package/dist/cjs/acl-resource-id-DBlYU0DE.d.cts +39 -0
- package/dist/cjs/acl-resource-id-D_hCU1Qg.cjs +69 -0
- package/dist/cjs/api/index.cjs +252 -0
- package/dist/cjs/api/index.d.cts +126 -0
- package/dist/cjs/grid-columns/index.cjs +151 -0
- package/dist/cjs/grid-columns/index.d.cts +146 -0
- package/dist/cjs/mass-actions/index.cjs +188 -0
- package/dist/cjs/mass-actions/index.d.cts +160 -0
- package/dist/cjs/menu/index.cjs +91 -0
- package/dist/cjs/menu/index.d.cts +63 -0
- package/dist/cjs/order-view-buttons/index.cjs +126 -0
- package/dist/cjs/order-view-buttons/index.d.cts +113 -0
- package/dist/cjs/rolldown-runtime-Cx6hovH8.cjs +67 -0
- package/dist/cjs/schemas-Ce10uBzN.cjs +41 -0
- package/dist/cjs/utils-B59fjd_w.cjs +39 -0
- package/dist/cjs/web/index.cjs +872 -0
- package/dist/cjs/web/index.d.cts +206 -0
- package/dist/es/acl-resource-id-DBlYU0DE.d.mts +39 -0
- package/dist/es/acl-resource-id-pryVxI_c.mjs +57 -0
- package/dist/es/api/index.d.mts +126 -0
- package/dist/es/api/index.mjs +262 -0
- package/dist/es/grid-columns/index.d.mts +146 -0
- package/dist/es/grid-columns/index.mjs +143 -0
- package/dist/es/mass-actions/index.d.mts +160 -0
- package/dist/es/mass-actions/index.mjs +178 -0
- package/dist/es/menu/index.d.mts +63 -0
- package/dist/es/menu/index.mjs +80 -0
- package/dist/es/order-view-buttons/index.d.mts +113 -0
- package/dist/es/order-view-buttons/index.mjs +119 -0
- package/dist/es/schemas-BFT8ys8P.mjs +34 -0
- package/dist/es/utils-COPGW1HO.mjs +32 -0
- package/dist/es/web/index.d.mts +206 -0
- package/dist/es/web/index.mjs +861 -0
- package/package.json +87 -10
- package/dist/cjs/index.cjs +0 -139
- package/dist/cjs/index.d.cts +0 -56
- package/dist/es/index.d.mts +0 -56
- package/dist/es/index.mjs +0 -114
|
@@ -0,0 +1,206 @@
|
|
|
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 { attach } from "@adobe/uix-guest";
|
|
17
|
+
import { NavigateOptions, ToOptions } from "@tanstack/react-router";
|
|
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/result.d.ts
|
|
27
|
+
/** The result of reading data that might not be available in the current host context. */
|
|
28
|
+
type Result<T, E = Error> = {
|
|
29
|
+
data: T;
|
|
30
|
+
error: null;
|
|
31
|
+
} | {
|
|
32
|
+
data: null;
|
|
33
|
+
error: E;
|
|
34
|
+
};
|
|
35
|
+
type ActionMap = {
|
|
36
|
+
[key: string]: (...args: unknown[]) => PromiseLike<unknown>;
|
|
37
|
+
};
|
|
38
|
+
/** The result of exposing an API that might not be available in the current host context. */
|
|
39
|
+
type ActionsResult<T extends ActionMap, E = Error> = {
|
|
40
|
+
actions: T;
|
|
41
|
+
error: null;
|
|
42
|
+
} | {
|
|
43
|
+
actions: null;
|
|
44
|
+
error: E;
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region source/web/react/auth/context/ims-context.d.ts
|
|
48
|
+
/**
|
|
49
|
+
* Returns the IMS credentials provided by the host. Works inside the Commerce Admin and the
|
|
50
|
+
* Experience Cloud shell.
|
|
51
|
+
*
|
|
52
|
+
* Returns an error when no host provides credentials.
|
|
53
|
+
*/
|
|
54
|
+
declare function useIms(): Result<ImsContext>;
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region source/web/react/commerce/types.d.ts
|
|
57
|
+
/** The guest connection that shares the context between the extension and the Admin UI host. */
|
|
58
|
+
type GuestConnection = Awaited<ReturnType<typeof attach>>;
|
|
59
|
+
/**
|
|
60
|
+
* The Commerce shared context for a mounted Admin UI iframe app.
|
|
61
|
+
*
|
|
62
|
+
* This only exists when the app runs inside the Commerce Admin: it is provided by the Commerce UIX
|
|
63
|
+
* host over the guest connection. It is distinct from the IMS credentials ({@link ImsContext}),
|
|
64
|
+
* which are also available in the Experience Cloud shell.
|
|
65
|
+
*/
|
|
66
|
+
type SharedContext = {
|
|
67
|
+
/** The extension ID of the app. */extensionId: string; /** The live `sharedContext` object provided by the host. */
|
|
68
|
+
sharedContext: NonNullable<GuestConnection["sharedContext"]>; /** The host proxy, used by `useHostConnection` to invoke host-frame actions (close/onError). */
|
|
69
|
+
host: NonNullable<GuestConnection["host"]>;
|
|
70
|
+
};
|
|
71
|
+
/** Actions for closing the extension iframe and returning control to the Commerce Admin. */
|
|
72
|
+
type HostConnection = {
|
|
73
|
+
/** 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. */
|
|
74
|
+
closeWithError: () => Promise<void>;
|
|
75
|
+
};
|
|
76
|
+
/** The context shared with mass-action extension points. */
|
|
77
|
+
type MassActionContext = {
|
|
78
|
+
selectedIds: string[];
|
|
79
|
+
};
|
|
80
|
+
/** The context shared with order view-button extension points. */
|
|
81
|
+
type OrderViewButtonContext = {
|
|
82
|
+
orderId: string;
|
|
83
|
+
};
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region source/web/react/commerce/context/shared-context.d.ts
|
|
86
|
+
/**
|
|
87
|
+
* Returns the current Commerce shared context. The guest connection is already established by
|
|
88
|
+
* the time this can be called (see {@link SharedContextProvider}).
|
|
89
|
+
*
|
|
90
|
+
* This is a low-level escape hatch that exposes the raw `sharedContext` and `host` objects.
|
|
91
|
+
* Prefer a purpose-built hook ({@link useCommerce}, {@link useMassActionContext},
|
|
92
|
+
* {@link useOrderViewButtonContext}) when one covers what you need.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```tsx
|
|
96
|
+
* import { useSharedContext } from "@adobe/aio-commerce-lib-admin-ui/web";
|
|
97
|
+
*
|
|
98
|
+
* function ImsTokenLabel() {
|
|
99
|
+
* const { data, error } = useSharedContext();
|
|
100
|
+
* if (error) return null;
|
|
101
|
+
* return <span>{data.sharedContext.get("imsToken")}</span>;
|
|
102
|
+
* }
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
declare function useSharedContext(): Result<SharedContext>;
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region source/web/react/commerce/hooks/use-commerce.d.ts
|
|
108
|
+
type CommerceData = {
|
|
109
|
+
commerceHost: string;
|
|
110
|
+
};
|
|
111
|
+
/** Drops a failed Commerce host resolution for `extensionId`, so a later render retries it. */
|
|
112
|
+
/**
|
|
113
|
+
* Returns the host (domain) of the Commerce Admin the extension is embedded in, resolving it over
|
|
114
|
+
* the guest connection.
|
|
115
|
+
*
|
|
116
|
+
* Returns an error when used outside a Commerce Admin UI frame, when the host does not expose the
|
|
117
|
+
* Commerce integration API, or when resolving the host fails.
|
|
118
|
+
*/
|
|
119
|
+
declare function useCommerce(): Result<CommerceData>;
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region source/web/react/commerce/hooks/use-extension-context.d.ts
|
|
122
|
+
/**
|
|
123
|
+
* Returns the context for a mass-action extension point: the selected row IDs the action was
|
|
124
|
+
* triggered with. The value is read from the host-provided Commerce context.
|
|
125
|
+
*
|
|
126
|
+
* Returns an error outside the Commerce shared context, or when the mass-action selection is
|
|
127
|
+
* missing, empty, or contains a non-string row ID.
|
|
128
|
+
*/
|
|
129
|
+
declare function useMassActionContext(): Result<MassActionContext>;
|
|
130
|
+
/**
|
|
131
|
+
* Returns the context for an order view-button extension point: the order ID the button was
|
|
132
|
+
* triggered from.
|
|
133
|
+
*
|
|
134
|
+
* Returns an error when no order ID is present in the page URL.
|
|
135
|
+
*/
|
|
136
|
+
declare function useOrderViewButtonContext(): Result<OrderViewButtonContext>;
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region source/web/react/commerce/hooks/use-host-connection.d.ts
|
|
139
|
+
/**
|
|
140
|
+
* Returns typed helpers for interacting with the Commerce Admin host.
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```tsx
|
|
144
|
+
* import { useHostConnection } from "@adobe/aio-commerce-lib-admin-ui/web";
|
|
145
|
+
*
|
|
146
|
+
* function DoneButton() {
|
|
147
|
+
* const { actions, error } = useHostConnection();
|
|
148
|
+
* if (error) return null;
|
|
149
|
+
* return <button onClick={actions.close}>Done</button>;
|
|
150
|
+
* }
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
declare function useHostConnection(): ActionsResult<HostConnection>;
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region source/web/react/routing/types.d.ts
|
|
156
|
+
declare module "@react-spectrum/s2/Provider" {
|
|
157
|
+
interface RouterConfig {
|
|
158
|
+
href: ToOptions;
|
|
159
|
+
routerOptions: Omit<NavigateOptions, keyof ToOptions>;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/** Defines a route that exists at a given path. */
|
|
163
|
+
type ExtensionRoute = {
|
|
164
|
+
/** The path for the route. */path: string; /** The React element to render for the route. */
|
|
165
|
+
element: ReactNode;
|
|
166
|
+
};
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region source/web/react/extension/create-app.d.ts
|
|
169
|
+
/** Configuration options when instantiating an extension app. */
|
|
170
|
+
type CreateExtensionAppOptions = {
|
|
171
|
+
/** General metadata about the extension app. */metadata: {
|
|
172
|
+
/** The unique identifier for the extension app. */extensionId: string;
|
|
173
|
+
}; /** The optional app page opened from the Commerce Admin menu and by default in Experience Cloud Shell. */
|
|
174
|
+
menu?: ReactNode; /** Optional root element where the app will be mounted. */
|
|
175
|
+
root?: HTMLElement; /** Additional path-based routes for the extension app. */
|
|
176
|
+
routes?: ExtensionRoute[];
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* Mounts a Commerce Admin UI iframe app and handles Experience Cloud Shell, UIX
|
|
180
|
+
* registration, shared-context attachment, routing, and Spectrum setup.
|
|
181
|
+
*
|
|
182
|
+
* The app is wrapped in React's `<StrictMode>`, so in development builds (e.g. when
|
|
183
|
+
* served via `aio app dev` or `aio app run`) components render twice and effects run
|
|
184
|
+
* an extra setup + cleanup cycle on mount. Production builds are unaffected.
|
|
185
|
+
*
|
|
186
|
+
* @param options - App bootstrap options.
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* ```tsx
|
|
190
|
+
* import { createExtensionApp } from "@adobe/aio-commerce-lib-admin-ui/web";
|
|
191
|
+
* import { MainPage } from "./pages/main-page.jsx";
|
|
192
|
+
*
|
|
193
|
+
* createExtensionApp({
|
|
194
|
+
* metadata: { extensionId: "my-extension-id" },
|
|
195
|
+
* menu: <MainPage />,
|
|
196
|
+
* });
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
declare function createExtensionApp({
|
|
200
|
+
menu,
|
|
201
|
+
metadata,
|
|
202
|
+
routes,
|
|
203
|
+
root: customRoot
|
|
204
|
+
}: CreateExtensionAppOptions): void;
|
|
205
|
+
//#endregion
|
|
206
|
+
export { type CreateExtensionAppOptions, type ExtensionRoute, type HostConnection, type ImsContext, type MassActionContext, type OrderViewButtonContext, type SharedContext, createExtensionApp, useCommerce, useHostConnection, useIms, useMassActionContext, useOrderViewButtonContext, useSharedContext };
|
|
@@ -0,0 +1,39 @@
|
|
|
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 };
|
|
@@ -0,0 +1,57 @@
|
|
|
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 };
|
|
@@ -0,0 +1,126 @@
|
|
|
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 getAclResourceId, t as AdminUiEntity } from "../acl-resource-id-DBlYU0DE.mjs";
|
|
16
|
+
import { CommerceSdkErrorBase, CommerceSdkErrorOptions } from "@adobe/aio-commerce-lib-core/error";
|
|
17
|
+
import { AdobeCommerceHttpClient, CommerceHttpClientParams } from "@adobe/aio-commerce-lib-api";
|
|
18
|
+
import * as v from "valibot";
|
|
19
|
+
|
|
20
|
+
//#region source/errors.d.ts
|
|
21
|
+
/** Base error for Admin UI SDK permission helper failures. */
|
|
22
|
+
declare class AdminUiPermissionError extends CommerceSdkErrorBase {}
|
|
23
|
+
/** Options for {@link AdminUiPermissionDeniedError}. */
|
|
24
|
+
type AdminUiPermissionDeniedErrorOptions = CommerceSdkErrorOptions;
|
|
25
|
+
/** Error thrown when the current user is denied access to an Admin UI SDK ACL resource. */
|
|
26
|
+
declare class AdminUiPermissionDeniedError extends AdminUiPermissionError {
|
|
27
|
+
readonly resource: string;
|
|
28
|
+
constructor(resource: string, options?: AdminUiPermissionDeniedErrorOptions);
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region source/api/lib/api-client.d.ts
|
|
32
|
+
/**
|
|
33
|
+
* Creates a new API client for the Admin UI API with all available operations.
|
|
34
|
+
*
|
|
35
|
+
* @param params - The parameters to build the Commerce HTTP client.
|
|
36
|
+
*/
|
|
37
|
+
declare function createAdminUiApiClient(params: CommerceHttpClientParams): import("@adobe/aio-commerce-lib-api").ApiClientRecord<AdobeCommerceHttpClient, {
|
|
38
|
+
registerExtension(httpClient: AdobeCommerceHttpClient, params: ExtensionRegistrationParams, fetchOptions?: import("ky").Options): Promise<RegisterExtensionResponse>;
|
|
39
|
+
unregisterExtension(httpClient: AdobeCommerceHttpClient, params: UnregisterExtensionParams, fetchOptions?: import("ky").Options): Promise<void>;
|
|
40
|
+
enableAdminUiSdk(httpClient: AdobeCommerceHttpClient, fetchOptions?: import("ky").Options): Promise<boolean>;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* An API client for the Admin UI API with all operations.
|
|
44
|
+
* @see {@link createAdminUiApiClient}
|
|
45
|
+
*/
|
|
46
|
+
type AdminUiApiClient = ReturnType<typeof createAdminUiApiClient>;
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region source/api/lib/permission-client.d.ts
|
|
49
|
+
/** Options used to create an Admin UI SDK permission client. */
|
|
50
|
+
type AdminUiPermissionClientOptions = {
|
|
51
|
+
/** The application's `metadata.id` value. When provided, `check()` and `require()` can be called with no resource argument. */appId?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Milliseconds to cache a permission result. Default: 300_000 (5 minutes).
|
|
54
|
+
* Set to 0 to disable result caching. Note: in-flight deduplication of concurrent identical
|
|
55
|
+
* requests is independent of this setting and remains active even when caching is disabled.
|
|
56
|
+
*/
|
|
57
|
+
cacheTtlMs?: number; /** Return false instead of throwing when a network or parse error occurs. Default: true. */
|
|
58
|
+
denyOnError?: boolean; /** Commerce HTTP client used to call the Admin UI SDK permission endpoint. */
|
|
59
|
+
httpClient: AdobeCommerceHttpClient;
|
|
60
|
+
};
|
|
61
|
+
/** Client for checking the current user's Admin UI SDK resource permissions. */
|
|
62
|
+
type AdminUiPermissionClient = {
|
|
63
|
+
/**
|
|
64
|
+
* Checks whether the current user has the given ACL resource granted.
|
|
65
|
+
*
|
|
66
|
+
* @param resource - The ACL resource id to check. When omitted, defaults to the id derived from `appId`.
|
|
67
|
+
* @returns `true` when granted; `false` when denied, on network or parse errors while `denyOnError` is
|
|
68
|
+
* `true` (the default), or immediately when neither `resource` nor a valid `appId` is available.
|
|
69
|
+
* @throws {@link AdminUiPermissionError} on HTTP 401, regardless of `denyOnError`.
|
|
70
|
+
*/
|
|
71
|
+
check: (resource?: string) => Promise<boolean>;
|
|
72
|
+
/**
|
|
73
|
+
* Clears cached permission results.
|
|
74
|
+
*
|
|
75
|
+
* @param resource - The ACL resource id whose cached result to clear. When omitted, clears all cached
|
|
76
|
+
* entries and in-flight tracking without aborting outstanding HTTP requests.
|
|
77
|
+
*/
|
|
78
|
+
invalidate: (resource?: string) => void;
|
|
79
|
+
/**
|
|
80
|
+
* Resolves when the current user has the given ACL resource granted.
|
|
81
|
+
*
|
|
82
|
+
* @param resource - The ACL resource id to require. When omitted, defaults to the id derived from `appId`.
|
|
83
|
+
* @throws {@link AdminUiPermissionDeniedError} when the resource is explicitly denied.
|
|
84
|
+
* @throws {@link AdminUiPermissionError} on HTTP 401, on network or parse errors while `denyOnError` is
|
|
85
|
+
* `false`, or immediately when neither `resource` nor a valid `appId` is available.
|
|
86
|
+
*/
|
|
87
|
+
require: (resource?: string) => Promise<void>;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Creates a client for checking Admin UI SDK ACL resources.
|
|
91
|
+
*
|
|
92
|
+
* @param options - Client configuration; see {@link AdminUiPermissionClientOptions}.
|
|
93
|
+
* @returns An {@link AdminUiPermissionClient} for checking and requiring ACL resources.
|
|
94
|
+
*/
|
|
95
|
+
declare function getAdminUiPermissionClient(options: AdminUiPermissionClientOptions): AdminUiPermissionClient;
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region source/api/extensions/schema.d.ts
|
|
98
|
+
/** Parameters for POST /V1/adminuisdk/extension. */
|
|
99
|
+
declare const ExtensionRegistrationParamsSchema: v.ObjectSchema<{
|
|
100
|
+
readonly extensionName: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
101
|
+
readonly extensionTitle: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
102
|
+
readonly extensionWorkspace: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
103
|
+
}, undefined>;
|
|
104
|
+
/** Parameters for DELETE /V1/adminuisdk/extension/{workspaceName}/{extensionName}. */
|
|
105
|
+
declare const UnregisterExtensionParamsSchema: v.ObjectSchema<{
|
|
106
|
+
readonly extensionName: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
107
|
+
readonly workspaceName: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
108
|
+
}, undefined>;
|
|
109
|
+
/** The parameters accepted by POST /V1/adminuisdk/extension. */
|
|
110
|
+
type ExtensionRegistrationParams = v.InferInput<typeof ExtensionRegistrationParamsSchema>;
|
|
111
|
+
/** The parameters accepted by DELETE /V1/adminuisdk/extension/{workspaceName}/{extensionName}. */
|
|
112
|
+
type UnregisterExtensionParams = v.InferInput<typeof UnregisterExtensionParamsSchema>;
|
|
113
|
+
/** The response returned by POST /V1/adminuisdk/extension. */
|
|
114
|
+
type RegisterExtensionResponse = {
|
|
115
|
+
extensionId: string;
|
|
116
|
+
};
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region source/api/permissions/schema.d.ts
|
|
119
|
+
/** Response shape returned by the Admin UI SDK permission check endpoint. */
|
|
120
|
+
declare const permissionCheckResponseSchema: v.ObjectSchema<{
|
|
121
|
+
readonly allowed: v.BooleanSchema<undefined>;
|
|
122
|
+
}, undefined>;
|
|
123
|
+
/** Parsed Admin UI SDK permission check response. */
|
|
124
|
+
type PermissionCheckResponse = v.InferOutput<typeof permissionCheckResponseSchema>;
|
|
125
|
+
//#endregion
|
|
126
|
+
export { AdminUiApiClient, type AdminUiEntity, AdminUiPermissionClient, AdminUiPermissionClientOptions, AdminUiPermissionDeniedError, AdminUiPermissionDeniedErrorOptions, AdminUiPermissionError, type ExtensionRegistrationParams, type ExtensionRegistrationParamsSchema, type PermissionCheckResponse, type RegisterExtensionResponse, type UnregisterExtensionParams, type UnregisterExtensionParamsSchema, createAdminUiApiClient, getAclResourceId, getAdminUiPermissionClient, type permissionCheckResponseSchema };
|