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