@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,8 +12,8 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
- import { a as hasCustomInstallationSteps, c as hasEventing, d as hasAdminUiSdk, i as hasCustomInstallation, l as hasExternalEvents, n as hasWebhooks, s as hasCommerceEvents } from "../webhooks-Dhrkkip7.mjs";
16
- import { a as hasConfigDomain, c as hasBusinessConfigSchema, i as getConfigDomains, n as validateCommerceAppConfigDomain, o as hasMetadata, r as CommerceAppConfigSchemas, s as hasBusinessConfig, t as validateCommerceAppConfig } from "../validate-Dn3lLTGj.mjs";
17
- import { d as defineConfig, n as readCommerceAppConfig, r as resolveCommerceAppConfig, t as parseCommerceAppConfig } from "../config-DGPFTk6w.mjs";
15
+ import { d as defineConfig, n as readCommerceAppConfig, r as resolveCommerceAppConfig, t as parseCommerceAppConfig } from "../config-3I4eLyyR.mjs";
16
+ import { a as hasCustomInstallationSteps, c as hasEventing, d as hasAdminUiSdk, i as hasCustomInstallation, l as hasExternalEvents, n as hasWebhooks, s as hasCommerceEvents } from "../webhooks-B5oq9ULL.mjs";
17
+ 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-Dfajrp99.mjs";
18
18
 
19
19
  export { CommerceAppConfigSchemas, defineConfig, getConfigDomains, hasAdminUiSdk, hasBusinessConfig, hasBusinessConfigSchema, hasCommerceEvents, hasConfigDomain, hasCustomInstallation, hasCustomInstallationSteps, hasEventing, hasExternalEvents, hasMetadata, hasWebhooks, parseCommerceAppConfig, readCommerceAppConfig, resolveCommerceAppConfig, validateCommerceAppConfig, validateCommerceAppConfigDomain };
@@ -12,14 +12,13 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
- import { t as validateCommerceAppConfig } from "./validate-Dn3lLTGj.mjs";
16
- import { t as stringifyError } from "./error-DHlYzkbb.mjs";
15
+ import { t as stringifyError } from "./error-_RMwtrUA.mjs";
16
+ import { t as validateCommerceAppConfig } from "./validate-Dfajrp99.mjs";
17
17
  import { dirname, join, parse } from "path";
18
18
  import { existsSync } from "fs";
19
19
  import { access, mkdir, readFile } from "fs/promises";
20
20
  import { resolveCommand } from "package-manager-detector";
21
21
  import { detect, getUserAgent } from "package-manager-detector/detect";
22
- import { createJiti } from "jiti";
23
22
 
24
23
  //#region source/config/lib/define.ts
25
24
  /**
@@ -169,7 +168,6 @@ function getInstallCommand(packageManager, packages) {
169
168
 
170
169
  //#endregion
171
170
  //#region source/config/lib/parser.ts
172
- const jiti = createJiti(import.meta.url);
173
171
  const configPaths = Object.freeze([
174
172
  "app.commerce.config.js",
175
173
  "app.commerce.config.ts",
@@ -220,7 +218,8 @@ async function readCommerceAppConfig(cwd = process.cwd()) {
220
218
  if (!configFilePath) throw new Error("Could not find a commerce app config file in the current working directory or its parents.");
221
219
  let config = null;
222
220
  try {
223
- config = await jiti.import(configFilePath);
221
+ const { createJiti } = await import("jiti");
222
+ config = await createJiti(import.meta.url).import(configFilePath);
224
223
  } catch (error) {
225
224
  const message = stringifyError(error);
226
225
  throw new Error(`Failed to read commerce app config file at ${configFilePath}: ${message}`, { cause: error });
@@ -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-DcY6dJiQ.mjs";
16
- import { f as StepMetaInfo, h as ValidationIssue, i as ExecutionContext, n as BranchStep, o as InstallationContext, p as ValidationContext } from "./step-0eI2x4C9.mjs";
15
+ import { r as CommerceAppConfigOutputModel } from "./app-DrYHK-z1.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
+ interface 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
+ type: "leaf";
154
+ name: TName;
155
+ meta: StepMeta;
156
+ when: ((config: CommerceAppConfigOutputModel) => config is TConfig) | undefined;
157
+ install: (config: TConfig, context: ExecutionContext<TStepCtx>) => TOutput | Promise<TOutput>;
158
+ uninstall: ((config: TConfig, context: ExecutionContext<TStepCtx>) => void | Promise<void>) | undefined;
159
+ validate: ((config: TConfig, context: ValidationExecutionContext<TStepCtx>) => ValidationIssue[] | Promise<ValidationIssue[]>) | 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
+ type: "branch";
177
+ name: TName;
178
+ meta: StepMeta;
179
+ when: ((config: CommerceAppConfigOutputModel) => config is TConfig) | undefined;
180
+ context: StepContextFactory<TStepCtx> | undefined;
181
+ children: TChildren;
182
+ validate: ((config: TConfig, context: ValidationExecutionContext<TStepCtx>) => ValidationIssue[] | Promise<ValidationIssue[]>) | 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";
@@ -309,4 +478,4 @@ type RunValidationOptions = {
309
478
  */
310
479
  declare function runValidation(options: RunValidationOptions): Promise<ValidationResult>;
311
480
  //#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 };
481
+ 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 };
@@ -12,6 +12,5 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
- import { _ as defineBranchStep, a as InferStepOutput, b as isLeafStep, c as LeafStepOptions, d as StepMeta, f as StepMetaInfo, g as ValidationIssueSeverity, h as ValidationIssue, i as ExecutionContext, l as Step, m as ValidationExecutionContext, n as BranchStep, o as InstallationContext, p as ValidationContext, r as BranchStepOptions, s as LeafStep, t as AnyStep, u as StepContextFactory, v as defineLeafStep, y as isBranchStep } from "../step-0eI2x4C9.mjs";
16
- import { A as ExecutionStatus, B as isCompletedState, C as executeUninstallWorkflow, D as StepFailedEvent, E as StepEvent, F as InstallationRetryMetadata, H as isInProgressState, I as InstallationState, L as InstallationStatus, M as InProgressInstallationState, N as InstallationData, O as StepStartedEvent, P as InstallationError, R as StepStatus, S as createRetryState, T as InstallationHooks, U as isSucceededState, V as isFailedState, _ as ValidationSummary, a as RunValidationOptions, b as ExecuteWorkflowOptions, c as runInstallation, d as CustomInstallationStepDefinition, f as CustomInstallationStepHandler, g as ValidationResult, h as ValidateStepTreeOptions, i as RunUninstallationOptions, j as FailedInstallationState, k as StepSucceededEvent, l as runUninstallation, m as StepValidationResult, n as CreateInitialUninstallationStateOptions, o as createInitialInstallationState, p as defineCustomInstallationStep, r as RunInstallationOptions, s as createInitialUninstallationState, t as CreateInitialInstallationStateOptions, u as runValidation, v as validateStepTree, w as executeWorkflow, x as createInitialState, y as CreateInitialStateOptions, z as SucceededInstallationState } from "../index-CCov0odd.mjs";
17
- export { AnyStep, BranchStep, BranchStepOptions, CreateInitialInstallationStateOptions, CreateInitialStateOptions, CreateInitialUninstallationStateOptions, CustomInstallationStepDefinition, CustomInstallationStepHandler, ExecuteWorkflowOptions, ExecutionContext, ExecutionStatus, FailedInstallationState, InProgressInstallationState, InferStepOutput, InstallationContext, InstallationData, InstallationError, InstallationHooks, InstallationRetryMetadata, InstallationState, InstallationStatus, LeafStep, LeafStepOptions, RunInstallationOptions, RunUninstallationOptions, RunValidationOptions, Step, StepContextFactory, StepEvent, StepFailedEvent, StepMeta, StepMetaInfo, StepStartedEvent, StepStatus, StepSucceededEvent, StepValidationResult, SucceededInstallationState, ValidateStepTreeOptions, ValidationContext, ValidationExecutionContext, ValidationIssue, ValidationIssueSeverity, ValidationResult, ValidationSummary, createInitialInstallationState, createInitialState, createInitialUninstallationState, createRetryState, defineBranchStep, defineCustomInstallationStep, defineLeafStep, executeUninstallWorkflow, executeWorkflow, isBranchStep, isCompletedState, isFailedState, isInProgressState, isLeafStep, isSucceededState, runInstallation, runUninstallation, runValidation, validateStepTree };
15
+ import { $ as StepContextFactory, A as ExecutionStatus, B as isCompletedState, C as executeUninstallWorkflow, D as StepFailedEvent, E as StepEvent, F as InstallationRetryMetadata, G as BranchStep, H as isInProgressState, I as InstallationState, J as InferStepOutput, K as BranchStepOptions, L as InstallationStatus, M as InProgressInstallationState, N as InstallationData, O as StepStartedEvent, P as InstallationError, Q as Step, R as StepStatus, S as createRetryState, T as InstallationHooks, U as isSucceededState, V as isFailedState, W as AnyStep, X as LeafStep, Y as InstallationContext, Z as LeafStepOptions, _ as ValidationSummary, a as RunValidationOptions, at as ValidationIssueSeverity, b as ExecuteWorkflowOptions, c as runInstallation, ct as isBranchStep, d as CustomInstallationStepDefinition, et as StepMeta, f as CustomInstallationStepHandler, g as ValidationResult, h as ValidateStepTreeOptions, i as RunUninstallationOptions, it as ValidationIssue, j as FailedInstallationState, k as StepSucceededEvent, l as runUninstallation, lt as isLeafStep, m as StepValidationResult, n as CreateInitialUninstallationStateOptions, nt as ValidationContext, o as createInitialInstallationState, ot as defineBranchStep, p as defineCustomInstallationStep, q as ExecutionContext, r as RunInstallationOptions, rt as ValidationExecutionContext, s as createInitialUninstallationState, st as defineLeafStep, t as CreateInitialInstallationStateOptions, tt as StepMetaInfo, u as runValidation, v as validateStepTree, w as executeWorkflow, x as createInitialState, y as CreateInitialStateOptions, z as SucceededInstallationState } from "../index-DLMbTtKS.mjs";
16
+ export { type AnyStep, type BranchStep, type BranchStepOptions, type CreateInitialInstallationStateOptions, type CreateInitialStateOptions, type CreateInitialUninstallationStateOptions, type CustomInstallationStepDefinition, type CustomInstallationStepHandler, type ExecuteWorkflowOptions, type ExecutionContext, type ExecutionStatus, type FailedInstallationState, type InProgressInstallationState, type InferStepOutput, type InstallationContext, type InstallationData, type InstallationError, type InstallationHooks, type InstallationRetryMetadata, type InstallationState, type InstallationStatus, type LeafStep, type LeafStepOptions, type RunInstallationOptions, type RunUninstallationOptions, type RunValidationOptions, type Step, type StepContextFactory, type StepEvent, type StepFailedEvent, type StepMeta, type StepMetaInfo, type StepStartedEvent, type StepStatus, type StepSucceededEvent, type StepValidationResult, type SucceededInstallationState, type ValidateStepTreeOptions, type ValidationContext, type ValidationExecutionContext, type ValidationIssue, type ValidationIssueSeverity, type ValidationResult, type ValidationSummary, createInitialInstallationState, type createInitialState, createInitialUninstallationState, type createRetryState, type defineBranchStep, defineCustomInstallationStep, type defineLeafStep, type executeUninstallWorkflow, type executeWorkflow, type isBranchStep, isCompletedState, isFailedState, isInProgressState, type isLeafStep, isSucceededState, runInstallation, runUninstallation, runValidation, type validateStepTree };
@@ -12,6 +12,6 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
- import { a as runValidation, c as isFailedState, i as runUninstallation, l as isInProgressState, n as createInitialUninstallationState, o as defineCustomInstallationStep, r as runInstallation, s as isCompletedState, t as createInitialInstallationState, u as isSucceededState } from "../management-CCsOfniv.mjs";
15
+ import { a as runValidation, c as isFailedState, i as runUninstallation, l as isInProgressState, n as createInitialUninstallationState, o as defineCustomInstallationStep, r as runInstallation, s as isCompletedState, t as createInitialInstallationState, u as isSucceededState } from "../management-BUX-w2Ji.mjs";
16
16
 
17
17
  export { createInitialInstallationState, createInitialUninstallationState, defineCustomInstallationStep, isCompletedState, isFailedState, isInProgressState, isSucceededState, runInstallation, runUninstallation, runValidation };
@@ -12,17 +12,34 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
- import { a as hasCustomInstallationSteps, c as hasEventing, d as hasAdminUiSdk, l as hasExternalEvents, n as hasWebhooks, s as hasCommerceEvents } from "./webhooks-Dhrkkip7.mjs";
16
- import { t as stringifyError } from "./error-DHlYzkbb.mjs";
17
- import { t as inspect } from "./logging-XIUXDK5T.mjs";
15
+ import { t as stringifyError } from "./error-_RMwtrUA.mjs";
16
+ import { a as hasCustomInstallationSteps, c as hasEventing, d as hasAdminUiSdk, l as hasExternalEvents, n as hasWebhooks, s as hasCommerceEvents } from "./webhooks-B5oq9ULL.mjs";
17
+ import { t as inspect } from "./logging-DbJHXSKh.mjs";
18
+ import { CommerceSdkValidationError } from "@adobe/aio-commerce-lib-core/error";
19
+ import * as v from "valibot";
18
20
  import { unwrapHttpError } from "@adobe/aio-commerce-lib-api/utils";
19
- import camelcase from "camelcase";
20
- import { AdobeCommerceHttpClient, resolveCommerceHttpClientParams, resolveIoEventsHttpClientParams } from "@adobe/aio-commerce-lib-api";
21
+ import * as camelcaseModule from "camelcase";
22
+ import { createAdminUiApiClient } from "@adobe/aio-commerce-lib-admin-ui/api";
23
+ import { resolveCommerceHttpClientParams, resolveIoEventsHttpClientParams } from "@adobe/aio-commerce-lib-api";
21
24
  import { resolveAuthParams, resolveImsAuthParams } from "@adobe/aio-commerce-lib-auth";
22
25
  import { createCustomCommerceEventsApiClient, createEventProvider, createEventSubscription, deleteEventProvider, deleteEventSubscription, getAllEventProviders, getAllEventSubscriptions, updateEventingConfiguration } from "@adobe/aio-commerce-lib-events/commerce";
23
26
  import { createCustomAdobeIoEventsApiClient, createEventMetadataForProvider, createEventProvider as createEventProvider$1, createRegistration, deleteEventMetadataForProvider, deleteEventProvider as deleteEventProvider$1, deleteRegistration, getAllEventProviders as getAllEventProviders$1, getAllRegistrations } from "@adobe/aio-commerce-lib-events/io-events";
24
27
  import { createCustomCommerceWebhooksApiClient, getWebhookList, subscribeWebhook, unsubscribeWebhook } from "@adobe/aio-commerce-lib-webhooks/api";
25
28
 
29
+ //#region ../../packages-private/common-utils/source/valibot/utils.ts
30
+ /**
31
+ * Parses the input using the provided schema and throws a {@link CommerceSdkValidationError} error if the input is invalid.
32
+ * @param schema - The schema to use for parsing.
33
+ * @param input - The input to parse.
34
+ * @param message - Optional custom error message for the validation error.
35
+ */
36
+ function parseOrThrow(schema, input, message) {
37
+ const result = v.safeParse(schema, input);
38
+ if (!result.success) throw new CommerceSdkValidationError(message ?? "Invalid input", { issues: result.issues });
39
+ return result.output;
40
+ }
41
+
42
+ //#endregion
26
43
  //#region source/management/installation/workflow/hooks.ts
27
44
  /** Helper to call a hook if it exists. */
28
45
  async function callHook(hooks, hookName, ...args) {
@@ -453,11 +470,38 @@ function aggregateSummary(result) {
453
470
 
454
471
  //#endregion
455
472
  //#region source/management/installation/custom-installation/custom-scripts.ts
456
- function isCustomInstallationStepDefinition(obj) {
457
- return typeof obj === "object" && obj !== null && "install" in obj && typeof obj.install === "function";
473
+ const camelcase = camelcaseModule.default.default ?? camelcaseModule.default;
474
+ const ScriptModuleSchema = v.union([v.function(), v.object({
475
+ install: v.function(),
476
+ uninstall: v.optional(v.function())
477
+ })]);
478
+ /**
479
+ * Validates that a loaded script export can be executed as a custom installation step.
480
+ *
481
+ * @param module - The loaded script export to validate.
482
+ * @throws If the export is not a function or an object with an `install` function.
483
+ */
484
+ function assertScriptModule(module) {
485
+ parseOrThrow(ScriptModuleSchema, module, "Invalid script module format. Expected a function or an object with an `install` method.");
458
486
  }
459
- function isCustomInstallationStepHandler(obj) {
460
- return typeof obj === "function";
487
+ /**
488
+ * Parses and validates a custom script module from the provided customScripts context.
489
+ * It supports both direct function exports and default exports.
490
+ *
491
+ * @param customScripts - The customScripts context containing the loaded modules
492
+ * @param script - The script path to resolve the module for
493
+ */
494
+ function getScriptModule(customScripts, script) {
495
+ let scriptModule = customScripts[script];
496
+ if (!scriptModule) throw new Error(`Script ${script} not found in customScripts context. Make sure the script is defined in the configuration and the action was generated with custom scripts support.`);
497
+ if (typeof scriptModule === "object" && "default" in scriptModule) scriptModule = scriptModule.default;
498
+ assertScriptModule(scriptModule);
499
+ return scriptModule;
500
+ }
501
+ function resolveCustomScriptHandler(scriptModule, handler) {
502
+ if (typeof scriptModule === "function") return handler === "install" ? scriptModule : null;
503
+ if (handler in scriptModule && typeof scriptModule[handler] === "function") return scriptModule[handler];
504
+ return null;
461
505
  }
462
506
  /**
463
507
  * Creates a leaf step for executing a single custom installation script.
@@ -475,15 +519,7 @@ function createCustomScriptStep(scriptConfig) {
475
519
  const customScripts = context.customScripts || {};
476
520
  logger.info(`Executing custom installation script: ${name}`);
477
521
  logger.debug(`Script path: ${script}`);
478
- const scriptModule = customScripts[script];
479
- if (!scriptModule) throw new Error(`Script ${script} not found in customScripts context. Make sure the script is defined in the configuration and the action was generated with custom scripts support.`);
480
- if (typeof scriptModule !== "object" || !("default" in scriptModule)) throw new Error(`Script ${script} must export a default function or object. Use defineCustomInstallationStep helper.`);
481
- const defaultExport = scriptModule.default;
482
- let runFunction = null;
483
- if (isCustomInstallationStepHandler(defaultExport)) runFunction = defaultExport;
484
- else if (isCustomInstallationStepDefinition(defaultExport)) runFunction = defaultExport.install;
485
- if (runFunction === null) throw new Error(`Script ${script} default export must be a function or an object with an install method. Use defineCustomInstallationStep helper.`);
486
- const scriptResult = await runFunction(config, context);
522
+ const scriptResult = await resolveCustomScriptHandler(getScriptModule(customScripts, script), "install")(config, context);
487
523
  logger.info(`Successfully executed script: ${name}`);
488
524
  return {
489
525
  script,
@@ -494,14 +530,7 @@ function createCustomScriptStep(scriptConfig) {
494
530
  const { logger } = context;
495
531
  const customScripts = context.customScripts || {};
496
532
  logger.debug(`Uninstalling custom script: ${name}`);
497
- const scriptModule = customScripts[script];
498
- if (!scriptModule) throw new Error(`Script ${script} not found in customScripts context. Make sure the script is defined in the configuration and the action was generated with custom scripts support.`);
499
- const defaultExport = scriptModule.default;
500
- if (!isCustomInstallationStepDefinition(defaultExport)) {
501
- logger.debug(`Script ${script} does not export an uninstall function, skipping uninstall.`);
502
- return;
503
- }
504
- const { uninstall } = defaultExport;
533
+ const uninstall = resolveCustomScriptHandler(getScriptModule(customScripts, script), "uninstall");
505
534
  if (!uninstall) {
506
535
  logger.debug(`Script ${script} does not export an uninstall function, skipping uninstall.`);
507
536
  return;
@@ -608,34 +637,40 @@ async function throwHttpError(logger, error, prefix) {
608
637
  /**
609
638
  * Registers the extension with Commerce via POST /V1/adminuisdk/extension.
610
639
  *
611
- * @param context - The execution context providing the Commerce HTTP client and logger.
612
- * @returns The response from the Commerce API.
640
+ * @param context - The execution context providing the Admin UI SDK client and logger.
613
641
  */
614
642
  async function registerExtension(context) {
615
- const { commerceClient, appData, logger } = context;
643
+ const { adminUiClient, appData, logger } = context;
644
+ const extensionName = process.env.__OW_NAMESPACE;
645
+ if (!extensionName) throw new Error("__OW_NAMESPACE environment variable is not set");
616
646
  logger.info(`Registering Admin UI SDK extension: ${appData.projectName}`);
617
- const response = await commerceClient.post("adminuisdk/extension", { json: { extension: {
618
- extensionName: process.env.__OW_NAMESPACE,
647
+ const { extensionId } = await adminUiClient.registerExtension({
648
+ extensionName,
619
649
  extensionTitle: appData.projectTitle,
620
- extensionUrl: `https://${process.env.__OW_NAMESPACE}.adobeio-static.net/index.html`,
650
+ extensionUrl: `https://${extensionName}.adobeio-static.net/index.html`,
621
651
  extensionWorkspace: appData.workspaceName
622
- } } }).json().catch((error) => throwHttpError(logger, error, "Failed to register Admin UI SDK extension"));
623
- logger.info(`Admin UI SDK extension registered successfully: ${response.extensionId}`);
624
- return response;
652
+ }).catch((error) => throwHttpError(logger, error, "Failed to register Admin UI SDK extension"));
653
+ logger.info(`Admin UI SDK extension registered successfully: ${extensionId}`);
625
654
  }
626
655
  /**
627
656
  * Unregisters the extension from Commerce via DELETE /V1/adminuisdk/extension/:workspace_name/:extension_name.
628
657
  * Best-effort: errors are logged as warnings and do not stop the uninstall workflow.
629
658
  *
630
- * @param context - The execution context providing the Commerce HTTP client and logger.
659
+ * @param context - The execution context providing the Admin UI SDK client and logger.
631
660
  */
632
- async function uninstallExtension(context) {
633
- const { commerceClient, appData, logger } = context;
661
+ async function unregisterExtension(context) {
662
+ const { adminUiClient, appData, logger } = context;
634
663
  const extensionName = process.env.__OW_NAMESPACE;
635
- const endpoint = `adminuisdk/extension/${appData.workspaceName}/${extensionName}`;
664
+ if (!extensionName) {
665
+ logger.warn("__OW_NAMESPACE environment variable is not set; skipping Admin UI SDK extension unregistration. Continuing uninstall.");
666
+ return;
667
+ }
636
668
  logger.info(`Unregistering Admin UI SDK extension "${extensionName}" from workspace "${appData.workspaceName}"...`);
637
669
  try {
638
- await commerceClient.delete(endpoint);
670
+ await adminUiClient.unregisterExtension({
671
+ workspaceName: appData.workspaceName,
672
+ extensionName
673
+ });
639
674
  logger.info(`Admin UI SDK extension "${extensionName}" unregistered successfully.`);
640
675
  } catch (error) {
641
676
  const msg = await unwrapHttpError(error);
@@ -645,19 +680,22 @@ async function uninstallExtension(context) {
645
680
 
646
681
  //#endregion
647
682
  //#region source/management/installation/admin-ui-sdk/utils.ts
648
- /** Creates the Admin UI SDK step context with a lazy-initialized Commerce HTTP client. */
683
+ function createAdminUiClient(params) {
684
+ return createAdminUiApiClient(resolveCommerceHttpClientParams(params, { tryForwardAuthProvider: true }));
685
+ }
686
+ /** Creates the Admin UI SDK step context with a lazy-initialized API client. */
649
687
  const createAdminUiSdkStepContext = (installation) => {
650
688
  const { params } = installation;
651
- let commerceClient = null;
652
- return { get commerceClient() {
653
- if (commerceClient === null) commerceClient = new AdobeCommerceHttpClient(resolveCommerceHttpClientParams(params, { tryForwardAuthProvider: true }));
654
- return commerceClient;
689
+ let adminUiClient = null;
690
+ return { get adminUiClient() {
691
+ if (adminUiClient === null) adminUiClient = createAdminUiClient(params);
692
+ return adminUiClient;
655
693
  } };
656
694
  };
657
695
 
658
696
  //#endregion
659
697
  //#region source/management/installation/admin-ui-sdk/branch.ts
660
- /** Leaf step that calls POST /V1/adminuisdk/extension to register the extension. */
698
+ /** Leaf step that registers the extension (POST) on install and unregisters it (DELETE) on uninstall. */
661
699
  const registerExtensionStep = defineLeafStep({
662
700
  name: "register-extension",
663
701
  meta: {
@@ -671,7 +709,7 @@ const registerExtensionStep = defineLeafStep({
671
709
  }
672
710
  },
673
711
  install: (_, context) => registerExtension(context),
674
- uninstall: (_, context) => uninstallExtension(context)
712
+ uninstall: (_, context) => unregisterExtension(context)
675
713
  });
676
714
  /** Branch step for setting up the Admin UI SDK extension registration. */
677
715
  const adminUiSdkStep = defineBranchStep({
@@ -766,15 +804,37 @@ function getNamespacedEvent(metadata, name) {
766
804
  function getIoEventCode(name, providerType) {
767
805
  return providerType === "dx_commerce_events" ? `com.adobe.commerce.${name}` : name;
768
806
  }
807
+ /** Maps a provider's metadata type to its human-readable label ("Commerce" or "External"). */
808
+ function getProviderTypeLabel(provider) {
809
+ return PROVIDER_TYPE_TO_LABEL[provider.provider_metadata];
810
+ }
769
811
  /**
770
- * Generates a registration name and description based on the provider, events, and runtime action.
812
+ * Generates a registration name based on the provider type, provider label, and runtime action.
813
+ *
814
+ * Prefixes with the provider type label ("Commerce" or "External") for readability, then the
815
+ * provider's own label to ensure uniqueness when multiple providers of the same type route
816
+ * events to the same runtime action.
817
+ *
771
818
  * @param provider - The provider this registration is associated to.
772
819
  * @param runtimeAction - The runtime action this registration points to.
773
820
  */
774
821
  function getRegistrationName(provider, runtimeAction) {
775
- const providerLabel = PROVIDER_TYPE_TO_LABEL[provider.provider_metadata];
776
822
  const [packageName, actionName] = runtimeAction.split("/").map(kebabToTitleCase);
777
- return `${providerLabel} Event Registration: ${actionName} (${packageName})`;
823
+ return `${getProviderTypeLabel(provider)} Event Registration: ${provider.label} - ${actionName} (${packageName})`;
824
+ }
825
+ /**
826
+ * Returns the registration name in the legacy format used by SDK versions that built
827
+ * the name from the generic provider type label ("Commerce" / "External") rather than
828
+ * the provider's own label. Used during uninstall to match registrations that were
829
+ * created before the naming change.
830
+ *
831
+ * @param provider - The provider this registration is associated to.
832
+ * @param runtimeAction - The runtime action this registration points to.
833
+ * @deprecated Use {@link getRegistrationName} for all new registrations.
834
+ */
835
+ function getLegacyRegistrationName(provider, runtimeAction) {
836
+ const [packageName, actionName] = runtimeAction.split("/").map(kebabToTitleCase);
837
+ return `${getProviderTypeLabel(provider)} Event Registration: ${actionName} (${packageName})`;
778
838
  }
779
839
  /**
780
840
  * Generates a registration name and description based on the provider, events, and runtime action.
@@ -1149,6 +1209,7 @@ async function createCommerceEventSubscription(params) {
1149
1209
  name: eventName,
1150
1210
  parent: event.config.name,
1151
1211
  fields: event.config.fields,
1212
+ rules: event.config.rules,
1152
1213
  provider_id: provider.id,
1153
1214
  destination: event.config.destination,
1154
1215
  hipaa_audit_required: event.config.hipaa_audit_required,
@@ -1273,7 +1334,8 @@ async function deleteIoEventRegistrations(providerData, provider, events, regist
1273
1334
  workspaceId: appData.workspaceId
1274
1335
  };
1275
1336
  const actionEventsMap = groupEventsByRuntimeActions(events);
1276
- const registrationNames = new Set(Array.from(actionEventsMap.keys()).map((runtimeAction) => getRegistrationName(providerData, runtimeAction)));
1337
+ const runtimeActions = Array.from(actionEventsMap.keys());
1338
+ const registrationNames = new Set([...runtimeActions.map((runtimeAction) => getRegistrationName(providerData, runtimeAction)), ...runtimeActions.map((runtimeAction) => getLegacyRegistrationName(providerData, runtimeAction))]);
1277
1339
  const providerRegistrations = registrations.filter((reg) => reg.client_id === runtimeParams.AIO_COMMERCE_AUTH_IMS_CLIENT_ID && registrationNames.has(reg.name));
1278
1340
  if (providerRegistrations.length === 0) {
1279
1341
  logger.info(`No I/O Events registrations found for provider "${provider.label}" (instance ID: "${providerData.instance_id}").`);