@adobe/aio-commerce-lib-admin-ui 0.2.0-beta-20260721105643 → 1.0.0
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 +9 -21
- package/dist/cjs/api/index.d.cts +6 -4
- package/dist/cjs/grid-columns/index.d.cts +0 -1
- package/dist/cjs/mass-actions/index.cjs +1 -55
- package/dist/cjs/mass-actions/index.d.cts +1 -43
- package/dist/cjs/order-view-buttons/index.d.cts +0 -1
- package/dist/cjs/web/index.d.cts +22 -17
- package/dist/es/api/index.d.mts +6 -4
- package/dist/es/grid-columns/index.d.mts +0 -1
- package/dist/es/mass-actions/index.d.mts +1 -43
- package/dist/es/mass-actions/index.mjs +1 -53
- package/dist/es/order-view-buttons/index.d.mts +0 -1
- package/dist/es/web/index.d.mts +22 -17
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,50 +1,38 @@
|
|
|
1
1
|
# @adobe/aio-commerce-lib-admin-ui
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
4
|
-
### Minor Changes
|
|
3
|
+
## 1.0.0
|
|
5
4
|
|
|
5
|
+
### Major Changes
|
|
6
6
|
|
|
7
|
+
- [#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.
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
## 0.2.0
|
|
9
10
|
|
|
11
|
+
### Minor Changes
|
|
10
12
|
|
|
13
|
+
- [#528](https://github.com/adobe/aio-commerce-sdk/pull/528) [`0bb7d15`](https://github.com/adobe/aio-commerce-sdk/commit/0bb7d150961f631116b1ac421124960b5b857896) Thanks [@oshmyheliuk](https://github.com/oshmyheliuk)! - Add `getGridColumnAclResourceId`, `getMassActionAclResourceId`, and `getOrderViewButtonAclResourceId` helpers to derive the Commerce ACL resource id for protected grid columns, mass actions, and order view buttons, mirroring `getMenuAclResourceId`.
|
|
11
14
|
|
|
12
15
|
- [#522](https://github.com/adobe/aio-commerce-sdk/pull/522) [`4396a64`](https://github.com/adobe/aio-commerce-sdk/commit/4396a647ad22dba063cdf03a16e04aef9387212f) Thanks [@oshmyheliuk](https://github.com/oshmyheliuk)! - Add `getAdminUiPermissionClient` for checking ACL permissions at runtime (SPA bootstrap and runtime action entry). Includes in-process TTL cache, in-flight request deduplication, and deny-by-default on errors. Also exports `getAclResourceId` for deterministic ACL resource id derivation from `metadata.id`.
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
|
|
16
17
|
- [#542](https://github.com/adobe/aio-commerce-sdk/pull/542) [`c15b50f`](https://github.com/adobe/aio-commerce-sdk/commit/c15b50f667e6d1288270dbd4192c150db0ff0914) Thanks [@iivvaannxx](https://github.com/iivvaannxx)! - Add browser helpers for Admin UI iframe extensions.
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
19
|
- [#508](https://github.com/adobe/aio-commerce-sdk/pull/508) [`c36f825`](https://github.com/adobe/aio-commerce-sdk/commit/c36f825aff7329fc2831d8aaca032d17bbee373a) Thanks [@iivvaannxx](https://github.com/iivvaannxx)! - Add `@adobe/aio-commerce-lib-admin-ui/menu` entrypoint with named constants for Commerce Admin menu IDs (`MENU_SALES`, `MENU_CATALOG`, etc.), a `COMMERCE_MENUS` collection, a `CommerceMenu` type, and an `isCommerceMenu` type guard.
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
21
|
- [#516](https://github.com/adobe/aio-commerce-sdk/pull/516) [`bdcced9`](https://github.com/adobe/aio-commerce-sdk/commit/bdcced9297ae5e1b87ce86490a2b6fad76b2e341) Thanks [@obarcelonap](https://github.com/obarcelonap)! - Add `order-view-buttons` entrypoint with request parsing and response builders for `commerce/backend-ui/2` order view button handlers.
|
|
25
22
|
|
|
26
|
-
|
|
27
|
-
|
|
28
23
|
- [#551](https://github.com/adobe/aio-commerce-sdk/pull/551) [`a66f389`](https://github.com/adobe/aio-commerce-sdk/commit/a66f3892622584d27cd6b5d2fc633e15bf9942a8) Thanks [@asalloum5](https://github.com/asalloum5)! - Add `enableAdminUiSdk` to the Admin UI API client, which enables the Admin UI SDK in Commerce via `PUT /V1/adminuisdk/config`.
|
|
29
24
|
|
|
30
|
-
|
|
31
|
-
|
|
32
25
|
- [#486](https://github.com/adobe/aio-commerce-sdk/pull/486) [`413da36`](https://github.com/adobe/aio-commerce-sdk/commit/413da36dcd83e5a41c194f5af50611097659e725) Thanks [@obarcelonap](https://github.com/obarcelonap)! - Add request and response builders for the `commerce/backend-ui/2` grid column wire contract.
|
|
33
26
|
|
|
34
|
-
|
|
35
|
-
|
|
36
27
|
- [#546](https://github.com/adobe/aio-commerce-sdk/pull/546) [`ca2c4fe`](https://github.com/adobe/aio-commerce-sdk/commit/ca2c4febcdfbe52b933775f08e9a53765fc306ab) Thanks [@obarcelonap](https://github.com/obarcelonap)! - Remove `extensionUrl` from extension registration params. The Commerce backend now derives the view URL from the App Registry, so the field has no effect for v2 installed apps.
|
|
37
28
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
- [#492](https://github.com/adobe/aio-commerce-sdk/pull/492) [`ce63b2b`](https://github.com/adobe/aio-commerce-sdk/commit/ce63b2b46f7ef1f2f68780b13e52d1c13fd5fe6e) Thanks [@jcuerdo](https://github.com/jcuerdo)! - Add `mass-actions` entrypoint with wire contract helpers for `commerce/backend-ui/2` mass actions. Parse worker action requests with `parseMassActionRequest`, build success/error responses with `okMassActionResponse`/`errorMassActionResponse`, and parse iframe selection parameters with `parseMassActionSelection`.
|
|
41
|
-
|
|
29
|
+
- [#492](https://github.com/adobe/aio-commerce-sdk/pull/492) [`ce63b2b`](https://github.com/adobe/aio-commerce-sdk/commit/ce63b2b46f7ef1f2f68780b13e52d1c13fd5fe6e) Thanks [@jcuerdo](https://github.com/jcuerdo)! - Add `mass-actions` entrypoint with wire contract helpers for `commerce/backend-ui/2` mass actions. Parse worker action requests with `parseMassActionRequest`, and build success/error responses with `okMassActionResponse`/`errorMassActionResponse`.
|
|
42
30
|
|
|
43
31
|
### Patch Changes
|
|
44
32
|
|
|
45
33
|
- Updated dependencies [[`19400fb`](https://github.com/adobe/aio-commerce-sdk/commit/19400fbdfc03c5bbfc30f995a2acdd4272c5e032), [`ce7768e`](https://github.com/adobe/aio-commerce-sdk/commit/ce7768e0ddc6ca35ad6ccec60f584c8bb5a743f0), [`4396a64`](https://github.com/adobe/aio-commerce-sdk/commit/4396a647ad22dba063cdf03a16e04aef9387212f), [`e85bec4`](https://github.com/adobe/aio-commerce-sdk/commit/e85bec40f1eaa91dd6bb7bc6954b2ecfc3ea4029), [`413da36`](https://github.com/adobe/aio-commerce-sdk/commit/413da36dcd83e5a41c194f5af50611097659e725)]:
|
|
46
|
-
- @adobe/aio-commerce-lib-core@1.2.0
|
|
47
|
-
- @adobe/aio-commerce-lib-api@1.3.0
|
|
34
|
+
- @adobe/aio-commerce-lib-core@1.2.0
|
|
35
|
+
- @adobe/aio-commerce-lib-api@1.3.0
|
|
48
36
|
|
|
49
37
|
## 0.1.0
|
|
50
38
|
|
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. */
|
|
@@ -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.
|
|
@@ -51,58 +51,6 @@ function getMassActionAclResourceId(metadataId, entity, actionId) {
|
|
|
51
51
|
return `${appRoot}_${entity}_massactions_${require_acl_resource_id.sanitizeSegment(actionId)}`;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
//#endregion
|
|
55
|
-
//#region source/mass-actions/view/schema.ts
|
|
56
|
-
/**
|
|
57
|
-
* Schema for the `selection` query parameter Commerce appends to the iframe URL
|
|
58
|
-
* of a view mass action.
|
|
59
|
-
*
|
|
60
|
-
* Commerce serializes the selection as a JSON-encoded string:
|
|
61
|
-
* `?selection={"ids":["000000001"],"gridType":"customer"}`
|
|
62
|
-
*/
|
|
63
|
-
const MassActionSelectionSchema = valibot.object({
|
|
64
|
-
gridType: valibot.picklist([
|
|
65
|
-
"order",
|
|
66
|
-
"product",
|
|
67
|
-
"customer"
|
|
68
|
-
]),
|
|
69
|
-
ids: valibot.pipe(valibot.array(require_schemas.nonEmptyStringValueSchema("id")), valibot.minLength(1, "The value of \"ids\" must contain at least one entry"))
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
//#endregion
|
|
73
|
-
//#region source/mass-actions/view/presets.ts
|
|
74
|
-
/**
|
|
75
|
-
* Parses the `selection` query parameter Commerce appends to the iframe URL of
|
|
76
|
-
* a view mass action.
|
|
77
|
-
*
|
|
78
|
-
* Commerce serializes the selection as a JSON string:
|
|
79
|
-
* `?selection={"ids":["000000001","000000002"],"gridType":"customer"}`
|
|
80
|
-
*
|
|
81
|
-
* Throws a `CommerceSdkValidationError` if the input is missing, not valid
|
|
82
|
-
* JSON, or does not match the expected shape.
|
|
83
|
-
*
|
|
84
|
-
* @param rawSelection - The raw string value of the `selection` query parameter.
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* ```ts
|
|
88
|
-
* import { parseMassActionSelection } from "@adobe/aio-commerce-lib-admin-ui/mass-actions";
|
|
89
|
-
*
|
|
90
|
-
* // In your SPA route handler:
|
|
91
|
-
* const raw = new URLSearchParams(window.location.search).get("selection");
|
|
92
|
-
* const { ids, gridType } = parseMassActionSelection(raw);
|
|
93
|
-
* ```
|
|
94
|
-
*/
|
|
95
|
-
function parseMassActionSelection(rawSelection) {
|
|
96
|
-
if (rawSelection === null || rawSelection === void 0) throw new Error("Invalid mass action selection: the selection query parameter is missing.");
|
|
97
|
-
let parsed;
|
|
98
|
-
try {
|
|
99
|
-
parsed = JSON.parse(String(rawSelection));
|
|
100
|
-
} catch (error) {
|
|
101
|
-
throw new Error(`Invalid mass action selection: expected a JSON string, got: ${String(rawSelection)}`, { cause: error });
|
|
102
|
-
}
|
|
103
|
-
return require_utils.parseOrThrow(MassActionSelectionSchema, parsed, "Invalid mass action selection");
|
|
104
|
-
}
|
|
105
|
-
|
|
106
54
|
//#endregion
|
|
107
55
|
//#region source/mass-actions/worker/schema.ts
|
|
108
56
|
/**
|
|
@@ -180,9 +128,7 @@ function massActionErrorResponse(statusCode, errorMessage) {
|
|
|
180
128
|
//#endregion
|
|
181
129
|
exports.MassActionGridTypeSchema = MassActionGridTypeSchema;
|
|
182
130
|
exports.MassActionRequestSchema = MassActionRequestSchema;
|
|
183
|
-
exports.MassActionSelectionSchema = MassActionSelectionSchema;
|
|
184
131
|
exports.getMassActionAclResourceId = getMassActionAclResourceId;
|
|
185
132
|
exports.massActionErrorResponse = massActionErrorResponse;
|
|
186
133
|
exports.okMassActionResponse = okMassActionResponse;
|
|
187
|
-
exports.parseMassActionRequest = parseMassActionRequest;
|
|
188
|
-
exports.parseMassActionSelection = parseMassActionSelection;
|
|
134
|
+
exports.parseMassActionRequest = parseMassActionRequest;
|
|
@@ -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.
|
|
@@ -42,47 +41,6 @@ import { ErrorResponse, SuccessResponse } from "@adobe/aio-commerce-lib-core/res
|
|
|
42
41
|
*/
|
|
43
42
|
declare function getMassActionAclResourceId(metadataId: string, entity: AdminUiEntity, actionId: string): string;
|
|
44
43
|
//#endregion
|
|
45
|
-
//#region source/mass-actions/view/schema.d.ts
|
|
46
|
-
/**
|
|
47
|
-
* Schema for the `selection` query parameter Commerce appends to the iframe URL
|
|
48
|
-
* of a view mass action.
|
|
49
|
-
*
|
|
50
|
-
* Commerce serializes the selection as a JSON-encoded string:
|
|
51
|
-
* `?selection={"ids":["000000001"],"gridType":"customer"}`
|
|
52
|
-
*/
|
|
53
|
-
declare const MassActionSelectionSchema: v.ObjectSchema<{
|
|
54
|
-
readonly gridType: v.PicklistSchema<["order", "product", "customer"], undefined>;
|
|
55
|
-
readonly ids: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>, undefined>, v.MinLengthAction<string[], 1, "The value of \"ids\" must contain at least one entry">]>;
|
|
56
|
-
}, undefined>;
|
|
57
|
-
//#endregion
|
|
58
|
-
//#region source/mass-actions/view/types.d.ts
|
|
59
|
-
/** Parsed `selection` query parameter appended by Commerce to the iframe URL. */
|
|
60
|
-
type MassActionSelection = v.InferOutput<typeof MassActionSelectionSchema>;
|
|
61
|
-
//#endregion
|
|
62
|
-
//#region source/mass-actions/view/presets.d.ts
|
|
63
|
-
/**
|
|
64
|
-
* Parses the `selection` query parameter Commerce appends to the iframe URL of
|
|
65
|
-
* a view mass action.
|
|
66
|
-
*
|
|
67
|
-
* Commerce serializes the selection as a JSON string:
|
|
68
|
-
* `?selection={"ids":["000000001","000000002"],"gridType":"customer"}`
|
|
69
|
-
*
|
|
70
|
-
* Throws a `CommerceSdkValidationError` if the input is missing, not valid
|
|
71
|
-
* JSON, or does not match the expected shape.
|
|
72
|
-
*
|
|
73
|
-
* @param rawSelection - The raw string value of the `selection` query parameter.
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* ```ts
|
|
77
|
-
* import { parseMassActionSelection } from "@adobe/aio-commerce-lib-admin-ui/mass-actions";
|
|
78
|
-
*
|
|
79
|
-
* // In your SPA route handler:
|
|
80
|
-
* const raw = new URLSearchParams(window.location.search).get("selection");
|
|
81
|
-
* const { ids, gridType } = parseMassActionSelection(raw);
|
|
82
|
-
* ```
|
|
83
|
-
*/
|
|
84
|
-
declare function parseMassActionSelection(rawSelection: unknown): MassActionSelection;
|
|
85
|
-
//#endregion
|
|
86
44
|
//#region source/mass-actions/worker/schema.d.ts
|
|
87
45
|
/**
|
|
88
46
|
* Grid identifier sent by Commerce on the `commerce/backend-ui/2` wire contract
|
|
@@ -157,4 +115,4 @@ declare function okMassActionResponse(body?: MassActionResponseBody): SuccessRes
|
|
|
157
115
|
*/
|
|
158
116
|
declare function massActionErrorResponse(statusCode: number, errorMessage: string): ErrorResponse<MassActionErrorBody>;
|
|
159
117
|
//#endregion
|
|
160
|
-
export { type AdminUiEntity, type MassActionErrorBody, type MassActionGridType, MassActionGridTypeSchema, type MassActionRequest, MassActionRequestSchema, type MassActionResponseBody,
|
|
118
|
+
export { type AdminUiEntity, type MassActionErrorBody, type MassActionGridType, MassActionGridTypeSchema, type MassActionRequest, MassActionRequestSchema, type MassActionResponseBody, getMassActionAclResourceId, massActionErrorResponse, okMassActionResponse, parseMassActionRequest };
|
|
@@ -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/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,18 +164,25 @@ 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
|
/**
|
|
@@ -196,11 +206,6 @@ type CreateExtensionAppOptions = {
|
|
|
196
206
|
* });
|
|
197
207
|
* ```
|
|
198
208
|
*/
|
|
199
|
-
declare function createExtensionApp({
|
|
200
|
-
menu,
|
|
201
|
-
metadata,
|
|
202
|
-
routes,
|
|
203
|
-
root: customRoot
|
|
204
|
-
}: CreateExtensionAppOptions): void;
|
|
209
|
+
declare function createExtensionApp({ menu, metadata, routes, root: customRoot }: CreateExtensionAppOptions): void;
|
|
205
210
|
//#endregion
|
|
206
211
|
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. */
|
|
@@ -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.
|
|
@@ -42,47 +41,6 @@ import { ErrorResponse, SuccessResponse } from "@adobe/aio-commerce-lib-core/res
|
|
|
42
41
|
*/
|
|
43
42
|
declare function getMassActionAclResourceId(metadataId: string, entity: AdminUiEntity, actionId: string): string;
|
|
44
43
|
//#endregion
|
|
45
|
-
//#region source/mass-actions/view/schema.d.ts
|
|
46
|
-
/**
|
|
47
|
-
* Schema for the `selection` query parameter Commerce appends to the iframe URL
|
|
48
|
-
* of a view mass action.
|
|
49
|
-
*
|
|
50
|
-
* Commerce serializes the selection as a JSON-encoded string:
|
|
51
|
-
* `?selection={"ids":["000000001"],"gridType":"customer"}`
|
|
52
|
-
*/
|
|
53
|
-
declare const MassActionSelectionSchema: v.ObjectSchema<{
|
|
54
|
-
readonly gridType: v.PicklistSchema<["order", "product", "customer"], undefined>;
|
|
55
|
-
readonly ids: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>, undefined>, v.MinLengthAction<string[], 1, "The value of \"ids\" must contain at least one entry">]>;
|
|
56
|
-
}, undefined>;
|
|
57
|
-
//#endregion
|
|
58
|
-
//#region source/mass-actions/view/types.d.ts
|
|
59
|
-
/** Parsed `selection` query parameter appended by Commerce to the iframe URL. */
|
|
60
|
-
type MassActionSelection = v.InferOutput<typeof MassActionSelectionSchema>;
|
|
61
|
-
//#endregion
|
|
62
|
-
//#region source/mass-actions/view/presets.d.ts
|
|
63
|
-
/**
|
|
64
|
-
* Parses the `selection` query parameter Commerce appends to the iframe URL of
|
|
65
|
-
* a view mass action.
|
|
66
|
-
*
|
|
67
|
-
* Commerce serializes the selection as a JSON string:
|
|
68
|
-
* `?selection={"ids":["000000001","000000002"],"gridType":"customer"}`
|
|
69
|
-
*
|
|
70
|
-
* Throws a `CommerceSdkValidationError` if the input is missing, not valid
|
|
71
|
-
* JSON, or does not match the expected shape.
|
|
72
|
-
*
|
|
73
|
-
* @param rawSelection - The raw string value of the `selection` query parameter.
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* ```ts
|
|
77
|
-
* import { parseMassActionSelection } from "@adobe/aio-commerce-lib-admin-ui/mass-actions";
|
|
78
|
-
*
|
|
79
|
-
* // In your SPA route handler:
|
|
80
|
-
* const raw = new URLSearchParams(window.location.search).get("selection");
|
|
81
|
-
* const { ids, gridType } = parseMassActionSelection(raw);
|
|
82
|
-
* ```
|
|
83
|
-
*/
|
|
84
|
-
declare function parseMassActionSelection(rawSelection: unknown): MassActionSelection;
|
|
85
|
-
//#endregion
|
|
86
44
|
//#region source/mass-actions/worker/schema.d.ts
|
|
87
45
|
/**
|
|
88
46
|
* Grid identifier sent by Commerce on the `commerce/backend-ui/2` wire contract
|
|
@@ -157,4 +115,4 @@ declare function okMassActionResponse(body?: MassActionResponseBody): SuccessRes
|
|
|
157
115
|
*/
|
|
158
116
|
declare function massActionErrorResponse(statusCode: number, errorMessage: string): ErrorResponse<MassActionErrorBody>;
|
|
159
117
|
//#endregion
|
|
160
|
-
export { type AdminUiEntity, type MassActionErrorBody, type MassActionGridType, MassActionGridTypeSchema, type MassActionRequest, MassActionRequestSchema, type MassActionResponseBody,
|
|
118
|
+
export { type AdminUiEntity, type MassActionErrorBody, type MassActionGridType, MassActionGridTypeSchema, type MassActionRequest, MassActionRequestSchema, type MassActionResponseBody, getMassActionAclResourceId, massActionErrorResponse, okMassActionResponse, parseMassActionRequest };
|
|
@@ -48,58 +48,6 @@ function getMassActionAclResourceId(metadataId, entity, actionId) {
|
|
|
48
48
|
return `${appRoot}_${entity}_massactions_${sanitizeSegment(actionId)}`;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
//#endregion
|
|
52
|
-
//#region source/mass-actions/view/schema.ts
|
|
53
|
-
/**
|
|
54
|
-
* Schema for the `selection` query parameter Commerce appends to the iframe URL
|
|
55
|
-
* of a view mass action.
|
|
56
|
-
*
|
|
57
|
-
* Commerce serializes the selection as a JSON-encoded string:
|
|
58
|
-
* `?selection={"ids":["000000001"],"gridType":"customer"}`
|
|
59
|
-
*/
|
|
60
|
-
const MassActionSelectionSchema = v.object({
|
|
61
|
-
gridType: v.picklist([
|
|
62
|
-
"order",
|
|
63
|
-
"product",
|
|
64
|
-
"customer"
|
|
65
|
-
]),
|
|
66
|
-
ids: v.pipe(v.array(nonEmptyStringValueSchema("id")), v.minLength(1, "The value of \"ids\" must contain at least one entry"))
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
//#endregion
|
|
70
|
-
//#region source/mass-actions/view/presets.ts
|
|
71
|
-
/**
|
|
72
|
-
* Parses the `selection` query parameter Commerce appends to the iframe URL of
|
|
73
|
-
* a view mass action.
|
|
74
|
-
*
|
|
75
|
-
* Commerce serializes the selection as a JSON string:
|
|
76
|
-
* `?selection={"ids":["000000001","000000002"],"gridType":"customer"}`
|
|
77
|
-
*
|
|
78
|
-
* Throws a `CommerceSdkValidationError` if the input is missing, not valid
|
|
79
|
-
* JSON, or does not match the expected shape.
|
|
80
|
-
*
|
|
81
|
-
* @param rawSelection - The raw string value of the `selection` query parameter.
|
|
82
|
-
*
|
|
83
|
-
* @example
|
|
84
|
-
* ```ts
|
|
85
|
-
* import { parseMassActionSelection } from "@adobe/aio-commerce-lib-admin-ui/mass-actions";
|
|
86
|
-
*
|
|
87
|
-
* // In your SPA route handler:
|
|
88
|
-
* const raw = new URLSearchParams(window.location.search).get("selection");
|
|
89
|
-
* const { ids, gridType } = parseMassActionSelection(raw);
|
|
90
|
-
* ```
|
|
91
|
-
*/
|
|
92
|
-
function parseMassActionSelection(rawSelection) {
|
|
93
|
-
if (rawSelection === null || rawSelection === void 0) throw new Error("Invalid mass action selection: the selection query parameter is missing.");
|
|
94
|
-
let parsed;
|
|
95
|
-
try {
|
|
96
|
-
parsed = JSON.parse(String(rawSelection));
|
|
97
|
-
} catch (error) {
|
|
98
|
-
throw new Error(`Invalid mass action selection: expected a JSON string, got: ${String(rawSelection)}`, { cause: error });
|
|
99
|
-
}
|
|
100
|
-
return parseOrThrow(MassActionSelectionSchema, parsed, "Invalid mass action selection");
|
|
101
|
-
}
|
|
102
|
-
|
|
103
51
|
//#endregion
|
|
104
52
|
//#region source/mass-actions/worker/schema.ts
|
|
105
53
|
/**
|
|
@@ -175,4 +123,4 @@ function massActionErrorResponse(statusCode, errorMessage) {
|
|
|
175
123
|
}
|
|
176
124
|
|
|
177
125
|
//#endregion
|
|
178
|
-
export { MassActionGridTypeSchema, MassActionRequestSchema,
|
|
126
|
+
export { MassActionGridTypeSchema, MassActionRequestSchema, getMassActionAclResourceId, massActionErrorResponse, okMassActionResponse, parseMassActionRequest };
|
|
@@ -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,18 +164,25 @@ 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
|
/**
|
|
@@ -196,11 +206,6 @@ type CreateExtensionAppOptions = {
|
|
|
196
206
|
* });
|
|
197
207
|
* ```
|
|
198
208
|
*/
|
|
199
|
-
declare function createExtensionApp({
|
|
200
|
-
menu,
|
|
201
|
-
metadata,
|
|
202
|
-
routes,
|
|
203
|
-
root: customRoot
|
|
204
|
-
}: CreateExtensionAppOptions): void;
|
|
209
|
+
declare function createExtensionApp({ menu, metadata, routes, root: customRoot }: CreateExtensionAppOptions): void;
|
|
205
210
|
//#endregion
|
|
206
211
|
export { type CreateExtensionAppOptions, type ExtensionRoute, type HostConnection, type ImsContext, type MassActionContext, type OrderViewButtonContext, type SharedContext, createExtensionApp, useCommerce, useHostConnection, useIms, useMassActionContext, useOrderViewButtonContext, useSharedContext };
|
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.0",
|
|
6
6
|
"private": false,
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=22 <=24"
|
|
@@ -113,8 +113,8 @@
|
|
|
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.0
|
|
117
|
-
"@adobe/aio-commerce-lib-core": "1.2.0
|
|
116
|
+
"@adobe/aio-commerce-lib-api": "1.3.0",
|
|
117
|
+
"@adobe/aio-commerce-lib-core": "1.2.0"
|
|
118
118
|
},
|
|
119
119
|
"peerDependencies": {
|
|
120
120
|
"@react-spectrum/s2": "^1.5.1",
|
|
@@ -139,13 +139,13 @@
|
|
|
139
139
|
"react": "^19.2.7",
|
|
140
140
|
"react-dom": "^19.2.7",
|
|
141
141
|
"typescript": "^6.0.0",
|
|
142
|
-
"@aio-commerce-sdk/common-utils": "0.2.6
|
|
142
|
+
"@aio-commerce-sdk/common-utils": "0.2.6",
|
|
143
143
|
"@aio-commerce-sdk/config-tsdown": "1.0.1",
|
|
144
144
|
"@aio-commerce-sdk/config-typedoc": "1.0.0",
|
|
145
|
-
"@aio-commerce-sdk/config-typescript": "1.0.0",
|
|
146
145
|
"@aio-commerce-sdk/config-vitest": "1.0.0",
|
|
147
|
-
"@aio-commerce-sdk/scripting-utils": "0.3.4
|
|
148
|
-
"@aio-commerce-sdk/scripts": "0.1.0"
|
|
146
|
+
"@aio-commerce-sdk/scripting-utils": "0.3.4",
|
|
147
|
+
"@aio-commerce-sdk/scripts": "0.1.0",
|
|
148
|
+
"@aio-commerce-sdk/config-typescript": "1.0.0"
|
|
149
149
|
},
|
|
150
150
|
"sideEffects": false,
|
|
151
151
|
"scripts": {
|