@adobe/aio-commerce-lib-app 2.2.0 → 2.3.0-beta-20261202103723

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 (63) hide show
  1. package/CHANGELOG.md +32 -1
  2. package/dist/cjs/actions/app-config/index.cjs +8 -8
  3. package/dist/cjs/actions/app-config/index.d.cts +2 -2
  4. package/dist/cjs/actions/association/index.cjs +4 -4
  5. package/dist/cjs/actions/config/index.cjs +19 -8
  6. package/dist/cjs/actions/config/index.d.cts +1 -1
  7. package/dist/cjs/actions/installation/index.cjs +39 -15
  8. package/dist/cjs/actions/installation/index.d.cts +3 -3
  9. package/dist/cjs/actions/scope-tree/index.cjs +6 -6
  10. package/dist/cjs/{app-B3bAEor-.d.cts → app-CLDvfJXp.d.cts} +634 -44
  11. package/dist/cjs/commands/index.cjs +174 -33
  12. package/dist/cjs/config/index.browser.d.cts +1 -1
  13. package/dist/cjs/config/index.node.cjs +3 -3
  14. package/dist/cjs/config/index.node.d.cts +50 -14
  15. package/dist/cjs/{define-eBMdGAq6.d.cts → define-BGpnO45V.d.cts} +1 -1
  16. package/dist/cjs/{environment-CW6M76gS.cjs → environment-CaV1hi2-.cjs} +1 -1
  17. package/dist/cjs/{index-BEeludy0.d.cts → index-p0duTbHE.d.cts} +2 -2
  18. package/dist/cjs/index.cjs +3 -3
  19. package/dist/cjs/index.d.cts +1 -1
  20. package/dist/cjs/{index.node-9bfp79rs.cjs → index.node-ECg3DGc8.cjs} +7 -6
  21. package/dist/cjs/{logging-Emi7P923.cjs → logging-r-r2bUWO.cjs} +1 -1
  22. package/dist/cjs/management/index.cjs +1 -1
  23. package/dist/cjs/management/index.d.cts +1 -1
  24. package/dist/cjs/{management-5Et1mEUp.cjs → management-CFQ4hjs6.cjs} +123 -108
  25. package/dist/cjs/{openapi-DghfuM8S.cjs → openapi-BaKoO7GY.cjs} +177 -26
  26. package/dist/cjs/{rolldown-runtime-CoOt0iuZ.cjs → rolldown-runtime-BKfnhsn2.cjs} +4 -4
  27. package/dist/cjs/{schemas-B6ITl1bG.cjs → schemas-B-jCi6Oz.cjs} +1 -1
  28. package/dist/cjs/{utils-CoR_PBHz.cjs → utils-CuzJBLgo.cjs} +2 -2
  29. package/dist/cjs/{utils-DSS0XlXq.cjs → utils-bwFwJcPW.cjs} +1 -1
  30. package/dist/cjs/{validate-BC3rnRLc.cjs → validate-DKMq3KNV.cjs} +13 -5
  31. package/dist/cjs/{version-5MonNzl5.cjs → version-BYcHBNng.cjs} +3 -3
  32. package/dist/{es/webhooks-DgaLfP36.d.mts → cjs/webhooks-BCYX3JqY.d.cts} +382 -43
  33. package/dist/cjs/{webhooks-ZPh2gVb3.cjs → webhooks-Bp1Roq8a.cjs} +70 -23
  34. package/dist/es/actions/app-config/index.d.mts +2 -2
  35. package/dist/es/actions/app-config/index.mjs +6 -6
  36. package/dist/es/actions/association/index.mjs +3 -3
  37. package/dist/es/actions/config/index.d.mts +2 -2
  38. package/dist/es/actions/config/index.mjs +19 -8
  39. package/dist/es/actions/installation/index.d.mts +4 -4
  40. package/dist/es/actions/installation/index.mjs +38 -14
  41. package/dist/es/actions/scope-tree/index.mjs +5 -5
  42. package/dist/es/{app-B3bAEor-.d.mts → app-CLDvfJXp.d.mts} +634 -44
  43. package/dist/es/commands/index.mjs +170 -29
  44. package/dist/es/config/index.browser.d.mts +1 -1
  45. package/dist/es/config/index.node.d.mts +51 -15
  46. package/dist/es/config/index.node.mjs +3 -3
  47. package/dist/es/{define-BdXyLAwb.d.mts → define-C-0hOMO3.d.mts} +1 -1
  48. package/dist/es/{environment-DUhU0_9z.mjs → environment-B1JJFHZw.mjs} +1 -1
  49. package/dist/es/{index-DE2KVXfH.d.mts → index-DYHaYwvJ.d.mts} +4 -4
  50. package/dist/es/{index-DUJtT78x.d.mts → index-U7CXicoW.d.mts} +1 -1
  51. package/dist/es/index.d.mts +2 -2
  52. package/dist/es/index.mjs +3 -3
  53. package/dist/es/{index.node-CURztkP5.mjs → index.node-ChWOTWnF.mjs} +5 -4
  54. package/dist/es/management/index.d.mts +1 -1
  55. package/dist/es/management/index.mjs +1 -1
  56. package/dist/es/{management-BAQ64OyR.mjs → management-CNMT6azj.mjs} +128 -113
  57. package/dist/es/{openapi-BvPVTUMt.mjs → openapi-ChihLuvm.mjs} +177 -26
  58. package/dist/es/{utils-DB8HaSj0.mjs → utils-Bg_LIAGV.mjs} +2 -2
  59. package/dist/es/{validate-xS9Dc-4m.mjs → validate-DeAMC-HS.mjs} +7 -5
  60. package/dist/es/{version-BWgrh_QM.mjs → version-Cj7a9rey.mjs} +1 -1
  61. package/dist/es/{webhooks-HBe_DEKA.mjs → webhooks-CyiUfRNG.mjs} +67 -20
  62. package/dist/{cjs/webhooks-DNLuuv9_.d.cts → es/webhooks-DyMAQMnm.d.mts} +382 -43
  63. package/package.json +14 -15
@@ -13,11 +13,11 @@
13
13
  */
14
14
 
15
15
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
16
- const require_repository = require("./repository-C3nn0Mon.cjs");
17
- const require_utils = require("./utils-CoR_PBHz.cjs");
18
16
  let _adobe_aio_commerce_lib_api = require("@adobe/aio-commerce-lib-api");
19
- let _adobe_aio_commerce_lib_config = require("@adobe/aio-commerce-lib-config");
17
+ const require_repository = require("./repository-C3nn0Mon.cjs");
20
18
  let _adobe_aio_commerce_lib_core_error = require("@adobe/aio-commerce-lib-core/error");
19
+ let _adobe_aio_commerce_lib_config = require("@adobe/aio-commerce-lib-config");
20
+ const require_utils = require("./utils-CuzJBLgo.cjs");
21
21
 
22
22
  // source/lib/errors.ts
23
23
  /**
@@ -19,9 +19,9 @@
19
19
  *
20
20
  * @packageDocumentation
21
21
  */
22
- import { t as AssociatedCommerceData } from "./types-DslZGym8.cjs";
23
22
  import { AdobeCommerceHttpClient, CommerceHttpClientParams } from "@adobe/aio-commerce-lib-api";
24
23
  import { ImsAuthParams, ImsAuthProvider } from "@adobe/aio-commerce-lib-auth";
24
+ import { t as AssociatedCommerceData } from "./types-DslZGym8.cjs";
25
25
  import { CommerceSdkErrorBase, CommerceSdkErrorBaseOptions } from "@adobe/aio-commerce-lib-core/error";
26
26
  import { AdobeIoEventsApiClient } from "@adobe/aio-commerce-lib-events/io-events";
27
27
  /**
@@ -12,18 +12,18 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
- const require_rolldown_runtime = require("./rolldown-runtime-CoOt0iuZ.cjs");
16
- const require_validate = require("./validate-BC3rnRLc.cjs");
15
+ const require_rolldown_runtime = require("./rolldown-runtime-BKfnhsn2.cjs");
16
+ let path = require("path");
17
17
  let _adobe_aio_commerce_lib_core_error = require("@adobe/aio-commerce-lib-core/error");
18
18
  let fs = require("fs");
19
19
  let fs_promises = require("fs/promises");
20
- let path = require("path");
21
20
  let _npmcli_package_json = require("@npmcli/package-json");
22
- _npmcli_package_json = require_rolldown_runtime.__toESM(_npmcli_package_json, 1);
23
21
  let local_pkg = require("local-pkg");
24
22
  let package_manager_detector = require("package-manager-detector");
25
23
  let package_manager_detector_detect = require("package-manager-detector/detect");
26
24
  let semver = require("semver");
25
+ const require_validate = require("./validate-DKMq3KNV.cjs");
26
+ _npmcli_package_json = require_rolldown_runtime.__toESM(_npmcli_package_json, 1);
27
27
 
28
28
  // ../../packages-private/scripting-utils/source/project.ts
29
29
  /**
@@ -42,7 +42,8 @@ async function findUp(name, options = {}) {
42
42
  const { root } = (0, path.parse)(cwd);
43
43
  const stopAt = options.stopAt || root;
44
44
  let currentDir = cwd;
45
- for (;;) {
45
+ let reachedTop = false;
46
+ while (!reachedTop) {
46
47
  for (const fileName of names) {
47
48
  const filePath = (0, path.join)(currentDir, fileName);
48
49
  try {
@@ -50,7 +51,7 @@ async function findUp(name, options = {}) {
50
51
  return filePath;
51
52
  } catch {}
52
53
  }
53
- if (currentDir === stopAt || currentDir === root) return;
54
+ reachedTop = currentDir === stopAt || currentDir === root;
54
55
  currentDir = (0, path.dirname)(currentDir);
55
56
  }
56
57
  }
@@ -12,7 +12,7 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
- const require_rolldown_runtime = require("./rolldown-runtime-CoOt0iuZ.cjs");
15
+ const require_rolldown_runtime = require("./rolldown-runtime-BKfnhsn2.cjs");
16
16
  let util = require("util");
17
17
  util = require_rolldown_runtime.__toESM(util, 1);
18
18
 
@@ -13,7 +13,7 @@
13
13
  */
14
14
 
15
15
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
16
- const require_management = require("../management-5Et1mEUp.cjs");
16
+ const require_management = require("../management-CFQ4hjs6.cjs");
17
17
 
18
18
  exports.createInitialInstallationState = require_management.createInitialInstallationState;
19
19
  exports.createInitialUninstallationState = require_management.createInitialUninstallationState;
@@ -17,5 +17,5 @@
17
17
  * This module exports shared application management utilities for the AIO Commerce SDK.
18
18
  * @packageDocumentation
19
19
  */
20
- import { $ as BranchStepOptions, A as createInitialState, B as InProgressWorkflowState, C as defineCustomInstallationStep, D as executePlannedWorkflow, E as createInitialPlanExecutionState, F as StepStartedEvent, G as WorkflowRunState, H as SucceededWorkflowState, I as StepSucceededEvent, J as isFailedState, K as WorkflowStateMetadata, L as WorkflowHooks, M as executeWorkflow, N as StepEvent, O as ValidateStepTreeOptions, P as StepFailedEvent, Q as BranchStep, R as ExecutionStatus, S as CustomInstallationStepHandler, T as planWorkflow, U as WorkflowData, V as StepStatus, W as WorkflowError, X as isSucceededState, Y as isInProgressState, Z as AnyStep, _ as createInitialUninstallationState, _t as ValidationIssueSeverity, a as InstallationError, at as Step, b as runValidation, c as InstallationStatus, ct as StepMetaInfo, d as CreateInitialUninstallationStateOptions, dt as defineBranchStep, et as ExecutionContext, f as InstallationHooks, ft as defineLeafStep, g as createInitialInstallationState, gt as ValidationIssue, h as RunValidationOptions, ht as StepValidationResult, i as InstallationData, it as LifecycleContext, j as executeUninstallWorkflow, k as validateStepTree, l as SucceededInstallationState, lt as ValidationContext, m as RunUninstallationOptions, mt as isLeafStep, n as InProgressInstallationState, nt as LeafStep, o as InstallationRetryMetadata, ot as StepContextFactory, p as RunInstallationOptions, pt as isBranchStep, q as isCompletedState, r as InstallationContext, rt as LeafStepOptions, s as InstallationState, st as StepMeta, t as FailedInstallationState, tt as InferStepOutput, u as CreateInitialInstallationStateOptions, ut as ValidationExecutionContext, v as runInstallation, vt as ValidationResult, w as createRetryState, x as CustomInstallationStepDefinition, y as runUninstallation, yt as ValidationSummary, z as FailedWorkflowState } from "../index-BEeludy0.cjs";
20
+ import { $ as BranchStepOptions, A as createInitialState, B as InProgressWorkflowState, C as defineCustomInstallationStep, D as executePlannedWorkflow, E as createInitialPlanExecutionState, F as StepStartedEvent, G as WorkflowRunState, H as SucceededWorkflowState, I as StepSucceededEvent, J as isFailedState, K as WorkflowStateMetadata, L as WorkflowHooks, M as executeWorkflow, N as StepEvent, O as ValidateStepTreeOptions, P as StepFailedEvent, Q as BranchStep, R as ExecutionStatus, S as CustomInstallationStepHandler, T as planWorkflow, U as WorkflowData, V as StepStatus, W as WorkflowError, X as isSucceededState, Y as isInProgressState, Z as AnyStep, _ as createInitialUninstallationState, _t as ValidationIssueSeverity, a as InstallationError, at as Step, b as runValidation, c as InstallationStatus, ct as StepMetaInfo, d as CreateInitialUninstallationStateOptions, dt as defineBranchStep, et as ExecutionContext, f as InstallationHooks, ft as defineLeafStep, g as createInitialInstallationState, gt as ValidationIssue, h as RunValidationOptions, ht as StepValidationResult, i as InstallationData, it as LifecycleContext, j as executeUninstallWorkflow, k as validateStepTree, l as SucceededInstallationState, lt as ValidationContext, m as RunUninstallationOptions, mt as isLeafStep, n as InProgressInstallationState, nt as LeafStep, o as InstallationRetryMetadata, ot as StepContextFactory, p as RunInstallationOptions, pt as isBranchStep, q as isCompletedState, r as InstallationContext, rt as LeafStepOptions, s as InstallationState, st as StepMeta, t as FailedInstallationState, tt as InferStepOutput, u as CreateInitialInstallationStateOptions, ut as ValidationExecutionContext, v as runInstallation, vt as ValidationResult, w as createRetryState, x as CustomInstallationStepDefinition, y as runUninstallation, yt as ValidationSummary, z as FailedWorkflowState } from "../index-p0duTbHE.cjs";
21
21
  export { type AnyStep, type BranchStep, type BranchStepOptions, type CreateInitialInstallationStateOptions, type CreateInitialUninstallationStateOptions, type CustomInstallationStepDefinition, type CustomInstallationStepHandler, type ExecutionContext, type ExecutionStatus, type FailedInstallationState, type FailedWorkflowState, type InProgressInstallationState, type InProgressWorkflowState, type InferStepOutput, type InstallationContext, type InstallationData, type InstallationError, type InstallationHooks, type InstallationRetryMetadata, type InstallationState, type InstallationStatus, type LeafStep, type LeafStepOptions, type LifecycleContext, type RunInstallationOptions, type RunUninstallationOptions, type RunValidationOptions, type Step, type StepContextFactory, type StepEvent, type StepFailedEvent, type StepMeta, type StepMetaInfo, type StepStartedEvent, type StepStatus, type StepSucceededEvent, type StepValidationResult, type SucceededInstallationState, type SucceededWorkflowState, type ValidateStepTreeOptions, type ValidationContext, type ValidationExecutionContext, type ValidationIssue, type ValidationIssueSeverity, type ValidationResult, type ValidationSummary, type WorkflowData, type WorkflowError, type WorkflowHooks, type WorkflowRunState, type WorkflowStateMetadata, createInitialInstallationState, type createInitialPlanExecutionState, type createInitialState, createInitialUninstallationState, type createRetryState, type defineBranchStep, defineCustomInstallationStep, type defineLeafStep, type executePlannedWorkflow, type executeUninstallWorkflow, type executeWorkflow, type isBranchStep, isCompletedState, isFailedState, isInProgressState, type isLeafStep, isSucceededState, type planWorkflow, runInstallation, runUninstallation, runValidation, type validateStepTree };
@@ -12,29 +12,29 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
- const require_rolldown_runtime = require("./rolldown-runtime-CoOt0iuZ.cjs");
16
- const require_webhooks = require("./webhooks-ZPh2gVb3.cjs");
17
- const require_constants = require("./constants-CgeVvu6f.cjs");
18
- const require_utils = require("./utils-DSS0XlXq.cjs");
19
- const require_environment = require("./environment-CW6M76gS.cjs");
20
- const require_utils$1 = require("./utils-CoR_PBHz.cjs");
21
- const require_logging = require("./logging-Emi7P923.cjs");
15
+ const require_rolldown_runtime = require("./rolldown-runtime-BKfnhsn2.cjs");
16
+ let _adobe_aio_commerce_lib_api_utils = require("@adobe/aio-commerce-lib-api/utils");
17
+ const require_webhooks = require("./webhooks-Bp1Roq8a.cjs");
18
+ let ky = require("ky");
19
+ let safe_stable_stringify = require("safe-stable-stringify");
20
+ let _adobe_aio_commerce_lib_admin_ui_api = require("@adobe/aio-commerce-lib-admin-ui/api");
22
21
  let _adobe_aio_commerce_lib_api = require("@adobe/aio-commerce-lib-api");
23
- let _adobe_aio_commerce_lib_config = require("@adobe/aio-commerce-lib-config");
24
- let _adobe_aio_commerce_lib_core_error = require("@adobe/aio-commerce-lib-core/error");
25
- let _adobe_aio_commerce_lib_auth = require("@adobe/aio-commerce-lib-auth");
22
+ const require_constants = require("./constants-CgeVvu6f.cjs");
23
+ const require_utils = require("./utils-bwFwJcPW.cjs");
26
24
  let valibot = require("valibot");
27
- valibot = require_rolldown_runtime.__toESM(valibot, 1);
28
- let _adobe_aio_commerce_lib_admin_ui_api = require("@adobe/aio-commerce-lib-admin-ui/api");
29
- let safe_stable_stringify = require("safe-stable-stringify");
30
- safe_stable_stringify = require_rolldown_runtime.__toESM(safe_stable_stringify, 1);
31
- let ky = require("ky");
32
- let _adobe_aio_commerce_lib_api_utils = require("@adobe/aio-commerce-lib-api/utils");
33
25
  let camelcase = require("camelcase");
34
- camelcase = require_rolldown_runtime.__toESM(camelcase, 1);
26
+ let _adobe_aio_commerce_lib_config = require("@adobe/aio-commerce-lib-config");
27
+ const require_environment = require("./environment-CaV1hi2-.cjs");
28
+ let _adobe_aio_commerce_lib_auth = require("@adobe/aio-commerce-lib-auth");
29
+ const require_utils$1 = require("./utils-CuzJBLgo.cjs");
30
+ const require_logging = require("./logging-r-r2bUWO.cjs");
35
31
  let _adobe_aio_commerce_lib_events_commerce = require("@adobe/aio-commerce-lib-events/commerce");
36
32
  let _adobe_aio_commerce_lib_events_io_events = require("@adobe/aio-commerce-lib-events/io-events");
33
+ let _adobe_aio_commerce_lib_core_error = require("@adobe/aio-commerce-lib-core/error");
37
34
  let _adobe_aio_commerce_lib_webhooks_api = require("@adobe/aio-commerce-lib-webhooks/api");
35
+ safe_stable_stringify = require_rolldown_runtime.__toESM(safe_stable_stringify, 1);
36
+ valibot = require_rolldown_runtime.__toESM(valibot, 1);
37
+ camelcase = require_rolldown_runtime.__toESM(camelcase, 1);
38
38
 
39
39
  // source/management/common/workflow/hooks.ts
40
40
  /** Helper to call a hook if it exists. */
@@ -757,6 +757,19 @@ function enumerateComponents(adminUi) {
757
757
  });
758
758
  }
759
759
  }
760
+ const customAttributeGridColumns = adminUi.creditMemo?.customAttributeGridColumns;
761
+ if (customAttributeGridColumns) {
762
+ const key = "creditMemo.custom-attribute-grid-columns";
763
+ components.set(key, {
764
+ config: customAttributeGridColumns,
765
+ key,
766
+ label: "Credit Memo custom attribute grid columns",
767
+ ref: {
768
+ entity: "creditMemo",
769
+ kind: "customAttributeGridColumns"
770
+ }
771
+ });
772
+ }
760
773
  for (const entity of require_webhooks.ADMIN_UI_MASS_ACTION_ENTITIES) {
761
774
  const entityConfig = adminUi[entity];
762
775
  for (const massAction of entityConfig?.massActions ?? []) {
@@ -974,51 +987,7 @@ const adminUiStep = defineBranchStep({
974
987
  name: "admin-ui"
975
988
  });
976
989
 
977
- // source/management/deprecated/domains/custom-installation.ts
978
- /**
979
- * Creates the legacy install/uninstall handlers of a custom installation script leaf.
980
- * Deleted in the next major.
981
- *
982
- * @param scriptConfig - The custom installation step the handlers belong to.
983
- */
984
- function createDeprecatedCustomScriptHandlers(scriptConfig) {
985
- const { script, name } = scriptConfig;
986
- return {
987
- install: async (config, context) => {
988
- const { logger } = context;
989
- const customScripts = context.customScripts || {};
990
- logger.info(`Executing custom installation script: ${name}`);
991
- logger.debug(`Script path: ${script}`);
992
- const scriptModule = getScriptModuleOrThrow(customScripts, script);
993
- const scriptResult = await resolveCustomScriptHandler(scriptModule, "install")(config, context);
994
- logger.info(`Successfully executed script: ${name}`);
995
- return {
996
- data: scriptResult,
997
- script
998
- };
999
- },
1000
- uninstall: async (config, context) => {
1001
- const { logger } = context;
1002
- const customScripts = context.customScripts || {};
1003
- logger.debug(`Uninstalling custom script: ${name}`);
1004
- const scriptModule = getScriptModule(customScripts, script);
1005
- if (!scriptModule) {
1006
- logger.warn(`Script ${script} not found in customScripts context, skipping uninstall. It may have been removed from the project after being configured.`);
1007
- return;
1008
- }
1009
- const uninstall = resolveCustomScriptHandler(scriptModule, "uninstall");
1010
- if (!uninstall) {
1011
- logger.debug(`Script ${script} does not export an uninstall function, skipping uninstall.`);
1012
- return;
1013
- }
1014
- await uninstall(config, context);
1015
- logger.info(`Successfully uninstalled script: ${name}`);
1016
- }
1017
- };
1018
- }
1019
-
1020
- // source/management/domains/custom-installation/custom-scripts.ts
1021
- const camelcase$1 = camelcase.default.default ?? camelcase.default;
990
+ // source/management/domains/custom-installation/script-module.ts
1022
991
  const ScriptModuleSchema = valibot.union([valibot.function(), valibot.object({
1023
992
  install: valibot.function(),
1024
993
  uninstall: valibot.optional(valibot.function())
@@ -1064,6 +1033,98 @@ function getScriptModuleOrThrow(customScripts, script) {
1064
1033
  if (!scriptModule) throw new Error(`Script ${script} not found in customScripts context. Make sure the script is defined in the configuration and the action was generated with custom scripts support.`);
1065
1034
  return scriptModule;
1066
1035
  }
1036
+
1037
+ // source/management/domains/custom-installation/apply.ts
1038
+ /** Runs a newly-added step's `install` handler and returns its persisted identity. */
1039
+ async function runAddedStep(step, targetConfig, context) {
1040
+ const { logger } = context;
1041
+ const scriptModule = getScriptModuleOrThrow(context.customScripts ?? {}, step.script);
1042
+ logger.info(`Executing custom installation script: ${step.name}`);
1043
+ await resolveCustomScriptHandler(scriptModule, "install")(targetConfig, context);
1044
+ logger.info(`Successfully executed script: ${step.name}`);
1045
+ return {
1046
+ name: step.name,
1047
+ script: step.script
1048
+ };
1049
+ }
1050
+ /**
1051
+ * Runs the `uninstall` of a step that ran before. Returns whether it ran: a step whose script is
1052
+ * not deployed, or that exports no `uninstall`, is skipped with a warning.
1053
+ */
1054
+ async function runRemovedStep(step, baselineConfig, context) {
1055
+ const { logger } = context;
1056
+ const scriptModule = getScriptModule(context.customScripts ?? {}, step.script);
1057
+ if (!scriptModule) {
1058
+ logger.warn(`Skipping the uninstall of custom installation step "${step.name}": its script "${step.script}" is not deployed.`);
1059
+ return false;
1060
+ }
1061
+ const uninstall = resolveCustomScriptHandler(scriptModule, "uninstall");
1062
+ if (!uninstall) {
1063
+ logger.warn(`Skipping the uninstall of custom installation step "${step.name}": its script exports no uninstall function.`);
1064
+ return false;
1065
+ }
1066
+ logger.info(`Executing custom uninstallation script: ${step.name}`);
1067
+ await uninstall(baselineConfig, context);
1068
+ logger.info(`Successfully executed script: ${step.name}`);
1069
+ return true;
1070
+ }
1071
+ /**
1072
+ * Applies the plan of a single custom installation step. An `add` runs its `install` and records
1073
+ * the step. A `remove` runs its `uninstall` and records `null`, or keeps the step's record when its
1074
+ * `uninstall` could not run.
1075
+ */
1076
+ async function applyCustomScript(plan, context) {
1077
+ const operation = plan.operations.at(0);
1078
+ if (operation?.kind === "add" && context.targetConfig) return { snapshotData: await runAddedStep(operation.after, context.targetConfig, context) };
1079
+ if (operation?.kind === "remove") return { snapshotData: plan.baselineConfig !== null && await runRemovedStep(operation.before, plan.baselineConfig, context) ? null : operation.before };
1080
+ throw new Error(`The plan of custom installation step "${plan.path.at(-1)}" has nothing to apply`);
1081
+ }
1082
+
1083
+ // source/management/deprecated/domains/custom-installation.ts
1084
+ /**
1085
+ * Creates the legacy install/uninstall handlers of a custom installation script leaf.
1086
+ * Deleted in the next major.
1087
+ *
1088
+ * @param scriptConfig - The custom installation step the handlers belong to.
1089
+ */
1090
+ function createDeprecatedCustomScriptHandlers(scriptConfig) {
1091
+ const { script, name } = scriptConfig;
1092
+ return {
1093
+ install: async (config, context) => {
1094
+ const { logger } = context;
1095
+ const customScripts = context.customScripts || {};
1096
+ logger.info(`Executing custom installation script: ${name}`);
1097
+ logger.debug(`Script path: ${script}`);
1098
+ const scriptModule = getScriptModuleOrThrow(customScripts, script);
1099
+ const scriptResult = await resolveCustomScriptHandler(scriptModule, "install")(config, context);
1100
+ logger.info(`Successfully executed script: ${name}`);
1101
+ return {
1102
+ data: scriptResult,
1103
+ script
1104
+ };
1105
+ },
1106
+ uninstall: async (config, context) => {
1107
+ const { logger } = context;
1108
+ const customScripts = context.customScripts || {};
1109
+ logger.debug(`Uninstalling custom script: ${name}`);
1110
+ const scriptModule = getScriptModule(customScripts, script);
1111
+ if (!scriptModule) {
1112
+ logger.warn(`Script ${script} not found in customScripts context, skipping uninstall. It may have been removed from the project after being configured.`);
1113
+ return;
1114
+ }
1115
+ const uninstall = resolveCustomScriptHandler(scriptModule, "uninstall");
1116
+ if (!uninstall) {
1117
+ logger.debug(`Script ${script} does not export an uninstall function, skipping uninstall.`);
1118
+ return;
1119
+ }
1120
+ await uninstall(config, context);
1121
+ logger.info(`Successfully uninstalled script: ${name}`);
1122
+ }
1123
+ };
1124
+ }
1125
+
1126
+ // source/management/domains/custom-installation/custom-scripts.ts
1127
+ const camelcase$1 = camelcase.default.default ?? camelcase.default;
1067
1128
  /** The custom installation step the config declares with the given name, if any. */
1068
1129
  function findDeclaredStep(config, name) {
1069
1130
  return require_webhooks.hasCustomInstallationSteps(config) ? config.installation.customInstallationSteps.find((step) => step.name === name) : void 0;
@@ -1112,52 +1173,6 @@ function createCustomScriptSteps(config) {
1112
1173
  return steps.map((scriptConfig) => createCustomScriptStep(scriptConfig));
1113
1174
  }
1114
1175
 
1115
- // source/management/domains/custom-installation/apply.ts
1116
- /** Runs a newly-added step's `install` handler and returns its persisted identity. */
1117
- async function runAddedStep(step, targetConfig, context) {
1118
- const { logger } = context;
1119
- const scriptModule = getScriptModuleOrThrow(context.customScripts ?? {}, step.script);
1120
- logger.info(`Executing custom installation script: ${step.name}`);
1121
- await resolveCustomScriptHandler(scriptModule, "install")(targetConfig, context);
1122
- logger.info(`Successfully executed script: ${step.name}`);
1123
- return {
1124
- name: step.name,
1125
- script: step.script
1126
- };
1127
- }
1128
- /**
1129
- * Runs the `uninstall` of a step that ran before. Returns whether it ran: a step whose script is
1130
- * not deployed, or that exports no `uninstall`, is skipped with a warning.
1131
- */
1132
- async function runRemovedStep(step, baselineConfig, context) {
1133
- const { logger } = context;
1134
- const scriptModule = getScriptModule(context.customScripts ?? {}, step.script);
1135
- if (!scriptModule) {
1136
- logger.warn(`Skipping the uninstall of custom installation step "${step.name}": its script "${step.script}" is not deployed.`);
1137
- return false;
1138
- }
1139
- const uninstall = resolveCustomScriptHandler(scriptModule, "uninstall");
1140
- if (!uninstall) {
1141
- logger.warn(`Skipping the uninstall of custom installation step "${step.name}": its script exports no uninstall function.`);
1142
- return false;
1143
- }
1144
- logger.info(`Executing custom uninstallation script: ${step.name}`);
1145
- await uninstall(baselineConfig, context);
1146
- logger.info(`Successfully executed script: ${step.name}`);
1147
- return true;
1148
- }
1149
- /**
1150
- * Applies the plan of a single custom installation step. An `add` runs its `install` and records
1151
- * the step. A `remove` runs its `uninstall` and records `null`, or keeps the step's record when its
1152
- * `uninstall` could not run.
1153
- */
1154
- async function applyCustomScript(plan, context) {
1155
- const operation = plan.operations.at(0);
1156
- if (operation?.kind === "add" && context.targetConfig) return { snapshotData: await runAddedStep(operation.after, context.targetConfig, context) };
1157
- if (operation?.kind === "remove") return { snapshotData: plan.baselineConfig !== null && await runRemovedStep(operation.before, plan.baselineConfig, context) ? null : operation.before };
1158
- throw new Error(`The plan of custom installation step "${plan.path.at(-1)}" has nothing to apply`);
1159
- }
1160
-
1161
1176
  // source/management/domains/custom-installation/changes.ts
1162
1177
  /**
1163
1178
  * The change of one custom installation step between the baseline and the target config: `add` when