@adobe/aio-commerce-lib-admin-ui 1.1.0 → 1.2.0-alpha-20261007115732
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 +15 -0
- package/README.md +1 -1
- package/dist/cjs/{acl-resource-id-B1UPaYNV.d.cts → acl-resource-id-Bha1pOIk.d.cts} +19 -2
- package/dist/{es/acl-resource-id-CIxfW36q.mjs → cjs/acl-resource-id-nCj_Kne2.cjs} +58 -1
- package/dist/cjs/api/index.cjs +1 -1
- package/dist/cjs/api/index.d.cts +1 -1
- package/dist/cjs/grid-columns/index.cjs +7 -7
- package/dist/cjs/grid-columns/index.d.cts +8 -4
- package/dist/cjs/invoice-view-buttons/index.cjs +92 -0
- package/dist/cjs/invoice-view-buttons/index.d.cts +78 -0
- package/dist/cjs/mass-actions/index.cjs +3 -7
- package/dist/cjs/mass-actions/index.d.cts +6 -6
- package/dist/cjs/menu/index.cjs +1 -1
- package/dist/cjs/order-view-buttons/index.cjs +2 -2
- package/dist/cjs/order-view-buttons/index.d.cts +1 -1
- package/dist/cjs/web/index.cjs +31 -1
- package/dist/cjs/web/index.d.cts +18 -2
- package/dist/es/{acl-resource-id-B1UPaYNV.d.mts → acl-resource-id-Bha1pOIk.d.mts} +19 -2
- package/dist/{cjs/acl-resource-id-BHCq3fxA.cjs → es/acl-resource-id-CHw95qd2.mjs} +29 -18
- package/dist/es/api/index.d.mts +1 -1
- package/dist/es/api/index.mjs +1 -1
- package/dist/es/grid-columns/index.d.mts +8 -4
- package/dist/es/grid-columns/index.mjs +7 -7
- package/dist/es/invoice-view-buttons/index.d.mts +78 -0
- package/dist/es/invoice-view-buttons/index.mjs +85 -0
- package/dist/es/mass-actions/index.d.mts +6 -6
- package/dist/es/mass-actions/index.mjs +3 -7
- package/dist/es/menu/index.mjs +1 -1
- package/dist/es/order-view-buttons/index.d.mts +1 -1
- package/dist/es/order-view-buttons/index.mjs +2 -2
- package/dist/es/web/index.d.mts +18 -2
- package/dist/es/web/index.mjs +31 -2
- package/package.json +12 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @adobe/aio-commerce-lib-admin-ui
|
|
2
2
|
|
|
3
|
+
## 1.2.0-alpha-20261007115732
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#692](https://github.com/adobe/aio-commerce-sdk/pull/692) [`264539a`](https://github.com/adobe/aio-commerce-sdk/commit/264539a13371b11b637eb01fd1c0aa185f4349cc) Thanks [@asalloum5](https://github.com/asalloum5)! - Add `invoice`, `creditmemo`, and `shipment` grid types to the grid column wire contract, so runtime action handlers and `getGridColumnAclResourceId` can target those grids in addition to order, product, and customer. Export a `MassActionEntity` type that reflects the entities mass actions actually support (order, product, customer); `getMassActionAclResourceId` now accepts it instead of the wider grid entity type.
|
|
8
|
+
|
|
9
|
+
- [#732](https://github.com/adobe/aio-commerce-sdk/pull/732) [`de5461a`](https://github.com/adobe/aio-commerce-sdk/commit/de5461a0498a360ff2771ef053278692de531560) Thanks [@asalloum5](https://github.com/asalloum5)! - Add invoice detail-page view and worker buttons, with configuration validation, generated operations, runtime and React helpers, and installation and upgrade support.
|
|
10
|
+
|
|
11
|
+
- [#699](https://github.com/adobe/aio-commerce-sdk/pull/699) [`53f1f8b`](https://github.com/adobe/aio-commerce-sdk/commit/53f1f8be4428862015294f1edc2816972e501a9e) Thanks [@mariam21arauj](https://github.com/mariam21arauj)! - Support the `newsletter` entity in grid-column and mass-action request parsing and ACL resource id helpers, so handlers can serve Newsletter Subscriber grids and mass actions.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [[`d78221e`](https://github.com/adobe/aio-commerce-sdk/commit/d78221e01894d2209b7864aca6a5fbfab93c7192), [`395eb22`](https://github.com/adobe/aio-commerce-sdk/commit/395eb22da7646944d5e5f02e1517dc23cc3ebfe6)]:
|
|
16
|
+
- @adobe/aio-commerce-lib-api@1.4.1-alpha-20261007115732
|
|
17
|
+
|
|
3
18
|
## 1.1.0
|
|
4
19
|
|
|
5
20
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# `@adobe/aio-commerce-lib-admin-ui`
|
|
2
2
|
|
|
3
|
-
This package provides utilities for interacting with the Adobe Commerce Admin UI SDK API, the extension points (grid columns, mass actions, menu, order view buttons), and browser-side helpers for Admin UI iframe extensions.
|
|
3
|
+
This package provides utilities for interacting with the Adobe Commerce Admin UI SDK API, the extension points (grid columns, mass actions, menu, order and invoice view buttons), and browser-side helpers for Admin UI iframe extensions.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -62,7 +62,24 @@ declare function getAclResourceId(metadataId: string): string;
|
|
|
62
62
|
* @returns The full Commerce ACL resource id, or an empty string when `metadataId` is blank.
|
|
63
63
|
*/
|
|
64
64
|
declare function getCustomAclResourceId(metadataId: string, resourceId: string, childId?: string): string;
|
|
65
|
+
/**
|
|
66
|
+
* Commerce entities an Admin UI component can attach to, using the same spelling Commerce
|
|
67
|
+
* sends in the wire-contract `gridType` field. Credit memo grids send `"creditmemo"` on the
|
|
68
|
+
* wire — not `"creditMemo"` — even though the corresponding config key (`adminUi.creditMemo`)
|
|
69
|
+
* is camelCase.
|
|
70
|
+
*
|
|
71
|
+
* Single source of truth for the entity vocabulary: `GridTypeSchema` derives its picklist from it.
|
|
72
|
+
*/
|
|
73
|
+
declare const ADMIN_UI_GRID_ENTITIES: readonly ["order", "product", "customer", "invoice", "creditmemo", "shipment", "newsletter"];
|
|
65
74
|
/** Commerce entity an Admin UI component is attached to. */
|
|
66
|
-
type AdminUiEntity =
|
|
75
|
+
type AdminUiEntity = (typeof ADMIN_UI_GRID_ENTITIES)[number];
|
|
76
|
+
/**
|
|
77
|
+
* Entities that support mass actions — a subset of `ADMIN_UI_GRID_ENTITIES`. Mass actions, unlike
|
|
78
|
+
* grid columns, are not available on the invoice, credit memo, or shipment grids.
|
|
79
|
+
* `MassActionGridTypeSchema` derives its picklist from it.
|
|
80
|
+
*/
|
|
81
|
+
declare const MASS_ACTION_ENTITIES: readonly ["order", "product", "customer", "newsletter"];
|
|
82
|
+
/** Commerce entity a mass action is attached to. */
|
|
83
|
+
type MassActionEntity = (typeof MASS_ACTION_ENTITIES)[number];
|
|
67
84
|
//#endregion
|
|
68
|
-
export { sanitizeSegment as i,
|
|
85
|
+
export { sanitizeSegment as a, getCustomAclResourceId as i, MassActionEntity as n, getAclResourceId as r, AdminUiEntity as t };
|
|
@@ -79,6 +79,63 @@ function getCustomAclResourceId(metadataId, resourceId, childId) {
|
|
|
79
79
|
const base = `${appRoot}_acl_${sanitizeSegment(resourceId)}`;
|
|
80
80
|
return childId === void 0 ? base : `${base}_${sanitizeSegment(childId)}`;
|
|
81
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Commerce entities an Admin UI component can attach to, using the same spelling Commerce
|
|
84
|
+
* sends in the wire-contract `gridType` field. Credit memo grids send `"creditmemo"` on the
|
|
85
|
+
* wire — not `"creditMemo"` — even though the corresponding config key (`adminUi.creditMemo`)
|
|
86
|
+
* is camelCase.
|
|
87
|
+
*
|
|
88
|
+
* Single source of truth for the entity vocabulary: `GridTypeSchema` derives its picklist from it.
|
|
89
|
+
*/
|
|
90
|
+
const ADMIN_UI_GRID_ENTITIES = [
|
|
91
|
+
"order",
|
|
92
|
+
"product",
|
|
93
|
+
"customer",
|
|
94
|
+
"invoice",
|
|
95
|
+
"creditmemo",
|
|
96
|
+
"shipment",
|
|
97
|
+
"newsletter"
|
|
98
|
+
];
|
|
99
|
+
/**
|
|
100
|
+
* Entities that support mass actions — a subset of `ADMIN_UI_GRID_ENTITIES`. Mass actions, unlike
|
|
101
|
+
* grid columns, are not available on the invoice, credit memo, or shipment grids.
|
|
102
|
+
* `MassActionGridTypeSchema` derives its picklist from it.
|
|
103
|
+
*/
|
|
104
|
+
const MASS_ACTION_ENTITIES = [
|
|
105
|
+
"order",
|
|
106
|
+
"product",
|
|
107
|
+
"customer",
|
|
108
|
+
"newsletter"
|
|
109
|
+
];
|
|
82
110
|
|
|
83
111
|
//#endregion
|
|
84
|
-
|
|
112
|
+
Object.defineProperty(exports, 'ADMIN_UI_GRID_ENTITIES', {
|
|
113
|
+
enumerable: true,
|
|
114
|
+
get: function () {
|
|
115
|
+
return ADMIN_UI_GRID_ENTITIES;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
Object.defineProperty(exports, 'MASS_ACTION_ENTITIES', {
|
|
119
|
+
enumerable: true,
|
|
120
|
+
get: function () {
|
|
121
|
+
return MASS_ACTION_ENTITIES;
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
Object.defineProperty(exports, 'getAclResourceId', {
|
|
125
|
+
enumerable: true,
|
|
126
|
+
get: function () {
|
|
127
|
+
return getAclResourceId;
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
Object.defineProperty(exports, 'getCustomAclResourceId', {
|
|
131
|
+
enumerable: true,
|
|
132
|
+
get: function () {
|
|
133
|
+
return getCustomAclResourceId;
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
Object.defineProperty(exports, 'sanitizeSegment', {
|
|
137
|
+
enumerable: true,
|
|
138
|
+
get: function () {
|
|
139
|
+
return sanitizeSegment;
|
|
140
|
+
}
|
|
141
|
+
});
|
package/dist/cjs/api/index.cjs
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
16
16
|
const require_rolldown_runtime = require('../rolldown-runtime-Bf2WWRga.cjs');
|
|
17
|
-
const require_acl_resource_id = require('../acl-resource-id-
|
|
17
|
+
const require_acl_resource_id = require('../acl-resource-id-nCj_Kne2.cjs');
|
|
18
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");
|
package/dist/cjs/api/index.d.cts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import { a as sanitizeSegment, i as getCustomAclResourceId, r as getAclResourceId, t as AdminUiEntity } from "../acl-resource-id-Bha1pOIk.cjs";
|
|
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";
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
16
16
|
const require_rolldown_runtime = require('../rolldown-runtime-Bf2WWRga.cjs');
|
|
17
|
-
const require_acl_resource_id = require('../acl-resource-id-
|
|
17
|
+
const require_acl_resource_id = require('../acl-resource-id-nCj_Kne2.cjs');
|
|
18
18
|
const require_schemas = require('../schemas-DRhCF0TF.cjs');
|
|
19
19
|
const require_utils = require('../utils-CiBhSMw4.cjs');
|
|
20
20
|
let valibot = require("valibot");
|
|
@@ -40,7 +40,8 @@ let _adobe_aio_commerce_lib_core_responses = require("@adobe/aio-commerce-lib-co
|
|
|
40
40
|
* ```
|
|
41
41
|
*
|
|
42
42
|
* @param metadataId - The application's `metadata.id` value (e.g. `"approval-dashboard-app"`).
|
|
43
|
-
* @param entity - The grid's Commerce entity (`"order"`, `"product"`,
|
|
43
|
+
* @param entity - The grid's Commerce entity (`"order"`, `"product"`, `"customer"`, `"invoice"`,
|
|
44
|
+
* `"creditmemo"`, `"shipment"`, or `"newsletter"`).
|
|
44
45
|
* @param columnId - The column's `id` value from `adminUi.<entity>.gridColumns.columns[].id`.
|
|
45
46
|
* @returns The full Commerce ACL resource id for the grid-column leaf node, or an empty string
|
|
46
47
|
* when `metadataId` is blank.
|
|
@@ -56,13 +57,12 @@ function getGridColumnAclResourceId(metadataId, entity, columnId) {
|
|
|
56
57
|
/**
|
|
57
58
|
* Grid identifier sent by Commerce on the `commerce/backend-ui/2` wire contract.
|
|
58
59
|
*
|
|
60
|
+
* Credit memo grids send `"creditmemo"` — not `"creditMemo"` — even though the corresponding
|
|
61
|
+
* config key (`adminUi.creditMemo`) is camelCase; see the Commerce module's `CustomColumn::GRID_MAP`.
|
|
62
|
+
*
|
|
59
63
|
* @see {@link https://github.com/magento-commerce/adobe-commerce-backend-uix Magento module reference}
|
|
60
64
|
*/
|
|
61
|
-
const GridTypeSchema = valibot.picklist(
|
|
62
|
-
"order",
|
|
63
|
-
"product",
|
|
64
|
-
"customer"
|
|
65
|
-
]);
|
|
65
|
+
const GridTypeSchema = valibot.picklist(require_acl_resource_id.ADMIN_UI_GRID_ENTITIES);
|
|
66
66
|
/**
|
|
67
67
|
* Schema for the JSON body Commerce POSTs to a grid column handler.
|
|
68
68
|
*
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import { t as AdminUiEntity } from "../acl-resource-id-
|
|
15
|
+
import { t as AdminUiEntity } from "../acl-resource-id-Bha1pOIk.cjs";
|
|
16
16
|
import * as v from "valibot";
|
|
17
17
|
import { ErrorResponse, SuccessResponse } from "@adobe/aio-commerce-lib-core/responses";
|
|
18
18
|
//#region source/grid-columns/acl-resource-id.d.ts
|
|
@@ -34,7 +34,8 @@ import { ErrorResponse, SuccessResponse } from "@adobe/aio-commerce-lib-core/res
|
|
|
34
34
|
* ```
|
|
35
35
|
*
|
|
36
36
|
* @param metadataId - The application's `metadata.id` value (e.g. `"approval-dashboard-app"`).
|
|
37
|
-
* @param entity - The grid's Commerce entity (`"order"`, `"product"`,
|
|
37
|
+
* @param entity - The grid's Commerce entity (`"order"`, `"product"`, `"customer"`, `"invoice"`,
|
|
38
|
+
* `"creditmemo"`, `"shipment"`, or `"newsletter"`).
|
|
38
39
|
* @param columnId - The column's `id` value from `adminUi.<entity>.gridColumns.columns[].id`.
|
|
39
40
|
* @returns The full Commerce ACL resource id for the grid-column leaf node, or an empty string
|
|
40
41
|
* when `metadataId` is blank.
|
|
@@ -45,9 +46,12 @@ export declare function getGridColumnAclResourceId(metadataId: string, entity: A
|
|
|
45
46
|
/**
|
|
46
47
|
* Grid identifier sent by Commerce on the `commerce/backend-ui/2` wire contract.
|
|
47
48
|
*
|
|
49
|
+
* Credit memo grids send `"creditmemo"` — not `"creditMemo"` — even though the corresponding
|
|
50
|
+
* config key (`adminUi.creditMemo`) is camelCase; see the Commerce module's `CustomColumn::GRID_MAP`.
|
|
51
|
+
*
|
|
48
52
|
* @see {@link https://github.com/magento-commerce/adobe-commerce-backend-uix Magento module reference}
|
|
49
53
|
*/
|
|
50
|
-
export declare const GridTypeSchema: v.PicklistSchema<["order", "product", "customer"], undefined>;
|
|
54
|
+
export declare const GridTypeSchema: v.PicklistSchema<readonly ["order", "product", "customer", "invoice", "creditmemo", "shipment", "newsletter"], undefined>;
|
|
51
55
|
/**
|
|
52
56
|
* Schema for the JSON body Commerce POSTs to a grid column handler.
|
|
53
57
|
*
|
|
@@ -56,7 +60,7 @@ export declare const GridTypeSchema: v.PicklistSchema<["order", "product", "cust
|
|
|
56
60
|
* enforced here.
|
|
57
61
|
*/
|
|
58
62
|
export declare const GridRequestSchema: v.ObjectSchema<{
|
|
59
|
-
readonly gridType: v.PicklistSchema<["order", "product", "customer"], undefined>;
|
|
63
|
+
readonly gridType: v.PicklistSchema<readonly ["order", "product", "customer", "invoice", "creditmemo", "shipment", "newsletter"], undefined>;
|
|
60
64
|
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">]>;
|
|
61
65
|
readonly requestId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
62
66
|
}, undefined>;
|
|
@@ -0,0 +1,92 @@
|
|
|
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
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
16
|
+
const require_rolldown_runtime = require('../rolldown-runtime-Bf2WWRga.cjs');
|
|
17
|
+
const require_acl_resource_id = require('../acl-resource-id-nCj_Kne2.cjs');
|
|
18
|
+
const require_schemas = require('../schemas-DRhCF0TF.cjs');
|
|
19
|
+
const require_utils = require('../utils-CiBhSMw4.cjs');
|
|
20
|
+
let valibot = require("valibot");
|
|
21
|
+
valibot = require_rolldown_runtime.__toESM(valibot, 1);
|
|
22
|
+
let _adobe_aio_commerce_lib_core_responses = require("@adobe/aio-commerce-lib-core/responses");
|
|
23
|
+
|
|
24
|
+
//#region source/invoice-view-buttons/acl-resource-id.ts
|
|
25
|
+
/**
|
|
26
|
+
* Derives the Commerce ACL resource ID for an invoice view button.
|
|
27
|
+
* App and button IDs are trimmed, lowercased, and sanitized independently.
|
|
28
|
+
*
|
|
29
|
+
* @param metadataId - The application's `metadata.id` value.
|
|
30
|
+
* @param buttonId - The button's `adminUi.invoice.viewButtons[].id` value.
|
|
31
|
+
* @returns The invoice view-button leaf ID, or an empty string when `metadataId` is blank.
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* getInvoiceViewButtonAclResourceId("billing-app", "export-invoice");
|
|
35
|
+
* // "Magento_CommerceBackendUix::adminuisdk_app_billing_app_invoice_viewbuttons_export_invoice"
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
function getInvoiceViewButtonAclResourceId(metadataId, buttonId) {
|
|
39
|
+
const appRoot = require_acl_resource_id.getAclResourceId(metadataId);
|
|
40
|
+
if (appRoot === "") return "";
|
|
41
|
+
return `${appRoot}_invoice_viewbuttons_${require_acl_resource_id.sanitizeSegment(buttonId)}`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region source/invoice-view-buttons/schema.ts
|
|
46
|
+
/**
|
|
47
|
+
* Schema for an invoice view-button worker request.
|
|
48
|
+
* `id` identifies the clicked button; `invoiceId` identifies the invoice being viewed.
|
|
49
|
+
* All three fields must be non-empty strings.
|
|
50
|
+
*/
|
|
51
|
+
const InvoiceViewButtonRequestSchema = valibot.object({
|
|
52
|
+
id: require_schemas.nonEmptyStringValueSchema("id"),
|
|
53
|
+
invoiceId: require_schemas.nonEmptyStringValueSchema("invoiceId"),
|
|
54
|
+
requestId: require_schemas.nonEmptyStringValueSchema("requestId")
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region source/invoice-view-buttons/presets.ts
|
|
59
|
+
/**
|
|
60
|
+
* Parses an invoice view-button worker request.
|
|
61
|
+
* Throws `CommerceSdkValidationError` when the input is malformed.
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* const { requestId, id, invoiceId } = parseInvoiceViewButtonRequest(params);
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
function parseInvoiceViewButtonRequest(input) {
|
|
68
|
+
return require_utils.parseOrThrow(InvoiceViewButtonRequestSchema, input, "Invalid invoice view button request");
|
|
69
|
+
}
|
|
70
|
+
/** Builds an HTTP 200 response with an empty body for an invoice view-button worker. */
|
|
71
|
+
function okInvoiceViewButtonResponse() {
|
|
72
|
+
return (0, _adobe_aio_commerce_lib_core_responses.ok)({ body: {} });
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Builds an error response for an invoice view-button worker.
|
|
76
|
+
* @param statusCode - The HTTP status code to return.
|
|
77
|
+
* @param errorMessage - The message included in the response body.
|
|
78
|
+
* @example
|
|
79
|
+
* ```ts
|
|
80
|
+
* return invoiceViewButtonErrorResponse(500, "Could not export the invoice");
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
function invoiceViewButtonErrorResponse(statusCode, errorMessage) {
|
|
84
|
+
return (0, _adobe_aio_commerce_lib_core_responses.buildErrorResponse)(statusCode, { body: { message: errorMessage } });
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
//#endregion
|
|
88
|
+
exports.InvoiceViewButtonRequestSchema = InvoiceViewButtonRequestSchema;
|
|
89
|
+
exports.getInvoiceViewButtonAclResourceId = getInvoiceViewButtonAclResourceId;
|
|
90
|
+
exports.invoiceViewButtonErrorResponse = invoiceViewButtonErrorResponse;
|
|
91
|
+
exports.okInvoiceViewButtonResponse = okInvoiceViewButtonResponse;
|
|
92
|
+
exports.parseInvoiceViewButtonRequest = parseInvoiceViewButtonRequest;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2026 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import * as v from "valibot";
|
|
16
|
+
import { ErrorResponse, SuccessResponse } from "@adobe/aio-commerce-lib-core/responses";
|
|
17
|
+
//#region source/invoice-view-buttons/acl-resource-id.d.ts
|
|
18
|
+
/**
|
|
19
|
+
* Derives the Commerce ACL resource ID for an invoice view button.
|
|
20
|
+
* App and button IDs are trimmed, lowercased, and sanitized independently.
|
|
21
|
+
*
|
|
22
|
+
* @param metadataId - The application's `metadata.id` value.
|
|
23
|
+
* @param buttonId - The button's `adminUi.invoice.viewButtons[].id` value.
|
|
24
|
+
* @returns The invoice view-button leaf ID, or an empty string when `metadataId` is blank.
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* getInvoiceViewButtonAclResourceId("billing-app", "export-invoice");
|
|
28
|
+
* // "Magento_CommerceBackendUix::adminuisdk_app_billing_app_invoice_viewbuttons_export_invoice"
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function getInvoiceViewButtonAclResourceId(metadataId: string, buttonId: string): string;
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region source/invoice-view-buttons/schema.d.ts
|
|
34
|
+
/**
|
|
35
|
+
* Schema for an invoice view-button worker request.
|
|
36
|
+
* `id` identifies the clicked button; `invoiceId` identifies the invoice being viewed.
|
|
37
|
+
* All three fields must be non-empty strings.
|
|
38
|
+
*/
|
|
39
|
+
export declare const InvoiceViewButtonRequestSchema: v.ObjectSchema<{
|
|
40
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
41
|
+
readonly invoiceId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
42
|
+
readonly requestId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
43
|
+
}, undefined>;
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region source/invoice-view-buttons/types.d.ts
|
|
46
|
+
/** Parsed request body for an invoice view-button worker. */
|
|
47
|
+
type InvoiceViewButtonRequest = v.InferOutput<typeof InvoiceViewButtonRequestSchema>;
|
|
48
|
+
/** Empty success body returned by an invoice view-button worker. */
|
|
49
|
+
type InvoiceViewButtonSuccessBody = Record<string, never>;
|
|
50
|
+
/** Error body returned by an invoice view-button worker. */
|
|
51
|
+
type InvoiceViewButtonErrorBody = {
|
|
52
|
+
message: string;
|
|
53
|
+
};
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region source/invoice-view-buttons/presets.d.ts
|
|
56
|
+
/**
|
|
57
|
+
* Parses an invoice view-button worker request.
|
|
58
|
+
* Throws `CommerceSdkValidationError` when the input is malformed.
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* const { requestId, id, invoiceId } = parseInvoiceViewButtonRequest(params);
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare function parseInvoiceViewButtonRequest(input: unknown): InvoiceViewButtonRequest;
|
|
65
|
+
/** Builds an HTTP 200 response with an empty body for an invoice view-button worker. */
|
|
66
|
+
export declare function okInvoiceViewButtonResponse(): SuccessResponse<InvoiceViewButtonSuccessBody>;
|
|
67
|
+
/**
|
|
68
|
+
* Builds an error response for an invoice view-button worker.
|
|
69
|
+
* @param statusCode - The HTTP status code to return.
|
|
70
|
+
* @param errorMessage - The message included in the response body.
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* return invoiceViewButtonErrorResponse(500, "Could not export the invoice");
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare function invoiceViewButtonErrorResponse(statusCode: number, errorMessage: string): ErrorResponse<InvoiceViewButtonErrorBody>;
|
|
77
|
+
//#endregion
|
|
78
|
+
export type { InvoiceViewButtonErrorBody, InvoiceViewButtonRequest, InvoiceViewButtonSuccessBody };
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
16
16
|
const require_rolldown_runtime = require('../rolldown-runtime-Bf2WWRga.cjs');
|
|
17
|
-
const require_acl_resource_id = require('../acl-resource-id-
|
|
17
|
+
const require_acl_resource_id = require('../acl-resource-id-nCj_Kne2.cjs');
|
|
18
18
|
const require_schemas = require('../schemas-DRhCF0TF.cjs');
|
|
19
19
|
const require_utils = require('../utils-CiBhSMw4.cjs');
|
|
20
20
|
let valibot = require("valibot");
|
|
@@ -40,7 +40,7 @@ let _adobe_aio_commerce_lib_core_responses = require("@adobe/aio-commerce-lib-co
|
|
|
40
40
|
* ```
|
|
41
41
|
*
|
|
42
42
|
* @param metadataId - The application's `metadata.id` value (e.g. `"approval-dashboard-app"`).
|
|
43
|
-
* @param entity - The grid's Commerce entity (`"order"`, `"product"`, or `"
|
|
43
|
+
* @param entity - The grid's Commerce entity (`"order"`, `"product"`, `"customer"`, or `"newsletter"`).
|
|
44
44
|
* @param actionId - The action's `id` value from `adminUi.<entity>.massActions[].id`.
|
|
45
45
|
* @returns The full Commerce ACL resource id for the mass-action leaf node, or an empty string
|
|
46
46
|
* when `metadataId` is blank.
|
|
@@ -57,11 +57,7 @@ function getMassActionAclResourceId(metadataId, entity, actionId) {
|
|
|
57
57
|
* Grid identifier sent by Commerce on the `commerce/backend-ui/2` wire contract
|
|
58
58
|
* for worker mass actions.
|
|
59
59
|
*/
|
|
60
|
-
const MassActionGridTypeSchema = valibot.picklist(
|
|
61
|
-
"order",
|
|
62
|
-
"product",
|
|
63
|
-
"customer"
|
|
64
|
-
]);
|
|
60
|
+
const MassActionGridTypeSchema = valibot.picklist(require_acl_resource_id.MASS_ACTION_ENTITIES);
|
|
65
61
|
/**
|
|
66
62
|
* Schema for the JSON body Commerce POSTs to a worker mass action handler.
|
|
67
63
|
*
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import { t as AdminUiEntity } from "../acl-resource-id-
|
|
15
|
+
import { n as MassActionEntity, t as AdminUiEntity } from "../acl-resource-id-Bha1pOIk.cjs";
|
|
16
16
|
import * as v from "valibot";
|
|
17
17
|
import { ErrorResponse, SuccessResponse } from "@adobe/aio-commerce-lib-core/responses";
|
|
18
18
|
//#region source/mass-actions/acl-resource-id.d.ts
|
|
@@ -34,19 +34,19 @@ import { ErrorResponse, SuccessResponse } from "@adobe/aio-commerce-lib-core/res
|
|
|
34
34
|
* ```
|
|
35
35
|
*
|
|
36
36
|
* @param metadataId - The application's `metadata.id` value (e.g. `"approval-dashboard-app"`).
|
|
37
|
-
* @param entity - The grid's Commerce entity (`"order"`, `"product"`, or `"
|
|
37
|
+
* @param entity - The grid's Commerce entity (`"order"`, `"product"`, `"customer"`, or `"newsletter"`).
|
|
38
38
|
* @param actionId - The action's `id` value from `adminUi.<entity>.massActions[].id`.
|
|
39
39
|
* @returns The full Commerce ACL resource id for the mass-action leaf node, or an empty string
|
|
40
40
|
* when `metadataId` is blank.
|
|
41
41
|
*/
|
|
42
|
-
export declare function getMassActionAclResourceId(metadataId: string, entity:
|
|
42
|
+
export declare function getMassActionAclResourceId(metadataId: string, entity: MassActionEntity, actionId: string): string;
|
|
43
43
|
//#endregion
|
|
44
44
|
//#region source/mass-actions/worker/schema.d.ts
|
|
45
45
|
/**
|
|
46
46
|
* Grid identifier sent by Commerce on the `commerce/backend-ui/2` wire contract
|
|
47
47
|
* for worker mass actions.
|
|
48
48
|
*/
|
|
49
|
-
export declare const MassActionGridTypeSchema: v.PicklistSchema<["order", "product", "customer"], undefined>;
|
|
49
|
+
export declare const MassActionGridTypeSchema: v.PicklistSchema<readonly ["order", "product", "customer", "newsletter"], undefined>;
|
|
50
50
|
/**
|
|
51
51
|
* Schema for the JSON body Commerce POSTs to a worker mass action handler.
|
|
52
52
|
*
|
|
@@ -55,7 +55,7 @@ export declare const MassActionGridTypeSchema: v.PicklistSchema<["order", "produ
|
|
|
55
55
|
* enforced here.
|
|
56
56
|
*/
|
|
57
57
|
export declare const MassActionRequestSchema: v.ObjectSchema<{
|
|
58
|
-
readonly gridType: v.PicklistSchema<["order", "product", "customer"], undefined>;
|
|
58
|
+
readonly gridType: v.PicklistSchema<readonly ["order", "product", "customer", "newsletter"], undefined>;
|
|
59
59
|
readonly requestId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
60
60
|
readonly selectedIds: 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 \"selectedIds\" must contain at least one entry">]>;
|
|
61
61
|
}, undefined>;
|
|
@@ -115,4 +115,4 @@ export declare function okMassActionResponse(body?: MassActionResponseBody): Suc
|
|
|
115
115
|
*/
|
|
116
116
|
export declare function massActionErrorResponse(statusCode: number, errorMessage: string): ErrorResponse<MassActionErrorBody>;
|
|
117
117
|
//#endregion
|
|
118
|
-
export type { AdminUiEntity, MassActionErrorBody, MassActionGridType, MassActionRequest, MassActionResponseBody };
|
|
118
|
+
export type { AdminUiEntity, MassActionEntity, MassActionErrorBody, MassActionGridType, MassActionRequest, MassActionResponseBody };
|
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-nCj_Kne2.cjs');
|
|
17
17
|
|
|
18
18
|
//#region source/menu/acl-resource-id.ts
|
|
19
19
|
/**
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
16
16
|
const require_rolldown_runtime = require('../rolldown-runtime-Bf2WWRga.cjs');
|
|
17
|
-
const require_acl_resource_id = require('../acl-resource-id-
|
|
17
|
+
const require_acl_resource_id = require('../acl-resource-id-nCj_Kne2.cjs');
|
|
18
18
|
const require_schemas = require('../schemas-DRhCF0TF.cjs');
|
|
19
19
|
const require_utils = require('../utils-CiBhSMw4.cjs');
|
|
20
20
|
let valibot = require("valibot");
|
|
@@ -25,7 +25,7 @@ let _adobe_aio_commerce_lib_core_responses = require("@adobe/aio-commerce-lib-co
|
|
|
25
25
|
/**
|
|
26
26
|
* Derives the deterministic Commerce ACL resource id for an order view button.
|
|
27
27
|
*
|
|
28
|
-
*
|
|
28
|
+
* This helper is scoped to the order entity, so no entity discriminator is needed.
|
|
29
29
|
* The id is assembled as: `getAclResourceId(metadataId)` + `"_order_viewbuttons_"` +
|
|
30
30
|
* sanitized `buttonId`. The `buttonId` is sanitized (trimmed, lowercased, non-`[a-z0-9_]` → `_`).
|
|
31
31
|
* `"Magento_CommerceBackendUix::adminuisdk_app_"` in the example is the fixed constant prefix
|
|
@@ -18,7 +18,7 @@ import { ErrorResponse, SuccessResponse } from "@adobe/aio-commerce-lib-core/res
|
|
|
18
18
|
/**
|
|
19
19
|
* Derives the deterministic Commerce ACL resource id for an order view button.
|
|
20
20
|
*
|
|
21
|
-
*
|
|
21
|
+
* This helper is scoped to the order entity, so no entity discriminator is needed.
|
|
22
22
|
* The id is assembled as: `getAclResourceId(metadataId)` + `"_order_viewbuttons_"` +
|
|
23
23
|
* sanitized `buttonId`. The `buttonId` is sanitized (trimmed, lowercased, non-`[a-z0-9_]` → `_`).
|
|
24
24
|
* `"Magento_CommerceBackendUix::adminuisdk_app_"` in the example is the fixed constant prefix
|
package/dist/cjs/web/index.cjs
CHANGED
|
@@ -37,8 +37,19 @@ let react_error_boundary = require("react-error-boundary");
|
|
|
37
37
|
* @param href - The URL to read the order ID from (typically `window.location.href`).
|
|
38
38
|
*/
|
|
39
39
|
function parseOrderId(href) {
|
|
40
|
+
return parseViewButtonId(href, "orderId");
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Extracts the invoice ID from the given absolute URL.
|
|
44
|
+
* @param href - The URL to read the invoice ID from (typically `window.location.href`).
|
|
45
|
+
*/
|
|
46
|
+
function parseInvoiceId(href) {
|
|
47
|
+
return parseViewButtonId(href, "invoiceId");
|
|
48
|
+
}
|
|
49
|
+
/** Reads a view-button identifier from the URL search parameters or hash-route query. */
|
|
50
|
+
function parseViewButtonId(href, key) {
|
|
40
51
|
const urlObj = new URL(href);
|
|
41
|
-
return urlObj.searchParams.get(
|
|
52
|
+
return urlObj.searchParams.get(key) ?? new URLSearchParams(urlObj.hash.split("?").at(1)).get(key);
|
|
42
53
|
}
|
|
43
54
|
/** Whether the app is embedded in a host frame (the Commerce Admin or the Experience Cloud shell). */
|
|
44
55
|
function isEmbeddedInHost() {
|
|
@@ -295,6 +306,24 @@ function useOrderViewButtonContext() {
|
|
|
295
306
|
return ok({ orderId });
|
|
296
307
|
}, []);
|
|
297
308
|
}
|
|
309
|
+
/**
|
|
310
|
+
* Returns the invoice ID for an invoice view-button extension point.
|
|
311
|
+
* Reads `invoiceId` from the page URL search parameters or hash-route query.
|
|
312
|
+
* Returns an error when the invoice ID is missing or blank.
|
|
313
|
+
* @example
|
|
314
|
+
* ```tsx
|
|
315
|
+
* const { data, error } = useInvoiceViewButtonContext();
|
|
316
|
+
* if (error) throw error;
|
|
317
|
+
* return <span>{data.invoiceId}</span>;
|
|
318
|
+
* ```
|
|
319
|
+
*/
|
|
320
|
+
function useInvoiceViewButtonContext() {
|
|
321
|
+
return (0, react.useMemo)(() => {
|
|
322
|
+
const invoiceId = parseInvoiceId(globalThis.location.href);
|
|
323
|
+
if (invoiceId === null || invoiceId.trim() === "") return error("Could not find an invoice ID. Is this frame running as an invoice view-button extension point?");
|
|
324
|
+
return ok({ invoiceId });
|
|
325
|
+
}, []);
|
|
326
|
+
}
|
|
298
327
|
|
|
299
328
|
//#endregion
|
|
300
329
|
//#region source/web/react/commerce/hooks/use-host-connection.ts
|
|
@@ -879,6 +908,7 @@ exports.createExtensionApp = createExtensionApp;
|
|
|
879
908
|
exports.useCommerce = useCommerce;
|
|
880
909
|
exports.useHostConnection = useHostConnection;
|
|
881
910
|
exports.useIms = useIms;
|
|
911
|
+
exports.useInvoiceViewButtonContext = useInvoiceViewButtonContext;
|
|
882
912
|
exports.useMassActionContext = useMassActionContext;
|
|
883
913
|
exports.useOrderViewButtonContext = useOrderViewButtonContext;
|
|
884
914
|
exports.useSharedContext = useSharedContext;
|
package/dist/cjs/web/index.d.cts
CHANGED
|
@@ -72,7 +72,7 @@ type SharedContext = {
|
|
|
72
72
|
};
|
|
73
73
|
/** Actions for closing the extension iframe and returning control to the Commerce Admin. */
|
|
74
74
|
type HostConnection = {
|
|
75
|
-
/** Closes the iframe and navigates back to the originating grid or
|
|
75
|
+
/** Closes the iframe and navigates back to the originating grid or detail page. */
|
|
76
76
|
close: () => Promise<void>;
|
|
77
77
|
/** Closes the iframe and navigates back, flagging the originating page that an error occurred. */
|
|
78
78
|
closeWithError: () => Promise<void>;
|
|
@@ -85,6 +85,10 @@ type MassActionContext = {
|
|
|
85
85
|
type OrderViewButtonContext = {
|
|
86
86
|
orderId: string;
|
|
87
87
|
};
|
|
88
|
+
/** The context shared with invoice view-button extension points. */
|
|
89
|
+
type InvoiceViewButtonContext = {
|
|
90
|
+
invoiceId: string;
|
|
91
|
+
};
|
|
88
92
|
//#endregion
|
|
89
93
|
//#region source/web/react/commerce/context/shared-context.d.ts
|
|
90
94
|
/**
|
|
@@ -137,6 +141,18 @@ export declare function useMassActionContext(): Result<MassActionContext>;
|
|
|
137
141
|
* Returns an error when no order ID is present in the page URL.
|
|
138
142
|
*/
|
|
139
143
|
export declare function useOrderViewButtonContext(): Result<OrderViewButtonContext>;
|
|
144
|
+
/**
|
|
145
|
+
* Returns the invoice ID for an invoice view-button extension point.
|
|
146
|
+
* Reads `invoiceId` from the page URL search parameters or hash-route query.
|
|
147
|
+
* Returns an error when the invoice ID is missing or blank.
|
|
148
|
+
* @example
|
|
149
|
+
* ```tsx
|
|
150
|
+
* const { data, error } = useInvoiceViewButtonContext();
|
|
151
|
+
* if (error) throw error;
|
|
152
|
+
* return <span>{data.invoiceId}</span>;
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
export declare function useInvoiceViewButtonContext(): Result<InvoiceViewButtonContext>;
|
|
140
156
|
//#endregion
|
|
141
157
|
//#region source/web/react/commerce/hooks/use-host-connection.d.ts
|
|
142
158
|
/**
|
|
@@ -210,4 +226,4 @@ type CreateExtensionAppOptions = {
|
|
|
210
226
|
*/
|
|
211
227
|
export declare function createExtensionApp({ menu, metadata, routes, root: customRoot }: CreateExtensionAppOptions): void;
|
|
212
228
|
//#endregion
|
|
213
|
-
export type { CreateExtensionAppOptions, ExtensionRoute, HostConnection, ImsContext, MassActionContext, OrderViewButtonContext, SharedContext };
|
|
229
|
+
export type { CreateExtensionAppOptions, ExtensionRoute, HostConnection, ImsContext, InvoiceViewButtonContext, MassActionContext, OrderViewButtonContext, SharedContext };
|
|
@@ -62,7 +62,24 @@ declare function getAclResourceId(metadataId: string): string;
|
|
|
62
62
|
* @returns The full Commerce ACL resource id, or an empty string when `metadataId` is blank.
|
|
63
63
|
*/
|
|
64
64
|
declare function getCustomAclResourceId(metadataId: string, resourceId: string, childId?: string): string;
|
|
65
|
+
/**
|
|
66
|
+
* Commerce entities an Admin UI component can attach to, using the same spelling Commerce
|
|
67
|
+
* sends in the wire-contract `gridType` field. Credit memo grids send `"creditmemo"` on the
|
|
68
|
+
* wire — not `"creditMemo"` — even though the corresponding config key (`adminUi.creditMemo`)
|
|
69
|
+
* is camelCase.
|
|
70
|
+
*
|
|
71
|
+
* Single source of truth for the entity vocabulary: `GridTypeSchema` derives its picklist from it.
|
|
72
|
+
*/
|
|
73
|
+
declare const ADMIN_UI_GRID_ENTITIES: readonly ["order", "product", "customer", "invoice", "creditmemo", "shipment", "newsletter"];
|
|
65
74
|
/** Commerce entity an Admin UI component is attached to. */
|
|
66
|
-
type AdminUiEntity =
|
|
75
|
+
type AdminUiEntity = (typeof ADMIN_UI_GRID_ENTITIES)[number];
|
|
76
|
+
/**
|
|
77
|
+
* Entities that support mass actions — a subset of `ADMIN_UI_GRID_ENTITIES`. Mass actions, unlike
|
|
78
|
+
* grid columns, are not available on the invoice, credit memo, or shipment grids.
|
|
79
|
+
* `MassActionGridTypeSchema` derives its picklist from it.
|
|
80
|
+
*/
|
|
81
|
+
declare const MASS_ACTION_ENTITIES: readonly ["order", "product", "customer", "newsletter"];
|
|
82
|
+
/** Commerce entity a mass action is attached to. */
|
|
83
|
+
type MassActionEntity = (typeof MASS_ACTION_ENTITIES)[number];
|
|
67
84
|
//#endregion
|
|
68
|
-
export { sanitizeSegment as i,
|
|
85
|
+
export { sanitizeSegment as a, getCustomAclResourceId as i, MassActionEntity as n, getAclResourceId as r, AdminUiEntity as t };
|
|
@@ -79,23 +79,34 @@ function getCustomAclResourceId(metadataId, resourceId, childId) {
|
|
|
79
79
|
const base = `${appRoot}_acl_${sanitizeSegment(resourceId)}`;
|
|
80
80
|
return childId === void 0 ? base : `${base}_${sanitizeSegment(childId)}`;
|
|
81
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Commerce entities an Admin UI component can attach to, using the same spelling Commerce
|
|
84
|
+
* sends in the wire-contract `gridType` field. Credit memo grids send `"creditmemo"` on the
|
|
85
|
+
* wire — not `"creditMemo"` — even though the corresponding config key (`adminUi.creditMemo`)
|
|
86
|
+
* is camelCase.
|
|
87
|
+
*
|
|
88
|
+
* Single source of truth for the entity vocabulary: `GridTypeSchema` derives its picklist from it.
|
|
89
|
+
*/
|
|
90
|
+
const ADMIN_UI_GRID_ENTITIES = [
|
|
91
|
+
"order",
|
|
92
|
+
"product",
|
|
93
|
+
"customer",
|
|
94
|
+
"invoice",
|
|
95
|
+
"creditmemo",
|
|
96
|
+
"shipment",
|
|
97
|
+
"newsletter"
|
|
98
|
+
];
|
|
99
|
+
/**
|
|
100
|
+
* Entities that support mass actions — a subset of `ADMIN_UI_GRID_ENTITIES`. Mass actions, unlike
|
|
101
|
+
* grid columns, are not available on the invoice, credit memo, or shipment grids.
|
|
102
|
+
* `MassActionGridTypeSchema` derives its picklist from it.
|
|
103
|
+
*/
|
|
104
|
+
const MASS_ACTION_ENTITIES = [
|
|
105
|
+
"order",
|
|
106
|
+
"product",
|
|
107
|
+
"customer",
|
|
108
|
+
"newsletter"
|
|
109
|
+
];
|
|
82
110
|
|
|
83
111
|
//#endregion
|
|
84
|
-
|
|
85
|
-
enumerable: true,
|
|
86
|
-
get: function () {
|
|
87
|
-
return getAclResourceId;
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
Object.defineProperty(exports, 'getCustomAclResourceId', {
|
|
91
|
-
enumerable: true,
|
|
92
|
-
get: function () {
|
|
93
|
-
return getCustomAclResourceId;
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
Object.defineProperty(exports, 'sanitizeSegment', {
|
|
97
|
-
enumerable: true,
|
|
98
|
-
get: function () {
|
|
99
|
-
return sanitizeSegment;
|
|
100
|
-
}
|
|
101
|
-
});
|
|
112
|
+
export { sanitizeSegment as a, getCustomAclResourceId as i, MASS_ACTION_ENTITIES as n, getAclResourceId as r, ADMIN_UI_GRID_ENTITIES as t };
|
package/dist/es/api/index.d.mts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import { a as sanitizeSegment, i as getCustomAclResourceId, r as getAclResourceId, t as AdminUiEntity } from "../acl-resource-id-Bha1pOIk.mjs";
|
|
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";
|
package/dist/es/api/index.mjs
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import { a as sanitizeSegment, i as getCustomAclResourceId, r as getAclResourceId } from "../acl-resource-id-CHw95qd2.mjs";
|
|
16
16
|
import { t as parseOrThrow } from "../utils-COPGW1HO.mjs";
|
|
17
17
|
import { CommerceSdkErrorBase } from "@adobe/aio-commerce-lib-core/error";
|
|
18
18
|
import { AdobeCommerceHttpClient, ApiClient } from "@adobe/aio-commerce-lib-api";
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import { t as AdminUiEntity } from "../acl-resource-id-
|
|
15
|
+
import { t as AdminUiEntity } from "../acl-resource-id-Bha1pOIk.mjs";
|
|
16
16
|
import * as v from "valibot";
|
|
17
17
|
import { ErrorResponse, SuccessResponse } from "@adobe/aio-commerce-lib-core/responses";
|
|
18
18
|
//#region source/grid-columns/acl-resource-id.d.ts
|
|
@@ -34,7 +34,8 @@ import { ErrorResponse, SuccessResponse } from "@adobe/aio-commerce-lib-core/res
|
|
|
34
34
|
* ```
|
|
35
35
|
*
|
|
36
36
|
* @param metadataId - The application's `metadata.id` value (e.g. `"approval-dashboard-app"`).
|
|
37
|
-
* @param entity - The grid's Commerce entity (`"order"`, `"product"`,
|
|
37
|
+
* @param entity - The grid's Commerce entity (`"order"`, `"product"`, `"customer"`, `"invoice"`,
|
|
38
|
+
* `"creditmemo"`, `"shipment"`, or `"newsletter"`).
|
|
38
39
|
* @param columnId - The column's `id` value from `adminUi.<entity>.gridColumns.columns[].id`.
|
|
39
40
|
* @returns The full Commerce ACL resource id for the grid-column leaf node, or an empty string
|
|
40
41
|
* when `metadataId` is blank.
|
|
@@ -45,9 +46,12 @@ export declare function getGridColumnAclResourceId(metadataId: string, entity: A
|
|
|
45
46
|
/**
|
|
46
47
|
* Grid identifier sent by Commerce on the `commerce/backend-ui/2` wire contract.
|
|
47
48
|
*
|
|
49
|
+
* Credit memo grids send `"creditmemo"` — not `"creditMemo"` — even though the corresponding
|
|
50
|
+
* config key (`adminUi.creditMemo`) is camelCase; see the Commerce module's `CustomColumn::GRID_MAP`.
|
|
51
|
+
*
|
|
48
52
|
* @see {@link https://github.com/magento-commerce/adobe-commerce-backend-uix Magento module reference}
|
|
49
53
|
*/
|
|
50
|
-
export declare const GridTypeSchema: v.PicklistSchema<["order", "product", "customer"], undefined>;
|
|
54
|
+
export declare const GridTypeSchema: v.PicklistSchema<readonly ["order", "product", "customer", "invoice", "creditmemo", "shipment", "newsletter"], undefined>;
|
|
51
55
|
/**
|
|
52
56
|
* Schema for the JSON body Commerce POSTs to a grid column handler.
|
|
53
57
|
*
|
|
@@ -56,7 +60,7 @@ export declare const GridTypeSchema: v.PicklistSchema<["order", "product", "cust
|
|
|
56
60
|
* enforced here.
|
|
57
61
|
*/
|
|
58
62
|
export declare const GridRequestSchema: v.ObjectSchema<{
|
|
59
|
-
readonly gridType: v.PicklistSchema<["order", "product", "customer"], undefined>;
|
|
63
|
+
readonly gridType: v.PicklistSchema<readonly ["order", "product", "customer", "invoice", "creditmemo", "shipment", "newsletter"], undefined>;
|
|
60
64
|
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">]>;
|
|
61
65
|
readonly requestId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
62
66
|
}, undefined>;
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import { a as sanitizeSegment, r as getAclResourceId, t as ADMIN_UI_GRID_ENTITIES } from "../acl-resource-id-CHw95qd2.mjs";
|
|
16
16
|
import { t as nonEmptyStringValueSchema } from "../schemas-BFT8ys8P.mjs";
|
|
17
17
|
import { t as parseOrThrow } from "../utils-COPGW1HO.mjs";
|
|
18
18
|
import * as v from "valibot";
|
|
@@ -37,7 +37,8 @@ import { buildErrorResponse, ok } from "@adobe/aio-commerce-lib-core/responses";
|
|
|
37
37
|
* ```
|
|
38
38
|
*
|
|
39
39
|
* @param metadataId - The application's `metadata.id` value (e.g. `"approval-dashboard-app"`).
|
|
40
|
-
* @param entity - The grid's Commerce entity (`"order"`, `"product"`,
|
|
40
|
+
* @param entity - The grid's Commerce entity (`"order"`, `"product"`, `"customer"`, `"invoice"`,
|
|
41
|
+
* `"creditmemo"`, `"shipment"`, or `"newsletter"`).
|
|
41
42
|
* @param columnId - The column's `id` value from `adminUi.<entity>.gridColumns.columns[].id`.
|
|
42
43
|
* @returns The full Commerce ACL resource id for the grid-column leaf node, or an empty string
|
|
43
44
|
* when `metadataId` is blank.
|
|
@@ -53,13 +54,12 @@ function getGridColumnAclResourceId(metadataId, entity, columnId) {
|
|
|
53
54
|
/**
|
|
54
55
|
* Grid identifier sent by Commerce on the `commerce/backend-ui/2` wire contract.
|
|
55
56
|
*
|
|
57
|
+
* Credit memo grids send `"creditmemo"` — not `"creditMemo"` — even though the corresponding
|
|
58
|
+
* config key (`adminUi.creditMemo`) is camelCase; see the Commerce module's `CustomColumn::GRID_MAP`.
|
|
59
|
+
*
|
|
56
60
|
* @see {@link https://github.com/magento-commerce/adobe-commerce-backend-uix Magento module reference}
|
|
57
61
|
*/
|
|
58
|
-
const GridTypeSchema = v.picklist(
|
|
59
|
-
"order",
|
|
60
|
-
"product",
|
|
61
|
-
"customer"
|
|
62
|
-
]);
|
|
62
|
+
const GridTypeSchema = v.picklist(ADMIN_UI_GRID_ENTITIES);
|
|
63
63
|
/**
|
|
64
64
|
* Schema for the JSON body Commerce POSTs to a grid column handler.
|
|
65
65
|
*
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2026 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import * as v from "valibot";
|
|
16
|
+
import { ErrorResponse, SuccessResponse } from "@adobe/aio-commerce-lib-core/responses";
|
|
17
|
+
//#region source/invoice-view-buttons/acl-resource-id.d.ts
|
|
18
|
+
/**
|
|
19
|
+
* Derives the Commerce ACL resource ID for an invoice view button.
|
|
20
|
+
* App and button IDs are trimmed, lowercased, and sanitized independently.
|
|
21
|
+
*
|
|
22
|
+
* @param metadataId - The application's `metadata.id` value.
|
|
23
|
+
* @param buttonId - The button's `adminUi.invoice.viewButtons[].id` value.
|
|
24
|
+
* @returns The invoice view-button leaf ID, or an empty string when `metadataId` is blank.
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* getInvoiceViewButtonAclResourceId("billing-app", "export-invoice");
|
|
28
|
+
* // "Magento_CommerceBackendUix::adminuisdk_app_billing_app_invoice_viewbuttons_export_invoice"
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function getInvoiceViewButtonAclResourceId(metadataId: string, buttonId: string): string;
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region source/invoice-view-buttons/schema.d.ts
|
|
34
|
+
/**
|
|
35
|
+
* Schema for an invoice view-button worker request.
|
|
36
|
+
* `id` identifies the clicked button; `invoiceId` identifies the invoice being viewed.
|
|
37
|
+
* All three fields must be non-empty strings.
|
|
38
|
+
*/
|
|
39
|
+
export declare const InvoiceViewButtonRequestSchema: v.ObjectSchema<{
|
|
40
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
41
|
+
readonly invoiceId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
42
|
+
readonly requestId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
43
|
+
}, undefined>;
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region source/invoice-view-buttons/types.d.ts
|
|
46
|
+
/** Parsed request body for an invoice view-button worker. */
|
|
47
|
+
type InvoiceViewButtonRequest = v.InferOutput<typeof InvoiceViewButtonRequestSchema>;
|
|
48
|
+
/** Empty success body returned by an invoice view-button worker. */
|
|
49
|
+
type InvoiceViewButtonSuccessBody = Record<string, never>;
|
|
50
|
+
/** Error body returned by an invoice view-button worker. */
|
|
51
|
+
type InvoiceViewButtonErrorBody = {
|
|
52
|
+
message: string;
|
|
53
|
+
};
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region source/invoice-view-buttons/presets.d.ts
|
|
56
|
+
/**
|
|
57
|
+
* Parses an invoice view-button worker request.
|
|
58
|
+
* Throws `CommerceSdkValidationError` when the input is malformed.
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* const { requestId, id, invoiceId } = parseInvoiceViewButtonRequest(params);
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare function parseInvoiceViewButtonRequest(input: unknown): InvoiceViewButtonRequest;
|
|
65
|
+
/** Builds an HTTP 200 response with an empty body for an invoice view-button worker. */
|
|
66
|
+
export declare function okInvoiceViewButtonResponse(): SuccessResponse<InvoiceViewButtonSuccessBody>;
|
|
67
|
+
/**
|
|
68
|
+
* Builds an error response for an invoice view-button worker.
|
|
69
|
+
* @param statusCode - The HTTP status code to return.
|
|
70
|
+
* @param errorMessage - The message included in the response body.
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* return invoiceViewButtonErrorResponse(500, "Could not export the invoice");
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare function invoiceViewButtonErrorResponse(statusCode: number, errorMessage: string): ErrorResponse<InvoiceViewButtonErrorBody>;
|
|
77
|
+
//#endregion
|
|
78
|
+
export type { InvoiceViewButtonErrorBody, InvoiceViewButtonRequest, InvoiceViewButtonSuccessBody };
|
|
@@ -0,0 +1,85 @@
|
|
|
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 { a as sanitizeSegment, r as getAclResourceId } from "../acl-resource-id-CHw95qd2.mjs";
|
|
16
|
+
import { t as nonEmptyStringValueSchema } from "../schemas-BFT8ys8P.mjs";
|
|
17
|
+
import { t as parseOrThrow } from "../utils-COPGW1HO.mjs";
|
|
18
|
+
import * as v from "valibot";
|
|
19
|
+
import { buildErrorResponse, ok } from "@adobe/aio-commerce-lib-core/responses";
|
|
20
|
+
|
|
21
|
+
//#region source/invoice-view-buttons/acl-resource-id.ts
|
|
22
|
+
/**
|
|
23
|
+
* Derives the Commerce ACL resource ID for an invoice view button.
|
|
24
|
+
* App and button IDs are trimmed, lowercased, and sanitized independently.
|
|
25
|
+
*
|
|
26
|
+
* @param metadataId - The application's `metadata.id` value.
|
|
27
|
+
* @param buttonId - The button's `adminUi.invoice.viewButtons[].id` value.
|
|
28
|
+
* @returns The invoice view-button leaf ID, or an empty string when `metadataId` is blank.
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* getInvoiceViewButtonAclResourceId("billing-app", "export-invoice");
|
|
32
|
+
* // "Magento_CommerceBackendUix::adminuisdk_app_billing_app_invoice_viewbuttons_export_invoice"
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
function getInvoiceViewButtonAclResourceId(metadataId, buttonId) {
|
|
36
|
+
const appRoot = getAclResourceId(metadataId);
|
|
37
|
+
if (appRoot === "") return "";
|
|
38
|
+
return `${appRoot}_invoice_viewbuttons_${sanitizeSegment(buttonId)}`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region source/invoice-view-buttons/schema.ts
|
|
43
|
+
/**
|
|
44
|
+
* Schema for an invoice view-button worker request.
|
|
45
|
+
* `id` identifies the clicked button; `invoiceId` identifies the invoice being viewed.
|
|
46
|
+
* All three fields must be non-empty strings.
|
|
47
|
+
*/
|
|
48
|
+
const InvoiceViewButtonRequestSchema = v.object({
|
|
49
|
+
id: nonEmptyStringValueSchema("id"),
|
|
50
|
+
invoiceId: nonEmptyStringValueSchema("invoiceId"),
|
|
51
|
+
requestId: nonEmptyStringValueSchema("requestId")
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region source/invoice-view-buttons/presets.ts
|
|
56
|
+
/**
|
|
57
|
+
* Parses an invoice view-button worker request.
|
|
58
|
+
* Throws `CommerceSdkValidationError` when the input is malformed.
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* const { requestId, id, invoiceId } = parseInvoiceViewButtonRequest(params);
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
function parseInvoiceViewButtonRequest(input) {
|
|
65
|
+
return parseOrThrow(InvoiceViewButtonRequestSchema, input, "Invalid invoice view button request");
|
|
66
|
+
}
|
|
67
|
+
/** Builds an HTTP 200 response with an empty body for an invoice view-button worker. */
|
|
68
|
+
function okInvoiceViewButtonResponse() {
|
|
69
|
+
return ok({ body: {} });
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Builds an error response for an invoice view-button worker.
|
|
73
|
+
* @param statusCode - The HTTP status code to return.
|
|
74
|
+
* @param errorMessage - The message included in the response body.
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* return invoiceViewButtonErrorResponse(500, "Could not export the invoice");
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
function invoiceViewButtonErrorResponse(statusCode, errorMessage) {
|
|
81
|
+
return buildErrorResponse(statusCode, { body: { message: errorMessage } });
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
//#endregion
|
|
85
|
+
export { InvoiceViewButtonRequestSchema, getInvoiceViewButtonAclResourceId, invoiceViewButtonErrorResponse, okInvoiceViewButtonResponse, parseInvoiceViewButtonRequest };
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import { t as AdminUiEntity } from "../acl-resource-id-
|
|
15
|
+
import { n as MassActionEntity, t as AdminUiEntity } from "../acl-resource-id-Bha1pOIk.mjs";
|
|
16
16
|
import * as v from "valibot";
|
|
17
17
|
import { ErrorResponse, SuccessResponse } from "@adobe/aio-commerce-lib-core/responses";
|
|
18
18
|
//#region source/mass-actions/acl-resource-id.d.ts
|
|
@@ -34,19 +34,19 @@ import { ErrorResponse, SuccessResponse } from "@adobe/aio-commerce-lib-core/res
|
|
|
34
34
|
* ```
|
|
35
35
|
*
|
|
36
36
|
* @param metadataId - The application's `metadata.id` value (e.g. `"approval-dashboard-app"`).
|
|
37
|
-
* @param entity - The grid's Commerce entity (`"order"`, `"product"`, or `"
|
|
37
|
+
* @param entity - The grid's Commerce entity (`"order"`, `"product"`, `"customer"`, or `"newsletter"`).
|
|
38
38
|
* @param actionId - The action's `id` value from `adminUi.<entity>.massActions[].id`.
|
|
39
39
|
* @returns The full Commerce ACL resource id for the mass-action leaf node, or an empty string
|
|
40
40
|
* when `metadataId` is blank.
|
|
41
41
|
*/
|
|
42
|
-
export declare function getMassActionAclResourceId(metadataId: string, entity:
|
|
42
|
+
export declare function getMassActionAclResourceId(metadataId: string, entity: MassActionEntity, actionId: string): string;
|
|
43
43
|
//#endregion
|
|
44
44
|
//#region source/mass-actions/worker/schema.d.ts
|
|
45
45
|
/**
|
|
46
46
|
* Grid identifier sent by Commerce on the `commerce/backend-ui/2` wire contract
|
|
47
47
|
* for worker mass actions.
|
|
48
48
|
*/
|
|
49
|
-
export declare const MassActionGridTypeSchema: v.PicklistSchema<["order", "product", "customer"], undefined>;
|
|
49
|
+
export declare const MassActionGridTypeSchema: v.PicklistSchema<readonly ["order", "product", "customer", "newsletter"], undefined>;
|
|
50
50
|
/**
|
|
51
51
|
* Schema for the JSON body Commerce POSTs to a worker mass action handler.
|
|
52
52
|
*
|
|
@@ -55,7 +55,7 @@ export declare const MassActionGridTypeSchema: v.PicklistSchema<["order", "produ
|
|
|
55
55
|
* enforced here.
|
|
56
56
|
*/
|
|
57
57
|
export declare const MassActionRequestSchema: v.ObjectSchema<{
|
|
58
|
-
readonly gridType: v.PicklistSchema<["order", "product", "customer"], undefined>;
|
|
58
|
+
readonly gridType: v.PicklistSchema<readonly ["order", "product", "customer", "newsletter"], undefined>;
|
|
59
59
|
readonly requestId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
60
60
|
readonly selectedIds: 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 \"selectedIds\" must contain at least one entry">]>;
|
|
61
61
|
}, undefined>;
|
|
@@ -115,4 +115,4 @@ export declare function okMassActionResponse(body?: MassActionResponseBody): Suc
|
|
|
115
115
|
*/
|
|
116
116
|
export declare function massActionErrorResponse(statusCode: number, errorMessage: string): ErrorResponse<MassActionErrorBody>;
|
|
117
117
|
//#endregion
|
|
118
|
-
export type { AdminUiEntity, MassActionErrorBody, MassActionGridType, MassActionRequest, MassActionResponseBody };
|
|
118
|
+
export type { AdminUiEntity, MassActionEntity, MassActionErrorBody, MassActionGridType, MassActionRequest, MassActionResponseBody };
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import { a as sanitizeSegment, n as MASS_ACTION_ENTITIES, r as getAclResourceId } from "../acl-resource-id-CHw95qd2.mjs";
|
|
16
16
|
import { t as nonEmptyStringValueSchema } from "../schemas-BFT8ys8P.mjs";
|
|
17
17
|
import { t as parseOrThrow } from "../utils-COPGW1HO.mjs";
|
|
18
18
|
import * as v from "valibot";
|
|
@@ -37,7 +37,7 @@ import { buildErrorResponse, ok } from "@adobe/aio-commerce-lib-core/responses";
|
|
|
37
37
|
* ```
|
|
38
38
|
*
|
|
39
39
|
* @param metadataId - The application's `metadata.id` value (e.g. `"approval-dashboard-app"`).
|
|
40
|
-
* @param entity - The grid's Commerce entity (`"order"`, `"product"`, or `"
|
|
40
|
+
* @param entity - The grid's Commerce entity (`"order"`, `"product"`, `"customer"`, or `"newsletter"`).
|
|
41
41
|
* @param actionId - The action's `id` value from `adminUi.<entity>.massActions[].id`.
|
|
42
42
|
* @returns The full Commerce ACL resource id for the mass-action leaf node, or an empty string
|
|
43
43
|
* when `metadataId` is blank.
|
|
@@ -54,11 +54,7 @@ function getMassActionAclResourceId(metadataId, entity, actionId) {
|
|
|
54
54
|
* Grid identifier sent by Commerce on the `commerce/backend-ui/2` wire contract
|
|
55
55
|
* for worker mass actions.
|
|
56
56
|
*/
|
|
57
|
-
const MassActionGridTypeSchema = v.picklist(
|
|
58
|
-
"order",
|
|
59
|
-
"product",
|
|
60
|
-
"customer"
|
|
61
|
-
]);
|
|
57
|
+
const MassActionGridTypeSchema = v.picklist(MASS_ACTION_ENTITIES);
|
|
62
58
|
/**
|
|
63
59
|
* Schema for the JSON body Commerce POSTs to a worker mass action handler.
|
|
64
60
|
*
|
package/dist/es/menu/index.mjs
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import { a as sanitizeSegment, r as getAclResourceId } from "../acl-resource-id-CHw95qd2.mjs";
|
|
16
16
|
|
|
17
17
|
//#region source/menu/acl-resource-id.ts
|
|
18
18
|
/**
|
|
@@ -18,7 +18,7 @@ import { ErrorResponse, SuccessResponse } from "@adobe/aio-commerce-lib-core/res
|
|
|
18
18
|
/**
|
|
19
19
|
* Derives the deterministic Commerce ACL resource id for an order view button.
|
|
20
20
|
*
|
|
21
|
-
*
|
|
21
|
+
* This helper is scoped to the order entity, so no entity discriminator is needed.
|
|
22
22
|
* The id is assembled as: `getAclResourceId(metadataId)` + `"_order_viewbuttons_"` +
|
|
23
23
|
* sanitized `buttonId`. The `buttonId` is sanitized (trimmed, lowercased, non-`[a-z0-9_]` → `_`).
|
|
24
24
|
* `"Magento_CommerceBackendUix::adminuisdk_app_"` in the example is the fixed constant prefix
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import { a as sanitizeSegment, r as getAclResourceId } from "../acl-resource-id-CHw95qd2.mjs";
|
|
16
16
|
import { t as nonEmptyStringValueSchema } from "../schemas-BFT8ys8P.mjs";
|
|
17
17
|
import { t as parseOrThrow } from "../utils-COPGW1HO.mjs";
|
|
18
18
|
import * as v from "valibot";
|
|
@@ -22,7 +22,7 @@ import { buildErrorResponse, ok } from "@adobe/aio-commerce-lib-core/responses";
|
|
|
22
22
|
/**
|
|
23
23
|
* Derives the deterministic Commerce ACL resource id for an order view button.
|
|
24
24
|
*
|
|
25
|
-
*
|
|
25
|
+
* This helper is scoped to the order entity, so no entity discriminator is needed.
|
|
26
26
|
* The id is assembled as: `getAclResourceId(metadataId)` + `"_order_viewbuttons_"` +
|
|
27
27
|
* sanitized `buttonId`. The `buttonId` is sanitized (trimmed, lowercased, non-`[a-z0-9_]` → `_`).
|
|
28
28
|
* `"Magento_CommerceBackendUix::adminuisdk_app_"` in the example is the fixed constant prefix
|
package/dist/es/web/index.d.mts
CHANGED
|
@@ -72,7 +72,7 @@ type SharedContext = {
|
|
|
72
72
|
};
|
|
73
73
|
/** Actions for closing the extension iframe and returning control to the Commerce Admin. */
|
|
74
74
|
type HostConnection = {
|
|
75
|
-
/** Closes the iframe and navigates back to the originating grid or
|
|
75
|
+
/** Closes the iframe and navigates back to the originating grid or detail page. */
|
|
76
76
|
close: () => Promise<void>;
|
|
77
77
|
/** Closes the iframe and navigates back, flagging the originating page that an error occurred. */
|
|
78
78
|
closeWithError: () => Promise<void>;
|
|
@@ -85,6 +85,10 @@ type MassActionContext = {
|
|
|
85
85
|
type OrderViewButtonContext = {
|
|
86
86
|
orderId: string;
|
|
87
87
|
};
|
|
88
|
+
/** The context shared with invoice view-button extension points. */
|
|
89
|
+
type InvoiceViewButtonContext = {
|
|
90
|
+
invoiceId: string;
|
|
91
|
+
};
|
|
88
92
|
//#endregion
|
|
89
93
|
//#region source/web/react/commerce/context/shared-context.d.ts
|
|
90
94
|
/**
|
|
@@ -137,6 +141,18 @@ export declare function useMassActionContext(): Result<MassActionContext>;
|
|
|
137
141
|
* Returns an error when no order ID is present in the page URL.
|
|
138
142
|
*/
|
|
139
143
|
export declare function useOrderViewButtonContext(): Result<OrderViewButtonContext>;
|
|
144
|
+
/**
|
|
145
|
+
* Returns the invoice ID for an invoice view-button extension point.
|
|
146
|
+
* Reads `invoiceId` from the page URL search parameters or hash-route query.
|
|
147
|
+
* Returns an error when the invoice ID is missing or blank.
|
|
148
|
+
* @example
|
|
149
|
+
* ```tsx
|
|
150
|
+
* const { data, error } = useInvoiceViewButtonContext();
|
|
151
|
+
* if (error) throw error;
|
|
152
|
+
* return <span>{data.invoiceId}</span>;
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
export declare function useInvoiceViewButtonContext(): Result<InvoiceViewButtonContext>;
|
|
140
156
|
//#endregion
|
|
141
157
|
//#region source/web/react/commerce/hooks/use-host-connection.d.ts
|
|
142
158
|
/**
|
|
@@ -210,4 +226,4 @@ type CreateExtensionAppOptions = {
|
|
|
210
226
|
*/
|
|
211
227
|
export declare function createExtensionApp({ menu, metadata, routes, root: customRoot }: CreateExtensionAppOptions): void;
|
|
212
228
|
//#endregion
|
|
213
|
-
export type { CreateExtensionAppOptions, ExtensionRoute, HostConnection, ImsContext, MassActionContext, OrderViewButtonContext, SharedContext };
|
|
229
|
+
export type { CreateExtensionAppOptions, ExtensionRoute, HostConnection, ImsContext, InvoiceViewButtonContext, MassActionContext, OrderViewButtonContext, SharedContext };
|
package/dist/es/web/index.mjs
CHANGED
|
@@ -32,8 +32,19 @@ import { ErrorBoundary } from "react-error-boundary";
|
|
|
32
32
|
* @param href - The URL to read the order ID from (typically `window.location.href`).
|
|
33
33
|
*/
|
|
34
34
|
function parseOrderId(href) {
|
|
35
|
+
return parseViewButtonId(href, "orderId");
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Extracts the invoice ID from the given absolute URL.
|
|
39
|
+
* @param href - The URL to read the invoice ID from (typically `window.location.href`).
|
|
40
|
+
*/
|
|
41
|
+
function parseInvoiceId(href) {
|
|
42
|
+
return parseViewButtonId(href, "invoiceId");
|
|
43
|
+
}
|
|
44
|
+
/** Reads a view-button identifier from the URL search parameters or hash-route query. */
|
|
45
|
+
function parseViewButtonId(href, key) {
|
|
35
46
|
const urlObj = new URL(href);
|
|
36
|
-
return urlObj.searchParams.get(
|
|
47
|
+
return urlObj.searchParams.get(key) ?? new URLSearchParams(urlObj.hash.split("?").at(1)).get(key);
|
|
37
48
|
}
|
|
38
49
|
/** Whether the app is embedded in a host frame (the Commerce Admin or the Experience Cloud shell). */
|
|
39
50
|
function isEmbeddedInHost() {
|
|
@@ -290,6 +301,24 @@ function useOrderViewButtonContext() {
|
|
|
290
301
|
return ok({ orderId });
|
|
291
302
|
}, []);
|
|
292
303
|
}
|
|
304
|
+
/**
|
|
305
|
+
* Returns the invoice ID for an invoice view-button extension point.
|
|
306
|
+
* Reads `invoiceId` from the page URL search parameters or hash-route query.
|
|
307
|
+
* Returns an error when the invoice ID is missing or blank.
|
|
308
|
+
* @example
|
|
309
|
+
* ```tsx
|
|
310
|
+
* const { data, error } = useInvoiceViewButtonContext();
|
|
311
|
+
* if (error) throw error;
|
|
312
|
+
* return <span>{data.invoiceId}</span>;
|
|
313
|
+
* ```
|
|
314
|
+
*/
|
|
315
|
+
function useInvoiceViewButtonContext() {
|
|
316
|
+
return useMemo(() => {
|
|
317
|
+
const invoiceId = parseInvoiceId(globalThis.location.href);
|
|
318
|
+
if (invoiceId === null || invoiceId.trim() === "") return error("Could not find an invoice ID. Is this frame running as an invoice view-button extension point?");
|
|
319
|
+
return ok({ invoiceId });
|
|
320
|
+
}, []);
|
|
321
|
+
}
|
|
293
322
|
|
|
294
323
|
//#endregion
|
|
295
324
|
//#region source/web/react/commerce/hooks/use-host-connection.ts
|
|
@@ -870,4 +899,4 @@ function createExtensionApp({ menu, metadata, routes = [], root: customRoot }) {
|
|
|
870
899
|
}
|
|
871
900
|
|
|
872
901
|
//#endregion
|
|
873
|
-
export { createExtensionApp, useCommerce, useHostConnection, useIms, useMassActionContext, useOrderViewButtonContext, useSharedContext };
|
|
902
|
+
export { createExtensionApp, useCommerce, useHostConnection, useIms, useInvoiceViewButtonContext, useMassActionContext, useOrderViewButtonContext, useSharedContext };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/aio-commerce-lib-admin-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0-alpha-20261007115732",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A library to interact with the Adobe Commerce Admin UI SDK API",
|
|
6
6
|
"keywords": [
|
|
@@ -52,6 +52,16 @@
|
|
|
52
52
|
"default": "./dist/cjs/grid-columns/index.cjs"
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
|
+
"./invoice-view-buttons": {
|
|
56
|
+
"import": {
|
|
57
|
+
"types": "./dist/es/invoice-view-buttons/index.d.mts",
|
|
58
|
+
"default": "./dist/es/invoice-view-buttons/index.mjs"
|
|
59
|
+
},
|
|
60
|
+
"require": {
|
|
61
|
+
"types": "./dist/cjs/invoice-view-buttons/index.d.cts",
|
|
62
|
+
"default": "./dist/cjs/invoice-view-buttons/index.cjs"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
55
65
|
"./mass-actions": {
|
|
56
66
|
"import": {
|
|
57
67
|
"types": "./dist/es/mass-actions/index.d.mts",
|
|
@@ -101,7 +111,7 @@
|
|
|
101
111
|
"README.md"
|
|
102
112
|
],
|
|
103
113
|
"dependencies": {
|
|
104
|
-
"@adobe/aio-commerce-lib-api": "1.4.
|
|
114
|
+
"@adobe/aio-commerce-lib-api": "1.4.1-alpha-20261007115732",
|
|
105
115
|
"@adobe/aio-commerce-lib-core": "1.2.0",
|
|
106
116
|
"@adobe/exc-app": "^1.4.20",
|
|
107
117
|
"@adobe/uix-guest": "^1.0.3",
|
|
@@ -116,7 +126,6 @@
|
|
|
116
126
|
"@aio-commerce-sdk/config-typedoc": "1.0.0",
|
|
117
127
|
"@aio-commerce-sdk/config-typescript": "1.0.0",
|
|
118
128
|
"@aio-commerce-sdk/config-vitest": "1.0.0",
|
|
119
|
-
"@aio-commerce-sdk/scripting-utils": "0.3.5",
|
|
120
129
|
"@aio-commerce-sdk/scripts": "0.1.1",
|
|
121
130
|
"@react-spectrum/s2": "^1.5.1",
|
|
122
131
|
"@types/react": "^19.2.17",
|