@adobe/aio-commerce-lib-app 1.5.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +49 -0
- package/dist/cjs/actions/app-config/index.cjs +202 -0
- package/dist/cjs/actions/{app-config.d.cts → app-config/index.d.cts} +11 -9
- package/dist/cjs/actions/{config.cjs → config/index.cjs} +79 -46
- package/dist/{es/actions/config.d.mts → cjs/actions/config/index.d.cts} +10 -8
- package/dist/cjs/actions/{installation.cjs → installation/index.cjs} +55 -36
- package/dist/{es/actions/installation.d.mts → cjs/actions/installation/index.d.cts} +11 -10
- package/dist/cjs/actions/{registration.cjs → registration/index.cjs} +16 -7
- package/dist/cjs/actions/{registration.d.cts → registration/index.d.cts} +8 -9
- package/dist/cjs/actions/{scope-tree.cjs → scope-tree/index.cjs} +52 -15
- package/dist/{es/actions/scope-tree.d.mts → cjs/actions/scope-tree/index.d.cts} +2 -5
- package/dist/cjs/{admin-ui-sdk-BiSopnKI.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 +241 -56
- package/dist/cjs/commands/templates/app-management/app-config.js.template +2 -2
- package/dist/cjs/config/index.cjs +3 -3
- package/dist/cjs/config/index.d.cts +181 -1158
- package/dist/cjs/{config-ct-qMOGj.cjs → config-D-s0GSep.cjs} +4 -6
- package/dist/cjs/{error-C5LNOZ4f.cjs → error-D-N0PKSl.cjs} +0 -1
- package/dist/cjs/{index-B5WKJ3hJ.d.cts → index-B5gJ-q4U.d.cts} +172 -3
- package/dist/cjs/index-BXm8UbK7.d.cts +16 -0
- package/dist/cjs/{logging-BTevALnL.cjs → logging-BVz3weoC.cjs} +1 -1
- package/dist/cjs/management/index.cjs +1 -1
- package/dist/cjs/management/index.d.cts +2 -3
- package/dist/cjs/{management-D1QXg4YU.cjs → management-Dehz9qSJ.cjs} +114 -51
- package/dist/cjs/openapi-Cux6K4ZD.cjs +3072 -0
- package/dist/cjs/{router-CFErodHU.cjs → router-BOR7T6qR.cjs} +1 -1
- package/dist/cjs/{schemas-CukVpc19.cjs → schemas-FngDuIeo.cjs} +1 -1
- package/dist/cjs/{validate-b_bI4mDb.cjs → validate-oAOpyFyb.cjs} +49 -17
- package/dist/cjs/{webhooks-DS1BtgED.cjs → webhooks-tbZy9G3p.cjs} +4 -4
- package/dist/es/actions/{app-config.d.mts → app-config/index.d.mts} +11 -9
- package/dist/es/actions/app-config/index.mjs +199 -0
- package/dist/{cjs/actions/config.d.cts → es/actions/config/index.d.mts} +10 -8
- package/dist/es/actions/{config.mjs → config/index.mjs} +78 -45
- package/dist/{cjs/actions/installation.d.cts → es/actions/installation/index.d.mts} +11 -10
- package/dist/es/actions/{installation.mjs → installation/index.mjs} +54 -36
- package/dist/es/actions/{registration.d.mts → registration/index.d.mts} +8 -9
- package/dist/es/actions/{registration.mjs → registration/index.mjs} +16 -6
- package/dist/{cjs/actions/scope-tree.d.cts → es/actions/scope-tree/index.d.mts} +2 -5
- package/dist/es/actions/{scope-tree.mjs → scope-tree/index.mjs} +51 -14
- package/dist/es/{admin-ui-sdk-CCo2SWiL.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 +223 -38
- package/dist/es/commands/templates/app-management/app-config.js.template +2 -2
- package/dist/es/config/index.d.mts +181 -1157
- package/dist/es/config/index.mjs +3 -3
- package/dist/es/{config-DGPFTk6w.mjs → config-3I4eLyyR.mjs} +4 -5
- package/dist/es/index-B0XqHwY5.d.mts +16 -0
- package/dist/es/{index-CCov0odd.d.mts → index-DLMbTtKS.d.mts} +172 -3
- package/dist/es/management/index.d.mts +2 -3
- package/dist/es/management/index.mjs +1 -1
- package/dist/es/{management-CCsOfniv.mjs → management-BUX-w2Ji.mjs} +113 -51
- package/dist/es/openapi-B6uP0SRn.mjs +3024 -0
- package/dist/es/{validate-Dn3lLTGj.mjs → validate-Dfajrp99.mjs} +37 -17
- package/dist/es/{webhooks-Dhrkkip7.mjs → webhooks-B5oq9ULL.mjs} +3 -3
- package/package.json +29 -17
- package/dist/cjs/actions/app-config.cjs +0 -41
- package/dist/cjs/app-C6kImBl7.d.cts +0 -564
- package/dist/cjs/step-CWYnKbga.d.cts +0 -187
- package/dist/es/actions/app-config.mjs +0 -39
- package/dist/es/app-DcY6dJiQ.d.mts +0 -564
- package/dist/es/step-0eI2x4C9.d.mts +0 -187
- /package/dist/cjs/{chunk-DS2yp5vX.cjs → chunk-Cozy-1ZF.cjs} +0 -0
- /package/dist/es/{error-DHlYzkbb.mjs → error-_RMwtrUA.mjs} +0 -0
- /package/dist/es/{logging-XIUXDK5T.mjs → logging-DbJHXSKh.mjs} +0 -0
- /package/dist/es/{router-BxaxEEu3.mjs → router-D58JJHHA.mjs} +0 -0
- /package/dist/es/{schemas-DOcnD16x.mjs → schemas-hRovglBF.mjs} +0 -0
|
@@ -12,15 +12,13 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
const
|
|
16
|
-
const require_validate = require('./validate-
|
|
17
|
-
const require_error = require('./error-C5LNOZ4f.cjs');
|
|
15
|
+
const require_error = require('./error-D-N0PKSl.cjs');
|
|
16
|
+
const require_validate = require('./validate-oAOpyFyb.cjs');
|
|
18
17
|
let path = require("path");
|
|
19
18
|
let fs = require("fs");
|
|
20
19
|
let fs_promises = require("fs/promises");
|
|
21
20
|
let package_manager_detector = require("package-manager-detector");
|
|
22
21
|
let package_manager_detector_detect = require("package-manager-detector/detect");
|
|
23
|
-
let jiti = require("jiti");
|
|
24
22
|
|
|
25
23
|
//#region source/config/lib/define.ts
|
|
26
24
|
/**
|
|
@@ -170,7 +168,6 @@ function getInstallCommand(packageManager, packages) {
|
|
|
170
168
|
|
|
171
169
|
//#endregion
|
|
172
170
|
//#region source/config/lib/parser.ts
|
|
173
|
-
const jiti$1 = (0, jiti.createJiti)(require("url").pathToFileURL(__filename).href);
|
|
174
171
|
const configPaths = Object.freeze([
|
|
175
172
|
"app.commerce.config.js",
|
|
176
173
|
"app.commerce.config.ts",
|
|
@@ -221,7 +218,8 @@ async function readCommerceAppConfig(cwd = process.cwd()) {
|
|
|
221
218
|
if (!configFilePath) throw new Error("Could not find a commerce app config file in the current working directory or its parents.");
|
|
222
219
|
let config = null;
|
|
223
220
|
try {
|
|
224
|
-
|
|
221
|
+
const { createJiti } = await import("jiti");
|
|
222
|
+
config = await createJiti(require("url").pathToFileURL(__filename).href).import(configFilePath);
|
|
225
223
|
} catch (error) {
|
|
226
224
|
const message = require_error.stringifyError(error);
|
|
227
225
|
throw new Error(`Failed to read commerce app config file at ${configFilePath}: ${message}`, { cause: error });
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
const require_chunk = require('./chunk-DS2yp5vX.cjs');
|
|
16
15
|
let _adobe_aio_commerce_lib_core_error = require("@adobe/aio-commerce-lib-core/error");
|
|
17
16
|
|
|
18
17
|
//#region ../../packages-private/scripting-utils/source/error.ts
|
|
@@ -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.cjs";
|
|
16
|
+
import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
|
|
17
|
+
import AioLogger from "@adobe/aio-lib-core-logging";
|
|
18
|
+
import * as v from "valibot";
|
|
17
19
|
|
|
20
|
+
//#region source/management/installation/schema.d.ts
|
|
21
|
+
/** Schema for validating Adobe I/O app credentials required for installation. */
|
|
22
|
+
declare const AppDataSchema: v.ObjectSchema<{
|
|
23
|
+
readonly consumerOrgId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
24
|
+
readonly orgName: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
25
|
+
readonly projectId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
26
|
+
readonly projectName: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
27
|
+
readonly projectTitle: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
28
|
+
readonly workspaceId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
29
|
+
readonly workspaceName: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
30
|
+
readonly workspaceTitle: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
31
|
+
}, undefined>;
|
|
32
|
+
/** Type for Adobe I/O app credentials. */
|
|
33
|
+
type AppData = v.InferOutput<typeof AppDataSchema>;
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region source/management/installation/workflow/step.d.ts
|
|
36
|
+
/** Severity level of a validation issue. */
|
|
37
|
+
type ValidationIssueSeverity = "error" | "warning" | "info";
|
|
38
|
+
/** A single validation issue reported by a step's validate handler. */
|
|
39
|
+
type ValidationIssue = {
|
|
40
|
+
/** Machine-readable code identifying the issue type. */code: string; /** Human-readable description of the issue. */
|
|
41
|
+
message: string; /** Severity of the issue. Only "error" severity blocks installation. */
|
|
42
|
+
severity: ValidationIssueSeverity; /** Optional additional context about the issue. */
|
|
43
|
+
details?: Record<string, unknown>;
|
|
44
|
+
};
|
|
45
|
+
/** Shared context available to all steps during installation. */
|
|
46
|
+
type InstallationContext = {
|
|
47
|
+
/** The credentials of the app being installed */appData: AppData; /** The raw action parameters from the App Builder runtime action. */
|
|
48
|
+
params: RuntimeActionParams & {
|
|
49
|
+
AIO_COMMERCE_AUTH_IMS_CLIENT_ID: string;
|
|
50
|
+
AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS: string | string[];
|
|
51
|
+
AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_ID: string;
|
|
52
|
+
AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_EMAIL: string;
|
|
53
|
+
AIO_COMMERCE_AUTH_IMS_ORG_ID: string;
|
|
54
|
+
AIO_COMMERCE_AUTH_IMS_SCOPES: string | string[];
|
|
55
|
+
}; /** Logger instance for installation logging. */
|
|
56
|
+
logger: ReturnType<typeof AioLogger>; /** Custom scripts defined in the configuration (if any). */
|
|
57
|
+
customScripts?: Record<string, unknown>;
|
|
58
|
+
};
|
|
59
|
+
/** Factory function type for creating step-specific context. */
|
|
60
|
+
type StepContextFactory<TStepCtx extends Record<string, unknown> = Record<string, unknown>> = (context: InstallationContext) => TStepCtx | Promise<TStepCtx>;
|
|
61
|
+
/** The execution context passed to leaf step run handlers. */
|
|
62
|
+
type ExecutionContext<TStepCtx extends Record<string, unknown> = Record<string, unknown>> = InstallationContext & TStepCtx;
|
|
63
|
+
/**
|
|
64
|
+
* A narrowed context available to step `validate` handlers.
|
|
65
|
+
* Excludes `customScripts` — those only apply during installation, not pre-flight validation.
|
|
66
|
+
*/
|
|
67
|
+
type ValidationContext = Omit<InstallationContext, "customScripts">;
|
|
68
|
+
/** The context passed to step `validate` handlers (base validation context merged with step-level context). */
|
|
69
|
+
type ValidationExecutionContext<TStepCtx extends Record<string, unknown> = Record<string, unknown>> = ValidationContext & TStepCtx;
|
|
70
|
+
/** Metadata info for a step (used for UI display). */
|
|
71
|
+
type StepMetaInfo = {
|
|
72
|
+
label: string;
|
|
73
|
+
description?: string;
|
|
74
|
+
};
|
|
75
|
+
/** Step metadata keyed by execution mode. */
|
|
76
|
+
type StepMeta = {
|
|
77
|
+
install: StepMetaInfo;
|
|
78
|
+
uninstall?: StepMetaInfo;
|
|
79
|
+
};
|
|
80
|
+
/** Defines the base properties of a step. */
|
|
81
|
+
type StepBase<TName extends string = string, TConfig extends CommerceAppConfigOutputModel = CommerceAppConfigOutputModel> = {
|
|
82
|
+
/** The name of this step. */name: TName; /** Metadata associated with the step, keyed by execution mode. */
|
|
83
|
+
meta: StepMeta; /** Whether the step should be taken into consideration. */
|
|
84
|
+
when?: (config: CommerceAppConfigOutputModel) => config is TConfig;
|
|
85
|
+
};
|
|
86
|
+
/** A leaf step that executes work (no children). */
|
|
87
|
+
type LeafStep<TName extends string = string, TConfig extends CommerceAppConfigOutputModel = CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TOutput = unknown> = StepBase<TName, TConfig> & {
|
|
88
|
+
type: "leaf"; /** The execution handler for the step. */
|
|
89
|
+
install: (config: TConfig, context: ExecutionContext<TStepCtx>) => TOutput | Promise<TOutput>;
|
|
90
|
+
/**
|
|
91
|
+
* Optional pre-installation validation handler.
|
|
92
|
+
* Called before installation begins to surface issues (errors or warnings).
|
|
93
|
+
* Returning an empty array means the step has no issues.
|
|
94
|
+
*/
|
|
95
|
+
validate?: (config: TConfig, context: ValidationExecutionContext<TStepCtx>) => ValidationIssue[] | Promise<ValidationIssue[]>;
|
|
96
|
+
/**
|
|
97
|
+
* Optional uninstall handler for the step.
|
|
98
|
+
* Called during uninstallation to reverse the work done by `install`.
|
|
99
|
+
* If absent, the step is silently skipped during uninstallation.
|
|
100
|
+
*/
|
|
101
|
+
uninstall?: (config: TConfig, context: ExecutionContext<TStepCtx>) => void | Promise<void>;
|
|
102
|
+
};
|
|
103
|
+
/** A branch step that contains children (no execution). */
|
|
104
|
+
type BranchStep<TName extends string = string, TConfig extends CommerceAppConfigOutputModel = CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TChildren extends AnyStep[] = AnyStep[]> = StepBase<TName, TConfig> & {
|
|
105
|
+
type: "branch"; /** An optional factory function to setup shared context for the children steps. */
|
|
106
|
+
context?: StepContextFactory<TStepCtx>; /** The children steps of this branch. */
|
|
107
|
+
children: TChildren;
|
|
108
|
+
/**
|
|
109
|
+
* Optional pre-installation validation handler for the branch itself.
|
|
110
|
+
* Called before children are validated. Returning an empty array means
|
|
111
|
+
* the branch has no issues at this level.
|
|
112
|
+
*/
|
|
113
|
+
validate?: (config: TConfig, context: ValidationExecutionContext<TStepCtx>) => ValidationIssue[] | Promise<ValidationIssue[]>;
|
|
114
|
+
};
|
|
115
|
+
/** A step in the installation tree (discriminated union by `type`). */
|
|
116
|
+
type Step<TName extends string = string, TConfig extends CommerceAppConfigOutputModel = CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TOutput = unknown> = LeafStep<TName, TConfig, TStepCtx, TOutput> | BranchStep<TName, TConfig, TStepCtx>;
|
|
117
|
+
/** Loosely-typed step for use in non type-safe contexts. */
|
|
118
|
+
interface AnyStep {
|
|
119
|
+
children?: AnyStep[];
|
|
120
|
+
context?: (context: InstallationContext) => any;
|
|
121
|
+
install?: (config: any, context: any) => unknown | Promise<unknown>;
|
|
122
|
+
meta: StepMeta;
|
|
123
|
+
name: string;
|
|
124
|
+
type: "leaf" | "branch";
|
|
125
|
+
uninstall?: (config: any, context: any) => void | Promise<void>;
|
|
126
|
+
validate?: (config: any, context: any) => ValidationIssue[] | Promise<ValidationIssue[]>;
|
|
127
|
+
when?: (config: CommerceAppConfigOutputModel) => boolean;
|
|
128
|
+
}
|
|
129
|
+
/** Check if a step is a leaf step. */
|
|
130
|
+
declare function isLeafStep(step: AnyStep): step is LeafStep;
|
|
131
|
+
/** Check if a step is a branch step. */
|
|
132
|
+
declare function isBranchStep(step: AnyStep): step is BranchStep;
|
|
133
|
+
/** Options for defining a leaf step. */
|
|
134
|
+
type LeafStepOptions<TName extends string, TConfig extends CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TOutput = unknown> = Omit<LeafStep<TName, TConfig, TStepCtx, TOutput>, "type">;
|
|
135
|
+
/** Options for defining a branch step. */
|
|
136
|
+
type BranchStepOptions<TName extends string, TConfig extends CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TChildren extends AnyStep[] = AnyStep[]> = Omit<BranchStep<TName, TConfig, TStepCtx, TChildren>, "type">;
|
|
137
|
+
/**
|
|
138
|
+
* Define a leaf step (executable, no children).
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* const createProviders = defineLeafStep({
|
|
143
|
+
* name: "providers",
|
|
144
|
+
* meta: { install: { label: "Create Providers", description: "Creates I/O Events providers" } },
|
|
145
|
+
* install: async ({ config, stepContext }) => {
|
|
146
|
+
* const { eventsClient } = stepContext;
|
|
147
|
+
* return eventsClient.createProvider(config.eventing);
|
|
148
|
+
* },
|
|
149
|
+
* });
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
declare function defineLeafStep<TName extends string, TConfig extends CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TOutput = unknown>(options: LeafStepOptions<TName, TConfig, TStepCtx, TOutput>): {
|
|
153
|
+
type: "leaf";
|
|
154
|
+
name: TName;
|
|
155
|
+
meta: StepMeta;
|
|
156
|
+
when: ((config: CommerceAppConfigOutputModel) => config is TConfig) | undefined;
|
|
157
|
+
install: (config: TConfig, context: ExecutionContext<TStepCtx>) => TOutput | Promise<TOutput>;
|
|
158
|
+
uninstall: ((config: TConfig, context: ExecutionContext<TStepCtx>) => void | Promise<void>) | undefined;
|
|
159
|
+
validate: ((config: TConfig, context: ValidationExecutionContext<TStepCtx>) => ValidationIssue[] | Promise<ValidationIssue[]>) | undefined;
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Define a branch step (container with children, no runner).
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```typescript
|
|
166
|
+
* const eventing = defineBranchStep({
|
|
167
|
+
* name: "eventing",
|
|
168
|
+
* meta: { install: { label: "Eventing", description: "Sets up I/O Events" } },
|
|
169
|
+
* when: hasEventing,
|
|
170
|
+
* context: async (ctx) => ({ eventsClient: await createEventsClient(ctx) }),
|
|
171
|
+
* children: [commerceEventsStep, externalEventsStep],
|
|
172
|
+
* });
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
declare function defineBranchStep<TName extends string, TConfig extends CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, const TChildren extends AnyStep[] = AnyStep[]>(options: BranchStepOptions<TName, TConfig, TStepCtx, TChildren>): {
|
|
176
|
+
type: "branch";
|
|
177
|
+
name: TName;
|
|
178
|
+
meta: StepMeta;
|
|
179
|
+
when: ((config: CommerceAppConfigOutputModel) => config is TConfig) | undefined;
|
|
180
|
+
context: StepContextFactory<TStepCtx> | undefined;
|
|
181
|
+
children: TChildren;
|
|
182
|
+
validate: ((config: TConfig, context: ValidationExecutionContext<TStepCtx>) => ValidationIssue[] | Promise<ValidationIssue[]>) | undefined;
|
|
183
|
+
};
|
|
184
|
+
/** Infer the output type from a leaf step. */
|
|
185
|
+
type InferStepOutput<TStep> = TStep extends LeafStep<infer _TName, infer _TConfig, infer _TStepCtx, infer TOutput> ? Awaited<TOutput> : never;
|
|
186
|
+
//#endregion
|
|
18
187
|
//#region source/management/installation/workflow/types.d.ts
|
|
19
188
|
/** Status of a step execution. */
|
|
20
189
|
type ExecutionStatus = "pending" | "in-progress" | "succeeded" | "failed";
|
|
@@ -309,4 +478,4 @@ type RunValidationOptions = {
|
|
|
309
478
|
*/
|
|
310
479
|
declare function runValidation(options: RunValidationOptions): Promise<ValidationResult>;
|
|
311
480
|
//#endregion
|
|
312
|
-
export { ExecutionStatus as A, isCompletedState as B, executeUninstallWorkflow as C, StepFailedEvent as D, StepEvent as E, InstallationRetryMetadata as F, isInProgressState as H, InstallationState as I, InstallationStatus as L, InProgressInstallationState as M, InstallationData as N, StepStartedEvent as O, InstallationError as P, StepStatus as R, createRetryState as S, InstallationHooks as T, isSucceededState as U, isFailedState as V, ValidationSummary as _, RunValidationOptions as a, ExecuteWorkflowOptions as b, runInstallation as c, CustomInstallationStepDefinition as d, CustomInstallationStepHandler as f, ValidationResult as g, ValidateStepTreeOptions as h, RunUninstallationOptions as i, FailedInstallationState as j, StepSucceededEvent as k, runUninstallation as l, StepValidationResult as m, CreateInitialUninstallationStateOptions as n, createInitialInstallationState as o, defineCustomInstallationStep as p, RunInstallationOptions as r, createInitialUninstallationState as s, CreateInitialInstallationStateOptions as t, runValidation as u, validateStepTree as v, executeWorkflow as w, createInitialState as x, CreateInitialStateOptions as y, SucceededInstallationState as z };
|
|
481
|
+
export { StepContextFactory as $, ExecutionStatus as A, isCompletedState as B, executeUninstallWorkflow as C, StepFailedEvent as D, StepEvent as E, InstallationRetryMetadata as F, BranchStep as G, isInProgressState as H, InstallationState as I, InferStepOutput as J, BranchStepOptions as K, InstallationStatus as L, InProgressInstallationState as M, InstallationData as N, StepStartedEvent as O, InstallationError as P, Step as Q, StepStatus as R, createRetryState as S, InstallationHooks as T, isSucceededState as U, isFailedState as V, AnyStep as W, LeafStep as X, InstallationContext as Y, LeafStepOptions as Z, ValidationSummary as _, RunValidationOptions as a, ValidationIssueSeverity as at, ExecuteWorkflowOptions as b, runInstallation as c, isBranchStep as ct, CustomInstallationStepDefinition as d, StepMeta as et, CustomInstallationStepHandler as f, ValidationResult as g, ValidateStepTreeOptions as h, RunUninstallationOptions as i, ValidationIssue as it, FailedInstallationState as j, StepSucceededEvent as k, runUninstallation as l, isLeafStep as lt, StepValidationResult as m, CreateInitialUninstallationStateOptions as n, ValidationContext as nt, createInitialInstallationState as o, defineBranchStep as ot, defineCustomInstallationStep as p, ExecutionContext as q, RunInstallationOptions as r, ValidationExecutionContext as rt, createInitialUninstallationState as s, defineLeafStep as st, CreateInitialInstallationStateOptions as t, StepMetaInfo as tt, runValidation as u, validateStepTree as v, executeWorkflow as w, createInitialState as x, CreateInitialStateOptions as y, SucceededInstallationState as z };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2026 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
|
|
16
|
+
import AioLogger from "@adobe/aio-lib-core-logging";
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
const require_chunk = require('./chunk-
|
|
15
|
+
const require_chunk = require('./chunk-Cozy-1ZF.cjs');
|
|
16
16
|
let util = require("util");
|
|
17
17
|
util = require_chunk.__toESM(util, 1);
|
|
18
18
|
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
16
|
-
const require_management = require('../management-
|
|
16
|
+
const require_management = require('../management-Dehz9qSJ.cjs');
|
|
17
17
|
|
|
18
18
|
exports.createInitialInstallationState = require_management.createInitialInstallationState;
|
|
19
19
|
exports.createInitialUninstallationState = require_management.createInitialUninstallationState;
|
|
@@ -12,6 +12,5 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import { _ as
|
|
16
|
-
|
|
17
|
-
export { AnyStep, BranchStep, BranchStepOptions, CreateInitialInstallationStateOptions, CreateInitialStateOptions, CreateInitialUninstallationStateOptions, CustomInstallationStepDefinition, CustomInstallationStepHandler, ExecuteWorkflowOptions, ExecutionContext, ExecutionStatus, FailedInstallationState, InProgressInstallationState, InferStepOutput, InstallationContext, InstallationData, InstallationError, InstallationHooks, InstallationRetryMetadata, InstallationState, InstallationStatus, LeafStep, LeafStepOptions, RunInstallationOptions, RunUninstallationOptions, RunValidationOptions, Step, StepContextFactory, StepEvent, StepFailedEvent, StepMeta, StepMetaInfo, StepStartedEvent, StepStatus, StepSucceededEvent, StepValidationResult, SucceededInstallationState, ValidateStepTreeOptions, ValidationContext, ValidationExecutionContext, ValidationIssue, ValidationIssueSeverity, ValidationResult, ValidationSummary, createInitialInstallationState, createInitialState, createInitialUninstallationState, createRetryState, defineBranchStep, defineCustomInstallationStep, defineLeafStep, executeUninstallWorkflow, executeWorkflow, isBranchStep, isCompletedState, isFailedState, isInProgressState, isLeafStep, isSucceededState, runInstallation, runUninstallation, runValidation, validateStepTree };
|
|
15
|
+
import { $ as StepContextFactory, A as ExecutionStatus, B as isCompletedState, C as executeUninstallWorkflow, D as StepFailedEvent, E as StepEvent, F as InstallationRetryMetadata, G as BranchStep, H as isInProgressState, I as InstallationState, J as InferStepOutput, K as BranchStepOptions, L as InstallationStatus, M as InProgressInstallationState, N as InstallationData, O as StepStartedEvent, P as InstallationError, Q as Step, R as StepStatus, S as createRetryState, T as InstallationHooks, U as isSucceededState, V as isFailedState, W as AnyStep, X as LeafStep, Y as InstallationContext, Z as LeafStepOptions, _ as ValidationSummary, a as RunValidationOptions, at as ValidationIssueSeverity, b as ExecuteWorkflowOptions, c as runInstallation, ct as isBranchStep, d as CustomInstallationStepDefinition, et as StepMeta, f as CustomInstallationStepHandler, g as ValidationResult, h as ValidateStepTreeOptions, i as RunUninstallationOptions, it as ValidationIssue, j as FailedInstallationState, k as StepSucceededEvent, l as runUninstallation, lt as isLeafStep, m as StepValidationResult, n as CreateInitialUninstallationStateOptions, nt as ValidationContext, o as createInitialInstallationState, ot as defineBranchStep, p as defineCustomInstallationStep, q as ExecutionContext, r as RunInstallationOptions, rt as ValidationExecutionContext, s as createInitialUninstallationState, st as defineLeafStep, t as CreateInitialInstallationStateOptions, tt as StepMetaInfo, u as runValidation, v as validateStepTree, w as executeWorkflow, x as createInitialState, y as CreateInitialStateOptions, z as SucceededInstallationState } from "../index-B5gJ-q4U.cjs";
|
|
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,19 +12,37 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
const require_chunk = require('./chunk-
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const require_logging = require('./logging-
|
|
15
|
+
const require_chunk = require('./chunk-Cozy-1ZF.cjs');
|
|
16
|
+
const require_error = require('./error-D-N0PKSl.cjs');
|
|
17
|
+
const require_webhooks = require('./webhooks-tbZy9G3p.cjs');
|
|
18
|
+
const require_logging = require('./logging-BVz3weoC.cjs');
|
|
19
|
+
let _adobe_aio_commerce_lib_core_error = require("@adobe/aio-commerce-lib-core/error");
|
|
20
|
+
let valibot = require("valibot");
|
|
21
|
+
valibot = require_chunk.__toESM(valibot, 1);
|
|
19
22
|
let _adobe_aio_commerce_lib_api_utils = require("@adobe/aio-commerce-lib-api/utils");
|
|
20
23
|
let camelcase = require("camelcase");
|
|
21
24
|
camelcase = require_chunk.__toESM(camelcase, 1);
|
|
25
|
+
let _adobe_aio_commerce_lib_admin_ui_api = require("@adobe/aio-commerce-lib-admin-ui/api");
|
|
22
26
|
let _adobe_aio_commerce_lib_api = require("@adobe/aio-commerce-lib-api");
|
|
23
27
|
let _adobe_aio_commerce_lib_auth = require("@adobe/aio-commerce-lib-auth");
|
|
24
28
|
let _adobe_aio_commerce_lib_events_commerce = require("@adobe/aio-commerce-lib-events/commerce");
|
|
25
29
|
let _adobe_aio_commerce_lib_events_io_events = require("@adobe/aio-commerce-lib-events/io-events");
|
|
26
30
|
let _adobe_aio_commerce_lib_webhooks_api = require("@adobe/aio-commerce-lib-webhooks/api");
|
|
27
31
|
|
|
32
|
+
//#region ../../packages-private/common-utils/source/valibot/utils.ts
|
|
33
|
+
/**
|
|
34
|
+
* Parses the input using the provided schema and throws a {@link CommerceSdkValidationError} error if the input is invalid.
|
|
35
|
+
* @param schema - The schema to use for parsing.
|
|
36
|
+
* @param input - The input to parse.
|
|
37
|
+
* @param message - Optional custom error message for the validation error.
|
|
38
|
+
*/
|
|
39
|
+
function parseOrThrow(schema, input, message) {
|
|
40
|
+
const result = valibot.safeParse(schema, input);
|
|
41
|
+
if (!result.success) throw new _adobe_aio_commerce_lib_core_error.CommerceSdkValidationError(message ?? "Invalid input", { issues: result.issues });
|
|
42
|
+
return result.output;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
28
46
|
//#region source/management/installation/workflow/hooks.ts
|
|
29
47
|
/** Helper to call a hook if it exists. */
|
|
30
48
|
async function callHook(hooks, hookName, ...args) {
|
|
@@ -455,11 +473,38 @@ function aggregateSummary(result) {
|
|
|
455
473
|
|
|
456
474
|
//#endregion
|
|
457
475
|
//#region source/management/installation/custom-installation/custom-scripts.ts
|
|
458
|
-
|
|
459
|
-
|
|
476
|
+
const camelcase$1 = camelcase.default.default ?? camelcase.default;
|
|
477
|
+
const ScriptModuleSchema = valibot.union([valibot.function(), valibot.object({
|
|
478
|
+
install: valibot.function(),
|
|
479
|
+
uninstall: valibot.optional(valibot.function())
|
|
480
|
+
})]);
|
|
481
|
+
/**
|
|
482
|
+
* Validates that a loaded script export can be executed as a custom installation step.
|
|
483
|
+
*
|
|
484
|
+
* @param module - The loaded script export to validate.
|
|
485
|
+
* @throws If the export is not a function or an object with an `install` function.
|
|
486
|
+
*/
|
|
487
|
+
function assertScriptModule(module) {
|
|
488
|
+
parseOrThrow(ScriptModuleSchema, module, "Invalid script module format. Expected a function or an object with an `install` method.");
|
|
460
489
|
}
|
|
461
|
-
|
|
462
|
-
|
|
490
|
+
/**
|
|
491
|
+
* Parses and validates a custom script module from the provided customScripts context.
|
|
492
|
+
* It supports both direct function exports and default exports.
|
|
493
|
+
*
|
|
494
|
+
* @param customScripts - The customScripts context containing the loaded modules
|
|
495
|
+
* @param script - The script path to resolve the module for
|
|
496
|
+
*/
|
|
497
|
+
function getScriptModule(customScripts, script) {
|
|
498
|
+
let scriptModule = customScripts[script];
|
|
499
|
+
if (!scriptModule) throw new Error(`Script ${script} not found in customScripts context. Make sure the script is defined in the configuration and the action was generated with custom scripts support.`);
|
|
500
|
+
if (typeof scriptModule === "object" && "default" in scriptModule) scriptModule = scriptModule.default;
|
|
501
|
+
assertScriptModule(scriptModule);
|
|
502
|
+
return scriptModule;
|
|
503
|
+
}
|
|
504
|
+
function resolveCustomScriptHandler(scriptModule, handler) {
|
|
505
|
+
if (typeof scriptModule === "function") return handler === "install" ? scriptModule : null;
|
|
506
|
+
if (handler in scriptModule && typeof scriptModule[handler] === "function") return scriptModule[handler];
|
|
507
|
+
return null;
|
|
463
508
|
}
|
|
464
509
|
/**
|
|
465
510
|
* Creates a leaf step for executing a single custom installation script.
|
|
@@ -467,7 +512,7 @@ function isCustomInstallationStepHandler(obj) {
|
|
|
467
512
|
function createCustomScriptStep(scriptConfig) {
|
|
468
513
|
const { script, name, description } = scriptConfig;
|
|
469
514
|
return defineLeafStep({
|
|
470
|
-
name:
|
|
515
|
+
name: camelcase$1(name),
|
|
471
516
|
meta: { install: {
|
|
472
517
|
label: name,
|
|
473
518
|
description
|
|
@@ -477,15 +522,7 @@ function createCustomScriptStep(scriptConfig) {
|
|
|
477
522
|
const customScripts = context.customScripts || {};
|
|
478
523
|
logger.info(`Executing custom installation script: ${name}`);
|
|
479
524
|
logger.debug(`Script path: ${script}`);
|
|
480
|
-
const
|
|
481
|
-
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.`);
|
|
482
|
-
if (typeof scriptModule !== "object" || !("default" in scriptModule)) throw new Error(`Script ${script} must export a default function or object. Use defineCustomInstallationStep helper.`);
|
|
483
|
-
const defaultExport = scriptModule.default;
|
|
484
|
-
let runFunction = null;
|
|
485
|
-
if (isCustomInstallationStepHandler(defaultExport)) runFunction = defaultExport;
|
|
486
|
-
else if (isCustomInstallationStepDefinition(defaultExport)) runFunction = defaultExport.install;
|
|
487
|
-
if (runFunction === null) throw new Error(`Script ${script} default export must be a function or an object with an install method. Use defineCustomInstallationStep helper.`);
|
|
488
|
-
const scriptResult = await runFunction(config, context);
|
|
525
|
+
const scriptResult = await resolveCustomScriptHandler(getScriptModule(customScripts, script), "install")(config, context);
|
|
489
526
|
logger.info(`Successfully executed script: ${name}`);
|
|
490
527
|
return {
|
|
491
528
|
script,
|
|
@@ -496,14 +533,7 @@ function createCustomScriptStep(scriptConfig) {
|
|
|
496
533
|
const { logger } = context;
|
|
497
534
|
const customScripts = context.customScripts || {};
|
|
498
535
|
logger.debug(`Uninstalling custom script: ${name}`);
|
|
499
|
-
const
|
|
500
|
-
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.`);
|
|
501
|
-
const defaultExport = scriptModule.default;
|
|
502
|
-
if (!isCustomInstallationStepDefinition(defaultExport)) {
|
|
503
|
-
logger.debug(`Script ${script} does not export an uninstall function, skipping uninstall.`);
|
|
504
|
-
return;
|
|
505
|
-
}
|
|
506
|
-
const { uninstall } = defaultExport;
|
|
536
|
+
const uninstall = resolveCustomScriptHandler(getScriptModule(customScripts, script), "uninstall");
|
|
507
537
|
if (!uninstall) {
|
|
508
538
|
logger.debug(`Script ${script} does not export an uninstall function, skipping uninstall.`);
|
|
509
539
|
return;
|
|
@@ -610,34 +640,40 @@ async function throwHttpError(logger, error, prefix) {
|
|
|
610
640
|
/**
|
|
611
641
|
* Registers the extension with Commerce via POST /V1/adminuisdk/extension.
|
|
612
642
|
*
|
|
613
|
-
* @param context - The execution context providing the
|
|
614
|
-
* @returns The response from the Commerce API.
|
|
643
|
+
* @param context - The execution context providing the Admin UI SDK client and logger.
|
|
615
644
|
*/
|
|
616
645
|
async function registerExtension(context) {
|
|
617
|
-
const {
|
|
646
|
+
const { adminUiClient, appData, logger } = context;
|
|
647
|
+
const extensionName = process.env.__OW_NAMESPACE;
|
|
648
|
+
if (!extensionName) throw new Error("__OW_NAMESPACE environment variable is not set");
|
|
618
649
|
logger.info(`Registering Admin UI SDK extension: ${appData.projectName}`);
|
|
619
|
-
const
|
|
620
|
-
extensionName
|
|
650
|
+
const { extensionId } = await adminUiClient.registerExtension({
|
|
651
|
+
extensionName,
|
|
621
652
|
extensionTitle: appData.projectTitle,
|
|
622
|
-
extensionUrl: `https://${
|
|
653
|
+
extensionUrl: `https://${extensionName}.adobeio-static.net/index.html`,
|
|
623
654
|
extensionWorkspace: appData.workspaceName
|
|
624
|
-
}
|
|
625
|
-
logger.info(`Admin UI SDK extension registered successfully: ${
|
|
626
|
-
return response;
|
|
655
|
+
}).catch((error) => throwHttpError(logger, error, "Failed to register Admin UI SDK extension"));
|
|
656
|
+
logger.info(`Admin UI SDK extension registered successfully: ${extensionId}`);
|
|
627
657
|
}
|
|
628
658
|
/**
|
|
629
659
|
* Unregisters the extension from Commerce via DELETE /V1/adminuisdk/extension/:workspace_name/:extension_name.
|
|
630
660
|
* Best-effort: errors are logged as warnings and do not stop the uninstall workflow.
|
|
631
661
|
*
|
|
632
|
-
* @param context - The execution context providing the
|
|
662
|
+
* @param context - The execution context providing the Admin UI SDK client and logger.
|
|
633
663
|
*/
|
|
634
|
-
async function
|
|
635
|
-
const {
|
|
664
|
+
async function unregisterExtension(context) {
|
|
665
|
+
const { adminUiClient, appData, logger } = context;
|
|
636
666
|
const extensionName = process.env.__OW_NAMESPACE;
|
|
637
|
-
|
|
667
|
+
if (!extensionName) {
|
|
668
|
+
logger.warn("__OW_NAMESPACE environment variable is not set; skipping Admin UI SDK extension unregistration. Continuing uninstall.");
|
|
669
|
+
return;
|
|
670
|
+
}
|
|
638
671
|
logger.info(`Unregistering Admin UI SDK extension "${extensionName}" from workspace "${appData.workspaceName}"...`);
|
|
639
672
|
try {
|
|
640
|
-
await
|
|
673
|
+
await adminUiClient.unregisterExtension({
|
|
674
|
+
workspaceName: appData.workspaceName,
|
|
675
|
+
extensionName
|
|
676
|
+
});
|
|
641
677
|
logger.info(`Admin UI SDK extension "${extensionName}" unregistered successfully.`);
|
|
642
678
|
} catch (error) {
|
|
643
679
|
const msg = await (0, _adobe_aio_commerce_lib_api_utils.unwrapHttpError)(error);
|
|
@@ -647,19 +683,22 @@ async function uninstallExtension(context) {
|
|
|
647
683
|
|
|
648
684
|
//#endregion
|
|
649
685
|
//#region source/management/installation/admin-ui-sdk/utils.ts
|
|
650
|
-
|
|
686
|
+
function createAdminUiClient(params) {
|
|
687
|
+
return (0, _adobe_aio_commerce_lib_admin_ui_api.createAdminUiApiClient)((0, _adobe_aio_commerce_lib_api.resolveCommerceHttpClientParams)(params, { tryForwardAuthProvider: true }));
|
|
688
|
+
}
|
|
689
|
+
/** Creates the Admin UI SDK step context with a lazy-initialized API client. */
|
|
651
690
|
const createAdminUiSdkStepContext = (installation) => {
|
|
652
691
|
const { params } = installation;
|
|
653
|
-
let
|
|
654
|
-
return { get
|
|
655
|
-
if (
|
|
656
|
-
return
|
|
692
|
+
let adminUiClient = null;
|
|
693
|
+
return { get adminUiClient() {
|
|
694
|
+
if (adminUiClient === null) adminUiClient = createAdminUiClient(params);
|
|
695
|
+
return adminUiClient;
|
|
657
696
|
} };
|
|
658
697
|
};
|
|
659
698
|
|
|
660
699
|
//#endregion
|
|
661
700
|
//#region source/management/installation/admin-ui-sdk/branch.ts
|
|
662
|
-
/** Leaf step that
|
|
701
|
+
/** Leaf step that registers the extension (POST) on install and unregisters it (DELETE) on uninstall. */
|
|
663
702
|
const registerExtensionStep = defineLeafStep({
|
|
664
703
|
name: "register-extension",
|
|
665
704
|
meta: {
|
|
@@ -673,7 +712,7 @@ const registerExtensionStep = defineLeafStep({
|
|
|
673
712
|
}
|
|
674
713
|
},
|
|
675
714
|
install: (_, context) => registerExtension(context),
|
|
676
|
-
uninstall: (_, context) =>
|
|
715
|
+
uninstall: (_, context) => unregisterExtension(context)
|
|
677
716
|
});
|
|
678
717
|
/** Branch step for setting up the Admin UI SDK extension registration. */
|
|
679
718
|
const adminUiSdkStep = defineBranchStep({
|
|
@@ -768,15 +807,37 @@ function getNamespacedEvent(metadata, name) {
|
|
|
768
807
|
function getIoEventCode(name, providerType) {
|
|
769
808
|
return providerType === "dx_commerce_events" ? `com.adobe.commerce.${name}` : name;
|
|
770
809
|
}
|
|
810
|
+
/** Maps a provider's metadata type to its human-readable label ("Commerce" or "External"). */
|
|
811
|
+
function getProviderTypeLabel(provider) {
|
|
812
|
+
return PROVIDER_TYPE_TO_LABEL[provider.provider_metadata];
|
|
813
|
+
}
|
|
771
814
|
/**
|
|
772
|
-
* Generates a registration name
|
|
815
|
+
* Generates a registration name based on the provider type, provider label, and runtime action.
|
|
816
|
+
*
|
|
817
|
+
* Prefixes with the provider type label ("Commerce" or "External") for readability, then the
|
|
818
|
+
* provider's own label to ensure uniqueness when multiple providers of the same type route
|
|
819
|
+
* events to the same runtime action.
|
|
820
|
+
*
|
|
773
821
|
* @param provider - The provider this registration is associated to.
|
|
774
822
|
* @param runtimeAction - The runtime action this registration points to.
|
|
775
823
|
*/
|
|
776
824
|
function getRegistrationName(provider, runtimeAction) {
|
|
777
|
-
const providerLabel = PROVIDER_TYPE_TO_LABEL[provider.provider_metadata];
|
|
778
825
|
const [packageName, actionName] = runtimeAction.split("/").map(kebabToTitleCase);
|
|
779
|
-
return `${
|
|
826
|
+
return `${getProviderTypeLabel(provider)} Event Registration: ${provider.label} - ${actionName} (${packageName})`;
|
|
827
|
+
}
|
|
828
|
+
/**
|
|
829
|
+
* Returns the registration name in the legacy format used by SDK versions that built
|
|
830
|
+
* the name from the generic provider type label ("Commerce" / "External") rather than
|
|
831
|
+
* the provider's own label. Used during uninstall to match registrations that were
|
|
832
|
+
* created before the naming change.
|
|
833
|
+
*
|
|
834
|
+
* @param provider - The provider this registration is associated to.
|
|
835
|
+
* @param runtimeAction - The runtime action this registration points to.
|
|
836
|
+
* @deprecated Use {@link getRegistrationName} for all new registrations.
|
|
837
|
+
*/
|
|
838
|
+
function getLegacyRegistrationName(provider, runtimeAction) {
|
|
839
|
+
const [packageName, actionName] = runtimeAction.split("/").map(kebabToTitleCase);
|
|
840
|
+
return `${getProviderTypeLabel(provider)} Event Registration: ${actionName} (${packageName})`;
|
|
780
841
|
}
|
|
781
842
|
/**
|
|
782
843
|
* Generates a registration name and description based on the provider, events, and runtime action.
|
|
@@ -1151,6 +1212,7 @@ async function createCommerceEventSubscription(params) {
|
|
|
1151
1212
|
name: eventName,
|
|
1152
1213
|
parent: event.config.name,
|
|
1153
1214
|
fields: event.config.fields,
|
|
1215
|
+
rules: event.config.rules,
|
|
1154
1216
|
provider_id: provider.id,
|
|
1155
1217
|
destination: event.config.destination,
|
|
1156
1218
|
hipaa_audit_required: event.config.hipaa_audit_required,
|
|
@@ -1275,7 +1337,8 @@ async function deleteIoEventRegistrations(providerData, provider, events, regist
|
|
|
1275
1337
|
workspaceId: appData.workspaceId
|
|
1276
1338
|
};
|
|
1277
1339
|
const actionEventsMap = groupEventsByRuntimeActions(events);
|
|
1278
|
-
const
|
|
1340
|
+
const runtimeActions = Array.from(actionEventsMap.keys());
|
|
1341
|
+
const registrationNames = new Set([...runtimeActions.map((runtimeAction) => getRegistrationName(providerData, runtimeAction)), ...runtimeActions.map((runtimeAction) => getLegacyRegistrationName(providerData, runtimeAction))]);
|
|
1279
1342
|
const providerRegistrations = registrations.filter((reg) => reg.client_id === runtimeParams.AIO_COMMERCE_AUTH_IMS_CLIENT_ID && registrationNames.has(reg.name));
|
|
1280
1343
|
if (providerRegistrations.length === 0) {
|
|
1281
1344
|
logger.info(`No I/O Events registrations found for provider "${provider.label}" (instance ID: "${providerData.instance_id}").`);
|