@adobe/aio-commerce-lib-app 0.3.1 → 1.0.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 +39 -0
- package/README.md +1 -4
- package/bin/cli.mjs +24 -0
- package/dist/cjs/actions/app-config.cjs +27 -0
- package/dist/cjs/actions/app-config.d.cts +15 -0
- package/dist/cjs/actions/config.cjs +79 -0
- package/dist/cjs/actions/config.d.cts +15 -0
- package/dist/cjs/actions/installation.cjs +424 -0
- package/dist/cjs/actions/{index.d.cts → installation.d.cts} +4 -3
- package/dist/cjs/actions/scope-tree.cjs +97 -0
- package/dist/cjs/actions/scope-tree.d.cts +8 -0
- package/dist/cjs/{app-Dx0ca6oL.d.cts → app-PTKvEBea.d.cts} +6 -6
- package/dist/cjs/commands/generate/actions/templates/app-management/app-config.js.template +22 -0
- package/dist/cjs/commands/generate/actions/templates/app-management/installation.js.template +1 -1
- package/dist/cjs/commands/generate/actions/templates/business-configuration/config.js.template +22 -0
- package/dist/cjs/commands/generate/actions/templates/business-configuration/scope-tree.js.template +18 -0
- package/dist/cjs/commands/index.cjs +105 -113
- package/dist/cjs/config/index.cjs +21 -19
- package/dist/cjs/config/index.d.cts +32 -332
- package/dist/cjs/error-DJ2UAPH2.cjs +24 -0
- package/dist/cjs/installation-nwF2RC7F.cjs +241 -0
- package/dist/cjs/{logging-DYwr5WQk.cjs → logging-IDRQG0as.cjs} +2 -2
- package/dist/cjs/management/index.cjs +9 -8
- package/dist/cjs/management/index.d.cts +2 -2
- package/dist/cjs/parser-DIchX9SL.cjs +267 -0
- package/dist/cjs/router-DCw7oEQ9.cjs +417 -0
- package/dist/cjs/{management-Dm5h0E6l.cjs → runner-CUJ8RHzY.cjs} +24 -30
- package/dist/{es/index-Bxr3zvCT.d.mts → cjs/runner-Ds2m27Q4.d.cts} +49 -95
- package/dist/cjs/schemas-CZ6c8Id9.cjs +98 -0
- package/dist/cjs/validate-BegMfe-i.cjs +235 -0
- package/dist/es/actions/app-config.d.mts +15 -0
- package/dist/es/actions/app-config.mjs +25 -0
- package/dist/es/actions/config.d.mts +15 -0
- package/dist/es/actions/config.mjs +77 -0
- package/dist/es/actions/{index.d.mts → installation.d.mts} +4 -3
- package/dist/es/actions/{index.mjs → installation.mjs} +27 -427
- package/dist/es/actions/scope-tree.d.mts +8 -0
- package/dist/es/actions/scope-tree.mjs +95 -0
- package/dist/es/{app-Cx1-6dn0.d.mts → app-vKXaAr6f.d.mts} +6 -6
- package/dist/es/commands/generate/actions/templates/app-management/app-config.js.template +22 -0
- package/dist/es/commands/generate/actions/templates/app-management/installation.js.template +1 -1
- package/dist/es/commands/generate/actions/templates/business-configuration/config.js.template +22 -0
- package/dist/es/commands/generate/actions/templates/business-configuration/scope-tree.js.template +18 -0
- package/dist/es/commands/index.mjs +82 -91
- package/dist/es/config/index.d.mts +32 -332
- package/dist/es/config/index.mjs +3 -2
- package/dist/es/error-CMV3IjBz.mjs +18 -0
- package/dist/es/{error-P7JgUTds.mjs → installation-SWIwhpKT.mjs} +72 -124
- package/dist/es/management/index.d.mts +2 -3
- package/dist/es/management/index.mjs +1 -1
- package/dist/es/parser-CKQyrTB7.mjs +201 -0
- package/dist/es/router-CJ4VWoCt.mjs +404 -0
- package/dist/es/{management-Y7pwEbNI.mjs → runner-DB2tDBQS.mjs} +17 -24
- package/dist/{cjs/index-C5SutkJQ.d.cts → es/runner-Uk7263hG.d.mts} +49 -95
- package/dist/es/schemas-B8yIv0_b.mjs +41 -0
- package/dist/es/validate-DXI6gwZ2.mjs +187 -0
- package/package.json +39 -25
- package/dist/cjs/actions/index.cjs +0 -824
- package/dist/cjs/commands/generate/actions/templates/app-management/get-app-config.js.template +0 -62
- package/dist/cjs/commands/generate/actions/templates/business-configuration/get-config-schema.js.template +0 -63
- package/dist/cjs/commands/generate/actions/templates/business-configuration/get-configuration.js.template +0 -104
- package/dist/cjs/commands/generate/actions/templates/business-configuration/get-scope-tree.js.template +0 -69
- package/dist/cjs/commands/generate/actions/templates/business-configuration/set-configuration.js.template +0 -125
- package/dist/cjs/commands/generate/actions/templates/business-configuration/set-custom-scope-tree.js.template +0 -83
- package/dist/cjs/commands/generate/actions/templates/business-configuration/sync-commerce-scopes.js.template +0 -113
- package/dist/cjs/commands/generate/actions/templates/business-configuration/unsync-commerce-scopes.js.template +0 -56
- package/dist/cjs/config-JQ_n-5Nk.cjs +0 -565
- package/dist/cjs/error-Byj1DVHZ.cjs +0 -344
- package/dist/es/commands/generate/actions/templates/app-management/get-app-config.js.template +0 -62
- package/dist/es/commands/generate/actions/templates/business-configuration/get-config-schema.js.template +0 -63
- package/dist/es/commands/generate/actions/templates/business-configuration/get-configuration.js.template +0 -104
- package/dist/es/commands/generate/actions/templates/business-configuration/get-scope-tree.js.template +0 -69
- package/dist/es/commands/generate/actions/templates/business-configuration/set-configuration.js.template +0 -125
- package/dist/es/commands/generate/actions/templates/business-configuration/set-custom-scope-tree.js.template +0 -83
- package/dist/es/commands/generate/actions/templates/business-configuration/sync-commerce-scopes.js.template +0 -113
- package/dist/es/commands/generate/actions/templates/business-configuration/unsync-commerce-scopes.js.template +0 -56
- package/dist/es/config-BSGerqCG.mjs +0 -457
- /package/dist/es/{logging-VgerMhp6.mjs → logging-CzmXDzxI.mjs} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as CommerceAppConfigOutputModel } from "./app-
|
|
2
|
-
import AioLogger from "@adobe/aio-lib-core-logging";
|
|
3
|
-
import * as v from "valibot";
|
|
1
|
+
import { n as CommerceAppConfigOutputModel } from "./app-PTKvEBea.cjs";
|
|
4
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
5
|
|
|
6
6
|
//#region source/management/installation/schema.d.ts
|
|
7
7
|
/** Schema for validating Adobe I/O app credentials required for installation. */
|
|
@@ -21,9 +21,7 @@ type AppData = v.InferOutput<typeof AppDataSchema>;
|
|
|
21
21
|
//#region source/management/installation/workflow/step.d.ts
|
|
22
22
|
/** Shared context available to all steps during installation. */
|
|
23
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. */
|
|
24
|
+
/** The credentials of the app being installed */appData: AppData; /** The raw action parameters from the App Builder runtime action. */
|
|
27
25
|
params: RuntimeActionParams & {
|
|
28
26
|
AIO_COMMERCE_AUTH_IMS_CLIENT_ID: string;
|
|
29
27
|
AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS: string | string[];
|
|
@@ -31,10 +29,8 @@ type InstallationContext = {
|
|
|
31
29
|
AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_EMAIL: string;
|
|
32
30
|
AIO_COMMERCE_AUTH_IMS_ORG_ID: string;
|
|
33
31
|
AIO_COMMERCE_AUTH_IMS_SCOPES: string | string[];
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
logger: ReturnType<typeof AioLogger>;
|
|
37
|
-
/** Custom scripts defined in the configuration (if any). */
|
|
32
|
+
}; /** Logger instance for installation logging. */
|
|
33
|
+
logger: ReturnType<typeof AioLogger>; /** Custom scripts defined in the configuration (if any). */
|
|
38
34
|
customScripts?: Record<string, unknown>;
|
|
39
35
|
};
|
|
40
36
|
/** Factory function type for creating step-specific context. */
|
|
@@ -48,45 +44,39 @@ type StepMeta = {
|
|
|
48
44
|
};
|
|
49
45
|
/** Defines the base properties of a step. */
|
|
50
46
|
type StepBase<TName extends string = string, TConfig extends CommerceAppConfigOutputModel = CommerceAppConfigOutputModel> = {
|
|
51
|
-
/** The name of this step. */
|
|
52
|
-
|
|
53
|
-
/** Metadata associated with the step. */
|
|
54
|
-
meta: StepMeta;
|
|
55
|
-
/** Whether the step should be taken into consideration. */
|
|
47
|
+
/** The name of this step. */name: TName; /** Metadata associated with the step. */
|
|
48
|
+
meta: StepMeta; /** Whether the step should be taken into consideration. */
|
|
56
49
|
when?: (config: CommerceAppConfigOutputModel) => config is TConfig;
|
|
57
50
|
};
|
|
58
51
|
/** 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
|
|
60
|
-
type: "leaf";
|
|
61
|
-
|
|
62
|
-
run: (config: TConfig, context: ExecutionContext<TStepCtx>) => TOutput$1 | Promise<TOutput$1>;
|
|
52
|
+
type LeafStep<TName extends string = string, TConfig extends CommerceAppConfigOutputModel = CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TOutput = unknown> = StepBase<TName, TConfig> & {
|
|
53
|
+
type: "leaf"; /** The execution handler for the step. */
|
|
54
|
+
run: (config: TConfig, context: ExecutionContext<TStepCtx>) => TOutput | Promise<TOutput>;
|
|
63
55
|
};
|
|
64
56
|
/** A branch step that contains children (no execution). */
|
|
65
57
|
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
|
-
|
|
68
|
-
context?: StepContextFactory<TStepCtx>;
|
|
69
|
-
/** The children steps of this branch. */
|
|
58
|
+
type: "branch"; /** An optional factory function to setup shared context for the children steps. */
|
|
59
|
+
context?: StepContextFactory<TStepCtx>; /** The children steps of this branch. */
|
|
70
60
|
children: AnyStep[];
|
|
71
61
|
};
|
|
72
62
|
/** 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
|
|
63
|
+
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>;
|
|
74
64
|
/** Loosely-typed step for use in non type-safe contexts. */
|
|
75
65
|
interface AnyStep {
|
|
76
|
-
type: "leaf" | "branch";
|
|
77
|
-
name: string;
|
|
78
|
-
meta: StepMeta;
|
|
79
|
-
when?: (config: CommerceAppConfigOutputModel) => boolean;
|
|
80
66
|
children?: AnyStep[];
|
|
81
67
|
context?: (context: InstallationContext) => any;
|
|
68
|
+
meta: StepMeta;
|
|
69
|
+
name: string;
|
|
82
70
|
run?: (config: any, context: any) => unknown | Promise<unknown>;
|
|
71
|
+
type: "leaf" | "branch";
|
|
72
|
+
when?: (config: CommerceAppConfigOutputModel) => boolean;
|
|
83
73
|
}
|
|
84
74
|
/** Check if a step is a leaf step. */
|
|
85
75
|
declare function isLeafStep(step: AnyStep): step is LeafStep;
|
|
86
76
|
/** Check if a step is a branch step. */
|
|
87
77
|
declare function isBranchStep(step: AnyStep): step is BranchStep;
|
|
88
78
|
/** Options for defining a leaf step. */
|
|
89
|
-
type LeafStepOptions<TName extends string, TConfig extends CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TOutput
|
|
79
|
+
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">;
|
|
90
80
|
/** Options for defining a branch step. */
|
|
91
81
|
type BranchStepOptions<TName extends string, TConfig extends CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>> = Omit<BranchStep<TName, TConfig, TStepCtx>, "type">;
|
|
92
82
|
/**
|
|
@@ -104,7 +94,7 @@ type BranchStepOptions<TName extends string, TConfig extends CommerceAppConfigOu
|
|
|
104
94
|
* });
|
|
105
95
|
* ```
|
|
106
96
|
*/
|
|
107
|
-
declare function defineLeafStep<TName extends string, TConfig extends CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TOutput
|
|
97
|
+
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>): LeafStep<TName, TConfig, TStepCtx, TOutput>;
|
|
108
98
|
/**
|
|
109
99
|
* Define a branch step (container with children, no runner).
|
|
110
100
|
*
|
|
@@ -130,28 +120,18 @@ type ExecutionStatus = "pending" | "in-progress" | "succeeded" | "failed";
|
|
|
130
120
|
type InstallationStatus = "pending" | "in-progress" | "succeeded" | "failed";
|
|
131
121
|
/** A structured error with path to the failing step. */
|
|
132
122
|
type InstallationError<TPayload = unknown> = {
|
|
133
|
-
/** Path to the step that failed (e.g., ["eventing", "commerce", "providers"]). */
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
key: string;
|
|
137
|
-
/** Human-readable error message. */
|
|
138
|
-
message?: string;
|
|
139
|
-
/** Additional error payload. */
|
|
123
|
+
/** Path to the step that failed (e.g., ["eventing", "commerce", "providers"]). */path: string[]; /** Error key for easy identification. */
|
|
124
|
+
key: string; /** Human-readable error message. */
|
|
125
|
+
message?: string; /** Additional error payload. */
|
|
140
126
|
payload?: TPayload;
|
|
141
127
|
};
|
|
142
128
|
/** Status of a step in the installation tree. */
|
|
143
129
|
type StepStatus = {
|
|
144
|
-
/** Step name (unique among siblings). */
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
|
|
148
|
-
/**
|
|
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). */
|
|
130
|
+
/** Step name (unique among siblings). */name: string; /** Unique step identifier (e.g., UUID). */
|
|
131
|
+
id: string; /** Full path from root to this step. */
|
|
132
|
+
path: string[]; /** Step metadata (for display purposes). */
|
|
133
|
+
meta: StepMeta; /** Current execution status. */
|
|
134
|
+
status: ExecutionStatus; /** Child step statuses (empty for leaf steps). */
|
|
155
135
|
children: StepStatus[];
|
|
156
136
|
};
|
|
157
137
|
/** Data collected during installation as a nested structure following step paths. */
|
|
@@ -160,35 +140,26 @@ type InstallationData = {
|
|
|
160
140
|
};
|
|
161
141
|
/** Base properties shared by all installation states. */
|
|
162
142
|
type InstallationStateBase = {
|
|
163
|
-
/** Unique installation identifier. */
|
|
164
|
-
|
|
165
|
-
/** Root step status. */
|
|
166
|
-
step: StepStatus;
|
|
167
|
-
/** Results from executed leaf steps, keyed by path. */
|
|
143
|
+
/** Unique installation identifier. */id: string; /** Root step status. */
|
|
144
|
+
step: StepStatus; /** Results from executed leaf steps, keyed by path. */
|
|
168
145
|
data: InstallationData | null;
|
|
169
146
|
};
|
|
170
147
|
/** Installation state when in progress. */
|
|
171
148
|
type InProgressInstallationState = InstallationStateBase & {
|
|
172
|
-
status: "in-progress";
|
|
173
|
-
/** ISO timestamp when installation started. */
|
|
149
|
+
status: "in-progress"; /** ISO timestamp when installation started. */
|
|
174
150
|
startedAt: string;
|
|
175
151
|
};
|
|
176
152
|
/** Installation state when completed successfully. */
|
|
177
153
|
type SucceededInstallationState = InstallationStateBase & {
|
|
178
|
-
status: "succeeded";
|
|
179
|
-
/** ISO timestamp when installation
|
|
180
|
-
startedAt: string;
|
|
181
|
-
/** ISO timestamp when installation completed. */
|
|
154
|
+
status: "succeeded"; /** ISO timestamp when installation started. */
|
|
155
|
+
startedAt: string; /** ISO timestamp when installation completed. */
|
|
182
156
|
completedAt: string;
|
|
183
157
|
};
|
|
184
158
|
/** Installation state when failed. */
|
|
185
159
|
type FailedInstallationState = InstallationStateBase & {
|
|
186
|
-
status: "failed";
|
|
187
|
-
/** ISO timestamp when installation
|
|
188
|
-
|
|
189
|
-
/** ISO timestamp when installation failed. */
|
|
190
|
-
completedAt: string;
|
|
191
|
-
/** Error information about the failure. */
|
|
160
|
+
status: "failed"; /** ISO timestamp when installation started. */
|
|
161
|
+
startedAt: string; /** ISO timestamp when installation failed. */
|
|
162
|
+
completedAt: string; /** Error information about the failure. */
|
|
192
163
|
error: InstallationError;
|
|
193
164
|
};
|
|
194
165
|
/**
|
|
@@ -213,24 +184,19 @@ type HookFunction<TEvent> = (event: TEvent, state: InstallationState) => void |
|
|
|
213
184
|
type InstallationHook = (state: InstallationState) => void | Promise<void>;
|
|
214
185
|
/** Base event payload for step events. */
|
|
215
186
|
type StepEvent = {
|
|
216
|
-
/** Full path to the step (e.g., ["eventing", "commerce", "providers"]). */
|
|
217
|
-
|
|
218
|
-
/** Step name (last element of path, for convenience). */
|
|
219
|
-
stepName: string;
|
|
220
|
-
/** Whether this is a leaf step (executable) or branch step (container). */
|
|
187
|
+
/** Full path to the step (e.g., ["eventing", "commerce", "providers"]). */path: string[]; /** Step name (last element of path, for convenience). */
|
|
188
|
+
stepName: string; /** Whether this is a leaf step (executable) or branch step (container). */
|
|
221
189
|
isLeaf: boolean;
|
|
222
190
|
};
|
|
223
191
|
/** Event payload when a step starts execution. */
|
|
224
192
|
type StepStartedEvent = StepEvent;
|
|
225
193
|
/** Event payload when a step succeeds. */
|
|
226
194
|
type StepSucceededEvent = StepEvent & {
|
|
227
|
-
/** Result returned by the step (only for leaf steps). */
|
|
228
|
-
result: unknown;
|
|
195
|
+
/** Result returned by the step (only for leaf steps). */result: unknown;
|
|
229
196
|
};
|
|
230
197
|
/** Event payload when a step fails. */
|
|
231
198
|
type StepFailedEvent = StepEvent & {
|
|
232
|
-
/** Error information. */
|
|
233
|
-
error: InstallationError;
|
|
199
|
+
/** Error information. */error: InstallationError;
|
|
234
200
|
};
|
|
235
201
|
/** Lifecycle hooks for installation execution. */
|
|
236
202
|
type InstallationHooks = {
|
|
@@ -245,22 +211,15 @@ type InstallationHooks = {
|
|
|
245
211
|
//#region source/management/installation/workflow/runner.d.ts
|
|
246
212
|
/** Options for creating an initial installation state. */
|
|
247
213
|
type CreateInitialStateOptions = {
|
|
248
|
-
/** The root branch step to build the state from. */
|
|
249
|
-
rootStep: BranchStep;
|
|
250
|
-
/** The app configuration used to determine applicable steps. */
|
|
214
|
+
/** The root branch step to build the state from. */rootStep: BranchStep; /** The app configuration used to determine applicable steps. */
|
|
251
215
|
config: CommerceAppConfigOutputModel;
|
|
252
216
|
};
|
|
253
217
|
/** Options for executing a workflow. */
|
|
254
218
|
type ExecuteWorkflowOptions = {
|
|
255
|
-
/** The root branch step to execute. */
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
|
|
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. */
|
|
219
|
+
/** The root branch step to execute. */rootStep: BranchStep; /** Shared installation context (params, logger, etc.). */
|
|
220
|
+
installationContext: InstallationContext; /** The app configuration. */
|
|
221
|
+
config: CommerceAppConfigOutputModel; /** The initial installation state (with all steps pending). */
|
|
222
|
+
initialState: InProgressInstallationState; /** Lifecycle hooks for status change notifications. */
|
|
264
223
|
hooks?: InstallationHooks;
|
|
265
224
|
};
|
|
266
225
|
/**
|
|
@@ -317,18 +276,13 @@ declare function defineCustomInstallationStep<TResult = unknown>(handler: Custom
|
|
|
317
276
|
//#region source/management/installation/runner.d.ts
|
|
318
277
|
/** Options for creating an initial installation state. */
|
|
319
278
|
type CreateInitialInstallationStateOptions = {
|
|
320
|
-
/** The app configuration used to determine applicable steps. */
|
|
321
|
-
config: CommerceAppConfigOutputModel;
|
|
279
|
+
/** The app configuration used to determine applicable steps. */config: CommerceAppConfigOutputModel;
|
|
322
280
|
};
|
|
323
281
|
/** Options for running an installation. */
|
|
324
282
|
type RunInstallationOptions = {
|
|
325
|
-
/** Shared installation context (params, logger, etc.). */
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
config: CommerceAppConfigOutputModel;
|
|
329
|
-
/** The initial installation state (with all steps pending). */
|
|
330
|
-
initialState: InProgressInstallationState;
|
|
331
|
-
/** Lifecycle hooks for status change notifications. */
|
|
283
|
+
/** Shared installation context (params, logger, etc.). */installationContext: InstallationContext; /** The app configuration. */
|
|
284
|
+
config: CommerceAppConfigOutputModel; /** The initial installation state (with all steps pending). */
|
|
285
|
+
initialState: InProgressInstallationState; /** Lifecycle hooks for status change notifications. */
|
|
332
286
|
hooks?: InstallationHooks;
|
|
333
287
|
};
|
|
334
288
|
/**
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
let valibot = require("valibot");
|
|
29
|
+
valibot = __toESM(valibot);
|
|
30
|
+
|
|
31
|
+
//#region ../../packages-private/common-utils/source/valibot/schemas.ts
|
|
32
|
+
const ALPHANUMERIC_OR_HYPHEN_REGEX = {
|
|
33
|
+
any: /^[a-zA-Z0-9-]+$/,
|
|
34
|
+
lowercase: /^[a-z0-9-]+$/,
|
|
35
|
+
uppercase: /^[A-Z0-9-]+$/
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* A schema for a string value.
|
|
39
|
+
* @param name The name of the field this schema refers to.
|
|
40
|
+
*/
|
|
41
|
+
function stringValueSchema(name) {
|
|
42
|
+
return valibot.string(`Expected a string value for '${name}'`);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A schema for a non-empty string value.
|
|
46
|
+
* @param name The name of the field this schema refers to.
|
|
47
|
+
*/
|
|
48
|
+
function nonEmptyStringValueSchema(name) {
|
|
49
|
+
return valibot.pipe(stringValueSchema(name), valibot.nonEmpty(`The value of "${name}" must not be empty`));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* A schema for a boolean value.
|
|
53
|
+
* @param name The name of the field this schema refers to.
|
|
54
|
+
*/
|
|
55
|
+
function booleanValueSchema(name) {
|
|
56
|
+
return valibot.boolean(`Expected a boolean value for '${name}'`);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* A schema for a string that only contains alphanumeric characters and hyphens.
|
|
60
|
+
* @param name The name of the field this schema refers to.
|
|
61
|
+
* @param casing The allowed casing for the string (default: "any").
|
|
62
|
+
*/
|
|
63
|
+
function alphaNumericOrHyphenSchema(name, casing = "any") {
|
|
64
|
+
const casingLabel = casing === "any" ? "" : ` (${casing} only)`;
|
|
65
|
+
return valibot.pipe(stringValueSchema(name), valibot.regex(ALPHANUMERIC_OR_HYPHEN_REGEX[casing], `Only alphanumeric characters and hyphens are allowed in string value of "${name}"${casingLabel}`));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
//#endregion
|
|
69
|
+
Object.defineProperty(exports, '__toESM', {
|
|
70
|
+
enumerable: true,
|
|
71
|
+
get: function () {
|
|
72
|
+
return __toESM;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
Object.defineProperty(exports, 'alphaNumericOrHyphenSchema', {
|
|
76
|
+
enumerable: true,
|
|
77
|
+
get: function () {
|
|
78
|
+
return alphaNumericOrHyphenSchema;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
Object.defineProperty(exports, 'booleanValueSchema', {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
get: function () {
|
|
84
|
+
return booleanValueSchema;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
Object.defineProperty(exports, 'nonEmptyStringValueSchema', {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function () {
|
|
90
|
+
return nonEmptyStringValueSchema;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
Object.defineProperty(exports, 'stringValueSchema', {
|
|
94
|
+
enumerable: true,
|
|
95
|
+
get: function () {
|
|
96
|
+
return stringValueSchema;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
const require_schemas = require('./schemas-CZ6c8Id9.cjs');
|
|
2
|
+
const require_installation = require('./installation-nwF2RC7F.cjs');
|
|
3
|
+
let _adobe_aio_commerce_lib_core_error = require("@adobe/aio-commerce-lib-core/error");
|
|
4
|
+
let valibot = require("valibot");
|
|
5
|
+
valibot = require_schemas.__toESM(valibot);
|
|
6
|
+
let _adobe_aio_commerce_lib_config = require("@adobe/aio-commerce-lib-config");
|
|
7
|
+
|
|
8
|
+
//#region source/config/schema/business-configuration.ts
|
|
9
|
+
/**
|
|
10
|
+
* Check if config has business config.
|
|
11
|
+
* @param config - The configuration to check.
|
|
12
|
+
*/
|
|
13
|
+
function hasBusinessConfig(config) {
|
|
14
|
+
return config.businessConfig !== void 0;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Check if config has business config schema.
|
|
18
|
+
* @param config - The configuration to check.
|
|
19
|
+
*/
|
|
20
|
+
function hasBusinessConfigSchema(config) {
|
|
21
|
+
return config.businessConfig?.schema !== void 0 && config.businessConfig.schema.length > 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region source/config/schema/metadata.ts
|
|
26
|
+
const MAX_DESCRIPTION_LENGTH = 255;
|
|
27
|
+
const MAX_DISPLAY_NAME_LENGTH = 50;
|
|
28
|
+
const NUMERIC_IDENTIFIER = "(0|[1-9]\\d*)";
|
|
29
|
+
const SEMVER_REGEX = new RegExp(`^${NUMERIC_IDENTIFIER}\\.${NUMERIC_IDENTIFIER}\\.${NUMERIC_IDENTIFIER}$`);
|
|
30
|
+
function nonEmptyString(fieldName) {
|
|
31
|
+
return valibot.pipe(valibot.string(`Expected a string for the ${fieldName}`), valibot.nonEmpty(`The ${fieldName} must not be empty`));
|
|
32
|
+
}
|
|
33
|
+
/** The schema for the metadata of the application. */
|
|
34
|
+
const MetadataSchema = valibot.object({
|
|
35
|
+
id: require_schemas.alphaNumericOrHyphenSchema("application id (metadata.id)"),
|
|
36
|
+
displayName: valibot.pipe(nonEmptyString("application display name"), valibot.maxLength(MAX_DISPLAY_NAME_LENGTH, `The application display name must not be longer than ${MAX_DISPLAY_NAME_LENGTH} characters`)),
|
|
37
|
+
description: valibot.pipe(nonEmptyString("metadata description"), valibot.maxLength(MAX_DESCRIPTION_LENGTH, `The metadata description must not be longer than ${MAX_DESCRIPTION_LENGTH} characters`)),
|
|
38
|
+
version: valibot.pipe(nonEmptyString("version"), valibot.regex(SEMVER_REGEX, "The version must follow semantic versioning (semver) format"))
|
|
39
|
+
});
|
|
40
|
+
/**
|
|
41
|
+
* Check if config has metadata.
|
|
42
|
+
* @param config - The configuration to check.
|
|
43
|
+
*/
|
|
44
|
+
function hasMetadata(config) {
|
|
45
|
+
return config.metadata !== void 0;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region source/config/schema/app.ts
|
|
50
|
+
/** biome-ignore-all lint/performance/noBarrelFile: We want to have all the schema exports in one file. */
|
|
51
|
+
/** The schema used to validate the commerce app config file. */
|
|
52
|
+
const CommerceAppConfigSchema = valibot.looseObject({
|
|
53
|
+
metadata: MetadataSchema,
|
|
54
|
+
businessConfig: valibot.optional(_adobe_aio_commerce_lib_config.SchemaBusinessConfig),
|
|
55
|
+
eventing: valibot.optional(require_installation.EventingSchema),
|
|
56
|
+
installation: valibot.optional(require_installation.InstallationSchema)
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region source/config/schema/domains.ts
|
|
61
|
+
/** The individual validatable domains of the app config. */
|
|
62
|
+
const CommerceAppConfigSchemas = {
|
|
63
|
+
metadata: MetadataSchema,
|
|
64
|
+
businessConfig: _adobe_aio_commerce_lib_config.SchemaBusinessConfig,
|
|
65
|
+
eventing: require_installation.EventingSchema,
|
|
66
|
+
installation: require_installation.InstallationSchema,
|
|
67
|
+
"businessConfig.schema": valibot.unwrap(_adobe_aio_commerce_lib_config.SchemaBusinessConfig.entries.schema),
|
|
68
|
+
"eventing.commerce": valibot.unwrap(require_installation.EventingSchema.entries.commerce),
|
|
69
|
+
"eventing.external": valibot.unwrap(require_installation.EventingSchema.entries.external),
|
|
70
|
+
"installation.customInstallationSteps": valibot.unwrap(require_installation.InstallationSchema.entries.customInstallationSteps)
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Get the config domains that are present in the config.
|
|
74
|
+
* @param config - The configuration to check.
|
|
75
|
+
*/
|
|
76
|
+
function getConfigDomains(config) {
|
|
77
|
+
const withCommerceEvents = require_installation.hasCommerceEvents(config);
|
|
78
|
+
const withExternalEvents = require_installation.hasExternalEvents(config);
|
|
79
|
+
const domains = {
|
|
80
|
+
metadata: hasMetadata(config),
|
|
81
|
+
businessConfig: hasBusinessConfig(config),
|
|
82
|
+
eventing: withCommerceEvents || withExternalEvents,
|
|
83
|
+
installation: require_installation.hasCustomInstallation(config),
|
|
84
|
+
"businessConfig.schema": hasBusinessConfigSchema(config),
|
|
85
|
+
"eventing.commerce": withCommerceEvents,
|
|
86
|
+
"eventing.external": withExternalEvents,
|
|
87
|
+
"installation.customInstallationSteps": require_installation.hasCustomInstallationSteps(config)
|
|
88
|
+
};
|
|
89
|
+
const domainsList = Object.entries(domains).filter(([_, value]) => value).map(([key]) => key);
|
|
90
|
+
return new Set(domainsList);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Check if the config has a specific domain.
|
|
94
|
+
* @param config - The configuration to check.
|
|
95
|
+
* @param domain - The domain to check.
|
|
96
|
+
*/
|
|
97
|
+
function hasConfigDomain(config, domain) {
|
|
98
|
+
return getConfigDomains(config).has(domain);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region source/config/lib/validate.ts
|
|
103
|
+
const commerceAppConfigDomainsSchema = valibot.picklist(Object.keys(CommerceAppConfigSchemas));
|
|
104
|
+
/**
|
|
105
|
+
* Validates a complete commerce app configuration object against the schema.
|
|
106
|
+
*
|
|
107
|
+
* @param config - The configuration object to validate.
|
|
108
|
+
* @returns The validated and typed configuration output model.
|
|
109
|
+
*
|
|
110
|
+
* @throws {CommerceSdkValidationError} If the configuration is invalid, with
|
|
111
|
+
* detailed validation issues included.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```typescript
|
|
115
|
+
* const config = {
|
|
116
|
+
* businessConfiguration: {
|
|
117
|
+
* // ... configuration data
|
|
118
|
+
* }
|
|
119
|
+
* };
|
|
120
|
+
*
|
|
121
|
+
* try {
|
|
122
|
+
* const validatedConfig = validateCommerceAppConfig(config);
|
|
123
|
+
* // Use validatedConfig safely
|
|
124
|
+
* } catch (error) {
|
|
125
|
+
* if (error instanceof CommerceSdkValidationError) {
|
|
126
|
+
* console.error('Validation failed:', error.display());
|
|
127
|
+
* }
|
|
128
|
+
* }
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
function validateCommerceAppConfig(config) {
|
|
132
|
+
const validatedConfig = valibot.safeParse(CommerceAppConfigSchema, config);
|
|
133
|
+
if (!validatedConfig.success) throw new _adobe_aio_commerce_lib_core_error.CommerceSdkValidationError("Invalid commerce app config", { issues: validatedConfig.issues });
|
|
134
|
+
return validatedConfig.output;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Validates a specific domain configuration within the commerce app config.
|
|
138
|
+
*
|
|
139
|
+
* This function validates only a specific domain's configuration rather than
|
|
140
|
+
* the entire commerce app configuration object. It first validates that the
|
|
141
|
+
* domain name is valid, then validates the configuration data against the
|
|
142
|
+
* schema for that specific domain.
|
|
143
|
+
*
|
|
144
|
+
* @template T - The type of the domain, constrained to valid domain names.
|
|
145
|
+
*
|
|
146
|
+
* @param config - The domain configuration object to validate.
|
|
147
|
+
* @param domain - The name of the domain to validate (e.g., 'businessConfiguration').
|
|
148
|
+
* @returns The validated and typed configuration for the specified domain.
|
|
149
|
+
*
|
|
150
|
+
* @throws {CommerceSdkValidationError} If the domain name is invalid or if the
|
|
151
|
+
* configuration doesn't match the domain's schema.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* const businessConfig = {
|
|
156
|
+
* fields: [
|
|
157
|
+
* {
|
|
158
|
+
* name: 'category',
|
|
159
|
+
* type: 'dropdown',
|
|
160
|
+
* // ... field configuration
|
|
161
|
+
* }
|
|
162
|
+
* ]
|
|
163
|
+
* };
|
|
164
|
+
*
|
|
165
|
+
* try {
|
|
166
|
+
* const validatedConfig = validateCommerceAppConfigDomain(
|
|
167
|
+
* businessConfig,
|
|
168
|
+
* 'businessConfig'
|
|
169
|
+
* );
|
|
170
|
+
* // Use validatedConfig safely
|
|
171
|
+
* } catch (error) {
|
|
172
|
+
* if (error instanceof CommerceSdkValidationError) {
|
|
173
|
+
* console.error('Domain validation failed:', error.issues);
|
|
174
|
+
* }
|
|
175
|
+
* }
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
function validateCommerceAppConfigDomain(config, domain) {
|
|
179
|
+
const domainSchema = valibot.safeParse(commerceAppConfigDomainsSchema, domain);
|
|
180
|
+
if (!domainSchema.success) throw new _adobe_aio_commerce_lib_core_error.CommerceSdkValidationError("Invalid commerce app config domain", { issues: domainSchema.issues });
|
|
181
|
+
const domainConfigSchema = CommerceAppConfigSchemas[domain];
|
|
182
|
+
const validatedConfig = valibot.safeParse(domainConfigSchema, config);
|
|
183
|
+
if (!validatedConfig.success) throw new _adobe_aio_commerce_lib_core_error.CommerceSdkValidationError(`Invalid commerce app config: ${domain}`, { issues: validatedConfig.issues });
|
|
184
|
+
return validatedConfig.output;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
//#endregion
|
|
188
|
+
Object.defineProperty(exports, 'CommerceAppConfigSchemas', {
|
|
189
|
+
enumerable: true,
|
|
190
|
+
get: function () {
|
|
191
|
+
return CommerceAppConfigSchemas;
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
Object.defineProperty(exports, 'getConfigDomains', {
|
|
195
|
+
enumerable: true,
|
|
196
|
+
get: function () {
|
|
197
|
+
return getConfigDomains;
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
Object.defineProperty(exports, 'hasBusinessConfig', {
|
|
201
|
+
enumerable: true,
|
|
202
|
+
get: function () {
|
|
203
|
+
return hasBusinessConfig;
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
Object.defineProperty(exports, 'hasBusinessConfigSchema', {
|
|
207
|
+
enumerable: true,
|
|
208
|
+
get: function () {
|
|
209
|
+
return hasBusinessConfigSchema;
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
Object.defineProperty(exports, 'hasConfigDomain', {
|
|
213
|
+
enumerable: true,
|
|
214
|
+
get: function () {
|
|
215
|
+
return hasConfigDomain;
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
Object.defineProperty(exports, 'hasMetadata', {
|
|
219
|
+
enumerable: true,
|
|
220
|
+
get: function () {
|
|
221
|
+
return hasMetadata;
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
Object.defineProperty(exports, 'validateCommerceAppConfig', {
|
|
225
|
+
enumerable: true,
|
|
226
|
+
get: function () {
|
|
227
|
+
return validateCommerceAppConfig;
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
Object.defineProperty(exports, 'validateCommerceAppConfigDomain', {
|
|
231
|
+
enumerable: true,
|
|
232
|
+
get: function () {
|
|
233
|
+
return validateCommerceAppConfigDomain;
|
|
234
|
+
}
|
|
235
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { n as CommerceAppConfigOutputModel } from "../app-vKXaAr6f.mjs";
|
|
2
|
+
import * as _adobe_aio_commerce_lib_core_responses0 from "@adobe/aio-commerce-lib-core/responses";
|
|
3
|
+
import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
|
|
4
|
+
|
|
5
|
+
//#region source/actions/app-config.d.ts
|
|
6
|
+
/** Arguments for the runtime action factory. */
|
|
7
|
+
type RuntimeActionFactoryArgs = {
|
|
8
|
+
appConfig: CommerceAppConfigOutputModel;
|
|
9
|
+
};
|
|
10
|
+
/** Factory to create the route handler for the `app-config` action. */
|
|
11
|
+
declare const appConfigRuntimeAction: ({
|
|
12
|
+
appConfig
|
|
13
|
+
}: RuntimeActionFactoryArgs) => (params: RuntimeActionParams) => Promise<_adobe_aio_commerce_lib_core_responses0.ActionResponse>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { appConfigRuntimeAction };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { n as logger, t as HttpActionRouter } from "../router-CJ4VWoCt.mjs";
|
|
2
|
+
import { t as validateCommerceAppConfig } from "../validate-DXI6gwZ2.mjs";
|
|
3
|
+
import { ok } from "@adobe/aio-commerce-lib-core/responses";
|
|
4
|
+
|
|
5
|
+
//#region source/actions/app-config.ts
|
|
6
|
+
/** Router for the app config actions. */
|
|
7
|
+
const router = new HttpActionRouter().use(logger({ name: () => "get-app-config" }));
|
|
8
|
+
/** GET / - Get app config */
|
|
9
|
+
router.get("/", { handler: async (_req, { logger, rawParams }) => {
|
|
10
|
+
logger.debug("Validating app config...");
|
|
11
|
+
const { appConfig } = rawParams;
|
|
12
|
+
const config = validateCommerceAppConfig(appConfig);
|
|
13
|
+
logger.debug("Successfully validated the app config");
|
|
14
|
+
return ok({ body: config });
|
|
15
|
+
} });
|
|
16
|
+
/** Factory to create the route handler for the `app-config` action. */
|
|
17
|
+
const appConfigRuntimeAction = ({ appConfig }) => async (params) => {
|
|
18
|
+
return await router.handler()({
|
|
19
|
+
...params,
|
|
20
|
+
appConfig
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export { appConfigRuntimeAction };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as _adobe_aio_commerce_lib_core_responses0 from "@adobe/aio-commerce-lib-core/responses";
|
|
2
|
+
import { BusinessConfigSchema } from "@adobe/aio-commerce-lib-config";
|
|
3
|
+
import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
|
|
4
|
+
|
|
5
|
+
//#region source/actions/config.d.ts
|
|
6
|
+
/** The arguments for the config action factory. */
|
|
7
|
+
type ConfigActionFactoryArgs = {
|
|
8
|
+
configSchema: BusinessConfigSchema;
|
|
9
|
+
};
|
|
10
|
+
/** Factory to create the route handler for the `config` action. */
|
|
11
|
+
declare const configRuntimeAction: ({
|
|
12
|
+
configSchema
|
|
13
|
+
}: ConfigActionFactoryArgs) => (params: RuntimeActionParams) => Promise<_adobe_aio_commerce_lib_core_responses0.ActionResponse>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { configRuntimeAction };
|