@adobe/aio-commerce-lib-app 1.5.0 → 1.7.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 (67) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/cjs/actions/app-config/index.cjs +202 -0
  3. package/dist/cjs/actions/{app-config.d.cts → app-config/index.d.cts} +11 -9
  4. package/dist/cjs/actions/{config.cjs → config/index.cjs} +79 -46
  5. package/dist/{es/actions/config.d.mts → cjs/actions/config/index.d.cts} +10 -8
  6. package/dist/cjs/actions/{installation.cjs → installation/index.cjs} +55 -36
  7. package/dist/{es/actions/installation.d.mts → cjs/actions/installation/index.d.cts} +11 -10
  8. package/dist/cjs/actions/{registration.cjs → registration/index.cjs} +16 -7
  9. package/dist/cjs/actions/{registration.d.cts → registration/index.d.cts} +8 -9
  10. package/dist/cjs/actions/{scope-tree.cjs → scope-tree/index.cjs} +52 -15
  11. package/dist/{es/actions/scope-tree.d.mts → cjs/actions/scope-tree/index.d.cts} +2 -5
  12. package/dist/cjs/{admin-ui-sdk-BiSopnKI.d.cts → admin-ui-sdk-EU915zlR.d.cts} +7 -8
  13. package/dist/cjs/app-DrYHK-z1.d.cts +1629 -0
  14. package/dist/cjs/commands/index.cjs +241 -56
  15. package/dist/cjs/commands/templates/app-management/app-config.js.template +2 -2
  16. package/dist/cjs/config/index.cjs +3 -3
  17. package/dist/cjs/config/index.d.cts +181 -1158
  18. package/dist/cjs/{config-ct-qMOGj.cjs → config-D-s0GSep.cjs} +4 -6
  19. package/dist/cjs/{error-C5LNOZ4f.cjs → error-D-N0PKSl.cjs} +0 -1
  20. package/dist/cjs/{index-B5WKJ3hJ.d.cts → index-B5gJ-q4U.d.cts} +172 -3
  21. package/dist/cjs/index-BXm8UbK7.d.cts +16 -0
  22. package/dist/cjs/{logging-BTevALnL.cjs → logging-BVz3weoC.cjs} +1 -1
  23. package/dist/cjs/management/index.cjs +1 -1
  24. package/dist/cjs/management/index.d.cts +2 -3
  25. package/dist/cjs/{management-D1QXg4YU.cjs → management-Dehz9qSJ.cjs} +114 -51
  26. package/dist/cjs/openapi-Cux6K4ZD.cjs +3072 -0
  27. package/dist/cjs/{router-CFErodHU.cjs → router-BOR7T6qR.cjs} +1 -1
  28. package/dist/cjs/{schemas-CukVpc19.cjs → schemas-FngDuIeo.cjs} +1 -1
  29. package/dist/cjs/{validate-b_bI4mDb.cjs → validate-oAOpyFyb.cjs} +49 -17
  30. package/dist/cjs/{webhooks-DS1BtgED.cjs → webhooks-tbZy9G3p.cjs} +4 -4
  31. package/dist/es/actions/{app-config.d.mts → app-config/index.d.mts} +11 -9
  32. package/dist/es/actions/app-config/index.mjs +199 -0
  33. package/dist/{cjs/actions/config.d.cts → es/actions/config/index.d.mts} +10 -8
  34. package/dist/es/actions/{config.mjs → config/index.mjs} +78 -45
  35. package/dist/{cjs/actions/installation.d.cts → es/actions/installation/index.d.mts} +11 -10
  36. package/dist/es/actions/{installation.mjs → installation/index.mjs} +54 -36
  37. package/dist/es/actions/{registration.d.mts → registration/index.d.mts} +8 -9
  38. package/dist/es/actions/{registration.mjs → registration/index.mjs} +16 -6
  39. package/dist/{cjs/actions/scope-tree.d.cts → es/actions/scope-tree/index.d.mts} +2 -5
  40. package/dist/es/actions/{scope-tree.mjs → scope-tree/index.mjs} +51 -14
  41. package/dist/es/{admin-ui-sdk-CCo2SWiL.d.mts → admin-ui-sdk-BwnD0xjK.d.mts} +6 -9
  42. package/dist/es/app-DrYHK-z1.d.mts +1629 -0
  43. package/dist/es/commands/index.mjs +223 -38
  44. package/dist/es/commands/templates/app-management/app-config.js.template +2 -2
  45. package/dist/es/config/index.d.mts +181 -1157
  46. package/dist/es/config/index.mjs +3 -3
  47. package/dist/es/{config-DGPFTk6w.mjs → config-3I4eLyyR.mjs} +4 -5
  48. package/dist/es/index-B0XqHwY5.d.mts +16 -0
  49. package/dist/es/{index-CCov0odd.d.mts → index-DLMbTtKS.d.mts} +172 -3
  50. package/dist/es/management/index.d.mts +2 -3
  51. package/dist/es/management/index.mjs +1 -1
  52. package/dist/es/{management-CCsOfniv.mjs → management-BUX-w2Ji.mjs} +113 -51
  53. package/dist/es/openapi-B6uP0SRn.mjs +3024 -0
  54. package/dist/es/{validate-Dn3lLTGj.mjs → validate-Dfajrp99.mjs} +37 -17
  55. package/dist/es/{webhooks-Dhrkkip7.mjs → webhooks-B5oq9ULL.mjs} +3 -3
  56. package/package.json +29 -17
  57. package/dist/cjs/actions/app-config.cjs +0 -41
  58. package/dist/cjs/app-C6kImBl7.d.cts +0 -564
  59. package/dist/cjs/step-CWYnKbga.d.cts +0 -187
  60. package/dist/es/actions/app-config.mjs +0 -39
  61. package/dist/es/app-DcY6dJiQ.d.mts +0 -564
  62. package/dist/es/step-0eI2x4C9.d.mts +0 -187
  63. /package/dist/cjs/{chunk-DS2yp5vX.cjs → chunk-Cozy-1ZF.cjs} +0 -0
  64. /package/dist/es/{error-DHlYzkbb.mjs → error-_RMwtrUA.mjs} +0 -0
  65. /package/dist/es/{logging-XIUXDK5T.mjs → logging-DbJHXSKh.mjs} +0 -0
  66. /package/dist/es/{router-BxaxEEu3.mjs → router-D58JJHHA.mjs} +0 -0
  67. /package/dist/es/{schemas-DOcnD16x.mjs → schemas-hRovglBF.mjs} +0 -0
@@ -12,12 +12,12 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
- import { n as logger, t as HttpActionRouter } from "../router-BxaxEEu3.mjs";
16
- import { r as nonEmptyStringValueSchema } from "../schemas-DOcnD16x.mjs";
17
- import { a as runValidation, c as isFailedState, i as runUninstallation, l as isInProgressState, n as createInitialUninstallationState, r as runInstallation, s as isCompletedState, t as createInitialInstallationState, u as isSucceededState } from "../management-CCsOfniv.mjs";
18
- import { accepted, badRequest, conflict, internalServerError, noContent, ok } from "@adobe/aio-commerce-lib-core/responses";
15
+ import { r as nonEmptyStringValueSchema } from "../../schemas-hRovglBF.mjs";
16
+ import { a as runValidation, c as isFailedState, i as runUninstallation, l as isInProgressState, n as createInitialUninstallationState, r as runInstallation, s as isCompletedState, t as createInitialInstallationState, u as isSucceededState } from "../../management-BUX-w2Ji.mjs";
17
+ import { t as validateCommerceAppConfig } from "../../validate-Dfajrp99.mjs";
18
+ import { n as logger, t as HttpActionRouter } from "../../router-D58JJHHA.mjs";
19
19
  import * as v from "valibot";
20
- import { object, string } from "valibot";
20
+ import { accepted, badRequest, conflict, internalServerError, noContent, ok } from "@adobe/aio-commerce-lib-core/responses";
21
21
  import { init } from "@adobe/aio-lib-files";
22
22
  import { init as init$1 } from "@adobe/aio-lib-state";
23
23
  import openwhisk from "openwhisk";
@@ -256,16 +256,19 @@ const AppDataSchema = v.object({
256
256
  });
257
257
 
258
258
  //#endregion
259
- //#region source/actions/installation.ts
260
- const DEFAULT_ACTION_NAME = "app-management/installation";
261
- /** Request body schema shared by POST / and POST /validation. */
262
- const InstallationRequestBodySchema = object({
259
+ //#region source/actions/installation/schema.ts
260
+ /** Request body for POST / and POST /validation (shared shape) */
261
+ const InstallationRequestBodySchema = v.object({
263
262
  appData: AppDataSchema,
264
- commerceBaseUrl: string(),
265
- commerceEnv: string(),
266
- ioEventsUrl: string(),
267
- ioEventsEnv: string()
263
+ commerceBaseUrl: v.string(),
264
+ commerceEnv: v.string(),
265
+ ioEventsUrl: v.string(),
266
+ ioEventsEnv: v.string()
268
267
  });
268
+
269
+ //#endregion
270
+ //#region source/actions/installation/router.ts
271
+ const DEFAULT_ACTION_NAME = "app-management/installation";
269
272
  /** Creates a workflow state store with the given prefix. */
270
273
  function createWorkflowStore(prefix) {
271
274
  return createCombinedStore({
@@ -348,14 +351,14 @@ function createInstallationHooks(store, logFn) {
348
351
  * Installation action router.
349
352
  *
350
353
  * Routes:
351
- * - GET /installation - Get current installation status
352
- * - POST /installation - Start installation (creates plan, invokes execution async)
353
- * - POST /installation/execution - Execute installation (internal, called async)
354
- * - POST /installation/validation - Pre-installation validation
355
- * - POST /installation/uninstallation - Start uninstallation (async)
356
- * - GET /installation/uninstallation - Get current uninstallation status
357
- * - POST /installation/uninstallation/execution - Execute uninstallation (internal, called async)
358
- * - DELETE /installation/uninstallation - Clear uninstallation state only (no offboarding)
354
+ * - GET / Get current installation status
355
+ * - POST / Start installation (creates plan, invokes execution async)
356
+ * - POST /execution Execute installation (internal, called async)
357
+ * - POST /validation Pre-installation validation
358
+ * - POST /uninstallation Start uninstallation (creates plan, invokes execution async)
359
+ * - GET /uninstallation Get current uninstallation status
360
+ * - POST /uninstallation/execution Execute uninstallation (internal, called async)
361
+ * - DELETE /uninstallation Clear uninstallation state only (no offboarding)
359
362
  */
360
363
  const router = new HttpActionRouter().use(logger({ name: () => "installation" }));
361
364
  /**
@@ -396,8 +399,9 @@ router.post("/", {
396
399
  }
397
400
  logger.debug("Previous installation failed, allowing retry");
398
401
  }
399
- const appConfig = rawParams.appConfig;
400
- if (!appConfig) return internalServerError("Could not find or parse the app.commerce.manifest.json file, is it present and valid?");
402
+ const rawAppConfig = rawParams.appConfig;
403
+ if (!rawAppConfig) return internalServerError("The app config is missing. Does the action receive it as a parameter?");
404
+ const appConfig = validateCommerceAppConfig(rawAppConfig);
401
405
  const initialState = createInitialInstallationState({ config: appConfig });
402
406
  logger.debug(`Created initial state: ${initialState.id}`);
403
407
  await store.put(getStorageKey(), initialState);
@@ -424,16 +428,18 @@ router.post("/", {
424
428
  }
425
429
  });
426
430
  /**
427
- * POST /installation/execution - Execute installation (internal)
431
+ * POST /installation/execution - Execute installation
432
+ * @internal - Do not add to OpenAPI Spec.
428
433
  *
429
434
  * This endpoint is called asynchronously by POST /installation.
430
435
  * It runs the actual installation workflow and saves state.
431
436
  */
432
437
  router.post("/execution", { handler: async (_req, { logger, rawParams }) => {
433
438
  const params = rawParams;
434
- const { initialState, appConfig, appData, AIO_COMMERCE_API_BASE_URL } = params;
439
+ const { initialState, appConfig: rawAppConfig, appData, AIO_COMMERCE_API_BASE_URL } = params;
435
440
  if (!initialState) return badRequest("initialState is required for execution");
436
- if (!appConfig) return badRequest("appConfig is required for execution");
441
+ if (!rawAppConfig) return badRequest("appConfig is required for execution");
442
+ const appConfig = validateCommerceAppConfig(rawAppConfig);
437
443
  const store = await createInstallationStore();
438
444
  const hooks = createInstallationHooks(store, (msg) => logger.debug(msg));
439
445
  const installationContext = buildInstallationContext(params, appConfig, logger);
@@ -469,8 +475,9 @@ router.post("/validation", {
469
475
  body: InstallationRequestBodySchema,
470
476
  handler: async (req, { logger, rawParams }) => {
471
477
  logger.debug("Running pre-installation validation...");
472
- const appConfig = rawParams.appConfig;
473
- if (!appConfig) return internalServerError("Could not find or parse the app.commerce.manifest.json file, is it present and valid?");
478
+ const rawAppConfig = rawParams.appConfig;
479
+ if (!rawAppConfig) return internalServerError("The app config is missing. Does the action receive it as a parameter?");
480
+ const appConfig = validateCommerceAppConfig(rawAppConfig);
474
481
  const { appData, ...params } = buildWorkflowParams(req.body, rawParams);
475
482
  const result = await runValidation({
476
483
  validationContext: {
@@ -508,8 +515,9 @@ router.post("/uninstallation", {
508
515
  handler: async (req, { logger, rawParams }) => {
509
516
  const { appData, commerceBaseUrl } = req.body;
510
517
  logger.debug(`Starting uninstallation for app "${appData.projectName}" (workspace: "${appData.workspaceName}", commerce: "${commerceBaseUrl}")`);
511
- const appConfig = rawParams.appConfig;
512
- if (!appConfig) return internalServerError("Could not find or parse the app.commerce.manifest.json file, is it present and valid?");
518
+ const rawAppConfig = rawParams.appConfig;
519
+ if (!rawAppConfig) return internalServerError("The app config is missing. Does the action receive it as a parameter?");
520
+ const appConfig = validateCommerceAppConfig(rawAppConfig);
513
521
  const store = await createUninstallationStore();
514
522
  const existingState = await store.get(getStorageKey());
515
523
  if (existingState && isInProgressState(existingState)) {
@@ -541,7 +549,8 @@ router.post("/uninstallation", {
541
549
  }
542
550
  });
543
551
  /**
544
- * POST /uninstallation/execution - Execute uninstallation (internal, called async by POST /uninstallation)
552
+ * POST /uninstallation/execution - Execute uninstallation
553
+ * @internal - Do not add to OpenAPI Spec.
545
554
  *
546
555
  * Flow:
547
556
  * 1. Build InstallationContext from params
@@ -552,9 +561,10 @@ router.post("/uninstallation", {
552
561
  */
553
562
  router.post("/uninstallation/execution", { handler: async (_req, { logger, rawParams }) => {
554
563
  const params = rawParams;
555
- const { initialState, appConfig, appData, AIO_COMMERCE_API_BASE_URL } = params;
564
+ const { initialState, appConfig: rawAppConfig, appData, AIO_COMMERCE_API_BASE_URL } = params;
556
565
  if (!initialState) return badRequest("initialState is required for execution");
557
- if (!appConfig) return badRequest("appConfig is required for execution");
566
+ if (!rawAppConfig) return badRequest("appConfig is required for execution");
567
+ const appConfig = validateCommerceAppConfig(rawAppConfig);
558
568
  const store = await createUninstallationStore();
559
569
  const hooks = createInstallationHooks(store, (msg) => logger.debug(msg));
560
570
  const installationContext = buildInstallationContext(params, appConfig, logger);
@@ -589,9 +599,17 @@ router.delete("/uninstallation", { handler: async (_req, { logger }) => {
589
599
  logger.debug("Uninstallation state cleared");
590
600
  return noContent();
591
601
  } });
592
- /** Factory to create the route handler for the `installation` action. */
593
- const installationRuntimeAction = ({ appConfig, customScriptsLoader }) => async (params) => {
594
- return await router.handler()({
602
+
603
+ //#endregion
604
+ //#region source/actions/installation/index.ts
605
+ /**
606
+ * Factory to create the route handler for the `installation` action.
607
+ * @param args - The arguments required to create the runtime action.
608
+ */
609
+ const installationRuntimeAction = (args) => async (params) => {
610
+ const handler = router.handler();
611
+ const { appConfig, customScriptsLoader } = args;
612
+ return await handler({
595
613
  ...params,
596
614
  appConfig,
597
615
  customScriptsLoader
@@ -12,22 +12,21 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
- import { n as AdminUiSdkRegistration } from "../admin-ui-sdk-CCo2SWiL.mjs";
16
- import * as _$_adobe_aio_commerce_lib_core_responses0 from "@adobe/aio-commerce-lib-core/responses";
15
+ import { n as AdminUiSdkRegistration } from "../../admin-ui-sdk-BwnD0xjK.mjs";
17
16
  import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
18
17
 
19
- //#region source/actions/registration.d.ts
20
- /** Arguments for the registration runtime action factory. */
21
- type RegistrationActionArgs = {
18
+ //#region source/actions/registration/router.d.ts
19
+ /** The arguments required to create the runtime action for the registration action. */
20
+ type RuntimeActionFactoryArgs = {
22
21
  registration: AdminUiSdkRegistration;
23
22
  };
23
+ //#endregion
24
+ //#region source/actions/registration/index.d.ts
24
25
  /**
25
26
  * Factory to create the route handler for the `registration` action.
26
- * @param args - The registration configuration to inline in the action.
27
+ * @param args - The arguments required to create the runtime action.
27
28
  * @experimental
28
29
  */
29
- declare const registrationRuntimeAction: ({
30
- registration
31
- }: RegistrationActionArgs) => (params: RuntimeActionParams) => Promise<_$_adobe_aio_commerce_lib_core_responses0.ActionResponse>;
30
+ declare const registrationRuntimeAction: (args: RuntimeActionFactoryArgs) => (params: RuntimeActionParams) => Promise<import("@adobe/aio-commerce-lib-core/responses").ActionResponse>;
32
31
  //#endregion
33
32
  export { registrationRuntimeAction };
@@ -12,24 +12,34 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
- import { n as logger, t as HttpActionRouter } from "../router-BxaxEEu3.mjs";
15
+ import { n as logger, t as HttpActionRouter } from "../../router-D58JJHHA.mjs";
16
16
  import { ok } from "@adobe/aio-commerce-lib-core/responses";
17
17
 
18
- //#region source/actions/registration.ts
19
- /** Router for the registration action. */
18
+ //#region source/actions/registration/router.ts
19
+ /**
20
+ * Registration action router.
21
+ *
22
+ * Routes:
23
+ * - GET / Retrieve the Admin UI SDK registration.
24
+ */
20
25
  const router = new HttpActionRouter().use(logger({ name: () => "registration" }));
21
26
  /** GET / - Return Admin UI SDK registration object */
22
27
  router.get("/", { handler: async (_req, { logger, rawParams }) => {
23
28
  logger.debug("Returning Admin UI SDK registration...");
24
29
  return ok({ body: { registration: rawParams.registration } });
25
30
  } });
31
+
32
+ //#endregion
33
+ //#region source/actions/registration/index.ts
26
34
  /**
27
35
  * Factory to create the route handler for the `registration` action.
28
- * @param args - The registration configuration to inline in the action.
36
+ * @param args - The arguments required to create the runtime action.
29
37
  * @experimental
30
38
  */
31
- const registrationRuntimeAction = ({ registration }) => async (params) => {
32
- return await router.handler()({
39
+ const registrationRuntimeAction = (args) => async (params) => {
40
+ const handler = router.handler();
41
+ const { registration } = args;
42
+ return await handler({
33
43
  ...params,
34
44
  registration
35
45
  });
@@ -12,11 +12,8 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
- import * as _$_adobe_aio_commerce_lib_core_responses0 from "@adobe/aio-commerce-lib-core/responses";
16
- import * as _$_adobe_aio_commerce_lib_core_params0 from "@adobe/aio-commerce-lib-core/params";
17
-
18
- //#region source/actions/scope-tree.d.ts
15
+ //#region source/actions/scope-tree/index.d.ts
19
16
  /** The handler method for the `scope-tree` action. */
20
- declare const scopeTreeRuntimeAction: (args: _$_adobe_aio_commerce_lib_core_params0.RuntimeActionParams) => Promise<_$_adobe_aio_commerce_lib_core_responses0.ActionResponse>;
17
+ declare const scopeTreeRuntimeAction: (args: import("@adobe/aio-commerce-lib-core/params").RuntimeActionParams) => Promise<import("@adobe/aio-commerce-lib-core/responses").ActionResponse>;
21
18
  //#endregion
22
19
  export { scopeTreeRuntimeAction };
@@ -12,16 +12,44 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
- import { n as logger, t as HttpActionRouter } from "../router-BxaxEEu3.mjs";
16
- import { r as nonEmptyStringValueSchema } from "../schemas-DOcnD16x.mjs";
17
- import { t as inspect } from "../logging-XIUXDK5T.mjs";
18
- import { internalServerError, nonAuthoritativeInformation, ok } from "@adobe/aio-commerce-lib-core/responses";
19
- import * as v from "valibot";
15
+ import { r as nonEmptyStringValueSchema } from "../../schemas-hRovglBF.mjs";
16
+ import { t as inspect } from "../../logging-DbJHXSKh.mjs";
17
+ import { n as logger, t as HttpActionRouter } from "../../router-D58JJHHA.mjs";
20
18
  import { getScopeTree, setCustomScopeTree, syncCommerceScopes, unsyncCommerceScopes } from "@adobe/aio-commerce-lib-config";
19
+ import * as v from "valibot";
21
20
  import { resolveCommerceHttpClientParams } from "@adobe/aio-commerce-lib-api";
21
+ import { badRequest, internalServerError, nonAuthoritativeInformation, ok } from "@adobe/aio-commerce-lib-core/responses";
22
+
23
+ //#region source/actions/scope-tree/schema.ts
24
+ const CustomScopeInputSchema = v.object({
25
+ id: v.optional(v.string()),
26
+ code: v.string(),
27
+ label: v.string(),
28
+ level: v.optional(v.string()),
29
+ is_editable: v.boolean(),
30
+ is_final: v.boolean(),
31
+ children: v.optional(v.array(v.lazy(() => CustomScopeInputSchema)))
32
+ });
33
+ /** Request body for PUT / */
34
+ const SetCustomScopeTreeBodySchema = v.object({ scopes: v.array(CustomScopeInputSchema) });
35
+ /** Request body for POST /commerce */
36
+ const SyncCommerceScopesBodySchema = v.object({
37
+ commerceBaseUrl: nonEmptyStringValueSchema("commerceBaseUrl"),
38
+ commerceEnv: v.optional(nonEmptyStringValueSchema("commerceEnv"))
39
+ });
22
40
 
23
- //#region source/actions/scope-tree.ts
24
- const router = new HttpActionRouter().use(logger());
41
+ //#endregion
42
+ //#region source/actions/scope-tree/router.ts
43
+ /**
44
+ * Scope Tree action router.
45
+ *
46
+ * Routes:
47
+ * - GET / Retrieve the scope tree.
48
+ * - PUT / Set custom scope tree.
49
+ * - POST /commerce Sync commerce scopes
50
+ * - DELETE /commerce Unsync commerce scopes
51
+ */
52
+ const router = new HttpActionRouter().use(logger({ name: () => "scope-tree" }));
25
53
  /** GET / - Get scope tree */
26
54
  router.get("/", { handler: async (_req, ctx) => {
27
55
  const { logger } = ctx;
@@ -33,15 +61,24 @@ router.get("/", { handler: async (_req, ctx) => {
33
61
  });
34
62
  return ok({ body: { scopes: result.scopeTree } });
35
63
  } });
36
- /** POST / - Set custom scope tree */
64
+ /** PUT / - Set custom scope tree */
37
65
  router.put("/", {
38
- body: v.object({ scopes: v.array(v.any()) }),
66
+ body: SetCustomScopeTreeBodySchema,
39
67
  handler: async (req, ctx) => {
40
68
  const { logger } = ctx;
41
69
  logger.debug(`Setting custom scope tree with ${req.body.scopes?.length || 0} scopes`);
42
70
  const request = { scopes: req.body.scopes };
71
+ let result;
43
72
  logger.debug(`Setting custom scope tree: ${inspect(request)}`);
44
- const result = await setCustomScopeTree(request);
73
+ try {
74
+ result = await setCustomScopeTree(request);
75
+ } catch (err) {
76
+ if (err instanceof Error && "isValidationError" in err) {
77
+ logger.debug(`Custom scope tree validation failed: ${err.message}`);
78
+ return badRequest({ body: { message: err.message } });
79
+ }
80
+ throw err;
81
+ }
45
82
  logger.debug(`Successfully set custom scope tree: ${inspect(result)}`);
46
83
  return ok({
47
84
  body: { result },
@@ -51,10 +88,7 @@ router.put("/", {
51
88
  });
52
89
  /** POST /commerce - Sync commerce scopes */
53
90
  router.post("/commerce", {
54
- body: v.object({
55
- commerceBaseUrl: nonEmptyStringValueSchema("commerceBaseUrl"),
56
- commerceEnv: v.optional(nonEmptyStringValueSchema("commerceEnv"))
57
- }),
91
+ body: SyncCommerceScopesBodySchema,
58
92
  handler: async (req, ctx) => {
59
93
  const { logger } = ctx;
60
94
  logger.debug("Syncing commerce scopes...");
@@ -102,6 +136,9 @@ router.delete("/commerce", { handler: async (_req, ctx) => {
102
136
  logger.debug(message);
103
137
  return ok(message);
104
138
  } });
139
+
140
+ //#endregion
141
+ //#region source/actions/scope-tree/index.ts
105
142
  /** The handler method for the `scope-tree` action. */
106
143
  const scopeTreeRuntimeAction = router.handler();
107
144
 
@@ -12,16 +12,9 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
- import { n as CommerceAppConfigOutputModel } from "./app-DcY6dJiQ.mjs";
15
+ import { r as CommerceAppConfigOutputModel, t as AnyCommerceAppConfig } from "./app-DrYHK-z1.mjs";
16
16
  import * as v from "valibot";
17
- import { AdobeCommerceHttpClient } from "@adobe/aio-commerce-lib-api";
18
17
 
19
- //#region source/management/installation/admin-ui-sdk/utils.d.ts
20
- /** Config type when Admin UI SDK registration is configured. */
21
- type AdminUiSdkConfig = CommerceAppConfigOutputModel & {
22
- adminUiSdk: NonNullable<CommerceAppConfigOutputModel["adminUiSdk"]>;
23
- };
24
- //#endregion
25
18
  //#region source/config/schema/admin-ui-sdk.d.ts
26
19
  declare const GridColumnsSchema: v.ObjectSchema<{
27
20
  readonly data: v.ObjectSchema<{
@@ -658,10 +651,14 @@ type BannerNotification = v.InferInput<typeof BannerNotificationSchema>;
658
651
  * @experimental
659
652
  */
660
653
  type MenuItem = v.InferInput<typeof MenuItemSchema>;
654
+ /** Config type when Admin UI SDK registration is configured. */
655
+ type AppConfigWithAdminUiSdk<T extends AnyCommerceAppConfig = CommerceAppConfigOutputModel> = T & {
656
+ adminUiSdk: NonNullable<T["adminUiSdk"]>;
657
+ };
661
658
  /**
662
659
  * Check if config has Admin UI SDK registration configuration.
663
660
  * @experimental
664
661
  */
665
- declare function hasAdminUiSdk(config: CommerceAppConfigOutputModel): config is AdminUiSdkConfig;
662
+ declare function hasAdminUiSdk<T extends AnyCommerceAppConfig>(config: T): config is T & AppConfigWithAdminUiSdk<T>;
666
663
  //#endregion
667
664
  export { CustomerMassAction as a, OrderMassAction as c, hasAdminUiSdk as d, CustomFee as i, OrderViewButton as l, AdminUiSdkRegistration as n, GridColumns as o, BannerNotification as r, MenuItem as s, AdminUiSdkConfiguration as t, ProductMassAction as u };