@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.
- package/CHANGELOG.md +23 -0
- package/dist/cjs/actions/app-config/index.cjs +202 -0
- package/dist/cjs/actions/app-config/index.d.cts +31 -0
- package/dist/cjs/actions/{config.cjs → config/index.cjs} +61 -33
- package/dist/{es/actions/config.d.mts → cjs/actions/config/index.d.cts} +10 -7
- package/dist/cjs/actions/{installation.cjs → installation/index.cjs} +43 -30
- package/dist/{es/actions/installation.d.mts → cjs/actions/installation/index.d.cts} +10 -8
- package/dist/cjs/actions/{registration.cjs → registration/index.cjs} +16 -6
- package/dist/cjs/actions/{registration.d.cts → registration/index.d.cts} +8 -8
- package/dist/cjs/actions/{scope-tree.cjs → scope-tree/index.cjs} +51 -14
- package/dist/cjs/actions/{scope-tree.d.cts → scope-tree/index.d.cts} +1 -1
- package/dist/cjs/{admin-ui-sdk-DZZJCrdT.d.cts → admin-ui-sdk-EU915zlR.d.cts} +7 -8
- package/dist/cjs/app-DrYHK-z1.d.cts +1629 -0
- package/dist/cjs/commands/index.cjs +12 -18
- package/dist/cjs/config/index.cjs +2 -2
- package/dist/cjs/config/index.d.cts +36 -976
- package/dist/cjs/{config-FNMclIFO.cjs → config-D-s0GSep.cjs} +1 -1
- package/dist/cjs/{index-Dw2NvVOY.d.cts → index-B5gJ-q4U.d.cts} +172 -3
- package/dist/{es/actions/app-config.d.mts → cjs/index-BXm8UbK7.d.cts} +1 -13
- package/dist/cjs/management/index.cjs +1 -1
- package/dist/cjs/management/index.d.cts +1 -2
- package/dist/cjs/{management-Cvsz4VMf.cjs → management-Dehz9qSJ.cjs} +81 -43
- package/dist/cjs/openapi-Cux6K4ZD.cjs +3072 -0
- package/dist/cjs/{validate-DydOAZha.cjs → validate-oAOpyFyb.cjs} +46 -14
- package/dist/es/actions/app-config/index.d.mts +31 -0
- package/dist/es/actions/app-config/index.mjs +199 -0
- package/dist/{cjs/actions/config.d.cts → es/actions/config/index.d.mts} +10 -7
- package/dist/es/actions/{config.mjs → config/index.mjs} +60 -32
- package/dist/{cjs/actions/installation.d.cts → es/actions/installation/index.d.mts} +10 -8
- package/dist/es/actions/{installation.mjs → installation/index.mjs} +42 -30
- package/dist/es/actions/{registration.d.mts → registration/index.d.mts} +8 -8
- package/dist/es/actions/{registration.mjs → registration/index.mjs} +16 -6
- package/dist/es/actions/{scope-tree.d.mts → scope-tree/index.d.mts} +1 -1
- package/dist/es/actions/{scope-tree.mjs → scope-tree/index.mjs} +50 -13
- package/dist/es/{admin-ui-sdk-hu6iWr0A.d.mts → admin-ui-sdk-BwnD0xjK.d.mts} +6 -9
- package/dist/es/app-DrYHK-z1.d.mts +1629 -0
- package/dist/es/commands/index.mjs +12 -18
- package/dist/es/config/index.d.mts +36 -975
- package/dist/es/config/index.mjs +2 -2
- package/dist/es/{config-CcE0EBG7.mjs → config-3I4eLyyR.mjs} +1 -1
- package/dist/{cjs/actions/app-config.d.cts → es/index-B0XqHwY5.d.mts} +2 -14
- package/dist/es/{index-Bo0tQsVq.d.mts → index-DLMbTtKS.d.mts} +172 -3
- package/dist/es/management/index.d.mts +1 -2
- package/dist/es/management/index.mjs +1 -1
- package/dist/es/{management-BZ4Y6lVp.mjs → management-BUX-w2Ji.mjs} +81 -44
- package/dist/es/openapi-B6uP0SRn.mjs +3024 -0
- package/dist/es/{validate-Du3LhCre.mjs → validate-Dfajrp99.mjs} +35 -15
- package/package.json +17 -10
- package/dist/cjs/actions/app-config.cjs +0 -54
- package/dist/cjs/app-CakwxQvs.d.cts +0 -673
- package/dist/cjs/step-CKVE0aJi.d.cts +0 -187
- package/dist/es/actions/app-config.mjs +0 -53
- package/dist/es/app-CakwxQvs.d.mts +0 -673
- package/dist/es/step-D64mMPrt.d.mts +0 -187
package/dist/es/config/index.mjs
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
+
import { d as defineConfig, n as readCommerceAppConfig, r as resolveCommerceAppConfig, t as parseCommerceAppConfig } from "../config-3I4eLyyR.mjs";
|
|
15
16
|
import { a as hasCustomInstallationSteps, c as hasEventing, d as hasAdminUiSdk, i as hasCustomInstallation, l as hasExternalEvents, n as hasWebhooks, s as hasCommerceEvents } from "../webhooks-B5oq9ULL.mjs";
|
|
16
|
-
import { a as
|
|
17
|
-
import { d as defineConfig, n as readCommerceAppConfig, r as resolveCommerceAppConfig, t as parseCommerceAppConfig } from "../config-CcE0EBG7.mjs";
|
|
17
|
+
import { a as CommerceAppConfigSchemas, c as hasMetadata, l as hasBusinessConfig, n as validateCommerceAppConfigDomain, o as getConfigDomains, s as hasConfigDomain, t as validateCommerceAppConfig, u as hasBusinessConfigSchema } from "../validate-Dfajrp99.mjs";
|
|
18
18
|
|
|
19
19
|
export { CommerceAppConfigSchemas, defineConfig, getConfigDomains, hasAdminUiSdk, hasBusinessConfig, hasBusinessConfigSchema, hasCommerceEvents, hasConfigDomain, hasCustomInstallation, hasCustomInstallationSteps, hasEventing, hasExternalEvents, hasMetadata, hasWebhooks, parseCommerceAppConfig, readCommerceAppConfig, resolveCommerceAppConfig, validateCommerceAppConfig, validateCommerceAppConfigDomain };
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import { t as validateCommerceAppConfig } from "./validate-Du3LhCre.mjs";
|
|
16
15
|
import { t as stringifyError } from "./error-_RMwtrUA.mjs";
|
|
16
|
+
import { t as validateCommerceAppConfig } from "./validate-Dfajrp99.mjs";
|
|
17
17
|
import { dirname, join, parse } from "path";
|
|
18
18
|
import { existsSync } from "fs";
|
|
19
19
|
import { access, mkdir, readFile } from "fs/promises";
|
|
@@ -12,17 +12,5 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import
|
|
16
|
-
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 };
|
|
15
|
+
import AioLogger from "@adobe/aio-lib-core-logging";
|
|
16
|
+
import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
|
|
@@ -12,9 +12,178 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import {
|
|
16
|
-
import
|
|
15
|
+
import { r as CommerceAppConfigOutputModel } from "./app-DrYHK-z1.mjs";
|
|
16
|
+
import * as v from "valibot";
|
|
17
|
+
import AioLogger from "@adobe/aio-lib-core-logging";
|
|
18
|
+
import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
|
|
17
19
|
|
|
20
|
+
//#region source/management/installation/schema.d.ts
|
|
21
|
+
/** Schema for validating Adobe I/O app credentials required for installation. */
|
|
22
|
+
declare const AppDataSchema: v.ObjectSchema<{
|
|
23
|
+
readonly consumerOrgId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
24
|
+
readonly orgName: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
25
|
+
readonly projectId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
26
|
+
readonly projectName: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
27
|
+
readonly projectTitle: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
28
|
+
readonly workspaceId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
29
|
+
readonly workspaceName: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
30
|
+
readonly workspaceTitle: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
31
|
+
}, undefined>;
|
|
32
|
+
/** Type for Adobe I/O app credentials. */
|
|
33
|
+
type AppData = v.InferOutput<typeof AppDataSchema>;
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region source/management/installation/workflow/step.d.ts
|
|
36
|
+
/** Severity level of a validation issue. */
|
|
37
|
+
type ValidationIssueSeverity = "error" | "warning" | "info";
|
|
38
|
+
/** A single validation issue reported by a step's validate handler. */
|
|
39
|
+
type ValidationIssue = {
|
|
40
|
+
/** Machine-readable code identifying the issue type. */code: string; /** Human-readable description of the issue. */
|
|
41
|
+
message: string; /** Severity of the issue. Only "error" severity blocks installation. */
|
|
42
|
+
severity: ValidationIssueSeverity; /** Optional additional context about the issue. */
|
|
43
|
+
details?: Record<string, unknown>;
|
|
44
|
+
};
|
|
45
|
+
/** Shared context available to all steps during installation. */
|
|
46
|
+
type InstallationContext = {
|
|
47
|
+
/** The credentials of the app being installed */appData: AppData; /** The raw action parameters from the App Builder runtime action. */
|
|
48
|
+
params: RuntimeActionParams & {
|
|
49
|
+
AIO_COMMERCE_AUTH_IMS_CLIENT_ID: string;
|
|
50
|
+
AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS: string | string[];
|
|
51
|
+
AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_ID: string;
|
|
52
|
+
AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_EMAIL: string;
|
|
53
|
+
AIO_COMMERCE_AUTH_IMS_ORG_ID: string;
|
|
54
|
+
AIO_COMMERCE_AUTH_IMS_SCOPES: string | string[];
|
|
55
|
+
}; /** Logger instance for installation logging. */
|
|
56
|
+
logger: ReturnType<typeof AioLogger>; /** Custom scripts defined in the configuration (if any). */
|
|
57
|
+
customScripts?: Record<string, unknown>;
|
|
58
|
+
};
|
|
59
|
+
/** Factory function type for creating step-specific context. */
|
|
60
|
+
type StepContextFactory<TStepCtx extends Record<string, unknown> = Record<string, unknown>> = (context: InstallationContext) => TStepCtx | Promise<TStepCtx>;
|
|
61
|
+
/** The execution context passed to leaf step run handlers. */
|
|
62
|
+
type ExecutionContext<TStepCtx extends Record<string, unknown> = Record<string, unknown>> = InstallationContext & TStepCtx;
|
|
63
|
+
/**
|
|
64
|
+
* A narrowed context available to step `validate` handlers.
|
|
65
|
+
* Excludes `customScripts` — those only apply during installation, not pre-flight validation.
|
|
66
|
+
*/
|
|
67
|
+
type ValidationContext = Omit<InstallationContext, "customScripts">;
|
|
68
|
+
/** The context passed to step `validate` handlers (base validation context merged with step-level context). */
|
|
69
|
+
type ValidationExecutionContext<TStepCtx extends Record<string, unknown> = Record<string, unknown>> = ValidationContext & TStepCtx;
|
|
70
|
+
/** Metadata info for a step (used for UI display). */
|
|
71
|
+
type StepMetaInfo = {
|
|
72
|
+
label: string;
|
|
73
|
+
description?: string;
|
|
74
|
+
};
|
|
75
|
+
/** Step metadata keyed by execution mode. */
|
|
76
|
+
type StepMeta = {
|
|
77
|
+
install: StepMetaInfo;
|
|
78
|
+
uninstall?: StepMetaInfo;
|
|
79
|
+
};
|
|
80
|
+
/** Defines the base properties of a step. */
|
|
81
|
+
type StepBase<TName extends string = string, TConfig extends CommerceAppConfigOutputModel = CommerceAppConfigOutputModel> = {
|
|
82
|
+
/** The name of this step. */name: TName; /** Metadata associated with the step, keyed by execution mode. */
|
|
83
|
+
meta: StepMeta; /** Whether the step should be taken into consideration. */
|
|
84
|
+
when?: (config: CommerceAppConfigOutputModel) => config is TConfig;
|
|
85
|
+
};
|
|
86
|
+
/** A leaf step that executes work (no children). */
|
|
87
|
+
type LeafStep<TName extends string = string, TConfig extends CommerceAppConfigOutputModel = CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TOutput = unknown> = StepBase<TName, TConfig> & {
|
|
88
|
+
type: "leaf"; /** The execution handler for the step. */
|
|
89
|
+
install: (config: TConfig, context: ExecutionContext<TStepCtx>) => TOutput | Promise<TOutput>;
|
|
90
|
+
/**
|
|
91
|
+
* Optional pre-installation validation handler.
|
|
92
|
+
* Called before installation begins to surface issues (errors or warnings).
|
|
93
|
+
* Returning an empty array means the step has no issues.
|
|
94
|
+
*/
|
|
95
|
+
validate?: (config: TConfig, context: ValidationExecutionContext<TStepCtx>) => ValidationIssue[] | Promise<ValidationIssue[]>;
|
|
96
|
+
/**
|
|
97
|
+
* Optional uninstall handler for the step.
|
|
98
|
+
* Called during uninstallation to reverse the work done by `install`.
|
|
99
|
+
* If absent, the step is silently skipped during uninstallation.
|
|
100
|
+
*/
|
|
101
|
+
uninstall?: (config: TConfig, context: ExecutionContext<TStepCtx>) => void | Promise<void>;
|
|
102
|
+
};
|
|
103
|
+
/** A branch step that contains children (no execution). */
|
|
104
|
+
type BranchStep<TName extends string = string, TConfig extends CommerceAppConfigOutputModel = CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TChildren extends AnyStep[] = AnyStep[]> = StepBase<TName, TConfig> & {
|
|
105
|
+
type: "branch"; /** An optional factory function to setup shared context for the children steps. */
|
|
106
|
+
context?: StepContextFactory<TStepCtx>; /** The children steps of this branch. */
|
|
107
|
+
children: TChildren;
|
|
108
|
+
/**
|
|
109
|
+
* Optional pre-installation validation handler for the branch itself.
|
|
110
|
+
* Called before children are validated. Returning an empty array means
|
|
111
|
+
* the branch has no issues at this level.
|
|
112
|
+
*/
|
|
113
|
+
validate?: (config: TConfig, context: ValidationExecutionContext<TStepCtx>) => ValidationIssue[] | Promise<ValidationIssue[]>;
|
|
114
|
+
};
|
|
115
|
+
/** A step in the installation tree (discriminated union by `type`). */
|
|
116
|
+
type Step<TName extends string = string, TConfig extends CommerceAppConfigOutputModel = CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TOutput = unknown> = LeafStep<TName, TConfig, TStepCtx, TOutput> | BranchStep<TName, TConfig, TStepCtx>;
|
|
117
|
+
/** Loosely-typed step for use in non type-safe contexts. */
|
|
118
|
+
interface AnyStep {
|
|
119
|
+
children?: AnyStep[];
|
|
120
|
+
context?: (context: InstallationContext) => any;
|
|
121
|
+
install?: (config: any, context: any) => unknown | Promise<unknown>;
|
|
122
|
+
meta: StepMeta;
|
|
123
|
+
name: string;
|
|
124
|
+
type: "leaf" | "branch";
|
|
125
|
+
uninstall?: (config: any, context: any) => void | Promise<void>;
|
|
126
|
+
validate?: (config: any, context: any) => ValidationIssue[] | Promise<ValidationIssue[]>;
|
|
127
|
+
when?: (config: CommerceAppConfigOutputModel) => boolean;
|
|
128
|
+
}
|
|
129
|
+
/** Check if a step is a leaf step. */
|
|
130
|
+
declare function isLeafStep(step: AnyStep): step is LeafStep;
|
|
131
|
+
/** Check if a step is a branch step. */
|
|
132
|
+
declare function isBranchStep(step: AnyStep): step is BranchStep;
|
|
133
|
+
/** Options for defining a leaf step. */
|
|
134
|
+
type LeafStepOptions<TName extends string, TConfig extends CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TOutput = unknown> = Omit<LeafStep<TName, TConfig, TStepCtx, TOutput>, "type">;
|
|
135
|
+
/** Options for defining a branch step. */
|
|
136
|
+
type BranchStepOptions<TName extends string, TConfig extends CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TChildren extends AnyStep[] = AnyStep[]> = Omit<BranchStep<TName, TConfig, TStepCtx, TChildren>, "type">;
|
|
137
|
+
/**
|
|
138
|
+
* Define a leaf step (executable, no children).
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* const createProviders = defineLeafStep({
|
|
143
|
+
* name: "providers",
|
|
144
|
+
* meta: { install: { label: "Create Providers", description: "Creates I/O Events providers" } },
|
|
145
|
+
* install: async ({ config, stepContext }) => {
|
|
146
|
+
* const { eventsClient } = stepContext;
|
|
147
|
+
* return eventsClient.createProvider(config.eventing);
|
|
148
|
+
* },
|
|
149
|
+
* });
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
declare function defineLeafStep<TName extends string, TConfig extends CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TOutput = unknown>(options: LeafStepOptions<TName, TConfig, TStepCtx, TOutput>): {
|
|
153
|
+
type: "leaf";
|
|
154
|
+
name: TName;
|
|
155
|
+
meta: StepMeta;
|
|
156
|
+
when: ((config: CommerceAppConfigOutputModel) => config is TConfig) | undefined;
|
|
157
|
+
install: (config: TConfig, context: ExecutionContext<TStepCtx>) => TOutput | Promise<TOutput>;
|
|
158
|
+
uninstall: ((config: TConfig, context: ExecutionContext<TStepCtx>) => void | Promise<void>) | undefined;
|
|
159
|
+
validate: ((config: TConfig, context: ValidationExecutionContext<TStepCtx>) => ValidationIssue[] | Promise<ValidationIssue[]>) | undefined;
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Define a branch step (container with children, no runner).
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```typescript
|
|
166
|
+
* const eventing = defineBranchStep({
|
|
167
|
+
* name: "eventing",
|
|
168
|
+
* meta: { install: { label: "Eventing", description: "Sets up I/O Events" } },
|
|
169
|
+
* when: hasEventing,
|
|
170
|
+
* context: async (ctx) => ({ eventsClient: await createEventsClient(ctx) }),
|
|
171
|
+
* children: [commerceEventsStep, externalEventsStep],
|
|
172
|
+
* });
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
declare function defineBranchStep<TName extends string, TConfig extends CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, const TChildren extends AnyStep[] = AnyStep[]>(options: BranchStepOptions<TName, TConfig, TStepCtx, TChildren>): {
|
|
176
|
+
type: "branch";
|
|
177
|
+
name: TName;
|
|
178
|
+
meta: StepMeta;
|
|
179
|
+
when: ((config: CommerceAppConfigOutputModel) => config is TConfig) | undefined;
|
|
180
|
+
context: StepContextFactory<TStepCtx> | undefined;
|
|
181
|
+
children: TChildren;
|
|
182
|
+
validate: ((config: TConfig, context: ValidationExecutionContext<TStepCtx>) => ValidationIssue[] | Promise<ValidationIssue[]>) | undefined;
|
|
183
|
+
};
|
|
184
|
+
/** Infer the output type from a leaf step. */
|
|
185
|
+
type InferStepOutput<TStep> = TStep extends LeafStep<infer _TName, infer _TConfig, infer _TStepCtx, infer TOutput> ? Awaited<TOutput> : never;
|
|
186
|
+
//#endregion
|
|
18
187
|
//#region source/management/installation/workflow/types.d.ts
|
|
19
188
|
/** Status of a step execution. */
|
|
20
189
|
type ExecutionStatus = "pending" | "in-progress" | "succeeded" | "failed";
|
|
@@ -309,4 +478,4 @@ type RunValidationOptions = {
|
|
|
309
478
|
*/
|
|
310
479
|
declare function runValidation(options: RunValidationOptions): Promise<ValidationResult>;
|
|
311
480
|
//#endregion
|
|
312
|
-
export { ExecutionStatus as A, isCompletedState as B, executeUninstallWorkflow as C, StepFailedEvent as D, StepEvent as E, InstallationRetryMetadata as F, isInProgressState as H, InstallationState as I, InstallationStatus as L, InProgressInstallationState as M, InstallationData as N, StepStartedEvent as O, InstallationError as P, StepStatus as R, createRetryState as S, InstallationHooks as T, isSucceededState as U, isFailedState as V, ValidationSummary as _, RunValidationOptions as a, ExecuteWorkflowOptions as b, runInstallation as c, CustomInstallationStepDefinition as d, CustomInstallationStepHandler as f, ValidationResult as g, ValidateStepTreeOptions as h, RunUninstallationOptions as i, FailedInstallationState as j, StepSucceededEvent as k, runUninstallation as l, StepValidationResult as m, CreateInitialUninstallationStateOptions as n, createInitialInstallationState as o, defineCustomInstallationStep as p, RunInstallationOptions as r, createInitialUninstallationState as s, CreateInitialInstallationStateOptions as t, runValidation as u, validateStepTree as v, executeWorkflow as w, createInitialState as x, CreateInitialStateOptions as y, SucceededInstallationState as z };
|
|
481
|
+
export { StepContextFactory as $, ExecutionStatus as A, isCompletedState as B, executeUninstallWorkflow as C, StepFailedEvent as D, StepEvent as E, InstallationRetryMetadata as F, BranchStep as G, isInProgressState as H, InstallationState as I, InferStepOutput as J, BranchStepOptions as K, InstallationStatus as L, InProgressInstallationState as M, InstallationData as N, StepStartedEvent as O, InstallationError as P, Step as Q, StepStatus as R, createRetryState as S, InstallationHooks as T, isSucceededState as U, isFailedState as V, AnyStep as W, LeafStep as X, InstallationContext as Y, LeafStepOptions as Z, ValidationSummary as _, RunValidationOptions as a, ValidationIssueSeverity as at, ExecuteWorkflowOptions as b, runInstallation as c, isBranchStep as ct, CustomInstallationStepDefinition as d, StepMeta as et, CustomInstallationStepHandler as f, ValidationResult as g, ValidateStepTreeOptions as h, RunUninstallationOptions as i, ValidationIssue as it, FailedInstallationState as j, StepSucceededEvent as k, runUninstallation as l, isLeafStep as lt, StepValidationResult as m, CreateInitialUninstallationStateOptions as n, ValidationContext as nt, createInitialInstallationState as o, defineBranchStep as ot, defineCustomInstallationStep as p, ExecutionContext as q, RunInstallationOptions as r, ValidationExecutionContext as rt, createInitialUninstallationState as s, defineLeafStep as st, CreateInitialInstallationStateOptions as t, StepMetaInfo as tt, runValidation as u, validateStepTree as v, executeWorkflow as w, createInitialState as x, CreateInitialStateOptions as y, SucceededInstallationState as z };
|
|
@@ -12,6 +12,5 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import { _ as
|
|
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-Bo0tQsVq.mjs";
|
|
15
|
+
import { $ as StepContextFactory, A as ExecutionStatus, B as isCompletedState, C as executeUninstallWorkflow, D as StepFailedEvent, E as StepEvent, F as InstallationRetryMetadata, G as BranchStep, H as isInProgressState, I as InstallationState, J as InferStepOutput, K as BranchStepOptions, L as InstallationStatus, M as InProgressInstallationState, N as InstallationData, O as StepStartedEvent, P as InstallationError, Q as Step, R as StepStatus, S as createRetryState, T as InstallationHooks, U as isSucceededState, V as isFailedState, W as AnyStep, X as LeafStep, Y as InstallationContext, Z as LeafStepOptions, _ as ValidationSummary, a as RunValidationOptions, at as ValidationIssueSeverity, b as ExecuteWorkflowOptions, c as runInstallation, ct as isBranchStep, d as CustomInstallationStepDefinition, et as StepMeta, f as CustomInstallationStepHandler, g as ValidationResult, h as ValidateStepTreeOptions, i as RunUninstallationOptions, it as ValidationIssue, j as FailedInstallationState, k as StepSucceededEvent, l as runUninstallation, lt as isLeafStep, m as StepValidationResult, n as CreateInitialUninstallationStateOptions, nt as ValidationContext, o as createInitialInstallationState, ot as defineBranchStep, p as defineCustomInstallationStep, q as ExecutionContext, r as RunInstallationOptions, rt as ValidationExecutionContext, s as createInitialUninstallationState, st as defineLeafStep, t as CreateInitialInstallationStateOptions, tt as StepMetaInfo, u as runValidation, v as validateStepTree, w as executeWorkflow, x as createInitialState, y as CreateInitialStateOptions, z as SucceededInstallationState } from "../index-DLMbTtKS.mjs";
|
|
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 };
|
|
@@ -12,6 +12,6 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import { a as runValidation, c as isFailedState, i as runUninstallation, l as isInProgressState, n as createInitialUninstallationState, o as defineCustomInstallationStep, r as runInstallation, s as isCompletedState, t as createInitialInstallationState, u as isSucceededState } from "../management-
|
|
15
|
+
import { a as runValidation, c as isFailedState, i as runUninstallation, l as isInProgressState, n as createInitialUninstallationState, o as defineCustomInstallationStep, r as runInstallation, s as isCompletedState, t as createInitialInstallationState, u as isSucceededState } from "../management-BUX-w2Ji.mjs";
|
|
16
16
|
|
|
17
17
|
export { createInitialInstallationState, createInitialUninstallationState, defineCustomInstallationStep, isCompletedState, isFailedState, isInProgressState, isSucceededState, runInstallation, runUninstallation, runValidation };
|
|
@@ -12,17 +12,34 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
+
import { t as stringifyError } from "./error-_RMwtrUA.mjs";
|
|
15
16
|
import { a as hasCustomInstallationSteps, c as hasEventing, d as hasAdminUiSdk, l as hasExternalEvents, n as hasWebhooks, s as hasCommerceEvents } from "./webhooks-B5oq9ULL.mjs";
|
|
16
17
|
import { t as inspect } from "./logging-DbJHXSKh.mjs";
|
|
17
|
-
import {
|
|
18
|
+
import { CommerceSdkValidationError } from "@adobe/aio-commerce-lib-core/error";
|
|
19
|
+
import * as v from "valibot";
|
|
18
20
|
import { unwrapHttpError } from "@adobe/aio-commerce-lib-api/utils";
|
|
19
21
|
import * as camelcaseModule from "camelcase";
|
|
20
|
-
import {
|
|
22
|
+
import { createAdminUiApiClient } from "@adobe/aio-commerce-lib-admin-ui/api";
|
|
23
|
+
import { resolveCommerceHttpClientParams, resolveIoEventsHttpClientParams } from "@adobe/aio-commerce-lib-api";
|
|
21
24
|
import { resolveAuthParams, resolveImsAuthParams } from "@adobe/aio-commerce-lib-auth";
|
|
22
25
|
import { createCustomCommerceEventsApiClient, createEventProvider, createEventSubscription, deleteEventProvider, deleteEventSubscription, getAllEventProviders, getAllEventSubscriptions, updateEventingConfiguration } from "@adobe/aio-commerce-lib-events/commerce";
|
|
23
26
|
import { createCustomAdobeIoEventsApiClient, createEventMetadataForProvider, createEventProvider as createEventProvider$1, createRegistration, deleteEventMetadataForProvider, deleteEventProvider as deleteEventProvider$1, deleteRegistration, getAllEventProviders as getAllEventProviders$1, getAllRegistrations } from "@adobe/aio-commerce-lib-events/io-events";
|
|
24
27
|
import { createCustomCommerceWebhooksApiClient, getWebhookList, subscribeWebhook, unsubscribeWebhook } from "@adobe/aio-commerce-lib-webhooks/api";
|
|
25
28
|
|
|
29
|
+
//#region ../../packages-private/common-utils/source/valibot/utils.ts
|
|
30
|
+
/**
|
|
31
|
+
* Parses the input using the provided schema and throws a {@link CommerceSdkValidationError} error if the input is invalid.
|
|
32
|
+
* @param schema - The schema to use for parsing.
|
|
33
|
+
* @param input - The input to parse.
|
|
34
|
+
* @param message - Optional custom error message for the validation error.
|
|
35
|
+
*/
|
|
36
|
+
function parseOrThrow(schema, input, message) {
|
|
37
|
+
const result = v.safeParse(schema, input);
|
|
38
|
+
if (!result.success) throw new CommerceSdkValidationError(message ?? "Invalid input", { issues: result.issues });
|
|
39
|
+
return result.output;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
26
43
|
//#region source/management/installation/workflow/hooks.ts
|
|
27
44
|
/** Helper to call a hook if it exists. */
|
|
28
45
|
async function callHook(hooks, hookName, ...args) {
|
|
@@ -454,11 +471,37 @@ function aggregateSummary(result) {
|
|
|
454
471
|
//#endregion
|
|
455
472
|
//#region source/management/installation/custom-installation/custom-scripts.ts
|
|
456
473
|
const camelcase = camelcaseModule.default.default ?? camelcaseModule.default;
|
|
457
|
-
|
|
458
|
-
|
|
474
|
+
const ScriptModuleSchema = v.union([v.function(), v.object({
|
|
475
|
+
install: v.function(),
|
|
476
|
+
uninstall: v.optional(v.function())
|
|
477
|
+
})]);
|
|
478
|
+
/**
|
|
479
|
+
* Validates that a loaded script export can be executed as a custom installation step.
|
|
480
|
+
*
|
|
481
|
+
* @param module - The loaded script export to validate.
|
|
482
|
+
* @throws If the export is not a function or an object with an `install` function.
|
|
483
|
+
*/
|
|
484
|
+
function assertScriptModule(module) {
|
|
485
|
+
parseOrThrow(ScriptModuleSchema, module, "Invalid script module format. Expected a function or an object with an `install` method.");
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Parses and validates a custom script module from the provided customScripts context.
|
|
489
|
+
* It supports both direct function exports and default exports.
|
|
490
|
+
*
|
|
491
|
+
* @param customScripts - The customScripts context containing the loaded modules
|
|
492
|
+
* @param script - The script path to resolve the module for
|
|
493
|
+
*/
|
|
494
|
+
function getScriptModule(customScripts, script) {
|
|
495
|
+
let scriptModule = customScripts[script];
|
|
496
|
+
if (!scriptModule) throw new Error(`Script ${script} not found in customScripts context. Make sure the script is defined in the configuration and the action was generated with custom scripts support.`);
|
|
497
|
+
if (typeof scriptModule === "object" && "default" in scriptModule) scriptModule = scriptModule.default;
|
|
498
|
+
assertScriptModule(scriptModule);
|
|
499
|
+
return scriptModule;
|
|
459
500
|
}
|
|
460
|
-
function
|
|
461
|
-
|
|
501
|
+
function resolveCustomScriptHandler(scriptModule, handler) {
|
|
502
|
+
if (typeof scriptModule === "function") return handler === "install" ? scriptModule : null;
|
|
503
|
+
if (handler in scriptModule && typeof scriptModule[handler] === "function") return scriptModule[handler];
|
|
504
|
+
return null;
|
|
462
505
|
}
|
|
463
506
|
/**
|
|
464
507
|
* Creates a leaf step for executing a single custom installation script.
|
|
@@ -476,15 +519,7 @@ function createCustomScriptStep(scriptConfig) {
|
|
|
476
519
|
const customScripts = context.customScripts || {};
|
|
477
520
|
logger.info(`Executing custom installation script: ${name}`);
|
|
478
521
|
logger.debug(`Script path: ${script}`);
|
|
479
|
-
const
|
|
480
|
-
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.`);
|
|
481
|
-
if (typeof scriptModule !== "object" || !("default" in scriptModule)) throw new Error(`Script ${script} must export a default function or object. Use defineCustomInstallationStep helper.`);
|
|
482
|
-
const defaultExport = scriptModule.default;
|
|
483
|
-
let runFunction = null;
|
|
484
|
-
if (isCustomInstallationStepHandler(defaultExport)) runFunction = defaultExport;
|
|
485
|
-
else if (isCustomInstallationStepDefinition(defaultExport)) runFunction = defaultExport.install;
|
|
486
|
-
if (runFunction === null) throw new Error(`Script ${script} default export must be a function or an object with an install method. Use defineCustomInstallationStep helper.`);
|
|
487
|
-
const scriptResult = await runFunction(config, context);
|
|
522
|
+
const scriptResult = await resolveCustomScriptHandler(getScriptModule(customScripts, script), "install")(config, context);
|
|
488
523
|
logger.info(`Successfully executed script: ${name}`);
|
|
489
524
|
return {
|
|
490
525
|
script,
|
|
@@ -495,14 +530,7 @@ function createCustomScriptStep(scriptConfig) {
|
|
|
495
530
|
const { logger } = context;
|
|
496
531
|
const customScripts = context.customScripts || {};
|
|
497
532
|
logger.debug(`Uninstalling custom script: ${name}`);
|
|
498
|
-
const
|
|
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
|
-
const defaultExport = scriptModule.default;
|
|
501
|
-
if (!isCustomInstallationStepDefinition(defaultExport)) {
|
|
502
|
-
logger.debug(`Script ${script} does not export an uninstall function, skipping uninstall.`);
|
|
503
|
-
return;
|
|
504
|
-
}
|
|
505
|
-
const { uninstall } = defaultExport;
|
|
533
|
+
const uninstall = resolveCustomScriptHandler(getScriptModule(customScripts, script), "uninstall");
|
|
506
534
|
if (!uninstall) {
|
|
507
535
|
logger.debug(`Script ${script} does not export an uninstall function, skipping uninstall.`);
|
|
508
536
|
return;
|
|
@@ -609,34 +637,40 @@ async function throwHttpError(logger, error, prefix) {
|
|
|
609
637
|
/**
|
|
610
638
|
* Registers the extension with Commerce via POST /V1/adminuisdk/extension.
|
|
611
639
|
*
|
|
612
|
-
* @param context - The execution context providing the
|
|
613
|
-
* @returns The response from the Commerce API.
|
|
640
|
+
* @param context - The execution context providing the Admin UI SDK client and logger.
|
|
614
641
|
*/
|
|
615
642
|
async function registerExtension(context) {
|
|
616
|
-
const {
|
|
643
|
+
const { adminUiClient, appData, logger } = context;
|
|
644
|
+
const extensionName = process.env.__OW_NAMESPACE;
|
|
645
|
+
if (!extensionName) throw new Error("__OW_NAMESPACE environment variable is not set");
|
|
617
646
|
logger.info(`Registering Admin UI SDK extension: ${appData.projectName}`);
|
|
618
|
-
const
|
|
619
|
-
extensionName
|
|
647
|
+
const { extensionId } = await adminUiClient.registerExtension({
|
|
648
|
+
extensionName,
|
|
620
649
|
extensionTitle: appData.projectTitle,
|
|
621
|
-
extensionUrl: `https://${
|
|
650
|
+
extensionUrl: `https://${extensionName}.adobeio-static.net/index.html`,
|
|
622
651
|
extensionWorkspace: appData.workspaceName
|
|
623
|
-
}
|
|
624
|
-
logger.info(`Admin UI SDK extension registered successfully: ${
|
|
625
|
-
return response;
|
|
652
|
+
}).catch((error) => throwHttpError(logger, error, "Failed to register Admin UI SDK extension"));
|
|
653
|
+
logger.info(`Admin UI SDK extension registered successfully: ${extensionId}`);
|
|
626
654
|
}
|
|
627
655
|
/**
|
|
628
656
|
* Unregisters the extension from Commerce via DELETE /V1/adminuisdk/extension/:workspace_name/:extension_name.
|
|
629
657
|
* Best-effort: errors are logged as warnings and do not stop the uninstall workflow.
|
|
630
658
|
*
|
|
631
|
-
* @param context - The execution context providing the
|
|
659
|
+
* @param context - The execution context providing the Admin UI SDK client and logger.
|
|
632
660
|
*/
|
|
633
|
-
async function
|
|
634
|
-
const {
|
|
661
|
+
async function unregisterExtension(context) {
|
|
662
|
+
const { adminUiClient, appData, logger } = context;
|
|
635
663
|
const extensionName = process.env.__OW_NAMESPACE;
|
|
636
|
-
|
|
664
|
+
if (!extensionName) {
|
|
665
|
+
logger.warn("__OW_NAMESPACE environment variable is not set; skipping Admin UI SDK extension unregistration. Continuing uninstall.");
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
637
668
|
logger.info(`Unregistering Admin UI SDK extension "${extensionName}" from workspace "${appData.workspaceName}"...`);
|
|
638
669
|
try {
|
|
639
|
-
await
|
|
670
|
+
await adminUiClient.unregisterExtension({
|
|
671
|
+
workspaceName: appData.workspaceName,
|
|
672
|
+
extensionName
|
|
673
|
+
});
|
|
640
674
|
logger.info(`Admin UI SDK extension "${extensionName}" unregistered successfully.`);
|
|
641
675
|
} catch (error) {
|
|
642
676
|
const msg = await unwrapHttpError(error);
|
|
@@ -646,19 +680,22 @@ async function uninstallExtension(context) {
|
|
|
646
680
|
|
|
647
681
|
//#endregion
|
|
648
682
|
//#region source/management/installation/admin-ui-sdk/utils.ts
|
|
649
|
-
|
|
683
|
+
function createAdminUiClient(params) {
|
|
684
|
+
return createAdminUiApiClient(resolveCommerceHttpClientParams(params, { tryForwardAuthProvider: true }));
|
|
685
|
+
}
|
|
686
|
+
/** Creates the Admin UI SDK step context with a lazy-initialized API client. */
|
|
650
687
|
const createAdminUiSdkStepContext = (installation) => {
|
|
651
688
|
const { params } = installation;
|
|
652
|
-
let
|
|
653
|
-
return { get
|
|
654
|
-
if (
|
|
655
|
-
return
|
|
689
|
+
let adminUiClient = null;
|
|
690
|
+
return { get adminUiClient() {
|
|
691
|
+
if (adminUiClient === null) adminUiClient = createAdminUiClient(params);
|
|
692
|
+
return adminUiClient;
|
|
656
693
|
} };
|
|
657
694
|
};
|
|
658
695
|
|
|
659
696
|
//#endregion
|
|
660
697
|
//#region source/management/installation/admin-ui-sdk/branch.ts
|
|
661
|
-
/** Leaf step that
|
|
698
|
+
/** Leaf step that registers the extension (POST) on install and unregisters it (DELETE) on uninstall. */
|
|
662
699
|
const registerExtensionStep = defineLeafStep({
|
|
663
700
|
name: "register-extension",
|
|
664
701
|
meta: {
|
|
@@ -672,7 +709,7 @@ const registerExtensionStep = defineLeafStep({
|
|
|
672
709
|
}
|
|
673
710
|
},
|
|
674
711
|
install: (_, context) => registerExtension(context),
|
|
675
|
-
uninstall: (_, context) =>
|
|
712
|
+
uninstall: (_, context) => unregisterExtension(context)
|
|
676
713
|
});
|
|
677
714
|
/** Branch step for setting up the Admin UI SDK extension registration. */
|
|
678
715
|
const adminUiSdkStep = defineBranchStep({
|