@adobe/aio-commerce-lib-app 2.1.0 → 2.2.0-alpha-20261110171457
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 +21 -0
- package/dist/cjs/actions/app-config/index.cjs +5 -5
- package/dist/cjs/actions/app-config/index.d.cts +2 -2
- package/dist/cjs/actions/association/index.cjs +2 -2
- package/dist/cjs/actions/config/index.cjs +2 -2
- package/dist/cjs/actions/config/index.d.cts +2 -2
- package/dist/cjs/actions/installation/index.cjs +61 -21
- package/dist/cjs/actions/installation/index.d.cts +4 -3
- package/dist/cjs/actions/scope-tree/index.cjs +2 -2
- package/dist/cjs/{app-Ch19CR6g.d.cts → app-DREvtzyX.d.cts} +330 -4
- package/dist/cjs/commands/index.cjs +27 -12
- package/dist/cjs/config/index.browser.d.cts +2 -1
- package/dist/cjs/config/index.node.cjs +3 -3
- package/dist/cjs/config/index.node.d.cts +96 -8
- package/dist/{es/define-C95h_wa0.d.mts → cjs/define-DW6Vzfku.d.cts} +1 -1
- package/dist/cjs/{index-D-Qn-irL.d.cts → index-B9MUZY-U.d.cts} +316 -316
- package/dist/cjs/{index-DWEigxhy.d.cts → index-vAue-u_y.d.cts} +1 -4
- package/dist/cjs/index.d.cts +8 -8
- package/dist/cjs/{index.node-CxdwPrOg.cjs → index.node-CcH8PCzC.cjs} +1 -1
- package/dist/cjs/management/index.cjs +1 -1
- package/dist/cjs/management/index.d.cts +6 -1
- package/dist/cjs/{management-C_JQpgVB.cjs → management-DeRZYcjS.cjs} +17 -5
- package/dist/cjs/{openapi-DFoMdZzI.cjs → openapi-CFqaMxUV.cjs} +426 -45
- package/dist/cjs/types-DslZGym8.d.cts +23 -0
- package/dist/cjs/{validate-B0rOILvG.cjs → validate-DAw7Pxp3.cjs} +1 -1
- package/dist/cjs/{router-DpB8wpR2.cjs → version-BACmFGD2.cjs} +77 -19
- package/dist/{es/webhooks-C9vMZZDZ.d.mts → cjs/webhooks-BMSr1l7c.d.cts} +268 -12
- package/dist/cjs/{webhooks-TvDm57xt.cjs → webhooks-EVlO8rxi.cjs} +53 -12
- package/dist/es/actions/app-config/index.d.mts +2 -2
- package/dist/es/actions/app-config/index.mjs +5 -5
- package/dist/es/actions/association/index.mjs +2 -2
- package/dist/es/actions/config/index.d.mts +1 -1
- package/dist/es/actions/config/index.mjs +2 -2
- package/dist/es/actions/installation/index.d.mts +4 -3
- package/dist/es/actions/installation/index.mjs +62 -22
- package/dist/es/actions/scope-tree/index.mjs +2 -2
- package/dist/es/{app-Ch19CR6g.d.mts → app-DREvtzyX.d.mts} +330 -4
- package/dist/es/commands/index.mjs +27 -12
- package/dist/es/config/index.browser.d.mts +2 -1
- package/dist/es/config/index.node.d.mts +95 -6
- package/dist/es/config/index.node.mjs +3 -3
- package/dist/{cjs/define-C12IwNNN.d.cts → es/define-B6cjhz1J.d.mts} +1 -1
- package/dist/es/{index-CgsSXApi.d.mts → index-DUJtT78x.d.mts} +2 -2
- package/dist/es/{index-VgCNSlLP.d.mts → index-zgc3l2nj.d.mts} +2 -2
- package/dist/es/index.d.mts +8 -8
- package/dist/es/{index.node-C8EXBW94.mjs → index.node-ClvSfs5w.mjs} +1 -1
- package/dist/es/management/index.d.mts +6 -1
- package/dist/es/management/index.mjs +1 -1
- package/dist/es/{management-DKDR7-fX.mjs → management-CG_4z2Ck.mjs} +17 -5
- package/dist/es/{openapi-E_1RFhAr.mjs → openapi-BUIws500.mjs} +426 -45
- package/dist/es/types-DslZGym8.d.mts +23 -0
- package/dist/es/{validate-CiJIjyOr.mjs → validate-BszbuhiE.mjs} +1 -1
- package/dist/es/{router-C23GIyGQ.mjs → version-CabzC7R9.mjs} +71 -20
- package/dist/{cjs/webhooks-Buu1d7AB.d.cts → es/webhooks-BLgKadnn.d.mts} +268 -12
- package/dist/es/{webhooks-CfrYeMy_.mjs → webhooks-DRPXVMMo.mjs} +48 -13
- package/package.json +4 -4
|
@@ -107,7 +107,7 @@ const ViewButtonLevelSchema = valibot.picklist([
|
|
|
107
107
|
0,
|
|
108
108
|
1
|
|
109
109
|
]);
|
|
110
|
-
const
|
|
110
|
+
const ViewButtonViewSchema = valibot.strictObject({
|
|
111
111
|
aclProtected: valibot.optional(valibot.boolean()),
|
|
112
112
|
confirm: valibot.optional(ConfirmSchema),
|
|
113
113
|
description: valibot.optional(require_schemas.nonEmptyStringValueSchema("view button description")),
|
|
@@ -119,7 +119,8 @@ const OrderViewButtonSchema = valibot.variant("type", [valibot.strictObject({
|
|
|
119
119
|
sandboxPermissions: valibot.optional(SandboxPermissionsSchema),
|
|
120
120
|
sortOrder: valibot.optional(require_schemas.positiveNumberValueSchema("sortOrder")),
|
|
121
121
|
type: valibot.literal("view")
|
|
122
|
-
})
|
|
122
|
+
});
|
|
123
|
+
const ViewButtonWorkerSchema = valibot.strictObject({
|
|
123
124
|
aclProtected: valibot.optional(valibot.boolean()),
|
|
124
125
|
confirm: valibot.optional(ConfirmSchema),
|
|
125
126
|
description: valibot.optional(require_schemas.nonEmptyStringValueSchema("view button description")),
|
|
@@ -131,7 +132,16 @@ const OrderViewButtonSchema = valibot.variant("type", [valibot.strictObject({
|
|
|
131
132
|
sortOrder: valibot.optional(require_schemas.positiveNumberValueSchema("sortOrder")),
|
|
132
133
|
timeout: valibot.optional(require_schemas.positiveNumberValueSchema("timeout")),
|
|
133
134
|
type: valibot.literal("worker")
|
|
134
|
-
})
|
|
135
|
+
});
|
|
136
|
+
const OrderViewButtonSchema = valibot.variant("type", [ViewButtonViewSchema, ViewButtonWorkerSchema]);
|
|
137
|
+
const InvoiceViewButtonSchema = valibot.variant("type", [valibot.strictObject({
|
|
138
|
+
...ViewButtonViewSchema.entries,
|
|
139
|
+
title: valibot.optional(require_schemas.nonEmptyStringValueSchema("view button page title"))
|
|
140
|
+
}), ViewButtonWorkerSchema]);
|
|
141
|
+
const CreditMemoViewButtonSchema = valibot.variant("type", [valibot.strictObject({
|
|
142
|
+
...ViewButtonViewSchema.entries,
|
|
143
|
+
title: valibot.optional(require_schemas.nonEmptyStringValueSchema("view button page title"))
|
|
144
|
+
}), ViewButtonWorkerSchema]);
|
|
135
145
|
const MassActionsSchema = valibot.pipe(valibot.array(MassActionSchema), valibot.check((items) => hasUniqueSanitizedIds(items), "Mass action ids must be unique after Commerce id sanitization."));
|
|
136
146
|
const AdminUiOrderSchema = valibot.object({
|
|
137
147
|
gridColumns: valibot.optional(GridColumnsSchema),
|
|
@@ -142,6 +152,14 @@ const AdminUiGridAndMassActionEntitySchema = valibot.object({
|
|
|
142
152
|
gridColumns: valibot.optional(GridColumnsSchema),
|
|
143
153
|
massActions: valibot.optional(MassActionsSchema)
|
|
144
154
|
});
|
|
155
|
+
const AdminUiInvoiceSchema = valibot.object({
|
|
156
|
+
gridColumns: valibot.optional(GridColumnsSchema),
|
|
157
|
+
viewButtons: valibot.optional(valibot.pipe(valibot.array(InvoiceViewButtonSchema), valibot.check((items) => hasUniqueSanitizedIds(items), "Invoice view button ids must be unique after Commerce id sanitization.")))
|
|
158
|
+
});
|
|
159
|
+
const AdminUiCreditMemoSchema = valibot.object({
|
|
160
|
+
gridColumns: valibot.optional(GridColumnsSchema),
|
|
161
|
+
viewButtons: valibot.optional(valibot.pipe(valibot.array(CreditMemoViewButtonSchema), valibot.check((items) => hasUniqueSanitizedIds(items), "Credit memo view button ids must be unique after Commerce id sanitization.")))
|
|
162
|
+
});
|
|
145
163
|
const AdminUiGridOnlyEntitySchema = valibot.object({ gridColumns: valibot.optional(GridColumnsSchema) });
|
|
146
164
|
const MenuIdSchema = valibot.pipe(require_schemas.nonEmptyStringValueSchema("menu ID"), valibot.regex(/^[A-Za-z0-9_/:]+$/u, "Menu ID may contain only letters, digits, \"/\", \":\", and \"_\""));
|
|
147
165
|
const MenuSchema = valibot.object({
|
|
@@ -158,6 +176,14 @@ const MenuSchema = valibot.object({
|
|
|
158
176
|
parentMenu: valibot.optional(valibot.picklist(_adobe_aio_commerce_lib_admin_ui_menu.COMMERCE_MENUS, "parentMenu must be a known Commerce Admin menu ID")),
|
|
159
177
|
sandboxPermissions: valibot.optional(SandboxPermissionsSchema)
|
|
160
178
|
});
|
|
179
|
+
const NATIVE_UI_REPLACED_PAGE_TARGETS = ["order.create", "return.create"];
|
|
180
|
+
const NativeUiReplacedPageSchema = valibot.strictObject({
|
|
181
|
+
path: require_schemas.nonEmptyStringValueSchema("replaced page path"),
|
|
182
|
+
sandboxPermissions: valibot.optional(SandboxPermissionsSchema),
|
|
183
|
+
target: valibot.picklist(NATIVE_UI_REPLACED_PAGE_TARGETS, `Invalid native UI replaced page target. Accepted values are: ${NATIVE_UI_REPLACED_PAGE_TARGETS.join(", ")}`),
|
|
184
|
+
title: require_schemas.nonEmptyStringValueSchema("replaced page title")
|
|
185
|
+
});
|
|
186
|
+
const NativeUiSchema = valibot.object({ replacedPages: valibot.pipe(valibot.array(NativeUiReplacedPageSchema), valibot.check((pages) => new Set(pages.map((page) => page.target)).size === pages.length, "Native UI replaced page targets must be unique.")) });
|
|
161
187
|
const AclResourceIdSchema = valibot.pipe(require_schemas.nonEmptyStringValueSchema("acl resource ID"), valibot.regex(/^[a-z0-9_]+$/u, "ACL resource ID may contain only lowercase letters, digits, and \"_\""));
|
|
162
188
|
const ACL_LABEL_MIN_LENGTH = 3;
|
|
163
189
|
const ACL_LABEL_MAX_LENGTH = 50;
|
|
@@ -194,14 +220,15 @@ const AdminUiAclSchema = valibot.pipe(valibot.array(AclResourceEntrySchema), val
|
|
|
194
220
|
}, "Custom ACL resource ids must stay unique after Commerce derivation: a top-level resource id must not equal a group's \"<group>_<child>\" combination."));
|
|
195
221
|
/**
|
|
196
222
|
* Schema for the `adminUi` config section.
|
|
197
|
-
* Supports grid column extensions, mass actions, order view buttons, menu, and custom ACL resources on `commerce/backend-ui/2`.
|
|
223
|
+
* Supports grid column extensions, mass actions, order, invoice, and credit memo view buttons, menu, native UI replaced pages, and custom ACL resources on `commerce/backend-ui/2`.
|
|
198
224
|
*/
|
|
199
225
|
const AdminUiSchema = valibot.object({
|
|
200
226
|
acl: valibot.optional(AdminUiAclSchema),
|
|
201
|
-
creditMemo: valibot.optional(
|
|
227
|
+
creditMemo: valibot.optional(AdminUiCreditMemoSchema),
|
|
202
228
|
customer: valibot.optional(AdminUiGridAndMassActionEntitySchema),
|
|
203
|
-
invoice: valibot.optional(
|
|
229
|
+
invoice: valibot.optional(AdminUiInvoiceSchema),
|
|
204
230
|
menu: valibot.optional(MenuSchema),
|
|
231
|
+
nativeUi: valibot.optional(NativeUiSchema),
|
|
205
232
|
newsletter: valibot.optional(AdminUiGridOnlyEntitySchema),
|
|
206
233
|
order: valibot.optional(AdminUiOrderSchema),
|
|
207
234
|
product: valibot.optional(AdminUiGridAndMassActionEntitySchema),
|
|
@@ -226,22 +253,30 @@ const ADMIN_UI_MASS_ACTION_ENTITIES = [
|
|
|
226
253
|
"product",
|
|
227
254
|
"customer"
|
|
228
255
|
];
|
|
256
|
+
/** Entities that support view buttons, in a stable order. */
|
|
257
|
+
const ADMIN_UI_VIEW_BUTTON_ENTITIES = [
|
|
258
|
+
"order",
|
|
259
|
+
"invoice",
|
|
260
|
+
"creditMemo"
|
|
261
|
+
];
|
|
229
262
|
/**
|
|
230
263
|
* Check whether the config declares an Admin UI component that requires the
|
|
231
264
|
* `commerce/backend-ui/2` extension point — a menu, grid columns, mass actions,
|
|
232
|
-
* or
|
|
233
|
-
* Commerce through the `extensibility/1`
|
|
234
|
-
* so an acl-only config needs no
|
|
265
|
+
* view buttons, or native UI replaced pages. Custom ACL resources are
|
|
266
|
+
* deliberately excluded: they reach Commerce through the `extensibility/1`
|
|
267
|
+
* app-config payload, not backend-ui/2, so an acl-only config needs no
|
|
268
|
+
* backend-ui/2 registration.
|
|
235
269
|
*/
|
|
236
270
|
function hasBackendUiV2Components(config) {
|
|
237
271
|
const { adminUi } = config;
|
|
238
272
|
if (!adminUi) return false;
|
|
239
|
-
return Boolean(adminUi.menu || adminUi.order?.gridColumns || adminUi.order?.massActions?.length || adminUi.order?.viewButtons?.length || adminUi.product?.gridColumns || adminUi.product?.massActions?.length || adminUi.customer?.gridColumns || adminUi.customer?.massActions?.length || adminUi.invoice?.gridColumns || adminUi.creditMemo?.gridColumns || adminUi.shipment?.gridColumns || adminUi.newsletter?.gridColumns);
|
|
273
|
+
return Boolean(adminUi.menu || adminUi.order?.gridColumns || adminUi.order?.massActions?.length || adminUi.order?.viewButtons?.length || adminUi.product?.gridColumns || adminUi.product?.massActions?.length || adminUi.customer?.gridColumns || adminUi.customer?.massActions?.length || adminUi.invoice?.gridColumns || adminUi.invoice?.viewButtons?.length || adminUi.creditMemo?.gridColumns || adminUi.creditMemo?.viewButtons?.length || adminUi.shipment?.gridColumns || adminUi.nativeUi?.replacedPages?.length || adminUi.newsletter?.gridColumns);
|
|
240
274
|
}
|
|
241
275
|
/**
|
|
242
276
|
* Check whether the config declares at least one Admin UI component (menu, grid
|
|
243
|
-
* columns, mass actions, view buttons,
|
|
244
|
-
* treated as absent — it
|
|
277
|
+
* columns, mass actions, view buttons, native UI replaced pages, or custom ACL
|
|
278
|
+
* resources). A component-less `adminUi` block is treated as absent — it
|
|
279
|
+
* registers nothing.
|
|
245
280
|
*/
|
|
246
281
|
function hasAdminUi(config) {
|
|
247
282
|
return hasBackendUiV2Components(config) || Boolean(config.adminUi?.acl?.length);
|
|
@@ -557,6 +592,12 @@ Object.defineProperty(exports, "ADMIN_UI_MASS_ACTION_ENTITIES", {
|
|
|
557
592
|
return ADMIN_UI_MASS_ACTION_ENTITIES;
|
|
558
593
|
}
|
|
559
594
|
});
|
|
595
|
+
Object.defineProperty(exports, "ADMIN_UI_VIEW_BUTTON_ENTITIES", {
|
|
596
|
+
enumerable: true,
|
|
597
|
+
get: function () {
|
|
598
|
+
return ADMIN_UI_VIEW_BUTTON_ENTITIES;
|
|
599
|
+
}
|
|
600
|
+
});
|
|
560
601
|
Object.defineProperty(exports, "AdminUiSchema", {
|
|
561
602
|
enumerable: true,
|
|
562
603
|
get: function () {
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import "../../index-
|
|
16
|
-
import { n as CommerceAppConfig } from "../../app-
|
|
15
|
+
import "../../index-DUJtT78x.mjs";
|
|
16
|
+
import { n as CommerceAppConfig } from "../../app-DREvtzyX.mjs";
|
|
17
17
|
import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
|
|
18
18
|
/** The arguments required to create the runtime action for the app-config action. */
|
|
19
19
|
type RuntimeActionFactoryArgs = {
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import { n as logger, t as
|
|
15
|
+
import { n as HttpActionRouter, r as logger, t as SDK_LIB_VERSIONS_HEADERS } from "../../version-CabzC7R9.mjs";
|
|
16
16
|
import { n as filterAppConfigByEnv } from "../../environment-DUhU0_9z.mjs";
|
|
17
|
-
import { i as requiresInstallationFromDomains, o as getConfigDomains, t as validateCommerceAppConfig, u as hasBusinessConfigSchema } from "../../validate-
|
|
17
|
+
import { i as requiresInstallationFromDomains, o as getConfigDomains, t as validateCommerceAppConfig, u as hasBusinessConfigSchema } from "../../validate-BszbuhiE.mjs";
|
|
18
18
|
import { resolveBusinessConfigSchema } from "@adobe/aio-commerce-lib-config";
|
|
19
19
|
import { CommerceEnvSchema } from "@adobe/aio-commerce-lib-core/commerce";
|
|
20
20
|
import * as v from "valibot";
|
|
@@ -26,7 +26,7 @@ import { createHash } from "crypto";
|
|
|
26
26
|
* Loads the committed OpenAPI spec via dynamic import so it
|
|
27
27
|
* lands in its own chunk and is not parsed on every cold start.
|
|
28
28
|
*/
|
|
29
|
-
const importOpenApi = () => import("../../openapi-
|
|
29
|
+
const importOpenApi = () => import("../../openapi-BUIws500.mjs");
|
|
30
30
|
/** Matches component schema `$ref` strings, capturing the schema name. */
|
|
31
31
|
const SCHEMA_REF_PATTERN = /"#\/components\/schemas\/(?<schema>\w+)"/gu;
|
|
32
32
|
/**
|
|
@@ -77,7 +77,7 @@ function pruneUnusedTags(spec) {
|
|
|
77
77
|
* @param domains - The active config domains.
|
|
78
78
|
*/
|
|
79
79
|
function getOpenApiCacheKey(domains) {
|
|
80
|
-
const input = `2.
|
|
80
|
+
const input = `2.2.0-alpha-20261110171457:${[...domains].sort().join(",")}:4.2.0`;
|
|
81
81
|
return createHash("sha256").update(input).digest("hex").slice(0, 8);
|
|
82
82
|
}
|
|
83
83
|
/** Returns the server URL to be set in the OpenAPI spec, based on the current namespace. */
|
|
@@ -129,7 +129,7 @@ async function buildOpenApiSpec(domains, logger) {
|
|
|
129
129
|
* - GET / Retrieve the Commerce App configuration.
|
|
130
130
|
* - GET /openapi.json Returns the OpenAPI spec for all SDK actions
|
|
131
131
|
*/
|
|
132
|
-
const router = new HttpActionRouter().use(logger({ name: () => "app-config" }));
|
|
132
|
+
const router = new HttpActionRouter({ headers: SDK_LIB_VERSIONS_HEADERS }).use(logger({ name: () => "app-config" }));
|
|
133
133
|
/** GET / - Get app config */
|
|
134
134
|
router.get("/", {
|
|
135
135
|
handler: async (req, { logger, rawParams }) => {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import { n as logger, t as
|
|
15
|
+
import { n as HttpActionRouter, r as logger, t as SDK_LIB_VERSIONS_HEADERS } from "../../version-CabzC7R9.mjs";
|
|
16
16
|
import { r as setAssociationData, t as clearAssociationData } from "../../repository-BVBp61y9.mjs";
|
|
17
17
|
import { resolveImsAuthParams } from "@adobe/aio-commerce-lib-auth";
|
|
18
18
|
import { CommerceEnvSchema } from "@adobe/aio-commerce-lib-core/commerce";
|
|
@@ -34,7 +34,7 @@ const AssociationRequestBodySchema = v.object({
|
|
|
34
34
|
* - POST / Store Commerce instance details (`baseUrl`, `env`)
|
|
35
35
|
* - DELETE / Clear stored Commerce instance details
|
|
36
36
|
*/
|
|
37
|
-
const router = new HttpActionRouter().use(logger({ name: () => "association" }));
|
|
37
|
+
const router = new HttpActionRouter({ headers: SDK_LIB_VERSIONS_HEADERS }).use(logger({ name: () => "association" }));
|
|
38
38
|
/** POST / - Store association data and return the app's own `client_id`. */
|
|
39
39
|
router.post("/", {
|
|
40
40
|
body: AssociationRequestBodySchema,
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import "../../index-
|
|
15
|
+
import "../../index-DUJtT78x.mjs";
|
|
16
16
|
import { BusinessConfigSchema } from "@adobe/aio-commerce-lib-config";
|
|
17
17
|
import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
|
|
18
18
|
/** The arguments required to create the runtime action for the config action. */
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import { n as logger, t as
|
|
15
|
+
import { n as HttpActionRouter, r as logger, t as SDK_LIB_VERSIONS_HEADERS } from "../../version-CabzC7R9.mjs";
|
|
16
16
|
import { r as filterSchemaByEnv } from "../../environment-DUhU0_9z.mjs";
|
|
17
17
|
import { r as nonEmptyStringValueSchema } from "../../schemas-DYMNbFdX.mjs";
|
|
18
18
|
import { byScopeId, getConfiguration, initialize, setConfiguration } from "@adobe/aio-commerce-lib-config";
|
|
@@ -64,7 +64,7 @@ function filterPasswordFields(schema, values) {
|
|
|
64
64
|
* - GET / Get current configuration values for a given scope
|
|
65
65
|
* - PATCH / Partially update configuration (only updates provided fields, allows unsetting)
|
|
66
66
|
*/
|
|
67
|
-
const router = new HttpActionRouter().use(logger({ name: () => "config" }));
|
|
67
|
+
const router = new HttpActionRouter({ headers: SDK_LIB_VERSIONS_HEADERS }).use(logger({ name: () => "config" }));
|
|
68
68
|
/** GET / - Retrieve configuration */
|
|
69
69
|
router.get("/", {
|
|
70
70
|
handler: async (req, ctx) => {
|
|
@@ -12,9 +12,10 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import "../../index-
|
|
16
|
-
import { G as LifecycleContext } from "../../index-
|
|
17
|
-
import { n as CommerceAppConfig, r as CommerceAppConfigOutputModel } from "../../app-
|
|
15
|
+
import "../../index-DUJtT78x.mjs";
|
|
16
|
+
import { G as LifecycleContext } from "../../index-zgc3l2nj.mjs";
|
|
17
|
+
import { n as CommerceAppConfig, r as CommerceAppConfigOutputModel } from "../../app-DREvtzyX.mjs";
|
|
18
|
+
import "../../types-DslZGym8.mjs";
|
|
18
19
|
import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
|
|
19
20
|
/** Loads generated custom installation script modules. */
|
|
20
21
|
type CustomScriptsLoader = (config: CommerceAppConfigOutputModel, logger: LifecycleContext["logger"]) => Record<string, unknown>;
|
|
@@ -12,15 +12,16 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import { n as logger, t as
|
|
15
|
+
import { n as HttpActionRouter, r as logger, t as SDK_LIB_VERSIONS_HEADERS } from "../../version-CabzC7R9.mjs";
|
|
16
16
|
import { r as nonEmptyStringValueSchema } from "../../schemas-DYMNbFdX.mjs";
|
|
17
|
-
import { C as isLeafStep, S as isBranchStep, _ as getAtPath, b as pathsEqual, c as getCustomScriptStepName, d as isInProgressState, f as isSucceededState, g as createWorkflowError, h as createSucceededState, l as isCompletedState, m as createFailedState, o as createRootInstallationStep, p as toValidationResult, v as isStepConfigured, w as callHook, x as setAtPath, y as nowIsoString } from "../../management-
|
|
18
|
-
import { n as getAssociationData } from "../../repository-BVBp61y9.mjs";
|
|
19
|
-
import { a as hasCustomInstallationSteps } from "../../webhooks-
|
|
20
|
-
import { r as requiresInstallation, t as validateCommerceAppConfig } from "../../validate-
|
|
17
|
+
import { C as isLeafStep, S as isBranchStep, _ as getAtPath, b as pathsEqual, c as getCustomScriptStepName, d as isInProgressState, f as isSucceededState, g as createWorkflowError, h as createSucceededState, l as isCompletedState, m as createFailedState, o as createRootInstallationStep, p as toValidationResult, v as isStepConfigured, w as callHook, x as setAtPath, y as nowIsoString } from "../../management-CG_4z2Ck.mjs";
|
|
18
|
+
import { n as getAssociationData, r as setAssociationData } from "../../repository-BVBp61y9.mjs";
|
|
19
|
+
import { a as hasCustomInstallationSteps } from "../../webhooks-DRPXVMMo.mjs";
|
|
20
|
+
import { r as requiresInstallation, t as validateCommerceAppConfig } from "../../validate-BszbuhiE.mjs";
|
|
21
21
|
import { init } from "@adobe/aio-lib-state";
|
|
22
22
|
import { CommerceSdkErrorBase } from "@adobe/aio-commerce-lib-core/error";
|
|
23
23
|
import { resolveImsAuthParams } from "@adobe/aio-commerce-lib-auth";
|
|
24
|
+
import { CommerceEnvSchema } from "@adobe/aio-commerce-lib-core/commerce";
|
|
24
25
|
import * as v from "valibot";
|
|
25
26
|
import stringify from "safe-stable-stringify";
|
|
26
27
|
import { accepted, badRequest, conflict, internalServerError, noContent, notFound, ok } from "@adobe/aio-commerce-lib-core/responses";
|
|
@@ -379,6 +380,8 @@ const AppDataSchema = v.object({
|
|
|
379
380
|
*/
|
|
380
381
|
const LifecycleRequestContextSchema = v.object({
|
|
381
382
|
appData: AppDataSchema,
|
|
383
|
+
commerceBaseUrl: v.nullish(v.pipe(v.string(), v.url("The 'commerceBaseUrl' field must be a valid absolute URL (e.g., 'https://my-store.example.com')"))),
|
|
384
|
+
commerceEnv: v.nullish(CommerceEnvSchema),
|
|
382
385
|
installedState: v.optional(v.literal("business-config-only")),
|
|
383
386
|
installedVersion: v.optional(v.string()),
|
|
384
387
|
ioEventsEnv: v.string(),
|
|
@@ -1023,20 +1026,36 @@ const DEFAULT_ACTION_NAME = "app-management/installation";
|
|
|
1023
1026
|
const CUSTOM_INSTALLATION_STEPS_PATH = ["installation", "customInstallationSteps"];
|
|
1024
1027
|
/**
|
|
1025
1028
|
* Merges the runtime params with the request body and the Commerce instance the app is
|
|
1026
|
-
* associated with. Returns `null` when the app
|
|
1029
|
+
* associated with. Returns `null` when the app has no Commerce instance to use.
|
|
1030
|
+
*
|
|
1031
|
+
* An uninstall without an association record uses the Commerce instance of the request body and
|
|
1032
|
+
* returns it as `commerceFromBody`. Any other operation needs the record.
|
|
1027
1033
|
*/
|
|
1028
|
-
async function resolveWorkflowParams(body, rawParams) {
|
|
1034
|
+
async function resolveWorkflowParams(body, rawParams, operation) {
|
|
1029
1035
|
const association = await getAssociationData();
|
|
1030
|
-
|
|
1036
|
+
const commerceFromBody = !association && operation === "uninstall" ? getBodyCommerce(body) : null;
|
|
1037
|
+
const commerce = association?.commerce ?? commerceFromBody;
|
|
1038
|
+
if (!commerce) return null;
|
|
1031
1039
|
return {
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1040
|
+
commerceFromBody,
|
|
1041
|
+
params: {
|
|
1042
|
+
...rawParams,
|
|
1043
|
+
AIO_COMMERCE_API_BASE_URL: commerce.baseUrl,
|
|
1044
|
+
AIO_COMMERCE_API_FLAVOR: commerce.env,
|
|
1045
|
+
AIO_COMMERCE_AUTH_IMS_ENVIRONMENT: body.ioEventsEnv,
|
|
1046
|
+
AIO_EVENTS_API_BASE_URL: body.ioEventsUrl,
|
|
1047
|
+
appData: body.appData
|
|
1048
|
+
}
|
|
1038
1049
|
};
|
|
1039
1050
|
}
|
|
1051
|
+
/** The Commerce instance the request body names, or `null` when it lacks the URL or the env. */
|
|
1052
|
+
function getBodyCommerce(body) {
|
|
1053
|
+
const { commerceBaseUrl, commerceEnv } = body;
|
|
1054
|
+
return commerceBaseUrl && commerceEnv ? {
|
|
1055
|
+
baseUrl: commerceBaseUrl,
|
|
1056
|
+
env: commerceEnv
|
|
1057
|
+
} : null;
|
|
1058
|
+
}
|
|
1040
1059
|
/** The response for a request on an app that is not associated with a Commerce instance. */
|
|
1041
1060
|
function notAssociatedConflict() {
|
|
1042
1061
|
return conflict({ body: {
|
|
@@ -1853,16 +1872,18 @@ async function persistDispatchFailure(stateStore, attempt, error, logger) {
|
|
|
1853
1872
|
|
|
1854
1873
|
// source/actions/installation/plan.ts
|
|
1855
1874
|
/**
|
|
1856
|
-
* Checks what every planning request needs (the action version, the app config and
|
|
1857
|
-
*
|
|
1875
|
+
* Checks what every planning request needs (the action version, the app config and a Commerce
|
|
1876
|
+
* instance) and creates the lifecycle runtime. `operation` is the operation the request is for,
|
|
1877
|
+
* when it is known before the state is read.
|
|
1858
1878
|
*/
|
|
1859
|
-
async function prepareRequest({ body, logger, rawParams }) {
|
|
1879
|
+
async function prepareRequest({ body, logger, rawParams }, operation) {
|
|
1860
1880
|
const actionVersion = process.env.__OW_ACTION_VERSION;
|
|
1861
1881
|
if (!actionVersion) return rejected(internalServerError("The OpenWhisk action version is required to plan a lifecycle operation"));
|
|
1862
1882
|
const rawAppConfig = rawParams.appConfig;
|
|
1863
1883
|
if (!rawAppConfig) return rejected(internalServerError("The app config is missing. Does the action receive it as a parameter?"));
|
|
1864
|
-
const
|
|
1865
|
-
if (!
|
|
1884
|
+
const resolved = await resolveWorkflowParams(body, rawParams, operation);
|
|
1885
|
+
if (!resolved) return rejected(notAssociatedConflict());
|
|
1886
|
+
const { commerceFromBody, params } = resolved;
|
|
1866
1887
|
logger.debug(`Lifecycle request for app "${body.appData.projectName}" (workspace: "${body.appData.workspaceName}", commerce: "${params.AIO_COMMERCE_API_BASE_URL}")`);
|
|
1867
1888
|
const appConfig = validateCommerceAppConfig(rawAppConfig);
|
|
1868
1889
|
const runtime = await createLifecycleRuntime(params, appConfig, logger);
|
|
@@ -1886,6 +1907,7 @@ async function prepareRequest({ body, logger, rawParams }) {
|
|
|
1886
1907
|
appConfig,
|
|
1887
1908
|
baseline,
|
|
1888
1909
|
businessConfigOnlyVersion: body.installedState === "business-config-only" && body.installedVersion ? body.installedVersion : null,
|
|
1910
|
+
commerceFromBody,
|
|
1889
1911
|
isBaselineMissing,
|
|
1890
1912
|
latestAttempt: state?.latestAttempt ?? null,
|
|
1891
1913
|
params,
|
|
@@ -1898,7 +1920,7 @@ async function prepareRequest({ body, logger, rawParams }) {
|
|
|
1898
1920
|
* the plan's issues as a validation result, and the plan, whose `id` starts it.
|
|
1899
1921
|
*/
|
|
1900
1922
|
async function planRequestedOperation(args) {
|
|
1901
|
-
const prepared = await prepareRequest(args);
|
|
1923
|
+
const prepared = await prepareRequest(args, args.body.operation);
|
|
1902
1924
|
if (prepared.kind === "rejected") return prepared.response;
|
|
1903
1925
|
const { request } = prepared;
|
|
1904
1926
|
const resolved = await resolveOperation(request, args.body.operation);
|
|
@@ -2062,8 +2084,8 @@ const StatusQuerySchema = v.object({
|
|
|
2062
2084
|
async function startPlannedRequest(args) {
|
|
2063
2085
|
const { planId } = args.body;
|
|
2064
2086
|
if (!planId) return badRequest("A lifecycle operation starts from a plan. Call POST /plan and pass the planId it returns.");
|
|
2065
|
-
const prepared = await prepareRequest(args);
|
|
2066
2087
|
const { logger } = args;
|
|
2088
|
+
const prepared = await prepareRequest(args, await getPendingPlanOperation(planId));
|
|
2067
2089
|
if (prepared.kind === "rejected") return prepared.response;
|
|
2068
2090
|
const { request } = prepared;
|
|
2069
2091
|
const { stateStore } = request.runtime;
|
|
@@ -2099,6 +2121,7 @@ async function startPlannedRequest(args) {
|
|
|
2099
2121
|
runtime: request.runtime
|
|
2100
2122
|
});
|
|
2101
2123
|
if (planned.kind === "rejected") return planned.response;
|
|
2124
|
+
await backfillAssociation(request.commerceFromBody, logger);
|
|
2102
2125
|
return startPlannedOperation({
|
|
2103
2126
|
actionVersion: request.actionVersion,
|
|
2104
2127
|
logger,
|
|
@@ -2108,6 +2131,23 @@ async function startPlannedRequest(args) {
|
|
|
2108
2131
|
});
|
|
2109
2132
|
}
|
|
2110
2133
|
/**
|
|
2134
|
+
* Stores the Commerce instance of the request as the association record, unless a record exists.
|
|
2135
|
+
* Does nothing when the request did not supply the instance.
|
|
2136
|
+
*/
|
|
2137
|
+
async function backfillAssociation(commerce, logger) {
|
|
2138
|
+
if (!commerce) return;
|
|
2139
|
+
if (await getAssociationData()) return;
|
|
2140
|
+
await setAssociationData({ commerce });
|
|
2141
|
+
logger.info(`Stored the Commerce instance "${commerce.baseUrl}" of the request as the association record.`);
|
|
2142
|
+
}
|
|
2143
|
+
/**
|
|
2144
|
+
* Reads the operation of the pending plan, or `undefined` when `planId` is not the pending plan.
|
|
2145
|
+
*/
|
|
2146
|
+
async function getPendingPlanOperation(planId) {
|
|
2147
|
+
const pendingPlan = (await (await createOrchestrationStateStore()).get(CURRENT_STATE_KEY))?.pendingPlan;
|
|
2148
|
+
return pendingPlan?.id === planId ? pendingPlan.operation : void 0;
|
|
2149
|
+
}
|
|
2150
|
+
/**
|
|
2111
2151
|
* Stores the baseline of an app installed with only business configuration: the target config
|
|
2112
2152
|
* without what needs installation, at the installed version, with no installed data.
|
|
2113
2153
|
*/
|
|
@@ -2136,7 +2176,7 @@ async function writeBusinessConfigOnlyBaseline({ appConfig, runtime }, state, in
|
|
|
2136
2176
|
* - POST /plan Plan an install, upgrade or uninstall for review
|
|
2137
2177
|
* - POST /execution Execute a started lifecycle attempt (internal, called async)
|
|
2138
2178
|
*/
|
|
2139
|
-
const router = new HttpActionRouter().use(logger({ name: () => "installation" }));
|
|
2179
|
+
const router = new HttpActionRouter({ headers: SDK_LIB_VERSIONS_HEADERS }).use(logger({ name: () => "installation" }));
|
|
2140
2180
|
/**
|
|
2141
2181
|
* GET / - Get the status of the latest lifecycle operation. Falls back to the record of an
|
|
2142
2182
|
* installation made by an older library version.
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import { n as logger, t as
|
|
15
|
+
import { n as HttpActionRouter, r as logger, t as SDK_LIB_VERSIONS_HEADERS } from "../../version-CabzC7R9.mjs";
|
|
16
16
|
import { t as inspect } from "../../logging-B1xb568A.mjs";
|
|
17
17
|
import { t as LIFECYCLE_HTTP_CLIENT_TIMEOUT_MS } from "../../constants-C-4fesPr.mjs";
|
|
18
18
|
import { r as nonEmptyStringValueSchema } from "../../schemas-DYMNbFdX.mjs";
|
|
@@ -50,7 +50,7 @@ const SyncCommerceScopesBodySchema = v.object({
|
|
|
50
50
|
* - POST /commerce Sync commerce scopes
|
|
51
51
|
* - DELETE /commerce Unsync commerce scopes
|
|
52
52
|
*/
|
|
53
|
-
const router = new HttpActionRouter().use(logger({ name: () => "scope-tree" }));
|
|
53
|
+
const router = new HttpActionRouter({ headers: SDK_LIB_VERSIONS_HEADERS }).use(logger({ name: () => "scope-tree" }));
|
|
54
54
|
/** GET / - Get scope tree */
|
|
55
55
|
router.get("/", { handler: async (_req, ctx) => {
|
|
56
56
|
const { logger } = ctx;
|