@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,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');
17
- const require_webhooks = require('../webhooks-tbZy9G3p.cjs');
18
- const require_validate = require('../validate-DydOAZha.cjs');
19
- const require_logging = require('../logging-BVz3weoC.cjs');
16
+ const require_rolldown_runtime = require('../rolldown-runtime-Cozy-1ZF.cjs');
20
17
  const require_error = require('../error-D-N0PKSl.cjs');
21
- const require_config = require('../config-FNMclIFO.cjs');
22
- let _adobe_aio_commerce_lib_config = require("@adobe/aio-commerce-lib-config");
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');
23
22
  let _adobe_aio_commerce_lib_core_error = require("@adobe/aio-commerce-lib-core/error");
24
- let consola = require("consola");
25
- consola = require_chunk.__toESM(consola, 1);
23
+ let _adobe_aio_commerce_lib_config = require("@adobe/aio-commerce-lib-config");
26
24
  let path = require("path");
27
- path = require_chunk.__toESM(path, 1);
28
- let prettier = require("prettier");
29
- prettier = require_chunk.__toESM(prettier, 1);
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,
203
- function: `${GENERATED_ACTIONS_PATH}/${actionName}.js`,
204
- web: options.web ?? "yes",
205
- runtime: "nodejs:22",
206
300
  annotations: {
207
- "require-adobe-auth": true,
208
- final: true
209
- }
301
+ final: true,
302
+ "require-adobe-auth": true
303
+ },
304
+ function: `${GENERATED_ACTIONS_PATH}/${actionName}.js`,
305
+ runtime: "nodejs:24",
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,32 +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
- const features = require_validate.getConfigDomains(appConfig);
233
- const hasPasswordFieldsInSchema = require_validate.hasBusinessConfigSchema(appConfig) && appConfig.businessConfig.schema.some((field) => field.type === "password");
234
330
  const extConfig = {
235
331
  hooks: { "pre-app-build": "EXTENSION=extensibility/1 $packageExec aio-commerce-lib-app hooks pre-app-build" },
236
332
  operations: { workerProcess: [{
237
- type: "action",
238
- impl: `${PACKAGE_NAME}/app-config`
333
+ impl: `${PACKAGE_NAME}/app-config`,
334
+ type: "action"
335
+ }, {
336
+ impl: `${PACKAGE_NAME}/association`,
337
+ type: "action"
239
338
  }] },
240
339
  runtimeManifest: { packages: { [PACKAGE_NAME]: {
241
- license: "Apache-2.0",
242
- actions: { "app-config": createActionDefinition("app-config") }
340
+ actions: {
341
+ "app-config": createActionDefinition("app-config"),
342
+ association: createActionDefinition("association")
343
+ },
344
+ license: "Apache-2.0"
243
345
  } } }
244
346
  };
245
- if ([
246
- "installation.customInstallationSteps",
247
- "eventing.commerce",
248
- "eventing.external",
249
- "webhooks",
250
- "adminUiSdk"
251
- ].some((feature) => features.has(feature))) {
347
+ const needsInstallAction = require_validate.requiresInstallation(appConfig);
348
+ const hasPasswordFieldsInSchema = require_validate.hasBusinessConfigSchema(appConfig) && appConfig.businessConfig.schema.some((field) => field.type === "password");
349
+ if (needsInstallAction) {
252
350
  extConfig.operations.workerProcess.push({
253
- type: "action",
254
- impl: `${PACKAGE_NAME}/installation`
351
+ impl: `${PACKAGE_NAME}/installation`,
352
+ type: "action"
255
353
  });
256
354
  extConfig.runtimeManifest.packages[PACKAGE_NAME].actions.installation = createActionDefinition("installation", { requiresEncryptionKey: hasPasswordFieldsInSchema }, {
257
355
  inputs: {
@@ -267,8 +365,8 @@ function buildAppManagementExtConfig(appConfig) {
267
365
  function buildBusinessConfigurationExtConfig() {
268
366
  const actions = [{
269
367
  name: "config",
270
- templateFile: "config.js.template",
271
- requiresEncryptionKey: true
368
+ requiresEncryptionKey: true,
369
+ templateFile: "config.js.template"
272
370
  }, {
273
371
  name: "scope-tree",
274
372
  templateFile: "scope-tree.js.template"
@@ -276,38 +374,64 @@ function buildBusinessConfigurationExtConfig() {
276
374
  return {
277
375
  hooks: { "pre-app-build": "EXTENSION=configuration/1 $packageExec aio-commerce-lib-app hooks pre-app-build" },
278
376
  operations: { workerProcess: actions.map((action) => ({
279
- type: "action",
280
- impl: `${PACKAGE_NAME}/${action.name}`
377
+ impl: `${PACKAGE_NAME}/${action.name}`,
378
+ type: "action"
281
379
  })) },
282
380
  runtimeManifest: { packages: { [PACKAGE_NAME]: {
283
- license: "Apache-2.0",
284
- 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"
285
383
  } } }
286
384
  };
287
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
+ }
288
412
  /**
289
- * 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.
290
417
  */
291
- function buildAdminUiSdkExtConfig() {
418
+ function buildAdminUiV2ExtConfig(appConfig) {
419
+ const { adminUi } = appConfig;
420
+ const runtimeActions = collectUniqueRuntimeActions(adminUi);
421
+ const requiresWeb = requiresWebSource(adminUi);
292
422
  return {
293
- hooks: { "pre-app-build": "EXTENSION=backend-ui/1 $packageExec aio-commerce-lib-app hooks pre-app-build" },
294
- operations: { view: [{
295
- type: "web",
296
- impl: "index.html"
297
- }] },
298
- web: "web-src",
299
- runtimeManifest: { packages: { [ADMIN_UI_SDK_PACKAGE_NAME]: {
300
- license: "Apache-2.0",
301
- actions: { registration: {
302
- function: `${ADMIN_UI_SDK_ACTIONS_PATH}/index.js`,
303
- web: "yes",
304
- runtime: "nodejs:22",
305
- annotations: {
306
- "require-adobe-auth": true,
307
- final: true
308
- }
309
- } }
310
- } } }
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" }
311
435
  };
312
436
  }
313
437
 
@@ -321,9 +445,9 @@ async function readYamlFile(path$5) {
321
445
  let doc = new yaml.Document();
322
446
  if ((0, fs.existsSync)(path$5)) try {
323
447
  doc = (0, yaml.parseDocument)(await (0, fs_promises.readFile)(path$5, "utf-8"), { keepSourceTokens: true });
324
- } catch {
448
+ } catch (err) {
325
449
  const file = (0, path.basename)(path$5);
326
- throw new Error(`Failed to parse ${file}`);
450
+ throw new Error(`Failed to parse ${file}`, { cause: err });
327
451
  }
328
452
  if (doc.contents === null) doc.contents = new yaml.YAMLMap();
329
453
  return doc;
@@ -357,8 +481,8 @@ function getOrCreateNode(doc, path$6, options, typeConfig) {
357
481
  */
358
482
  function getOrCreateSeq(doc, path$7, options) {
359
483
  return getOrCreateNode(doc, path$7, options ?? {}, {
360
- typeGuard: yaml.isSeq,
361
484
  createNode: () => new yaml.YAMLSeq(),
485
+ typeGuard: yaml.isSeq,
362
486
  typeName: "sequence"
363
487
  });
364
488
  }
@@ -370,8 +494,8 @@ function getOrCreateSeq(doc, path$7, options) {
370
494
  */
371
495
  function getOrCreateMap(doc, path$8, options) {
372
496
  return getOrCreateNode(doc, path$8, options ?? {}, {
373
- typeGuard: yaml.isMap,
374
497
  createNode: () => new yaml.YAMLMap(),
498
+ typeGuard: yaml.isMap,
375
499
  typeName: "map"
376
500
  });
377
501
  }
@@ -415,10 +539,9 @@ async function createOrUpdateExtConfig(path, config, doc) {
415
539
  const extConfigDoc = doc ?? new yaml.Document({});
416
540
  if (config.web !== void 0) buildWeb(extConfigDoc, config.web);
417
541
  config.hooks ??= {};
418
- config.runtimeManifest ??= { packages: {} };
419
542
  await buildHooks(extConfigDoc, config.hooks);
420
543
  if (config.operations !== void 0) buildOperations(extConfigDoc, config.operations);
421
- buildRuntimeManifest(extConfigDoc, config.runtimeManifest);
544
+ if (config.runtimeManifest !== void 0) buildRuntimeManifest(extConfigDoc, config.runtimeManifest);
422
545
  await writeExtConfig(path, extConfigDoc);
423
546
  return extConfigDoc;
424
547
  }
@@ -450,15 +573,15 @@ function buildActionDefinition(action, existingAction) {
450
573
  const managedInputs = { LOG_LEVEL: "$LOG_LEVEL" };
451
574
  actionDef.set("function", action.function);
452
575
  actionDef.set("web", action.web ?? "yes");
453
- actionDef.set("runtime", existingRuntime ?? action.runtime ?? "nodejs:22");
576
+ actionDef.set("runtime", existingRuntime ?? action.runtime ?? "nodejs:24");
454
577
  actionDef.set("inputs", {
455
578
  ...existingInputs,
456
579
  ...managedInputs,
457
580
  ...action.inputs ?? {}
458
581
  });
459
582
  actionDef.set("annotations", { ...action.annotations ?? {
460
- "require-adobe-auth": true,
461
- final: true
583
+ final: true,
584
+ "require-adobe-auth": true
462
585
  } });
463
586
  const includes = action.include ?? [];
464
587
  if (includes.length > 0) {
@@ -515,10 +638,11 @@ function buildOperations(extConfig, operations) {
515
638
  * @param packages - The packages to build
516
639
  */
517
640
  function buildRuntimeManifest(extConfig, manifest) {
641
+ const packages = manifest.packages ?? {};
642
+ if (Object.keys(packages).length === 0) return;
518
643
  getOrCreateMap(extConfig, ["runtimeManifest"], { onBeforeCreate: (pair) => {
519
644
  pair.key.spaceBefore = true;
520
645
  } });
521
- const packages = manifest.packages ?? {};
522
646
  getOrCreateMap(extConfig, ["runtimeManifest", "packages"]);
523
647
  for (const [name, pkg] of Object.entries(packages)) {
524
648
  const packageDef = getOrCreateMap(extConfig, [
@@ -550,7 +674,7 @@ async function buildHooks(extConfig, hooks) {
550
674
  pair.key.spaceBefore = true;
551
675
  pair.key.commentBefore = ` The ${generatedHooks} hooks are auto-generated. Do not remove or manually edit.`;
552
676
  } });
553
- const execCommand = require_config.getExecCommand(await require_config.detectPackageManager());
677
+ const execCommand = require_index_node.getExecCommand(await require_index_node.detectPackageManager());
554
678
  for (const [name, command] of Object.entries(hooks)) {
555
679
  const fullCommand = `${command.replaceAll("$packageExec", execCommand)}`;
556
680
  const prevValue = (hooksMap.get(name) ?? "").trim();
@@ -566,26 +690,15 @@ async function buildHooks(extConfig, hooks) {
566
690
  */
567
691
  async function writeExtConfig(configPath, doc) {
568
692
  await (0, fs_promises.writeFile)(configPath, doc.toString({
693
+ defaultStringType: "PLAIN",
569
694
  indent: 2,
570
- lineWidth: 0,
571
- defaultStringType: "PLAIN"
695
+ lineWidth: 0
572
696
  }), "utf-8");
573
697
  }
574
698
 
575
699
  //#endregion
576
700
  //#region source/commands/generate/actions/lib.ts
577
- const __dirname$1 = (0, path.dirname)((0, url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
578
- /** The path to the action templates directory, sibling to this file. */
579
- const TEMPLATES_DIR = (0, path.join)(__dirname$1, "templates");
580
- const TYPESCRIPT_CONFIG_EXTENSIONS = new Set([
581
- ".ts",
582
- ".mts",
583
- ".cts"
584
- ]);
585
701
  const LEADING_DOT_SLASH_PATTERN = /^\.\//u;
586
- const DYNAMIC_APP_CONFIG_IMPORT = `import appConfig from "${APP_CONFIG_IMPORT_ALIAS}";`;
587
- const STATIC_APP_MANIFEST_IMPORT = "import appConfig from \"../../app.commerce.manifest.json\" with { type: \"json\" };";
588
- const STATIC_CONFIG_SCHEMA_IMPORT = "import configSchema from \"../../configuration-schema.json\" with { type: \"json\" };";
589
702
  /** Normalize a path for use as an ESM import specifier. */
590
703
  function normalizeImportPath(path$3) {
591
704
  const normalizedPath = path$3.split(path.sep).join("/");
@@ -597,7 +710,8 @@ function normalizePackageJsonPath(path$4) {
597
710
  }
598
711
  /** Add or update the package import alias used by dynamic generated actions. */
599
712
  async function updateAppConfigImportAlias(projectRoot, runtimeConfigPath) {
600
- 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.");
601
715
  const existingImports = typeof pkg.content.imports === "object" && pkg.content.imports !== null ? pkg.content.imports : {};
602
716
  pkg.update({ imports: {
603
717
  ...existingImports,
@@ -605,24 +719,13 @@ async function updateAppConfigImportAlias(projectRoot, runtimeConfigPath) {
605
719
  } });
606
720
  await pkg.save();
607
721
  }
608
- /** Remove the package import alias used only by dynamic generated actions. */
609
- async function deleteAppConfigImportAlias(projectRoot) {
610
- const pkg = await _npmcli_package_json.default.load(projectRoot);
611
- const existingImports = typeof pkg.content.imports === "object" && pkg.content.imports !== null ? pkg.content.imports : {};
612
- if (!("#app.commerce.config" in existingImports)) return;
613
- const imports = { ...existingImports };
614
- delete imports[APP_CONFIG_IMPORT_ALIAS];
615
- if (Object.keys(imports).length > 0) pkg.update({ imports });
616
- else pkg.content.imports = void 0;
617
- await pkg.save();
618
- }
619
- /** Write an ESM passthrough module for JavaScript app config files. */
722
+ /** Write an ESM passthrough module that re-exports an app config file. */
620
723
  async function writeJavaScriptAppConfigModule(configFilePath, outputPath) {
621
724
  await (0, fs_promises.writeFile)(outputPath, [
622
725
  "// This file has been auto-generated by `@adobe/aio-commerce-lib-app`",
623
726
  "// Do not modify this file directly",
624
727
  "",
625
- `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\" }" : ""};`,
626
729
  "",
627
730
  "export default appConfig;",
628
731
  ""
@@ -631,23 +734,23 @@ async function writeJavaScriptAppConfigModule(configFilePath, outputPath) {
631
734
  /** Bundle a TypeScript app config file into runtime-safe ESM. */
632
735
  async function bundleTypeScriptAppConfigModule(configFilePath, outputPath) {
633
736
  await (0, esbuild.build)({
634
- entryPoints: [configFilePath],
635
- outfile: outputPath,
636
737
  bundle: true,
738
+ entryPoints: [configFilePath],
637
739
  format: "esm",
638
- platform: "node",
639
- target: "node22",
740
+ logLevel: "silent",
741
+ outfile: outputPath,
640
742
  packages: "external",
641
- logLevel: "silent"
743
+ platform: "node",
744
+ target: "node22"
642
745
  });
643
746
  }
644
747
  /** Generate the runtime-safe app config module used by generated runtime actions. */
645
748
  async function generateRuntimeAppConfigModule() {
646
- const projectRoot = await require_config.getProjectRootDirectory();
749
+ const projectRoot = await require_index_node.getProjectRootDirectory();
647
750
  const runtimeConfigPath = getRuntimeAppConfigPath();
648
- await require_config.makeOutputDirFor((0, path.dirname)(runtimeConfigPath));
751
+ await require_index_node.makeOutputDirFor((0, path.dirname)(runtimeConfigPath));
649
752
  const outputPath = (0, path.join)(projectRoot, runtimeConfigPath);
650
- const configFilePath = await require_config.resolveCommerceAppConfig(projectRoot);
753
+ const configFilePath = await require_index_node.resolveCommerceAppConfig(projectRoot);
651
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.");
652
755
  consola.consola.info("Generating JS config module...");
653
756
  if (TYPESCRIPT_CONFIG_EXTENSIONS.has((0, path.extname)(configFilePath))) await bundleTypeScriptAppConfigModule(configFilePath, outputPath);
@@ -655,41 +758,41 @@ async function generateRuntimeAppConfigModule() {
655
758
  await updateAppConfigImportAlias(projectRoot, runtimeConfigPath);
656
759
  consola.consola.success(`Generated JS config module: ${(0, path.relative)(process.cwd(), outputPath)}`);
657
760
  }
658
- /** Remove the generated app config module when generated actions use static JSON. */
659
- async function cleanupRuntimeAppConfigModule() {
660
- const projectRoot = await require_config.getProjectRootDirectory();
661
- await (0, fs_promises.rm)((0, path.join)(projectRoot, getRuntimeAppConfigPath()), { force: true });
662
- 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);
663
772
  }
664
773
  /**
665
774
  * Prepare runtime-side config artifacts consumed by generated actions: the
666
775
  * bundled ESM module and its `#app.commerce.config` package import alias.
667
776
  *
668
- * 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.
669
778
  */
670
779
  async function prepareRuntimeAppConfigModule(appManifest) {
671
780
  if (hasDynamicAppConfig(appManifest)) {
672
781
  await generateRuntimeAppConfigModule();
673
782
  return;
674
783
  }
675
- await cleanupRuntimeAppConfigModule();
676
- }
677
- /** Switch static JSON imports to the generated runtime config module for dynamic schemas. */
678
- function applyRuntimeAppConfigImport(template, actionName) {
679
- if (actionName === "app-config" || actionName === "installation") return template.replace(STATIC_APP_MANIFEST_IMPORT, DYNAMIC_APP_CONFIG_IMPORT);
680
- if (actionName === "config") return template.replace(STATIC_CONFIG_SCHEMA_IMPORT, DYNAMIC_APP_CONFIG_IMPORT).replace("const args = { configSchema };", "const args = { configSchema: appConfig.businessConfig.schema };");
681
- return template;
784
+ await prepareStaticAppConfigImportAlias();
682
785
  }
683
786
  /**
684
787
  * Read an extension point's ext.config.yaml file and return it as a JS object.
685
788
  * @param extensionPointId - The extension point ID to read the config for.
686
789
  */
687
790
  async function readExtConfig(extensionPointId) {
688
- const extConfigPath = (0, path.join)(await require_config.getProjectRootDirectory(), getExtConfigPath(extensionPointId));
791
+ const extConfigPath = (0, path.join)(await require_index_node.getProjectRootDirectory(), getExtConfigPath(extensionPointId));
689
792
  try {
690
793
  return {
691
- path: extConfigPath,
692
- doc: await readYamlFile(extConfigPath)
794
+ doc: await readYamlFile(extConfigPath),
795
+ path: extConfigPath
693
796
  };
694
797
  } catch (error) {
695
798
  const reason = error instanceof Error ? error.message : "Unexpected error while reading the file.";
@@ -697,13 +800,13 @@ async function readExtConfig(extensionPointId) {
697
800
  `Could not read ext.config.yaml for ${extensionPointId} at ${extConfigPath}.`,
698
801
  `Make sure the file exists and is valid YAML. You can regenerate it with "aio-commerce-lib-app generate actions".`,
699
802
  `Reason: ${reason}`
700
- ].join("\n"));
803
+ ].join("\n"), { cause: error });
701
804
  }
702
805
  }
703
806
  /** Update the ext.config.yaml file */
704
807
  async function updateExtConfig(appConfig, extensionPointId) {
705
808
  consola.consola.info(`Updating ext.config.yaml for ${extensionPointId}...`);
706
- await require_config.makeOutputDirFor(getExtensionPointFolderPath(extensionPointId));
809
+ await require_index_node.makeOutputDirFor(getExtensionPointFolderPath(extensionPointId));
707
810
  const { path: extConfigPath, doc: extConfigDoc } = await readExtConfig(extensionPointId);
708
811
  let extConfig;
709
812
  switch (extensionPointId) {
@@ -713,31 +816,162 @@ async function updateExtConfig(appConfig, extensionPointId) {
713
816
  case CONFIGURATION_EXTENSION_POINT_ID:
714
817
  extConfig = buildBusinessConfigurationExtConfig();
715
818
  break;
716
- case BACKEND_UI_EXTENSION_POINT_ID:
717
- extConfig = buildAdminUiSdkExtConfig();
819
+ case BACKEND_UI_V2_EXTENSION_POINT_ID:
820
+ extConfig = buildAdminUiV2ExtConfig(appConfig);
718
821
  break;
719
822
  }
720
823
  await createOrUpdateExtConfig(extConfigPath, extConfig, extConfigDoc);
721
824
  return extConfig;
722
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
+ }
723
960
  /** Generate the action files */
724
961
  async function generateActionFiles(appManifest, actions, extensionPointId, templatesDir) {
725
962
  consola.consola.start("Generating runtime actions...");
726
- await require_config.makeOutputDirFor(getActionsDir(extensionPointId));
727
- const projectRoot = await require_config.getProjectRootDirectory();
728
- const outputFiles = [];
729
- const useDynamicImports = hasDynamicAppConfig(appManifest);
730
- 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) => {
731
966
  let template = await (0, fs_promises.readFile)((0, path.join)(templatesDir, action.templateFile), "utf-8");
732
- if (useDynamicImports) template = applyRuntimeAppConfigImport(template, action.name);
733
967
  if (action.name === "installation") {
734
968
  const scriptsTemplate = await generateCustomScriptsTemplate(await (0, fs_promises.readFile)((0, path.join)(templatesDir, "app-management", "custom-scripts.js.template"), "utf-8"), appManifest);
735
969
  template = applyCustomScripts(template, scriptsTemplate);
736
970
  }
737
971
  const actionPath = (0, path.join)(projectRoot, getActionPath(extensionPointId, action.name));
738
972
  await (0, fs_promises.writeFile)(actionPath, template, "utf-8");
739
- outputFiles.push(` ${(0, path.relative)(process.cwd(), actionPath)}`);
740
- }
973
+ return ` ${(0, path.relative)(process.cwd(), actionPath)}`;
974
+ }));
741
975
  consola.consola.success(`Generated ${actions.length} action(s)`);
742
976
  consola.consola.log.raw((0, consola_utils.formatTree)(outputFiles));
743
977
  }
@@ -756,11 +990,12 @@ function applyCustomScripts(installationTemplate, customScriptsTemplate) {
756
990
  */
757
991
  async function generateCustomScriptsTemplate(template, appManifest) {
758
992
  if (!require_webhooks.hasCustomInstallationSteps(appManifest)) return null;
759
- const projectRoot = await require_config.getProjectRootDirectory();
993
+ const projectRoot = await require_index_node.getProjectRootDirectory();
760
994
  const installationActionDir = (0, path.join)(projectRoot, getActionsDir(EXTENSIBILITY_EXTENSION_POINT_ID));
761
995
  const customSteps = appManifest.installation.customInstallationSteps;
762
996
  const importStatements = customSteps.map((step, index) => {
763
- 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);
764
999
  if (!relativeImportPath.startsWith(".")) relativeImportPath = `./${relativeImportPath}`;
765
1000
  relativeImportPath = relativeImportPath.replace(/\\/g, "/");
766
1001
  return `import * as ${`customScript${index}`} from "${relativeImportPath}";`;
@@ -771,23 +1006,6 @@ async function generateCustomScriptsTemplate(template, appManifest) {
771
1006
  }).join("\n");
772
1007
  return template.replace(CUSTOM_IMPORTS_PLACEHOLDER, importStatements).replace(CUSTOM_SCRIPTS_MAP_PLACEHOLDER, scriptMap);
773
1008
  }
774
- /**
775
- * Generates `registration/index.js` with the Admin UI SDK registration config
776
- * inlined as a JS object literal.
777
- * @param appManifest - The validated app config; must satisfy `hasAdminUiSdk`.
778
- * @param extensionPointId - The extension point ID that owns the registration action.
779
- * @param templatesDir - The root directory containing the action templates.
780
- */
781
- async function generateRegistrationActionFile(appManifest, extensionPointId, templatesDir = TEMPLATES_DIR) {
782
- consola.consola.start("Generating Admin UI SDK registration action...");
783
- await require_config.makeOutputDirFor(getAdminUiSdkActionsDir(extensionPointId));
784
- const projectRoot = await require_config.getProjectRootDirectory();
785
- const template = await (0, fs_promises.readFile)((0, path.join)(templatesDir, "admin-ui-sdk", "registration.js.template"), "utf-8");
786
- const { registration } = appManifest.adminUiSdk;
787
- const actionPath = (0, path.join)(projectRoot, getAdminUiSdkRegistrationActionPath(extensionPointId));
788
- await (0, fs_promises.writeFile)(actionPath, await prettierFormat(template.replace(REGISTRATION_JSON_PLACEHOLDER, `const registration = ${(0, safe_stable_stringify.default)(registration)};`), actionPath), "utf-8");
789
- consola.consola.success(`Generated registration action at ${(0, path.relative)(process.cwd(), actionPath)}`);
790
- }
791
1009
 
792
1010
  //#endregion
793
1011
  //#region source/commands/generate/actions/main.ts
@@ -800,9 +1018,12 @@ async function run$5(appManifest, templatesDir = TEMPLATES_DIR) {
800
1018
  await prepareRuntimeAppConfigModule(appManifest);
801
1019
  await generateActionFiles(appManifest, getRuntimeActions(await updateExtConfig(appManifest, EXTENSIBILITY_EXTENSION_POINT_ID), "app-management"), EXTENSIBILITY_EXTENSION_POINT_ID, templatesDir);
802
1020
  if (require_validate.hasBusinessConfigSchema(appManifest)) await generateActionFiles(appManifest, getRuntimeActions(await updateExtConfig(appManifest, CONFIGURATION_EXTENSION_POINT_ID), "business-configuration"), CONFIGURATION_EXTENSION_POINT_ID, templatesDir);
803
- if (require_webhooks.hasAdminUiSdk(appManifest)) {
804
- await updateExtConfig(appManifest, BACKEND_UI_EXTENSION_POINT_ID);
805
- 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
+ }
806
1027
  }
807
1028
  }
808
1029
  /** Run the generate actions command */
@@ -820,7 +1041,7 @@ async function exec$5() {
820
1041
  //#region source/commands/generate/manifest/main.ts
821
1042
  async function run$4(appConfig) {
822
1043
  if (hasDynamicAppConfig(appConfig)) {
823
- const stalePath = (0, path.join)(await require_config.getProjectRootDirectory(), getManifestPath());
1044
+ const stalePath = (0, path.join)(await require_index_node.getProjectRootDirectory(), getManifestPath());
824
1045
  if (await (0, fs_promises.access)(stalePath).then(() => true, () => false)) {
825
1046
  await (0, fs_promises.rm)(stalePath, { force: true });
826
1047
  consola.consola.success(`Removed stale ${APP_MANIFEST_FILE}`);
@@ -829,7 +1050,7 @@ async function run$4(appConfig) {
829
1050
  }
830
1051
  consola.consola.info("Generating app manifest...");
831
1052
  const contents = (0, safe_stable_stringify.stringify)(appConfig, null, 2);
832
- 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");
833
1054
  consola.consola.success(`Generated ${APP_MANIFEST_FILE}\n`);
834
1055
  }
835
1056
  /** Run the generate manifest command */
@@ -862,12 +1083,12 @@ async function run$3(appConfig) {
862
1083
  consola.consola.debug("Business configuration schema not found in application configuration. Nothing to do.");
863
1084
  return;
864
1085
  }
865
- const projectDir = await require_config.getProjectRootDirectory();
1086
+ const projectDir = await require_index_node.getProjectRootDirectory();
866
1087
  const envPath = (0, path.join)(projectDir, ".env");
867
1088
  await touch(envPath);
868
1089
  process.loadEnvFile(envPath);
869
1090
  if (appConfig.businessConfig.schema.some((field) => field.type === "password")) {
870
- const packageExec = require_config.getExecCommand(await require_config.detectPackageManager(projectDir));
1091
+ const packageExec = require_index_node.getExecCommand(await require_index_node.detectPackageManager(projectDir));
871
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`);
872
1093
  else (0, child_process.execSync)(`${packageExec} aio-commerce-lib-config encryption setup`);
873
1094
  }
@@ -880,7 +1101,7 @@ async function run$3(appConfig) {
880
1101
  return;
881
1102
  }
882
1103
  consola.consola.info("Generating configuration schema...");
883
- const outputDir = await require_config.makeOutputDirFor(getGeneratedDir(CONFIGURATION_EXTENSION_POINT_ID));
1104
+ const outputDir = await require_index_node.makeOutputDirFor(getGeneratedDir(CONFIGURATION_EXTENSION_POINT_ID));
884
1105
  const contents = (0, safe_stable_stringify.stringify)(appConfig.businessConfig.schema, null, 2);
885
1106
  await (0, fs_promises.writeFile)((0, path.join)(outputDir, CONFIG_SCHEMA_FILE_NAME), contents, "utf-8");
886
1107
  consola.consola.success(`Generated ${CONFIG_SCHEMA_FILE_NAME}\n`);
@@ -925,10 +1146,10 @@ const { context } = _adobe_aio_lib_ims.default;
925
1146
  const IMS_KEYS = {
926
1147
  client_id: "AIO_COMMERCE_AUTH_IMS_CLIENT_ID",
927
1148
  client_secrets: "AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS",
928
- technical_account_email: "AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_EMAIL",
929
- technical_account_id: "AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_ID",
1149
+ ims_org_id: "AIO_COMMERCE_AUTH_IMS_ORG_ID",
930
1150
  scopes: "AIO_COMMERCE_AUTH_IMS_SCOPES",
931
- 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"
932
1153
  };
933
1154
  /**
934
1155
  * Replaces or creates an environment variable in a .env file
@@ -960,7 +1181,7 @@ function resolveEnvPath() {
960
1181
  }
961
1182
  /** Resolves the IMS server to server context from the project workspace credentials. */
962
1183
  function resolveImsS2SContext() {
963
- 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);
964
1185
  if (!credential) return Promise.resolve(null);
965
1186
  return context.get(credential);
966
1187
  }
@@ -1013,8 +1234,14 @@ async function run$1(extension, templatesDir = TEMPLATES_DIR) {
1013
1234
  await generateActionFiles(appManifest, getRuntimeActions(businessConfigExtConfig.toJS(), "business-configuration"), CONFIGURATION_EXTENSION_POINT_ID, templatesDir);
1014
1235
  return;
1015
1236
  }
1016
- if (extension === "backend-ui/1") {
1017
- 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
+ }
1018
1245
  return;
1019
1246
  }
1020
1247
  throw new Error(`Unsupported extension: ${extension}`);
@@ -1022,10 +1249,10 @@ async function run$1(extension, templatesDir = TEMPLATES_DIR) {
1022
1249
  /** Runs the pre-app-build hook */
1023
1250
  async function exec$1() {
1024
1251
  consola.default.debug("Running lib-app pre-app-build hook");
1025
- const extension = process.env.EXTENSION;
1252
+ const rawExtension = process.env.EXTENSION;
1026
1253
  try {
1027
- if (!extension) throw new Error("EXTENSION environment variable is not set");
1028
- await run$1(extension);
1254
+ if (!rawExtension) throw new Error("EXTENSION environment variable is not set");
1255
+ await run$1(rawExtension);
1029
1256
  } catch (error) {
1030
1257
  if (error instanceof _adobe_aio_commerce_lib_core_error.CommerceSdkValidationError) consola.default.error(error.display());
1031
1258
  else consola.default.error(error);
@@ -1038,77 +1265,77 @@ async function exec$1() {
1038
1265
  /** The default values for the features of the commerce app config. */
1039
1266
  const DOMAIN_DEFAULTS = {
1040
1267
  businessConfig: { schema: [{
1041
- type: "list",
1042
- name: "sampleList",
1043
- label: "Sample List",
1044
- selectionMode: "multiple",
1045
1268
  default: ["a"],
1269
+ label: "Sample List",
1270
+ name: "sampleList",
1046
1271
  options: [{
1047
1272
  label: "Option A",
1048
1273
  value: "a"
1049
1274
  }, {
1050
1275
  label: "Option B",
1051
1276
  value: "b"
1052
- }]
1277
+ }],
1278
+ selectionMode: "multiple",
1279
+ type: "list"
1053
1280
  }, {
1054
- type: "text",
1055
- name: "sampleText",
1281
+ default: "Hello, world!",
1056
1282
  label: "Sample Text",
1057
- default: "Hello, world!"
1283
+ name: "sampleText",
1284
+ type: "text"
1058
1285
  }] },
1059
1286
  "eventing.commerce": [{
1060
- provider: {
1061
- label: "Commerce Events Provider",
1062
- description: "A description for your Commerce Events provider."
1063
- },
1064
1287
  events: [{
1065
- name: "plugin.sample_event",
1288
+ description: "Use case description for the event.",
1066
1289
  fields: [{ name: "*" }],
1067
1290
  label: "Sample Event",
1068
- description: "Use case description for the event.",
1291
+ name: "plugin.sample_event",
1069
1292
  runtimeActions: ["my-package/handle-sample-event"]
1070
- }]
1293
+ }],
1294
+ provider: {
1295
+ description: "A description for your Commerce Events provider.",
1296
+ label: "Commerce Events Provider"
1297
+ }
1071
1298
  }],
1072
1299
  "eventing.external": [{
1073
- provider: {
1074
- label: "External Events Provider",
1075
- description: "A description for your External Events provider."
1076
- },
1077
1300
  events: [{
1078
- name: "be-observer.sample_event",
1079
- label: "Sample Event",
1080
1301
  description: "Use case description for the event.",
1302
+ label: "Sample Event",
1303
+ name: "be-observer.sample_event",
1081
1304
  runtimeActions: ["my-package/handle-sample-event"]
1082
- }]
1305
+ }],
1306
+ provider: {
1307
+ description: "A description for your External Events provider.",
1308
+ label: "External Events Provider"
1309
+ }
1083
1310
  }],
1084
1311
  "installation.customInstallationSteps": [{
1085
- name: "sample-step",
1086
1312
  description: "Use case description for the step.",
1313
+ name: "sample-step",
1087
1314
  script: "./path/to/script.js"
1088
1315
  }],
1089
1316
  webhooks: [{
1090
- label: "Sample Webhook",
1317
+ category: "modification",
1091
1318
  description: "A sample Commerce Webhook handler.",
1319
+ label: "Sample Webhook",
1092
1320
  runtimeAction: "my-package/handle-webhook",
1093
- category: "modification",
1094
1321
  webhook: {
1095
- webhook_method: "plugin.sample.event",
1096
- webhook_type: "after",
1097
1322
  batch_name: "my_app",
1098
1323
  hook_name: "sample_hook",
1099
- method: "POST"
1324
+ method: "POST",
1325
+ webhook_method: "plugin.sample.event",
1326
+ webhook_type: "after"
1100
1327
  }
1101
1328
  }, {
1102
- label: "Sample Webhook with URL",
1103
- description: "A sample Commerce Webhook handler using an explicit URL.",
1104
1329
  category: "modification",
1330
+ description: "A sample Commerce Webhook handler using an explicit URL.",
1331
+ label: "Sample Webhook with URL",
1105
1332
  webhook: {
1106
- webhook_method: "plugin.sample.event",
1107
- webhook_type: "after",
1108
1333
  batch_name: "my_app",
1109
1334
  hook_name: "sample_hook_url",
1110
1335
  method: "POST",
1111
- url: "https://example.com/webhook"
1336
+ url: "https://example.com/webhook",
1337
+ webhook_method: "plugin.sample.event",
1338
+ webhook_type: "after"
1112
1339
  }
1113
1340
  }]
1114
1341
  };
@@ -1131,30 +1358,28 @@ function initFlagsToScaffoldAppAnswers(flags) {
1131
1358
  /** Prompt the user to scaffold a new Commerce App configuration. When options are provided, prompts are skipped. */
1132
1359
  async function promptForCommerceAppConfig() {
1133
1360
  const configFormat = await consola.default.prompt("What format do you want to use for the config file?", {
1134
- type: "select",
1361
+ cancel: "reject",
1135
1362
  default: "ts",
1136
1363
  initial: "ts",
1137
- cancel: "reject",
1138
1364
  options: [{
1365
+ hint: "Recommended",
1139
1366
  label: "TypeScript",
1140
- value: "ts",
1141
- hint: "Recommended"
1367
+ value: "ts"
1142
1368
  }, {
1143
1369
  label: "JavaScript",
1144
1370
  value: "js"
1145
- }]
1371
+ }],
1372
+ type: "select"
1146
1373
  });
1147
1374
  const appName = await consola.default.prompt("What is the name of your app?", {
1148
- type: "text",
1149
- placeholder: "Application Display Name",
1375
+ cancel: "reject",
1150
1376
  default: "My Application",
1151
- cancel: "reject"
1377
+ placeholder: "Application Display Name",
1378
+ type: "text"
1152
1379
  });
1153
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")}`, {
1154
- type: "multiselect",
1155
- initial: [],
1156
- required: true,
1157
1381
  cancel: "reject",
1382
+ initial: [],
1158
1383
  options: [
1159
1384
  {
1160
1385
  label: "Business Configuration",
@@ -1176,7 +1401,9 @@ async function promptForCommerceAppConfig() {
1176
1401
  label: "Custom Installation Steps",
1177
1402
  value: "installation.customInstallationSteps"
1178
1403
  }
1179
- ]
1404
+ ],
1405
+ required: true,
1406
+ type: "multiselect"
1180
1407
  });
1181
1408
  const configFile = `${COMMERCE_APP_CONFIG_FILE}.${configFormat}`;
1182
1409
  const domains = new Set(featuresToAdd);
@@ -1184,20 +1411,20 @@ async function promptForCommerceAppConfig() {
1184
1411
  return {
1185
1412
  appName,
1186
1413
  configFile,
1187
- domains,
1188
- configFormat
1414
+ configFormat,
1415
+ domains
1189
1416
  };
1190
1417
  }
1191
1418
  /** Create the default commerce app config file content */
1192
1419
  async function getDefaultCommerceAppConfig(cwd, { appName, configFormat, domains }) {
1193
- const needsESM = await require_config.isESM(cwd) || configFormat === "ts";
1420
+ const needsESM = await require_index_node.isESM(cwd) || configFormat === "ts";
1194
1421
  const exportKeyword = needsESM ? "export default" : "module.exports =";
1195
1422
  const importStatement = needsESM ? "import { defineConfig } from \"@adobe/aio-commerce-lib-app/config\";" : "const { defineConfig } = require(\"@adobe/aio-commerce-lib-app/config\");";
1196
1423
  const defaultConfig = { metadata: {
1197
- id: appName.toLowerCase().replace(/ /g, "-"),
1424
+ description: "A custom Adobe Commerce application. Fill description for your app.",
1198
1425
  displayName: appName,
1199
- version: "1.0.0",
1200
- description: "A custom Adobe Commerce application. Fill description for your app."
1426
+ id: appName.toLowerCase().replace(/ /g, "-"),
1427
+ version: "1.0.0"
1201
1428
  } };
1202
1429
  if (domains.has("businessConfig.schema")) defaultConfig.businessConfig = { schema: DOMAIN_DEFAULTS.businessConfig.schema };
1203
1430
  if (domains.has("eventing.commerce")) defaultConfig.eventing = {
@@ -1287,7 +1514,7 @@ async function addExtensionPointToInstallYaml(extensionPointId, rootDirectory, c
1287
1514
  async function ensureCommerceAppConfig(cwd = process.cwd(), formatConfig = true, flags) {
1288
1515
  let config = null;
1289
1516
  try {
1290
- config = await require_config.readCommerceAppConfig(cwd);
1517
+ config = await require_index_node.readCommerceAppConfig(cwd);
1291
1518
  } catch {}
1292
1519
  if (config) try {
1293
1520
  const validatedConfig = require_validate.validateCommerceAppConfig(config);
@@ -1302,22 +1529,22 @@ async function ensureCommerceAppConfig(cwd = process.cwd(), formatConfig = true,
1302
1529
  if (!flags) {
1303
1530
  consola.consola.warn(`${COMMERCE_APP_CONFIG_FILE} not found.`);
1304
1531
  if (!await consola.consola.prompt(`Do you want to create a ${"app.commerce.config"} file? (y/n)`, {
1305
- type: "confirm",
1532
+ default: false,
1306
1533
  initial: true,
1307
- default: false
1534
+ type: "confirm"
1308
1535
  })) throw new Error("Initialization cancelled.");
1309
1536
  }
1310
1537
  const answers = flags ? initFlagsToScaffoldAppAnswers(flags) : await promptForCommerceAppConfig();
1311
1538
  try {
1312
1539
  const configContent = await getDefaultCommerceAppConfig(cwd, answers);
1313
- 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);
1314
1541
  consola.consola.info(`Creating ${answers.configFile}...`);
1315
1542
  if (formatConfig) await (0, fs_promises.writeFile)(path$2, await prettierFormat(configContent, path$2), "utf-8");
1316
1543
  else await (0, fs_promises.writeFile)(path$2, configContent, "utf-8");
1317
- const config = await require_config.parseCommerceAppConfig(cwd);
1544
+ const createdConfig = await require_index_node.parseCommerceAppConfig(cwd);
1318
1545
  consola.consola.success(`Created ${answers.configFile}`);
1319
1546
  return {
1320
- config,
1547
+ config: createdConfig,
1321
1548
  domains: answers.domains
1322
1549
  };
1323
1550
  } catch (error) {
@@ -1329,25 +1556,24 @@ async function ensureCommerceAppConfig(cwd = process.cwd(), formatConfig = true,
1329
1556
  * @param cwd - Directory to check; defaults to `process.cwd()`
1330
1557
  */
1331
1558
  async function ensurePackageJson(cwd = process.cwd()) {
1332
- const existing = await require_config.readPackageJson(cwd);
1559
+ const existing = await require_index_node.readPackageJson(cwd);
1333
1560
  let packageJson;
1334
1561
  if (existing) packageJson = existing;
1335
1562
  else {
1336
1563
  consola.consola.warn("package.json not found. Creating one...");
1337
1564
  packageJson = {
1338
1565
  name: "my-commerce-app",
1339
- version: "1.0.0",
1340
- private: true
1566
+ private: true,
1567
+ version: "1.0.0"
1341
1568
  };
1342
1569
  await (0, fs_promises.writeFile)((0, path.join)((0, path.resolve)(cwd), PACKAGE_JSON_FILE), JSON.stringify(packageJson, null, 2), "utf-8");
1343
1570
  consola.consola.success("Wrote package.json");
1344
1571
  }
1345
- const packageManager = await require_config.detectPackageManager(cwd);
1346
- const execCommand = require_config.getExecCommand(packageManager);
1572
+ const packageManager = await require_index_node.detectPackageManager(cwd);
1347
1573
  return {
1574
+ execCommand: require_index_node.getExecCommand(packageManager),
1348
1575
  packageJson,
1349
- packageManager,
1350
- execCommand
1576
+ packageManager
1351
1577
  };
1352
1578
  }
1353
1579
  /**
@@ -1357,7 +1583,8 @@ async function ensurePackageJson(cwd = process.cwd()) {
1357
1583
  */
1358
1584
  async function writePostinstallHook(execCommand, cwd = process.cwd()) {
1359
1585
  const postinstallScript = `${execCommand} aio-commerce-lib-app hooks postinstall`;
1360
- 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.");
1361
1588
  const existing = pkg.content.scripts?.postinstall;
1362
1589
  if (existing === postinstallScript || existing?.includes(postinstallScript)) {
1363
1590
  consola.consola.success(`postinstall script already configured in ${PACKAGE_JSON_FILE}`);
@@ -1375,32 +1602,12 @@ async function writePostinstallHook(execCommand, cwd = process.cwd()) {
1375
1602
  }
1376
1603
  /** Ensure app.config.yaml has the extension reference */
1377
1604
  async function ensureAppConfig(domains, cwd = process.cwd()) {
1378
- const rootDirectory = await require_config.getProjectRootDirectory(cwd);
1605
+ const rootDirectory = await require_index_node.getProjectRootDirectory(cwd);
1379
1606
  if (domains.has("businessConfig.schema")) await addExtensionPointToAppConfig(CONFIGURATION_EXTENSION_POINT_ID, rootDirectory, " This extension is required for business configuration. Do not remove.");
1380
- 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.");
1381
1608
  await addExtensionPointToAppConfig(EXTENSIBILITY_EXTENSION_POINT_ID, rootDirectory, " This extension is required for app management. Do not remove.");
1382
1609
  }
1383
1610
  /**
1384
- * Install the given dependencies.
1385
- * @param packageManager - The detected package manager
1386
- * @param dependencies - Package specifiers to install; no-op when empty
1387
- * @param cwd - Working directory for the install command
1388
- */
1389
- function runInstall(packageManager, dependencies, cwd = process.cwd()) {
1390
- if (dependencies.length === 0) return;
1391
- const dependencyListString = dependencies.map((dependency) => ` - ${dependency}`).join("\n");
1392
- consola.consola.start([`Installing the following dependencies with ${packageManager}:\n${dependencyListString}\n`, "This may take a few seconds...\n"].join("\n"));
1393
- const { command, args } = require_config.getInstallCommand(packageManager, dependencies);
1394
- const displayCommand = [command, ...args].join(" ");
1395
- const result = (0, child_process.spawnSync)(command, args, {
1396
- cwd,
1397
- stdio: "inherit"
1398
- });
1399
- 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}`) });
1400
- consola.consola.log("");
1401
- consola.consola.success("Dependencies installed successfully");
1402
- }
1403
- /**
1404
1611
  * Install the domain-specific dependencies derived from the selected domains.
1405
1612
  * @param packageManager - The detected package manager
1406
1613
  * @param domains - Domains enabled in the commerce app config
@@ -1408,7 +1615,7 @@ function runInstall(packageManager, dependencies, cwd = process.cwd()) {
1408
1615
  */
1409
1616
  function installDependencies(packageManager, domains, cwd = process.cwd()) {
1410
1617
  const packages = [];
1411
- if (domains.has("businessConfig.schema")) packages.push(`@adobe/aio-commerce-lib-config@^1.5.0`);
1618
+ if (domains.has("businessConfig.schema")) packages.push(`@adobe/aio-commerce-lib-config@^1.6.0-beta-20260714082406`);
1412
1619
  if (packages.length === 0) {
1413
1620
  consola.consola.info("No additional domain dependencies to install.");
1414
1621
  return;
@@ -1427,15 +1634,15 @@ async function runGeneration(appConfig, execCommand) {
1427
1634
  }
1428
1635
  /** Ensure install.yaml has the extension reference */
1429
1636
  async function ensureInstallYaml(domains, cwd = process.cwd()) {
1430
- const rootDirectory = await require_config.getProjectRootDirectory(cwd);
1637
+ const rootDirectory = await require_index_node.getProjectRootDirectory(cwd);
1431
1638
  if (domains.has("businessConfig.schema")) await addExtensionPointToInstallYaml(CONFIGURATION_EXTENSION_POINT_ID, rootDirectory, " This extension is required for business configuration. Do not remove.");
1432
- 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.");
1433
1640
  await addExtensionPointToInstallYaml(EXTENSIBILITY_EXTENSION_POINT_ID, rootDirectory, " This extension is required for app management. Do not remove.");
1434
1641
  }
1435
1642
 
1436
1643
  //#endregion
1437
1644
  //#region source/commands/init/main.ts
1438
- const REQUIRED_DEPENDENCIES = ["@adobe/aio-commerce-sdk", `@adobe/aio-commerce-lib-app@1.6.0`];
1645
+ const REQUIRED_DEPENDENCIES = ["@adobe/aio-commerce-sdk", `@adobe/aio-commerce-lib-app@1.8.0-beta-20260714082406`];
1439
1646
  /** Initialize the project */
1440
1647
  async function run(flags, extraOptions) {
1441
1648
  consola.consola.start("Initializing app...");
@@ -1443,11 +1650,12 @@ async function run(flags, extraOptions) {
1443
1650
  runInstall(packageManager, REQUIRED_DEPENDENCIES);
1444
1651
  const { config, domains } = await ensureCommerceAppConfig(process.cwd(), extraOptions?.formatConfig ?? true, flags);
1445
1652
  installDependencies(packageManager, domains);
1446
- 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.");
1447
1655
  pkg.update({
1656
+ description: config.metadata.description,
1448
1657
  name: config.metadata.id,
1449
- version: config.metadata.version,
1450
- description: config.metadata.description
1658
+ version: config.metadata.version
1451
1659
  });
1452
1660
  await pkg.save();
1453
1661
  await runGeneration(config, execCommand);
@@ -1505,17 +1713,17 @@ async function generateAll() {
1505
1713
  }
1506
1714
  /** Command handlers registry mapping command names to their subcommand handlers */
1507
1715
  const COMMANDS = {
1508
- init: exec,
1509
- hooks: {
1510
- "pre-app-build": exec$1,
1511
- postinstall: exec$2
1512
- },
1513
1716
  generate: {
1514
1717
  actions: exec$5,
1718
+ all: generateAll,
1515
1719
  manifest: exec$4,
1516
- schema: exec$3,
1517
- all: generateAll
1518
- }
1720
+ schema: exec$3
1721
+ },
1722
+ hooks: {
1723
+ postinstall: exec$2,
1724
+ "pre-app-build": exec$1
1725
+ },
1726
+ init: exec
1519
1727
  };
1520
1728
  /**
1521
1729
  * Generic command handler that dispatches to specific command implementations