@adobe/aio-commerce-lib-app 0.1.1 → 0.3.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.
- package/CHANGELOG.md +46 -0
- package/dist/cjs/actions/index.cjs +824 -0
- package/dist/cjs/actions/index.d.cts +18 -0
- package/dist/cjs/app-Dx0ca6oL.d.cts +181 -0
- package/dist/cjs/commands/generate/actions/templates/app-management/custom-scripts.js.template +28 -0
- package/dist/cjs/commands/generate/actions/templates/app-management/get-app-config.js.template +62 -0
- package/dist/cjs/commands/generate/actions/templates/app-management/installation.js.template +21 -0
- package/dist/cjs/commands/generate/actions/templates/{get-app-config.js.template → business-configuration/get-config-schema.js.template} +13 -11
- package/dist/cjs/commands/generate/actions/templates/business-configuration/get-configuration.js.template +104 -0
- package/dist/cjs/commands/generate/actions/templates/business-configuration/get-scope-tree.js.template +69 -0
- package/dist/cjs/commands/generate/actions/templates/business-configuration/set-configuration.js.template +125 -0
- package/dist/cjs/commands/generate/actions/templates/business-configuration/set-custom-scope-tree.js.template +83 -0
- package/dist/cjs/commands/generate/actions/templates/business-configuration/sync-commerce-scopes.js.template +113 -0
- package/dist/cjs/commands/generate/actions/templates/business-configuration/unsync-commerce-scopes.js.template +56 -0
- package/dist/cjs/commands/index.cjs +1075 -117
- package/dist/cjs/config/index.cjs +20 -1
- package/dist/cjs/config/index.d.cts +591 -364
- package/dist/cjs/config-JQ_n-5Nk.cjs +565 -0
- package/dist/cjs/error-Byj1DVHZ.cjs +344 -0
- package/dist/cjs/index-C5SutkJQ.d.cts +345 -0
- package/dist/cjs/logging-DYwr5WQk.cjs +25 -0
- package/dist/cjs/management/index.cjs +9 -0
- package/dist/cjs/management/index.d.cts +2 -0
- package/dist/cjs/management-Dm5h0E6l.cjs +1246 -0
- package/dist/es/actions/index.d.mts +18 -0
- package/dist/es/actions/index.mjs +822 -0
- package/dist/es/app-Cx1-6dn0.d.mts +181 -0
- package/dist/es/commands/generate/actions/templates/app-management/custom-scripts.js.template +28 -0
- package/dist/es/commands/generate/actions/templates/app-management/get-app-config.js.template +62 -0
- package/dist/es/commands/generate/actions/templates/app-management/installation.js.template +21 -0
- package/dist/es/commands/generate/actions/templates/{get-app-config.js.template → business-configuration/get-config-schema.js.template} +13 -11
- package/dist/es/commands/generate/actions/templates/business-configuration/get-configuration.js.template +104 -0
- package/dist/es/commands/generate/actions/templates/business-configuration/get-scope-tree.js.template +69 -0
- package/dist/es/commands/generate/actions/templates/business-configuration/set-configuration.js.template +125 -0
- package/dist/es/commands/generate/actions/templates/business-configuration/set-custom-scope-tree.js.template +83 -0
- package/dist/es/commands/generate/actions/templates/business-configuration/sync-commerce-scopes.js.template +113 -0
- package/dist/es/commands/generate/actions/templates/business-configuration/unsync-commerce-scopes.js.template +56 -0
- package/dist/es/commands/index.mjs +1070 -117
- package/dist/es/config/index.d.mts +591 -364
- package/dist/es/config/index.mjs +4 -1
- package/dist/es/config-BSGerqCG.mjs +457 -0
- package/dist/es/error-P7JgUTds.mjs +251 -0
- package/dist/es/index-Bxr3zvCT.d.mts +345 -0
- package/dist/es/logging-VgerMhp6.mjs +18 -0
- package/dist/es/management/index.d.mts +3 -0
- package/dist/es/management/index.mjs +3 -0
- package/dist/es/management-Y7pwEbNI.mjs +1204 -0
- package/package.json +46 -6
- package/dist/cjs/parser-x_oUOtEM.cjs +0 -1
- package/dist/es/parser-djQHmDCQ.mjs +0 -1
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import { n as CommerceAppConfigOutputModel } from "./app-Dx0ca6oL.cjs";
|
|
2
|
+
import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
|
|
3
|
+
import * as v from "valibot";
|
|
4
|
+
import AioLogger from "@adobe/aio-lib-core-logging";
|
|
5
|
+
|
|
6
|
+
//#region source/management/installation/schema.d.ts
|
|
7
|
+
/** Schema for validating Adobe I/O app credentials required for installation. */
|
|
8
|
+
declare const AppDataSchema: v.ObjectSchema<{
|
|
9
|
+
readonly consumerOrgId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
10
|
+
readonly orgName: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
11
|
+
readonly projectId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
12
|
+
readonly projectName: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
13
|
+
readonly projectTitle: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
14
|
+
readonly workspaceId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
15
|
+
readonly workspaceName: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
16
|
+
readonly workspaceTitle: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
17
|
+
}, undefined>;
|
|
18
|
+
/** Type for Adobe I/O app credentials. */
|
|
19
|
+
type AppData = v.InferOutput<typeof AppDataSchema>;
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region source/management/installation/workflow/step.d.ts
|
|
22
|
+
/** Shared context available to all steps during installation. */
|
|
23
|
+
type InstallationContext = {
|
|
24
|
+
/** The credentials of the app being installed */
|
|
25
|
+
appData: AppData;
|
|
26
|
+
/** The raw action parameters from the App Builder runtime action. */
|
|
27
|
+
params: RuntimeActionParams & {
|
|
28
|
+
AIO_COMMERCE_AUTH_IMS_CLIENT_ID: string;
|
|
29
|
+
AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS: string | string[];
|
|
30
|
+
AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_ID: string;
|
|
31
|
+
AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_EMAIL: string;
|
|
32
|
+
AIO_COMMERCE_AUTH_IMS_ORG_ID: string;
|
|
33
|
+
AIO_COMMERCE_AUTH_IMS_SCOPES: string | string[];
|
|
34
|
+
};
|
|
35
|
+
/** Logger instance for installation logging. */
|
|
36
|
+
logger: ReturnType<typeof AioLogger>;
|
|
37
|
+
/** Custom scripts defined in the configuration (if any). */
|
|
38
|
+
customScripts?: Record<string, unknown>;
|
|
39
|
+
};
|
|
40
|
+
/** Factory function type for creating step-specific context. */
|
|
41
|
+
type StepContextFactory<TStepCtx extends Record<string, unknown> = Record<string, unknown>> = (context: InstallationContext) => TStepCtx | Promise<TStepCtx>;
|
|
42
|
+
/** The execution context passed to leaf step run handlers. */
|
|
43
|
+
type ExecutionContext<TStepCtx extends Record<string, unknown> = Record<string, unknown>> = InstallationContext & TStepCtx;
|
|
44
|
+
/** Metadata for a step (used for UI display). */
|
|
45
|
+
type StepMeta = {
|
|
46
|
+
label: string;
|
|
47
|
+
description?: string;
|
|
48
|
+
};
|
|
49
|
+
/** Defines the base properties of a step. */
|
|
50
|
+
type StepBase<TName extends string = string, TConfig extends CommerceAppConfigOutputModel = CommerceAppConfigOutputModel> = {
|
|
51
|
+
/** The name of this step. */
|
|
52
|
+
name: TName;
|
|
53
|
+
/** Metadata associated with the step. */
|
|
54
|
+
meta: StepMeta;
|
|
55
|
+
/** Whether the step should be taken into consideration. */
|
|
56
|
+
when?: (config: CommerceAppConfigOutputModel) => config is TConfig;
|
|
57
|
+
};
|
|
58
|
+
/** A leaf step that executes work (no children). */
|
|
59
|
+
type LeafStep<TName extends string = string, TConfig extends CommerceAppConfigOutputModel = CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TOutput$1 = unknown> = StepBase<TName, TConfig> & {
|
|
60
|
+
type: "leaf";
|
|
61
|
+
/** The execution handler for the step. */
|
|
62
|
+
run: (config: TConfig, context: ExecutionContext<TStepCtx>) => TOutput$1 | Promise<TOutput$1>;
|
|
63
|
+
};
|
|
64
|
+
/** A branch step that contains children (no execution). */
|
|
65
|
+
type BranchStep<TName extends string = string, TConfig extends CommerceAppConfigOutputModel = CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>> = StepBase<TName, TConfig> & {
|
|
66
|
+
type: "branch";
|
|
67
|
+
/** An optional factory function to setup shared context for the children steps. */
|
|
68
|
+
context?: StepContextFactory<TStepCtx>;
|
|
69
|
+
/** The children steps of this branch. */
|
|
70
|
+
children: AnyStep[];
|
|
71
|
+
};
|
|
72
|
+
/** A step in the installation tree (discriminated union by `type`). */
|
|
73
|
+
type Step<TName extends string = string, TConfig extends CommerceAppConfigOutputModel = CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TOutput$1 = unknown> = LeafStep<TName, TConfig, TStepCtx, TOutput$1> | BranchStep<TName, TConfig, TStepCtx>;
|
|
74
|
+
/** Loosely-typed step for use in non type-safe contexts. */
|
|
75
|
+
interface AnyStep {
|
|
76
|
+
type: "leaf" | "branch";
|
|
77
|
+
name: string;
|
|
78
|
+
meta: StepMeta;
|
|
79
|
+
when?: (config: CommerceAppConfigOutputModel) => boolean;
|
|
80
|
+
children?: AnyStep[];
|
|
81
|
+
context?: (context: InstallationContext) => any;
|
|
82
|
+
run?: (config: any, context: any) => unknown | Promise<unknown>;
|
|
83
|
+
}
|
|
84
|
+
/** Check if a step is a leaf step. */
|
|
85
|
+
declare function isLeafStep(step: AnyStep): step is LeafStep;
|
|
86
|
+
/** Check if a step is a branch step. */
|
|
87
|
+
declare function isBranchStep(step: AnyStep): step is BranchStep;
|
|
88
|
+
/** Options for defining a leaf step. */
|
|
89
|
+
type LeafStepOptions<TName extends string, TConfig extends CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TOutput$1 = unknown> = Omit<LeafStep<TName, TConfig, TStepCtx, TOutput$1>, "type">;
|
|
90
|
+
/** Options for defining a branch step. */
|
|
91
|
+
type BranchStepOptions<TName extends string, TConfig extends CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>> = Omit<BranchStep<TName, TConfig, TStepCtx>, "type">;
|
|
92
|
+
/**
|
|
93
|
+
* Define a leaf step (executable, no children).
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* const createProviders = defineLeafStep({
|
|
98
|
+
* name: "providers",
|
|
99
|
+
* meta: { label: "Create Providers", description: "Creates I/O Events providers" },
|
|
100
|
+
* run: async ({ config, stepContext }) => {
|
|
101
|
+
* const { eventsClient } = stepContext;
|
|
102
|
+
* return eventsClient.createProvider(config.eventing);
|
|
103
|
+
* },
|
|
104
|
+
* });
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
declare function defineLeafStep<TName extends string, TConfig extends CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TOutput$1 = unknown>(options: LeafStepOptions<TName, TConfig, TStepCtx, TOutput$1>): LeafStep<TName, TConfig, TStepCtx, TOutput$1>;
|
|
108
|
+
/**
|
|
109
|
+
* Define a branch step (container with children, no runner).
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* const eventing = defineBranchStep({
|
|
114
|
+
* name: "eventing",
|
|
115
|
+
* meta: { label: "Eventing", description: "Sets up I/O Events" },
|
|
116
|
+
* when: hasEventing,
|
|
117
|
+
* context: async (ctx) => ({ eventsClient: await createEventsClient(ctx) }),
|
|
118
|
+
* children: [commerceEventsStep, externalEventsStep],
|
|
119
|
+
* });
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
declare function defineBranchStep<TName extends string, TConfig extends CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>>(options: BranchStepOptions<TName, TConfig, TStepCtx>): BranchStep<TName, TConfig, TStepCtx>;
|
|
123
|
+
/** Infer the output type from a leaf step. */
|
|
124
|
+
type InferStepOutput<TStep> = TStep extends LeafStep<infer _TName, infer _TConfig, infer _TStepCtx, infer TOutput> ? Awaited<TOutput> : never;
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region source/management/installation/workflow/types.d.ts
|
|
127
|
+
/** Status of a step execution. */
|
|
128
|
+
type ExecutionStatus = "pending" | "in-progress" | "succeeded" | "failed";
|
|
129
|
+
/** Overall installation status. */
|
|
130
|
+
type InstallationStatus = "pending" | "in-progress" | "succeeded" | "failed";
|
|
131
|
+
/** A structured error with path to the failing step. */
|
|
132
|
+
type InstallationError<TPayload = unknown> = {
|
|
133
|
+
/** Path to the step that failed (e.g., ["eventing", "commerce", "providers"]). */
|
|
134
|
+
path: string[];
|
|
135
|
+
/** Error key for easy identification. */
|
|
136
|
+
key: string;
|
|
137
|
+
/** Human-readable error message. */
|
|
138
|
+
message?: string;
|
|
139
|
+
/** Additional error payload. */
|
|
140
|
+
payload?: TPayload;
|
|
141
|
+
};
|
|
142
|
+
/** Status of a step in the installation tree. */
|
|
143
|
+
type StepStatus = {
|
|
144
|
+
/** Step name (unique among siblings). */
|
|
145
|
+
name: string;
|
|
146
|
+
/** Unique step identifier (e.g., UUID). */
|
|
147
|
+
id: string;
|
|
148
|
+
/** Full path from root to this step. */
|
|
149
|
+
path: string[];
|
|
150
|
+
/** Step metadata (for display purposes). */
|
|
151
|
+
meta: StepMeta;
|
|
152
|
+
/** Current execution status. */
|
|
153
|
+
status: ExecutionStatus;
|
|
154
|
+
/** Child step statuses (empty for leaf steps). */
|
|
155
|
+
children: StepStatus[];
|
|
156
|
+
};
|
|
157
|
+
/** Data collected during installation as a nested structure following step paths. */
|
|
158
|
+
type InstallationData = {
|
|
159
|
+
[key: string]: unknown | InstallationData;
|
|
160
|
+
};
|
|
161
|
+
/** Base properties shared by all installation states. */
|
|
162
|
+
type InstallationStateBase = {
|
|
163
|
+
/** Unique installation identifier. */
|
|
164
|
+
id: string;
|
|
165
|
+
/** Root step status. */
|
|
166
|
+
step: StepStatus;
|
|
167
|
+
/** Results from executed leaf steps, keyed by path. */
|
|
168
|
+
data: InstallationData | null;
|
|
169
|
+
};
|
|
170
|
+
/** Installation state when in progress. */
|
|
171
|
+
type InProgressInstallationState = InstallationStateBase & {
|
|
172
|
+
status: "in-progress";
|
|
173
|
+
/** ISO timestamp when installation started. */
|
|
174
|
+
startedAt: string;
|
|
175
|
+
};
|
|
176
|
+
/** Installation state when completed successfully. */
|
|
177
|
+
type SucceededInstallationState = InstallationStateBase & {
|
|
178
|
+
status: "succeeded";
|
|
179
|
+
/** ISO timestamp when installation started. */
|
|
180
|
+
startedAt: string;
|
|
181
|
+
/** ISO timestamp when installation completed. */
|
|
182
|
+
completedAt: string;
|
|
183
|
+
};
|
|
184
|
+
/** Installation state when failed. */
|
|
185
|
+
type FailedInstallationState = InstallationStateBase & {
|
|
186
|
+
status: "failed";
|
|
187
|
+
/** ISO timestamp when installation started. */
|
|
188
|
+
startedAt: string;
|
|
189
|
+
/** ISO timestamp when installation failed. */
|
|
190
|
+
completedAt: string;
|
|
191
|
+
/** Error information about the failure. */
|
|
192
|
+
error: InstallationError;
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* The full installation state (persisted and returned by status endpoints).
|
|
196
|
+
* Discriminated union by `status` field.
|
|
197
|
+
*/
|
|
198
|
+
type InstallationState = InProgressInstallationState | SucceededInstallationState | FailedInstallationState;
|
|
199
|
+
/** Type guard for pending installation state. */
|
|
200
|
+
/** Type guard for in-progress installation state. */
|
|
201
|
+
declare function isInProgressState(state: InstallationState): state is InProgressInstallationState;
|
|
202
|
+
/** Type guard for succeeded installation state. */
|
|
203
|
+
declare function isSucceededState(state: InstallationState): state is SucceededInstallationState;
|
|
204
|
+
/** Type guard for failed installation state. */
|
|
205
|
+
declare function isFailedState(state: InstallationState): state is FailedInstallationState;
|
|
206
|
+
/** Type guard for completed installation state (succeeded or failed). */
|
|
207
|
+
declare function isCompletedState(state: InstallationState): state is SucceededInstallationState | FailedInstallationState;
|
|
208
|
+
//#endregion
|
|
209
|
+
//#region source/management/installation/workflow/hooks.d.ts
|
|
210
|
+
/** Hook function that receives an event and the current state. */
|
|
211
|
+
type HookFunction<TEvent> = (event: TEvent, state: InstallationState) => void | Promise<void>;
|
|
212
|
+
/** Hook function that only receives the current state. */
|
|
213
|
+
type InstallationHook = (state: InstallationState) => void | Promise<void>;
|
|
214
|
+
/** Base event payload for step events. */
|
|
215
|
+
type StepEvent = {
|
|
216
|
+
/** Full path to the step (e.g., ["eventing", "commerce", "providers"]). */
|
|
217
|
+
path: string[];
|
|
218
|
+
/** Step name (last element of path, for convenience). */
|
|
219
|
+
stepName: string;
|
|
220
|
+
/** Whether this is a leaf step (executable) or branch step (container). */
|
|
221
|
+
isLeaf: boolean;
|
|
222
|
+
};
|
|
223
|
+
/** Event payload when a step starts execution. */
|
|
224
|
+
type StepStartedEvent = StepEvent;
|
|
225
|
+
/** Event payload when a step succeeds. */
|
|
226
|
+
type StepSucceededEvent = StepEvent & {
|
|
227
|
+
/** Result returned by the step (only for leaf steps). */
|
|
228
|
+
result: unknown;
|
|
229
|
+
};
|
|
230
|
+
/** Event payload when a step fails. */
|
|
231
|
+
type StepFailedEvent = StepEvent & {
|
|
232
|
+
/** Error information. */
|
|
233
|
+
error: InstallationError;
|
|
234
|
+
};
|
|
235
|
+
/** Lifecycle hooks for installation execution. */
|
|
236
|
+
type InstallationHooks = {
|
|
237
|
+
onInstallationStart?: InstallationHook;
|
|
238
|
+
onInstallationSuccess?: InstallationHook;
|
|
239
|
+
onInstallationFailure?: InstallationHook;
|
|
240
|
+
onStepStart?: HookFunction<StepStartedEvent>;
|
|
241
|
+
onStepSuccess?: HookFunction<StepSucceededEvent>;
|
|
242
|
+
onStepFailure?: HookFunction<StepFailedEvent>;
|
|
243
|
+
};
|
|
244
|
+
//#endregion
|
|
245
|
+
//#region source/management/installation/workflow/runner.d.ts
|
|
246
|
+
/** Options for creating an initial installation state. */
|
|
247
|
+
type CreateInitialStateOptions = {
|
|
248
|
+
/** The root branch step to build the state from. */
|
|
249
|
+
rootStep: BranchStep;
|
|
250
|
+
/** The app configuration used to determine applicable steps. */
|
|
251
|
+
config: CommerceAppConfigOutputModel;
|
|
252
|
+
};
|
|
253
|
+
/** Options for executing a workflow. */
|
|
254
|
+
type ExecuteWorkflowOptions = {
|
|
255
|
+
/** The root branch step to execute. */
|
|
256
|
+
rootStep: BranchStep;
|
|
257
|
+
/** Shared installation context (params, logger, etc.). */
|
|
258
|
+
installationContext: InstallationContext;
|
|
259
|
+
/** The app configuration. */
|
|
260
|
+
config: CommerceAppConfigOutputModel;
|
|
261
|
+
/** The initial installation state (with all steps pending). */
|
|
262
|
+
initialState: InProgressInstallationState;
|
|
263
|
+
/** Lifecycle hooks for status change notifications. */
|
|
264
|
+
hooks?: InstallationHooks;
|
|
265
|
+
};
|
|
266
|
+
/**
|
|
267
|
+
* Creates an initial installation state from a root step and config.
|
|
268
|
+
*
|
|
269
|
+
* Filters steps based on their `when` conditions and builds a
|
|
270
|
+
* tree structure with all steps set to "pending".
|
|
271
|
+
*/
|
|
272
|
+
declare function createInitialState(options: CreateInitialStateOptions): InProgressInstallationState;
|
|
273
|
+
/**
|
|
274
|
+
* Executes a workflow from an initial state. Returns the final state (never throws).
|
|
275
|
+
*/
|
|
276
|
+
declare function executeWorkflow(options: ExecuteWorkflowOptions): Promise<SucceededInstallationState | FailedInstallationState>;
|
|
277
|
+
//#endregion
|
|
278
|
+
//#region source/management/installation/custom-installation/define.d.ts
|
|
279
|
+
/**
|
|
280
|
+
* Handler function type for custom installation steps.
|
|
281
|
+
*
|
|
282
|
+
* @param config - The validated commerce app configuration
|
|
283
|
+
* @param context - Execution context with logger, params, and other utilities
|
|
284
|
+
* @returns The result of the installation step (can be any value or Promise)
|
|
285
|
+
*/
|
|
286
|
+
type CustomInstallationStepHandler<TResult = unknown> = (config: CommerceAppConfigOutputModel, context: ExecutionContext) => TResult | Promise<TResult>;
|
|
287
|
+
/**
|
|
288
|
+
* Define a custom installation step with type-safe parameters.
|
|
289
|
+
*
|
|
290
|
+
* This helper provides type safety and IDE autocompletion for custom installation scripts.
|
|
291
|
+
* The handler function receives properly typed `config` and `context` parameters.
|
|
292
|
+
*
|
|
293
|
+
* @param handler - The installation step handler function
|
|
294
|
+
* @returns The same handler function (for use as default export)
|
|
295
|
+
*
|
|
296
|
+
* @example
|
|
297
|
+
* ```typescript
|
|
298
|
+
* import { defineCustomInstallationStep } from "@adobe/aio-commerce-lib-app/management";
|
|
299
|
+
*
|
|
300
|
+
* export default defineCustomInstallationStep(async (config, context) => {
|
|
301
|
+
* const { logger, params } = context;
|
|
302
|
+
*
|
|
303
|
+
* logger.info(`Setting up ${config.metadata.displayName}...`);
|
|
304
|
+
*
|
|
305
|
+
* // Your installation logic here
|
|
306
|
+
* // TypeScript will provide autocompletion for config and context
|
|
307
|
+
*
|
|
308
|
+
* return {
|
|
309
|
+
* status: "success",
|
|
310
|
+
* message: "Setup completed",
|
|
311
|
+
* };
|
|
312
|
+
* });
|
|
313
|
+
* ```
|
|
314
|
+
*/
|
|
315
|
+
declare function defineCustomInstallationStep<TResult = unknown>(handler: CustomInstallationStepHandler<TResult>): CustomInstallationStepHandler<TResult>;
|
|
316
|
+
//#endregion
|
|
317
|
+
//#region source/management/installation/runner.d.ts
|
|
318
|
+
/** Options for creating an initial installation state. */
|
|
319
|
+
type CreateInitialInstallationStateOptions = {
|
|
320
|
+
/** The app configuration used to determine applicable steps. */
|
|
321
|
+
config: CommerceAppConfigOutputModel;
|
|
322
|
+
};
|
|
323
|
+
/** Options for running an installation. */
|
|
324
|
+
type RunInstallationOptions = {
|
|
325
|
+
/** Shared installation context (params, logger, etc.). */
|
|
326
|
+
installationContext: InstallationContext;
|
|
327
|
+
/** The app configuration. */
|
|
328
|
+
config: CommerceAppConfigOutputModel;
|
|
329
|
+
/** The initial installation state (with all steps pending). */
|
|
330
|
+
initialState: InProgressInstallationState;
|
|
331
|
+
/** Lifecycle hooks for status change notifications. */
|
|
332
|
+
hooks?: InstallationHooks;
|
|
333
|
+
};
|
|
334
|
+
/**
|
|
335
|
+
* Creates an initial installation state from the config and step definitions.
|
|
336
|
+
* Filters steps based on their `when` conditions and builds a tree structure
|
|
337
|
+
* with all steps set to "pending".
|
|
338
|
+
*/
|
|
339
|
+
declare function createInitialInstallationState(options: CreateInitialInstallationStateOptions): InProgressInstallationState;
|
|
340
|
+
/**
|
|
341
|
+
* Runs the full installation workflow. Returns the final state (never throws).
|
|
342
|
+
*/
|
|
343
|
+
declare function runInstallation(options: RunInstallationOptions): Promise<SucceededInstallationState | FailedInstallationState>;
|
|
344
|
+
//#endregion
|
|
345
|
+
export { BranchStep as A, defineBranchStep as B, StepStatus as C, isInProgressState as D, isFailedState as E, LeafStep as F, isBranchStep as H, LeafStepOptions as I, Step as L, ExecutionContext as M, InferStepOutput as N, isSucceededState as O, InstallationContext as P, StepContextFactory as R, InstallationStatus as S, isCompletedState as T, isLeafStep as U, defineLeafStep as V, FailedInstallationState as _, CustomInstallationStepHandler as a, InstallationError as b, ExecuteWorkflowOptions as c, InstallationHooks as d, StepEvent as f, ExecutionStatus as g, StepSucceededEvent as h, runInstallation as i, BranchStepOptions as j, AnyStep as k, createInitialState as l, StepStartedEvent as m, RunInstallationOptions as n, defineCustomInstallationStep as o, StepFailedEvent as p, createInitialInstallationState as r, CreateInitialStateOptions as s, CreateInitialInstallationStateOptions as t, executeWorkflow as u, InProgressInstallationState as v, SucceededInstallationState as w, InstallationState as x, InstallationData as y, StepMeta as z };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const require_error = require('./error-Byj1DVHZ.cjs');
|
|
2
|
+
let util = require("util");
|
|
3
|
+
util = require_error.__toESM(util);
|
|
4
|
+
|
|
5
|
+
//#region ../../packages-private/common-utils/source/logging.ts
|
|
6
|
+
/**
|
|
7
|
+
* Shorthand to inspect an object.
|
|
8
|
+
*
|
|
9
|
+
* @param obj - The object to inspect.
|
|
10
|
+
* @returns A string representation of the object.
|
|
11
|
+
*/
|
|
12
|
+
function inspect(obj, params = {}) {
|
|
13
|
+
return util.default.inspect(obj, {
|
|
14
|
+
depth: null,
|
|
15
|
+
...params
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
Object.defineProperty(exports, 'inspect', {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () {
|
|
23
|
+
return inspect;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const require_management = require('../management-Dm5h0E6l.cjs');
|
|
2
|
+
|
|
3
|
+
exports.createInitialInstallationState = require_management.createInitialInstallationState;
|
|
4
|
+
exports.defineCustomInstallationStep = require_management.defineCustomInstallationStep;
|
|
5
|
+
exports.isCompletedState = require_management.isCompletedState;
|
|
6
|
+
exports.isFailedState = require_management.isFailedState;
|
|
7
|
+
exports.isInProgressState = require_management.isInProgressState;
|
|
8
|
+
exports.isSucceededState = require_management.isSucceededState;
|
|
9
|
+
exports.runInstallation = require_management.runInstallation;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { A as BranchStep, B as defineBranchStep, C as StepStatus, D as isInProgressState, E as isFailedState, F as LeafStep, H as isBranchStep, I as LeafStepOptions, L as Step, M as ExecutionContext, N as InferStepOutput, O as isSucceededState, P as InstallationContext, R as StepContextFactory, S as InstallationStatus, T as isCompletedState, U as isLeafStep, V as defineLeafStep, _ as FailedInstallationState, a as CustomInstallationStepHandler, b as InstallationError, c as ExecuteWorkflowOptions, d as InstallationHooks, f as StepEvent, g as ExecutionStatus, h as StepSucceededEvent, i as runInstallation, j as BranchStepOptions, k as AnyStep, l as createInitialState, m as StepStartedEvent, n as RunInstallationOptions, o as defineCustomInstallationStep, p as StepFailedEvent, r as createInitialInstallationState, s as CreateInitialStateOptions, t as CreateInitialInstallationStateOptions, u as executeWorkflow, v as InProgressInstallationState, w as SucceededInstallationState, x as InstallationState, y as InstallationData, z as StepMeta } from "../index-C5SutkJQ.cjs";
|
|
2
|
+
export { AnyStep, BranchStep, BranchStepOptions, CreateInitialInstallationStateOptions, CreateInitialStateOptions, CustomInstallationStepHandler, ExecuteWorkflowOptions, ExecutionContext, ExecutionStatus, FailedInstallationState, InProgressInstallationState, InferStepOutput, InstallationContext, InstallationData, InstallationError, InstallationHooks, InstallationState, InstallationStatus, LeafStep, LeafStepOptions, RunInstallationOptions, Step, StepContextFactory, StepEvent, StepFailedEvent, StepMeta, StepStartedEvent, StepStatus, StepSucceededEvent, SucceededInstallationState, createInitialInstallationState, createInitialState, defineBranchStep, defineCustomInstallationStep, defineLeafStep, executeWorkflow, isBranchStep, isCompletedState, isFailedState, isInProgressState, isLeafStep, isSucceededState, runInstallation };
|