@adobe/aio-commerce-lib-app 2.2.0 → 2.3.0-beta-20261202103723
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 +32 -1
- package/dist/cjs/actions/app-config/index.cjs +8 -8
- package/dist/cjs/actions/app-config/index.d.cts +2 -2
- package/dist/cjs/actions/association/index.cjs +4 -4
- package/dist/cjs/actions/config/index.cjs +19 -8
- package/dist/cjs/actions/config/index.d.cts +1 -1
- package/dist/cjs/actions/installation/index.cjs +39 -15
- package/dist/cjs/actions/installation/index.d.cts +3 -3
- package/dist/cjs/actions/scope-tree/index.cjs +6 -6
- package/dist/cjs/{app-B3bAEor-.d.cts → app-CLDvfJXp.d.cts} +634 -44
- package/dist/cjs/commands/index.cjs +174 -33
- package/dist/cjs/config/index.browser.d.cts +1 -1
- package/dist/cjs/config/index.node.cjs +3 -3
- package/dist/cjs/config/index.node.d.cts +50 -14
- package/dist/cjs/{define-eBMdGAq6.d.cts → define-BGpnO45V.d.cts} +1 -1
- package/dist/cjs/{environment-CW6M76gS.cjs → environment-CaV1hi2-.cjs} +1 -1
- package/dist/cjs/{index-BEeludy0.d.cts → index-p0duTbHE.d.cts} +2 -2
- package/dist/cjs/index.cjs +3 -3
- package/dist/cjs/index.d.cts +1 -1
- package/dist/cjs/{index.node-9bfp79rs.cjs → index.node-ECg3DGc8.cjs} +7 -6
- package/dist/cjs/{logging-Emi7P923.cjs → logging-r-r2bUWO.cjs} +1 -1
- package/dist/cjs/management/index.cjs +1 -1
- package/dist/cjs/management/index.d.cts +1 -1
- package/dist/cjs/{management-5Et1mEUp.cjs → management-CFQ4hjs6.cjs} +123 -108
- package/dist/cjs/{openapi-DghfuM8S.cjs → openapi-BaKoO7GY.cjs} +177 -26
- package/dist/cjs/{rolldown-runtime-CoOt0iuZ.cjs → rolldown-runtime-BKfnhsn2.cjs} +4 -4
- package/dist/cjs/{schemas-B6ITl1bG.cjs → schemas-B-jCi6Oz.cjs} +1 -1
- package/dist/cjs/{utils-CoR_PBHz.cjs → utils-CuzJBLgo.cjs} +2 -2
- package/dist/cjs/{utils-DSS0XlXq.cjs → utils-bwFwJcPW.cjs} +1 -1
- package/dist/cjs/{validate-BC3rnRLc.cjs → validate-DKMq3KNV.cjs} +13 -5
- package/dist/cjs/{version-5MonNzl5.cjs → version-BYcHBNng.cjs} +3 -3
- package/dist/{es/webhooks-DgaLfP36.d.mts → cjs/webhooks-BCYX3JqY.d.cts} +382 -43
- package/dist/cjs/{webhooks-ZPh2gVb3.cjs → webhooks-Bp1Roq8a.cjs} +70 -23
- package/dist/es/actions/app-config/index.d.mts +2 -2
- package/dist/es/actions/app-config/index.mjs +6 -6
- package/dist/es/actions/association/index.mjs +3 -3
- package/dist/es/actions/config/index.d.mts +2 -2
- package/dist/es/actions/config/index.mjs +19 -8
- package/dist/es/actions/installation/index.d.mts +4 -4
- package/dist/es/actions/installation/index.mjs +38 -14
- package/dist/es/actions/scope-tree/index.mjs +5 -5
- package/dist/es/{app-B3bAEor-.d.mts → app-CLDvfJXp.d.mts} +634 -44
- package/dist/es/commands/index.mjs +170 -29
- package/dist/es/config/index.browser.d.mts +1 -1
- package/dist/es/config/index.node.d.mts +51 -15
- package/dist/es/config/index.node.mjs +3 -3
- package/dist/es/{define-BdXyLAwb.d.mts → define-C-0hOMO3.d.mts} +1 -1
- package/dist/es/{environment-DUhU0_9z.mjs → environment-B1JJFHZw.mjs} +1 -1
- package/dist/es/{index-DE2KVXfH.d.mts → index-DYHaYwvJ.d.mts} +4 -4
- package/dist/es/{index-DUJtT78x.d.mts → index-U7CXicoW.d.mts} +1 -1
- package/dist/es/index.d.mts +2 -2
- package/dist/es/index.mjs +3 -3
- package/dist/es/{index.node-CURztkP5.mjs → index.node-ChWOTWnF.mjs} +5 -4
- package/dist/es/management/index.d.mts +1 -1
- package/dist/es/management/index.mjs +1 -1
- package/dist/es/{management-BAQ64OyR.mjs → management-CNMT6azj.mjs} +128 -113
- package/dist/es/{openapi-BvPVTUMt.mjs → openapi-ChihLuvm.mjs} +177 -26
- package/dist/es/{utils-DB8HaSj0.mjs → utils-Bg_LIAGV.mjs} +2 -2
- package/dist/es/{validate-xS9Dc-4m.mjs → validate-DeAMC-HS.mjs} +7 -5
- package/dist/es/{version-BWgrh_QM.mjs → version-Cj7a9rey.mjs} +1 -1
- package/dist/es/{webhooks-HBe_DEKA.mjs → webhooks-CyiUfRNG.mjs} +67 -20
- package/dist/{cjs/webhooks-DNLuuv9_.d.cts → es/webhooks-DyMAQMnm.d.mts} +382 -43
- package/package.json +14 -15
|
@@ -33,9 +33,23 @@ const SANDBOX_PERMISSION_VALUES = [
|
|
|
33
33
|
"allow-modals",
|
|
34
34
|
"allow-popups"
|
|
35
35
|
];
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
const ALLOW_PERMISSION_VALUES = ["autoplay", "microphone"];
|
|
37
|
+
/**
|
|
38
|
+
* Builds a schema for a non-empty, duplicate-free list of iframe permissions.
|
|
39
|
+
* @param field - The config field name, used in error messages.
|
|
40
|
+
* @param kind - The permission kind, used in error messages (e.g. `sandbox`).
|
|
41
|
+
* @param values - The accepted permission values.
|
|
42
|
+
*/
|
|
43
|
+
function permissionListSchema(field, kind, values) {
|
|
44
|
+
return v.pipe(v.array(v.picklist(values, `Invalid ${kind} permission. Accepted values are: ${values.join(", ")}`)), v.minLength(1, `${field} must contain at least one permission when it's defined`), v.check((permissions) => new Set(permissions).size === permissions.length, `Duplicate permissions are not allowed in ${field}`));
|
|
45
|
+
}
|
|
46
|
+
const SandboxPermissionsSchema = permissionListSchema("sandboxPermissions", "sandbox", SANDBOX_PERMISSION_VALUES);
|
|
47
|
+
const AllowPermissionsSchema = permissionListSchema("allow", "iframe allow", ALLOW_PERMISSION_VALUES);
|
|
48
|
+
/** Optional iframe permission fields shared by every iframe-based entry. */
|
|
49
|
+
const iframePermissionEntries = {
|
|
50
|
+
allow: v.optional(AllowPermissionsSchema),
|
|
51
|
+
sandboxPermissions: v.optional(SandboxPermissionsSchema)
|
|
52
|
+
};
|
|
39
53
|
const NotificationsSchema = v.object({
|
|
40
54
|
error: v.optional(nonEmptyStringValueSchema("error notification")),
|
|
41
55
|
success: v.optional(nonEmptyStringValueSchema("success notification"))
|
|
@@ -70,6 +84,28 @@ const GridColumnsSchema = v.object({
|
|
|
70
84
|
label: nonEmptyStringValueSchema("grid columns label"),
|
|
71
85
|
runtimeAction: nonEmptyStringValueSchema("runtime action")
|
|
72
86
|
});
|
|
87
|
+
const INVALID_ATTRIBUTE_CODE_PATTERN = /[^A-Za-z0-9_]/u;
|
|
88
|
+
const CustomAttributeFilterSchema = v.variant("type", [v.strictObject({ type: v.literal("boolean") }), v.strictObject({
|
|
89
|
+
conditions: v.pipe(v.array(v.picklist([
|
|
90
|
+
"eq",
|
|
91
|
+
"neq",
|
|
92
|
+
"contains"
|
|
93
|
+
])), v.minLength(1, "Text filters require at least one condition")),
|
|
94
|
+
type: v.literal("text")
|
|
95
|
+
})]);
|
|
96
|
+
const CustomAttributeGridColumnSchema = v.strictObject({
|
|
97
|
+
aclProtected: v.optional(v.boolean()),
|
|
98
|
+
align: ColumnAlignSchema,
|
|
99
|
+
attribute_code: v.pipe(nonEmptyStringValueSchema("custom attribute code"), v.maxLength(255, "Custom attribute codes must not exceed 255 characters"), v.check((code) => !INVALID_ATTRIBUTE_CODE_PATTERN.test(code), "Custom attribute codes may contain only ASCII letters, digits, and \"_\"")),
|
|
100
|
+
filter: v.optional(CustomAttributeFilterSchema),
|
|
101
|
+
id: v.pipe(nonEmptyStringValueSchema("column ID"), v.check((id) => id.trim().length > 0, "Column IDs must not be blank")),
|
|
102
|
+
label: v.pipe(nonEmptyStringValueSchema("column label"), v.check((label) => label.trim().length > 0, "Column labels must not be blank"))
|
|
103
|
+
});
|
|
104
|
+
const CustomAttributeGridColumnsSchema = v.strictObject({
|
|
105
|
+
columns: v.pipe(v.array(CustomAttributeGridColumnSchema), v.minLength(1, "At least one custom-attribute grid column is required"), v.check((items) => hasUniqueSanitizedIds(items), "Grid column ids must be unique after Commerce id sanitization.")),
|
|
106
|
+
description: v.optional(nonEmptyStringValueSchema("custom-attribute grid columns description")),
|
|
107
|
+
label: v.optional(nonEmptyStringValueSchema("custom-attribute grid columns label"))
|
|
108
|
+
});
|
|
73
109
|
/** Fields shared by both mass-action variants. `description` is flat — no `installation` nesting. */
|
|
74
110
|
const massActionCommonEntries = {
|
|
75
111
|
aclProtected: v.optional(v.boolean()),
|
|
@@ -84,8 +120,8 @@ const massActionCommonEntries = {
|
|
|
84
120
|
/** `type: "view"` mass action — renders an iframe at `path`. */
|
|
85
121
|
const ViewMassActionSchema = v.strictObject({
|
|
86
122
|
...massActionCommonEntries,
|
|
123
|
+
...iframePermissionEntries,
|
|
87
124
|
path: nonEmptyStringValueSchema("mass action path"),
|
|
88
|
-
sandboxPermissions: v.optional(SandboxPermissionsSchema),
|
|
89
125
|
type: v.literal("view")
|
|
90
126
|
});
|
|
91
127
|
/** `type: "worker"` mass action — invokes a workerProcess runtime action. */
|
|
@@ -106,6 +142,7 @@ const ViewButtonLevelSchema = v.picklist([
|
|
|
106
142
|
1
|
|
107
143
|
]);
|
|
108
144
|
const ViewButtonViewSchema = v.strictObject({
|
|
145
|
+
...iframePermissionEntries,
|
|
109
146
|
aclProtected: v.optional(v.boolean()),
|
|
110
147
|
confirm: v.optional(ConfirmSchema),
|
|
111
148
|
description: v.optional(nonEmptyStringValueSchema("view button description")),
|
|
@@ -114,7 +151,6 @@ const ViewButtonViewSchema = v.strictObject({
|
|
|
114
151
|
level: v.optional(ViewButtonLevelSchema),
|
|
115
152
|
notifications: v.optional(NotificationsSchema),
|
|
116
153
|
path: nonEmptyStringValueSchema("view button path"),
|
|
117
|
-
sandboxPermissions: v.optional(SandboxPermissionsSchema),
|
|
118
154
|
sortOrder: v.optional(positiveNumberValueSchema("sortOrder")),
|
|
119
155
|
type: v.literal("view")
|
|
120
156
|
});
|
|
@@ -153,14 +189,16 @@ const AdminUiInvoiceSchema = v.object({
|
|
|
153
189
|
gridColumns: v.optional(GridColumnsSchema),
|
|
154
190
|
viewButtons: v.optional(v.pipe(v.array(InvoiceViewButtonSchema), v.check((items) => hasUniqueSanitizedIds(items), "Invoice view button ids must be unique after Commerce id sanitization.")))
|
|
155
191
|
});
|
|
156
|
-
const AdminUiCreditMemoSchema = v.object({
|
|
192
|
+
const AdminUiCreditMemoSchema = v.pipe(v.object({
|
|
193
|
+
customAttributeGridColumns: v.optional(CustomAttributeGridColumnsSchema),
|
|
157
194
|
gridColumns: v.optional(GridColumnsSchema),
|
|
158
195
|
viewButtons: v.optional(v.pipe(v.array(CreditMemoViewButtonSchema), v.check((items) => hasUniqueSanitizedIds(items), "Credit memo view button ids must be unique after Commerce id sanitization.")))
|
|
159
|
-
});
|
|
196
|
+
}), v.forward(v.check(({ customAttributeGridColumns, gridColumns }) => !customAttributeGridColumns || hasUniqueSanitizedIds([...gridColumns?.columns ?? [], ...customAttributeGridColumns.columns]), "Runtime and custom-attribute grid column ids must be unique after Commerce id sanitization."), ["customAttributeGridColumns", "columns"]));
|
|
160
197
|
const AdminUiRmaSchema = v.object({ viewButtons: v.optional(v.pipe(v.array(RmaViewButtonSchema), v.check((items) => hasUniqueSanitizedIds(items), "Return view button ids must be unique after Commerce id sanitization."))) });
|
|
161
198
|
const AdminUiGridOnlyEntitySchema = v.object({ gridColumns: v.optional(GridColumnsSchema) });
|
|
162
199
|
const MenuIdSchema = v.pipe(nonEmptyStringValueSchema("menu ID"), v.regex(/^[A-Za-z0-9_/:]+$/u, "Menu ID may contain only letters, digits, \"/\", \":\", and \"_\""));
|
|
163
200
|
const MenuSchema = v.object({
|
|
201
|
+
...iframePermissionEntries,
|
|
164
202
|
/**
|
|
165
203
|
* When `true`, Commerce auto-generates a per-app ACL resource id from `metadata.id`
|
|
166
204
|
* and injects it into the Adobe Commerce User Roles permission tree, allowing role-based
|
|
@@ -171,13 +209,12 @@ const MenuSchema = v.object({
|
|
|
171
209
|
id: MenuIdSchema,
|
|
172
210
|
label: nonEmptyStringValueSchema("menu label"),
|
|
173
211
|
pageTitle: v.optional(nonEmptyStringValueSchema("menu page title")),
|
|
174
|
-
parentMenu: v.optional(v.picklist(COMMERCE_MENUS, "parentMenu must be a known Commerce Admin menu ID"))
|
|
175
|
-
sandboxPermissions: v.optional(SandboxPermissionsSchema)
|
|
212
|
+
parentMenu: v.optional(v.picklist(COMMERCE_MENUS, "parentMenu must be a known Commerce Admin menu ID"))
|
|
176
213
|
});
|
|
177
214
|
const NATIVE_UI_REPLACED_PAGE_TARGETS = ["order.create", "return.create"];
|
|
178
215
|
const NativeUiReplacedPageSchema = v.strictObject({
|
|
216
|
+
...iframePermissionEntries,
|
|
179
217
|
path: nonEmptyStringValueSchema("replaced page path"),
|
|
180
|
-
sandboxPermissions: v.optional(SandboxPermissionsSchema),
|
|
181
218
|
target: v.picklist(NATIVE_UI_REPLACED_PAGE_TARGETS, `Invalid native UI replaced page target. Accepted values are: ${NATIVE_UI_REPLACED_PAGE_TARGETS.join(", ")}`),
|
|
182
219
|
title: nonEmptyStringValueSchema("replaced page title")
|
|
183
220
|
});
|
|
@@ -217,8 +254,8 @@ const AdminUiAclSchema = v.pipe(v.array(AclResourceEntrySchema), v.minLength(1,
|
|
|
217
254
|
return new Set(ids).size === ids.length;
|
|
218
255
|
}, "Custom ACL resource ids must stay unique after Commerce derivation: a top-level resource id must not equal a group's \"<group>_<child>\" combination."));
|
|
219
256
|
/**
|
|
220
|
-
* Schema for
|
|
221
|
-
*
|
|
257
|
+
* Schema for Admin UI components, including Credit Memo custom-attribute columns.
|
|
258
|
+
* Custom-attribute columns and custom ACL resources require no backend-ui/2 workers or views.
|
|
222
259
|
*/
|
|
223
260
|
const AdminUiSchema = v.object({
|
|
224
261
|
acl: v.optional(AdminUiAclSchema),
|
|
@@ -264,8 +301,8 @@ const ADMIN_UI_VIEW_BUTTON_ENTITIES = [
|
|
|
264
301
|
* `commerce/backend-ui/2` extension point — a menu, grid columns, mass actions,
|
|
265
302
|
* view buttons, or native UI replaced pages. Custom ACL resources are
|
|
266
303
|
* deliberately excluded: they reach Commerce through the `extensibility/1`
|
|
267
|
-
* app-config payload, not backend-ui/2
|
|
268
|
-
* backend-ui/2 registration.
|
|
304
|
+
* app-config payload, not backend-ui/2. Custom-attribute grid columns also need
|
|
305
|
+
* no backend-ui/2 registration because Commerce reads their values locally.
|
|
269
306
|
*/
|
|
270
307
|
function hasBackendUiV2Components(config) {
|
|
271
308
|
const { adminUi } = config;
|
|
@@ -274,12 +311,22 @@ function hasBackendUiV2Components(config) {
|
|
|
274
311
|
}
|
|
275
312
|
/**
|
|
276
313
|
* Check whether the config declares at least one Admin UI component (menu, grid
|
|
277
|
-
* columns, mass actions, view buttons, native UI
|
|
278
|
-
* resources). A component-less `adminUi` block
|
|
279
|
-
* registers nothing.
|
|
314
|
+
* columns, custom-attribute columns, mass actions, view buttons, native UI
|
|
315
|
+
* replaced pages, or custom ACL resources). A component-less `adminUi` block
|
|
316
|
+
* is treated as absent — it registers nothing.
|
|
280
317
|
*/
|
|
281
318
|
function hasAdminUi(config) {
|
|
282
|
-
return hasBackendUiV2Components(config) || Boolean(config.adminUi?.acl?.length);
|
|
319
|
+
return hasBackendUiV2Components(config) || Boolean(config.adminUi?.acl?.length || config.adminUi?.creditMemo?.customAttributeGridColumns);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// source/config/schema/runtime-action.ts
|
|
323
|
+
const RUNTIME_ACTION_REFERENCE_REGEX = /^\w(?:[\w@ .-]*[\w@.-])?\/\w(?:[\w@ .-]*[\w@.-])?$/u;
|
|
324
|
+
/**
|
|
325
|
+
* Schema for a runtime action reference in the format `<package>/<action>`.
|
|
326
|
+
* @param name - The name of the field, used in error messages.
|
|
327
|
+
*/
|
|
328
|
+
function runtimeActionReferenceSchema(name) {
|
|
329
|
+
return v.pipe(nonEmptyStringValueSchema(name), v.regex(RUNTIME_ACTION_REFERENCE_REGEX, "Runtime action must be in the format \"<package>/<action>\" (e.g., \"my-package/my-action\")"));
|
|
283
330
|
}
|
|
284
331
|
|
|
285
332
|
// source/config/schema/eventing.ts
|
|
@@ -361,7 +408,7 @@ const BaseEventSchema = v.object({
|
|
|
361
408
|
description: v.pipe(nonEmptyStringValueSchema("event description"), ioEventsTextSchema("Event description"), v.maxLength(MAX_DESCRIPTION_LENGTH$1, `The event description must not be longer than ${MAX_DESCRIPTION_LENGTH$1} characters`)),
|
|
362
409
|
env: v.optional(CommerceEnvArraySchema),
|
|
363
410
|
label: v.pipe(nonEmptyStringValueSchema("event label"), ioEventsTextSchema("Event label"), v.maxLength(MAX_LABEL_LENGTH, `The event label must not be longer than ${MAX_LABEL_LENGTH} characters`)),
|
|
364
|
-
runtimeActions: v.array(
|
|
411
|
+
runtimeActions: v.array(runtimeActionReferenceSchema("runtime action"), "Expected an array of runtime actions in the format <package>/<action>")
|
|
365
412
|
});
|
|
366
413
|
/**
|
|
367
414
|
* Schema for rule operator values.
|
|
@@ -560,7 +607,7 @@ const WebhookEntryBaseSchema = v.object({
|
|
|
560
607
|
const WebhookEntryWithRuntimeActionSchema = v.object({
|
|
561
608
|
...WebhookEntryBaseSchema.entries,
|
|
562
609
|
requireAdobeAuth: v.optional(booleanValueSchema("requireAdobeAuth")),
|
|
563
|
-
runtimeAction:
|
|
610
|
+
runtimeAction: runtimeActionReferenceSchema("runtimeAction"),
|
|
564
611
|
webhook: WebhookDefinitionBaseSchema
|
|
565
612
|
});
|
|
566
613
|
/** Schema for a webhook entry that provides an explicit URL. */
|