@adobe/aio-commerce-lib-admin-ui 1.2.0 → 1.3.0-alpha-20261110204456

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +1 -1
  3. package/dist/cjs/api/index.cjs +2 -2
  4. package/dist/cjs/api/index.d.cts +1 -0
  5. package/dist/cjs/credit-memo-view-buttons/index.cjs +90 -0
  6. package/dist/cjs/credit-memo-view-buttons/index.d.cts +76 -0
  7. package/dist/cjs/grid-columns/index.cjs +3 -3
  8. package/dist/cjs/grid-columns/index.d.cts +9 -0
  9. package/dist/cjs/invoice-view-buttons/index.cjs +90 -0
  10. package/dist/cjs/invoice-view-buttons/index.d.cts +76 -0
  11. package/dist/cjs/mass-actions/index.cjs +3 -3
  12. package/dist/cjs/mass-actions/index.d.cts +10 -0
  13. package/dist/cjs/menu/index.d.cts +9 -0
  14. package/dist/cjs/order-view-buttons/index.cjs +6 -5
  15. package/dist/cjs/order-view-buttons/index.d.cts +10 -1
  16. package/dist/cjs/{rolldown-runtime-DREAZOkv.cjs → rolldown-runtime-DdowHpbl.cjs} +4 -4
  17. package/dist/cjs/{schemas-C-tIBLog.cjs → schemas-CkbEkj5k.cjs} +1 -1
  18. package/dist/cjs/{utils-D5meZ8l8.cjs → utils-Dz_BZgfW.cjs} +1 -1
  19. package/dist/cjs/view-button-request-BymT_z5j.cjs +46 -0
  20. package/dist/cjs/web/index.cjs +95 -3
  21. package/dist/cjs/web/index.d.cts +63 -2
  22. package/dist/es/api/index.d.mts +1 -0
  23. package/dist/es/api/index.mjs +4 -4
  24. package/dist/es/credit-memo-view-buttons/index.d.mts +76 -0
  25. package/dist/es/credit-memo-view-buttons/index.mjs +83 -0
  26. package/dist/es/grid-columns/index.d.mts +9 -0
  27. package/dist/es/invoice-view-buttons/index.d.mts +76 -0
  28. package/dist/es/invoice-view-buttons/index.mjs +83 -0
  29. package/dist/es/mass-actions/index.d.mts +10 -0
  30. package/dist/es/menu/index.d.mts +9 -0
  31. package/dist/es/order-view-buttons/index.d.mts +10 -1
  32. package/dist/es/order-view-buttons/index.mjs +3 -2
  33. package/dist/es/view-button-request-Cu7Qz7jY.mjs +39 -0
  34. package/dist/es/web/index.d.mts +63 -2
  35. package/dist/es/web/index.mjs +90 -2
  36. package/package.json +21 -1
@@ -13,7 +13,8 @@
13
13
  */
14
14
 
15
15
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
16
- const require_rolldown_runtime = require("../rolldown-runtime-DREAZOkv.cjs");
16
+ const require_rolldown_runtime = require("../rolldown-runtime-DdowHpbl.cjs");
17
+ let valibot = require("valibot");
17
18
  let react = require("react");
18
19
  let react_jsx_runtime = require("react/jsx-runtime");
19
20
  let _adobe_exc_app = require("@adobe/exc-app");
@@ -37,8 +38,26 @@ let react_error_boundary = require("react-error-boundary");
37
38
  * @param href - The URL to read the order ID from (typically `window.location.href`).
38
39
  */
39
40
  function parseOrderId(href) {
41
+ return parseViewButtonId(href, "orderId");
42
+ }
43
+ /**
44
+ * Extracts the invoice ID from the given absolute URL.
45
+ * @param href - The URL to read the invoice ID from (typically `window.location.href`).
46
+ */
47
+ function parseInvoiceId(href) {
48
+ return parseViewButtonId(href, "invoiceId");
49
+ }
50
+ /**
51
+ * Extracts the credit memo ID from the given absolute URL.
52
+ * @param href - The URL to read the credit memo ID from (typically `window.location.href`).
53
+ */
54
+ function parseCreditMemoId(href) {
55
+ return parseViewButtonId(href, "creditMemoId");
56
+ }
57
+ /** Reads a view-button identifier from the URL search parameters or hash-route query. */
58
+ function parseViewButtonId(href, key) {
40
59
  const urlObj = new URL(href);
41
- return urlObj.searchParams.get("orderId") ?? new URLSearchParams(urlObj.hash.split("?")[1]).get("orderId");
60
+ return urlObj.searchParams.get(key) ?? new URLSearchParams(urlObj.hash.split("?").at(1)).get(key);
42
61
  }
43
62
  /** Whether the app is embedded in a host frame (the Commerce Admin or the Experience Cloud shell). */
44
63
  function isEmbeddedInHost() {
@@ -258,6 +277,7 @@ function useCommerce() {
258
277
  }
259
278
 
260
279
  // source/web/react/commerce/hooks/use-extension-context.ts
280
+ const ContextIdSchema = (0, valibot.union)([(0, valibot.string)(), (0, valibot.pipe)((0, valibot.number)(), (0, valibot.finite)())]);
261
281
  /**
262
282
  * Returns the context for a mass-action extension point: the selected row IDs the action was
263
283
  * triggered with. The value is read from the host-provided Commerce context.
@@ -289,6 +309,74 @@ function useOrderViewButtonContext() {
289
309
  return ok({ orderId });
290
310
  }, []);
291
311
  }
312
+ /**
313
+ * Returns the customer identifier from the Commerce shared context as a string.
314
+ * Numeric identifiers are converted to strings; existing strings retain leading zeros.
315
+ *
316
+ * Returns an error outside the Commerce shared context or when the customer identifier is
317
+ * missing, null, or not a string or finite number. The store identifier is not required.
318
+ */
319
+ function useCustomerContext() {
320
+ const { data, error: contextError } = useSharedContext();
321
+ return (0, react.useMemo)(() => {
322
+ if (contextError) return error(contextError.message, { cause: contextError });
323
+ const customerId = data.sharedContext.get("customerId");
324
+ if (!(0, valibot.is)(ContextIdSchema, customerId)) return error("The Commerce shared context value \"customerId\" must be a string or finite number.");
325
+ return ok({ customerId: String(customerId) });
326
+ }, [data, contextError]);
327
+ }
328
+ /**
329
+ * Returns the store identifier from the Commerce shared context as a string.
330
+ * Numeric identifiers are converted to strings; existing strings retain leading zeros.
331
+ *
332
+ * Returns an error outside the Commerce shared context or when the store identifier is
333
+ * missing, null, or not a string or finite number. The customer identifier is not required.
334
+ */
335
+ function useStoreContext() {
336
+ const { data, error: contextError } = useSharedContext();
337
+ return (0, react.useMemo)(() => {
338
+ if (contextError) return error(contextError.message, { cause: contextError });
339
+ const storeId = data.sharedContext.get("storeId");
340
+ if (!(0, valibot.is)(ContextIdSchema, storeId)) return error("The Commerce shared context value \"storeId\" must be a string or finite number.");
341
+ return ok({ storeId: String(storeId) });
342
+ }, [data, contextError]);
343
+ }
344
+ /**
345
+ * Returns the invoice ID for an invoice view-button extension point.
346
+ * Reads `invoiceId` from the page URL search parameters or hash-route query.
347
+ * Returns an error when the invoice ID is missing or blank.
348
+ * @example
349
+ * ```tsx
350
+ * const { data, error } = useInvoiceViewButtonContext();
351
+ * if (error) throw error;
352
+ * return <span>{data.invoiceId}</span>;
353
+ * ```
354
+ */
355
+ function useInvoiceViewButtonContext() {
356
+ return (0, react.useMemo)(() => {
357
+ const invoiceId = parseInvoiceId(globalThis.location.href);
358
+ if (invoiceId === null || invoiceId.trim() === "") return error("Could not find an invoice ID. Is this frame running as an invoice view-button extension point?");
359
+ return ok({ invoiceId });
360
+ }, []);
361
+ }
362
+ /**
363
+ * Returns the credit memo ID for a credit memo view-button extension point.
364
+ * Reads `creditMemoId` from the page URL search parameters or hash-route query.
365
+ * Returns an error when the credit memo ID is missing or blank.
366
+ * @example
367
+ * ```tsx
368
+ * const { data, error } = useCreditMemoViewButtonContext();
369
+ * if (error) throw error;
370
+ * return <span>{data.creditMemoId}</span>;
371
+ * ```
372
+ */
373
+ function useCreditMemoViewButtonContext() {
374
+ return (0, react.useMemo)(() => {
375
+ const creditMemoId = parseCreditMemoId(globalThis.location.href);
376
+ if (creditMemoId === null || creditMemoId.trim() === "") return error("Could not find a credit memo ID. Is this frame running as a credit memo view-button extension point?");
377
+ return ok({ creditMemoId });
378
+ }, []);
379
+ }
292
380
 
293
381
  // source/web/react/commerce/hooks/use-host-connection.ts
294
382
  /**
@@ -854,8 +942,12 @@ function createExtensionApp({ menu, metadata, routes = [], root: customRoot }) {
854
942
 
855
943
  exports.createExtensionApp = createExtensionApp;
856
944
  exports.useCommerce = useCommerce;
945
+ exports.useCreditMemoViewButtonContext = useCreditMemoViewButtonContext;
946
+ exports.useCustomerContext = useCustomerContext;
857
947
  exports.useHostConnection = useHostConnection;
858
948
  exports.useIms = useIms;
949
+ exports.useInvoiceViewButtonContext = useInvoiceViewButtonContext;
859
950
  exports.useMassActionContext = useMassActionContext;
860
951
  exports.useOrderViewButtonContext = useOrderViewButtonContext;
861
- exports.useSharedContext = useSharedContext;
952
+ exports.useSharedContext = useSharedContext;
953
+ exports.useStoreContext = useStoreContext;
@@ -12,6 +12,11 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
+ /** biome-ignore-all lint/performance/noBarrelFile: This is the public API for the web entrypoint. */
16
+ /**
17
+ * Browser helpers for mounting `commerce/backend-ui/2` iframe apps.
18
+ * @packageDocumentation
19
+ */
15
20
  import { ReactNode } from "react";
16
21
  import { attach } from "@adobe/uix-guest";
17
22
  import { NavigateOptions, ToOptions } from "@tanstack/react-router";
@@ -65,7 +70,7 @@ type SharedContext = {
65
70
  };
66
71
  /** Actions for closing the extension iframe and returning control to the Commerce Admin. */
67
72
  type HostConnection = {
68
- /** Closes the iframe and navigates back to the originating grid or order. */
73
+ /** Closes the iframe and navigates back to the originating grid or detail page. */
69
74
  close: () => Promise<void>;
70
75
  /** Closes the iframe and navigates back, flagging the originating page that an error occurred. */
71
76
  closeWithError: () => Promise<void>;
@@ -78,6 +83,22 @@ type MassActionContext = {
78
83
  type OrderViewButtonContext = {
79
84
  orderId: string;
80
85
  };
86
+ /** The customer identifier provided by the Commerce shared context. */
87
+ type CustomerContext = {
88
+ customerId: string;
89
+ };
90
+ /** The store identifier provided by the Commerce shared context. */
91
+ type StoreContext = {
92
+ storeId: string;
93
+ };
94
+ /** The context shared with invoice view-button extension points. */
95
+ type InvoiceViewButtonContext = {
96
+ invoiceId: string;
97
+ };
98
+ /** The context shared with credit memo view-button extension points. */
99
+ type CreditMemoViewButtonContext = {
100
+ creditMemoId: string;
101
+ };
81
102
  /**
82
103
  * Returns the current Commerce shared context. The guest connection is already established by
83
104
  * the time this can be called (see {@link SharedContextProvider}).
@@ -124,6 +145,46 @@ export declare function useMassActionContext(): Result<MassActionContext>;
124
145
  * Returns an error when no order ID is present in the page URL.
125
146
  */
126
147
  export declare function useOrderViewButtonContext(): Result<OrderViewButtonContext>;
148
+ /**
149
+ * Returns the customer identifier from the Commerce shared context as a string.
150
+ * Numeric identifiers are converted to strings; existing strings retain leading zeros.
151
+ *
152
+ * Returns an error outside the Commerce shared context or when the customer identifier is
153
+ * missing, null, or not a string or finite number. The store identifier is not required.
154
+ */
155
+ export declare function useCustomerContext(): Result<CustomerContext>;
156
+ /**
157
+ * Returns the store identifier from the Commerce shared context as a string.
158
+ * Numeric identifiers are converted to strings; existing strings retain leading zeros.
159
+ *
160
+ * Returns an error outside the Commerce shared context or when the store identifier is
161
+ * missing, null, or not a string or finite number. The customer identifier is not required.
162
+ */
163
+ export declare function useStoreContext(): Result<StoreContext>;
164
+ /**
165
+ * Returns the invoice ID for an invoice view-button extension point.
166
+ * Reads `invoiceId` from the page URL search parameters or hash-route query.
167
+ * Returns an error when the invoice ID is missing or blank.
168
+ * @example
169
+ * ```tsx
170
+ * const { data, error } = useInvoiceViewButtonContext();
171
+ * if (error) throw error;
172
+ * return <span>{data.invoiceId}</span>;
173
+ * ```
174
+ */
175
+ export declare function useInvoiceViewButtonContext(): Result<InvoiceViewButtonContext>;
176
+ /**
177
+ * Returns the credit memo ID for a credit memo view-button extension point.
178
+ * Reads `creditMemoId` from the page URL search parameters or hash-route query.
179
+ * Returns an error when the credit memo ID is missing or blank.
180
+ * @example
181
+ * ```tsx
182
+ * const { data, error } = useCreditMemoViewButtonContext();
183
+ * if (error) throw error;
184
+ * return <span>{data.creditMemoId}</span>;
185
+ * ```
186
+ */
187
+ export declare function useCreditMemoViewButtonContext(): Result<CreditMemoViewButtonContext>;
127
188
  /**
128
189
  * Returns typed helpers for interacting with the Commerce Admin host.
129
190
  *
@@ -190,4 +251,4 @@ type CreateExtensionAppOptions = {
190
251
  * ```
191
252
  */
192
253
  export declare function createExtensionApp({ menu, metadata, routes, root: customRoot }: CreateExtensionAppOptions): void;
193
- export type { CreateExtensionAppOptions, ExtensionRoute, HostConnection, ImsContext, MassActionContext, OrderViewButtonContext, SharedContext };
254
+ export type { CreateExtensionAppOptions, CreditMemoViewButtonContext, CustomerContext, ExtensionRoute, HostConnection, ImsContext, InvoiceViewButtonContext, MassActionContext, OrderViewButtonContext, SharedContext, StoreContext };
@@ -12,6 +12,7 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
+ /** biome-ignore-all lint/performance/noBarrelFile: This is the `@adobe/aio-commerce-lib-admin-ui/api` entrypoint. */
15
16
  import { a as sanitizeSegment, i as getCustomAclResourceId, r as getAclResourceId, t as AdminUiEntity } from "../acl-resource-id-CXVgxUmB.mjs";
16
17
  import { CommerceSdkErrorBase, CommerceSdkErrorOptions } from "@adobe/aio-commerce-lib-core/error";
17
18
  import { AdobeCommerceHttpClient, CommerceHttpClientParams } from "@adobe/aio-commerce-lib-api";
@@ -21,18 +21,18 @@ import { HTTPError } from "ky";
21
21
 
22
22
  // \0rolldown/runtime.js
23
23
  var __defProp = Object.defineProperty;
24
- var __exportAll = (all, no_symbols) => {
25
- let target = {};
24
+ var __exportAll = (all, flags) => {
25
+ let target = Object.setPrototypeOf({}, null);
26
26
  for (var name in all) {
27
27
  __defProp(target, name, {
28
28
  get: all[name],
29
29
  enumerable: true
30
30
  });
31
31
  }
32
- if (!no_symbols) {
32
+ if (!(flags & 1)) {
33
33
  __defProp(target, Symbol.toStringTag, { value: "Module" });
34
34
  }
35
- return target;
35
+ return flags & 2 ? target : Object.preventExtensions(target);
36
36
  };
37
37
 
38
38
  // source/errors.ts
@@ -0,0 +1,76 @@
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
+ /** biome-ignore-all lint/performance/noBarrelFile: This is the public API for the credit-memo-view-buttons entrypoint. */
16
+ /**
17
+ * Request parsing, response builders, and ACL resource IDs for `commerce/backend-ui/2`
18
+ * credit memo view buttons registered under `adminUi.creditMemo.viewButtons`.
19
+ * @packageDocumentation
20
+ */
21
+ import * as v from "valibot";
22
+ import { ErrorResponse, SuccessResponse } from "@adobe/aio-commerce-lib-core/responses";
23
+ /**
24
+ * Derives the Commerce ACL resource ID for a credit memo view button.
25
+ * App and button IDs are trimmed, lowercased, and sanitized independently.
26
+ *
27
+ * @param metadataId - The application's `metadata.id` value.
28
+ * @param buttonId - The button's `adminUi.creditMemo.viewButtons[].id` value.
29
+ * @returns The credit memo view-button leaf ID, or an empty string when `metadataId` is blank.
30
+ * @example
31
+ * ```ts
32
+ * getCreditMemoViewButtonAclResourceId("refund-app", "refund-offline");
33
+ * // "Magento_CommerceBackendUix::adminuisdk_app_refund_app_creditmemo_viewbuttons_refund_offline"
34
+ * ```
35
+ */
36
+ export declare function getCreditMemoViewButtonAclResourceId(metadataId: string, buttonId: string): string;
37
+ /**
38
+ * Schema for a credit memo view-button worker request.
39
+ * `id` identifies the clicked button; `creditMemoId` identifies the credit memo being viewed.
40
+ * All three fields must be non-empty strings.
41
+ */
42
+ export declare const CreditMemoViewButtonRequestSchema: v.ObjectSchema<{
43
+ readonly creditMemoId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
44
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
45
+ readonly requestId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
46
+ }, undefined>;
47
+ /** Parsed request body for a credit memo view-button worker. */
48
+ type CreditMemoViewButtonRequest = v.InferOutput<typeof CreditMemoViewButtonRequestSchema>;
49
+ /** Empty success body returned by a credit memo view-button worker. */
50
+ type CreditMemoViewButtonSuccessBody = Record<string, never>;
51
+ /** Error body returned by a credit memo view-button worker. */
52
+ type CreditMemoViewButtonErrorBody = {
53
+ message: string;
54
+ };
55
+ /**
56
+ * Parses a credit memo view-button worker request.
57
+ * Throws `CommerceSdkValidationError` when the input is malformed.
58
+ * @example
59
+ * ```ts
60
+ * const { requestId, id, creditMemoId } = parseCreditMemoViewButtonRequest(params);
61
+ * ```
62
+ */
63
+ export declare function parseCreditMemoViewButtonRequest(input: unknown): CreditMemoViewButtonRequest;
64
+ /** Builds an HTTP 200 response with an empty body for a credit memo view-button worker. */
65
+ export declare function okCreditMemoViewButtonResponse(): SuccessResponse<CreditMemoViewButtonSuccessBody>;
66
+ /**
67
+ * Builds an error response for a credit memo view-button worker.
68
+ * @param statusCode - The HTTP status code to return.
69
+ * @param errorMessage - The message included in the response body.
70
+ * @example
71
+ * ```ts
72
+ * return creditMemoViewButtonErrorResponse(500, "Could not refund the credit memo");
73
+ * ```
74
+ */
75
+ export declare function creditMemoViewButtonErrorResponse(statusCode: number, errorMessage: string): ErrorResponse<CreditMemoViewButtonErrorBody>;
76
+ export type { CreditMemoViewButtonErrorBody, CreditMemoViewButtonRequest, CreditMemoViewButtonSuccessBody };
@@ -0,0 +1,83 @@
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-C4Is2i_h.mjs";
16
+ import { t as parseOrThrow } from "../utils-G-EDWmew.mjs";
17
+ import { t as normalizeViewButtonWorkerParams } from "../view-button-request-Cu7Qz7jY.mjs";
18
+ import { t as nonEmptyStringValueSchema } from "../schemas-Dftlsf98.mjs";
19
+ import * as v from "valibot";
20
+ import { buildErrorResponse, ok } from "@adobe/aio-commerce-lib-core/responses";
21
+
22
+ // source/credit-memo-view-buttons/acl-resource-id.ts
23
+ /**
24
+ * Derives the Commerce ACL resource ID for a credit memo view button.
25
+ * App and button IDs are trimmed, lowercased, and sanitized independently.
26
+ *
27
+ * @param metadataId - The application's `metadata.id` value.
28
+ * @param buttonId - The button's `adminUi.creditMemo.viewButtons[].id` value.
29
+ * @returns The credit memo view-button leaf ID, or an empty string when `metadataId` is blank.
30
+ * @example
31
+ * ```ts
32
+ * getCreditMemoViewButtonAclResourceId("refund-app", "refund-offline");
33
+ * // "Magento_CommerceBackendUix::adminuisdk_app_refund_app_creditmemo_viewbuttons_refund_offline"
34
+ * ```
35
+ */
36
+ function getCreditMemoViewButtonAclResourceId(metadataId, buttonId) {
37
+ const appRoot = getAclResourceId(metadataId);
38
+ if (appRoot === "") return "";
39
+ return `${appRoot}_creditmemo_viewbuttons_${sanitizeSegment(buttonId)}`;
40
+ }
41
+
42
+ // source/credit-memo-view-buttons/schema.ts
43
+ /**
44
+ * Schema for a credit memo view-button worker request.
45
+ * `id` identifies the clicked button; `creditMemoId` identifies the credit memo being viewed.
46
+ * All three fields must be non-empty strings.
47
+ */
48
+ const CreditMemoViewButtonRequestSchema = v.object({
49
+ creditMemoId: nonEmptyStringValueSchema("creditMemoId"),
50
+ id: nonEmptyStringValueSchema("id"),
51
+ requestId: nonEmptyStringValueSchema("requestId")
52
+ });
53
+
54
+ // source/credit-memo-view-buttons/presets.ts
55
+ /**
56
+ * Parses a credit memo view-button worker request.
57
+ * Throws `CommerceSdkValidationError` when the input is malformed.
58
+ * @example
59
+ * ```ts
60
+ * const { requestId, id, creditMemoId } = parseCreditMemoViewButtonRequest(params);
61
+ * ```
62
+ */
63
+ function parseCreditMemoViewButtonRequest(input) {
64
+ return parseOrThrow(CreditMemoViewButtonRequestSchema, normalizeViewButtonWorkerParams(input), "Invalid credit memo view button request");
65
+ }
66
+ /** Builds an HTTP 200 response with an empty body for a credit memo view-button worker. */
67
+ function okCreditMemoViewButtonResponse() {
68
+ return ok({ body: {} });
69
+ }
70
+ /**
71
+ * Builds an error response for a credit memo view-button worker.
72
+ * @param statusCode - The HTTP status code to return.
73
+ * @param errorMessage - The message included in the response body.
74
+ * @example
75
+ * ```ts
76
+ * return creditMemoViewButtonErrorResponse(500, "Could not refund the credit memo");
77
+ * ```
78
+ */
79
+ function creditMemoViewButtonErrorResponse(statusCode, errorMessage) {
80
+ return buildErrorResponse(statusCode, { body: { message: errorMessage } });
81
+ }
82
+
83
+ export { CreditMemoViewButtonRequestSchema, creditMemoViewButtonErrorResponse, getCreditMemoViewButtonAclResourceId, okCreditMemoViewButtonResponse, parseCreditMemoViewButtonRequest };
@@ -12,6 +12,15 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
+ /** biome-ignore-all lint/performance/noBarrelFile: This is the public API for the grid-columns entrypoint. */
16
+ /**
17
+ * Builders for the `commerce/backend-ui/2` grid column wire contract.
18
+ *
19
+ * Provides request parsing and response envelope construction for runtime
20
+ * actions registered under `adminUi.<grid>.gridColumns.runtimeAction`.
21
+ *
22
+ * @packageDocumentation
23
+ */
15
24
  import { t as AdminUiEntity } from "../acl-resource-id-CXVgxUmB.mjs";
16
25
  import * as v from "valibot";
17
26
  import { ErrorResponse, SuccessResponse } from "@adobe/aio-commerce-lib-core/responses";
@@ -0,0 +1,76 @@
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
+ /** biome-ignore-all lint/performance/noBarrelFile: This is the public API for the invoice-view-buttons entrypoint. */
16
+ /**
17
+ * Request parsing, response builders, and ACL resource IDs for `commerce/backend-ui/2`
18
+ * invoice view buttons registered under `adminUi.invoice.viewButtons`.
19
+ * @packageDocumentation
20
+ */
21
+ import * as v from "valibot";
22
+ import { ErrorResponse, SuccessResponse } from "@adobe/aio-commerce-lib-core/responses";
23
+ /**
24
+ * Derives the Commerce ACL resource ID for an invoice view button.
25
+ * App and button IDs are trimmed, lowercased, and sanitized independently.
26
+ *
27
+ * @param metadataId - The application's `metadata.id` value.
28
+ * @param buttonId - The button's `adminUi.invoice.viewButtons[].id` value.
29
+ * @returns The invoice view-button leaf ID, or an empty string when `metadataId` is blank.
30
+ * @example
31
+ * ```ts
32
+ * getInvoiceViewButtonAclResourceId("billing-app", "export-invoice");
33
+ * // "Magento_CommerceBackendUix::adminuisdk_app_billing_app_invoice_viewbuttons_export_invoice"
34
+ * ```
35
+ */
36
+ export declare function getInvoiceViewButtonAclResourceId(metadataId: string, buttonId: string): string;
37
+ /**
38
+ * Schema for an invoice view-button worker request.
39
+ * `id` identifies the clicked button; `invoiceId` identifies the invoice being viewed.
40
+ * All three fields must be non-empty strings.
41
+ */
42
+ export declare const InvoiceViewButtonRequestSchema: v.ObjectSchema<{
43
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
44
+ readonly invoiceId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
45
+ readonly requestId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
46
+ }, undefined>;
47
+ /** Parsed request body for an invoice view-button worker. */
48
+ type InvoiceViewButtonRequest = v.InferOutput<typeof InvoiceViewButtonRequestSchema>;
49
+ /** Empty success body returned by an invoice view-button worker. */
50
+ type InvoiceViewButtonSuccessBody = Record<string, never>;
51
+ /** Error body returned by an invoice view-button worker. */
52
+ type InvoiceViewButtonErrorBody = {
53
+ message: string;
54
+ };
55
+ /**
56
+ * Parses an invoice view-button worker request.
57
+ * Throws `CommerceSdkValidationError` when the input is malformed.
58
+ * @example
59
+ * ```ts
60
+ * const { requestId, id, invoiceId } = parseInvoiceViewButtonRequest(params);
61
+ * ```
62
+ */
63
+ export declare function parseInvoiceViewButtonRequest(input: unknown): InvoiceViewButtonRequest;
64
+ /** Builds an HTTP 200 response with an empty body for an invoice view-button worker. */
65
+ export declare function okInvoiceViewButtonResponse(): SuccessResponse<InvoiceViewButtonSuccessBody>;
66
+ /**
67
+ * Builds an error response for an invoice view-button worker.
68
+ * @param statusCode - The HTTP status code to return.
69
+ * @param errorMessage - The message included in the response body.
70
+ * @example
71
+ * ```ts
72
+ * return invoiceViewButtonErrorResponse(500, "Could not export the invoice");
73
+ * ```
74
+ */
75
+ export declare function invoiceViewButtonErrorResponse(statusCode: number, errorMessage: string): ErrorResponse<InvoiceViewButtonErrorBody>;
76
+ export type { InvoiceViewButtonErrorBody, InvoiceViewButtonRequest, InvoiceViewButtonSuccessBody };
@@ -0,0 +1,83 @@
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-C4Is2i_h.mjs";
16
+ import { t as parseOrThrow } from "../utils-G-EDWmew.mjs";
17
+ import { t as normalizeViewButtonWorkerParams } from "../view-button-request-Cu7Qz7jY.mjs";
18
+ import { t as nonEmptyStringValueSchema } from "../schemas-Dftlsf98.mjs";
19
+ import * as v from "valibot";
20
+ import { buildErrorResponse, ok } from "@adobe/aio-commerce-lib-core/responses";
21
+
22
+ // source/invoice-view-buttons/acl-resource-id.ts
23
+ /**
24
+ * Derives the Commerce ACL resource ID for an invoice view button.
25
+ * App and button IDs are trimmed, lowercased, and sanitized independently.
26
+ *
27
+ * @param metadataId - The application's `metadata.id` value.
28
+ * @param buttonId - The button's `adminUi.invoice.viewButtons[].id` value.
29
+ * @returns The invoice view-button leaf ID, or an empty string when `metadataId` is blank.
30
+ * @example
31
+ * ```ts
32
+ * getInvoiceViewButtonAclResourceId("billing-app", "export-invoice");
33
+ * // "Magento_CommerceBackendUix::adminuisdk_app_billing_app_invoice_viewbuttons_export_invoice"
34
+ * ```
35
+ */
36
+ function getInvoiceViewButtonAclResourceId(metadataId, buttonId) {
37
+ const appRoot = getAclResourceId(metadataId);
38
+ if (appRoot === "") return "";
39
+ return `${appRoot}_invoice_viewbuttons_${sanitizeSegment(buttonId)}`;
40
+ }
41
+
42
+ // 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
+ // source/invoice-view-buttons/presets.ts
55
+ /**
56
+ * Parses an invoice view-button worker request.
57
+ * Throws `CommerceSdkValidationError` when the input is malformed.
58
+ * @example
59
+ * ```ts
60
+ * const { requestId, id, invoiceId } = parseInvoiceViewButtonRequest(params);
61
+ * ```
62
+ */
63
+ function parseInvoiceViewButtonRequest(input) {
64
+ return parseOrThrow(InvoiceViewButtonRequestSchema, normalizeViewButtonWorkerParams(input), "Invalid invoice view button request");
65
+ }
66
+ /** Builds an HTTP 200 response with an empty body for an invoice view-button worker. */
67
+ function okInvoiceViewButtonResponse() {
68
+ return ok({ body: {} });
69
+ }
70
+ /**
71
+ * Builds an error response for an invoice view-button worker.
72
+ * @param statusCode - The HTTP status code to return.
73
+ * @param errorMessage - The message included in the response body.
74
+ * @example
75
+ * ```ts
76
+ * return invoiceViewButtonErrorResponse(500, "Could not export the invoice");
77
+ * ```
78
+ */
79
+ function invoiceViewButtonErrorResponse(statusCode, errorMessage) {
80
+ return buildErrorResponse(statusCode, { body: { message: errorMessage } });
81
+ }
82
+
83
+ export { InvoiceViewButtonRequestSchema, getInvoiceViewButtonAclResourceId, invoiceViewButtonErrorResponse, okInvoiceViewButtonResponse, parseInvoiceViewButtonRequest };
@@ -12,6 +12,16 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
+ /** biome-ignore-all lint/performance/noBarrelFile: This is the public API for the mass-actions entrypoint. */
16
+ /**
17
+ * Builders for the `commerce/backend-ui/2` mass action wire contract.
18
+ *
19
+ * - **Worker actions**: request parsing and response envelope construction for
20
+ * runtime actions registered under `adminUi.<entity>.massActions` with
21
+ * `type: "worker"`.
22
+ *
23
+ * @packageDocumentation
24
+ */
15
25
  import { n as MassActionEntity, t as AdminUiEntity } from "../acl-resource-id-CXVgxUmB.mjs";
16
26
  import * as v from "valibot";
17
27
  import { ErrorResponse, SuccessResponse } from "@adobe/aio-commerce-lib-core/responses";
@@ -12,6 +12,15 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
+ /** biome-ignore-all lint/performance/noBarrelFile: This is the public API for the menu entrypoint. */
16
+ /**
17
+ * Helpers and constants for working with the Adobe Commerce admin menu.
18
+ *
19
+ * Provides named constants for many menu IDs in the Adobe Commerce Admin,
20
+ * as well as type guards for distinguishing menu IDs at runtime.
21
+ *
22
+ * @packageDocumentation
23
+ */
15
24
  /**
16
25
  * Derives the deterministic Commerce ACL resource id for a specific menu item.
17
26
  *
@@ -12,12 +12,21 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
+ /** biome-ignore-all lint/performance/noBarrelFile: This is the public API for the order-view-buttons entrypoint. */
16
+ /**
17
+ * Builders for the `commerce/backend-ui/2` order view button wire contract.
18
+ *
19
+ * Provides request parsing and response envelope construction for runtime
20
+ * actions registered under `adminUi.order.viewButtons[].runtimeAction`.
21
+ *
22
+ * @packageDocumentation
23
+ */
15
24
  import * as v from "valibot";
16
25
  import { ErrorResponse, SuccessResponse } from "@adobe/aio-commerce-lib-core/responses";
17
26
  /**
18
27
  * Derives the deterministic Commerce ACL resource id for an order view button.
19
28
  *
20
- * View buttons exist only on the order entity, so no entity discriminator is needed.
29
+ * This helper is scoped to the order entity, so no entity discriminator is needed.
21
30
  * The id is assembled as: `getAclResourceId(metadataId)` + `"_order_viewbuttons_"` +
22
31
  * sanitized `buttonId`. The `buttonId` is sanitized (trimmed, lowercased, non-`[a-z0-9_]` → `_`).
23
32
  * `"Magento_CommerceBackendUix::adminuisdk_app_"` in the example is the fixed constant prefix