@adobe/aio-commerce-lib-app 1.6.0 → 1.8.0-alpha-20260717142750

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 +111 -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-BwehWeu1.d.cts +1835 -0
  13. package/dist/cjs/commands/index.cjs +515 -307
  14. package/dist/cjs/commands/templates/admin-ui/tsconfig.json +14 -0
  15. package/dist/cjs/commands/templates/admin-ui/web-src/index.css +5 -0
  16. package/dist/cjs/commands/templates/admin-ui/web-src/index.html +17 -0
  17. package/dist/cjs/commands/templates/admin-ui/web-src/src/app.jsx +13 -0
  18. package/dist/cjs/commands/templates/admin-ui/web-src/src/components/welcome.jsx +12 -0
  19. package/dist/cjs/commands/templates/admin-ui/web-src/src/pages/main-page.jsx +10 -0
  20. package/dist/cjs/commands/templates/{admin-ui-sdk/registration.js.template → admin-ui/web-src-template.d.ts} +11 -6
  21. package/dist/cjs/commands/templates/app-management/app-config.js.template +1 -14
  22. package/dist/cjs/commands/templates/app-management/association.js.template +6 -0
  23. package/dist/cjs/commands/templates/app-management/installation.js.template +1 -13
  24. package/dist/cjs/commands/templates/business-configuration/config.js.template +2 -15
  25. package/dist/cjs/commands/templates/business-configuration/scope-tree.js.template +0 -12
  26. package/dist/cjs/config/index.browser.cjs +18 -0
  27. package/dist/cjs/config/index.browser.d.cts +16 -0
  28. package/dist/cjs/config/{index.cjs → index.node.cjs} +9 -8
  29. package/dist/cjs/config/index.node.d.cts +1707 -0
  30. package/dist/cjs/define-DOqVyexT.d.cts +34 -0
  31. package/dist/cjs/define-hlcQw7Cv.cjs +41 -0
  32. package/dist/cjs/environment-B7EnozSg.cjs +135 -0
  33. package/dist/cjs/{index-Dw2NvVOY.d.cts → index-B3ISkC54.d.cts} +177 -3
  34. package/dist/cjs/index-BXm8UbK7.d.cts +16 -0
  35. package/dist/cjs/index.cjs +273 -0
  36. package/dist/cjs/index.d.cts +235 -0
  37. package/dist/cjs/{config-FNMclIFO.cjs → index.node-gWAIhXSG.cjs} +119 -35
  38. package/dist/cjs/{logging-BVz3weoC.cjs → logging-udPuAJPt.cjs} +2 -2
  39. package/dist/cjs/management/index.cjs +1 -1
  40. package/dist/cjs/management/index.d.cts +1 -2
  41. package/dist/cjs/{management-Cvsz4VMf.cjs → management-DEsRVP2L.cjs} +432 -591
  42. package/dist/cjs/openapi-CwytYdWl.cjs +2948 -0
  43. package/dist/cjs/repository-CbceYZqc.cjs +69 -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-C_eCKp21.cjs} +62 -30
  48. package/dist/cjs/{webhooks-tbZy9G3p.cjs → webhooks-L4DWHSOl.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-BwehWeu1.d.mts +1835 -0
  60. package/dist/es/commands/index.mjs +549 -339
  61. package/dist/es/commands/templates/admin-ui/tsconfig.json +14 -0
  62. package/dist/es/commands/templates/admin-ui/web-src/index.css +5 -0
  63. package/dist/es/commands/templates/admin-ui/web-src/index.html +17 -0
  64. package/dist/es/commands/templates/admin-ui/web-src/src/app.jsx +13 -0
  65. package/dist/es/commands/templates/admin-ui/web-src/src/components/welcome.jsx +12 -0
  66. package/dist/es/commands/templates/admin-ui/web-src/src/pages/main-page.jsx +10 -0
  67. package/dist/es/commands/templates/{admin-ui-sdk/registration.js.template → admin-ui/web-src-template.d.ts} +11 -6
  68. package/dist/es/commands/templates/app-management/app-config.js.template +1 -14
  69. package/dist/es/commands/templates/app-management/association.js.template +6 -0
  70. package/dist/es/commands/templates/app-management/installation.js.template +1 -13
  71. package/dist/es/commands/templates/business-configuration/config.js.template +2 -15
  72. package/dist/es/commands/templates/business-configuration/scope-tree.js.template +0 -12
  73. package/dist/es/config/index.browser.d.mts +16 -0
  74. package/dist/es/config/index.browser.mjs +17 -0
  75. package/dist/es/config/index.node.d.mts +1708 -0
  76. package/dist/es/config/index.node.mjs +20 -0
  77. package/dist/es/define-DxH1BFia.d.mts +34 -0
  78. package/dist/es/define-Z_Glf1-_.mjs +35 -0
  79. package/dist/es/environment-C84BPRJZ.mjs +104 -0
  80. package/dist/es/index-B0XqHwY5.d.mts +16 -0
  81. package/dist/es/{index-Bo0tQsVq.d.mts → index-DSk-RmwM.d.mts} +177 -3
  82. package/dist/es/index.d.mts +235 -0
  83. package/dist/es/index.mjs +264 -0
  84. package/dist/es/{config-CcE0EBG7.mjs → index.node-BkSA7XIO.mjs} +94 -30
  85. package/dist/es/management/index.d.mts +1 -2
  86. package/dist/es/management/index.mjs +1 -1
  87. package/dist/es/{management-BZ4Y6lVp.mjs → management-D5pmBBec.mjs} +402 -562
  88. package/dist/es/openapi-CXonvevE.mjs +2900 -0
  89. package/dist/es/repository-BGmy0YeZ.mjs +52 -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-t0T0F2MF.mjs} +48 -28
  93. package/dist/es/{webhooks-B5oq9ULL.mjs → webhooks-D7DExIDM.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,33 +13,52 @@
13
13
  */
14
14
 
15
15
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
16
- const require_chunk = require('../chunk-Cozy-1ZF.cjs');
17
- const require_router = require('../router-BOR7T6qR.cjs');
18
- const require_schemas = require('../schemas-FngDuIeo.cjs');
16
+ const require_rolldown_runtime = require('../../rolldown-runtime-Cozy-1ZF.cjs');
17
+ const require_schemas = require('../../schemas-mLxMh_ko.cjs');
18
+ const require_environment = require('../../environment-B7EnozSg.cjs');
19
+ const require_router = require('../../router-hA_Y9gZ1.cjs');
19
20
  let _adobe_aio_commerce_lib_config = require("@adobe/aio-commerce-lib-config");
20
- let _adobe_aio_commerce_lib_core_responses = require("@adobe/aio-commerce-lib-core/responses");
21
21
  let valibot = require("valibot");
22
- valibot = require_chunk.__toESM(valibot, 1);
22
+ valibot = require_rolldown_runtime.__toESM(valibot, 1);
23
+ let _adobe_aio_commerce_lib_core_commerce = require("@adobe/aio-commerce-lib-core/commerce");
24
+ let _adobe_aio_commerce_lib_core_responses = require("@adobe/aio-commerce-lib-core/responses");
23
25
 
24
- //#region source/actions/config.ts
26
+ //#region source/actions/config/schema.ts
27
+ const AcceptedConfigurationValuesSchema = valibot.union([
28
+ valibot.boolean(),
29
+ valibot.string(),
30
+ valibot.array(valibot.string())
31
+ ]);
32
+ /** Query parameters for GET / */
33
+ const GetConfigurationQuerySchema = valibot.object({
34
+ commerceEnv: valibot.optional(_adobe_aio_commerce_lib_core_commerce.CommerceEnvSchema),
35
+ scopeId: require_schemas.nonEmptyStringValueSchema("scopeId")
36
+ });
37
+ /** Request body for PUT / */
38
+ const PutConfigBodySchema = valibot.object({
39
+ config: valibot.array(valibot.object({
40
+ name: require_schemas.nonEmptyStringValueSchema("config[i].name"),
41
+ value: valibot.union([valibot.string(), valibot.array(valibot.string())])
42
+ })),
43
+ scopeId: require_schemas.nonEmptyStringValueSchema("scopeId")
44
+ });
45
+ /** Request body for PATCH / */
46
+ const PatchConfigBodySchema = valibot.object({
47
+ config: valibot.array(valibot.object({
48
+ name: require_schemas.nonEmptyStringValueSchema("config[i].name"),
49
+ value: valibot.nullable(AcceptedConfigurationValuesSchema)
50
+ })),
51
+ scopeId: require_schemas.nonEmptyStringValueSchema("scopeId")
52
+ });
53
+
54
+ //#endregion
55
+ //#region source/actions/config/router.ts
25
56
  const MASKED_PASSWORD_VALUE = "*****";
26
- /** The set of valid Commerce environments a configuration field can be scoped to. */
27
- const COMMERCE_ENVS = ["paas", "saas"];
28
- /**
29
- * Filters a business configuration schema to the fields applicable to the
30
- * given Commerce environment. Fields without an `env` property apply to all
31
- * environments and are always included.
32
- * @param schema - The business configuration schema to filter.
33
- * @param env - The Commerce environment to filter by.
34
- */
35
- function filterSchemaByEnv(schema, env) {
36
- return schema.filter((field) => field.env === void 0 || field.env.includes(env));
37
- }
38
57
  /**
39
58
  * Filters password fields from the configuration values.
59
+ *
40
60
  * @param schema - The schema to use to filter the values.
41
61
  * @param values - The values to filter.
42
- * @returns The filtered values.
43
62
  */
44
63
  function filterPasswordFields(schema, values) {
45
64
  return values.map((item) => {
@@ -50,22 +69,26 @@ function filterPasswordFields(schema, values) {
50
69
  return item;
51
70
  });
52
71
  }
53
- const router = new require_router.HttpActionRouter().use(require_router.logger());
72
+ /**
73
+ * Config action router.
74
+ *
75
+ * Routes:
76
+ * - GET / Get current configuration values for a given scope
77
+ * - POST / Set configuration (overrides all values for the scope) (deprecated)
78
+ * - PATCH / Partially update configuration (only updates provided fields, allows unsetting)
79
+ */
80
+ const router = new require_router.HttpActionRouter().use(require_router.logger({ name: () => "config" }));
54
81
  /** GET / - Retrieve configuration */
55
82
  router.get("/", {
56
- query: valibot.object({
57
- scopeId: require_schemas.nonEmptyStringValueSchema("scopeId"),
58
- commerceEnv: valibot.optional(valibot.picklist(COMMERCE_ENVS))
59
- }),
60
83
  handler: async (req, ctx) => {
61
84
  const { logger, rawParams } = ctx;
62
85
  const { configSchema: rawConfigSchema } = rawParams;
63
86
  const env = req.query.commerceEnv;
64
- const envFilteredSchema = env ? filterSchemaByEnv(rawConfigSchema, env) : rawConfigSchema;
87
+ const envFilteredSchema = env ? require_environment.filterSchemaByEnv(rawConfigSchema, env) : rawConfigSchema;
65
88
  logger.debug("Initializing configuration");
66
89
  const { configSchema } = await (0, _adobe_aio_commerce_lib_config.initialize)({
67
- schema: envFilteredSchema,
68
- params: rawParams
90
+ params: rawParams,
91
+ schema: envFilteredSchema
69
92
  });
70
93
  const { scopeId } = req.query;
71
94
  logger.debug(`Retrieving configuration with scope id: ${scopeId}`);
@@ -76,28 +99,24 @@ router.get("/", {
76
99
  schema: configSchema,
77
100
  values: appConfiguration
78
101
  } });
79
- }
102
+ },
103
+ query: GetConfigurationQuerySchema
80
104
  });
81
105
  /**
82
106
  * PUT / - Set configuration (deprecated)
107
+ *
83
108
  * @deprecated Use PATCH instead. This endpoint overwrites all values for the scope
84
109
  * and does not support partial updates or unset semantics.
85
110
  */
86
111
  router.put("/", {
87
- body: valibot.object({
88
- scopeId: require_schemas.nonEmptyStringValueSchema("scopeId"),
89
- config: valibot.array(valibot.object({
90
- name: require_schemas.nonEmptyStringValueSchema("config.name"),
91
- value: valibot.union([valibot.string(), valibot.array(valibot.string())])
92
- }))
93
- }),
112
+ body: PutConfigBodySchema,
94
113
  handler: async (req, ctx) => {
95
114
  const { logger, rawParams } = ctx;
96
115
  logger.debug(`Setting configuration with scope id: ${req.body.scopeId}`);
97
116
  const { scopeId, config } = req.body;
98
117
  const { configSchema } = await (0, _adobe_aio_commerce_lib_config.initialize)({
99
- schema: rawParams.configSchema,
100
- params: rawParams
118
+ params: rawParams,
119
+ schema: rawParams.configSchema
101
120
  });
102
121
  const result = await (0, _adobe_aio_commerce_lib_config.setConfiguration)({ config: config.filter((item) => item.value !== MASKED_PASSWORD_VALUE) }, (0, _adobe_aio_commerce_lib_config.byScopeId)(scopeId), { encryptionKey: rawParams.AIO_COMMERCE_CONFIG_ENCRYPTION_KEY });
103
122
  result.config = filterPasswordFields(configSchema, result.config);
@@ -112,24 +131,14 @@ router.put("/", {
112
131
  });
113
132
  /** PATCH / - Partially update configuration */
114
133
  router.patch("/", {
115
- body: valibot.object({
116
- scopeId: require_schemas.nonEmptyStringValueSchema("scopeId"),
117
- config: valibot.array(valibot.object({
118
- name: require_schemas.nonEmptyStringValueSchema("config.name"),
119
- value: valibot.nullable(valibot.union([
120
- valibot.boolean(),
121
- valibot.string(),
122
- valibot.array(valibot.string())
123
- ]))
124
- }))
125
- }),
134
+ body: PatchConfigBodySchema,
126
135
  handler: async (req, ctx) => {
127
136
  const { logger, rawParams } = ctx;
128
137
  logger.debug(`Patching configuration with scope id: ${req.body.scopeId}`);
129
138
  const { scopeId, config } = req.body;
130
139
  const { configSchema } = await (0, _adobe_aio_commerce_lib_config.initialize)({
131
- schema: rawParams.configSchema,
132
- params: rawParams
140
+ params: rawParams,
141
+ schema: rawParams.configSchema
133
142
  });
134
143
  const result = await (0, _adobe_aio_commerce_lib_config.setConfiguration)({ config }, (0, _adobe_aio_commerce_lib_config.byScopeId)(scopeId), { encryptionKey: rawParams.AIO_COMMERCE_CONFIG_ENCRYPTION_KEY });
135
144
  result.config = filterPasswordFields(configSchema, result.config);
@@ -139,9 +148,17 @@ router.patch("/", {
139
148
  });
140
149
  }
141
150
  });
142
- /** Factory to create the route handler for the `config` action. */
143
- const configRuntimeAction = ({ configSchema }) => async (params) => {
144
- return await router.handler()({
151
+
152
+ //#endregion
153
+ //#region source/actions/config/index.ts
154
+ /**
155
+ * Factory to create the route handler for the `config` action.
156
+ * @param args - The arguments required to create the runtime action.
157
+ */
158
+ const configRuntimeAction = (args) => async (params) => {
159
+ const handler = router.handler();
160
+ const { configSchema } = args;
161
+ return await handler({
145
162
  ...params,
146
163
  configSchema
147
164
  });
@@ -12,17 +12,20 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
- import { BusinessConfigSchema } from "@adobe/aio-commerce-lib-config";
16
15
  import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
16
+ import { BusinessConfigSchema } from "@adobe/aio-commerce-lib-config";
17
17
 
18
- //#region source/actions/config.d.ts
19
- /** The arguments for the config action factory. */
18
+ //#region source/actions/config/router.d.ts
19
+ /** The arguments required to create the runtime action for the config action. */
20
20
  type ConfigActionFactoryArgs = {
21
21
  configSchema: BusinessConfigSchema;
22
22
  };
23
- /** Factory to create the route handler for the `config` action. */
24
- declare const configRuntimeAction: ({
25
- configSchema
26
- }: ConfigActionFactoryArgs) => (params: RuntimeActionParams) => Promise<import("@adobe/aio-commerce-lib-core/responses").ActionResponse>;
23
+ //#endregion
24
+ //#region source/actions/config/index.d.ts
25
+ /**
26
+ * Factory to create the route handler for the `config` action.
27
+ * @param args - The arguments required to create the runtime action.
28
+ */
29
+ declare const configRuntimeAction: (args: ConfigActionFactoryArgs) => (params: RuntimeActionParams) => Promise<import("@adobe/aio-commerce-lib-core/responses").ActionResponse>;
27
30
  //#endregion
28
31
  export { configRuntimeAction };
@@ -13,18 +13,19 @@
13
13
  */
14
14
 
15
15
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
16
- const require_chunk = require('../chunk-Cozy-1ZF.cjs');
17
- const require_router = require('../router-BOR7T6qR.cjs');
18
- const require_schemas = require('../schemas-FngDuIeo.cjs');
19
- const require_validate = require('../validate-DydOAZha.cjs');
20
- const require_management = require('../management-Cvsz4VMf.cjs');
21
- let _adobe_aio_commerce_lib_core_responses = require("@adobe/aio-commerce-lib-core/responses");
16
+ const require_rolldown_runtime = require('../../rolldown-runtime-Cozy-1ZF.cjs');
17
+ const require_schemas = require('../../schemas-mLxMh_ko.cjs');
18
+ const require_validate = require('../../validate-C_eCKp21.cjs');
19
+ const require_management = require('../../management-DEsRVP2L.cjs');
20
+ const require_router = require('../../router-hA_Y9gZ1.cjs');
21
+ let _adobe_aio_lib_state = require("@adobe/aio-lib-state");
22
22
  let valibot = require("valibot");
23
- valibot = require_chunk.__toESM(valibot, 1);
23
+ valibot = require_rolldown_runtime.__toESM(valibot, 1);
24
+ let _adobe_aio_commerce_lib_core_commerce = require("@adobe/aio-commerce-lib-core/commerce");
25
+ let _adobe_aio_commerce_lib_core_responses = require("@adobe/aio-commerce-lib-core/responses");
24
26
  let _adobe_aio_lib_files = require("@adobe/aio-lib-files");
25
- let _adobe_aio_lib_state = require("@adobe/aio-lib-state");
26
27
  let openwhisk = require("openwhisk");
27
- openwhisk = require_chunk.__toESM(openwhisk, 1);
28
+ openwhisk = require_rolldown_runtime.__toESM(openwhisk, 1);
28
29
 
29
30
  //#region ../../packages-private/common-utils/source/storage/files-store.ts
30
31
  /** Default directory prefix. */
@@ -55,12 +56,15 @@ const DEFAULT_DIR_PREFIX = "store";
55
56
  */
56
57
  async function createFilesStore(options = {}) {
57
58
  const { dirPrefix = DEFAULT_DIR_PREFIX } = options;
58
- return new FilesStore(await (0, _adobe_aio_lib_files.init)(), dirPrefix);
59
+ const files = await (0, _adobe_aio_lib_files.init)();
60
+ return new FilesStore(files, dirPrefix);
59
61
  }
60
62
  /**
61
63
  * Key-value store implementation using @adobe/aio-lib-files.
62
64
  */
63
65
  var FilesStore = class {
66
+ files;
67
+ dirPrefix;
64
68
  constructor(files, dirPrefix) {
65
69
  this.files = files;
66
70
  this.dirPrefix = dirPrefix;
@@ -125,12 +129,16 @@ const DEFAULT_KEY_PREFIX = "store";
125
129
  */
126
130
  async function createStateStore(options = {}) {
127
131
  const { keyPrefix = DEFAULT_KEY_PREFIX, ttlSeconds = DEFAULT_TTL_SECONDS } = options;
128
- return new StateStore(await (0, _adobe_aio_lib_state.init)(), keyPrefix, ttlSeconds);
132
+ const state = await (0, _adobe_aio_lib_state.init)();
133
+ return new StateStore(state, keyPrefix, ttlSeconds);
129
134
  }
130
135
  /**
131
136
  * Key-value store implementation using @adobe/aio-lib-state.
132
137
  */
133
138
  var StateStore = class {
139
+ state;
140
+ keyPrefix;
141
+ ttlSeconds;
134
142
  constructor(state, keyPrefix, ttlSeconds) {
135
143
  this.state = state;
136
144
  this.keyPrefix = keyPrefix;
@@ -220,6 +228,9 @@ async function createCombinedStore(options = {}) {
220
228
  * Uses lib-state for cache and lib-files for persistence.
221
229
  */
222
230
  var CombinedStore = class {
231
+ cache;
232
+ persistent;
233
+ shouldPersist;
223
234
  constructor(cache, persistent, shouldPersist) {
224
235
  this.cache = cache;
225
236
  this.persistent = persistent;
@@ -240,7 +251,7 @@ var CombinedStore = class {
240
251
  if (!this.shouldPersist || this.shouldPersist(data)) await this.persistent.put(key, data);
241
252
  }
242
253
  async delete(key) {
243
- const [cacheDeleted, persistentDeleted] = await Promise.all([this.cache.delete?.(key) ?? Promise.resolve(false), this.persistent.delete?.(key) ?? Promise.resolve(false)]);
254
+ const [cacheDeleted, persistentDeleted] = await Promise.all([this.cache.delete(key), this.persistent.delete(key)]);
244
255
  return cacheDeleted || persistentDeleted;
245
256
  }
246
257
  };
@@ -260,16 +271,19 @@ const AppDataSchema = valibot.object({
260
271
  });
261
272
 
262
273
  //#endregion
263
- //#region source/actions/installation.ts
264
- const DEFAULT_ACTION_NAME = "app-management/installation";
265
- /** Request body schema shared by POST / and POST /validation. */
266
- const InstallationRequestBodySchema = (0, valibot.object)({
274
+ //#region source/actions/installation/schema.ts
275
+ /** Request body for POST / and POST /validation (shared shape) */
276
+ const InstallationRequestBodySchema = valibot.object({
267
277
  appData: AppDataSchema,
268
- commerceBaseUrl: (0, valibot.string)(),
269
- commerceEnv: (0, valibot.string)(),
270
- ioEventsUrl: (0, valibot.string)(),
271
- ioEventsEnv: (0, valibot.string)()
278
+ commerceBaseUrl: valibot.string(),
279
+ commerceEnv: _adobe_aio_commerce_lib_core_commerce.CommerceEnvSchema,
280
+ ioEventsEnv: valibot.string(),
281
+ ioEventsUrl: valibot.string()
272
282
  });
283
+
284
+ //#endregion
285
+ //#region source/actions/installation/router.ts
286
+ const DEFAULT_ACTION_NAME = "app-management/installation";
273
287
  /** Creates a workflow state store with the given prefix. */
274
288
  function createWorkflowStore(prefix) {
275
289
  return createCombinedStore({
@@ -299,11 +313,11 @@ function getStorageKey() {
299
313
  function buildWorkflowParams(body, rawParams) {
300
314
  return {
301
315
  ...rawParams,
302
- appData: body.appData,
303
- AIO_EVENTS_API_BASE_URL: body.ioEventsUrl,
304
- AIO_COMMERCE_AUTH_IMS_ENVIRONMENT: body.ioEventsEnv,
305
316
  AIO_COMMERCE_API_BASE_URL: body.commerceBaseUrl,
306
- AIO_COMMERCE_API_FLAVOR: body.commerceEnv
317
+ AIO_COMMERCE_API_FLAVOR: body.commerceEnv,
318
+ AIO_COMMERCE_AUTH_IMS_ENVIRONMENT: body.ioEventsEnv,
319
+ AIO_EVENTS_API_BASE_URL: body.ioEventsUrl,
320
+ appData: body.appData
307
321
  };
308
322
  }
309
323
  /**
@@ -313,9 +327,9 @@ function buildWorkflowParams(body, rawParams) {
313
327
  function buildInstallationContext(params, appConfig, logFn) {
314
328
  return {
315
329
  appData: params.appData,
316
- params,
330
+ customScripts: params.customScriptsLoader?.(appConfig, logFn) ?? {},
317
331
  logger: logFn,
318
- customScripts: params.customScriptsLoader?.(appConfig, logFn) ?? {}
332
+ params
319
333
  };
320
334
  }
321
335
  /**
@@ -340,26 +354,26 @@ function createInstallationHooks(store, logFn) {
340
354
  await store.put(getStorageKey(), data);
341
355
  };
342
356
  return {
343
- onInstallationStart: (state) => logAndSave("Installation started", state),
344
357
  onInstallationFailure: (state) => logAndSave("Installation failed", state),
358
+ onInstallationStart: (state) => logAndSave("Installation started", state),
345
359
  onInstallationSuccess: (state) => logAndSave(state.status === "succeeded" && state.metadata?.isRetry ? "Installation succeeded on retry" : "Installation succeeded", state),
360
+ onStepFailure: (event, state) => logAndSave(`Step failed: ${event.stepName} — ${event.error.message ?? `(key: ${event.error.key})`}`, state),
346
361
  onStepStart: (event, state) => logAndSave(`Step started: ${event.stepName}`, state),
347
- onStepSuccess: (event, state) => logAndSave(`Step succeeded: ${event.stepName}`, state),
348
- onStepFailure: (event, state) => logAndSave(`Step failed: ${event.stepName} — ${event.error.message ?? `(key: ${event.error.key})`}`, state)
362
+ onStepSuccess: (event, state) => logAndSave(`Step succeeded: ${event.stepName}`, state)
349
363
  };
350
364
  }
351
365
  /**
352
366
  * Installation action router.
353
367
  *
354
368
  * Routes:
355
- * - GET /installation - Get current installation status
356
- * - POST /installation - Start installation (creates plan, invokes execution async)
357
- * - POST /installation/execution - Execute installation (internal, called async)
358
- * - POST /installation/validation - Pre-installation validation
359
- * - POST /installation/uninstallation - Start uninstallation (async)
360
- * - GET /installation/uninstallation - Get current uninstallation status
361
- * - POST /installation/uninstallation/execution - Execute uninstallation (internal, called async)
362
- * - DELETE /installation/uninstallation - Clear uninstallation state only (no offboarding)
369
+ * - GET / Get current installation status
370
+ * - POST / Start installation (creates plan, invokes execution async)
371
+ * - POST /execution Execute installation (internal, called async)
372
+ * - POST /validation Pre-installation validation
373
+ * - POST /uninstallation Start uninstallation (creates plan, invokes execution async)
374
+ * - GET /uninstallation Get current uninstallation status
375
+ * - POST /uninstallation/execution Execute uninstallation (internal, called async)
376
+ * - DELETE /uninstallation Clear uninstallation state only (no offboarding)
363
377
  */
364
378
  const router = new require_router.HttpActionRouter().use(require_router.logger({ name: () => "installation" }));
365
379
  /**
@@ -401,7 +415,7 @@ router.post("/", {
401
415
  logger.debug("Previous installation failed, allowing retry");
402
416
  }
403
417
  const rawAppConfig = rawParams.appConfig;
404
- if (!rawAppConfig) return (0, _adobe_aio_commerce_lib_core_responses.internalServerError)("Could not find or parse the app.commerce.manifest.json file, is it present and valid?");
418
+ if (!rawAppConfig) return (0, _adobe_aio_commerce_lib_core_responses.internalServerError)("The app config is missing. Does the action receive it as a parameter?");
405
419
  const appConfig = require_validate.validateCommerceAppConfig(rawAppConfig);
406
420
  const initialState = require_management.createInitialInstallationState({ config: appConfig });
407
421
  logger.debug(`Created initial state: ${initialState.id}`);
@@ -409,27 +423,28 @@ router.post("/", {
409
423
  const ow = (0, openwhisk.default)();
410
424
  const mergedParams = buildWorkflowParams(req.body, rawParams);
411
425
  const activation = await ow.actions.invoke({
412
- name: DEFAULT_ACTION_NAME,
413
426
  blocking: false,
414
- result: false,
427
+ name: DEFAULT_ACTION_NAME,
415
428
  params: {
416
429
  ...mergedParams,
417
- initialState,
418
- appConfig,
430
+ __ow_method: "post",
419
431
  __ow_path: "/execution",
420
- __ow_method: "post"
421
- }
432
+ appConfig,
433
+ initialState
434
+ },
435
+ result: false
422
436
  });
423
437
  logger.debug(`Async execution started: ${activation.activationId}`);
424
438
  return (0, _adobe_aio_commerce_lib_core_responses.accepted)({ body: {
425
- message: "Installation started",
426
439
  activationId: activation.activationId,
440
+ message: "Installation started",
427
441
  ...initialState
428
442
  } });
429
443
  }
430
444
  });
431
445
  /**
432
- * POST /installation/execution - Execute installation (internal)
446
+ * POST /installation/execution - Execute installation
447
+ * @internal - Do not add to OpenAPI Spec.
433
448
  *
434
449
  * This endpoint is called asynchronously by POST /installation.
435
450
  * It runs the actual installation workflow and saves state.
@@ -445,16 +460,16 @@ router.post("/execution", { handler: async (_req, { logger, rawParams }) => {
445
460
  const installationContext = buildInstallationContext(params, appConfig, logger);
446
461
  logger.debug(`Executing installation ${initialState.id} for app "${appData.projectName}" (workspace: "${appData.workspaceName}", commerce: "${AIO_COMMERCE_API_BASE_URL}")`);
447
462
  const result = await require_management.runInstallation({
448
- installationContext,
449
463
  config: appConfig,
464
+ hooks,
450
465
  initialState,
451
- hooks
466
+ installationContext
452
467
  });
453
468
  await store.put(getStorageKey(), result);
454
469
  logger.debug(`Installation completed: ${result.status}`);
455
470
  if (require_management.isFailedState(result)) return (0, _adobe_aio_commerce_lib_core_responses.internalServerError)({ body: {
456
- message: "Installation failed",
457
471
  error: result.error,
472
+ message: "Installation failed",
458
473
  state: result
459
474
  } });
460
475
  return (0, _adobe_aio_commerce_lib_core_responses.ok)({ body: result });
@@ -476,16 +491,16 @@ router.post("/validation", {
476
491
  handler: async (req, { logger, rawParams }) => {
477
492
  logger.debug("Running pre-installation validation...");
478
493
  const rawAppConfig = rawParams.appConfig;
479
- if (!rawAppConfig) return (0, _adobe_aio_commerce_lib_core_responses.internalServerError)("Could not find or parse the app.commerce.manifest.json file, is it present and valid?");
494
+ if (!rawAppConfig) return (0, _adobe_aio_commerce_lib_core_responses.internalServerError)("The app config is missing. Does the action receive it as a parameter?");
480
495
  const appConfig = require_validate.validateCommerceAppConfig(rawAppConfig);
481
496
  const { appData, ...params } = buildWorkflowParams(req.body, rawParams);
482
497
  const result = await require_management.runValidation({
498
+ config: appConfig,
483
499
  validationContext: {
484
500
  appData,
485
- params,
486
- logger
487
- },
488
- config: appConfig
501
+ logger,
502
+ params
503
+ }
489
504
  });
490
505
  logger.debug(`Validation complete — valid: ${result.valid}, errors: ${result.summary.errors}, warnings: ${result.summary.warnings}`);
491
506
  return (0, _adobe_aio_commerce_lib_core_responses.ok)({ body: result });
@@ -515,41 +530,43 @@ router.post("/uninstallation", {
515
530
  handler: async (req, { logger, rawParams }) => {
516
531
  const { appData, commerceBaseUrl } = req.body;
517
532
  logger.debug(`Starting uninstallation for app "${appData.projectName}" (workspace: "${appData.workspaceName}", commerce: "${commerceBaseUrl}")`);
518
- const rawAppConfig = rawParams.appConfig;
519
- if (!rawAppConfig) return (0, _adobe_aio_commerce_lib_core_responses.internalServerError)("Could not find or parse the app.commerce.manifest.json file, is it present and valid?");
520
- const appConfig = require_validate.validateCommerceAppConfig(rawAppConfig);
521
533
  const store = await createUninstallationStore();
522
534
  const existingState = await store.get(getStorageKey());
523
535
  if (existingState && require_management.isInProgressState(existingState)) {
524
536
  logger.debug(`Uninstallation already in progress: ${existingState.status}`);
525
537
  return (0, _adobe_aio_commerce_lib_core_responses.conflict)("Uninstallation is already in progress. Wait for it to complete.");
526
538
  }
527
- const initialState = require_management.createInitialUninstallationState({ config: appConfig });
539
+ const installAppConfig = (await getInstallationSnapshot())?.config;
540
+ const uninstallConfig = installAppConfig ?? rawParams.appConfig;
541
+ if (!uninstallConfig) return (0, _adobe_aio_commerce_lib_core_responses.internalServerError)("Cannot determine what to uninstall: no recorded installation snapshot and no app config was provided.");
542
+ logger.debug(installAppConfig ? "Sourcing uninstallation from recorded install snapshot" : "No recorded install config found; falling back to request config");
543
+ const initialState = require_management.createInitialUninstallationState({ config: require_validate.validateCommerceAppConfig(uninstallConfig) });
528
544
  logger.debug(`Created initial uninstall state: ${initialState.id}`);
529
545
  await store.put(getStorageKey(), initialState);
530
546
  const workflowParams = buildWorkflowParams(req.body, rawParams);
531
547
  const activation = await (0, openwhisk.default)().actions.invoke({
532
- name: DEFAULT_ACTION_NAME,
533
548
  blocking: false,
534
- result: false,
549
+ name: DEFAULT_ACTION_NAME,
535
550
  params: {
536
551
  ...workflowParams,
537
- initialState,
538
- appConfig,
552
+ __ow_method: "post",
539
553
  __ow_path: "/uninstallation/execution",
540
- __ow_method: "post"
541
- }
554
+ appConfig: uninstallConfig,
555
+ initialState
556
+ },
557
+ result: false
542
558
  });
543
559
  logger.debug(`Async uninstallation started: ${activation.activationId}`);
544
560
  return (0, _adobe_aio_commerce_lib_core_responses.accepted)({ body: {
545
- message: "Uninstallation started",
546
561
  activationId: activation.activationId,
562
+ message: "Uninstallation started",
547
563
  ...initialState
548
564
  } });
549
565
  }
550
566
  });
551
567
  /**
552
- * POST /uninstallation/execution - Execute uninstallation (internal, called async by POST /uninstallation)
568
+ * POST /uninstallation/execution - Execute uninstallation
569
+ * @internal - Do not add to OpenAPI Spec.
553
570
  *
554
571
  * Flow:
555
572
  * 1. Build InstallationContext from params
@@ -569,10 +586,10 @@ router.post("/uninstallation/execution", { handler: async (_req, { logger, rawPa
569
586
  const installationContext = buildInstallationContext(params, appConfig, logger);
570
587
  logger.debug(`Executing uninstallation ${initialState.id} for app "${appData.projectName}" (workspace: "${appData.workspaceName}", commerce: "${AIO_COMMERCE_API_BASE_URL}")`);
571
588
  const result = await require_management.runUninstallation({
572
- installationContext,
573
589
  config: appConfig,
590
+ hooks,
574
591
  initialState,
575
- hooks
592
+ installationContext
576
593
  });
577
594
  await store.put(getStorageKey(), result);
578
595
  logger.debug(`Uninstallation completed: ${result.status}`);
@@ -581,8 +598,8 @@ router.post("/uninstallation/execution", { handler: async (_req, { logger, rawPa
581
598
  logger.debug("Cleared installation state after successful uninstallation");
582
599
  }
583
600
  if (require_management.isFailedState(result)) return (0, _adobe_aio_commerce_lib_core_responses.internalServerError)({ body: {
584
- message: "Uninstallation failed",
585
601
  error: result.error,
602
+ message: "Uninstallation failed",
586
603
  state: result
587
604
  } });
588
605
  return (0, _adobe_aio_commerce_lib_core_responses.ok)({ body: result });
@@ -598,9 +615,26 @@ router.delete("/uninstallation", { handler: async (_req, { logger }) => {
598
615
  logger.debug("Uninstallation state cleared");
599
616
  return (0, _adobe_aio_commerce_lib_core_responses.noContent)();
600
617
  } });
601
- /** Factory to create the route handler for the `installation` action. */
602
- const installationRuntimeAction = ({ appConfig, customScriptsLoader }) => async (params) => {
603
- return await router.handler()({
618
+ /**
619
+ * Returns the completed installation snapshot that recorded its config, or null
620
+ * when none is authoritative (no install, an in-progress install, or a legacy
621
+ * record persisted before the config was recorded).
622
+ */
623
+ async function getInstallationSnapshot() {
624
+ const installSnapshot = await (await createInstallationStore()).get(getStorageKey());
625
+ return installSnapshot && require_management.isCompletedState(installSnapshot) && installSnapshot.config ? installSnapshot : null;
626
+ }
627
+
628
+ //#endregion
629
+ //#region source/actions/installation/index.ts
630
+ /**
631
+ * Factory to create the route handler for the `installation` action.
632
+ * @param args - The arguments required to create the runtime action.
633
+ */
634
+ const installationRuntimeAction = (args) => async (params) => {
635
+ const handler = router.handler();
636
+ const { appConfig, customScriptsLoader } = args;
637
+ return await handler({
604
638
  ...params,
605
639
  appConfig,
606
640
  customScriptsLoader
@@ -12,21 +12,23 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
- import { n as CommerceAppConfigOutputModel, t as CommerceAppConfig } from "../app-CakwxQvs.mjs";
16
- import { o as InstallationContext } from "../step-D64mMPrt.mjs";
15
+ import { n as CommerceAppConfig, r as CommerceAppConfigOutputModel } from "../../app-BwehWeu1.cjs";
16
+ import { Y as InstallationContext } from "../../index-B3ISkC54.cjs";
17
17
  import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
18
18
 
19
- //#region source/actions/installation.d.ts
19
+ //#region source/actions/installation/router.d.ts
20
20
  type CustomScriptsLoader = (config: CommerceAppConfigOutputModel, logger: InstallationContext["logger"]) => Record<string, unknown>;
21
21
  /** Arguments for the runtime action factory. */
22
22
  type RuntimeActionFactoryArgs = {
23
23
  appConfig: CommerceAppConfig;
24
24
  customScriptsLoader?: CustomScriptsLoader;
25
25
  };
26
- /** Factory to create the route handler for the `installation` action. */
27
- declare const installationRuntimeAction: ({
28
- appConfig,
29
- customScriptsLoader
30
- }: RuntimeActionFactoryArgs) => (params: RuntimeActionParams) => Promise<import("@adobe/aio-commerce-lib-core/responses").ActionResponse>;
26
+ //#endregion
27
+ //#region source/actions/installation/index.d.ts
28
+ /**
29
+ * Factory to create the route handler for the `installation` action.
30
+ * @param args - The arguments required to create the runtime action.
31
+ */
32
+ declare const installationRuntimeAction: (args: RuntimeActionFactoryArgs) => (params: RuntimeActionParams) => Promise<import("@adobe/aio-commerce-lib-core/responses").ActionResponse>;
31
33
  //#endregion
32
34
  export { installationRuntimeAction };