@adobe/aio-commerce-lib-app 1.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/cjs/actions/app-config.cjs +18 -4
  3. package/dist/cjs/actions/app-config.d.cts +15 -1
  4. package/dist/cjs/actions/config.cjs +17 -3
  5. package/dist/cjs/actions/config.d.cts +14 -0
  6. package/dist/cjs/actions/installation.cjs +70 -16
  7. package/dist/cjs/actions/installation.d.cts +16 -2
  8. package/dist/cjs/actions/scope-tree.cjs +17 -3
  9. package/dist/cjs/actions/scope-tree.d.cts +14 -0
  10. package/dist/cjs/{app-DWX5-Hsf.d.cts → app-lymFcs59.d.cts} +146 -1
  11. package/dist/cjs/commands/index.cjs +41 -27
  12. package/dist/cjs/commands/index.d.cts +14 -0
  13. package/dist/cjs/config/index.cjs +27 -12
  14. package/dist/cjs/config/index.d.cts +576 -4
  15. package/dist/cjs/{parser-BPpg_9QB.cjs → config-YEeaEqzi.cjs} +17 -3
  16. package/dist/cjs/error-Dn7ool6k.cjs +38 -0
  17. package/dist/{es/runner-BD-lItnK.d.mts → cjs/index-DRhLtRrX.d.cts} +102 -4
  18. package/dist/cjs/logging-4s36JTiN.cjs +39 -0
  19. package/dist/cjs/management/index.cjs +23 -8
  20. package/dist/cjs/management/index.d.cts +16 -2
  21. package/dist/cjs/{runner-NHMvoMO2.cjs → management-PZtLe4Ji.cjs} +371 -30
  22. package/dist/cjs/{router-DCw7oEQ9.cjs → router-KeQRduO3.cjs} +15 -1
  23. package/dist/cjs/{schemas-CZ6c8Id9.cjs → schemas-nkIxa8sL.cjs} +34 -0
  24. package/dist/cjs/{validate-Btzn9ilZ.cjs → validate-CwwYD8aC.cjs} +31 -14
  25. package/dist/cjs/{installation-CLbceU9F.cjs → webhooks-CbZpv9y_.cjs} +105 -1
  26. package/dist/es/actions/app-config.d.mts +15 -1
  27. package/dist/es/actions/app-config.mjs +17 -3
  28. package/dist/es/actions/config.d.mts +14 -0
  29. package/dist/es/actions/config.mjs +17 -3
  30. package/dist/es/actions/installation.d.mts +16 -2
  31. package/dist/es/actions/installation.mjs +64 -10
  32. package/dist/es/actions/scope-tree.d.mts +14 -0
  33. package/dist/es/actions/scope-tree.mjs +17 -3
  34. package/dist/es/{app-BAiyvNo2.d.mts → app-Ct7Y0NP8.d.mts} +146 -1
  35. package/dist/es/commands/index.d.mts +14 -0
  36. package/dist/es/commands/index.mjs +21 -7
  37. package/dist/es/config/index.d.mts +576 -4
  38. package/dist/es/config/index.mjs +18 -4
  39. package/dist/es/{parser-CQZTVG6i.mjs → config-BbrkH0Xt.mjs} +16 -2
  40. package/dist/es/error-DHlYzkbb.mjs +32 -0
  41. package/dist/{cjs/runner-DemKouFJ.d.cts → es/index-D33OCH0D.d.mts} +102 -4
  42. package/dist/es/logging-XIUXDK5T.mjs +32 -0
  43. package/dist/es/management/index.d.mts +16 -2
  44. package/dist/es/management/index.mjs +16 -2
  45. package/dist/es/{runner-vwAhjD5r.mjs → management-CIoVWirU.mjs} +360 -25
  46. package/dist/es/{router-CJ4VWoCt.mjs → router-BxaxEEu3.mjs} +14 -0
  47. package/dist/es/{schemas-B8yIv0_b.mjs → schemas-BvPxQwgQ.mjs} +29 -1
  48. package/dist/es/{validate-DKnju9-R.mjs → validate-qRpfubPo.mjs} +21 -4
  49. package/dist/es/{installation-BTL9X7iv.mjs → webhooks-NgM6k3_r.mjs} +94 -2
  50. package/package.json +10 -7
  51. package/dist/cjs/error-DJ2UAPH2.cjs +0 -24
  52. package/dist/cjs/logging-IDRQG0as.cjs +0 -25
  53. package/dist/es/error-CMV3IjBz.mjs +0 -18
  54. package/dist/es/logging-CzmXDzxI.mjs +0 -18
@@ -1,4 +1,18 @@
1
- const require_schemas = require('./schemas-CZ6c8Id9.cjs');
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
+ const require_schemas = require('./schemas-nkIxa8sL.cjs');
2
16
  let valibot = require("valibot");
3
17
  valibot = require_schemas.__toESM(valibot);
4
18
 
@@ -198,6 +212,84 @@ function hasCustomInstallationSteps(config) {
198
212
  return Array.isArray(config?.installation?.customInstallationSteps) && config.installation.customInstallationSteps.length > 0;
199
213
  }
200
214
 
215
+ //#endregion
216
+ //#region source/config/schema/webhooks.ts
217
+ /** Schema for webhook field configuration (name and optional source). */
218
+ const WebhookFieldSchema = valibot.object({
219
+ name: require_schemas.nonEmptyStringValueSchema("field name"),
220
+ source: valibot.optional(require_schemas.stringValueSchema("field source"))
221
+ });
222
+ /** Schema for webhook rule configuration (field, operator, value). */
223
+ const WebhookRuleSchema = valibot.object({
224
+ field: require_schemas.nonEmptyStringValueSchema("rule field"),
225
+ operator: require_schemas.nonEmptyStringValueSchema("rule operator"),
226
+ value: require_schemas.nonEmptyStringValueSchema("rule value")
227
+ });
228
+ /** Schema for webhook header configuration (name, value). */
229
+ const WebhookHeaderSchema = valibot.object({
230
+ name: require_schemas.nonEmptyStringValueSchema("header name"),
231
+ value: require_schemas.nonEmptyStringValueSchema("header value")
232
+ });
233
+ /** batch_name and hook_name must contain only letters, numbers, and underscores. */
234
+ const WEBHOOK_IDENTIFIER_REGEX = /^[a-zA-Z0-9_]+$/;
235
+ /** Category for conflict detection: validation, append, or modification. */
236
+ const CATEGORIES = [
237
+ "validation",
238
+ "append",
239
+ "modification"
240
+ ];
241
+ const CategorySchema = valibot.picklist(CATEGORIES, `Webhook category must be one of: ${CATEGORIES.join(", ")}`);
242
+ /** Schema for the nested webhook payload without url — used when runtimeAction resolves the URL at runtime. */
243
+ const WebhookDefinitionBaseSchema = valibot.object({
244
+ webhook_method: require_schemas.nonEmptyStringValueSchema("webhook_method"),
245
+ webhook_type: require_schemas.nonEmptyStringValueSchema("webhook_type"),
246
+ batch_name: valibot.pipe(require_schemas.nonEmptyStringValueSchema("batch_name"), valibot.regex(WEBHOOK_IDENTIFIER_REGEX, "batch_name must contain only letters, numbers, and underscores")),
247
+ batch_order: valibot.optional(require_schemas.positiveNumberValueSchema("batch_order")),
248
+ hook_name: valibot.pipe(require_schemas.nonEmptyStringValueSchema("hook_name"), valibot.regex(WEBHOOK_IDENTIFIER_REGEX, "hook_name must contain only letters, numbers, and underscores")),
249
+ priority: valibot.optional(require_schemas.positiveNumberValueSchema("priority")),
250
+ required: valibot.optional(require_schemas.booleanValueSchema("required")),
251
+ soft_timeout: valibot.optional(require_schemas.positiveNumberValueSchema("soft_timeout")),
252
+ timeout: valibot.optional(require_schemas.positiveNumberValueSchema("timeout")),
253
+ method: require_schemas.nonEmptyStringValueSchema("HTTP method"),
254
+ fallback_error_message: valibot.optional(require_schemas.stringValueSchema("fallback_error_message")),
255
+ ttl: valibot.optional(require_schemas.positiveNumberValueSchema("ttl")),
256
+ fields: valibot.optional(valibot.array(WebhookFieldSchema, "Expected an array of webhook field objects")),
257
+ rules: valibot.optional(valibot.array(WebhookRuleSchema, "Expected an array of webhook rule objects")),
258
+ headers: valibot.optional(valibot.array(WebhookHeaderSchema, "Expected an array of webhook header objects"))
259
+ });
260
+ /** Schema for the nested webhook payload with a required url. */
261
+ const WebhookDefinitionWithUrlSchema = valibot.object({
262
+ ...WebhookDefinitionBaseSchema.entries,
263
+ url: valibot.pipe(require_schemas.stringValueSchema("webhook URL"), valibot.url("The 'url' field must be a valid absolute URL (e.g., 'https://example.com/webhook')"))
264
+ });
265
+ /** Schema for a webhook entry that resolves its URL from a runtime action. */
266
+ const WebhookEntryWithRuntimeActionSchema = valibot.object({
267
+ label: require_schemas.nonEmptyStringValueSchema("webhook label"),
268
+ description: require_schemas.nonEmptyStringValueSchema("webhook description"),
269
+ category: valibot.optional(CategorySchema),
270
+ runtimeAction: require_schemas.nonEmptyStringValueSchema("runtimeAction"),
271
+ requireAdobeAuth: valibot.optional(require_schemas.booleanValueSchema("requireAdobeAuth")),
272
+ webhook: WebhookDefinitionBaseSchema
273
+ });
274
+ /** Schema for a webhook entry that provides an explicit URL. */
275
+ const WebhookEntryWithUrlSchema = valibot.object({
276
+ label: require_schemas.nonEmptyStringValueSchema("webhook label"),
277
+ description: require_schemas.nonEmptyStringValueSchema("webhook description"),
278
+ category: valibot.optional(CategorySchema),
279
+ webhook: WebhookDefinitionWithUrlSchema
280
+ });
281
+ /** Schema for a single webhook entry — either runtimeAction (no url) or explicit url (no runtimeAction). */
282
+ const WebhookEntrySchema = valibot.union([WebhookEntryWithRuntimeActionSchema, WebhookEntryWithUrlSchema], "Each webhook entry must define either a 'runtimeAction' (to resolve the URL from a runtime action) or an explicit 'url' inside the 'webhook' object, but not both");
283
+ /** Schema for the optional webhooks array (when present, must have at least one item). */
284
+ const WebhooksSchema = valibot.optional(valibot.pipe(valibot.array(WebhookEntrySchema, "Expected an array of webhook entries"), valibot.minLength(1, "webhooks array must contain at least one webhook when present")));
285
+ /**
286
+ * Check if config has webhooks (non-empty array).
287
+ * @param config - The configuration to check.
288
+ */
289
+ function hasWebhooks(config) {
290
+ return Array.isArray(config?.webhooks) && config.webhooks.length > 0;
291
+ }
292
+
201
293
  //#endregion
202
294
  Object.defineProperty(exports, 'EventingSchema', {
203
295
  enumerable: true,
@@ -211,6 +303,12 @@ Object.defineProperty(exports, 'InstallationSchema', {
211
303
  return InstallationSchema;
212
304
  }
213
305
  });
306
+ Object.defineProperty(exports, 'WebhooksSchema', {
307
+ enumerable: true,
308
+ get: function () {
309
+ return WebhooksSchema;
310
+ }
311
+ });
214
312
  Object.defineProperty(exports, 'hasCommerceEvents', {
215
313
  enumerable: true,
216
314
  get: function () {
@@ -240,4 +338,10 @@ Object.defineProperty(exports, 'hasExternalEvents', {
240
338
  get: function () {
241
339
  return hasExternalEvents;
242
340
  }
341
+ });
342
+ Object.defineProperty(exports, 'hasWebhooks', {
343
+ enumerable: true,
344
+ get: function () {
345
+ return hasWebhooks;
346
+ }
243
347
  });
@@ -1,4 +1,18 @@
1
- import { n as CommerceAppConfigOutputModel } from "../app-BAiyvNo2.mjs";
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 { n as CommerceAppConfigOutputModel } from "../app-Ct7Y0NP8.mjs";
2
16
  import * as _adobe_aio_commerce_lib_core_responses0 from "@adobe/aio-commerce-lib-core/responses";
3
17
  import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
4
18
 
@@ -1,10 +1,24 @@
1
- import { n as logger, t as HttpActionRouter } from "../router-CJ4VWoCt.mjs";
2
- import { t as validateCommerceAppConfig } from "../validate-DKnju9-R.mjs";
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 { n as logger, t as HttpActionRouter } from "../router-BxaxEEu3.mjs";
16
+ import { t as validateCommerceAppConfig } from "../validate-qRpfubPo.mjs";
3
17
  import { ok } from "@adobe/aio-commerce-lib-core/responses";
4
18
 
5
19
  //#region source/actions/app-config.ts
6
20
  /** Router for the app config actions. */
7
- const router = new HttpActionRouter().use(logger({ name: () => "get-app-config" }));
21
+ const router = new HttpActionRouter().use(logger({ name: () => "app-config" }));
8
22
  /** GET / - Get app config */
9
23
  router.get("/", { handler: async (_req, { logger, rawParams }) => {
10
24
  logger.debug("Validating app config...");
@@ -1,3 +1,17 @@
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
+
1
15
  import * as _adobe_aio_commerce_lib_core_responses0 from "@adobe/aio-commerce-lib-core/responses";
2
16
  import { BusinessConfigSchema } from "@adobe/aio-commerce-lib-config";
3
17
  import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
@@ -1,6 +1,20 @@
1
- import { n as logger, t as HttpActionRouter } from "../router-CJ4VWoCt.mjs";
2
- import { n as validateCommerceAppConfigDomain } from "../validate-DKnju9-R.mjs";
3
- import { r as nonEmptyStringValueSchema } from "../schemas-B8yIv0_b.mjs";
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 { n as logger, t as HttpActionRouter } from "../router-BxaxEEu3.mjs";
16
+ import { n as validateCommerceAppConfigDomain } from "../validate-qRpfubPo.mjs";
17
+ import { r as nonEmptyStringValueSchema } from "../schemas-BvPxQwgQ.mjs";
4
18
  import { ok } from "@adobe/aio-commerce-lib-core/responses";
5
19
  import * as v from "valibot";
6
20
  import { byScopeId, getConfiguration, initialize, setConfiguration } from "@adobe/aio-commerce-lib-config";
@@ -1,5 +1,19 @@
1
- import { n as CommerceAppConfigOutputModel } from "../app-BAiyvNo2.mjs";
2
- import { P as InstallationContext } from "../runner-BD-lItnK.mjs";
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 { n as CommerceAppConfigOutputModel } from "../app-Ct7Y0NP8.mjs";
16
+ import { V as InstallationContext } from "../index-D33OCH0D.mjs";
3
17
  import * as _adobe_aio_commerce_lib_core_responses0 from "@adobe/aio-commerce-lib-core/responses";
4
18
  import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
5
19
 
@@ -1,6 +1,20 @@
1
- import { n as logger, t as HttpActionRouter } from "../router-CJ4VWoCt.mjs";
2
- import { r as nonEmptyStringValueSchema } from "../schemas-B8yIv0_b.mjs";
3
- import { a as isFailedState, i as isCompletedState, n as runInstallation, o as isInProgressState, s as isSucceededState, t as createInitialInstallationState } from "../runner-vwAhjD5r.mjs";
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 { n as logger, t as HttpActionRouter } from "../router-BxaxEEu3.mjs";
16
+ import { r as nonEmptyStringValueSchema } from "../schemas-BvPxQwgQ.mjs";
17
+ import { a as isCompletedState, c as isSucceededState, n as runInstallation, o as isFailedState, r as runValidation, s as isInProgressState, t as createInitialInstallationState } from "../management-CIoVWirU.mjs";
4
18
  import { accepted, badRequest, conflict, internalServerError, noContent, ok } from "@adobe/aio-commerce-lib-core/responses";
5
19
  import * as v from "valibot";
6
20
  import { object, string } from "valibot";
@@ -244,6 +258,14 @@ const AppDataSchema = v.object({
244
258
  //#endregion
245
259
  //#region source/actions/installation.ts
246
260
  const DEFAULT_ACTION_NAME = "app-management/installation";
261
+ /** Request body schema shared by POST / and POST /validation. */
262
+ const InstallationRequestBodySchema = object({
263
+ appData: AppDataSchema,
264
+ commerceBaseUrl: string(),
265
+ commerceEnv: string(),
266
+ ioEventsUrl: string(),
267
+ ioEventsEnv: string()
268
+ });
247
269
  /** Creates an installation state store using lib-core combined storage. */
248
270
  function createInstallationStore() {
249
271
  return createCombinedStore({
@@ -311,13 +333,7 @@ router.get("/", { handler: async (_req, { logger }) => {
311
333
  * 3. If not found or failed: create plan, invoke execution async, return 202 Accepted
312
334
  */
313
335
  router.post("/", {
314
- body: object({
315
- appData: AppDataSchema,
316
- commerceBaseUrl: string(),
317
- commerceEnv: string(),
318
- ioEventsUrl: string(),
319
- ioEventsEnv: string()
320
- }),
336
+ body: InstallationRequestBodySchema,
321
337
  handler: async (req, { logger, rawParams }) => {
322
338
  logger.debug("Starting installation...");
323
339
  const store = await createInstallationStore();
@@ -399,6 +415,44 @@ router.post("/execution", { handler: async (_req, { logger, rawParams }) => {
399
415
  return ok({ body: result });
400
416
  } });
401
417
  /**
418
+ * POST /installation/validation - Pre-installation validation
419
+ *
420
+ * Synchronously validates the step tree before installation begins.
421
+ * Accepts the same request body as POST / (installation start) so the
422
+ * frontend can reuse the same parameters without any extra mapping.
423
+ *
424
+ * Flow:
425
+ * 1. Build a ValidationContext from the request parameters
426
+ * 2. Call runValidation() — traverses the step tree and collects issues
427
+ * 3. Return the structured ValidationResult immediately (no async invoke)
428
+ */
429
+ router.post("/validation", {
430
+ body: InstallationRequestBodySchema,
431
+ handler: async (req, { logger, rawParams }) => {
432
+ logger.debug("Running pre-installation validation...");
433
+ const appConfig = rawParams.appConfig;
434
+ if (!appConfig) return internalServerError("Could not find or parse the app.commerce.manifest.json file, is it present and valid?");
435
+ const { appData, ...params } = {
436
+ ...rawParams,
437
+ appData: req.body.appData,
438
+ AIO_EVENTS_API_BASE_URL: req.body.ioEventsUrl,
439
+ AIO_COMMERCE_AUTH_IMS_ENVIRONMENT: req.body.ioEventsEnv,
440
+ AIO_COMMERCE_API_BASE_URL: req.body.commerceBaseUrl,
441
+ AIO_COMMERCE_API_FLAVOR: req.body.commerceEnv
442
+ };
443
+ const result = await runValidation({
444
+ validationContext: {
445
+ appData,
446
+ params,
447
+ logger
448
+ },
449
+ config: appConfig
450
+ });
451
+ logger.debug(`Validation complete — valid: ${result.valid}, errors: ${result.summary.errors}, warnings: ${result.summary.warnings}`);
452
+ return ok({ body: result });
453
+ }
454
+ });
455
+ /**
402
456
  * DELETE / - Clear installation state
403
457
  *
404
458
  * This endpoint allows clearing the installation state.
@@ -1,3 +1,17 @@
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
+
1
15
  import * as _adobe_aio_commerce_lib_core_responses0 from "@adobe/aio-commerce-lib-core/responses";
2
16
  import * as _adobe_aio_commerce_lib_core_params0 from "@adobe/aio-commerce-lib-core/params";
3
17
 
@@ -1,6 +1,20 @@
1
- import { n as logger, t as HttpActionRouter } from "../router-CJ4VWoCt.mjs";
2
- import { r as nonEmptyStringValueSchema } from "../schemas-B8yIv0_b.mjs";
3
- import { t as inspect } from "../logging-CzmXDzxI.mjs";
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 { n as logger, t as HttpActionRouter } from "../router-BxaxEEu3.mjs";
16
+ import { r as nonEmptyStringValueSchema } from "../schemas-BvPxQwgQ.mjs";
17
+ import { t as inspect } from "../logging-XIUXDK5T.mjs";
4
18
  import { internalServerError, nonAuthoritativeInformation, ok } from "@adobe/aio-commerce-lib-core/responses";
5
19
  import * as v from "valibot";
6
20
  import { getScopeTree, setCustomScopeTree, syncCommerceScopes, unsyncCommerceScopes } from "@adobe/aio-commerce-lib-config";
@@ -1,3 +1,17 @@
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
+
1
15
  import * as v from "valibot";
2
16
 
3
17
  //#region source/config/schema/app.d.ts
@@ -7,7 +21,7 @@ declare const CommerceAppConfigSchema: v.LooseObjectSchema<{
7
21
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.RegexAction<string, `Only alphanumeric characters and hyphens are allowed in string value of "${string}"${string}`>]>;
8
22
  readonly displayName: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string for the ${string}`>, v.NonEmptyAction<string, `The ${string} must not be empty`>]>, v.MaxLengthAction<string, 50, "The application display name must not be longer than 50 characters">]>;
9
23
  readonly description: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string for the ${string}`>, v.NonEmptyAction<string, `The ${string} must not be empty`>]>, v.MaxLengthAction<string, 255, "The metadata description must not be longer than 255 characters">]>;
10
- readonly version: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string for the ${string}`>, v.NonEmptyAction<string, `The ${string} must not be empty`>]>, v.RegexAction<string, "The version must follow semantic versioning (semver) format">]>;
24
+ readonly version: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string for the ${string}`>, v.NonEmptyAction<string, `The ${string} must not be empty`>]>, v.RegexAction<string, "The version must follow semantic versioning (semver) format: Major.Minor.Patch (e.g., '1.0.0', '2.3.1')">]>;
11
25
  }, undefined>;
12
26
  readonly businessConfig: v.OptionalSchema<v.ObjectSchema<{
13
27
  readonly schema: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.VariantSchema<"type", [v.VariantSchema<"selectionMode", [v.ObjectSchema<{
@@ -172,6 +186,137 @@ declare const CommerceAppConfigSchema: v.LooseObjectSchema<{
172
186
  description: string;
173
187
  }[] | undefined, "Duplicate step names detected in custom installation steps. Each step must have a unique name.">]>;
174
188
  }, undefined>, undefined>;
189
+ readonly webhooks: v.OptionalSchema<v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
190
+ readonly label: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
191
+ readonly description: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
192
+ readonly category: v.OptionalSchema<v.PicklistSchema<readonly ["validation", "append", "modification"], `Webhook category must be one of: ${string}`>, undefined>;
193
+ readonly runtimeAction: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
194
+ readonly requireAdobeAuth: v.OptionalSchema<v.BooleanSchema<`Expected a boolean value for '${string}'`>, undefined>;
195
+ readonly webhook: v.ObjectSchema<{
196
+ readonly webhook_method: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
197
+ readonly webhook_type: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
198
+ readonly batch_name: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>, v.RegexAction<string, "batch_name must contain only letters, numbers, and underscores">]>;
199
+ readonly batch_order: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<`Expected a number value for '${string}'`>, v.MinValueAction<number, 0, `The value of ${string} must be a non-negative number`>]>, undefined>;
200
+ readonly hook_name: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>, v.RegexAction<string, "hook_name must contain only letters, numbers, and underscores">]>;
201
+ readonly priority: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<`Expected a number value for '${string}'`>, v.MinValueAction<number, 0, `The value of ${string} must be a non-negative number`>]>, undefined>;
202
+ readonly required: v.OptionalSchema<v.BooleanSchema<`Expected a boolean value for '${string}'`>, undefined>;
203
+ readonly soft_timeout: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<`Expected a number value for '${string}'`>, v.MinValueAction<number, 0, `The value of ${string} must be a non-negative number`>]>, undefined>;
204
+ readonly timeout: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<`Expected a number value for '${string}'`>, v.MinValueAction<number, 0, `The value of ${string} must be a non-negative number`>]>, undefined>;
205
+ readonly method: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
206
+ readonly fallback_error_message: v.OptionalSchema<v.StringSchema<`Expected a string value for '${string}'`>, undefined>;
207
+ readonly ttl: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<`Expected a number value for '${string}'`>, v.MinValueAction<number, 0, `The value of ${string} must be a non-negative number`>]>, undefined>;
208
+ readonly fields: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
209
+ readonly name: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
210
+ readonly source: v.OptionalSchema<v.StringSchema<`Expected a string value for '${string}'`>, undefined>;
211
+ }, undefined>, "Expected an array of webhook field objects">, undefined>;
212
+ readonly rules: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
213
+ readonly field: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
214
+ readonly operator: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
215
+ readonly value: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
216
+ }, undefined>, "Expected an array of webhook rule objects">, undefined>;
217
+ readonly headers: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
218
+ readonly name: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
219
+ readonly value: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
220
+ }, undefined>, "Expected an array of webhook header objects">, undefined>;
221
+ }, undefined>;
222
+ }, undefined>, v.ObjectSchema<{
223
+ readonly label: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
224
+ readonly description: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
225
+ readonly category: v.OptionalSchema<v.PicklistSchema<readonly ["validation", "append", "modification"], `Webhook category must be one of: ${string}`>, undefined>;
226
+ readonly webhook: v.ObjectSchema<{
227
+ readonly url: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.UrlAction<string, "The 'url' field must be a valid absolute URL (e.g., 'https://example.com/webhook')">]>;
228
+ readonly webhook_method: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
229
+ readonly webhook_type: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
230
+ readonly batch_name: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>, v.RegexAction<string, "batch_name must contain only letters, numbers, and underscores">]>;
231
+ readonly batch_order: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<`Expected a number value for '${string}'`>, v.MinValueAction<number, 0, `The value of ${string} must be a non-negative number`>]>, undefined>;
232
+ readonly hook_name: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>, v.RegexAction<string, "hook_name must contain only letters, numbers, and underscores">]>;
233
+ readonly priority: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<`Expected a number value for '${string}'`>, v.MinValueAction<number, 0, `The value of ${string} must be a non-negative number`>]>, undefined>;
234
+ readonly required: v.OptionalSchema<v.BooleanSchema<`Expected a boolean value for '${string}'`>, undefined>;
235
+ readonly soft_timeout: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<`Expected a number value for '${string}'`>, v.MinValueAction<number, 0, `The value of ${string} must be a non-negative number`>]>, undefined>;
236
+ readonly timeout: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<`Expected a number value for '${string}'`>, v.MinValueAction<number, 0, `The value of ${string} must be a non-negative number`>]>, undefined>;
237
+ readonly method: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
238
+ readonly fallback_error_message: v.OptionalSchema<v.StringSchema<`Expected a string value for '${string}'`>, undefined>;
239
+ readonly ttl: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<`Expected a number value for '${string}'`>, v.MinValueAction<number, 0, `The value of ${string} must be a non-negative number`>]>, undefined>;
240
+ readonly fields: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
241
+ readonly name: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
242
+ readonly source: v.OptionalSchema<v.StringSchema<`Expected a string value for '${string}'`>, undefined>;
243
+ }, undefined>, "Expected an array of webhook field objects">, undefined>;
244
+ readonly rules: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
245
+ readonly field: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
246
+ readonly operator: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
247
+ readonly value: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
248
+ }, undefined>, "Expected an array of webhook rule objects">, undefined>;
249
+ readonly headers: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
250
+ readonly name: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
251
+ readonly value: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
252
+ }, undefined>, "Expected an array of webhook header objects">, undefined>;
253
+ }, undefined>;
254
+ }, undefined>], "Each webhook entry must define either a 'runtimeAction' (to resolve the URL from a runtime action) or an explicit 'url' inside the 'webhook' object, but not both">, "Expected an array of webhook entries">, v.MinLengthAction<({
255
+ label: string;
256
+ description: string;
257
+ category?: "validation" | "append" | "modification" | undefined;
258
+ runtimeAction: string;
259
+ requireAdobeAuth?: boolean | undefined;
260
+ webhook: {
261
+ webhook_method: string;
262
+ webhook_type: string;
263
+ batch_name: string;
264
+ batch_order?: number | undefined;
265
+ hook_name: string;
266
+ priority?: number | undefined;
267
+ required?: boolean | undefined;
268
+ soft_timeout?: number | undefined;
269
+ timeout?: number | undefined;
270
+ method: string;
271
+ fallback_error_message?: string | undefined;
272
+ ttl?: number | undefined;
273
+ fields?: {
274
+ name: string;
275
+ source?: string | undefined;
276
+ }[] | undefined;
277
+ rules?: {
278
+ field: string;
279
+ operator: string;
280
+ value: string;
281
+ }[] | undefined;
282
+ headers?: {
283
+ name: string;
284
+ value: string;
285
+ }[] | undefined;
286
+ };
287
+ } | {
288
+ label: string;
289
+ description: string;
290
+ category?: "validation" | "append" | "modification" | undefined;
291
+ webhook: {
292
+ url: string;
293
+ webhook_method: string;
294
+ webhook_type: string;
295
+ batch_name: string;
296
+ batch_order?: number | undefined;
297
+ hook_name: string;
298
+ priority?: number | undefined;
299
+ required?: boolean | undefined;
300
+ soft_timeout?: number | undefined;
301
+ timeout?: number | undefined;
302
+ method: string;
303
+ fallback_error_message?: string | undefined;
304
+ ttl?: number | undefined;
305
+ fields?: {
306
+ name: string;
307
+ source?: string | undefined;
308
+ }[] | undefined;
309
+ rules?: {
310
+ field: string;
311
+ operator: string;
312
+ value: string;
313
+ }[] | undefined;
314
+ headers?: {
315
+ name: string;
316
+ value: string;
317
+ }[] | undefined;
318
+ };
319
+ })[], 1, "webhooks array must contain at least one webhook when present">]>, undefined>, undefined>;
175
320
  }, undefined>;
176
321
  /** The input shape of the commerce app config schema. */
177
322
  type CommerceAppConfig = v.InferInput<typeof CommerceAppConfigSchema>;
@@ -1 +1,15 @@
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
+
1
15
  export { };
@@ -1,9 +1,23 @@
1
1
  #!/usr/bin/env node
2
- import { c as hasBusinessConfigSchema, i as getConfigDomains, t as validateCommerceAppConfig } from "../validate-DKnju9-R.mjs";
3
- import { r as hasCustomInstallationSteps } from "../installation-BTL9X7iv.mjs";
4
- import { a as findNearestPackageJson, c as isESM, i as detectPackageManager, l as makeOutputDirFor, n as readCommerceAppConfig, o as getExecCommand, s as getProjectRootDirectory, t as parseCommerceAppConfig, u as readPackageJson } from "../parser-CQZTVG6i.mjs";
5
- import { t as stringifyError } from "../error-CMV3IjBz.mjs";
6
- import { t as inspect } from "../logging-CzmXDzxI.mjs";
2
+ /**
3
+ * @license
4
+ *
5
+ * Copyright 2026 Adobe. All rights reserved.
6
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License. You may obtain a copy
8
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software distributed under
11
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ * OF ANY KIND, either express or implied. See the License for the specific language
13
+ * governing permissions and limitations under the License.
14
+ */
15
+
16
+ import { c as hasBusinessConfigSchema, i as getConfigDomains, t as validateCommerceAppConfig } from "../validate-qRpfubPo.mjs";
17
+ import { a as hasCustomInstallationSteps } from "../webhooks-NgM6k3_r.mjs";
18
+ import { a as findNearestPackageJson, c as isESM, i as detectPackageManager, l as makeOutputDirFor, n as readCommerceAppConfig, o as getExecCommand, s as getProjectRootDirectory, t as parseCommerceAppConfig, u as readPackageJson } from "../config-BbrkH0Xt.mjs";
19
+ import { t as stringifyError } from "../error-DHlYzkbb.mjs";
20
+ import { t as inspect } from "../logging-XIUXDK5T.mjs";
7
21
  import { CommerceSdkValidationError } from "@adobe/aio-commerce-lib-core/error";
8
22
  import path, { basename, dirname, join, relative, resolve } from "path";
9
23
  import { existsSync, readFileSync, writeFileSync } from "fs";
@@ -299,7 +313,7 @@ function createActionDefinition(actionName, config = {}, options = {}) {
299
313
  * @param extConfig - The ext.config.yaml configuration.
300
314
  */
301
315
  function getRuntimeActions(extConfig, dir) {
302
- return Object.entries(extConfig.runtimeManifest?.packages?.[PACKAGE_NAME]?.actions ?? {}).map(([name, _]) => ({
316
+ return Object.entries(extConfig.runtimeManifest?.packages?.["app-management"]?.actions ?? {}).map(([name, _]) => ({
303
317
  name,
304
318
  templateFile: join(dir, `${name}.js.template`)
305
319
  }));
@@ -840,7 +854,7 @@ async function ensureCommerceAppConfig(cwd = process.cwd()) {
840
854
  throw new Error(`${COMMERCE_APP_CONFIG_FILE} is invalid`, { cause: error });
841
855
  }
842
856
  consola$1.warn(`${COMMERCE_APP_CONFIG_FILE} not found.`);
843
- if (!await consola$1.prompt(`Do you want to create a ${COMMERCE_APP_CONFIG_FILE} file? (y/n)`, {
857
+ if (!await consola$1.prompt(`Do you want to create a ${"app.commerce.config"} file? (y/n)`, {
844
858
  type: "confirm",
845
859
  initial: true,
846
860
  default: false