@adobe/aio-commerce-lib-app 1.6.0 → 1.8.0-beta-20260714082406

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/CHANGELOG.md +106 -0
  2. package/dist/cjs/actions/app-config/index.cjs +205 -0
  3. package/dist/cjs/actions/{app-config.d.cts → app-config/index.d.cts} +10 -7
  4. package/dist/cjs/actions/association/index.cjs +85 -0
  5. package/dist/cjs/actions/association/index.d.cts +28 -0
  6. package/dist/cjs/actions/{config.cjs → config/index.cjs} +70 -53
  7. package/dist/{es/actions/config.d.mts → cjs/actions/config/index.d.cts} +10 -7
  8. package/dist/cjs/actions/{installation.cjs → installation/index.cjs} +106 -72
  9. package/dist/{es/actions/installation.d.mts → cjs/actions/installation/index.d.cts} +10 -8
  10. package/dist/cjs/actions/{scope-tree.cjs → scope-tree/index.cjs} +60 -22
  11. package/dist/cjs/actions/{scope-tree.d.cts → scope-tree/index.d.cts} +1 -1
  12. package/dist/cjs/app-D3P-Z6uY.d.cts +1679 -0
  13. package/dist/cjs/association-repository-BAs3-VkW.cjs +69 -0
  14. package/dist/cjs/commands/index.cjs +517 -309
  15. package/dist/cjs/commands/templates/admin-ui/tsconfig.json +14 -0
  16. package/dist/cjs/commands/templates/admin-ui/web-src/index.css +5 -0
  17. package/dist/cjs/commands/templates/admin-ui/web-src/index.html +17 -0
  18. package/dist/cjs/commands/templates/admin-ui/web-src/src/app.jsx +13 -0
  19. package/dist/cjs/commands/templates/admin-ui/web-src/src/components/welcome.jsx +12 -0
  20. package/dist/cjs/commands/templates/admin-ui/web-src/src/pages/main-page.jsx +10 -0
  21. package/dist/cjs/commands/templates/{admin-ui-sdk/registration.js.template → admin-ui/web-src-template.d.ts} +11 -6
  22. package/dist/cjs/commands/templates/app-management/app-config.js.template +1 -14
  23. package/dist/cjs/commands/templates/app-management/association.js.template +6 -0
  24. package/dist/cjs/commands/templates/app-management/installation.js.template +1 -13
  25. package/dist/cjs/commands/templates/business-configuration/config.js.template +2 -15
  26. package/dist/cjs/commands/templates/business-configuration/scope-tree.js.template +0 -12
  27. package/dist/cjs/config/index.browser.cjs +18 -0
  28. package/dist/cjs/config/index.browser.d.cts +16 -0
  29. package/dist/cjs/config/{index.cjs → index.node.cjs} +9 -8
  30. package/dist/cjs/config/index.node.d.cts +1603 -0
  31. package/dist/cjs/define-DBxAlJfN.d.cts +34 -0
  32. package/dist/cjs/define-hlcQw7Cv.cjs +41 -0
  33. package/dist/cjs/environment-B7EnozSg.cjs +135 -0
  34. package/dist/cjs/index-BXm8UbK7.d.cts +16 -0
  35. package/dist/cjs/{index-Dw2NvVOY.d.cts → index-CzReNwbF.d.cts} +177 -3
  36. package/dist/cjs/index.cjs +250 -0
  37. package/dist/cjs/index.d.cts +217 -0
  38. package/dist/cjs/{config-FNMclIFO.cjs → index.node-Dz4lV4qe.cjs} +119 -35
  39. package/dist/cjs/{logging-BVz3weoC.cjs → logging-udPuAJPt.cjs} +2 -2
  40. package/dist/cjs/management/index.cjs +1 -1
  41. package/dist/cjs/management/index.d.cts +1 -2
  42. package/dist/cjs/{management-Cvsz4VMf.cjs → management-B9ItB80R.cjs} +432 -591
  43. package/dist/cjs/openapi-CwytYdWl.cjs +2948 -0
  44. package/dist/cjs/{router-BOR7T6qR.cjs → router-hA_Y9gZ1.cjs} +42 -44
  45. package/dist/cjs/{schemas-FngDuIeo.cjs → schemas-mLxMh_ko.cjs} +2 -2
  46. package/dist/cjs/utils-DSCmZ_iJ.cjs +408 -0
  47. package/dist/cjs/{validate-DydOAZha.cjs → validate-BfxhZ5Wv.cjs} +63 -31
  48. package/dist/cjs/{webhooks-tbZy9G3p.cjs → webhooks-B5tb9NeF.cjs} +159 -151
  49. package/dist/es/actions/{app-config.d.mts → app-config/index.d.mts} +10 -7
  50. package/dist/es/actions/app-config/index.mjs +202 -0
  51. package/dist/es/actions/association/index.d.mts +28 -0
  52. package/dist/es/actions/association/index.mjs +82 -0
  53. package/dist/{cjs/actions/config.d.cts → es/actions/config/index.d.mts} +10 -7
  54. package/dist/es/actions/{config.mjs → config/index.mjs} +67 -50
  55. package/dist/{cjs/actions/installation.d.cts → es/actions/installation/index.d.mts} +10 -8
  56. package/dist/es/actions/{installation.mjs → installation/index.mjs} +104 -71
  57. package/dist/es/actions/{scope-tree.d.mts → scope-tree/index.d.mts} +1 -1
  58. package/dist/es/actions/{scope-tree.mjs → scope-tree/index.mjs} +58 -20
  59. package/dist/es/app-D3P-Z6uY.d.mts +1679 -0
  60. package/dist/es/association-repository-BbQv9WCl.mjs +52 -0
  61. package/dist/es/commands/index.mjs +550 -340
  62. package/dist/es/commands/templates/admin-ui/tsconfig.json +14 -0
  63. package/dist/es/commands/templates/admin-ui/web-src/index.css +5 -0
  64. package/dist/es/commands/templates/admin-ui/web-src/index.html +17 -0
  65. package/dist/es/commands/templates/admin-ui/web-src/src/app.jsx +13 -0
  66. package/dist/es/commands/templates/admin-ui/web-src/src/components/welcome.jsx +12 -0
  67. package/dist/es/commands/templates/admin-ui/web-src/src/pages/main-page.jsx +10 -0
  68. package/dist/es/commands/templates/{admin-ui-sdk/registration.js.template → admin-ui/web-src-template.d.ts} +11 -6
  69. package/dist/es/commands/templates/app-management/app-config.js.template +1 -14
  70. package/dist/es/commands/templates/app-management/association.js.template +6 -0
  71. package/dist/es/commands/templates/app-management/installation.js.template +1 -13
  72. package/dist/es/commands/templates/business-configuration/config.js.template +2 -15
  73. package/dist/es/commands/templates/business-configuration/scope-tree.js.template +0 -12
  74. package/dist/es/config/index.browser.d.mts +16 -0
  75. package/dist/es/config/index.browser.mjs +17 -0
  76. package/dist/es/config/index.node.d.mts +1604 -0
  77. package/dist/es/config/index.node.mjs +20 -0
  78. package/dist/es/define-EoYRZbpe.d.mts +34 -0
  79. package/dist/es/define-Z_Glf1-_.mjs +35 -0
  80. package/dist/es/environment-C84BPRJZ.mjs +104 -0
  81. package/dist/es/index-B0XqHwY5.d.mts +16 -0
  82. package/dist/es/{index-Bo0tQsVq.d.mts → index-D52xglhZ.d.mts} +177 -3
  83. package/dist/es/index.d.mts +217 -0
  84. package/dist/es/index.mjs +242 -0
  85. package/dist/es/{config-CcE0EBG7.mjs → index.node-CDH5gwJE.mjs} +94 -30
  86. package/dist/es/management/index.d.mts +1 -2
  87. package/dist/es/management/index.mjs +1 -1
  88. package/dist/es/{management-BZ4Y6lVp.mjs → management-B89ApQVY.mjs} +402 -562
  89. package/dist/es/openapi-CXonvevE.mjs +2900 -0
  90. package/dist/es/{router-D58JJHHA.mjs → router-B_h0cvjc.mjs} +40 -42
  91. package/dist/es/utils-_gj8L6eN.mjs +289 -0
  92. package/dist/es/{validate-Du3LhCre.mjs → validate-9cRZWGrA.mjs} +49 -29
  93. package/dist/es/{webhooks-B5oq9ULL.mjs → webhooks-BBPbY2mb.mjs} +150 -142
  94. package/package.json +52 -22
  95. package/dist/cjs/actions/app-config.cjs +0 -54
  96. package/dist/cjs/actions/registration.cjs +0 -40
  97. package/dist/cjs/actions/registration.d.cts +0 -32
  98. package/dist/cjs/admin-ui-sdk-DZZJCrdT.d.cts +0 -665
  99. package/dist/cjs/app-CakwxQvs.d.cts +0 -673
  100. package/dist/cjs/config/index.d.cts +0 -1975
  101. package/dist/cjs/step-CKVE0aJi.d.cts +0 -187
  102. package/dist/es/actions/app-config.mjs +0 -53
  103. package/dist/es/actions/registration.d.mts +0 -32
  104. package/dist/es/actions/registration.mjs +0 -39
  105. package/dist/es/admin-ui-sdk-hu6iWr0A.d.mts +0 -667
  106. package/dist/es/app-CakwxQvs.d.mts +0 -673
  107. package/dist/es/config/index.d.mts +0 -1975
  108. package/dist/es/config/index.mjs +0 -19
  109. package/dist/es/step-D64mMPrt.d.mts +0 -187
  110. /package/dist/cjs/{chunk-Cozy-1ZF.cjs → rolldown-runtime-Cozy-1ZF.cjs} +0 -0
@@ -13,25 +13,24 @@
13
13
  * governing permissions and limitations under the License.
14
14
  */
15
15
 
16
- import { a as hasCustomInstallationSteps, d as hasAdminUiSdk } from "../webhooks-B5oq9ULL.mjs";
17
- import { c as hasBusinessConfigSchema, i as getConfigDomains, t as validateCommerceAppConfig } from "../validate-Du3LhCre.mjs";
18
- import { t as inspect } from "../logging-DbJHXSKh.mjs";
19
16
  import { t as stringifyError } from "../error-_RMwtrUA.mjs";
20
- import { a as getExecCommand, c as isESM, i as detectPackageManager, l as makeOutputDirFor, n as readCommerceAppConfig, o as getInstallCommand, r as resolveCommerceAppConfig, s as getProjectRootDirectory, t as parseCommerceAppConfig, u as readPackageJson } from "../config-CcE0EBG7.mjs";
21
- import { hasDynamicSchema } from "@adobe/aio-commerce-lib-config";
17
+ import { a as getExecCommand, c as getProjectInstallCommand, d as loadPackageJson, f as makeOutputDirFor, i as detectPackageManager, l as getProjectRootDirectory, m as readPackageJson, n as readCommerceAppConfig, o as getInstallCommand, p as mergePackageJsonDependencies, r as resolveCommerceAppConfig, s as getPackageDependencyInstallPlan, t as parseCommerceAppConfig, u as isESM } from "../index.node-CDH5gwJE.mjs";
18
+ import { a as hasCustomInstallationSteps, d as hasAdminUi } from "../webhooks-BBPbY2mb.mjs";
19
+ import { o as getConfigDomains, r as requiresInstallation, t as validateCommerceAppConfig, u as hasBusinessConfigSchema } from "../validate-9cRZWGrA.mjs";
20
+ import { t as inspect } from "../logging-DbJHXSKh.mjs";
22
21
  import { CommerceSdkValidationError } from "@adobe/aio-commerce-lib-core/error";
23
- import consola, { consola as consola$1 } from "consola";
22
+ import { hasDynamicSchema } from "@adobe/aio-commerce-lib-config";
24
23
  import path, { basename, dirname, extname, join, relative, resolve, sep } from "path";
25
- import * as prettier from "prettier";
26
24
  import { existsSync, readFileSync, writeFileSync } from "fs";
27
- import { access, readFile, rm, writeFile } from "fs/promises";
25
+ import { access, mkdir, readFile, readdir, rm, writeFile } from "fs/promises";
26
+ import consola$1, { consola } from "consola";
27
+ import { execSync, spawnSync } from "child_process";
28
+ import * as prettier from "prettier";
28
29
  import { fileURLToPath } from "url";
29
30
  import { Document, YAMLMap, YAMLSeq, isMap, isPair, isSeq, parseDocument } from "yaml";
30
- import NpmPackageJson from "@npmcli/package-json";
31
31
  import { colorize, formatTree } from "consola/utils";
32
32
  import { build } from "esbuild";
33
- import stringify, { stringify as stringify$1 } from "safe-stable-stringify";
34
- import { execSync, spawnSync } from "child_process";
33
+ import { stringify } from "safe-stable-stringify";
35
34
  import config from "@adobe/aio-lib-core-config";
36
35
  import aioIms from "@adobe/aio-lib-ims";
37
36
  import dotenv from "dotenv";
@@ -49,12 +48,8 @@ const GENERATED_ACTIONS_PATH = `${GENERATED_PATH}/${ACTIONS_FOLDER}`;
49
48
  const EXTENSIBILITY_EXTENSION_POINT_ID = "commerce/extensibility/1";
50
49
  /** The name of the extension point for configuration. */
51
50
  const CONFIGURATION_EXTENSION_POINT_ID = "commerce/configuration/1";
52
- /** The name of the extension point for Admin UI SDK. */
53
- const BACKEND_UI_EXTENSION_POINT_ID = "commerce/backend-ui/1";
54
- /** The name of the package containing the admin UI SDK generated actions */
55
- const ADMIN_UI_SDK_PACKAGE_NAME = "admin-ui-sdk";
56
- /** The path to the directory containing the generated Admin UI SDK actions. */
57
- const ADMIN_UI_SDK_ACTIONS_PATH = `${GENERATED_PATH}/actions/registration`;
51
+ /** The name of the extension point for Admin UI. */
52
+ const BACKEND_UI_V2_EXTENSION_POINT_ID = "commerce/backend-ui/2";
58
53
  /** The name of the configuration schema file */
59
54
  const APP_MANIFEST_FILE = "app.commerce.manifest.json";
60
55
  /** The name of the generated runtime-safe app config module (dynamic schemas only). */
@@ -81,25 +76,63 @@ function getExtensionPointFolderPath(extensionPointId) {
81
76
  /** Format file content using prettier, inferring the parser from the file path. */
82
77
  function prettierFormat(content, filepath) {
83
78
  return prettier.format(content, {
84
- semi: true,
85
- quoteStyle: "double",
86
79
  arrowParens: "always",
87
80
  bracketSameLine: true,
88
81
  bracketSpacing: true,
89
- trailingComma: "all",
90
- tabWidth: 2,
91
- useTabs: false,
82
+ filepath,
92
83
  printWidth: 80,
93
- filepath
84
+ quoteStyle: "double",
85
+ semi: true,
86
+ tabWidth: 2,
87
+ trailingComma: "all",
88
+ useTabs: false
94
89
  });
95
90
  }
96
91
  /** Load the app commerce config */
97
92
  async function loadAppManifest() {
98
93
  const appConfig = await parseCommerceAppConfig();
99
- consola.debug("Loaded app commerce config");
94
+ consola$1.debug("Loaded app commerce config");
100
95
  return appConfig;
101
96
  }
102
97
  /**
98
+ * Install the given dependencies.
99
+ * @param packageManager - The detected package manager.
100
+ * @param dependencies - Package specifiers to install; no-op when empty.
101
+ * @param cwd - Working directory for the install command.
102
+ * @param options - Install command options.
103
+ */
104
+ function runInstall(packageManager, dependencies, cwd = process.cwd(), options = {}) {
105
+ if (dependencies.length === 0) return;
106
+ const dependencyListString = dependencies.map((dependency) => ` - ${dependency}`).join("\n");
107
+ consola$1.start([`Installing the following dependencies with ${packageManager}:\n${dependencyListString}\n`, "This may take a few seconds...\n"].join("\n"));
108
+ const { command, args } = getInstallCommand(packageManager, dependencies, options);
109
+ const displayCommand = [command, ...args].join(" ");
110
+ const result = spawnSync(command, args, {
111
+ cwd,
112
+ stdio: "inherit"
113
+ });
114
+ if (result.error || result.status !== 0) throw new Error(`Failed to install dependencies automatically. Please install manually: ${displayCommand}`, { cause: result.error ?? /* @__PURE__ */ new Error(`Install exited with code ${result.status}`) });
115
+ consola$1.log("");
116
+ consola$1.success("Dependencies installed successfully");
117
+ }
118
+ /**
119
+ * Install dependencies declared in package.json.
120
+ * @param packageManager - The detected package manager.
121
+ * @param cwd - Working directory for the install command.
122
+ */
123
+ function runProjectInstall(packageManager, cwd = process.cwd()) {
124
+ consola$1.start([`Installing project dependencies with ${packageManager}...`, "This may take a few seconds...\n"].join("\n"));
125
+ const { command, args } = getProjectInstallCommand(packageManager);
126
+ const displayCommand = [command, ...args].join(" ");
127
+ const result = spawnSync(command, args, {
128
+ cwd,
129
+ stdio: "inherit"
130
+ });
131
+ if (result.error || result.status !== 0) throw new Error(`Failed to install dependencies automatically. Please install manually: ${displayCommand}`, { cause: result.error ?? /* @__PURE__ */ new Error(`Install exited with code ${result.status}`) });
132
+ consola$1.log("");
133
+ consola$1.success("Dependencies installed successfully");
134
+ }
135
+ /**
103
136
  * Whether the app config contains anything that can't be JSON-serialized as-is
104
137
  * and therefore requires generating a runtime-safe ESM config module.
105
138
  */
@@ -136,20 +169,6 @@ function getActionPath(extensionPointId, actionName) {
136
169
  function getExtConfigPath(extensionPointId) {
137
170
  return join(getExtensionPointFolderPath(extensionPointId), "ext.config.yaml");
138
171
  }
139
- /**
140
- * Path to an Admin UI SDK generated actions directory, relative to the project root.
141
- * @param extensionPointId - The extension point ID, e.g. "commerce/backend-ui/1"
142
- */
143
- function getAdminUiSdkActionsDir(extensionPointId) {
144
- return join(getExtensionPointFolderPath(extensionPointId), ADMIN_UI_SDK_ACTIONS_PATH);
145
- }
146
- /**
147
- * Path to the generated Admin UI SDK registration action file, relative to the project root.
148
- * @param extensionPointId - The extension point ID, e.g. "commerce/backend-ui/1"
149
- */
150
- function getAdminUiSdkRegistrationActionPath(extensionPointId) {
151
- return join(getAdminUiSdkActionsDir(extensionPointId), "index.js");
152
- }
153
172
  /** Path to the generated app manifest JSON file, relative to the project root. */
154
173
  function getManifestPath() {
155
174
  return join(getGeneratedDir(EXTENSIBILITY_EXTENSION_POINT_ID), APP_MANIFEST_FILE);
@@ -167,8 +186,11 @@ function getSchemaPath() {
167
186
  }
168
187
 
169
188
  //#endregion
170
- //#region source/commands/generate/actions/config.ts
171
- /** The list of Commerce variables that are required for the runtime actions */
189
+ //#region source/commands/generate/actions/constants.ts
190
+ const __dirname = dirname(fileURLToPath(import.meta.url));
191
+ /** The path to the action templates directory, sibling to this file. */
192
+ const TEMPLATES_DIR = join(__dirname, "templates");
193
+ /** The list of Commerce variables that are required for the runtime actions. */
172
194
  const COMMERCE_VARIABLES = [
173
195
  "AIO_COMMERCE_AUTH_IMS_CLIENT_ID",
174
196
  "AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS",
@@ -177,27 +199,104 @@ const COMMERCE_VARIABLES = [
177
199
  "AIO_COMMERCE_AUTH_IMS_ORG_ID",
178
200
  "AIO_COMMERCE_AUTH_IMS_SCOPES"
179
201
  ];
180
- /** The inputs for the generated runtime actions */
202
+ /** The inputs for the generated runtime actions. */
181
203
  const COMMERCE_ACTION_INPUTS = Object.fromEntries(COMMERCE_VARIABLES.map((variable) => [variable, `$${variable}`]));
182
204
  const CUSTOM_IMPORTS_PLACEHOLDER = "// {{CUSTOM_SCRIPTS_IMPORTS}}";
183
205
  const CUSTOM_SCRIPTS_MAP_PLACEHOLDER = "// {{CUSTOM_SCRIPTS_MAP}}";
184
206
  const CUSTOM_SCRIPTS_LOADER_PLACEHOLDER = "// {{CUSTOM_SCRIPTS_LOADER}}";
185
- const REGISTRATION_JSON_PLACEHOLDER = "// {{REGISTRATION_JSON}}";
207
+ /** File extensions that require bundling or TypeScript web-src templates. */
208
+ const TYPESCRIPT_CONFIG_EXTENSIONS = /* @__PURE__ */ new Set([
209
+ ".ts",
210
+ ".mts",
211
+ ".cts"
212
+ ]);
213
+ const JSX_FILE_EXTENSION = ".jsx";
214
+ const TSX_FILE_EXTENSION = ".tsx";
215
+ const APP_TITLE_PLACEHOLDER = "APP_TITLE";
216
+ const WEB_SOURCE_ENTRYPOINT_FILE = "index.html";
217
+ const WEB_SOURCE_IMPORT_ALIAS = "#web/*";
218
+ /** Runtime dependencies required by the generated web-src app. */
219
+ const WEB_SOURCE_DEPENDENCIES = [
220
+ {
221
+ name: "@adobe/aio-commerce-lib-admin-ui",
222
+ version: "^0.2.0-beta-20260714082406"
223
+ },
224
+ {
225
+ name: "react",
226
+ version: "^19.2.7"
227
+ },
228
+ {
229
+ name: "react-dom",
230
+ version: "^19.2.7"
231
+ },
232
+ {
233
+ name: "@react-spectrum/s2",
234
+ version: "^1.5.1"
235
+ }
236
+ ];
237
+ /** Development dependencies required by the generated web-src app. */
238
+ const WEB_SOURCE_DEV_DEPENDENCIES = [{
239
+ name: "@types/react",
240
+ version: "^19.2.17"
241
+ }, {
242
+ name: "@types/react-dom",
243
+ version: "^19.2.3"
244
+ }];
245
+ /** Development dependencies required only by TypeScript web-src scaffolds. */
246
+ const WEB_SOURCE_TS_DEV_DEPENDENCIES = [{
247
+ name: "@tsconfig/bases",
248
+ version: "latest"
249
+ }, {
250
+ name: "typescript",
251
+ version: "latest"
252
+ }];
253
+ /** tsconfig.json generated for TypeScript web-src scaffolds. */
254
+ const WEB_SOURCE_TSCONFIG_FILE = "tsconfig.json";
255
+ const WEB_SOURCE_TSCONFIG = {
256
+ compilerOptions: {
257
+ allowImportingTsExtensions: true,
258
+ allowJs: true,
259
+ checkJs: true,
260
+ jsx: "react-jsx",
261
+ jsxImportSource: "react",
262
+ module: "esnext",
263
+ moduleResolution: "bundler",
264
+ noEmit: true,
265
+ rewriteRelativeImportExtensions: false
266
+ },
267
+ extends: ["@tsconfig/bases/recommended"],
268
+ include: [
269
+ "src/**/*.js",
270
+ "src/**/*.ts",
271
+ "src/**/*.tsx",
272
+ "src/**/*.jsx"
273
+ ]
274
+ };
275
+ /** Parcel shared bundle config required by Spectrum S2 styles. */
276
+ const WEB_SOURCE_SHARED_BUNDLES = [{
277
+ assets: ["**/@react-spectrum/s2/**", "src/commerce-backend-ui-2/web-src/*.{js,jsx,ts,tsx}"],
278
+ name: "s2-styles",
279
+ types: ["css"]
280
+ }];
281
+
282
+ //#endregion
283
+ //#region source/commands/generate/actions/config.ts
186
284
  /**
187
285
  * Creates a runtime action configuration.
188
286
  * @param actionName - The name of the action.
287
+ * @param config - Action generation options.
189
288
  * @param options - Optional configuration options.
190
289
  */
191
290
  function createActionDefinition(actionName, config = {}, options = {}) {
192
291
  const def = {
193
292
  ...options,
194
- function: `${GENERATED_ACTIONS_PATH}/${actionName}.js`,
195
- web: options.web ?? "yes",
196
- runtime: "nodejs:22",
197
293
  annotations: {
198
- "require-adobe-auth": true,
199
- final: true
200
- }
294
+ final: true,
295
+ "require-adobe-auth": true
296
+ },
297
+ function: `${GENERATED_ACTIONS_PATH}/${actionName}.js`,
298
+ runtime: "nodejs:24",
299
+ web: options.web ?? "yes"
201
300
  };
202
301
  if (config.requiresEncryptionKey) def.inputs = {
203
302
  ...def.inputs,
@@ -208,6 +307,7 @@ function createActionDefinition(actionName, config = {}, options = {}) {
208
307
  /**
209
308
  * Gets the runtime actions to be generated from the ext.config.yaml configuration.
210
309
  * @param extConfig - The ext.config.yaml configuration.
310
+ * @param dir - Directory containing the runtime action templates.
211
311
  */
212
312
  function getRuntimeActions(extConfig, dir) {
213
313
  return Object.entries(extConfig.runtimeManifest?.packages?.["app-management"]?.actions ?? {}).map(([name, _]) => ({
@@ -217,32 +317,32 @@ function getRuntimeActions(extConfig, dir) {
217
317
  }
218
318
  /**
219
319
  * Builds the ext.config.yaml configuration for the extensibility extension.
220
- * @param features - The features that are enabled for the app.
320
+ * @param appConfig - Parsed app configuration.
221
321
  */
222
322
  function buildAppManagementExtConfig(appConfig) {
223
- const features = getConfigDomains(appConfig);
224
- const hasPasswordFieldsInSchema = hasBusinessConfigSchema(appConfig) && appConfig.businessConfig.schema.some((field) => field.type === "password");
225
323
  const extConfig = {
226
324
  hooks: { "pre-app-build": "EXTENSION=extensibility/1 $packageExec aio-commerce-lib-app hooks pre-app-build" },
227
325
  operations: { workerProcess: [{
228
- type: "action",
229
- impl: `${PACKAGE_NAME}/app-config`
326
+ impl: `${PACKAGE_NAME}/app-config`,
327
+ type: "action"
328
+ }, {
329
+ impl: `${PACKAGE_NAME}/association`,
330
+ type: "action"
230
331
  }] },
231
332
  runtimeManifest: { packages: { [PACKAGE_NAME]: {
232
- license: "Apache-2.0",
233
- actions: { "app-config": createActionDefinition("app-config") }
333
+ actions: {
334
+ "app-config": createActionDefinition("app-config"),
335
+ association: createActionDefinition("association")
336
+ },
337
+ license: "Apache-2.0"
234
338
  } } }
235
339
  };
236
- if ([
237
- "installation.customInstallationSteps",
238
- "eventing.commerce",
239
- "eventing.external",
240
- "webhooks",
241
- "adminUiSdk"
242
- ].some((feature) => features.has(feature))) {
340
+ const needsInstallAction = requiresInstallation(appConfig);
341
+ const hasPasswordFieldsInSchema = hasBusinessConfigSchema(appConfig) && appConfig.businessConfig.schema.some((field) => field.type === "password");
342
+ if (needsInstallAction) {
243
343
  extConfig.operations.workerProcess.push({
244
- type: "action",
245
- impl: `${PACKAGE_NAME}/installation`
344
+ impl: `${PACKAGE_NAME}/installation`,
345
+ type: "action"
246
346
  });
247
347
  extConfig.runtimeManifest.packages[PACKAGE_NAME].actions.installation = createActionDefinition("installation", { requiresEncryptionKey: hasPasswordFieldsInSchema }, {
248
348
  inputs: {
@@ -258,8 +358,8 @@ function buildAppManagementExtConfig(appConfig) {
258
358
  function buildBusinessConfigurationExtConfig() {
259
359
  const actions = [{
260
360
  name: "config",
261
- templateFile: "config.js.template",
262
- requiresEncryptionKey: true
361
+ requiresEncryptionKey: true,
362
+ templateFile: "config.js.template"
263
363
  }, {
264
364
  name: "scope-tree",
265
365
  templateFile: "scope-tree.js.template"
@@ -267,38 +367,64 @@ function buildBusinessConfigurationExtConfig() {
267
367
  return {
268
368
  hooks: { "pre-app-build": "EXTENSION=configuration/1 $packageExec aio-commerce-lib-app hooks pre-app-build" },
269
369
  operations: { workerProcess: actions.map((action) => ({
270
- type: "action",
271
- impl: `${PACKAGE_NAME}/${action.name}`
370
+ impl: `${PACKAGE_NAME}/${action.name}`,
371
+ type: "action"
272
372
  })) },
273
373
  runtimeManifest: { packages: { [PACKAGE_NAME]: {
274
- license: "Apache-2.0",
275
- actions: Object.fromEntries(actions.map((action) => [action.name, createActionDefinition(action.name, action)]))
374
+ actions: Object.fromEntries(actions.map((action) => [action.name, createActionDefinition(action.name, action)])),
375
+ license: "Apache-2.0"
276
376
  } } }
277
377
  };
278
378
  }
379
+ /** Collects unique `runtimeAction` strings from all worker entries in an `adminUi` config. */
380
+ function collectUniqueRuntimeActions(adminUi) {
381
+ const entities = [
382
+ "order",
383
+ "product",
384
+ "customer"
385
+ ].map((key) => adminUi?.[key]);
386
+ const gridRuntimeActions = entities.map((entity) => entity?.gridColumns?.runtimeAction).filter((action) => action !== void 0);
387
+ const massActionRuntimeActions = entities.flatMap((entity) => entity?.massActions ?? []).filter((action) => action.type === "worker").map((action) => action.runtimeAction);
388
+ const viewButtonRuntimeActions = (adminUi?.order?.viewButtons ?? []).filter((button) => button.type === "worker").map((button) => button.runtimeAction);
389
+ return [.../* @__PURE__ */ new Set([
390
+ ...gridRuntimeActions,
391
+ ...massActionRuntimeActions,
392
+ ...viewButtonRuntimeActions
393
+ ])];
394
+ }
395
+ /** Returns true if the `adminUi` config requires a `view` operation and `web` source in ext.config.yaml. */
396
+ function requiresWebSource(adminUi) {
397
+ if (adminUi?.menu !== void 0) return true;
398
+ if ((adminUi?.order?.viewButtons ?? []).some((button) => button.type === "view")) return true;
399
+ return [
400
+ "order",
401
+ "product",
402
+ "customer"
403
+ ].map((key) => adminUi?.[key]).flatMap((entity) => entity?.massActions ?? []).some((action) => action.type === "view");
404
+ }
279
405
  /**
280
- * Builds the ext.config.yaml configuration for the Admin UI SDK backend-ui extension.
406
+ * Builds the ext.config.yaml for the Admin UI v2 extension (`commerce/backend-ui/2`).
407
+ * Derives `workerProcess` and `view` operation declarations from `adminUi` config.
408
+ * Adds a `view` operation and `web` source when view-type entries or `adminUi.menu` is configured.
409
+ * @param appConfig - Parsed app configuration.
281
410
  */
282
- function buildAdminUiSdkExtConfig() {
411
+ function buildAdminUiV2ExtConfig(appConfig) {
412
+ const { adminUi } = appConfig;
413
+ const runtimeActions = collectUniqueRuntimeActions(adminUi);
414
+ const requiresWeb = requiresWebSource(adminUi);
283
415
  return {
284
- hooks: { "pre-app-build": "EXTENSION=backend-ui/1 $packageExec aio-commerce-lib-app hooks pre-app-build" },
285
- operations: { view: [{
286
- type: "web",
287
- impl: "index.html"
288
- }] },
289
- web: "web-src",
290
- runtimeManifest: { packages: { [ADMIN_UI_SDK_PACKAGE_NAME]: {
291
- license: "Apache-2.0",
292
- actions: { registration: {
293
- function: `${ADMIN_UI_SDK_ACTIONS_PATH}/index.js`,
294
- web: "yes",
295
- runtime: "nodejs:22",
296
- annotations: {
297
- "require-adobe-auth": true,
298
- final: true
299
- }
300
- } }
301
- } } }
416
+ hooks: { "pre-app-build": "EXTENSION=backend-ui/2 $packageExec aio-commerce-lib-app hooks pre-app-build" },
417
+ operations: {
418
+ ...requiresWeb && { view: [{
419
+ impl: "index.html",
420
+ type: "web"
421
+ }] },
422
+ ...runtimeActions.length > 0 && { workerProcess: runtimeActions.map((impl) => ({
423
+ impl,
424
+ type: "action"
425
+ })) }
426
+ },
427
+ ...requiresWeb && { web: "web-src" }
302
428
  };
303
429
  }
304
430
 
@@ -312,9 +438,9 @@ async function readYamlFile(path) {
312
438
  let doc = new Document();
313
439
  if (existsSync(path)) try {
314
440
  doc = parseDocument(await readFile(path, "utf-8"), { keepSourceTokens: true });
315
- } catch {
441
+ } catch (err) {
316
442
  const file = basename(path);
317
- throw new Error(`Failed to parse ${file}`);
443
+ throw new Error(`Failed to parse ${file}`, { cause: err });
318
444
  }
319
445
  if (doc.contents === null) doc.contents = new YAMLMap();
320
446
  return doc;
@@ -348,8 +474,8 @@ function getOrCreateNode(doc, path, options, typeConfig) {
348
474
  */
349
475
  function getOrCreateSeq(doc, path, options) {
350
476
  return getOrCreateNode(doc, path, options ?? {}, {
351
- typeGuard: isSeq,
352
477
  createNode: () => new YAMLSeq(),
478
+ typeGuard: isSeq,
353
479
  typeName: "sequence"
354
480
  });
355
481
  }
@@ -361,8 +487,8 @@ function getOrCreateSeq(doc, path, options) {
361
487
  */
362
488
  function getOrCreateMap(doc, path, options) {
363
489
  return getOrCreateNode(doc, path, options ?? {}, {
364
- typeGuard: isMap,
365
490
  createNode: () => new YAMLMap(),
491
+ typeGuard: isMap,
366
492
  typeName: "map"
367
493
  });
368
494
  }
@@ -406,10 +532,9 @@ async function createOrUpdateExtConfig(path, config, doc) {
406
532
  const extConfigDoc = doc ?? new Document({});
407
533
  if (config.web !== void 0) buildWeb(extConfigDoc, config.web);
408
534
  config.hooks ??= {};
409
- config.runtimeManifest ??= { packages: {} };
410
535
  await buildHooks(extConfigDoc, config.hooks);
411
536
  if (config.operations !== void 0) buildOperations(extConfigDoc, config.operations);
412
- buildRuntimeManifest(extConfigDoc, config.runtimeManifest);
537
+ if (config.runtimeManifest !== void 0) buildRuntimeManifest(extConfigDoc, config.runtimeManifest);
413
538
  await writeExtConfig(path, extConfigDoc);
414
539
  return extConfigDoc;
415
540
  }
@@ -441,15 +566,15 @@ function buildActionDefinition(action, existingAction) {
441
566
  const managedInputs = { LOG_LEVEL: "$LOG_LEVEL" };
442
567
  actionDef.set("function", action.function);
443
568
  actionDef.set("web", action.web ?? "yes");
444
- actionDef.set("runtime", existingRuntime ?? action.runtime ?? "nodejs:22");
569
+ actionDef.set("runtime", existingRuntime ?? action.runtime ?? "nodejs:24");
445
570
  actionDef.set("inputs", {
446
571
  ...existingInputs,
447
572
  ...managedInputs,
448
573
  ...action.inputs ?? {}
449
574
  });
450
575
  actionDef.set("annotations", { ...action.annotations ?? {
451
- "require-adobe-auth": true,
452
- final: true
576
+ final: true,
577
+ "require-adobe-auth": true
453
578
  } });
454
579
  const includes = action.include ?? [];
455
580
  if (includes.length > 0) {
@@ -506,10 +631,11 @@ function buildOperations(extConfig, operations) {
506
631
  * @param packages - The packages to build
507
632
  */
508
633
  function buildRuntimeManifest(extConfig, manifest) {
634
+ const packages = manifest.packages ?? {};
635
+ if (Object.keys(packages).length === 0) return;
509
636
  getOrCreateMap(extConfig, ["runtimeManifest"], { onBeforeCreate: (pair) => {
510
637
  pair.key.spaceBefore = true;
511
638
  } });
512
- const packages = manifest.packages ?? {};
513
639
  getOrCreateMap(extConfig, ["runtimeManifest", "packages"]);
514
640
  for (const [name, pkg] of Object.entries(packages)) {
515
641
  const packageDef = getOrCreateMap(extConfig, [
@@ -557,26 +683,15 @@ async function buildHooks(extConfig, hooks) {
557
683
  */
558
684
  async function writeExtConfig(configPath, doc) {
559
685
  await writeFile(configPath, doc.toString({
686
+ defaultStringType: "PLAIN",
560
687
  indent: 2,
561
- lineWidth: 0,
562
- defaultStringType: "PLAIN"
688
+ lineWidth: 0
563
689
  }), "utf-8");
564
690
  }
565
691
 
566
692
  //#endregion
567
693
  //#region source/commands/generate/actions/lib.ts
568
- const __dirname = dirname(fileURLToPath(import.meta.url));
569
- /** The path to the action templates directory, sibling to this file. */
570
- const TEMPLATES_DIR = join(__dirname, "templates");
571
- const TYPESCRIPT_CONFIG_EXTENSIONS = new Set([
572
- ".ts",
573
- ".mts",
574
- ".cts"
575
- ]);
576
694
  const LEADING_DOT_SLASH_PATTERN = /^\.\//u;
577
- const DYNAMIC_APP_CONFIG_IMPORT = `import appConfig from "${APP_CONFIG_IMPORT_ALIAS}";`;
578
- const STATIC_APP_MANIFEST_IMPORT = "import appConfig from \"../../app.commerce.manifest.json\" with { type: \"json\" };";
579
- const STATIC_CONFIG_SCHEMA_IMPORT = "import configSchema from \"../../configuration-schema.json\" with { type: \"json\" };";
580
695
  /** Normalize a path for use as an ESM import specifier. */
581
696
  function normalizeImportPath(path) {
582
697
  const normalizedPath = path.split(sep).join("/");
@@ -588,7 +703,8 @@ function normalizePackageJsonPath(path) {
588
703
  }
589
704
  /** Add or update the package import alias used by dynamic generated actions. */
590
705
  async function updateAppConfigImportAlias(projectRoot, runtimeConfigPath) {
591
- const pkg = await NpmPackageJson.load(projectRoot);
706
+ const pkg = await loadPackageJson(projectRoot);
707
+ if (pkg === null) throw new Error("Could not find package.json.");
592
708
  const existingImports = typeof pkg.content.imports === "object" && pkg.content.imports !== null ? pkg.content.imports : {};
593
709
  pkg.update({ imports: {
594
710
  ...existingImports,
@@ -596,24 +712,13 @@ async function updateAppConfigImportAlias(projectRoot, runtimeConfigPath) {
596
712
  } });
597
713
  await pkg.save();
598
714
  }
599
- /** Remove the package import alias used only by dynamic generated actions. */
600
- async function deleteAppConfigImportAlias(projectRoot) {
601
- const pkg = await NpmPackageJson.load(projectRoot);
602
- const existingImports = typeof pkg.content.imports === "object" && pkg.content.imports !== null ? pkg.content.imports : {};
603
- if (!("#app.commerce.config" in existingImports)) return;
604
- const imports = { ...existingImports };
605
- delete imports[APP_CONFIG_IMPORT_ALIAS];
606
- if (Object.keys(imports).length > 0) pkg.update({ imports });
607
- else pkg.content.imports = void 0;
608
- await pkg.save();
609
- }
610
- /** Write an ESM passthrough module for JavaScript app config files. */
715
+ /** Write an ESM passthrough module that re-exports an app config file. */
611
716
  async function writeJavaScriptAppConfigModule(configFilePath, outputPath) {
612
717
  await writeFile(outputPath, [
613
718
  "// This file has been auto-generated by `@adobe/aio-commerce-lib-app`",
614
719
  "// Do not modify this file directly",
615
720
  "",
616
- `import appConfig from "${normalizeImportPath(relative(dirname(outputPath), configFilePath))}";`,
721
+ `import appConfig from "${normalizeImportPath(relative(dirname(outputPath), configFilePath))}"${extname(configFilePath) === ".json" ? " with { type: \"json\" }" : ""};`,
617
722
  "",
618
723
  "export default appConfig;",
619
724
  ""
@@ -622,14 +727,14 @@ async function writeJavaScriptAppConfigModule(configFilePath, outputPath) {
622
727
  /** Bundle a TypeScript app config file into runtime-safe ESM. */
623
728
  async function bundleTypeScriptAppConfigModule(configFilePath, outputPath) {
624
729
  await build({
625
- entryPoints: [configFilePath],
626
- outfile: outputPath,
627
730
  bundle: true,
731
+ entryPoints: [configFilePath],
628
732
  format: "esm",
629
- platform: "node",
630
- target: "node22",
733
+ logLevel: "silent",
734
+ outfile: outputPath,
631
735
  packages: "external",
632
- logLevel: "silent"
736
+ platform: "node",
737
+ target: "node22"
633
738
  });
634
739
  }
635
740
  /** Generate the runtime-safe app config module used by generated runtime actions. */
@@ -640,36 +745,36 @@ async function generateRuntimeAppConfigModule() {
640
745
  const outputPath = join(projectRoot, runtimeConfigPath);
641
746
  const configFilePath = await resolveCommerceAppConfig(projectRoot);
642
747
  if (!configFilePath) throw new Error("Dynamic list options require an app.commerce.config.* file so generated actions can import the option factories at runtime.");
643
- consola$1.info("Generating JS config module...");
748
+ consola.info("Generating JS config module...");
644
749
  if (TYPESCRIPT_CONFIG_EXTENSIONS.has(extname(configFilePath))) await bundleTypeScriptAppConfigModule(configFilePath, outputPath);
645
750
  else await writeJavaScriptAppConfigModule(configFilePath, outputPath);
646
751
  await updateAppConfigImportAlias(projectRoot, runtimeConfigPath);
647
- consola$1.success(`Generated JS config module: ${relative(process.cwd(), outputPath)}`);
752
+ consola.success(`Generated JS config module: ${relative(process.cwd(), outputPath)}`);
648
753
  }
649
- /** Remove the generated app config module when generated actions use static JSON. */
650
- async function cleanupRuntimeAppConfigModule() {
754
+ /**
755
+ * Write an ESM module that re-exports the static app manifest JSON so generated
756
+ * actions can import it via the alias without needing a JSON import attribute.
757
+ */
758
+ async function prepareStaticAppConfigImportAlias() {
651
759
  const projectRoot = await getProjectRootDirectory();
652
- await rm(join(projectRoot, getRuntimeAppConfigPath()), { force: true });
653
- await deleteAppConfigImportAlias(projectRoot);
760
+ const runtimeConfigPath = getRuntimeAppConfigPath();
761
+ const outputPath = join(projectRoot, runtimeConfigPath);
762
+ await makeOutputDirFor(dirname(runtimeConfigPath));
763
+ await writeJavaScriptAppConfigModule(join(projectRoot, getManifestPath()), outputPath);
764
+ await updateAppConfigImportAlias(projectRoot, runtimeConfigPath);
654
765
  }
655
766
  /**
656
767
  * Prepare runtime-side config artifacts consumed by generated actions: the
657
768
  * bundled ESM module and its `#app.commerce.config` package import alias.
658
769
  *
659
- * Generates them for dynamic schemas, cleans them up for static ones.
770
+ * Dynamic schemas use the source config file, while static schemas use the generated JSON manifest.
660
771
  */
661
772
  async function prepareRuntimeAppConfigModule(appManifest) {
662
773
  if (hasDynamicAppConfig(appManifest)) {
663
774
  await generateRuntimeAppConfigModule();
664
775
  return;
665
776
  }
666
- await cleanupRuntimeAppConfigModule();
667
- }
668
- /** Switch static JSON imports to the generated runtime config module for dynamic schemas. */
669
- function applyRuntimeAppConfigImport(template, actionName) {
670
- if (actionName === "app-config" || actionName === "installation") return template.replace(STATIC_APP_MANIFEST_IMPORT, DYNAMIC_APP_CONFIG_IMPORT);
671
- if (actionName === "config") return template.replace(STATIC_CONFIG_SCHEMA_IMPORT, DYNAMIC_APP_CONFIG_IMPORT).replace("const args = { configSchema };", "const args = { configSchema: appConfig.businessConfig.schema };");
672
- return template;
777
+ await prepareStaticAppConfigImportAlias();
673
778
  }
674
779
  /**
675
780
  * Read an extension point's ext.config.yaml file and return it as a JS object.
@@ -679,8 +784,8 @@ async function readExtConfig(extensionPointId) {
679
784
  const extConfigPath = join(await getProjectRootDirectory(), getExtConfigPath(extensionPointId));
680
785
  try {
681
786
  return {
682
- path: extConfigPath,
683
- doc: await readYamlFile(extConfigPath)
787
+ doc: await readYamlFile(extConfigPath),
788
+ path: extConfigPath
684
789
  };
685
790
  } catch (error) {
686
791
  const reason = error instanceof Error ? error.message : "Unexpected error while reading the file.";
@@ -688,12 +793,12 @@ async function readExtConfig(extensionPointId) {
688
793
  `Could not read ext.config.yaml for ${extensionPointId} at ${extConfigPath}.`,
689
794
  `Make sure the file exists and is valid YAML. You can regenerate it with "aio-commerce-lib-app generate actions".`,
690
795
  `Reason: ${reason}`
691
- ].join("\n"));
796
+ ].join("\n"), { cause: error });
692
797
  }
693
798
  }
694
799
  /** Update the ext.config.yaml file */
695
800
  async function updateExtConfig(appConfig, extensionPointId) {
696
- consola$1.info(`Updating ext.config.yaml for ${extensionPointId}...`);
801
+ consola.info(`Updating ext.config.yaml for ${extensionPointId}...`);
697
802
  await makeOutputDirFor(getExtensionPointFolderPath(extensionPointId));
698
803
  const { path: extConfigPath, doc: extConfigDoc } = await readExtConfig(extensionPointId);
699
804
  let extConfig;
@@ -704,33 +809,164 @@ async function updateExtConfig(appConfig, extensionPointId) {
704
809
  case CONFIGURATION_EXTENSION_POINT_ID:
705
810
  extConfig = buildBusinessConfigurationExtConfig();
706
811
  break;
707
- case BACKEND_UI_EXTENSION_POINT_ID:
708
- extConfig = buildAdminUiSdkExtConfig();
812
+ case BACKEND_UI_V2_EXTENSION_POINT_ID:
813
+ extConfig = buildAdminUiV2ExtConfig(appConfig);
709
814
  break;
710
815
  }
711
816
  await createOrUpdateExtConfig(extConfigPath, extConfig, extConfigDoc);
712
817
  return extConfig;
713
818
  }
819
+ /**
820
+ * Resolve the generated web-src entrypoint path from an extension config.
821
+ * @param extConfig - Extension config containing the view operation.
822
+ * @param extensionPointId - Extension point that owns the web source folder.
823
+ */
824
+ function getWebSourceEntrypoint(extConfig, extensionPointId) {
825
+ const viewEntrypoint = extConfig.operations?.view?.[0]?.impl;
826
+ if (viewEntrypoint === void 0) return null;
827
+ return join(getExtensionPointFolderPath(extensionPointId), extConfig.web ?? "web-src", viewEntrypoint);
828
+ }
829
+ /**
830
+ * Ensure package.json has the dependencies and Parcel config needed by web-src.
831
+ * @param projectRoot - Project root containing the package.json to update.
832
+ */
833
+ async function prepareWebSourcePackage(projectRoot, extension) {
834
+ const pkg = await loadPackageJson(projectRoot);
835
+ if (pkg === null) throw new Error("Could not find package.json.");
836
+ const requiredDevDependencies = [...WEB_SOURCE_DEV_DEPENDENCIES, ...extension === "tsx" ? WEB_SOURCE_TS_DEV_DEPENDENCIES : []];
837
+ const installPlan = await getPackageDependencyInstallPlan([...WEB_SOURCE_DEPENDENCIES, ...requiredDevDependencies], projectRoot);
838
+ if (installPlan.incompatible.length > 0) {
839
+ const incompatibleDependencies = installPlan.incompatible.map(({ name, version, installedVersion }) => `${name}@${installedVersion} does not satisfy ${version}`).join("\n");
840
+ throw new Error(`Cannot scaffold web-src because installed dependencies are incompatible:\n${incompatibleDependencies}`);
841
+ }
842
+ const dependencies = pkg.content.dependencies ?? {};
843
+ const devDependencies = pkg.content.devDependencies ?? {};
844
+ const dependencyMaps = [dependencies, devDependencies];
845
+ const declaredDependencyNames = new Set(dependencyMaps.flatMap((depMap) => Object.keys(depMap)));
846
+ const dependenciesToDeclare = [...WEB_SOURCE_DEPENDENCIES, ...requiredDevDependencies].filter(({ name }) => !declaredDependencyNames.has(name));
847
+ if (dependenciesToDeclare.length > 0) {
848
+ consola.info("Adding web-src dependencies in package.json:");
849
+ consola.log.raw(formatTree(dependenciesToDeclare.map(({ name, version }) => ` ${name}@${version}`)));
850
+ } else consola.info("web-src dependencies are already declared in package.json.");
851
+ pkg.update({
852
+ "@parcel/bundler-default": {
853
+ ...pkg.content["@parcel/bundler-default"],
854
+ manualSharedBundles: WEB_SOURCE_SHARED_BUNDLES
855
+ },
856
+ "@parcel/resolver-default": {
857
+ ...pkg.content["@parcel/resolver-default"],
858
+ packageExports: true
859
+ },
860
+ dependencies: mergePackageJsonDependencies(dependencies, WEB_SOURCE_DEPENDENCIES, dependencyMaps),
861
+ devDependencies: mergePackageJsonDependencies(devDependencies, requiredDevDependencies, dependencyMaps)
862
+ });
863
+ await pkg.save();
864
+ if (installPlan.missing.length === 0) {
865
+ consola.info("web-src dependencies are already installed.");
866
+ return;
867
+ }
868
+ consola.info("Installing missing web-src dependencies from package.json:");
869
+ consola.log.raw(formatTree(installPlan.missing.map(({ name, version }) => ` ${name}@${version}`)));
870
+ runProjectInstall(await detectPackageManager(projectRoot), projectRoot);
871
+ }
872
+ /**
873
+ * Add the package import alias for an existing or generated web-src.
874
+ * @param extConfig - Extension config containing the view operation.
875
+ */
876
+ async function prepareWebSourceImportAlias(extConfig) {
877
+ const entrypoint = getWebSourceEntrypoint(extConfig, BACKEND_UI_V2_EXTENSION_POINT_ID);
878
+ if (entrypoint === null) return;
879
+ const pkg = await loadPackageJson(await getProjectRootDirectory());
880
+ if (pkg === null) throw new Error("Could not find package.json.");
881
+ const existingImports = typeof pkg.content.imports === "object" && pkg.content.imports !== null ? pkg.content.imports : {};
882
+ const webSourceSrcPath = join(dirname(entrypoint), "src");
883
+ pkg.update({ imports: {
884
+ ...existingImports,
885
+ [WEB_SOURCE_IMPORT_ALIAS]: `${normalizePackageJsonPath(webSourceSrcPath)}/*`
886
+ } });
887
+ await pkg.save();
888
+ }
889
+ /**
890
+ * Resolve the generated web-src file extension from the app config file type.
891
+ * @param projectRoot - Project root used to find the commerce app config file.
892
+ */
893
+ async function resolveWebSourceExtension(projectRoot) {
894
+ const configFilePath = await resolveCommerceAppConfig(projectRoot);
895
+ return configFilePath !== null && TYPESCRIPT_CONFIG_EXTENSIONS.has(extname(configFilePath)) ? "tsx" : "jsx";
896
+ }
897
+ /**
898
+ * Resolve the destination path for a web-src template file.
899
+ * @param templatePath - Template file path relative to its source directory.
900
+ * @param extension - Web source extension to generate.
901
+ */
902
+ function getWebSourceTemplateTargetPath(templatePath, extension) {
903
+ if (extension === "jsx" || !templatePath.endsWith(".jsx")) return templatePath;
904
+ return `${templatePath.slice(0, -JSX_FILE_EXTENSION.length)}${TSX_FILE_EXTENSION}`;
905
+ }
906
+ /**
907
+ * Copy web-src templates directly to the final file extension and entrypoint.
908
+ * @param sourceDir - Template web-src directory.
909
+ * @param targetDir - Generated web-src directory.
910
+ * @param extension - Web source extension to generate.
911
+ */
912
+ async function copyWebSourceTemplates(sourceDir, targetDir, extension, appTitle) {
913
+ await mkdir(targetDir, { recursive: true });
914
+ const entries = await readdir(sourceDir, { withFileTypes: true });
915
+ return (await Promise.all(entries.map(async (entry) => {
916
+ const sourcePath = join(sourceDir, entry.name);
917
+ const targetPath = join(targetDir, getWebSourceTemplateTargetPath(entry.name, extension));
918
+ if (entry.isDirectory()) return await copyWebSourceTemplates(sourcePath, targetPath, extension, appTitle);
919
+ let content = await readFile(sourcePath, "utf-8");
920
+ if (extension === "tsx") content = content.replaceAll(`${JSX_FILE_EXTENSION}"`, `${TSX_FILE_EXTENSION}"`);
921
+ if (targetPath.endsWith("index.html")) content = content.replaceAll(APP_TITLE_PLACEHOLDER, appTitle);
922
+ await writeFile(targetPath, content, {
923
+ encoding: "utf-8",
924
+ flag: "wx"
925
+ });
926
+ return ` ${relative(process.cwd(), targetPath)}`;
927
+ }))).flat();
928
+ }
929
+ /** Generate the web source scaffold for iframe-based Admin UI extensions. */
930
+ async function generateWebSrc(extConfig, extensionPointId, appName, templatesDir = TEMPLATES_DIR) {
931
+ const entrypoint = getWebSourceEntrypoint(extConfig, extensionPointId);
932
+ if (entrypoint === null) return;
933
+ const projectRoot = await getProjectRootDirectory();
934
+ const entrypointPath = join(projectRoot, entrypoint);
935
+ if (existsSync(entrypointPath)) {
936
+ consola.info(`web-src entrypoint already exists, skipping scaffold: ${relative(process.cwd(), entrypointPath)}`);
937
+ return;
938
+ }
939
+ consola.start(`Scaffolding web-src for ${extensionPointId}...`);
940
+ const sourceDir = join(templatesDir, "admin-ui", "web-src");
941
+ const targetDir = dirname(entrypointPath);
942
+ const extension = await resolveWebSourceExtension(projectRoot);
943
+ const outputFiles = await copyWebSourceTemplates(sourceDir, targetDir, extension, appName);
944
+ if (extension === "tsx") {
945
+ const tsconfigPath = join(targetDir, WEB_SOURCE_TSCONFIG_FILE);
946
+ await writeFile(tsconfigPath, JSON.stringify(WEB_SOURCE_TSCONFIG, null, 2), "utf-8");
947
+ outputFiles.push(` ${relative(process.cwd(), tsconfigPath)}`);
948
+ }
949
+ await prepareWebSourcePackage(projectRoot, extension);
950
+ consola.success(`Scaffolded ${relative(process.cwd(), targetDir)}`);
951
+ consola.log.raw(formatTree(outputFiles));
952
+ }
714
953
  /** Generate the action files */
715
954
  async function generateActionFiles(appManifest, actions, extensionPointId, templatesDir) {
716
- consola$1.start("Generating runtime actions...");
955
+ consola.start("Generating runtime actions...");
717
956
  await makeOutputDirFor(getActionsDir(extensionPointId));
718
957
  const projectRoot = await getProjectRootDirectory();
719
- const outputFiles = [];
720
- const useDynamicImports = hasDynamicAppConfig(appManifest);
721
- for (const action of actions) {
958
+ const outputFiles = await Promise.all(actions.map(async (action) => {
722
959
  let template = await readFile(join(templatesDir, action.templateFile), "utf-8");
723
- if (useDynamicImports) template = applyRuntimeAppConfigImport(template, action.name);
724
960
  if (action.name === "installation") {
725
961
  const scriptsTemplate = await generateCustomScriptsTemplate(await readFile(join(templatesDir, "app-management", "custom-scripts.js.template"), "utf-8"), appManifest);
726
962
  template = applyCustomScripts(template, scriptsTemplate);
727
963
  }
728
964
  const actionPath = join(projectRoot, getActionPath(extensionPointId, action.name));
729
965
  await writeFile(actionPath, template, "utf-8");
730
- outputFiles.push(` ${relative(process.cwd(), actionPath)}`);
731
- }
732
- consola$1.success(`Generated ${actions.length} action(s)`);
733
- consola$1.log.raw(formatTree(outputFiles));
966
+ return ` ${relative(process.cwd(), actionPath)}`;
967
+ }));
968
+ consola.success(`Generated ${actions.length} action(s)`);
969
+ consola.log.raw(formatTree(outputFiles));
734
970
  }
735
971
  /**
736
972
  * Applies the given custom scripts template code to the given installation template.
@@ -739,7 +975,7 @@ async function generateActionFiles(appManifest, actions, extensionPointId, templ
739
975
  */
740
976
  function applyCustomScripts(installationTemplate, customScriptsTemplate) {
741
977
  if (customScriptsTemplate !== null) return installationTemplate.replace(CUSTOM_SCRIPTS_LOADER_PLACEHOLDER, customScriptsTemplate).replace("const args = { appConfig };", "const args = { appConfig, customScriptsLoader };");
742
- consola$1.debug("No custom installation steps found, skipping custom-scripts.js generation...");
978
+ consola.debug("No custom installation steps found, skipping custom-scripts.js generation...");
743
979
  return installationTemplate.replace(CUSTOM_SCRIPTS_LOADER_PLACEHOLDER, "// No custom installation scripts configured");
744
980
  }
745
981
  /**
@@ -751,7 +987,8 @@ async function generateCustomScriptsTemplate(template, appManifest) {
751
987
  const installationActionDir = join(projectRoot, getActionsDir(EXTENSIBILITY_EXTENSION_POINT_ID));
752
988
  const customSteps = appManifest.installation.customInstallationSteps;
753
989
  const importStatements = customSteps.map((step, index) => {
754
- let relativeImportPath = relative(installationActionDir, join(projectRoot, step.script));
990
+ const absoluteScriptPath = join(projectRoot, step.script);
991
+ let relativeImportPath = relative(installationActionDir, absoluteScriptPath);
755
992
  if (!relativeImportPath.startsWith(".")) relativeImportPath = `./${relativeImportPath}`;
756
993
  relativeImportPath = relativeImportPath.replace(/\\/g, "/");
757
994
  return `import * as ${`customScript${index}`} from "${relativeImportPath}";`;
@@ -762,23 +999,6 @@ async function generateCustomScriptsTemplate(template, appManifest) {
762
999
  }).join("\n");
763
1000
  return template.replace(CUSTOM_IMPORTS_PLACEHOLDER, importStatements).replace(CUSTOM_SCRIPTS_MAP_PLACEHOLDER, scriptMap);
764
1001
  }
765
- /**
766
- * Generates `registration/index.js` with the Admin UI SDK registration config
767
- * inlined as a JS object literal.
768
- * @param appManifest - The validated app config; must satisfy `hasAdminUiSdk`.
769
- * @param extensionPointId - The extension point ID that owns the registration action.
770
- * @param templatesDir - The root directory containing the action templates.
771
- */
772
- async function generateRegistrationActionFile(appManifest, extensionPointId, templatesDir = TEMPLATES_DIR) {
773
- consola$1.start("Generating Admin UI SDK registration action...");
774
- await makeOutputDirFor(getAdminUiSdkActionsDir(extensionPointId));
775
- const projectRoot = await getProjectRootDirectory();
776
- const template = await readFile(join(templatesDir, "admin-ui-sdk", "registration.js.template"), "utf-8");
777
- const { registration } = appManifest.adminUiSdk;
778
- const actionPath = join(projectRoot, getAdminUiSdkRegistrationActionPath(extensionPointId));
779
- await writeFile(actionPath, await prettierFormat(template.replace(REGISTRATION_JSON_PLACEHOLDER, `const registration = ${stringify(registration)};`), actionPath), "utf-8");
780
- consola$1.success(`Generated registration action at ${relative(process.cwd(), actionPath)}`);
781
- }
782
1002
 
783
1003
  //#endregion
784
1004
  //#region source/commands/generate/actions/main.ts
@@ -791,9 +1011,12 @@ async function run$5(appManifest, templatesDir = TEMPLATES_DIR) {
791
1011
  await prepareRuntimeAppConfigModule(appManifest);
792
1012
  await generateActionFiles(appManifest, getRuntimeActions(await updateExtConfig(appManifest, EXTENSIBILITY_EXTENSION_POINT_ID), "app-management"), EXTENSIBILITY_EXTENSION_POINT_ID, templatesDir);
793
1013
  if (hasBusinessConfigSchema(appManifest)) await generateActionFiles(appManifest, getRuntimeActions(await updateExtConfig(appManifest, CONFIGURATION_EXTENSION_POINT_ID), "business-configuration"), CONFIGURATION_EXTENSION_POINT_ID, templatesDir);
794
- if (hasAdminUiSdk(appManifest)) {
795
- await updateExtConfig(appManifest, BACKEND_UI_EXTENSION_POINT_ID);
796
- await generateRegistrationActionFile(appManifest, BACKEND_UI_EXTENSION_POINT_ID, templatesDir);
1014
+ if (hasAdminUi(appManifest)) {
1015
+ const extConfig = await updateExtConfig(appManifest, BACKEND_UI_V2_EXTENSION_POINT_ID);
1016
+ if (extConfig.operations?.view) {
1017
+ await prepareWebSourceImportAlias(extConfig);
1018
+ await generateWebSrc(extConfig, BACKEND_UI_V2_EXTENSION_POINT_ID, appManifest.metadata.displayName, templatesDir);
1019
+ }
797
1020
  }
798
1021
  }
799
1022
  /** Run the generate actions command */
@@ -801,8 +1024,8 @@ async function exec$5() {
801
1024
  try {
802
1025
  await run$5(await loadAppManifest());
803
1026
  } catch (error) {
804
- if (error instanceof CommerceSdkValidationError) consola$1.error(error.display());
805
- else consola$1.error(error);
1027
+ if (error instanceof CommerceSdkValidationError) consola.error(error.display());
1028
+ else consola.error(error);
806
1029
  process.exit(1);
807
1030
  }
808
1031
  }
@@ -814,22 +1037,22 @@ async function run$4(appConfig) {
814
1037
  const stalePath = join(await getProjectRootDirectory(), getManifestPath());
815
1038
  if (await access(stalePath).then(() => true, () => false)) {
816
1039
  await rm(stalePath, { force: true });
817
- consola$1.success(`Removed stale ${APP_MANIFEST_FILE}`);
1040
+ consola.success(`Removed stale ${APP_MANIFEST_FILE}`);
818
1041
  }
819
1042
  return;
820
1043
  }
821
- consola$1.info("Generating app manifest...");
822
- const contents = stringify$1(appConfig, null, 2);
1044
+ consola.info("Generating app manifest...");
1045
+ const contents = stringify(appConfig, null, 2);
823
1046
  await writeFile(join(await makeOutputDirFor(getGeneratedDir(EXTENSIBILITY_EXTENSION_POINT_ID)), APP_MANIFEST_FILE), contents, "utf-8");
824
- consola$1.success(`Generated ${APP_MANIFEST_FILE}\n`);
1047
+ consola.success(`Generated ${APP_MANIFEST_FILE}\n`);
825
1048
  }
826
1049
  /** Run the generate manifest command */
827
1050
  async function exec$4() {
828
1051
  try {
829
1052
  await run$4(await loadAppManifest());
830
1053
  } catch (error) {
831
- if (error instanceof CommerceSdkValidationError) consola$1.error(error.display());
832
- else consola$1.error(error);
1054
+ if (error instanceof CommerceSdkValidationError) consola.error(error.display());
1055
+ else consola.error(error);
833
1056
  process.exit(1);
834
1057
  }
835
1058
  }
@@ -850,7 +1073,7 @@ async function touch(filePath) {
850
1073
  //#region source/commands/generate/schema/main.ts
851
1074
  async function run$3(appConfig) {
852
1075
  if (!hasBusinessConfigSchema(appConfig)) {
853
- consola$1.debug("Business configuration schema not found in application configuration. Nothing to do.");
1076
+ consola.debug("Business configuration schema not found in application configuration. Nothing to do.");
854
1077
  return;
855
1078
  }
856
1079
  const projectDir = await getProjectRootDirectory();
@@ -866,23 +1089,23 @@ async function run$3(appConfig) {
866
1089
  const stalePath = join(projectDir, getSchemaPath());
867
1090
  if (await access(stalePath).then(() => true, () => false)) {
868
1091
  await rm(stalePath, { force: true });
869
- consola$1.success(`Removed stale ${CONFIG_SCHEMA_FILE_NAME}`);
1092
+ consola.success(`Removed stale ${CONFIG_SCHEMA_FILE_NAME}`);
870
1093
  }
871
1094
  return;
872
1095
  }
873
- consola$1.info("Generating configuration schema...");
1096
+ consola.info("Generating configuration schema...");
874
1097
  const outputDir = await makeOutputDirFor(getGeneratedDir(CONFIGURATION_EXTENSION_POINT_ID));
875
- const contents = stringify$1(appConfig.businessConfig.schema, null, 2);
1098
+ const contents = stringify(appConfig.businessConfig.schema, null, 2);
876
1099
  await writeFile(join(outputDir, CONFIG_SCHEMA_FILE_NAME), contents, "utf-8");
877
- consola$1.success(`Generated ${CONFIG_SCHEMA_FILE_NAME}\n`);
1100
+ consola.success(`Generated ${CONFIG_SCHEMA_FILE_NAME}\n`);
878
1101
  }
879
1102
  /** Run the generate schema command */
880
1103
  async function exec$3() {
881
1104
  try {
882
1105
  await run$3(await loadAppManifest());
883
1106
  } catch (error) {
884
- if (error instanceof CommerceSdkValidationError) consola$1.error(error.display());
885
- else consola$1.error(error);
1107
+ if (error instanceof CommerceSdkValidationError) consola.error(error.display());
1108
+ else consola.error(error);
886
1109
  process.exit(1);
887
1110
  }
888
1111
  }
@@ -896,12 +1119,12 @@ async function run$2(appManifest, templatesDir) {
896
1119
  }
897
1120
  /** Runs the postinstall hook */
898
1121
  async function exec$2() {
899
- consola.debug("Running lib-app postinstall hook");
1122
+ consola$1.debug("Running lib-app postinstall hook");
900
1123
  try {
901
1124
  await run$2(await loadAppManifest());
902
1125
  } catch (error) {
903
- if (error instanceof CommerceSdkValidationError) consola.error(error.display());
904
- else consola.error(error);
1126
+ if (error instanceof CommerceSdkValidationError) consola$1.error(error.display());
1127
+ else consola$1.error(error);
905
1128
  process.exit(1);
906
1129
  }
907
1130
  }
@@ -916,10 +1139,10 @@ const { context } = aioIms;
916
1139
  const IMS_KEYS = {
917
1140
  client_id: "AIO_COMMERCE_AUTH_IMS_CLIENT_ID",
918
1141
  client_secrets: "AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS",
919
- technical_account_email: "AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_EMAIL",
920
- technical_account_id: "AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_ID",
1142
+ ims_org_id: "AIO_COMMERCE_AUTH_IMS_ORG_ID",
921
1143
  scopes: "AIO_COMMERCE_AUTH_IMS_SCOPES",
922
- ims_org_id: "AIO_COMMERCE_AUTH_IMS_ORG_ID"
1144
+ technical_account_email: "AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_EMAIL",
1145
+ technical_account_id: "AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_ID"
923
1146
  };
924
1147
  /**
925
1148
  * Replaces or creates an environment variable in a .env file
@@ -951,7 +1174,7 @@ function resolveEnvPath() {
951
1174
  }
952
1175
  /** Resolves the IMS server to server context from the project workspace credentials. */
953
1176
  function resolveImsS2SContext() {
954
- const [credential] = (config.get("project.workspace.details.credentials") ?? []).filter(({ integration_type }) => integration_type === "oauth_server_to_server").map(({ name }) => name) ?? [];
1177
+ const [credential] = (config.get("project.workspace.details.credentials") ?? []).filter(({ integration_type }) => integration_type === "oauth_server_to_server").map(({ name }) => name);
955
1178
  if (!credential) return Promise.resolve(null);
956
1179
  return context.get(credential);
957
1180
  }
@@ -994,7 +1217,7 @@ async function run$1(extension, templatesDir = TEMPLATES_DIR) {
994
1217
  const { doc: extensibilityExtConfig } = await readExtConfig(EXTENSIBILITY_EXTENSION_POINT_ID);
995
1218
  await run$4(appManifest);
996
1219
  await generateActionFiles(appManifest, getRuntimeActions(extensibilityExtConfig.toJS(), "app-management"), EXTENSIBILITY_EXTENSION_POINT_ID, templatesDir);
997
- consola.info("Syncing IMS credentials...");
1220
+ consola$1.info("Syncing IMS credentials...");
998
1221
  await syncImsCredentials();
999
1222
  return;
1000
1223
  }
@@ -1004,22 +1227,28 @@ async function run$1(extension, templatesDir = TEMPLATES_DIR) {
1004
1227
  await generateActionFiles(appManifest, getRuntimeActions(businessConfigExtConfig.toJS(), "business-configuration"), CONFIGURATION_EXTENSION_POINT_ID, templatesDir);
1005
1228
  return;
1006
1229
  }
1007
- if (extension === "backend-ui/1") {
1008
- if (hasAdminUiSdk(appManifest)) await generateRegistrationActionFile(appManifest, BACKEND_UI_EXTENSION_POINT_ID);
1230
+ if (extension === "backend-ui/2") {
1231
+ if (hasAdminUi(appManifest)) {
1232
+ const extConfig = await updateExtConfig(appManifest, BACKEND_UI_V2_EXTENSION_POINT_ID);
1233
+ if (extConfig.operations?.view) {
1234
+ await prepareWebSourceImportAlias(extConfig);
1235
+ await generateWebSrc(extConfig, BACKEND_UI_V2_EXTENSION_POINT_ID, appManifest.metadata.displayName, templatesDir);
1236
+ }
1237
+ }
1009
1238
  return;
1010
1239
  }
1011
1240
  throw new Error(`Unsupported extension: ${extension}`);
1012
1241
  }
1013
1242
  /** Runs the pre-app-build hook */
1014
1243
  async function exec$1() {
1015
- consola.debug("Running lib-app pre-app-build hook");
1016
- const extension = process.env.EXTENSION;
1244
+ consola$1.debug("Running lib-app pre-app-build hook");
1245
+ const rawExtension = process.env.EXTENSION;
1017
1246
  try {
1018
- if (!extension) throw new Error("EXTENSION environment variable is not set");
1019
- await run$1(extension);
1247
+ if (!rawExtension) throw new Error("EXTENSION environment variable is not set");
1248
+ await run$1(rawExtension);
1020
1249
  } catch (error) {
1021
- if (error instanceof CommerceSdkValidationError) consola.error(error.display());
1022
- else consola.error(error);
1250
+ if (error instanceof CommerceSdkValidationError) consola$1.error(error.display());
1251
+ else consola$1.error(error);
1023
1252
  process.exit(1);
1024
1253
  }
1025
1254
  }
@@ -1029,77 +1258,77 @@ async function exec$1() {
1029
1258
  /** The default values for the features of the commerce app config. */
1030
1259
  const DOMAIN_DEFAULTS = {
1031
1260
  businessConfig: { schema: [{
1032
- type: "list",
1033
- name: "sampleList",
1034
- label: "Sample List",
1035
- selectionMode: "multiple",
1036
1261
  default: ["a"],
1262
+ label: "Sample List",
1263
+ name: "sampleList",
1037
1264
  options: [{
1038
1265
  label: "Option A",
1039
1266
  value: "a"
1040
1267
  }, {
1041
1268
  label: "Option B",
1042
1269
  value: "b"
1043
- }]
1270
+ }],
1271
+ selectionMode: "multiple",
1272
+ type: "list"
1044
1273
  }, {
1045
- type: "text",
1046
- name: "sampleText",
1274
+ default: "Hello, world!",
1047
1275
  label: "Sample Text",
1048
- default: "Hello, world!"
1276
+ name: "sampleText",
1277
+ type: "text"
1049
1278
  }] },
1050
1279
  "eventing.commerce": [{
1051
- provider: {
1052
- label: "Commerce Events Provider",
1053
- description: "A description for your Commerce Events provider."
1054
- },
1055
1280
  events: [{
1056
- name: "plugin.sample_event",
1281
+ description: "Use case description for the event.",
1057
1282
  fields: [{ name: "*" }],
1058
1283
  label: "Sample Event",
1059
- description: "Use case description for the event.",
1284
+ name: "plugin.sample_event",
1060
1285
  runtimeActions: ["my-package/handle-sample-event"]
1061
- }]
1286
+ }],
1287
+ provider: {
1288
+ description: "A description for your Commerce Events provider.",
1289
+ label: "Commerce Events Provider"
1290
+ }
1062
1291
  }],
1063
1292
  "eventing.external": [{
1064
- provider: {
1065
- label: "External Events Provider",
1066
- description: "A description for your External Events provider."
1067
- },
1068
1293
  events: [{
1069
- name: "be-observer.sample_event",
1070
- label: "Sample Event",
1071
1294
  description: "Use case description for the event.",
1295
+ label: "Sample Event",
1296
+ name: "be-observer.sample_event",
1072
1297
  runtimeActions: ["my-package/handle-sample-event"]
1073
- }]
1298
+ }],
1299
+ provider: {
1300
+ description: "A description for your External Events provider.",
1301
+ label: "External Events Provider"
1302
+ }
1074
1303
  }],
1075
1304
  "installation.customInstallationSteps": [{
1076
- name: "sample-step",
1077
1305
  description: "Use case description for the step.",
1306
+ name: "sample-step",
1078
1307
  script: "./path/to/script.js"
1079
1308
  }],
1080
1309
  webhooks: [{
1081
- label: "Sample Webhook",
1310
+ category: "modification",
1082
1311
  description: "A sample Commerce Webhook handler.",
1312
+ label: "Sample Webhook",
1083
1313
  runtimeAction: "my-package/handle-webhook",
1084
- category: "modification",
1085
1314
  webhook: {
1086
- webhook_method: "plugin.sample.event",
1087
- webhook_type: "after",
1088
1315
  batch_name: "my_app",
1089
1316
  hook_name: "sample_hook",
1090
- method: "POST"
1317
+ method: "POST",
1318
+ webhook_method: "plugin.sample.event",
1319
+ webhook_type: "after"
1091
1320
  }
1092
1321
  }, {
1093
- label: "Sample Webhook with URL",
1094
- description: "A sample Commerce Webhook handler using an explicit URL.",
1095
1322
  category: "modification",
1323
+ description: "A sample Commerce Webhook handler using an explicit URL.",
1324
+ label: "Sample Webhook with URL",
1096
1325
  webhook: {
1097
- webhook_method: "plugin.sample.event",
1098
- webhook_type: "after",
1099
1326
  batch_name: "my_app",
1100
1327
  hook_name: "sample_hook_url",
1101
1328
  method: "POST",
1102
- url: "https://example.com/webhook"
1329
+ url: "https://example.com/webhook",
1330
+ webhook_method: "plugin.sample.event",
1331
+ webhook_type: "after"
1103
1332
  }
1104
1333
  }]
1105
1334
  };
@@ -1121,31 +1350,29 @@ function initFlagsToScaffoldAppAnswers(flags) {
1121
1350
  }
1122
1351
  /** Prompt the user to scaffold a new Commerce App configuration. When options are provided, prompts are skipped. */
1123
1352
  async function promptForCommerceAppConfig() {
1124
- const configFormat = await consola.prompt("What format do you want to use for the config file?", {
1125
- type: "select",
1353
+ const configFormat = await consola$1.prompt("What format do you want to use for the config file?", {
1354
+ cancel: "reject",
1126
1355
  default: "ts",
1127
1356
  initial: "ts",
1128
- cancel: "reject",
1129
1357
  options: [{
1358
+ hint: "Recommended",
1130
1359
  label: "TypeScript",
1131
- value: "ts",
1132
- hint: "Recommended"
1360
+ value: "ts"
1133
1361
  }, {
1134
1362
  label: "JavaScript",
1135
1363
  value: "js"
1136
- }]
1364
+ }],
1365
+ type: "select"
1137
1366
  });
1138
- const appName = await consola.prompt("What is the name of your app?", {
1139
- type: "text",
1140
- placeholder: "Application Display Name",
1367
+ const appName = await consola$1.prompt("What is the name of your app?", {
1368
+ cancel: "reject",
1141
1369
  default: "My Application",
1142
- cancel: "reject"
1370
+ placeholder: "Application Display Name",
1371
+ type: "text"
1143
1372
  });
1144
- const featuresToAdd = await consola.prompt(`What features do you want to add to your app? ${colorize("gray", "Space to select/deselect, Enter to submit")}`, {
1145
- type: "multiselect",
1146
- initial: [],
1147
- required: true,
1373
+ const featuresToAdd = await consola$1.prompt(`What features do you want to add to your app? ${colorize("gray", "Space to select/deselect, Enter to submit")}`, {
1148
1374
  cancel: "reject",
1375
+ initial: [],
1149
1376
  options: [
1150
1377
  {
1151
1378
  label: "Business Configuration",
@@ -1167,16 +1394,18 @@ async function promptForCommerceAppConfig() {
1167
1394
  label: "Custom Installation Steps",
1168
1395
  value: "installation.customInstallationSteps"
1169
1396
  }
1170
- ]
1397
+ ],
1398
+ required: true,
1399
+ type: "multiselect"
1171
1400
  });
1172
1401
  const configFile = `${COMMERCE_APP_CONFIG_FILE}.${configFormat}`;
1173
1402
  const domains = new Set(featuresToAdd);
1174
- consola.log("");
1403
+ consola$1.log("");
1175
1404
  return {
1176
1405
  appName,
1177
1406
  configFile,
1178
- domains,
1179
- configFormat
1407
+ configFormat,
1408
+ domains
1180
1409
  };
1181
1410
  }
1182
1411
  /** Create the default commerce app config file content */
@@ -1185,10 +1414,10 @@ async function getDefaultCommerceAppConfig(cwd, { appName, configFormat, domains
1185
1414
  const exportKeyword = needsESM ? "export default" : "module.exports =";
1186
1415
  const importStatement = needsESM ? "import { defineConfig } from \"@adobe/aio-commerce-lib-app/config\";" : "const { defineConfig } = require(\"@adobe/aio-commerce-lib-app/config\");";
1187
1416
  const defaultConfig = { metadata: {
1188
- id: appName.toLowerCase().replace(/ /g, "-"),
1417
+ description: "A custom Adobe Commerce application. Fill description for your app.",
1189
1418
  displayName: appName,
1190
- version: "1.0.0",
1191
- description: "A custom Adobe Commerce application. Fill description for your app."
1419
+ id: appName.toLowerCase().replace(/ /g, "-"),
1420
+ version: "1.0.0"
1192
1421
  } };
1193
1422
  if (domains.has("businessConfig.schema")) defaultConfig.businessConfig = { schema: DOMAIN_DEFAULTS.businessConfig.schema };
1194
1423
  if (domains.has("eventing.commerce")) defaultConfig.eventing = {
@@ -1228,10 +1457,10 @@ async function addExtensionPointToAppConfig(extensionPointId, rootDirectory, com
1228
1457
  extensionPointId,
1229
1458
  "$include"
1230
1459
  ]) === includePath) {
1231
- consola.success(`Extension "${extensionPointId}" already configured in ${APP_CONFIG_FILE}`);
1460
+ consola$1.success(`Extension "${extensionPointId}" already configured in ${APP_CONFIG_FILE}`);
1232
1461
  return;
1233
1462
  }
1234
- consola.info(`Adding extension "${extensionPointId}" to ${APP_CONFIG_FILE}...`);
1463
+ consola$1.info(`Adding extension "${extensionPointId}" to ${APP_CONFIG_FILE}...`);
1235
1464
  const extensions = getOrCreateMap(doc, ["extensions"], { onBeforeCreate: (pair) => {
1236
1465
  pair.key.spaceBefore = true;
1237
1466
  } });
@@ -1261,10 +1490,10 @@ async function addExtensionPointToInstallYaml(extensionPointId, rootDirectory, c
1261
1490
  throw new Error(`Failed to parse ${INSTALL_YAML_FILE}. \nPlease add manually: \n\n${fallbackContent}`, { cause: error });
1262
1491
  }
1263
1492
  if (extensions.items.some((item) => isMap(item) && item.get("extensionPointId") === extensionPointId)) {
1264
- consola.success(`Extension "${extensionPointId}" already configured in ${INSTALL_YAML_FILE}`);
1493
+ consola$1.success(`Extension "${extensionPointId}" already configured in ${INSTALL_YAML_FILE}`);
1265
1494
  return;
1266
1495
  }
1267
- consola.info(`Adding extension "${extensionPointId}" to ${INSTALL_YAML_FILE}...`);
1496
+ consola$1.info(`Adding extension "${extensionPointId}" to ${INSTALL_YAML_FILE}...`);
1268
1497
  const extension = doc.createPair("extensionPointId", extensionPointId);
1269
1498
  extension.key.spaceBefore = extensions.items.length > 0;
1270
1499
  extension.key.commentBefore = commentBefore;
@@ -1282,7 +1511,7 @@ async function ensureCommerceAppConfig(cwd = process.cwd(), formatConfig = true,
1282
1511
  } catch {}
1283
1512
  if (config) try {
1284
1513
  const validatedConfig = validateCommerceAppConfig(config);
1285
- consola$1.success(`${COMMERCE_APP_CONFIG_FILE} found and is valid. Continuing...`);
1514
+ consola.success(`${COMMERCE_APP_CONFIG_FILE} found and is valid. Continuing...`);
1286
1515
  return {
1287
1516
  config: validatedConfig,
1288
1517
  domains: getConfigDomains(validatedConfig)
@@ -1291,24 +1520,24 @@ async function ensureCommerceAppConfig(cwd = process.cwd(), formatConfig = true,
1291
1520
  throw new Error(`${COMMERCE_APP_CONFIG_FILE} is invalid`, { cause: error });
1292
1521
  }
1293
1522
  if (!flags) {
1294
- consola$1.warn(`${COMMERCE_APP_CONFIG_FILE} not found.`);
1295
- if (!await consola$1.prompt(`Do you want to create a ${"app.commerce.config"} file? (y/n)`, {
1296
- type: "confirm",
1523
+ consola.warn(`${COMMERCE_APP_CONFIG_FILE} not found.`);
1524
+ if (!await consola.prompt(`Do you want to create a ${"app.commerce.config"} file? (y/n)`, {
1525
+ default: false,
1297
1526
  initial: true,
1298
- default: false
1527
+ type: "confirm"
1299
1528
  })) throw new Error("Initialization cancelled.");
1300
1529
  }
1301
1530
  const answers = flags ? initFlagsToScaffoldAppAnswers(flags) : await promptForCommerceAppConfig();
1302
1531
  try {
1303
1532
  const configContent = await getDefaultCommerceAppConfig(cwd, answers);
1304
1533
  const path = join(await getProjectRootDirectory(cwd), answers.configFile);
1305
- consola$1.info(`Creating ${answers.configFile}...`);
1534
+ consola.info(`Creating ${answers.configFile}...`);
1306
1535
  if (formatConfig) await writeFile(path, await prettierFormat(configContent, path), "utf-8");
1307
1536
  else await writeFile(path, configContent, "utf-8");
1308
- const config = await parseCommerceAppConfig(cwd);
1309
- consola$1.success(`Created ${answers.configFile}`);
1537
+ const createdConfig = await parseCommerceAppConfig(cwd);
1538
+ consola.success(`Created ${answers.configFile}`);
1310
1539
  return {
1311
- config,
1540
+ config: createdConfig,
1312
1541
  domains: answers.domains
1313
1542
  };
1314
1543
  } catch (error) {
@@ -1324,21 +1553,20 @@ async function ensurePackageJson(cwd = process.cwd()) {
1324
1553
  let packageJson;
1325
1554
  if (existing) packageJson = existing;
1326
1555
  else {
1327
- consola$1.warn("package.json not found. Creating one...");
1556
+ consola.warn("package.json not found. Creating one...");
1328
1557
  packageJson = {
1329
1558
  name: "my-commerce-app",
1330
- version: "1.0.0",
1331
- private: true
1559
+ private: true,
1560
+ version: "1.0.0"
1332
1561
  };
1333
1562
  await writeFile(join(resolve(cwd), PACKAGE_JSON_FILE), JSON.stringify(packageJson, null, 2), "utf-8");
1334
- consola$1.success("Wrote package.json");
1563
+ consola.success("Wrote package.json");
1335
1564
  }
1336
1565
  const packageManager = await detectPackageManager(cwd);
1337
- const execCommand = getExecCommand(packageManager);
1338
1566
  return {
1567
+ execCommand: getExecCommand(packageManager),
1339
1568
  packageJson,
1340
- packageManager,
1341
- execCommand
1569
+ packageManager
1342
1570
  };
1343
1571
  }
1344
1572
  /**
@@ -1348,50 +1576,31 @@ async function ensurePackageJson(cwd = process.cwd()) {
1348
1576
  */
1349
1577
  async function writePostinstallHook(execCommand, cwd = process.cwd()) {
1350
1578
  const postinstallScript = `${execCommand} aio-commerce-lib-app hooks postinstall`;
1351
- const pkg = await NpmPackageJson.load(cwd);
1579
+ const pkg = await loadPackageJson(cwd);
1580
+ if (pkg === null) throw new Error("Could not find package.json.");
1352
1581
  const existing = pkg.content.scripts?.postinstall;
1353
1582
  if (existing === postinstallScript || existing?.includes(postinstallScript)) {
1354
- consola$1.success(`postinstall script already configured in ${PACKAGE_JSON_FILE}`);
1583
+ consola.success(`postinstall script already configured in ${PACKAGE_JSON_FILE}`);
1355
1584
  return;
1356
1585
  }
1357
1586
  const nextPostinstall = existing ? `${existing} && ${postinstallScript}` : postinstallScript;
1358
- if (existing) consola$1.warn(`${PACKAGE_JSON_FILE} already has a postinstall script. Adding a new one...`);
1359
- else consola$1.info(`Adding postinstall script to ${PACKAGE_JSON_FILE}...`);
1587
+ if (existing) consola.warn(`${PACKAGE_JSON_FILE} already has a postinstall script. Adding a new one...`);
1588
+ else consola.info(`Adding postinstall script to ${PACKAGE_JSON_FILE}...`);
1360
1589
  pkg.update({ scripts: {
1361
1590
  ...pkg.content.scripts,
1362
1591
  postinstall: nextPostinstall
1363
1592
  } });
1364
1593
  await pkg.save();
1365
- consola$1.success(`Added postinstall script to ${PACKAGE_JSON_FILE}`);
1594
+ consola.success(`Added postinstall script to ${PACKAGE_JSON_FILE}`);
1366
1595
  }
1367
1596
  /** Ensure app.config.yaml has the extension reference */
1368
1597
  async function ensureAppConfig(domains, cwd = process.cwd()) {
1369
1598
  const rootDirectory = await getProjectRootDirectory(cwd);
1370
1599
  if (domains.has("businessConfig.schema")) await addExtensionPointToAppConfig(CONFIGURATION_EXTENSION_POINT_ID, rootDirectory, " This extension is required for business configuration. Do not remove.");
1371
- if (domains.has("adminUiSdk")) await addExtensionPointToAppConfig(BACKEND_UI_EXTENSION_POINT_ID, rootDirectory, " This extension is required for Admin UI SDK. Do not remove.");
1600
+ if (domains.has("adminUi")) await addExtensionPointToAppConfig(BACKEND_UI_V2_EXTENSION_POINT_ID, rootDirectory, " This extension is required for Admin UI. Do not remove.");
1372
1601
  await addExtensionPointToAppConfig(EXTENSIBILITY_EXTENSION_POINT_ID, rootDirectory, " This extension is required for app management. Do not remove.");
1373
1602
  }
1374
1603
  /**
1375
- * Install the given dependencies.
1376
- * @param packageManager - The detected package manager
1377
- * @param dependencies - Package specifiers to install; no-op when empty
1378
- * @param cwd - Working directory for the install command
1379
- */
1380
- function runInstall(packageManager, dependencies, cwd = process.cwd()) {
1381
- if (dependencies.length === 0) return;
1382
- const dependencyListString = dependencies.map((dependency) => ` - ${dependency}`).join("\n");
1383
- consola$1.start([`Installing the following dependencies with ${packageManager}:\n${dependencyListString}\n`, "This may take a few seconds...\n"].join("\n"));
1384
- const { command, args } = getInstallCommand(packageManager, dependencies);
1385
- const displayCommand = [command, ...args].join(" ");
1386
- const result = spawnSync(command, args, {
1387
- cwd,
1388
- stdio: "inherit"
1389
- });
1390
- if (result.error || result.status !== 0) throw new Error(`Failed to install dependencies automatically. Please install manually: ${displayCommand}`, { cause: result.error ?? /* @__PURE__ */ new Error(`Install exited with code ${result.status}`) });
1391
- consola$1.log("");
1392
- consola$1.success("Dependencies installed successfully");
1393
- }
1394
- /**
1395
1604
  * Install the domain-specific dependencies derived from the selected domains.
1396
1605
  * @param packageManager - The detected package manager
1397
1606
  * @param domains - Domains enabled in the commerce app config
@@ -1399,9 +1608,9 @@ function runInstall(packageManager, dependencies, cwd = process.cwd()) {
1399
1608
  */
1400
1609
  function installDependencies(packageManager, domains, cwd = process.cwd()) {
1401
1610
  const packages = [];
1402
- if (domains.has("businessConfig.schema")) packages.push(`@adobe/aio-commerce-lib-config@^1.5.0`);
1611
+ if (domains.has("businessConfig.schema")) packages.push(`@adobe/aio-commerce-lib-config@^1.6.0-beta-20260714082406`);
1403
1612
  if (packages.length === 0) {
1404
- consola$1.info("No additional domain dependencies to install.");
1613
+ consola.info("No additional domain dependencies to install.");
1405
1614
  return;
1406
1615
  }
1407
1616
  runInstall(packageManager, packages, cwd);
@@ -1420,33 +1629,34 @@ async function runGeneration(appConfig, execCommand) {
1420
1629
  async function ensureInstallYaml(domains, cwd = process.cwd()) {
1421
1630
  const rootDirectory = await getProjectRootDirectory(cwd);
1422
1631
  if (domains.has("businessConfig.schema")) await addExtensionPointToInstallYaml(CONFIGURATION_EXTENSION_POINT_ID, rootDirectory, " This extension is required for business configuration. Do not remove.");
1423
- if (domains.has("adminUiSdk")) await addExtensionPointToInstallYaml(BACKEND_UI_EXTENSION_POINT_ID, rootDirectory, " This extension is required for Admin UI SDK. Do not remove.");
1632
+ if (domains.has("adminUi")) await addExtensionPointToInstallYaml(BACKEND_UI_V2_EXTENSION_POINT_ID, rootDirectory, " This extension is required for Admin UI. Do not remove.");
1424
1633
  await addExtensionPointToInstallYaml(EXTENSIBILITY_EXTENSION_POINT_ID, rootDirectory, " This extension is required for app management. Do not remove.");
1425
1634
  }
1426
1635
 
1427
1636
  //#endregion
1428
1637
  //#region source/commands/init/main.ts
1429
- const REQUIRED_DEPENDENCIES = ["@adobe/aio-commerce-sdk", `@adobe/aio-commerce-lib-app@1.6.0`];
1638
+ const REQUIRED_DEPENDENCIES = ["@adobe/aio-commerce-sdk", `@adobe/aio-commerce-lib-app@1.8.0-beta-20260714082406`];
1430
1639
  /** Initialize the project */
1431
1640
  async function run(flags, extraOptions) {
1432
- consola$1.start("Initializing app...");
1641
+ consola.start("Initializing app...");
1433
1642
  const { execCommand, packageManager } = await ensurePackageJson();
1434
1643
  runInstall(packageManager, REQUIRED_DEPENDENCIES);
1435
1644
  const { config, domains } = await ensureCommerceAppConfig(process.cwd(), extraOptions?.formatConfig ?? true, flags);
1436
1645
  installDependencies(packageManager, domains);
1437
- const pkg = await NpmPackageJson.load(process.cwd());
1646
+ const pkg = await loadPackageJson(process.cwd());
1647
+ if (pkg === null) throw new Error("Could not find package.json.");
1438
1648
  pkg.update({
1649
+ description: config.metadata.description,
1439
1650
  name: config.metadata.id,
1440
- version: config.metadata.version,
1441
- description: config.metadata.description
1651
+ version: config.metadata.version
1442
1652
  });
1443
1653
  await pkg.save();
1444
1654
  await runGeneration(config, execCommand);
1445
1655
  await ensureAppConfig(domains);
1446
1656
  await ensureInstallYaml(domains);
1447
1657
  await writePostinstallHook(execCommand);
1448
- consola$1.success("Initialization complete!");
1449
- consola$1.box([
1658
+ consola.success("Initialization complete!");
1659
+ consola.box([
1450
1660
  "Next steps:",
1451
1661
  " - Review and customize app.commerce.config.*",
1452
1662
  " - Build and deploy your app"
@@ -1457,8 +1667,8 @@ async function exec() {
1457
1667
  try {
1458
1668
  await run();
1459
1669
  } catch (error) {
1460
- if (error instanceof CommerceSdkValidationError) consola$1.error(error.display());
1461
- else consola$1.error(error);
1670
+ if (error instanceof CommerceSdkValidationError) consola.error(error.display());
1671
+ else consola.error(error);
1462
1672
  process.exit(1);
1463
1673
  }
1464
1674
  }
@@ -1496,17 +1706,17 @@ async function generateAll() {
1496
1706
  }
1497
1707
  /** Command handlers registry mapping command names to their subcommand handlers */
1498
1708
  const COMMANDS = {
1499
- init: exec,
1500
- hooks: {
1501
- "pre-app-build": exec$1,
1502
- postinstall: exec$2
1503
- },
1504
1709
  generate: {
1505
1710
  actions: exec$5,
1711
+ all: generateAll,
1506
1712
  manifest: exec$4,
1507
- schema: exec$3,
1508
- all: generateAll
1509
- }
1713
+ schema: exec$3
1714
+ },
1715
+ hooks: {
1716
+ postinstall: exec$2,
1717
+ "pre-app-build": exec$1
1718
+ },
1719
+ init: exec
1510
1720
  };
1511
1721
  /**
1512
1722
  * Generic command handler that dispatches to specific command implementations
@@ -1516,8 +1726,8 @@ const COMMANDS = {
1516
1726
  */
1517
1727
  async function handleCommand(commandName, target, handlers) {
1518
1728
  function invalidTargetError(message) {
1519
- consola.error(message);
1520
- consola.info(`Available targets: ${Object.keys(handlers).join(" | ")}`);
1729
+ consola$1.error(message);
1730
+ consola$1.info(`Available targets: ${Object.keys(handlers).join(" | ")}`);
1521
1731
  process.exit(1);
1522
1732
  }
1523
1733
  if (!target) invalidTargetError(`No ${commandName} target specified`);
@@ -1527,14 +1737,14 @@ async function handleCommand(commandName, target, handlers) {
1527
1737
  }
1528
1738
  async function main() {
1529
1739
  if (!command || command === "help" || command === "--help" || command === "-h") {
1530
- consola.log.raw(USAGE);
1740
+ consola$1.log.raw(USAGE);
1531
1741
  process.exit(0);
1532
1742
  }
1533
1743
  try {
1534
1744
  const handlers = COMMANDS[command];
1535
1745
  if (!handlers) {
1536
- consola.error(`Unknown command: ${command}`);
1537
- consola.log.raw(USAGE);
1746
+ consola$1.error(`Unknown command: ${command}`);
1747
+ consola$1.log.raw(USAGE);
1538
1748
  process.exit(1);
1539
1749
  }
1540
1750
  if (typeof handlers === "function") {
@@ -1543,7 +1753,7 @@ async function main() {
1543
1753
  }
1544
1754
  await handleCommand(command, subcommand, handlers);
1545
1755
  } catch (error) {
1546
- consola.error(stringifyError(error));
1756
+ consola$1.error(stringifyError(error));
1547
1757
  }
1548
1758
  }
1549
1759
  main();