@adobe/aio-commerce-lib-app 1.6.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 (54) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/cjs/actions/app-config/index.cjs +202 -0
  3. package/dist/cjs/actions/app-config/index.d.cts +31 -0
  4. package/dist/cjs/actions/{config.cjs → config/index.cjs} +61 -33
  5. package/dist/{es/actions/config.d.mts → cjs/actions/config/index.d.cts} +10 -7
  6. package/dist/cjs/actions/{installation.cjs → installation/index.cjs} +43 -30
  7. package/dist/{es/actions/installation.d.mts → cjs/actions/installation/index.d.cts} +10 -8
  8. package/dist/cjs/actions/{registration.cjs → registration/index.cjs} +16 -6
  9. package/dist/cjs/actions/{registration.d.cts → registration/index.d.cts} +8 -8
  10. package/dist/cjs/actions/{scope-tree.cjs → scope-tree/index.cjs} +51 -14
  11. package/dist/cjs/actions/{scope-tree.d.cts → scope-tree/index.d.cts} +1 -1
  12. package/dist/cjs/{admin-ui-sdk-DZZJCrdT.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 +12 -18
  15. package/dist/cjs/config/index.cjs +2 -2
  16. package/dist/cjs/config/index.d.cts +36 -976
  17. package/dist/cjs/{config-FNMclIFO.cjs → config-D-s0GSep.cjs} +1 -1
  18. package/dist/cjs/{index-Dw2NvVOY.d.cts → index-B5gJ-q4U.d.cts} +172 -3
  19. package/dist/{es/actions/app-config.d.mts → cjs/index-BXm8UbK7.d.cts} +1 -13
  20. package/dist/cjs/management/index.cjs +1 -1
  21. package/dist/cjs/management/index.d.cts +1 -2
  22. package/dist/cjs/{management-Cvsz4VMf.cjs → management-Dehz9qSJ.cjs} +81 -43
  23. package/dist/cjs/openapi-Cux6K4ZD.cjs +3072 -0
  24. package/dist/cjs/{validate-DydOAZha.cjs → validate-oAOpyFyb.cjs} +46 -14
  25. package/dist/es/actions/app-config/index.d.mts +31 -0
  26. package/dist/es/actions/app-config/index.mjs +199 -0
  27. package/dist/{cjs/actions/config.d.cts → es/actions/config/index.d.mts} +10 -7
  28. package/dist/es/actions/{config.mjs → config/index.mjs} +60 -32
  29. package/dist/{cjs/actions/installation.d.cts → es/actions/installation/index.d.mts} +10 -8
  30. package/dist/es/actions/{installation.mjs → installation/index.mjs} +42 -30
  31. package/dist/es/actions/{registration.d.mts → registration/index.d.mts} +8 -8
  32. package/dist/es/actions/{registration.mjs → registration/index.mjs} +16 -6
  33. package/dist/es/actions/{scope-tree.d.mts → scope-tree/index.d.mts} +1 -1
  34. package/dist/es/actions/{scope-tree.mjs → scope-tree/index.mjs} +50 -13
  35. package/dist/es/{admin-ui-sdk-hu6iWr0A.d.mts → admin-ui-sdk-BwnD0xjK.d.mts} +6 -9
  36. package/dist/es/app-DrYHK-z1.d.mts +1629 -0
  37. package/dist/es/commands/index.mjs +12 -18
  38. package/dist/es/config/index.d.mts +36 -975
  39. package/dist/es/config/index.mjs +2 -2
  40. package/dist/es/{config-CcE0EBG7.mjs → config-3I4eLyyR.mjs} +1 -1
  41. package/dist/{cjs/actions/app-config.d.cts → es/index-B0XqHwY5.d.mts} +2 -14
  42. package/dist/es/{index-Bo0tQsVq.d.mts → index-DLMbTtKS.d.mts} +172 -3
  43. package/dist/es/management/index.d.mts +1 -2
  44. package/dist/es/management/index.mjs +1 -1
  45. package/dist/es/{management-BZ4Y6lVp.mjs → management-BUX-w2Ji.mjs} +81 -44
  46. package/dist/es/openapi-B6uP0SRn.mjs +3024 -0
  47. package/dist/es/{validate-Du3LhCre.mjs → validate-Dfajrp99.mjs} +35 -15
  48. package/package.json +17 -10
  49. package/dist/cjs/actions/app-config.cjs +0 -54
  50. package/dist/cjs/app-CakwxQvs.d.cts +0 -673
  51. package/dist/cjs/step-CKVE0aJi.d.cts +0 -187
  52. package/dist/es/actions/app-config.mjs +0 -53
  53. package/dist/es/app-CakwxQvs.d.mts +0 -673
  54. package/dist/es/step-D64mMPrt.d.mts +0 -187
@@ -12,21 +12,21 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
- import { n as AdminUiSdkRegistration } from "../admin-ui-sdk-hu6iWr0A.mjs";
15
+ import { n as AdminUiSdkRegistration } from "../../admin-ui-sdk-BwnD0xjK.mjs";
16
16
  import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
17
17
 
18
- //#region source/actions/registration.d.ts
19
- /** Arguments for the registration runtime action factory. */
20
- 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 = {
21
21
  registration: AdminUiSdkRegistration;
22
22
  };
23
+ //#endregion
24
+ //#region source/actions/registration/index.d.ts
23
25
  /**
24
26
  * Factory to create the route handler for the `registration` action.
25
- * @param args - The registration configuration to inline in the action.
27
+ * @param args - The arguments required to create the runtime action.
26
28
  * @experimental
27
29
  */
28
- declare const registrationRuntimeAction: ({
29
- registration
30
- }: RegistrationActionArgs) => (params: RuntimeActionParams) => Promise<import("@adobe/aio-commerce-lib-core/responses").ActionResponse>;
30
+ declare const registrationRuntimeAction: (args: RuntimeActionFactoryArgs) => (params: RuntimeActionParams) => Promise<import("@adobe/aio-commerce-lib-core/responses").ActionResponse>;
31
31
  //#endregion
32
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-D58JJHHA.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,7 +12,7 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
- //#region source/actions/scope-tree.d.ts
15
+ //#region source/actions/scope-tree/index.d.ts
16
16
  /** The handler method for the `scope-tree` action. */
17
17
  declare const scopeTreeRuntimeAction: (args: import("@adobe/aio-commerce-lib-core/params").RuntimeActionParams) => Promise<import("@adobe/aio-commerce-lib-core/responses").ActionResponse>;
18
18
  //#endregion
@@ -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-D58JJHHA.mjs";
16
- import { r as nonEmptyStringValueSchema } from "../schemas-hRovglBF.mjs";
17
- import { t as inspect } from "../logging-DbJHXSKh.mjs";
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";
18
18
  import { getScopeTree, setCustomScopeTree, syncCommerceScopes, unsyncCommerceScopes } from "@adobe/aio-commerce-lib-config";
19
- import { internalServerError, nonAuthoritativeInformation, ok } from "@adobe/aio-commerce-lib-core/responses";
20
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
22
 
23
- //#region source/actions/scope-tree.ts
24
- const router = new HttpActionRouter().use(logger());
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
+ });
40
+
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-CakwxQvs.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 };