@adobe/aio-commerce-lib-app 1.6.0 → 1.8.0-beta-20260714082406

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 (110) hide show
  1. package/CHANGELOG.md +106 -0
  2. package/dist/cjs/actions/app-config/index.cjs +205 -0
  3. package/dist/cjs/actions/{app-config.d.cts → app-config/index.d.cts} +10 -7
  4. package/dist/cjs/actions/association/index.cjs +85 -0
  5. package/dist/cjs/actions/association/index.d.cts +28 -0
  6. package/dist/cjs/actions/{config.cjs → config/index.cjs} +70 -53
  7. package/dist/{es/actions/config.d.mts → cjs/actions/config/index.d.cts} +10 -7
  8. package/dist/cjs/actions/{installation.cjs → installation/index.cjs} +106 -72
  9. package/dist/{es/actions/installation.d.mts → cjs/actions/installation/index.d.cts} +10 -8
  10. package/dist/cjs/actions/{scope-tree.cjs → scope-tree/index.cjs} +60 -22
  11. package/dist/cjs/actions/{scope-tree.d.cts → scope-tree/index.d.cts} +1 -1
  12. package/dist/cjs/app-D3P-Z6uY.d.cts +1679 -0
  13. package/dist/cjs/association-repository-BAs3-VkW.cjs +69 -0
  14. package/dist/cjs/commands/index.cjs +517 -309
  15. package/dist/cjs/commands/templates/admin-ui/tsconfig.json +14 -0
  16. package/dist/cjs/commands/templates/admin-ui/web-src/index.css +5 -0
  17. package/dist/cjs/commands/templates/admin-ui/web-src/index.html +17 -0
  18. package/dist/cjs/commands/templates/admin-ui/web-src/src/app.jsx +13 -0
  19. package/dist/cjs/commands/templates/admin-ui/web-src/src/components/welcome.jsx +12 -0
  20. package/dist/cjs/commands/templates/admin-ui/web-src/src/pages/main-page.jsx +10 -0
  21. package/dist/cjs/commands/templates/{admin-ui-sdk/registration.js.template → admin-ui/web-src-template.d.ts} +11 -6
  22. package/dist/cjs/commands/templates/app-management/app-config.js.template +1 -14
  23. package/dist/cjs/commands/templates/app-management/association.js.template +6 -0
  24. package/dist/cjs/commands/templates/app-management/installation.js.template +1 -13
  25. package/dist/cjs/commands/templates/business-configuration/config.js.template +2 -15
  26. package/dist/cjs/commands/templates/business-configuration/scope-tree.js.template +0 -12
  27. package/dist/cjs/config/index.browser.cjs +18 -0
  28. package/dist/cjs/config/index.browser.d.cts +16 -0
  29. package/dist/cjs/config/{index.cjs → index.node.cjs} +9 -8
  30. package/dist/cjs/config/index.node.d.cts +1603 -0
  31. package/dist/cjs/define-DBxAlJfN.d.cts +34 -0
  32. package/dist/cjs/define-hlcQw7Cv.cjs +41 -0
  33. package/dist/cjs/environment-B7EnozSg.cjs +135 -0
  34. package/dist/cjs/index-BXm8UbK7.d.cts +16 -0
  35. package/dist/cjs/{index-Dw2NvVOY.d.cts → index-CzReNwbF.d.cts} +177 -3
  36. package/dist/cjs/index.cjs +250 -0
  37. package/dist/cjs/index.d.cts +217 -0
  38. package/dist/cjs/{config-FNMclIFO.cjs → index.node-Dz4lV4qe.cjs} +119 -35
  39. package/dist/cjs/{logging-BVz3weoC.cjs → logging-udPuAJPt.cjs} +2 -2
  40. package/dist/cjs/management/index.cjs +1 -1
  41. package/dist/cjs/management/index.d.cts +1 -2
  42. package/dist/cjs/{management-Cvsz4VMf.cjs → management-B9ItB80R.cjs} +432 -591
  43. package/dist/cjs/openapi-CwytYdWl.cjs +2948 -0
  44. package/dist/cjs/{router-BOR7T6qR.cjs → router-hA_Y9gZ1.cjs} +42 -44
  45. package/dist/cjs/{schemas-FngDuIeo.cjs → schemas-mLxMh_ko.cjs} +2 -2
  46. package/dist/cjs/utils-DSCmZ_iJ.cjs +408 -0
  47. package/dist/cjs/{validate-DydOAZha.cjs → validate-BfxhZ5Wv.cjs} +63 -31
  48. package/dist/cjs/{webhooks-tbZy9G3p.cjs → webhooks-B5tb9NeF.cjs} +159 -151
  49. package/dist/es/actions/{app-config.d.mts → app-config/index.d.mts} +10 -7
  50. package/dist/es/actions/app-config/index.mjs +202 -0
  51. package/dist/es/actions/association/index.d.mts +28 -0
  52. package/dist/es/actions/association/index.mjs +82 -0
  53. package/dist/{cjs/actions/config.d.cts → es/actions/config/index.d.mts} +10 -7
  54. package/dist/es/actions/{config.mjs → config/index.mjs} +67 -50
  55. package/dist/{cjs/actions/installation.d.cts → es/actions/installation/index.d.mts} +10 -8
  56. package/dist/es/actions/{installation.mjs → installation/index.mjs} +104 -71
  57. package/dist/es/actions/{scope-tree.d.mts → scope-tree/index.d.mts} +1 -1
  58. package/dist/es/actions/{scope-tree.mjs → scope-tree/index.mjs} +58 -20
  59. package/dist/es/app-D3P-Z6uY.d.mts +1679 -0
  60. package/dist/es/association-repository-BbQv9WCl.mjs +52 -0
  61. package/dist/es/commands/index.mjs +550 -340
  62. package/dist/es/commands/templates/admin-ui/tsconfig.json +14 -0
  63. package/dist/es/commands/templates/admin-ui/web-src/index.css +5 -0
  64. package/dist/es/commands/templates/admin-ui/web-src/index.html +17 -0
  65. package/dist/es/commands/templates/admin-ui/web-src/src/app.jsx +13 -0
  66. package/dist/es/commands/templates/admin-ui/web-src/src/components/welcome.jsx +12 -0
  67. package/dist/es/commands/templates/admin-ui/web-src/src/pages/main-page.jsx +10 -0
  68. package/dist/es/commands/templates/{admin-ui-sdk/registration.js.template → admin-ui/web-src-template.d.ts} +11 -6
  69. package/dist/es/commands/templates/app-management/app-config.js.template +1 -14
  70. package/dist/es/commands/templates/app-management/association.js.template +6 -0
  71. package/dist/es/commands/templates/app-management/installation.js.template +1 -13
  72. package/dist/es/commands/templates/business-configuration/config.js.template +2 -15
  73. package/dist/es/commands/templates/business-configuration/scope-tree.js.template +0 -12
  74. package/dist/es/config/index.browser.d.mts +16 -0
  75. package/dist/es/config/index.browser.mjs +17 -0
  76. package/dist/es/config/index.node.d.mts +1604 -0
  77. package/dist/es/config/index.node.mjs +20 -0
  78. package/dist/es/define-EoYRZbpe.d.mts +34 -0
  79. package/dist/es/define-Z_Glf1-_.mjs +35 -0
  80. package/dist/es/environment-C84BPRJZ.mjs +104 -0
  81. package/dist/es/index-B0XqHwY5.d.mts +16 -0
  82. package/dist/es/{index-Bo0tQsVq.d.mts → index-D52xglhZ.d.mts} +177 -3
  83. package/dist/es/index.d.mts +217 -0
  84. package/dist/es/index.mjs +242 -0
  85. package/dist/es/{config-CcE0EBG7.mjs → index.node-CDH5gwJE.mjs} +94 -30
  86. package/dist/es/management/index.d.mts +1 -2
  87. package/dist/es/management/index.mjs +1 -1
  88. package/dist/es/{management-BZ4Y6lVp.mjs → management-B89ApQVY.mjs} +402 -562
  89. package/dist/es/openapi-CXonvevE.mjs +2900 -0
  90. package/dist/es/{router-D58JJHHA.mjs → router-B_h0cvjc.mjs} +40 -42
  91. package/dist/es/utils-_gj8L6eN.mjs +289 -0
  92. package/dist/es/{validate-Du3LhCre.mjs → validate-9cRZWGrA.mjs} +49 -29
  93. package/dist/es/{webhooks-B5oq9ULL.mjs → webhooks-BBPbY2mb.mjs} +150 -142
  94. package/package.json +52 -22
  95. package/dist/cjs/actions/app-config.cjs +0 -54
  96. package/dist/cjs/actions/registration.cjs +0 -40
  97. package/dist/cjs/actions/registration.d.cts +0 -32
  98. package/dist/cjs/admin-ui-sdk-DZZJCrdT.d.cts +0 -665
  99. package/dist/cjs/app-CakwxQvs.d.cts +0 -673
  100. package/dist/cjs/config/index.d.cts +0 -1975
  101. package/dist/cjs/step-CKVE0aJi.d.cts +0 -187
  102. package/dist/es/actions/app-config.mjs +0 -53
  103. package/dist/es/actions/registration.d.mts +0 -32
  104. package/dist/es/actions/registration.mjs +0 -39
  105. package/dist/es/admin-ui-sdk-hu6iWr0A.d.mts +0 -667
  106. package/dist/es/app-CakwxQvs.d.mts +0 -673
  107. package/dist/es/config/index.d.mts +0 -1975
  108. package/dist/es/config/index.mjs +0 -19
  109. package/dist/es/step-D64mMPrt.d.mts +0 -187
  110. /package/dist/cjs/{chunk-Cozy-1ZF.cjs → rolldown-runtime-Cozy-1ZF.cjs} +0 -0
@@ -0,0 +1,20 @@
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 { t as defineConfig } from "../define-Z_Glf1-_.mjs";
16
+ import { n as readCommerceAppConfig, r as resolveCommerceAppConfig, t as parseCommerceAppConfig } from "../index.node-CDH5gwJE.mjs";
17
+ import { a as hasCustomInstallationSteps, c as hasEventing, d as hasAdminUi, i as hasCustomInstallation, l as hasExternalEvents, n as hasWebhooks, s as hasCommerceEvents } from "../webhooks-BBPbY2mb.mjs";
18
+ import { a as CommerceAppConfigSchemas, c as hasMetadata, l as hasBusinessConfig, n as validateCommerceAppConfigDomain, o as getConfigDomains, s as hasConfigDomain, t as validateCommerceAppConfig, u as hasBusinessConfigSchema } from "../validate-9cRZWGrA.mjs";
19
+
20
+ export { CommerceAppConfigSchemas, defineConfig, getConfigDomains, hasAdminUi, hasBusinessConfig, hasBusinessConfigSchema, hasCommerceEvents, hasConfigDomain, hasCustomInstallation, hasCustomInstallationSteps, hasEventing, hasExternalEvents, hasMetadata, hasWebhooks, parseCommerceAppConfig, readCommerceAppConfig, resolveCommerceAppConfig, validateCommerceAppConfig, validateCommerceAppConfigDomain };
@@ -0,0 +1,34 @@
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 CommerceAppConfig } from "./app-D3P-Z6uY.mjs";
16
+
17
+ //#region source/config/lib/define.d.ts
18
+ /**
19
+ * Helper to type-safely define the app config.
20
+ * @param config - The app config to define.
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * import { defineConfig } from "@adobe/aio-commerce-lib-app";
25
+ *
26
+ * // In app.commerce.config.js
27
+ * export default defineConfig({
28
+ * // You get autocompletion and type-safety for the config object.
29
+ * businessConfig: { ... }
30
+ * });
31
+ */
32
+ declare function defineConfig<const T extends CommerceAppConfig>(config: T): T;
33
+ //#endregion
34
+ export { defineConfig as t };
@@ -0,0 +1,35 @@
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
+ //#region source/config/lib/define.ts
16
+ /**
17
+ * Helper to type-safely define the app config.
18
+ * @param config - The app config to define.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * import { defineConfig } from "@adobe/aio-commerce-lib-app";
23
+ *
24
+ * // In app.commerce.config.js
25
+ * export default defineConfig({
26
+ * // You get autocompletion and type-safety for the config object.
27
+ * businessConfig: { ... }
28
+ * });
29
+ */
30
+ function defineConfig(config) {
31
+ return config;
32
+ }
33
+
34
+ //#endregion
35
+ export { defineConfig as t };
@@ -0,0 +1,104 @@
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 { CommerceSdkValidationError } from "@adobe/aio-commerce-lib-core/error";
16
+ import * as v from "valibot";
17
+ import { CommerceEnvSchema } from "@adobe/aio-commerce-lib-core/commerce";
18
+
19
+ //#region ../../packages-private/common-utils/source/valibot/utils.ts
20
+ /**
21
+ * Parses the input using the provided schema and throws a {@link CommerceSdkValidationError} error if the input is invalid.
22
+ * @param schema - The schema to use for parsing.
23
+ * @param input - The input to parse.
24
+ * @param message - Optional custom error message for the validation error.
25
+ */
26
+ function parseOrThrow(schema, input, message) {
27
+ const result = v.safeParse(schema, input);
28
+ if (!result.success) throw new CommerceSdkValidationError(message ?? "Invalid input", { issues: result.issues });
29
+ return result.output;
30
+ }
31
+
32
+ //#endregion
33
+ //#region source/config/lib/environment.ts
34
+ /**
35
+ * Returns true when an item applies to the given Commerce environment: either it
36
+ * declares no `env` (applies to all environments) or its `env` list includes the
37
+ * environment. This is the single keep-rule shared by install-time filtering and
38
+ * the environment-filtered `app-config` display path.
39
+ *
40
+ * @param item - The webhook or event entry, which may carry an optional `env` array.
41
+ * @param env - The target Commerce environment (e.g. `"paas"` or `"saas"`).
42
+ */
43
+ function appliesToEnv(item, env) {
44
+ return item.env === void 0 || item.env.includes(env);
45
+ }
46
+ /**
47
+ * Reads and validates the target Commerce environment from the install workflow params,
48
+ * where the router maps the request's `commerceEnv` onto `AIO_COMMERCE_API_FLAVOR`.
49
+ * Throws if the value is absent or not a recognised Commerce environment.
50
+ *
51
+ * @param params - The runtime action params available to install steps.
52
+ */
53
+ function getInstallCommerceEnv(params) {
54
+ return parseOrThrow(CommerceEnvSchema, params.AIO_COMMERCE_API_FLAVOR, "Missing or unknown commerce environment");
55
+ }
56
+ /**
57
+ * Filters a provider list to the given environment: each provider keeps only its
58
+ * applicable events, and providers left with no events are dropped entirely.
59
+ */
60
+ function filterProvidersByEnv(providers, env) {
61
+ return providers.map((provider) => ({
62
+ ...provider,
63
+ events: provider.events.filter((event) => appliesToEnv(event, env))
64
+ })).filter((provider) => provider.events.length > 0);
65
+ }
66
+ /**
67
+ * Returns a copy of a validated app config scoped to the given Commerce environment:
68
+ * business-config fields and webhooks not applicable to the environment are removed,
69
+ * each event provider keeps only its applicable events, and providers left with no
70
+ * events are dropped. Uses the same `appliesToEnv` keep-rule as the `config` action,
71
+ * so the `app-config` action renders the same scoped set that the rest of the SDK
72
+ * (install and `config`) applies.
73
+ *
74
+ * @param config - The validated app config.
75
+ * @param env - The target Commerce environment (e.g. `"paas"` or `"saas"`).
76
+ */
77
+ function filterAppConfigByEnv(config, env) {
78
+ const filtered = { ...config };
79
+ if (filtered.businessConfig && Array.isArray(filtered.businessConfig.schema)) filtered.businessConfig = {
80
+ ...filtered.businessConfig,
81
+ schema: filtered.businessConfig.schema.filter((field) => appliesToEnv(field, env))
82
+ };
83
+ if (Array.isArray(filtered.webhooks)) filtered.webhooks = filtered.webhooks.filter((webhook) => appliesToEnv(webhook, env));
84
+ if (filtered.eventing) filtered.eventing = {
85
+ ...filtered.eventing,
86
+ ...filtered.eventing.commerce && { commerce: filterProvidersByEnv(filtered.eventing.commerce, env) },
87
+ ...filtered.eventing.external && { external: filterProvidersByEnv(filtered.eventing.external, env) }
88
+ };
89
+ return filtered;
90
+ }
91
+ /**
92
+ * Filters a business configuration schema to the fields applicable to the
93
+ * given Commerce environment. Fields without an `env` property apply to all
94
+ * environments and are always included.
95
+ *
96
+ * @param schema - The business configuration schema to filter.
97
+ * @param env - The Commerce environment to filter by.
98
+ */
99
+ function filterSchemaByEnv(schema, env) {
100
+ return schema.filter((field) => appliesToEnv(field, env));
101
+ }
102
+
103
+ //#endregion
104
+ export { parseOrThrow as a, getInstallCommerceEnv as i, filterAppConfigByEnv as n, filterSchemaByEnv as r, appliesToEnv as t };
@@ -0,0 +1,16 @@
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 AioLogger from "@adobe/aio-lib-core-logging";
16
+ import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
@@ -12,9 +12,178 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
- import { n as CommerceAppConfigOutputModel } from "./app-CakwxQvs.mjs";
16
- import { f as StepMetaInfo, h as ValidationIssue, i as ExecutionContext, n as BranchStep, o as InstallationContext, p as ValidationContext } from "./step-D64mMPrt.mjs";
15
+ import { r as CommerceAppConfigOutputModel } from "./app-D3P-Z6uY.mjs";
16
+ import * as v from "valibot";
17
+ import AioLogger from "@adobe/aio-lib-core-logging";
18
+ import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
17
19
 
20
+ //#region source/management/installation/schema.d.ts
21
+ /** Schema for validating Adobe I/O app credentials required for installation. */
22
+ declare const AppDataSchema: v.ObjectSchema<{
23
+ readonly consumerOrgId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
24
+ readonly orgName: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
25
+ readonly projectId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
26
+ readonly projectName: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
27
+ readonly projectTitle: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
28
+ readonly workspaceId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
29
+ readonly workspaceName: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
30
+ readonly workspaceTitle: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
31
+ }, undefined>;
32
+ /** Type for Adobe I/O app credentials. */
33
+ type AppData = v.InferOutput<typeof AppDataSchema>;
34
+ //#endregion
35
+ //#region source/management/installation/workflow/step.d.ts
36
+ /** Severity level of a validation issue. */
37
+ type ValidationIssueSeverity = "error" | "warning" | "info";
38
+ /** A single validation issue reported by a step's validate handler. */
39
+ type ValidationIssue = {
40
+ /** Machine-readable code identifying the issue type. */code: string; /** Human-readable description of the issue. */
41
+ message: string; /** Severity of the issue. Only "error" severity blocks installation. */
42
+ severity: ValidationIssueSeverity; /** Optional additional context about the issue. */
43
+ details?: Record<string, unknown>;
44
+ };
45
+ /** Shared context available to all steps during installation. */
46
+ type InstallationContext = {
47
+ /** The credentials of the app being installed */appData: AppData; /** The raw action parameters from the App Builder runtime action. */
48
+ params: RuntimeActionParams & {
49
+ AIO_COMMERCE_AUTH_IMS_CLIENT_ID: string;
50
+ AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS: string | string[];
51
+ AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_ID: string;
52
+ AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_EMAIL: string;
53
+ AIO_COMMERCE_AUTH_IMS_ORG_ID: string;
54
+ AIO_COMMERCE_AUTH_IMS_SCOPES: string | string[];
55
+ }; /** Logger instance for installation logging. */
56
+ logger: ReturnType<typeof AioLogger>; /** Custom scripts defined in the configuration (if any). */
57
+ customScripts?: Record<string, unknown>;
58
+ };
59
+ /** Factory function type for creating step-specific context. */
60
+ type StepContextFactory<TStepCtx extends Record<string, unknown> = Record<string, unknown>> = (context: InstallationContext) => TStepCtx | Promise<TStepCtx>;
61
+ /** The execution context passed to leaf step run handlers. */
62
+ type ExecutionContext<TStepCtx extends Record<string, unknown> = Record<string, unknown>> = InstallationContext & TStepCtx;
63
+ /**
64
+ * A narrowed context available to step `validate` handlers.
65
+ * Excludes `customScripts` — those only apply during installation, not pre-flight validation.
66
+ */
67
+ type ValidationContext = Omit<InstallationContext, "customScripts">;
68
+ /** The context passed to step `validate` handlers (base validation context merged with step-level context). */
69
+ type ValidationExecutionContext<TStepCtx extends Record<string, unknown> = Record<string, unknown>> = ValidationContext & TStepCtx;
70
+ /** Metadata info for a step (used for UI display). */
71
+ type StepMetaInfo = {
72
+ label: string;
73
+ description?: string;
74
+ };
75
+ /** Step metadata keyed by execution mode. */
76
+ type StepMeta = {
77
+ install: StepMetaInfo;
78
+ uninstall?: StepMetaInfo;
79
+ };
80
+ /** Defines the base properties of a step. */
81
+ type StepBase<TName extends string = string, TConfig extends CommerceAppConfigOutputModel = CommerceAppConfigOutputModel> = {
82
+ /** The name of this step. */name: TName; /** Metadata associated with the step, keyed by execution mode. */
83
+ meta: StepMeta; /** Whether the step should be taken into consideration. */
84
+ when?: (config: CommerceAppConfigOutputModel) => config is TConfig;
85
+ };
86
+ /** A leaf step that executes work (no children). */
87
+ type LeafStep<TName extends string = string, TConfig extends CommerceAppConfigOutputModel = CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TOutput = unknown> = StepBase<TName, TConfig> & {
88
+ type: "leaf"; /** The execution handler for the step. */
89
+ install: (config: TConfig, context: ExecutionContext<TStepCtx>) => TOutput | Promise<TOutput>;
90
+ /**
91
+ * Optional pre-installation validation handler.
92
+ * Called before installation begins to surface issues (errors or warnings).
93
+ * Returning an empty array means the step has no issues.
94
+ */
95
+ validate?: (config: TConfig, context: ValidationExecutionContext<TStepCtx>) => ValidationIssue[] | Promise<ValidationIssue[]>;
96
+ /**
97
+ * Optional uninstall handler for the step.
98
+ * Called during uninstallation to reverse the work done by `install`.
99
+ * If absent, the step is silently skipped during uninstallation.
100
+ */
101
+ uninstall?: (config: TConfig, context: ExecutionContext<TStepCtx>) => void | Promise<void>;
102
+ };
103
+ /** A branch step that contains children (no execution). */
104
+ type BranchStep<TName extends string = string, TConfig extends CommerceAppConfigOutputModel = CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TChildren extends AnyStep[] = AnyStep[]> = StepBase<TName, TConfig> & {
105
+ type: "branch"; /** An optional factory function to setup shared context for the children steps. */
106
+ context?: StepContextFactory<TStepCtx>; /** The children steps of this branch. */
107
+ children: TChildren;
108
+ /**
109
+ * Optional pre-installation validation handler for the branch itself.
110
+ * Called before children are validated. Returning an empty array means
111
+ * the branch has no issues at this level.
112
+ */
113
+ validate?: (config: TConfig, context: ValidationExecutionContext<TStepCtx>) => ValidationIssue[] | Promise<ValidationIssue[]>;
114
+ };
115
+ /** A step in the installation tree (discriminated union by `type`). */
116
+ type Step<TName extends string = string, TConfig extends CommerceAppConfigOutputModel = CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TOutput = unknown> = LeafStep<TName, TConfig, TStepCtx, TOutput> | BranchStep<TName, TConfig, TStepCtx>;
117
+ /** Loosely-typed step for use in non type-safe contexts. */
118
+ type AnyStep = {
119
+ children?: AnyStep[];
120
+ context?: (context: InstallationContext) => any;
121
+ install?: (config: any, context: any) => unknown | Promise<unknown>;
122
+ meta: StepMeta;
123
+ name: string;
124
+ type: "leaf" | "branch";
125
+ uninstall?: (config: any, context: any) => void | Promise<void>;
126
+ validate?: (config: any, context: any) => ValidationIssue[] | Promise<ValidationIssue[]>;
127
+ when?: (config: CommerceAppConfigOutputModel) => boolean;
128
+ };
129
+ /** Check if a step is a leaf step. */
130
+ declare function isLeafStep(step: AnyStep): step is LeafStep;
131
+ /** Check if a step is a branch step. */
132
+ declare function isBranchStep(step: AnyStep): step is BranchStep;
133
+ /** Options for defining a leaf step. */
134
+ type LeafStepOptions<TName extends string, TConfig extends CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TOutput = unknown> = Omit<LeafStep<TName, TConfig, TStepCtx, TOutput>, "type">;
135
+ /** Options for defining a branch step. */
136
+ type BranchStepOptions<TName extends string, TConfig extends CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TChildren extends AnyStep[] = AnyStep[]> = Omit<BranchStep<TName, TConfig, TStepCtx, TChildren>, "type">;
137
+ /**
138
+ * Define a leaf step (executable, no children).
139
+ *
140
+ * @example
141
+ * ```typescript
142
+ * const createProviders = defineLeafStep({
143
+ * name: "providers",
144
+ * meta: { install: { label: "Create Providers", description: "Creates I/O Events providers" } },
145
+ * install: async ({ config, stepContext }) => {
146
+ * const { eventsClient } = stepContext;
147
+ * return eventsClient.createProvider(config.eventing);
148
+ * },
149
+ * });
150
+ * ```
151
+ */
152
+ declare function defineLeafStep<TName extends string, TConfig extends CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TOutput = unknown>(options: LeafStepOptions<TName, TConfig, TStepCtx, TOutput>): {
153
+ install: (config: TConfig, context: ExecutionContext<TStepCtx>) => TOutput | Promise<TOutput>;
154
+ meta: StepMeta;
155
+ name: TName;
156
+ type: "leaf";
157
+ uninstall: ((config: TConfig, context: ExecutionContext<TStepCtx>) => void | Promise<void>) | undefined;
158
+ validate: ((config: TConfig, context: ValidationExecutionContext<TStepCtx>) => ValidationIssue[] | Promise<ValidationIssue[]>) | undefined;
159
+ when: ((config: CommerceAppConfigOutputModel) => config is TConfig) | undefined;
160
+ };
161
+ /**
162
+ * Define a branch step (container with children, no runner).
163
+ *
164
+ * @example
165
+ * ```typescript
166
+ * const eventing = defineBranchStep({
167
+ * name: "eventing",
168
+ * meta: { install: { label: "Eventing", description: "Sets up I/O Events" } },
169
+ * when: hasEventing,
170
+ * context: async (ctx) => ({ eventsClient: await createEventsClient(ctx) }),
171
+ * children: [commerceEventsStep, externalEventsStep],
172
+ * });
173
+ * ```
174
+ */
175
+ declare function defineBranchStep<TName extends string, TConfig extends CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, const TChildren extends AnyStep[] = AnyStep[]>(options: BranchStepOptions<TName, TConfig, TStepCtx, TChildren>): {
176
+ children: TChildren;
177
+ context: StepContextFactory<TStepCtx> | undefined;
178
+ meta: StepMeta;
179
+ name: TName;
180
+ type: "branch";
181
+ validate: ((config: TConfig, context: ValidationExecutionContext<TStepCtx>) => ValidationIssue[] | Promise<ValidationIssue[]>) | undefined;
182
+ when: ((config: CommerceAppConfigOutputModel) => config is TConfig) | undefined;
183
+ };
184
+ /** Infer the output type from a leaf step. */
185
+ type InferStepOutput<TStep> = TStep extends LeafStep<infer _TName, infer _TConfig, infer _TStepCtx, infer TOutput> ? Awaited<TOutput> : never;
186
+ //#endregion
18
187
  //#region source/management/installation/workflow/types.d.ts
19
188
  /** Status of a step execution. */
20
189
  type ExecutionStatus = "pending" | "in-progress" | "succeeded" | "failed";
@@ -45,6 +214,11 @@ type InstallationStateBase = {
45
214
  /** Unique installation identifier. */id: string; /** Root step status. */
46
215
  step: StepStatus; /** Results from executed leaf steps, keyed by path. */
47
216
  data: InstallationData | null;
217
+ /**
218
+ * The validated app configuration that drove this workflow. May be
219
+ * undefined on states persisted before this field was introduced.
220
+ */
221
+ config?: CommerceAppConfigOutputModel;
48
222
  };
49
223
  /** Installation state when in progress. */
50
224
  type InProgressInstallationState = InstallationStateBase & {
@@ -309,4 +483,4 @@ type RunValidationOptions = {
309
483
  */
310
484
  declare function runValidation(options: RunValidationOptions): Promise<ValidationResult>;
311
485
  //#endregion
312
- export { ExecutionStatus as A, isCompletedState as B, executeUninstallWorkflow as C, StepFailedEvent as D, StepEvent as E, InstallationRetryMetadata as F, isInProgressState as H, InstallationState as I, InstallationStatus as L, InProgressInstallationState as M, InstallationData as N, StepStartedEvent as O, InstallationError as P, StepStatus as R, createRetryState as S, InstallationHooks as T, isSucceededState as U, isFailedState as V, ValidationSummary as _, RunValidationOptions as a, ExecuteWorkflowOptions as b, runInstallation as c, CustomInstallationStepDefinition as d, CustomInstallationStepHandler as f, ValidationResult as g, ValidateStepTreeOptions as h, RunUninstallationOptions as i, FailedInstallationState as j, StepSucceededEvent as k, runUninstallation as l, StepValidationResult as m, CreateInitialUninstallationStateOptions as n, createInitialInstallationState as o, defineCustomInstallationStep as p, RunInstallationOptions as r, createInitialUninstallationState as s, CreateInitialInstallationStateOptions as t, runValidation as u, validateStepTree as v, executeWorkflow as w, createInitialState as x, CreateInitialStateOptions as y, SucceededInstallationState as z };
486
+ export { StepContextFactory as $, ExecutionStatus as A, isCompletedState as B, executeUninstallWorkflow as C, StepFailedEvent as D, StepEvent as E, InstallationRetryMetadata as F, BranchStep as G, isInProgressState as H, InstallationState as I, InferStepOutput as J, BranchStepOptions as K, InstallationStatus as L, InProgressInstallationState as M, InstallationData as N, StepStartedEvent as O, InstallationError as P, Step as Q, StepStatus as R, createRetryState as S, InstallationHooks as T, isSucceededState as U, isFailedState as V, AnyStep as W, LeafStep as X, InstallationContext as Y, LeafStepOptions as Z, ValidationSummary as _, RunValidationOptions as a, ValidationIssueSeverity as at, ExecuteWorkflowOptions as b, runInstallation as c, isBranchStep as ct, CustomInstallationStepDefinition as d, StepMeta as et, CustomInstallationStepHandler as f, ValidationResult as g, ValidateStepTreeOptions as h, RunUninstallationOptions as i, ValidationIssue as it, FailedInstallationState as j, StepSucceededEvent as k, runUninstallation as l, isLeafStep as lt, StepValidationResult as m, CreateInitialUninstallationStateOptions as n, ValidationContext as nt, createInitialInstallationState as o, defineBranchStep as ot, defineCustomInstallationStep as p, ExecutionContext as q, RunInstallationOptions as r, ValidationExecutionContext as rt, createInitialUninstallationState as s, defineLeafStep as st, CreateInitialInstallationStateOptions as t, StepMetaInfo as tt, runValidation as u, validateStepTree as v, executeWorkflow as w, createInitialState as x, CreateInitialStateOptions as y, SucceededInstallationState as z };
@@ -0,0 +1,217 @@
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 { AdobeCommerceHttpClient, CommerceHttpClientParams } from "@adobe/aio-commerce-lib-api";
16
+ import { CommerceSdkErrorBase, CommerceSdkErrorBaseOptions } from "@adobe/aio-commerce-lib-core/error";
17
+ import { ImsAuthParams, ImsAuthProvider } from "@adobe/aio-commerce-lib-auth";
18
+ import { CommerceEnv } from "@adobe/aio-commerce-lib-core/commerce";
19
+ import { AdobeIoEventsApiClient } from "@adobe/aio-commerce-lib-events/io-events";
20
+
21
+ //#region source/management/association/types.d.ts
22
+ /**
23
+ * The Commerce instance an app is associated with.
24
+ */
25
+ type AssociatedCommerceInstance = {
26
+ /** Commerce API base URL. */baseUrl: string; /** Deployment type of the Commerce instance. */
27
+ env: CommerceEnv;
28
+ };
29
+ //#endregion
30
+ //#region source/access/commerce-instance.d.ts
31
+ /**
32
+ * Returns the Commerce instance this app is currently associated with.
33
+ *
34
+ * @throws {AppNotAssociatedError} If the app is not associated, was
35
+ * unassociated, or was associated by an older SDK that did not store this
36
+ * data. Re-associating the app resolves the error.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * import { getCommerceInstance } from "@adobe/aio-commerce-lib-app";
41
+ *
42
+ * export async function main() {
43
+ * const instance = await getCommerceInstance();
44
+ *
45
+ * // instance.baseUrl — e.g. "https://my-store.example.com"
46
+ * // instance.env — "saas" | "paas"
47
+ * }
48
+ * ```
49
+ */
50
+ declare function getCommerceInstance(): Promise<AssociatedCommerceInstance>;
51
+ /**
52
+ * Returns an initialised `AdobeCommerceHttpClient` for the Commerce instance
53
+ * this app is currently associated with.
54
+ *
55
+ * The base URL and flavor come from the stored association data
56
+ * ({@link getCommerceInstance}); the caller supplies the resolved IMS auth.
57
+ *
58
+ * @param auth - Resolved IMS auth params or an IMS auth provider.
59
+ * @param fetchOptions - Optional global fetch options forwarded to the
60
+ * underlying `AdobeCommerceHttpClient` (e.g. `headers`, `timeout`, `retry`).
61
+ * @throws {AppNotAssociatedError} If the app is not associated, was
62
+ * unassociated, or was associated by an older SDK that did not store this
63
+ * data. Re-associating the app resolves the error.
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * import { getCommerceClient } from "@adobe/aio-commerce-lib-app";
68
+ * import { resolveImsAuthParams } from "@adobe/aio-commerce-lib-auth";
69
+ *
70
+ * export async function main(params) {
71
+ * const client = await getCommerceClient(resolveImsAuthParams(params));
72
+ * const products = await client.get("products").json();
73
+ * }
74
+ * ```
75
+ */
76
+ declare function getCommerceClient(auth: ImsAuthParams | ImsAuthProvider, fetchOptions?: CommerceHttpClientParams["fetchOptions"]): Promise<AdobeCommerceHttpClient>;
77
+ //#endregion
78
+ //#region source/access/events.d.ts
79
+ /**
80
+ * Publishes an event declared in the app's eventing configuration.
81
+ *
82
+ * Resolves the provider key and event name to their respective I/O Events IDs from
83
+ * data written to system storage at installation time, then delegates the HTTP call
84
+ * to the given client. No management API round-trip is needed at runtime.
85
+ *
86
+ * @param params.client - An {@link AdobeIoEventsApiClient} configured with the correct IMS auth.
87
+ * @param params.provider - The `key` of an event provider declared in `app.commerce.config.ts`.
88
+ * @param params.event - The `name` of an event within that provider.
89
+ * @param params.payload - The event payload. Must be a JSON object.
90
+ *
91
+ * @throws {EventsDataNotInitializedError} If no eventing installation data is found in system storage.
92
+ * @throws {ProviderNotFoundError} If the provider key is not found in the stored data.
93
+ * @throws {EventNotFoundError} If the event name is not found under the given provider.
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * import { publishEvent } from "@adobe/aio-commerce-lib-app";
98
+ * import { createAdobeIoEventsApiClient } from "@adobe/aio-commerce-lib-events";
99
+ * import { resolveImsAuthParams } from "@adobe/aio-commerce-lib-auth";
100
+ *
101
+ * export async function main(params) {
102
+ * const client = createAdobeIoEventsApiClient({
103
+ * auth: resolveImsAuthParams(params),
104
+ * config: { ingressBaseUrl: params.AIO_EVENTS_INGRESS_BASE_URL },
105
+ * });
106
+ *
107
+ * await publishEvent({
108
+ * client,
109
+ * provider: "order-events",
110
+ * event: "order.created",
111
+ * payload: { orderId: "100000123", total: 149.99 },
112
+ * });
113
+ * }
114
+ * ```
115
+ */
116
+ declare function publishEvent<TPayload extends Record<string, unknown> = Record<string, unknown>>(params: {
117
+ client: AdobeIoEventsApiClient;
118
+ provider: string;
119
+ event: string;
120
+ payload: TPayload;
121
+ }): Promise<void>;
122
+ //#endregion
123
+ //#region source/errors/app-not-associated-error.d.ts
124
+ /** Options accepted by {@link AppNotAssociatedError}. */
125
+ type AppNotAssociatedErrorOptions = CommerceSdkErrorBaseOptions;
126
+ /**
127
+ * Thrown when a runtime action calls `getCommerceInstance` or `getCommerceClient`
128
+ * but the app has no stored association data — for example, when the app has
129
+ * never been associated, has been unassociated, or was associated by an older
130
+ * SDK that did not store this data.
131
+ *
132
+ * Re-associating the app resolves the error.
133
+ *
134
+ * @example
135
+ * ```ts
136
+ * import { getCommerceClient, AppNotAssociatedError } from "@adobe/aio-commerce-lib-app";
137
+ * import { resolveImsAuthParams } from "@adobe/aio-commerce-lib-auth";
138
+ *
139
+ * try {
140
+ * const client = await getCommerceClient(resolveImsAuthParams(params));
141
+ * // ... use client
142
+ * } catch (error) {
143
+ * if (error instanceof AppNotAssociatedError) {
144
+ * // handle the unassociated case (e.g. return a 400 response)
145
+ * }
146
+ * throw error;
147
+ * }
148
+ * ```
149
+ */
150
+ declare class AppNotAssociatedError extends CommerceSdkErrorBase {
151
+ constructor(message?: string, options?: AppNotAssociatedErrorOptions);
152
+ }
153
+ //#endregion
154
+ //#region source/errors/publish-event-errors.d.ts
155
+ /**
156
+ * Base error thrown by {@link publishEvent} when event resolution or publishing fails.
157
+ * Catch this to handle all publish-event failures in a single clause.
158
+ */
159
+ declare class PublishEventError extends CommerceSdkErrorBase {}
160
+ /**
161
+ * Thrown when {@link publishEvent} cannot find the eventing installation data in system storage.
162
+ *
163
+ * This typically means the app installation has not run yet, or ran with an older SDK version
164
+ * that did not write event provider metadata to storage. Re-running the installation resolves it.
165
+ *
166
+ * @example
167
+ * ```ts
168
+ * try {
169
+ * await publishEvent({ client, provider: "order-events", event: "order.created", payload });
170
+ * } catch (error) {
171
+ * if (error instanceof EventsDataNotInitializedError) {
172
+ * // Prompt re-installation
173
+ * }
174
+ * }
175
+ * ```
176
+ */
177
+ declare class EventsDataNotInitializedError extends PublishEventError {
178
+ constructor();
179
+ }
180
+ /**
181
+ * Thrown when the provider key passed to {@link publishEvent} does not match any provider
182
+ * declared in the app's eventing configuration.
183
+ *
184
+ * @example
185
+ * ```ts
186
+ * try {
187
+ * await publishEvent({ client, provider: "order-events", event: "order.created", payload });
188
+ * } catch (error) {
189
+ * if (error instanceof ProviderNotFoundError) {
190
+ * // "order-events" was not found — check app.commerce.config.ts
191
+ * }
192
+ * }
193
+ * ```
194
+ */
195
+ declare class ProviderNotFoundError extends PublishEventError {
196
+ constructor(providerKey: string);
197
+ }
198
+ /**
199
+ * Thrown when the event name passed to {@link publishEvent} does not match any event
200
+ * declared under the given provider in the app's eventing configuration.
201
+ *
202
+ * @example
203
+ * ```ts
204
+ * try {
205
+ * await publishEvent({ client, provider: "order-events", event: "order.created", payload });
206
+ * } catch (error) {
207
+ * if (error instanceof EventNotFoundError) {
208
+ * // "order.created" was not found under "order-events" — check app.commerce.config.ts
209
+ * }
210
+ * }
211
+ * ```
212
+ */
213
+ declare class EventNotFoundError extends PublishEventError {
214
+ constructor(eventName: string, providerKey: string);
215
+ }
216
+ //#endregion
217
+ export { AppNotAssociatedError, type AssociatedCommerceInstance, EventNotFoundError, EventsDataNotInitializedError, ProviderNotFoundError, PublishEventError, getCommerceClient, getCommerceInstance, publishEvent };