@adobe/aio-commerce-lib-app 1.6.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/cjs/actions/app-config/index.cjs +202 -0
  3. package/dist/cjs/actions/app-config/index.d.cts +31 -0
  4. package/dist/cjs/actions/{config.cjs → config/index.cjs} +61 -33
  5. package/dist/{es/actions/config.d.mts → cjs/actions/config/index.d.cts} +10 -7
  6. package/dist/cjs/actions/{installation.cjs → installation/index.cjs} +43 -30
  7. package/dist/{es/actions/installation.d.mts → cjs/actions/installation/index.d.cts} +10 -8
  8. package/dist/cjs/actions/{registration.cjs → registration/index.cjs} +16 -6
  9. package/dist/cjs/actions/{registration.d.cts → registration/index.d.cts} +8 -8
  10. package/dist/cjs/actions/{scope-tree.cjs → scope-tree/index.cjs} +51 -14
  11. package/dist/cjs/actions/{scope-tree.d.cts → scope-tree/index.d.cts} +1 -1
  12. package/dist/cjs/{admin-ui-sdk-DZZJCrdT.d.cts → admin-ui-sdk-EU915zlR.d.cts} +7 -8
  13. package/dist/cjs/app-DrYHK-z1.d.cts +1629 -0
  14. package/dist/cjs/commands/index.cjs +12 -18
  15. package/dist/cjs/config/index.cjs +2 -2
  16. package/dist/cjs/config/index.d.cts +36 -976
  17. package/dist/cjs/{config-FNMclIFO.cjs → config-D-s0GSep.cjs} +1 -1
  18. package/dist/cjs/{index-Dw2NvVOY.d.cts → index-B5gJ-q4U.d.cts} +172 -3
  19. package/dist/{es/actions/app-config.d.mts → cjs/index-BXm8UbK7.d.cts} +1 -13
  20. package/dist/cjs/management/index.cjs +1 -1
  21. package/dist/cjs/management/index.d.cts +1 -2
  22. package/dist/cjs/{management-Cvsz4VMf.cjs → management-Dehz9qSJ.cjs} +81 -43
  23. package/dist/cjs/openapi-Cux6K4ZD.cjs +3072 -0
  24. package/dist/cjs/{validate-DydOAZha.cjs → validate-oAOpyFyb.cjs} +46 -14
  25. package/dist/es/actions/app-config/index.d.mts +31 -0
  26. package/dist/es/actions/app-config/index.mjs +199 -0
  27. package/dist/{cjs/actions/config.d.cts → es/actions/config/index.d.mts} +10 -7
  28. package/dist/es/actions/{config.mjs → config/index.mjs} +60 -32
  29. package/dist/{cjs/actions/installation.d.cts → es/actions/installation/index.d.mts} +10 -8
  30. package/dist/es/actions/{installation.mjs → installation/index.mjs} +42 -30
  31. package/dist/es/actions/{registration.d.mts → registration/index.d.mts} +8 -8
  32. package/dist/es/actions/{registration.mjs → registration/index.mjs} +16 -6
  33. package/dist/es/actions/{scope-tree.d.mts → scope-tree/index.d.mts} +1 -1
  34. package/dist/es/actions/{scope-tree.mjs → scope-tree/index.mjs} +50 -13
  35. package/dist/es/{admin-ui-sdk-hu6iWr0A.d.mts → admin-ui-sdk-BwnD0xjK.d.mts} +6 -9
  36. package/dist/es/app-DrYHK-z1.d.mts +1629 -0
  37. package/dist/es/commands/index.mjs +12 -18
  38. package/dist/es/config/index.d.mts +36 -975
  39. package/dist/es/config/index.mjs +2 -2
  40. package/dist/es/{config-CcE0EBG7.mjs → config-3I4eLyyR.mjs} +1 -1
  41. package/dist/{cjs/actions/app-config.d.cts → es/index-B0XqHwY5.d.mts} +2 -14
  42. package/dist/es/{index-Bo0tQsVq.d.mts → index-DLMbTtKS.d.mts} +172 -3
  43. package/dist/es/management/index.d.mts +1 -2
  44. package/dist/es/management/index.mjs +1 -1
  45. package/dist/es/{management-BZ4Y6lVp.mjs → management-BUX-w2Ji.mjs} +81 -44
  46. package/dist/es/openapi-B6uP0SRn.mjs +3024 -0
  47. package/dist/es/{validate-Du3LhCre.mjs → validate-Dfajrp99.mjs} +35 -15
  48. package/package.json +17 -10
  49. package/dist/cjs/actions/app-config.cjs +0 -54
  50. package/dist/cjs/app-CakwxQvs.d.cts +0 -673
  51. package/dist/cjs/step-CKVE0aJi.d.cts +0 -187
  52. package/dist/es/actions/app-config.mjs +0 -53
  53. package/dist/es/app-CakwxQvs.d.mts +0 -673
  54. package/dist/es/step-D64mMPrt.d.mts +0 -187
@@ -12,8 +12,8 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
- const require_validate = require('./validate-DydOAZha.cjs');
16
15
  const require_error = require('./error-D-N0PKSl.cjs');
16
+ const require_validate = require('./validate-oAOpyFyb.cjs');
17
17
  let path = require("path");
18
18
  let fs = require("fs");
19
19
  let fs_promises = require("fs/promises");
@@ -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.cjs";
16
- import { f as StepMetaInfo, h as ValidationIssue, i as ExecutionContext, n as BranchStep, o as InstallationContext, p as ValidationContext } from "./step-CKVE0aJi.cjs";
15
+ import { r as CommerceAppConfigOutputModel } from "./app-DrYHK-z1.cjs";
16
+ import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
17
+ import AioLogger from "@adobe/aio-lib-core-logging";
18
+ import * as v from "valibot";
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,17 +12,5 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
- import { t as CommerceAppConfig } from "../app-CakwxQvs.mjs";
16
15
  import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
17
-
18
- //#region source/actions/app-config.d.ts
19
- /** Arguments for the runtime action factory. */
20
- type RuntimeActionFactoryArgs = {
21
- appConfig: CommerceAppConfig;
22
- };
23
- /** Factory to create the route handler for the `app-config` action. */
24
- declare const appConfigRuntimeAction: ({
25
- appConfig
26
- }: RuntimeActionFactoryArgs) => (params: RuntimeActionParams) => Promise<import("@adobe/aio-commerce-lib-core/responses").ActionResponse>;
27
- //#endregion
28
- export { appConfigRuntimeAction };
16
+ import AioLogger from "@adobe/aio-lib-core-logging";
@@ -13,7 +13,7 @@
13
13
  */
14
14
 
15
15
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
16
- const require_management = require('../management-Cvsz4VMf.cjs');
16
+ const require_management = require('../management-Dehz9qSJ.cjs');
17
17
 
18
18
  exports.createInitialInstallationState = require_management.createInitialInstallationState;
19
19
  exports.createInitialUninstallationState = require_management.createInitialUninstallationState;
@@ -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-CKVE0aJi.cjs";
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-Dw2NvVOY.cjs";
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-B5gJ-q4U.cjs";
17
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 };
@@ -13,18 +13,36 @@
13
13
  */
14
14
 
15
15
  const require_chunk = require('./chunk-Cozy-1ZF.cjs');
16
+ const require_error = require('./error-D-N0PKSl.cjs');
16
17
  const require_webhooks = require('./webhooks-tbZy9G3p.cjs');
17
18
  const require_logging = require('./logging-BVz3weoC.cjs');
18
- const require_error = require('./error-D-N0PKSl.cjs');
19
+ let _adobe_aio_commerce_lib_core_error = require("@adobe/aio-commerce-lib-core/error");
20
+ let valibot = require("valibot");
21
+ valibot = require_chunk.__toESM(valibot, 1);
19
22
  let _adobe_aio_commerce_lib_api_utils = require("@adobe/aio-commerce-lib-api/utils");
20
23
  let camelcase = require("camelcase");
21
24
  camelcase = require_chunk.__toESM(camelcase, 1);
25
+ let _adobe_aio_commerce_lib_admin_ui_api = require("@adobe/aio-commerce-lib-admin-ui/api");
22
26
  let _adobe_aio_commerce_lib_api = require("@adobe/aio-commerce-lib-api");
23
27
  let _adobe_aio_commerce_lib_auth = require("@adobe/aio-commerce-lib-auth");
24
28
  let _adobe_aio_commerce_lib_events_commerce = require("@adobe/aio-commerce-lib-events/commerce");
25
29
  let _adobe_aio_commerce_lib_events_io_events = require("@adobe/aio-commerce-lib-events/io-events");
26
30
  let _adobe_aio_commerce_lib_webhooks_api = require("@adobe/aio-commerce-lib-webhooks/api");
27
31
 
32
+ //#region ../../packages-private/common-utils/source/valibot/utils.ts
33
+ /**
34
+ * Parses the input using the provided schema and throws a {@link CommerceSdkValidationError} error if the input is invalid.
35
+ * @param schema - The schema to use for parsing.
36
+ * @param input - The input to parse.
37
+ * @param message - Optional custom error message for the validation error.
38
+ */
39
+ function parseOrThrow(schema, input, message) {
40
+ const result = valibot.safeParse(schema, input);
41
+ if (!result.success) throw new _adobe_aio_commerce_lib_core_error.CommerceSdkValidationError(message ?? "Invalid input", { issues: result.issues });
42
+ return result.output;
43
+ }
44
+
45
+ //#endregion
28
46
  //#region source/management/installation/workflow/hooks.ts
29
47
  /** Helper to call a hook if it exists. */
30
48
  async function callHook(hooks, hookName, ...args) {
@@ -456,11 +474,37 @@ function aggregateSummary(result) {
456
474
  //#endregion
457
475
  //#region source/management/installation/custom-installation/custom-scripts.ts
458
476
  const camelcase$1 = camelcase.default.default ?? camelcase.default;
459
- function isCustomInstallationStepDefinition(obj) {
460
- return typeof obj === "object" && obj !== null && "install" in obj && typeof obj.install === "function";
477
+ const ScriptModuleSchema = valibot.union([valibot.function(), valibot.object({
478
+ install: valibot.function(),
479
+ uninstall: valibot.optional(valibot.function())
480
+ })]);
481
+ /**
482
+ * Validates that a loaded script export can be executed as a custom installation step.
483
+ *
484
+ * @param module - The loaded script export to validate.
485
+ * @throws If the export is not a function or an object with an `install` function.
486
+ */
487
+ function assertScriptModule(module) {
488
+ parseOrThrow(ScriptModuleSchema, module, "Invalid script module format. Expected a function or an object with an `install` method.");
489
+ }
490
+ /**
491
+ * Parses and validates a custom script module from the provided customScripts context.
492
+ * It supports both direct function exports and default exports.
493
+ *
494
+ * @param customScripts - The customScripts context containing the loaded modules
495
+ * @param script - The script path to resolve the module for
496
+ */
497
+ function getScriptModule(customScripts, script) {
498
+ let scriptModule = customScripts[script];
499
+ 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.`);
500
+ if (typeof scriptModule === "object" && "default" in scriptModule) scriptModule = scriptModule.default;
501
+ assertScriptModule(scriptModule);
502
+ return scriptModule;
461
503
  }
462
- function isCustomInstallationStepHandler(obj) {
463
- return typeof obj === "function";
504
+ function resolveCustomScriptHandler(scriptModule, handler) {
505
+ if (typeof scriptModule === "function") return handler === "install" ? scriptModule : null;
506
+ if (handler in scriptModule && typeof scriptModule[handler] === "function") return scriptModule[handler];
507
+ return null;
464
508
  }
465
509
  /**
466
510
  * Creates a leaf step for executing a single custom installation script.
@@ -478,15 +522,7 @@ function createCustomScriptStep(scriptConfig) {
478
522
  const customScripts = context.customScripts || {};
479
523
  logger.info(`Executing custom installation script: ${name}`);
480
524
  logger.debug(`Script path: ${script}`);
481
- const scriptModule = customScripts[script];
482
- 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.`);
483
- if (typeof scriptModule !== "object" || !("default" in scriptModule)) throw new Error(`Script ${script} must export a default function or object. Use defineCustomInstallationStep helper.`);
484
- const defaultExport = scriptModule.default;
485
- let runFunction = null;
486
- if (isCustomInstallationStepHandler(defaultExport)) runFunction = defaultExport;
487
- else if (isCustomInstallationStepDefinition(defaultExport)) runFunction = defaultExport.install;
488
- if (runFunction === null) throw new Error(`Script ${script} default export must be a function or an object with an install method. Use defineCustomInstallationStep helper.`);
489
- const scriptResult = await runFunction(config, context);
525
+ const scriptResult = await resolveCustomScriptHandler(getScriptModule(customScripts, script), "install")(config, context);
490
526
  logger.info(`Successfully executed script: ${name}`);
491
527
  return {
492
528
  script,
@@ -497,14 +533,7 @@ function createCustomScriptStep(scriptConfig) {
497
533
  const { logger } = context;
498
534
  const customScripts = context.customScripts || {};
499
535
  logger.debug(`Uninstalling custom script: ${name}`);
500
- const scriptModule = customScripts[script];
501
- 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.`);
502
- const defaultExport = scriptModule.default;
503
- if (!isCustomInstallationStepDefinition(defaultExport)) {
504
- logger.debug(`Script ${script} does not export an uninstall function, skipping uninstall.`);
505
- return;
506
- }
507
- const { uninstall } = defaultExport;
536
+ const uninstall = resolveCustomScriptHandler(getScriptModule(customScripts, script), "uninstall");
508
537
  if (!uninstall) {
509
538
  logger.debug(`Script ${script} does not export an uninstall function, skipping uninstall.`);
510
539
  return;
@@ -611,34 +640,40 @@ async function throwHttpError(logger, error, prefix) {
611
640
  /**
612
641
  * Registers the extension with Commerce via POST /V1/adminuisdk/extension.
613
642
  *
614
- * @param context - The execution context providing the Commerce HTTP client and logger.
615
- * @returns The response from the Commerce API.
643
+ * @param context - The execution context providing the Admin UI SDK client and logger.
616
644
  */
617
645
  async function registerExtension(context) {
618
- const { commerceClient, appData, logger } = context;
646
+ const { adminUiClient, appData, logger } = context;
647
+ const extensionName = process.env.__OW_NAMESPACE;
648
+ if (!extensionName) throw new Error("__OW_NAMESPACE environment variable is not set");
619
649
  logger.info(`Registering Admin UI SDK extension: ${appData.projectName}`);
620
- const response = await commerceClient.post("adminuisdk/extension", { json: { extension: {
621
- extensionName: process.env.__OW_NAMESPACE,
650
+ const { extensionId } = await adminUiClient.registerExtension({
651
+ extensionName,
622
652
  extensionTitle: appData.projectTitle,
623
- extensionUrl: `https://${process.env.__OW_NAMESPACE}.adobeio-static.net/index.html`,
653
+ extensionUrl: `https://${extensionName}.adobeio-static.net/index.html`,
624
654
  extensionWorkspace: appData.workspaceName
625
- } } }).json().catch((error) => throwHttpError(logger, error, "Failed to register Admin UI SDK extension"));
626
- logger.info(`Admin UI SDK extension registered successfully: ${response.extensionId}`);
627
- return response;
655
+ }).catch((error) => throwHttpError(logger, error, "Failed to register Admin UI SDK extension"));
656
+ logger.info(`Admin UI SDK extension registered successfully: ${extensionId}`);
628
657
  }
629
658
  /**
630
659
  * Unregisters the extension from Commerce via DELETE /V1/adminuisdk/extension/:workspace_name/:extension_name.
631
660
  * Best-effort: errors are logged as warnings and do not stop the uninstall workflow.
632
661
  *
633
- * @param context - The execution context providing the Commerce HTTP client and logger.
662
+ * @param context - The execution context providing the Admin UI SDK client and logger.
634
663
  */
635
- async function uninstallExtension(context) {
636
- const { commerceClient, appData, logger } = context;
664
+ async function unregisterExtension(context) {
665
+ const { adminUiClient, appData, logger } = context;
637
666
  const extensionName = process.env.__OW_NAMESPACE;
638
- const endpoint = `adminuisdk/extension/${appData.workspaceName}/${extensionName}`;
667
+ if (!extensionName) {
668
+ logger.warn("__OW_NAMESPACE environment variable is not set; skipping Admin UI SDK extension unregistration. Continuing uninstall.");
669
+ return;
670
+ }
639
671
  logger.info(`Unregistering Admin UI SDK extension "${extensionName}" from workspace "${appData.workspaceName}"...`);
640
672
  try {
641
- await commerceClient.delete(endpoint);
673
+ await adminUiClient.unregisterExtension({
674
+ workspaceName: appData.workspaceName,
675
+ extensionName
676
+ });
642
677
  logger.info(`Admin UI SDK extension "${extensionName}" unregistered successfully.`);
643
678
  } catch (error) {
644
679
  const msg = await (0, _adobe_aio_commerce_lib_api_utils.unwrapHttpError)(error);
@@ -648,19 +683,22 @@ async function uninstallExtension(context) {
648
683
 
649
684
  //#endregion
650
685
  //#region source/management/installation/admin-ui-sdk/utils.ts
651
- /** Creates the Admin UI SDK step context with a lazy-initialized Commerce HTTP client. */
686
+ function createAdminUiClient(params) {
687
+ return (0, _adobe_aio_commerce_lib_admin_ui_api.createAdminUiApiClient)((0, _adobe_aio_commerce_lib_api.resolveCommerceHttpClientParams)(params, { tryForwardAuthProvider: true }));
688
+ }
689
+ /** Creates the Admin UI SDK step context with a lazy-initialized API client. */
652
690
  const createAdminUiSdkStepContext = (installation) => {
653
691
  const { params } = installation;
654
- let commerceClient = null;
655
- return { get commerceClient() {
656
- if (commerceClient === null) commerceClient = new _adobe_aio_commerce_lib_api.AdobeCommerceHttpClient((0, _adobe_aio_commerce_lib_api.resolveCommerceHttpClientParams)(params, { tryForwardAuthProvider: true }));
657
- return commerceClient;
692
+ let adminUiClient = null;
693
+ return { get adminUiClient() {
694
+ if (adminUiClient === null) adminUiClient = createAdminUiClient(params);
695
+ return adminUiClient;
658
696
  } };
659
697
  };
660
698
 
661
699
  //#endregion
662
700
  //#region source/management/installation/admin-ui-sdk/branch.ts
663
- /** Leaf step that calls POST /V1/adminuisdk/extension to register the extension. */
701
+ /** Leaf step that registers the extension (POST) on install and unregisters it (DELETE) on uninstall. */
664
702
  const registerExtensionStep = defineLeafStep({
665
703
  name: "register-extension",
666
704
  meta: {
@@ -674,7 +712,7 @@ const registerExtensionStep = defineLeafStep({
674
712
  }
675
713
  },
676
714
  install: (_, context) => registerExtension(context),
677
- uninstall: (_, context) => uninstallExtension(context)
715
+ uninstall: (_, context) => unregisterExtension(context)
678
716
  });
679
717
  /** Branch step for setting up the Admin UI SDK extension registration. */
680
718
  const adminUiSdkStep = defineBranchStep({