@adobe/aio-commerce-lib-app 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/cjs/actions/app-config.cjs +18 -4
  3. package/dist/cjs/actions/app-config.d.cts +15 -1
  4. package/dist/cjs/actions/config.cjs +17 -3
  5. package/dist/cjs/actions/config.d.cts +14 -0
  6. package/dist/cjs/actions/installation.cjs +70 -16
  7. package/dist/cjs/actions/installation.d.cts +16 -2
  8. package/dist/cjs/actions/scope-tree.cjs +17 -3
  9. package/dist/cjs/actions/scope-tree.d.cts +14 -0
  10. package/dist/cjs/{app-DWX5-Hsf.d.cts → app-lymFcs59.d.cts} +146 -1
  11. package/dist/cjs/commands/index.cjs +41 -28
  12. package/dist/cjs/commands/index.d.cts +14 -0
  13. package/dist/cjs/config/index.cjs +27 -12
  14. package/dist/cjs/config/index.d.cts +576 -4
  15. package/dist/cjs/{parser-BPpg_9QB.cjs → config-YEeaEqzi.cjs} +17 -3
  16. package/dist/cjs/error-Dn7ool6k.cjs +38 -0
  17. package/dist/{es/runner-BD-lItnK.d.mts → cjs/index-DRhLtRrX.d.cts} +102 -4
  18. package/dist/cjs/logging-4s36JTiN.cjs +39 -0
  19. package/dist/cjs/management/index.cjs +23 -8
  20. package/dist/cjs/management/index.d.cts +16 -2
  21. package/dist/cjs/{runner-NHMvoMO2.cjs → management-PZtLe4Ji.cjs} +371 -30
  22. package/dist/cjs/{router-DCw7oEQ9.cjs → router-KeQRduO3.cjs} +15 -1
  23. package/dist/cjs/{schemas-CZ6c8Id9.cjs → schemas-nkIxa8sL.cjs} +34 -0
  24. package/dist/cjs/{validate-Btzn9ilZ.cjs → validate-CwwYD8aC.cjs} +31 -14
  25. package/dist/cjs/{installation-CLbceU9F.cjs → webhooks-CbZpv9y_.cjs} +105 -1
  26. package/dist/es/actions/app-config.d.mts +15 -1
  27. package/dist/es/actions/app-config.mjs +17 -3
  28. package/dist/es/actions/config.d.mts +14 -0
  29. package/dist/es/actions/config.mjs +17 -3
  30. package/dist/es/actions/installation.d.mts +16 -2
  31. package/dist/es/actions/installation.mjs +64 -10
  32. package/dist/es/actions/scope-tree.d.mts +14 -0
  33. package/dist/es/actions/scope-tree.mjs +17 -3
  34. package/dist/es/{app-BAiyvNo2.d.mts → app-Ct7Y0NP8.d.mts} +146 -1
  35. package/dist/es/commands/index.d.mts +14 -0
  36. package/dist/es/commands/index.mjs +21 -8
  37. package/dist/es/config/index.d.mts +576 -4
  38. package/dist/es/config/index.mjs +18 -4
  39. package/dist/es/{parser-CQZTVG6i.mjs → config-BbrkH0Xt.mjs} +16 -2
  40. package/dist/es/error-DHlYzkbb.mjs +32 -0
  41. package/dist/{cjs/runner-DemKouFJ.d.cts → es/index-D33OCH0D.d.mts} +102 -4
  42. package/dist/es/logging-XIUXDK5T.mjs +32 -0
  43. package/dist/es/management/index.d.mts +16 -2
  44. package/dist/es/management/index.mjs +16 -2
  45. package/dist/es/{runner-vwAhjD5r.mjs → management-CIoVWirU.mjs} +360 -25
  46. package/dist/es/{router-CJ4VWoCt.mjs → router-BxaxEEu3.mjs} +14 -0
  47. package/dist/es/{schemas-B8yIv0_b.mjs → schemas-BvPxQwgQ.mjs} +29 -1
  48. package/dist/es/{validate-DKnju9-R.mjs → validate-qRpfubPo.mjs} +21 -4
  49. package/dist/es/{installation-BTL9X7iv.mjs → webhooks-NgM6k3_r.mjs} +94 -2
  50. package/package.json +11 -8
  51. package/dist/cjs/error-DJ2UAPH2.cjs +0 -24
  52. package/dist/cjs/logging-IDRQG0as.cjs +0 -25
  53. package/dist/es/error-CMV3IjBz.mjs +0 -18
  54. package/dist/es/logging-CzmXDzxI.mjs +0 -18
@@ -1,10 +1,24 @@
1
1
  #!/usr/bin/env node
2
- const require_schemas = require('../schemas-CZ6c8Id9.cjs');
3
- const require_validate = require('../validate-Btzn9ilZ.cjs');
4
- const require_installation = require('../installation-CLbceU9F.cjs');
5
- const require_parser = require('../parser-BPpg_9QB.cjs');
6
- const require_error = require('../error-DJ2UAPH2.cjs');
7
- const require_logging = require('../logging-IDRQG0as.cjs');
2
+ /**
3
+ * @license
4
+ *
5
+ * Copyright 2026 Adobe. All rights reserved.
6
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License. You may obtain a copy
8
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software distributed under
11
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ * OF ANY KIND, either express or implied. See the License for the specific language
13
+ * governing permissions and limitations under the License.
14
+ */
15
+
16
+ const require_schemas = require('../schemas-nkIxa8sL.cjs');
17
+ const require_validate = require('../validate-CwwYD8aC.cjs');
18
+ const require_webhooks = require('../webhooks-CbZpv9y_.cjs');
19
+ const require_config = require('../config-YEeaEqzi.cjs');
20
+ const require_error = require('../error-Dn7ool6k.cjs');
21
+ const require_logging = require('../logging-4s36JTiN.cjs');
8
22
  let _adobe_aio_commerce_lib_core_error = require("@adobe/aio-commerce-lib-core/error");
9
23
  let path = require("path");
10
24
  path = require_schemas.__toESM(path);
@@ -201,7 +215,7 @@ async function buildHooks(extConfig, hooks) {
201
215
  pair.key.spaceBefore = true;
202
216
  pair.key.commentBefore = ` The ${generatedHooks} hooks are auto-generated. Do not remove or manually edit.`;
203
217
  } });
204
- const execCommand = require_parser.getExecCommand(await require_parser.detectPackageManager());
218
+ const execCommand = require_config.getExecCommand(await require_config.detectPackageManager());
205
219
  for (const [name, command] of Object.entries(hooks)) {
206
220
  const fullCommand = `${command.replaceAll("$packageExec", execCommand)}`;
207
221
  const prevValue = (hooksMap.get(name) ?? "").trim();
@@ -258,7 +272,7 @@ function getExtensionPointFolderPath(extensionPointId) {
258
272
  //#region source/commands/utils.ts
259
273
  /** Load the app commerce config */
260
274
  async function loadAppManifest() {
261
- const appConfig = await require_parser.parseCommerceAppConfig();
275
+ const appConfig = await require_config.parseCommerceAppConfig();
262
276
  consola.default.debug("Loaded app commerce config");
263
277
  return appConfig;
264
278
  }
@@ -267,7 +281,6 @@ async function loadAppManifest() {
267
281
  //#region source/commands/generate/actions/config.ts
268
282
  /** The list of Commerce variables that are required for the runtime actions */
269
283
  const COMMERCE_VARIABLES = [
270
- "AIO_COMMERCE_API_BASE_URL",
271
284
  "AIO_COMMERCE_AUTH_IMS_CLIENT_ID",
272
285
  "AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS",
273
286
  "AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_ID",
@@ -307,7 +320,7 @@ function createActionDefinition(actionName, config = {}, options = {}) {
307
320
  * @param extConfig - The ext.config.yaml configuration.
308
321
  */
309
322
  function getRuntimeActions(extConfig, dir) {
310
- return Object.entries(extConfig.runtimeManifest?.packages?.[PACKAGE_NAME]?.actions ?? {}).map(([name, _]) => ({
323
+ return Object.entries(extConfig.runtimeManifest?.packages?.["app-management"]?.actions ?? {}).map(([name, _]) => ({
311
324
  name,
312
325
  templateFile: (0, path.join)(dir, `${name}.js.template`)
313
326
  }));
@@ -392,7 +405,7 @@ async function exec$5() {
392
405
  /** Update the ext.config.yaml file */
393
406
  async function updateExtConfig(appConfig, extensionPointId) {
394
407
  consola.consola.info(`Updating ext.config.yaml for ${extensionPointId}...`);
395
- const extConfigPath = (0, path.join)(await require_parser.makeOutputDirFor(getExtensionPointFolderPath(extensionPointId)), "ext.config.yaml");
408
+ const extConfigPath = (0, path.join)(await require_config.makeOutputDirFor(getExtensionPointFolderPath(extensionPointId)), "ext.config.yaml");
396
409
  const extConfigDoc = await readYamlFile(extConfigPath);
397
410
  let extConfig;
398
411
  switch (extensionPointId) {
@@ -410,7 +423,7 @@ async function updateExtConfig(appConfig, extensionPointId) {
410
423
  /** Generate the action files */
411
424
  async function generateActionFiles(appManifest, actions, extensionPointId) {
412
425
  consola.consola.start("Generating runtime actions...");
413
- const outputDir = await require_parser.makeOutputDirFor((0, path.join)(getExtensionPointFolderPath(extensionPointId), GENERATED_ACTIONS_PATH));
426
+ const outputDir = await require_config.makeOutputDirFor((0, path.join)(getExtensionPointFolderPath(extensionPointId), GENERATED_ACTIONS_PATH));
414
427
  const outputFiles = [];
415
428
  const templatesDir = (0, path.join)(__dirname$1, "generate/actions/templates");
416
429
  for (const action of actions) {
@@ -440,8 +453,8 @@ function applyCustomScripts(installationTemplate, customScriptsTemplate) {
440
453
  * Generate the installation template with dynamic custom script imports
441
454
  */
442
455
  async function generateCustomScriptsTemplate(template, appManifest) {
443
- if (!require_installation.hasCustomInstallationSteps(appManifest)) return null;
444
- const projectRoot = await require_parser.getProjectRootDirectory();
456
+ if (!require_webhooks.hasCustomInstallationSteps(appManifest)) return null;
457
+ const projectRoot = await require_config.getProjectRootDirectory();
445
458
  const installationActionDir = (0, path.join)(projectRoot, getExtensionPointFolderPath(EXTENSIBILITY_EXTENSION_POINT_ID), GENERATED_ACTIONS_PATH);
446
459
  const customSteps = appManifest.installation.customInstallationSteps;
447
460
  const importStatements = customSteps.map((step, index) => {
@@ -462,7 +475,7 @@ async function generateCustomScriptsTemplate(template, appManifest) {
462
475
  async function run$3(appConfig) {
463
476
  consola.consola.info("Generating app manifest...");
464
477
  const contents = (0, safe_stable_stringify.stringify)(appConfig, null, 2);
465
- await (0, fs_promises.writeFile)((0, path.join)(await require_parser.makeOutputDirFor(`${getExtensionPointFolderPath(EXTENSIBILITY_EXTENSION_POINT_ID)}/.generated`), APP_MANIFEST_FILE), contents, "utf-8");
478
+ await (0, fs_promises.writeFile)((0, path.join)(await require_config.makeOutputDirFor(`${getExtensionPointFolderPath(EXTENSIBILITY_EXTENSION_POINT_ID)}/.generated`), APP_MANIFEST_FILE), contents, "utf-8");
466
479
  consola.consola.success(`Generated ${APP_MANIFEST_FILE}`);
467
480
  }
468
481
  /** Run the generate manifest command */
@@ -484,16 +497,16 @@ async function run$2(appConfig) {
484
497
  consola.consola.warn("Business configuration schema not found");
485
498
  return;
486
499
  }
487
- const projectDir = (0, path.dirname)(await require_parser.findNearestPackageJson() ?? process.cwd());
500
+ const projectDir = (0, path.dirname)(await require_config.findNearestPackageJson() ?? process.cwd());
488
501
  const envPath = (0, path.join)(projectDir, ".env");
489
502
  process.loadEnvFile(envPath);
490
503
  if (appConfig.businessConfig.schema.some((field) => field.type === "password")) {
491
- const packageExec = require_parser.getExecCommand(await require_parser.detectPackageManager(projectDir));
504
+ const packageExec = require_config.getExecCommand(await require_config.detectPackageManager(projectDir));
492
505
  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`);
493
506
  else (0, child_process.execSync)(`${packageExec} aio-commerce-lib-config encryption setup`);
494
507
  }
495
508
  const contents = (0, safe_stable_stringify.stringify)(appConfig.businessConfig.schema, null, 2);
496
- await (0, fs_promises.writeFile)((0, path.join)(await require_parser.makeOutputDirFor(`${getExtensionPointFolderPath(CONFIGURATION_EXTENSION_POINT_ID)}/.generated`), CONFIG_SCHEMA_FILE_NAME), contents, "utf-8");
509
+ await (0, fs_promises.writeFile)((0, path.join)(await require_config.makeOutputDirFor(`${getExtensionPointFolderPath(CONFIGURATION_EXTENSION_POINT_ID)}/.generated`), CONFIG_SCHEMA_FILE_NAME), contents, "utf-8");
497
510
  consola.consola.success(`Generated ${CONFIG_SCHEMA_FILE_NAME}`);
498
511
  }
499
512
  /** Run the generate manifest command */
@@ -738,7 +751,7 @@ async function promptForCommerceAppConfig() {
738
751
  }
739
752
  /** Create the default commerce app config file content */
740
753
  async function getDefaultCommerceAppConfig(cwd, { appName, configFormat, domains }) {
741
- const needsESM = await require_parser.isESM(cwd) || configFormat === "ts";
754
+ const needsESM = await require_config.isESM(cwd) || configFormat === "ts";
742
755
  const exportKeyword = needsESM ? "export default" : "module.exports =";
743
756
  const importStatement = needsESM ? "import { defineConfig } from \"@adobe/aio-commerce-lib-app/config\";" : "const { defineConfig } = require(\"@adobe/aio-commerce-lib-app/config\");";
744
757
  const defaultConfig = { metadata: {
@@ -835,7 +848,7 @@ async function addExtensionPointToInstallYaml(extensionPointId, rootDirectory, c
835
848
  async function ensureCommerceAppConfig(cwd = process.cwd()) {
836
849
  let config = null;
837
850
  try {
838
- config = await require_parser.readCommerceAppConfig(cwd);
851
+ config = await require_config.readCommerceAppConfig(cwd);
839
852
  } catch (_) {}
840
853
  if (config) try {
841
854
  const validatedConfig = require_validate.validateCommerceAppConfig(config);
@@ -848,7 +861,7 @@ async function ensureCommerceAppConfig(cwd = process.cwd()) {
848
861
  throw new Error(`${COMMERCE_APP_CONFIG_FILE} is invalid`, { cause: error });
849
862
  }
850
863
  consola.consola.warn(`${COMMERCE_APP_CONFIG_FILE} not found.`);
851
- if (!await consola.consola.prompt(`Do you want to create a ${COMMERCE_APP_CONFIG_FILE} file? (y/n)`, {
864
+ if (!await consola.consola.prompt(`Do you want to create a ${"app.commerce.config"} file? (y/n)`, {
852
865
  type: "confirm",
853
866
  initial: true,
854
867
  default: false
@@ -857,7 +870,7 @@ async function ensureCommerceAppConfig(cwd = process.cwd()) {
857
870
  try {
858
871
  const configContent = await getDefaultCommerceAppConfig(cwd, answers);
859
872
  consola.consola.info(`Creating ${answers.configFile}...`);
860
- const path$2 = (0, path.join)(await require_parser.getProjectRootDirectory(cwd), answers.configFile);
873
+ const path$2 = (0, path.join)(await require_config.getProjectRootDirectory(cwd), answers.configFile);
861
874
  await (0, fs_promises.writeFile)(path$2, await prettier.format(configContent, {
862
875
  semi: true,
863
876
  quoteStyle: "double",
@@ -872,7 +885,7 @@ async function ensureCommerceAppConfig(cwd = process.cwd()) {
872
885
  }), "utf-8");
873
886
  consola.consola.success(`Created ${answers.configFile}`);
874
887
  return {
875
- config: await require_parser.parseCommerceAppConfig(cwd),
888
+ config: await require_config.parseCommerceAppConfig(cwd),
876
889
  domains: answers.domains
877
890
  };
878
891
  } catch (error) {
@@ -881,7 +894,7 @@ async function ensureCommerceAppConfig(cwd = process.cwd()) {
881
894
  }
882
895
  /** Ensure package.json has the postinstall script */
883
896
  async function ensurePackageJson(cwd = process.cwd()) {
884
- const packageJson = await require_parser.readPackageJson(cwd);
897
+ const packageJson = await require_config.readPackageJson(cwd);
885
898
  if (!packageJson) {
886
899
  consola.consola.warn("package.json not found. Creating one...");
887
900
  const packageJsonContent = {
@@ -898,8 +911,8 @@ async function ensurePackageJson(cwd = process.cwd()) {
898
911
  execCommand: "npx"
899
912
  };
900
913
  }
901
- const packageManager = await require_parser.detectPackageManager();
902
- const execCommand = require_parser.getExecCommand(packageManager);
914
+ const packageManager = await require_config.detectPackageManager();
915
+ const execCommand = require_config.getExecCommand(packageManager);
903
916
  const postinstallScript = `${execCommand} aio-commerce-lib-app hooks postinstall`;
904
917
  packageJson.scripts ??= {};
905
918
  if (packageJson.scripts.postinstall === postinstallScript || packageJson.scripts.postinstall?.includes(postinstallScript)) {
@@ -926,7 +939,7 @@ async function ensurePackageJson(cwd = process.cwd()) {
926
939
  }
927
940
  /** Ensure app.config.yaml has the extension reference */
928
941
  async function ensureAppConfig(domains, cwd = process.cwd()) {
929
- const rootDirectory = await require_parser.getProjectRootDirectory(cwd);
942
+ const rootDirectory = await require_config.getProjectRootDirectory(cwd);
930
943
  if (domains.has("businessConfig.schema")) await addExtensionPointToAppConfig(CONFIGURATION_EXTENSION_POINT_ID, rootDirectory, " This extension is required for business configuration. Do not remove.");
931
944
  await addExtensionPointToAppConfig(EXTENSIBILITY_EXTENSION_POINT_ID, rootDirectory, " This extension is required for app management. Do not remove.");
932
945
  }
@@ -968,7 +981,7 @@ async function runGeneration(appConfig, execCommand) {
968
981
  }
969
982
  /** Ensure install.yaml has the extension reference */
970
983
  async function ensureInstallYaml(domains, cwd = process.cwd()) {
971
- const rootDirectory = await require_parser.getProjectRootDirectory(cwd);
984
+ const rootDirectory = await require_config.getProjectRootDirectory(cwd);
972
985
  if (domains.has("businessConfig.schema")) await addExtensionPointToInstallYaml(CONFIGURATION_EXTENSION_POINT_ID, rootDirectory, " This extension is required for business configuration. Do not remove.");
973
986
  await addExtensionPointToInstallYaml(EXTENSIBILITY_EXTENSION_POINT_ID, rootDirectory, " This extension is required for app management. Do not remove.");
974
987
  }
@@ -1 +1,15 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright 2026 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+
1
15
  export { };
@@ -1,22 +1,37 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright 2026 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+
1
15
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_validate = require('../validate-Btzn9ilZ.cjs');
3
- const require_installation = require('../installation-CLbceU9F.cjs');
4
- const require_parser = require('../parser-BPpg_9QB.cjs');
16
+ const require_validate = require('../validate-CwwYD8aC.cjs');
17
+ const require_webhooks = require('../webhooks-CbZpv9y_.cjs');
18
+ const require_config = require('../config-YEeaEqzi.cjs');
5
19
 
6
20
  exports.CommerceAppConfigSchemas = require_validate.CommerceAppConfigSchemas;
7
- exports.defineConfig = require_parser.defineConfig;
21
+ exports.defineConfig = require_config.defineConfig;
8
22
  exports.getConfigDomains = require_validate.getConfigDomains;
9
23
  exports.hasBusinessConfig = require_validate.hasBusinessConfig;
10
24
  exports.hasBusinessConfigSchema = require_validate.hasBusinessConfigSchema;
11
- exports.hasCommerceEvents = require_installation.hasCommerceEvents;
25
+ exports.hasCommerceEvents = require_webhooks.hasCommerceEvents;
12
26
  exports.hasConfigDomain = require_validate.hasConfigDomain;
13
- exports.hasCustomInstallation = require_installation.hasCustomInstallation;
14
- exports.hasCustomInstallationSteps = require_installation.hasCustomInstallationSteps;
15
- exports.hasEventing = require_installation.hasEventing;
16
- exports.hasExternalEvents = require_installation.hasExternalEvents;
27
+ exports.hasCustomInstallation = require_webhooks.hasCustomInstallation;
28
+ exports.hasCustomInstallationSteps = require_webhooks.hasCustomInstallationSteps;
29
+ exports.hasEventing = require_webhooks.hasEventing;
30
+ exports.hasExternalEvents = require_webhooks.hasExternalEvents;
17
31
  exports.hasMetadata = require_validate.hasMetadata;
18
- exports.parseCommerceAppConfig = require_parser.parseCommerceAppConfig;
19
- exports.readCommerceAppConfig = require_parser.readCommerceAppConfig;
20
- exports.resolveCommerceAppConfig = require_parser.resolveCommerceAppConfig;
32
+ exports.hasWebhooks = require_webhooks.hasWebhooks;
33
+ exports.parseCommerceAppConfig = require_config.parseCommerceAppConfig;
34
+ exports.readCommerceAppConfig = require_config.readCommerceAppConfig;
35
+ exports.resolveCommerceAppConfig = require_config.resolveCommerceAppConfig;
21
36
  exports.validateCommerceAppConfig = require_validate.validateCommerceAppConfig;
22
37
  exports.validateCommerceAppConfigDomain = require_validate.validateCommerceAppConfigDomain;