@adobe/aio-commerce-lib-app 2.1.0-beta-20261028171115 → 2.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.
- package/CHANGELOG.md +15 -13
- package/dist/cjs/actions/app-config/index.cjs +4 -4
- package/dist/cjs/actions/association/index.cjs +1 -1
- package/dist/cjs/actions/config/index.cjs +2 -2
- package/dist/cjs/actions/installation/index.cjs +88 -100
- package/dist/cjs/actions/installation/index.d.cts +1 -1
- package/dist/cjs/actions/scope-tree/index.cjs +2 -2
- package/dist/cjs/commands/index.cjs +48 -35
- package/dist/cjs/config/index.node.cjs +2 -2
- package/dist/cjs/config/index.node.d.cts +1 -1
- package/dist/cjs/{index-CkejDFwj.d.cts → index-D-Qn-irL.d.cts} +5 -2
- package/dist/cjs/{index.node-BVp-SSw8.cjs → index.node-CxdwPrOg.cjs} +1 -1
- package/dist/cjs/management/index.cjs +1 -1
- package/dist/cjs/management/index.d.cts +1 -1
- package/dist/cjs/{management-Cwm3C9g0.cjs → management-C_JQpgVB.cjs} +2 -2
- package/dist/cjs/{openapi-XsGx1PMf.cjs → openapi-DFoMdZzI.cjs} +15 -175
- package/dist/cjs/{validate-ChXLh7rw.cjs → validate-B0rOILvG.cjs} +14 -1
- package/dist/es/actions/app-config/index.mjs +4 -4
- package/dist/es/actions/association/index.mjs +1 -1
- package/dist/es/actions/config/index.mjs +2 -2
- package/dist/es/actions/installation/index.d.mts +1 -1
- package/dist/es/actions/installation/index.mjs +88 -100
- package/dist/es/actions/scope-tree/index.mjs +2 -2
- package/dist/es/commands/index.mjs +49 -36
- package/dist/es/config/index.node.d.mts +1 -1
- package/dist/es/config/index.node.mjs +2 -2
- package/dist/es/{index-DgbSfJG7.d.mts → index-VgCNSlLP.d.mts} +5 -2
- package/dist/es/{index.node-ptUgKLMP.mjs → index.node-C8EXBW94.mjs} +1 -1
- package/dist/es/management/index.d.mts +1 -1
- package/dist/es/management/index.mjs +1 -1
- package/dist/es/{management-DEpo0JN4.mjs → management-DKDR7-fX.mjs} +2 -2
- package/dist/es/{openapi-DG5-kOUx.mjs → openapi-E_1RFhAr.mjs} +15 -175
- package/dist/es/{validate-Dk9U67PF.mjs → validate-CiJIjyOr.mjs} +9 -2
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @adobe/aio-commerce-lib-app
|
|
2
2
|
|
|
3
|
-
## 2.1.0
|
|
3
|
+
## 2.1.0
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
- [#699](https://github.com/adobe/aio-commerce-sdk/pull/699) [`53f1f8b`](https://github.com/adobe/aio-commerce-sdk/commit/53f1f8be4428862015294f1edc2816972e501a9e) Thanks [@mariam21arauj](https://github.com/mariam21arauj)! - Add a `newsletter` entity to the v2 `adminUi` config so apps can declare Newsletter Subscriber grid columns on `commerce/backend-ui/2`.
|
|
14
14
|
|
|
15
|
-
- [#744](https://github.com/adobe/aio-commerce-sdk/pull/744) [`8f28544`](https://github.com/adobe/aio-commerce-sdk/commit/8f2854444cba44b3a41e6572b2f388487f2872c5) Thanks [@iivvaannxx](https://github.com/iivvaannxx)! - Trace failed lifecycle operations. `GET /installation
|
|
15
|
+
- [#744](https://github.com/adobe/aio-commerce-sdk/pull/744) [`8f28544`](https://github.com/adobe/aio-commerce-sdk/commit/8f2854444cba44b3a41e6572b2f388487f2872c5) Thanks [@iivvaannxx](https://github.com/iivvaannxx)! - Trace failed lifecycle operations. `GET /installation` reads the latest attempt. `attemptId` reads one attempt, and `operation` (`install`, `upgrade` or `uninstall`) reads only the attempts of that operation, with `204` when none ran it. Attempt statuses now include the OpenWhisk activations that started and executed them and, once an attempt succeeds, the snapshot and app version it left installed. Steps record when they started and completed, the default logs show each lifecycle transition with its ids, and the `post-app-deploy` hook prints the run id and the execution activation id when an automatic upgrade fails.
|
|
16
16
|
|
|
17
17
|
- [#777](https://github.com/adobe/aio-commerce-sdk/pull/777) [`130e26b`](https://github.com/adobe/aio-commerce-sdk/commit/130e26b521b32a168a5a73ac8390cafb8d39d36a) Thanks [@iivvaannxx](https://github.com/iivvaannxx)! - Plans and attempt statuses now list the configuration changes of each domain in a `changes` array, which is empty when there are none. It names the items the new configuration adds, updates or removes compared with the installed one. It does not depend on the live state, so an item that is already live still appears. The step of an attempt now shows a domain whose items are already in place as succeeded.
|
|
18
18
|
|
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
|
|
27
27
|
- [#716](https://github.com/adobe/aio-commerce-sdk/pull/716) [`a643c80`](https://github.com/adobe/aio-commerce-sdk/commit/a643c80fc480483918dc17d4b718225ffbdae24b) Thanks [@iivvaannxx](https://github.com/iivvaannxx)! - Retrying a failed upgrade now plans again from the current state instead of resuming from where the failed attempt stopped. Each planned operation now has a `reason`: `change` when the new configuration causes it, `drift` when only the deployed state differs from the configuration.
|
|
28
28
|
|
|
29
|
+
- [#788](https://github.com/adobe/aio-commerce-sdk/pull/788) [`fb08604`](https://github.com/adobe/aio-commerce-sdk/commit/fb08604f4ce27775fe827c47366f56410b49e8e5) Thanks [@iivvaannxx](https://github.com/iivvaannxx)! - The installation action no longer reads the `x-aio-commerce-installation-invocation-source` header. `GET /` with no lifecycle attempt and no `operation` now always falls back to the legacy installation record, and the OpenAPI document no longer lists the header.
|
|
30
|
+
|
|
29
31
|
- [#763](https://github.com/adobe/aio-commerce-sdk/pull/763) [`b5bb479`](https://github.com/adobe/aio-commerce-sdk/commit/b5bb4797d7361e1e64b1c5daf1c674b076f3b22c) Thanks [@iivvaannxx](https://github.com/iivvaannxx)! - Keep the extension points in `app.config.yaml` in a fixed order (backend UI, configuration, then extensibility) so an upgrade works reliably. `init` and the `postinstall` hook write and reorder the file. If it is still out of order, the `pre-app-build` hook reorders it and logs a one-off warning. Also stop `init` from adding a blank line before the `extensions` key in `app.config.yaml` and `install.yaml`.
|
|
30
32
|
|
|
31
33
|
- [#716](https://github.com/adobe/aio-commerce-sdk/pull/716) [`a643c80`](https://github.com/adobe/aio-commerce-sdk/commit/a643c80fc480483918dc17d4b718225ffbdae24b) Thanks [@iivvaannxx](https://github.com/iivvaannxx)! - Upgrades now use the Adobe I/O Events URL and IMS environment from the request, like installs and uninstalls do.
|
|
@@ -35,13 +37,13 @@
|
|
|
35
37
|
- [#717](https://github.com/adobe/aio-commerce-sdk/pull/717) [`fe9135b`](https://github.com/adobe/aio-commerce-sdk/commit/fe9135b4d1a88f65cee94fe03f8bbe167bb0e1bc) Thanks [@iivvaannxx](https://github.com/iivvaannxx)! - Upgrades now fix webhooks that a failed upgrade or a manual edit left missing, different or no longer declared.
|
|
36
38
|
|
|
37
39
|
- [#724](https://github.com/adobe/aio-commerce-sdk/pull/724) [`36cd90a`](https://github.com/adobe/aio-commerce-sdk/commit/36cd90acde5e8713a289ad2d9470525a708cdb8d) Thanks [@iivvaannxx](https://github.com/iivvaannxx)! - Several issues fixed:
|
|
38
|
-
|
|
40
|
+
|
|
39
41
|
- An upgrade request that runs into another one in progress, or whose plan another request replaced, now gets a `409` with code `in-progress` or `stale-plan` instead of a `500`.
|
|
40
|
-
|
|
42
|
+
|
|
41
43
|
- An upgrade that cannot start, for example because the app was deployed again after planning, is recorded as failed right away instead of blocking new upgrades until its deadline.
|
|
42
|
-
|
|
44
|
+
|
|
43
45
|
- A request whose stored upgrade state cannot be read now gets a `409` with code `unreadable-state` instead of installing the app again.
|
|
44
|
-
|
|
46
|
+
|
|
45
47
|
- When saving installation or upgrade state fails, the cached copy no longer keeps the unsaved value.
|
|
46
48
|
|
|
47
49
|
- [#744](https://github.com/adobe/aio-commerce-sdk/pull/744) [`8f28544`](https://github.com/adobe/aio-commerce-sdk/commit/8f2854444cba44b3a41e6572b2f388487f2872c5) Thanks [@iivvaannxx](https://github.com/iivvaannxx)! - Install, upgrade and uninstall now plan the operation and validate the plan before anything changes. Uninstalling removes what the app installed and what it can prove it owns, even without an installation record, and runs the uninstall of every custom installation step that ran and is still configured. Every lifecycle operation uses the Commerce instance stored at association.
|
|
@@ -58,13 +60,13 @@
|
|
|
58
60
|
|
|
59
61
|
- [#689](https://github.com/adobe/aio-commerce-sdk/pull/689) [`194db8d`](https://github.com/adobe/aio-commerce-sdk/commit/194db8d382edf49f7976ea9aeffad54acb8e3da1) Thanks [@obarcelonap](https://github.com/obarcelonap)! - Commerce Eventing setup now provides a default technical account when your app authenticates with OAuth Server-to-Server credentials that don't have one, such as those provided via the `include-ims-credentials` annotation, so Commerce can still consume the workspace configuration. The pre-build hook also warns that manually wired `AIO_COMMERCE_AUTH_IMS_*` credentials are deprecated.
|
|
60
62
|
- Updated dependencies [[`264539a`](https://github.com/adobe/aio-commerce-sdk/commit/264539a13371b11b637eb01fd1c0aa185f4349cc), [`cda4f20`](https://github.com/adobe/aio-commerce-sdk/commit/cda4f206c9cd1877046f5a2196fa60478d35dfb9), [`d78221e`](https://github.com/adobe/aio-commerce-sdk/commit/d78221e01894d2209b7864aca6a5fbfab93c7192), [`f513024`](https://github.com/adobe/aio-commerce-sdk/commit/f5130248fb5033cb019ad561358a9d436be7c0f7), [`194db8d`](https://github.com/adobe/aio-commerce-sdk/commit/194db8d382edf49f7976ea9aeffad54acb8e3da1), [`53f1f8b`](https://github.com/adobe/aio-commerce-sdk/commit/53f1f8be4428862015294f1edc2816972e501a9e), [`395eb22`](https://github.com/adobe/aio-commerce-sdk/commit/395eb22da7646944d5e5f02e1517dc23cc3ebfe6), [`9145e82`](https://github.com/adobe/aio-commerce-sdk/commit/9145e822b17b99465bfee649fae69d61c11bc0ab)]:
|
|
61
|
-
- @adobe/aio-commerce-lib-admin-ui@1.2.0
|
|
62
|
-
- @adobe/aio-commerce-lib-config@1.8.1
|
|
63
|
-
- @adobe/aio-commerce-lib-api@1.4.1
|
|
64
|
-
- @adobe/aio-commerce-lib-events@1.5.0
|
|
65
|
-
- @adobe/aio-commerce-lib-auth@1.2.0
|
|
66
|
-
- @adobe/aio-commerce-lib-core@1.3.0
|
|
67
|
-
- @adobe/aio-commerce-lib-webhooks@1.2.3
|
|
63
|
+
- @adobe/aio-commerce-lib-admin-ui@1.2.0
|
|
64
|
+
- @adobe/aio-commerce-lib-config@1.8.1
|
|
65
|
+
- @adobe/aio-commerce-lib-api@1.4.1
|
|
66
|
+
- @adobe/aio-commerce-lib-events@1.5.0
|
|
67
|
+
- @adobe/aio-commerce-lib-auth@1.2.0
|
|
68
|
+
- @adobe/aio-commerce-lib-core@1.3.0
|
|
69
|
+
- @adobe/aio-commerce-lib-webhooks@1.2.3
|
|
68
70
|
|
|
69
71
|
## 2.0.0
|
|
70
72
|
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
|
|
15
15
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
16
16
|
const require_rolldown_runtime = require("../../rolldown-runtime-CoOt0iuZ.cjs");
|
|
17
|
-
const require_environment = require("../../environment-CW6M76gS.cjs");
|
|
18
|
-
const require_validate = require("../../validate-ChXLh7rw.cjs");
|
|
19
17
|
const require_router = require("../../router-DpB8wpR2.cjs");
|
|
18
|
+
const require_environment = require("../../environment-CW6M76gS.cjs");
|
|
19
|
+
const require_validate = require("../../validate-B0rOILvG.cjs");
|
|
20
20
|
let _adobe_aio_commerce_lib_config = require("@adobe/aio-commerce-lib-config");
|
|
21
21
|
let _adobe_aio_commerce_lib_core_commerce = require("@adobe/aio-commerce-lib-core/commerce");
|
|
22
22
|
let valibot = require("valibot");
|
|
@@ -29,7 +29,7 @@ let crypto = require("crypto");
|
|
|
29
29
|
* Loads the committed OpenAPI spec via dynamic import so it
|
|
30
30
|
* lands in its own chunk and is not parsed on every cold start.
|
|
31
31
|
*/
|
|
32
|
-
const importOpenApi = () => Promise.resolve().then(() => require("../../openapi-
|
|
32
|
+
const importOpenApi = () => Promise.resolve().then(() => require("../../openapi-DFoMdZzI.cjs"));
|
|
33
33
|
/** Matches component schema `$ref` strings, capturing the schema name. */
|
|
34
34
|
const SCHEMA_REF_PATTERN = /"#\/components\/schemas\/(?<schema>\w+)"/gu;
|
|
35
35
|
/**
|
|
@@ -80,7 +80,7 @@ function pruneUnusedTags(spec) {
|
|
|
80
80
|
* @param domains - The active config domains.
|
|
81
81
|
*/
|
|
82
82
|
function getOpenApiCacheKey(domains) {
|
|
83
|
-
const input = `2.1.0
|
|
83
|
+
const input = `2.1.0:${[...domains].sort().join(",")}:4.0.0`;
|
|
84
84
|
return (0, crypto.createHash)("sha256").update(input).digest("hex").slice(0, 8);
|
|
85
85
|
}
|
|
86
86
|
/** Returns the server URL to be set in the OpenAPI spec, based on the current namespace. */
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
16
16
|
const require_rolldown_runtime = require("../../rolldown-runtime-CoOt0iuZ.cjs");
|
|
17
|
-
const require_repository = require("../../repository-C3nn0Mon.cjs");
|
|
18
17
|
const require_router = require("../../router-DpB8wpR2.cjs");
|
|
18
|
+
const require_repository = require("../../repository-C3nn0Mon.cjs");
|
|
19
19
|
let _adobe_aio_commerce_lib_auth = require("@adobe/aio-commerce-lib-auth");
|
|
20
20
|
let _adobe_aio_commerce_lib_core_commerce = require("@adobe/aio-commerce-lib-core/commerce");
|
|
21
21
|
let valibot = require("valibot");
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
|
|
15
15
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
16
16
|
const require_rolldown_runtime = require("../../rolldown-runtime-CoOt0iuZ.cjs");
|
|
17
|
-
const require_schemas = require("../../schemas-B6ITl1bG.cjs");
|
|
18
|
-
const require_environment = require("../../environment-CW6M76gS.cjs");
|
|
19
17
|
const require_router = require("../../router-DpB8wpR2.cjs");
|
|
18
|
+
const require_environment = require("../../environment-CW6M76gS.cjs");
|
|
19
|
+
const require_schemas = require("../../schemas-B6ITl1bG.cjs");
|
|
20
20
|
let _adobe_aio_commerce_lib_config = require("@adobe/aio-commerce-lib-config");
|
|
21
21
|
let _adobe_aio_commerce_lib_core_commerce = require("@adobe/aio-commerce-lib-core/commerce");
|
|
22
22
|
let valibot = require("valibot");
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
|
|
15
15
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
16
16
|
const require_rolldown_runtime = require("../../rolldown-runtime-CoOt0iuZ.cjs");
|
|
17
|
-
const
|
|
17
|
+
const require_router = require("../../router-DpB8wpR2.cjs");
|
|
18
18
|
const require_schemas = require("../../schemas-B6ITl1bG.cjs");
|
|
19
|
+
const require_management = require("../../management-C_JQpgVB.cjs");
|
|
20
|
+
const require_repository = require("../../repository-C3nn0Mon.cjs");
|
|
19
21
|
const require_webhooks = require("../../webhooks-TvDm57xt.cjs");
|
|
20
|
-
const require_validate = require("../../validate-
|
|
21
|
-
const require_management = require("../../management-Cwm3C9g0.cjs");
|
|
22
|
-
const require_router = require("../../router-DpB8wpR2.cjs");
|
|
22
|
+
const require_validate = require("../../validate-B0rOILvG.cjs");
|
|
23
23
|
let _adobe_aio_lib_state = require("@adobe/aio-lib-state");
|
|
24
24
|
let _adobe_aio_commerce_lib_core_error = require("@adobe/aio-commerce-lib-core/error");
|
|
25
25
|
let _adobe_aio_commerce_lib_auth = require("@adobe/aio-commerce-lib-auth");
|
|
@@ -29,7 +29,6 @@ let safe_stable_stringify = require("safe-stable-stringify");
|
|
|
29
29
|
safe_stable_stringify = require_rolldown_runtime.__toESM(safe_stable_stringify, 1);
|
|
30
30
|
let _adobe_aio_commerce_lib_core_responses = require("@adobe/aio-commerce-lib-core/responses");
|
|
31
31
|
let _adobe_aio_lib_files = require("@adobe/aio-lib-files");
|
|
32
|
-
let _adobe_aio_commerce_lib_core_headers = require("@adobe/aio-commerce-lib-core/headers");
|
|
33
32
|
let openwhisk = require("openwhisk");
|
|
34
33
|
openwhisk = require_rolldown_runtime.__toESM(openwhisk, 1);
|
|
35
34
|
|
|
@@ -385,6 +384,8 @@ const AppDataSchema = valibot.object({
|
|
|
385
384
|
*/
|
|
386
385
|
const LifecycleRequestContextSchema = valibot.object({
|
|
387
386
|
appData: AppDataSchema,
|
|
387
|
+
installedState: valibot.optional(valibot.literal("business-config-only")),
|
|
388
|
+
installedVersion: valibot.optional(valibot.string()),
|
|
388
389
|
ioEventsEnv: valibot.string(),
|
|
389
390
|
ioEventsUrl: valibot.string(),
|
|
390
391
|
operation: valibot.optional(valibot.literal("uninstall")),
|
|
@@ -1025,18 +1026,6 @@ function createLifecyclePlanStore() {
|
|
|
1025
1026
|
const DEFAULT_ACTION_NAME = "app-management/installation";
|
|
1026
1027
|
/** Path of the custom installation steps' data in the lifecycle data. */
|
|
1027
1028
|
const CUSTOM_INSTALLATION_STEPS_PATH = ["installation", "customInstallationSteps"];
|
|
1028
|
-
/** Header used to identify the source of an installation action request. */
|
|
1029
|
-
const INSTALLATION_INVOCATION_SOURCE_HEADER = "x-aio-commerce-installation-invocation-source";
|
|
1030
|
-
/** Invocation source used by the generated post-deploy hook. */
|
|
1031
|
-
const POST_APP_DEPLOY_INVOCATION_SOURCE = "post-app-deploy";
|
|
1032
|
-
/** Returns the declared installation action invocation source, if present. */
|
|
1033
|
-
function getInstallationInvocationSource(headers) {
|
|
1034
|
-
return (0, _adobe_aio_commerce_lib_core_headers.getHeader)(headers, INSTALLATION_INVOCATION_SOURCE_HEADER);
|
|
1035
|
-
}
|
|
1036
|
-
/** Returns whether the request originated from the generated post-deploy hook. */
|
|
1037
|
-
function isPostAppDeployInvocation(headers) {
|
|
1038
|
-
return getInstallationInvocationSource(headers) === POST_APP_DEPLOY_INVOCATION_SOURCE;
|
|
1039
|
-
}
|
|
1040
1029
|
/**
|
|
1041
1030
|
* Merges the runtime params with the request body and the Commerce instance the app is
|
|
1042
1031
|
* associated with. Returns `null` when the app is not associated.
|
|
@@ -1250,8 +1239,8 @@ async function executeLifecycleAttempt(options) {
|
|
|
1250
1239
|
const executionDeadline = Date.parse(options.executionDeadline);
|
|
1251
1240
|
if (!Number.isFinite(executionDeadline) || executionDeadline <= Date.now()) return await failPendingAttempt(options, state, currentAttempt, new InvalidExecutionDeadlineError(options.executionDeadline));
|
|
1252
1241
|
const { source } = currentAttempt.plan;
|
|
1253
|
-
const baseline = source ? await options.snapshotStore.get(source.snapshotId) : null;
|
|
1254
|
-
if (source && !baseline) return await failPendingAttempt(options, state, currentAttempt, new LifecycleBaselineNotFoundError());
|
|
1242
|
+
const baseline = source?.snapshotId ? await options.snapshotStore.get(source.snapshotId) : null;
|
|
1243
|
+
if (source?.snapshotId && !baseline) return await failPendingAttempt(options, state, currentAttempt, new LifecycleBaselineNotFoundError());
|
|
1255
1244
|
const attempt = {
|
|
1256
1245
|
...currentAttempt,
|
|
1257
1246
|
activations: {
|
|
@@ -1429,11 +1418,8 @@ async function planLifecycle(options) {
|
|
|
1429
1418
|
rootStep: options.rootStep,
|
|
1430
1419
|
target
|
|
1431
1420
|
});
|
|
1432
|
-
const issues = isPlannedFromFallback ? [FALLBACK_BASELINE_ISSUE, ...planning.issues] : planning.issues;
|
|
1433
|
-
const source = baseline ?
|
|
1434
|
-
appVersion: baseline.config.metadata.version,
|
|
1435
|
-
snapshotId: baseline.id
|
|
1436
|
-
} : null;
|
|
1421
|
+
const issues = isPlannedFromFallback && require_validate.requiresInstallation(fallbackBaselineConfig) ? [FALLBACK_BASELINE_ISSUE, ...planning.issues] : planning.issues;
|
|
1422
|
+
const source = getPlanSource(baseline, isPlannedFromFallback && options.operation === "upgrade" ? fallbackBaselineConfig : void 0);
|
|
1437
1423
|
const plan = {
|
|
1438
1424
|
actionVersion: options.actionVersion,
|
|
1439
1425
|
domains: planning.domains,
|
|
@@ -1455,6 +1441,17 @@ async function planLifecycle(options) {
|
|
|
1455
1441
|
planDiff: diffAgainstReviewedPlan(reviewedPlan, plan)
|
|
1456
1442
|
} : result;
|
|
1457
1443
|
}
|
|
1444
|
+
/** The state a plan starts from: the baseline's, a fallback's version without a snapshot, or nothing. */
|
|
1445
|
+
function getPlanSource(baseline, fallbackConfig) {
|
|
1446
|
+
if (baseline) return {
|
|
1447
|
+
appVersion: baseline.config.metadata.version,
|
|
1448
|
+
snapshotId: baseline.id
|
|
1449
|
+
};
|
|
1450
|
+
return fallbackConfig ? {
|
|
1451
|
+
appVersion: fallbackConfig.metadata.version,
|
|
1452
|
+
snapshotId: null
|
|
1453
|
+
} : null;
|
|
1454
|
+
}
|
|
1458
1455
|
/** Returns the pending plan, or throws when it is not the plan with the given id. */
|
|
1459
1456
|
function requirePendingPlan(state, planId) {
|
|
1460
1457
|
const plan = state.pendingPlan;
|
|
@@ -1802,47 +1799,6 @@ async function findLatestAttemptOf(operation, latestAttempt, attemptStore) {
|
|
|
1802
1799
|
return attempt ?? void 0;
|
|
1803
1800
|
}
|
|
1804
1801
|
/**
|
|
1805
|
-
* The status of the latest attempt with the plans it ran and replaced, every earlier attempt
|
|
1806
|
-
* (newest first, each with its own plans) and the plans made since it.
|
|
1807
|
-
*
|
|
1808
|
-
* @param attempt - The latest attempt.
|
|
1809
|
-
* @param pendingPlan - The pending plan, or `null` when none is pending.
|
|
1810
|
-
* @param stores - The attempt and plan stores.
|
|
1811
|
-
* @param limit - How many earlier attempts to read at most. Reads all of them when absent.
|
|
1812
|
-
* @param operation - Lists only the earlier attempts and pending plans of this operation.
|
|
1813
|
-
*/
|
|
1814
|
-
async function toAttemptHistory(attempt, pendingPlan, stores, limit, operation) {
|
|
1815
|
-
const history = [];
|
|
1816
|
-
let previousId = attempt.previousAttemptId;
|
|
1817
|
-
while (previousId && (limit === void 0 || history.length < limit)) {
|
|
1818
|
-
const previous = await stores.attemptStore.get(previousId);
|
|
1819
|
-
if (!previous) break;
|
|
1820
|
-
if (!operation || previous.operation === operation) history.push({
|
|
1821
|
-
...toAttemptStatus(previous),
|
|
1822
|
-
plans: await readPlanChain(previous.plan, stores.planStore)
|
|
1823
|
-
});
|
|
1824
|
-
previousId = previous.previousAttemptId;
|
|
1825
|
-
}
|
|
1826
|
-
return {
|
|
1827
|
-
...toAttemptStatus(attempt),
|
|
1828
|
-
history,
|
|
1829
|
-
pendingPlans: pendingPlan ? (await readPlanChain(pendingPlan, stores.planStore)).filter((plan) => !operation || plan.operation === operation) : [],
|
|
1830
|
-
plans: await readPlanChain(attempt.plan, stores.planStore)
|
|
1831
|
-
};
|
|
1832
|
-
}
|
|
1833
|
-
/** The given plan followed by the stored plans it replaced, newest first, up to the first missing one. */
|
|
1834
|
-
async function readPlanChain(plan, planStore) {
|
|
1835
|
-
const plans = [plan];
|
|
1836
|
-
let previousId = plan.previousPlanId;
|
|
1837
|
-
while (previousId) {
|
|
1838
|
-
const previous = await planStore.get(previousId);
|
|
1839
|
-
if (!previous) break;
|
|
1840
|
-
plans.push(previous);
|
|
1841
|
-
previousId = previous.previousPlanId;
|
|
1842
|
-
}
|
|
1843
|
-
return plans;
|
|
1844
|
-
}
|
|
1845
|
-
/**
|
|
1846
1802
|
* The response for a request that finds another attempt starting or running. Carries that
|
|
1847
1803
|
* attempt's status when it is a lifecycle attempt, so the caller can follow it.
|
|
1848
1804
|
*/
|
|
@@ -1934,6 +1890,7 @@ async function prepareRequest({ body, logger, rawParams }) {
|
|
|
1934
1890
|
actionVersion,
|
|
1935
1891
|
appConfig,
|
|
1936
1892
|
baseline,
|
|
1893
|
+
businessConfigOnlyVersion: body.installedState === "business-config-only" && body.installedVersion ? body.installedVersion : null,
|
|
1937
1894
|
isBaselineMissing,
|
|
1938
1895
|
latestAttempt: state?.latestAttempt ?? null,
|
|
1939
1896
|
params,
|
|
@@ -1953,7 +1910,7 @@ async function planRequestedOperation(args) {
|
|
|
1953
1910
|
if (resolved.kind === "rejected") return resolved.response;
|
|
1954
1911
|
const { operation } = resolved;
|
|
1955
1912
|
const planned = await planOperation({
|
|
1956
|
-
...getPlanInputs(operation, request.appConfig),
|
|
1913
|
+
...getPlanInputs(operation, request.appConfig, request.businessConfigOnlyVersion),
|
|
1957
1914
|
actionVersion: request.actionVersion,
|
|
1958
1915
|
operation,
|
|
1959
1916
|
runtime: request.runtime
|
|
@@ -1963,9 +1920,10 @@ async function planRequestedOperation(args) {
|
|
|
1963
1920
|
}
|
|
1964
1921
|
/**
|
|
1965
1922
|
* Resolves the operation to plan: `uninstall` when asked for, otherwise `upgrade` when a baseline
|
|
1966
|
-
* exists and `install` when not.
|
|
1923
|
+
* exists and `install` when not. An app installed with only business configuration has no baseline
|
|
1924
|
+
* but is installed, so it resolves `upgrade`. Returns the response that refuses it when it cannot be planned.
|
|
1967
1925
|
*/
|
|
1968
|
-
async function resolveOperation({ appConfig, baseline, isBaselineMissing, latestAttempt, runtime }, requested) {
|
|
1926
|
+
async function resolveOperation({ appConfig, baseline, businessConfigOnlyVersion, isBaselineMissing, latestAttempt, runtime }, requested) {
|
|
1969
1927
|
if (!baseline && await isOrchestrationStateUnreadable(runtime.stateStore)) return rejected((0, _adobe_aio_commerce_lib_core_responses.conflict)({ body: {
|
|
1970
1928
|
code: "unreadable-state",
|
|
1971
1929
|
message: "The stored lifecycle state cannot be read and there is no installation record to rebuild it from. Nothing was planned."
|
|
@@ -1979,7 +1937,11 @@ async function resolveOperation({ appConfig, baseline, isBaselineMissing, latest
|
|
|
1979
1937
|
message: `The latest lifecycle attempt with ID "${latestAttempt.id}" is an uninstall that failed. Retry the uninstall before planning anything else.`
|
|
1980
1938
|
} }));
|
|
1981
1939
|
if (requested === "uninstall") return resolvedUnlessRefused("uninstall", await refuseLegacyUninstall());
|
|
1982
|
-
if (!baseline)
|
|
1940
|
+
if (!baseline) {
|
|
1941
|
+
const refusal = await refuseLegacyInstall();
|
|
1942
|
+
if (!businessConfigOnlyVersion) return resolvedUnlessRefused("install", refusal);
|
|
1943
|
+
return resolvedUnlessRefused("upgrade", refusal ?? refuseRepeatedVersion(businessConfigOnlyVersion, appConfig));
|
|
1944
|
+
}
|
|
1983
1945
|
return resolvedUnlessRefused("upgrade", refuseUpgrade(baseline, appConfig));
|
|
1984
1946
|
}
|
|
1985
1947
|
/** The operation as resolved, or the refusal when there is one. */
|
|
@@ -1990,12 +1952,30 @@ function resolvedUnlessRefused(operation, refusal) {
|
|
|
1990
1952
|
};
|
|
1991
1953
|
}
|
|
1992
1954
|
/** The target and fallback baseline an operation plans with. */
|
|
1993
|
-
function getPlanInputs(operation, appConfig) {
|
|
1994
|
-
|
|
1955
|
+
function getPlanInputs(operation, appConfig, businessConfigOnlyVersion = null) {
|
|
1956
|
+
if (operation === "uninstall") return {
|
|
1995
1957
|
fallbackBaselineConfig: appConfig,
|
|
1996
1958
|
targetConfig: null
|
|
1959
|
+
};
|
|
1960
|
+
return operation === "upgrade" && businessConfigOnlyVersion ? {
|
|
1961
|
+
fallbackBaselineConfig: toBusinessConfigOnlyConfig(appConfig, businessConfigOnlyVersion),
|
|
1962
|
+
targetConfig: appConfig
|
|
1997
1963
|
} : { targetConfig: appConfig };
|
|
1998
1964
|
}
|
|
1965
|
+
/**
|
|
1966
|
+
* The config an app installed with only business configuration has: the target config at the
|
|
1967
|
+
* installed version, without the sections that need installation.
|
|
1968
|
+
*/
|
|
1969
|
+
function toBusinessConfigOnlyConfig(appConfig, installedVersion) {
|
|
1970
|
+
const { adminUi, eventing, installation, webhooks, ...kept } = appConfig;
|
|
1971
|
+
return {
|
|
1972
|
+
...kept,
|
|
1973
|
+
metadata: {
|
|
1974
|
+
...appConfig.metadata,
|
|
1975
|
+
version: installedVersion
|
|
1976
|
+
}
|
|
1977
|
+
};
|
|
1978
|
+
}
|
|
1999
1979
|
/** Refuses an uninstall while an older library version is uninstalling the app. */
|
|
2000
1980
|
async function refuseLegacyUninstall() {
|
|
2001
1981
|
const record = await (await createUninstallationStore()).get(getStorageKey());
|
|
@@ -2014,7 +1994,11 @@ async function refuseLegacyInstall() {
|
|
|
2014
1994
|
/** Refuses an upgrade that changes the app id or keeps the installed version. */
|
|
2015
1995
|
function refuseUpgrade(baseline, appConfig) {
|
|
2016
1996
|
if (baseline.config.metadata.id !== appConfig.metadata.id) return (0, _adobe_aio_commerce_lib_core_responses.conflict)({ body: { message: `The application ID (metadata.id) cannot be changed during an upgrade. Expected "${baseline.config.metadata.id}", received "${appConfig.metadata.id}".` } });
|
|
2017
|
-
|
|
1997
|
+
return refuseRepeatedVersion(baseline.config.metadata.version, appConfig);
|
|
1998
|
+
}
|
|
1999
|
+
/** Refuses an upgrade to the version that is already installed. */
|
|
2000
|
+
function refuseRepeatedVersion(installedVersion, appConfig) {
|
|
2001
|
+
if (installedVersion === appConfig.metadata.version) return (0, _adobe_aio_commerce_lib_core_responses.conflict)({ body: {
|
|
2018
2002
|
code: "already-current",
|
|
2019
2003
|
message: "The app is already on the target version."
|
|
2020
2004
|
} });
|
|
@@ -2064,27 +2048,16 @@ const OperationSchema = valibot.optional(valibot.picklist([
|
|
|
2064
2048
|
"upgrade",
|
|
2065
2049
|
"uninstall"
|
|
2066
2050
|
]));
|
|
2067
|
-
/** Query params that read the latest attempt or its history. */
|
|
2068
|
-
const HistoryQuerySchema = valibot.object({
|
|
2069
|
-
attemptId: valibot.optional(valibot.never()),
|
|
2070
|
-
history: valibot.optional(valibot.picklist(["true", "false"]), "false"),
|
|
2071
|
-
limit: valibot.optional(valibot.pipe(valibot.string(), valibot.toNumber(), valibot.integer(), valibot.minValue(1))),
|
|
2072
|
-
operation: OperationSchema
|
|
2073
|
-
});
|
|
2074
|
-
/** Query params that read one attempt by id. */
|
|
2075
|
-
const AttemptQuerySchema = valibot.object({
|
|
2076
|
-
attemptId: valibot.pipe(valibot.string(), valibot.minLength(1)),
|
|
2077
|
-
history: valibot.optional(valibot.never()),
|
|
2078
|
-
limit: valibot.optional(valibot.never()),
|
|
2079
|
-
operation: OperationSchema
|
|
2080
|
-
});
|
|
2081
2051
|
/**
|
|
2082
2052
|
* Query params of `GET /`. Query values arrive as strings.
|
|
2083
2053
|
*
|
|
2084
2054
|
* Unknown keys are accepted: with an empty query string the router falls back to every other
|
|
2085
2055
|
* action param, such as `appConfig`.
|
|
2086
2056
|
*/
|
|
2087
|
-
const StatusQuerySchema = valibot.
|
|
2057
|
+
const StatusQuerySchema = valibot.object({
|
|
2058
|
+
attemptId: valibot.optional(valibot.pipe(valibot.string(), valibot.minLength(1))),
|
|
2059
|
+
operation: OperationSchema
|
|
2060
|
+
});
|
|
2088
2061
|
|
|
2089
2062
|
// source/actions/installation/start.ts
|
|
2090
2063
|
/**
|
|
@@ -2111,15 +2084,20 @@ async function startPlannedRequest(args) {
|
|
|
2111
2084
|
logger.warn(`Refused to start plan ${planId} because it is not the pending plan (the pending plan is ${pendingPlan?.id ?? "none"}).`);
|
|
2112
2085
|
return stalePlanConflict("The plan is no longer the pending plan. Call POST /plan again and review the new plan.");
|
|
2113
2086
|
}
|
|
2114
|
-
const
|
|
2087
|
+
const businessConfigOnlyVersion = pendingPlan.operation === "upgrade" && pendingPlan.source?.snapshotId === null ? pendingPlan.source.appVersion : null;
|
|
2088
|
+
const resolved = await resolveOperation({
|
|
2089
|
+
...request,
|
|
2090
|
+
businessConfigOnlyVersion
|
|
2091
|
+
}, pendingPlan.operation === "uninstall" ? "uninstall" : void 0);
|
|
2115
2092
|
if (resolved.kind === "rejected") return resolved.response;
|
|
2116
2093
|
const { operation } = resolved;
|
|
2117
2094
|
if (operation !== pendingPlan.operation) {
|
|
2118
2095
|
logger.warn(`Refused to start plan ${planId} because it is for an ${pendingPlan.operation}, but the app now needs an ${operation}.`);
|
|
2119
2096
|
return stalePlanConflict(`The plan is for an ${pendingPlan.operation}, but the app now needs an ${operation}. Call POST /plan again.`);
|
|
2120
2097
|
}
|
|
2098
|
+
if (businessConfigOnlyVersion && !request.baseline && state) await writeBusinessConfigOnlyBaseline(request, state, businessConfigOnlyVersion);
|
|
2121
2099
|
const planned = await planOperation({
|
|
2122
|
-
...getPlanInputs(operation, request.appConfig),
|
|
2100
|
+
...getPlanInputs(operation, request.appConfig, businessConfigOnlyVersion),
|
|
2123
2101
|
actionVersion: request.actionVersion,
|
|
2124
2102
|
operation,
|
|
2125
2103
|
reviewedPlanId: planId,
|
|
@@ -2134,13 +2112,31 @@ async function startPlannedRequest(args) {
|
|
|
2134
2112
|
runtime: request.runtime
|
|
2135
2113
|
});
|
|
2136
2114
|
}
|
|
2115
|
+
/**
|
|
2116
|
+
* Stores the baseline of an app installed with only business configuration: the target config
|
|
2117
|
+
* without what needs installation, at the installed version, with no installed data.
|
|
2118
|
+
*/
|
|
2119
|
+
async function writeBusinessConfigOnlyBaseline({ appConfig, runtime }, state, installedVersion) {
|
|
2120
|
+
const snapshot = {
|
|
2121
|
+
attemptId: null,
|
|
2122
|
+
config: toBusinessConfigOnlyConfig(appConfig, installedVersion),
|
|
2123
|
+
createdAt: require_management.nowIsoString(),
|
|
2124
|
+
data: null,
|
|
2125
|
+
id: crypto.randomUUID()
|
|
2126
|
+
};
|
|
2127
|
+
await runtime.snapshotStore.put(snapshot.id, snapshot);
|
|
2128
|
+
await runtime.stateStore.put(CURRENT_STATE_KEY, {
|
|
2129
|
+
...state,
|
|
2130
|
+
baselineSnapshotId: snapshot.id
|
|
2131
|
+
});
|
|
2132
|
+
}
|
|
2137
2133
|
|
|
2138
2134
|
// source/actions/installation/router.ts
|
|
2139
2135
|
/**
|
|
2140
2136
|
* Installation action router.
|
|
2141
2137
|
*
|
|
2142
2138
|
* Routes:
|
|
2143
|
-
* - GET / Get the status of the latest lifecycle operation
|
|
2139
|
+
* - GET / Get the status of the latest lifecycle operation or of one attempt on `attemptId`
|
|
2144
2140
|
* - POST / Start the pending plan named by `planId`
|
|
2145
2141
|
* - POST /plan Plan an install, upgrade or uninstall for review
|
|
2146
2142
|
* - POST /execution Execute a started lifecycle attempt (internal, called async)
|
|
@@ -2154,11 +2150,8 @@ const router = new require_router.HttpActionRouter().use(require_router.logger({
|
|
|
2154
2150
|
* and answers 404 when no such attempt exists. With `operation` too, the attempt must have run that
|
|
2155
2151
|
* operation, or the answer is 404.
|
|
2156
2152
|
*
|
|
2157
|
-
* With `
|
|
2158
|
-
*
|
|
2159
|
-
*
|
|
2160
|
-
* With `operation`, the latest attempt is the most recent one that ran that operation, the history
|
|
2161
|
-
* and the plans made since only list that operation, and the answer is 204 when no attempt ran it.
|
|
2153
|
+
* With `operation`, the latest attempt is the most recent one that ran that operation, and the
|
|
2154
|
+
* answer is 204 when no attempt ran it.
|
|
2162
2155
|
*/
|
|
2163
2156
|
router.get("/", {
|
|
2164
2157
|
handler: async (req, { logger }) => {
|
|
@@ -2177,17 +2170,12 @@ router.get("/", {
|
|
|
2177
2170
|
const attempt = operation ? await findLatestAttemptOf(operation, state?.latestAttempt, persistence.attemptStore) : state?.latestAttempt;
|
|
2178
2171
|
if (state && attempt) {
|
|
2179
2172
|
logger.debug(`Found the ${attempt.operation} attempt ${attempt.id} with status ${attempt.status}.`);
|
|
2180
|
-
if (req.query.history === "true") return (0, _adobe_aio_commerce_lib_core_responses.ok)({ body: await toAttemptHistory(attempt, state.pendingPlan, persistence, req.query.limit, operation) });
|
|
2181
2173
|
return (0, _adobe_aio_commerce_lib_core_responses.ok)({ body: toAttemptStatus(attempt) });
|
|
2182
2174
|
}
|
|
2183
2175
|
if (operation) {
|
|
2184
2176
|
logger.debug(`No ${operation} attempt found`);
|
|
2185
2177
|
return (0, _adobe_aio_commerce_lib_core_responses.noContent)();
|
|
2186
2178
|
}
|
|
2187
|
-
if (isPostAppDeployInvocation(req.headers)) {
|
|
2188
|
-
logger.debug("No lifecycle attempt found");
|
|
2189
|
-
return (0, _adobe_aio_commerce_lib_core_responses.noContent)();
|
|
2190
|
-
}
|
|
2191
2179
|
logger.debug("Getting legacy installation status...");
|
|
2192
2180
|
const store = await createInstallationStore();
|
|
2193
2181
|
return readStateFromStore(store, (msg) => logger.debug(msg));
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import "../../index-DWEigxhy.cjs";
|
|
16
|
+
import { G as LifecycleContext } from "../../index-D-Qn-irL.cjs";
|
|
16
17
|
import { n as CommerceAppConfig, r as CommerceAppConfigOutputModel } from "../../app-Ch19CR6g.cjs";
|
|
17
|
-
import { G as LifecycleContext } from "../../index-CkejDFwj.cjs";
|
|
18
18
|
import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
|
|
19
19
|
/** Loads generated custom installation script modules. */
|
|
20
20
|
type CustomScriptsLoader = (config: CommerceAppConfigOutputModel, logger: LifecycleContext["logger"]) => Record<string, unknown>;
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
|
|
15
15
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
16
16
|
const require_rolldown_runtime = require("../../rolldown-runtime-CoOt0iuZ.cjs");
|
|
17
|
-
const
|
|
17
|
+
const require_router = require("../../router-DpB8wpR2.cjs");
|
|
18
18
|
const require_logging = require("../../logging-Emi7P923.cjs");
|
|
19
19
|
const require_constants = require("../../constants-CgeVvu6f.cjs");
|
|
20
|
-
const
|
|
20
|
+
const require_schemas = require("../../schemas-B6ITl1bG.cjs");
|
|
21
21
|
let _adobe_aio_commerce_lib_api = require("@adobe/aio-commerce-lib-api");
|
|
22
22
|
let _adobe_aio_commerce_lib_config = require("@adobe/aio-commerce-lib-config");
|
|
23
23
|
let _adobe_aio_commerce_lib_core_commerce = require("@adobe/aio-commerce-lib-core/commerce");
|