@adobe/aio-commerce-lib-app 1.6.0 → 1.8.0-beta-20260714082406
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +106 -0
- package/dist/cjs/actions/app-config/index.cjs +205 -0
- package/dist/cjs/actions/{app-config.d.cts → app-config/index.d.cts} +10 -7
- package/dist/cjs/actions/association/index.cjs +85 -0
- package/dist/cjs/actions/association/index.d.cts +28 -0
- package/dist/cjs/actions/{config.cjs → config/index.cjs} +70 -53
- package/dist/{es/actions/config.d.mts → cjs/actions/config/index.d.cts} +10 -7
- package/dist/cjs/actions/{installation.cjs → installation/index.cjs} +106 -72
- package/dist/{es/actions/installation.d.mts → cjs/actions/installation/index.d.cts} +10 -8
- package/dist/cjs/actions/{scope-tree.cjs → scope-tree/index.cjs} +60 -22
- package/dist/cjs/actions/{scope-tree.d.cts → scope-tree/index.d.cts} +1 -1
- package/dist/cjs/app-D3P-Z6uY.d.cts +1679 -0
- package/dist/cjs/association-repository-BAs3-VkW.cjs +69 -0
- package/dist/cjs/commands/index.cjs +517 -309
- package/dist/cjs/commands/templates/admin-ui/tsconfig.json +14 -0
- package/dist/cjs/commands/templates/admin-ui/web-src/index.css +5 -0
- package/dist/cjs/commands/templates/admin-ui/web-src/index.html +17 -0
- package/dist/cjs/commands/templates/admin-ui/web-src/src/app.jsx +13 -0
- package/dist/cjs/commands/templates/admin-ui/web-src/src/components/welcome.jsx +12 -0
- package/dist/cjs/commands/templates/admin-ui/web-src/src/pages/main-page.jsx +10 -0
- package/dist/cjs/commands/templates/{admin-ui-sdk/registration.js.template → admin-ui/web-src-template.d.ts} +11 -6
- package/dist/cjs/commands/templates/app-management/app-config.js.template +1 -14
- package/dist/cjs/commands/templates/app-management/association.js.template +6 -0
- package/dist/cjs/commands/templates/app-management/installation.js.template +1 -13
- package/dist/cjs/commands/templates/business-configuration/config.js.template +2 -15
- package/dist/cjs/commands/templates/business-configuration/scope-tree.js.template +0 -12
- package/dist/cjs/config/index.browser.cjs +18 -0
- package/dist/cjs/config/index.browser.d.cts +16 -0
- package/dist/cjs/config/{index.cjs → index.node.cjs} +9 -8
- package/dist/cjs/config/index.node.d.cts +1603 -0
- package/dist/cjs/define-DBxAlJfN.d.cts +34 -0
- package/dist/cjs/define-hlcQw7Cv.cjs +41 -0
- package/dist/cjs/environment-B7EnozSg.cjs +135 -0
- package/dist/cjs/index-BXm8UbK7.d.cts +16 -0
- package/dist/cjs/{index-Dw2NvVOY.d.cts → index-CzReNwbF.d.cts} +177 -3
- package/dist/cjs/index.cjs +250 -0
- package/dist/cjs/index.d.cts +217 -0
- package/dist/cjs/{config-FNMclIFO.cjs → index.node-Dz4lV4qe.cjs} +119 -35
- package/dist/cjs/{logging-BVz3weoC.cjs → logging-udPuAJPt.cjs} +2 -2
- package/dist/cjs/management/index.cjs +1 -1
- package/dist/cjs/management/index.d.cts +1 -2
- package/dist/cjs/{management-Cvsz4VMf.cjs → management-B9ItB80R.cjs} +432 -591
- package/dist/cjs/openapi-CwytYdWl.cjs +2948 -0
- package/dist/cjs/{router-BOR7T6qR.cjs → router-hA_Y9gZ1.cjs} +42 -44
- package/dist/cjs/{schemas-FngDuIeo.cjs → schemas-mLxMh_ko.cjs} +2 -2
- package/dist/cjs/utils-DSCmZ_iJ.cjs +408 -0
- package/dist/cjs/{validate-DydOAZha.cjs → validate-BfxhZ5Wv.cjs} +63 -31
- package/dist/cjs/{webhooks-tbZy9G3p.cjs → webhooks-B5tb9NeF.cjs} +159 -151
- package/dist/es/actions/{app-config.d.mts → app-config/index.d.mts} +10 -7
- package/dist/es/actions/app-config/index.mjs +202 -0
- package/dist/es/actions/association/index.d.mts +28 -0
- package/dist/es/actions/association/index.mjs +82 -0
- package/dist/{cjs/actions/config.d.cts → es/actions/config/index.d.mts} +10 -7
- package/dist/es/actions/{config.mjs → config/index.mjs} +67 -50
- package/dist/{cjs/actions/installation.d.cts → es/actions/installation/index.d.mts} +10 -8
- package/dist/es/actions/{installation.mjs → installation/index.mjs} +104 -71
- package/dist/es/actions/{scope-tree.d.mts → scope-tree/index.d.mts} +1 -1
- package/dist/es/actions/{scope-tree.mjs → scope-tree/index.mjs} +58 -20
- package/dist/es/app-D3P-Z6uY.d.mts +1679 -0
- package/dist/es/association-repository-BbQv9WCl.mjs +52 -0
- package/dist/es/commands/index.mjs +550 -340
- package/dist/es/commands/templates/admin-ui/tsconfig.json +14 -0
- package/dist/es/commands/templates/admin-ui/web-src/index.css +5 -0
- package/dist/es/commands/templates/admin-ui/web-src/index.html +17 -0
- package/dist/es/commands/templates/admin-ui/web-src/src/app.jsx +13 -0
- package/dist/es/commands/templates/admin-ui/web-src/src/components/welcome.jsx +12 -0
- package/dist/es/commands/templates/admin-ui/web-src/src/pages/main-page.jsx +10 -0
- package/dist/es/commands/templates/{admin-ui-sdk/registration.js.template → admin-ui/web-src-template.d.ts} +11 -6
- package/dist/es/commands/templates/app-management/app-config.js.template +1 -14
- package/dist/es/commands/templates/app-management/association.js.template +6 -0
- package/dist/es/commands/templates/app-management/installation.js.template +1 -13
- package/dist/es/commands/templates/business-configuration/config.js.template +2 -15
- package/dist/es/commands/templates/business-configuration/scope-tree.js.template +0 -12
- package/dist/es/config/index.browser.d.mts +16 -0
- package/dist/es/config/index.browser.mjs +17 -0
- package/dist/es/config/index.node.d.mts +1604 -0
- package/dist/es/config/index.node.mjs +20 -0
- package/dist/es/define-EoYRZbpe.d.mts +34 -0
- package/dist/es/define-Z_Glf1-_.mjs +35 -0
- package/dist/es/environment-C84BPRJZ.mjs +104 -0
- package/dist/es/index-B0XqHwY5.d.mts +16 -0
- package/dist/es/{index-Bo0tQsVq.d.mts → index-D52xglhZ.d.mts} +177 -3
- package/dist/es/index.d.mts +217 -0
- package/dist/es/index.mjs +242 -0
- package/dist/es/{config-CcE0EBG7.mjs → index.node-CDH5gwJE.mjs} +94 -30
- package/dist/es/management/index.d.mts +1 -2
- package/dist/es/management/index.mjs +1 -1
- package/dist/es/{management-BZ4Y6lVp.mjs → management-B89ApQVY.mjs} +402 -562
- package/dist/es/openapi-CXonvevE.mjs +2900 -0
- package/dist/es/{router-D58JJHHA.mjs → router-B_h0cvjc.mjs} +40 -42
- package/dist/es/utils-_gj8L6eN.mjs +289 -0
- package/dist/es/{validate-Du3LhCre.mjs → validate-9cRZWGrA.mjs} +49 -29
- package/dist/es/{webhooks-B5oq9ULL.mjs → webhooks-BBPbY2mb.mjs} +150 -142
- package/package.json +52 -22
- package/dist/cjs/actions/app-config.cjs +0 -54
- package/dist/cjs/actions/registration.cjs +0 -40
- package/dist/cjs/actions/registration.d.cts +0 -32
- package/dist/cjs/admin-ui-sdk-DZZJCrdT.d.cts +0 -665
- package/dist/cjs/app-CakwxQvs.d.cts +0 -673
- package/dist/cjs/config/index.d.cts +0 -1975
- package/dist/cjs/step-CKVE0aJi.d.cts +0 -187
- package/dist/es/actions/app-config.mjs +0 -53
- package/dist/es/actions/registration.d.mts +0 -32
- package/dist/es/actions/registration.mjs +0 -39
- package/dist/es/admin-ui-sdk-hu6iWr0A.d.mts +0 -667
- package/dist/es/app-CakwxQvs.d.mts +0 -673
- package/dist/es/config/index.d.mts +0 -1975
- package/dist/es/config/index.mjs +0 -19
- package/dist/es/step-D64mMPrt.d.mts +0 -187
- /package/dist/cjs/{chunk-Cozy-1ZF.cjs → rolldown-runtime-Cozy-1ZF.cjs} +0 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2026 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { n as CommerceAppConfig } from "./app-D3P-Z6uY.cjs";
|
|
16
|
+
|
|
17
|
+
//#region source/config/lib/define.d.ts
|
|
18
|
+
/**
|
|
19
|
+
* Helper to type-safely define the app config.
|
|
20
|
+
* @param config - The app config to define.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* import { defineConfig } from "@adobe/aio-commerce-lib-app";
|
|
25
|
+
*
|
|
26
|
+
* // In app.commerce.config.js
|
|
27
|
+
* export default defineConfig({
|
|
28
|
+
* // You get autocompletion and type-safety for the config object.
|
|
29
|
+
* businessConfig: { ... }
|
|
30
|
+
* });
|
|
31
|
+
*/
|
|
32
|
+
declare function defineConfig<const T extends CommerceAppConfig>(config: T): T;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { defineConfig as t };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2026 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
//#region source/config/lib/define.ts
|
|
17
|
+
/**
|
|
18
|
+
* Helper to type-safely define the app config.
|
|
19
|
+
* @param config - The app config to define.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* import { defineConfig } from "@adobe/aio-commerce-lib-app";
|
|
24
|
+
*
|
|
25
|
+
* // In app.commerce.config.js
|
|
26
|
+
* export default defineConfig({
|
|
27
|
+
* // You get autocompletion and type-safety for the config object.
|
|
28
|
+
* businessConfig: { ... }
|
|
29
|
+
* });
|
|
30
|
+
*/
|
|
31
|
+
function defineConfig(config) {
|
|
32
|
+
return config;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
Object.defineProperty(exports, 'defineConfig', {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return defineConfig;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2026 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const require_rolldown_runtime = require('./rolldown-runtime-Cozy-1ZF.cjs');
|
|
16
|
+
let _adobe_aio_commerce_lib_core_error = require("@adobe/aio-commerce-lib-core/error");
|
|
17
|
+
let valibot = require("valibot");
|
|
18
|
+
valibot = require_rolldown_runtime.__toESM(valibot, 1);
|
|
19
|
+
let _adobe_aio_commerce_lib_core_commerce = require("@adobe/aio-commerce-lib-core/commerce");
|
|
20
|
+
|
|
21
|
+
//#region ../../packages-private/common-utils/source/valibot/utils.ts
|
|
22
|
+
/**
|
|
23
|
+
* Parses the input using the provided schema and throws a {@link CommerceSdkValidationError} error if the input is invalid.
|
|
24
|
+
* @param schema - The schema to use for parsing.
|
|
25
|
+
* @param input - The input to parse.
|
|
26
|
+
* @param message - Optional custom error message for the validation error.
|
|
27
|
+
*/
|
|
28
|
+
function parseOrThrow(schema, input, message) {
|
|
29
|
+
const result = valibot.safeParse(schema, input);
|
|
30
|
+
if (!result.success) throw new _adobe_aio_commerce_lib_core_error.CommerceSdkValidationError(message ?? "Invalid input", { issues: result.issues });
|
|
31
|
+
return result.output;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region source/config/lib/environment.ts
|
|
36
|
+
/**
|
|
37
|
+
* Returns true when an item applies to the given Commerce environment: either it
|
|
38
|
+
* declares no `env` (applies to all environments) or its `env` list includes the
|
|
39
|
+
* environment. This is the single keep-rule shared by install-time filtering and
|
|
40
|
+
* the environment-filtered `app-config` display path.
|
|
41
|
+
*
|
|
42
|
+
* @param item - The webhook or event entry, which may carry an optional `env` array.
|
|
43
|
+
* @param env - The target Commerce environment (e.g. `"paas"` or `"saas"`).
|
|
44
|
+
*/
|
|
45
|
+
function appliesToEnv(item, env) {
|
|
46
|
+
return item.env === void 0 || item.env.includes(env);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Reads and validates the target Commerce environment from the install workflow params,
|
|
50
|
+
* where the router maps the request's `commerceEnv` onto `AIO_COMMERCE_API_FLAVOR`.
|
|
51
|
+
* Throws if the value is absent or not a recognised Commerce environment.
|
|
52
|
+
*
|
|
53
|
+
* @param params - The runtime action params available to install steps.
|
|
54
|
+
*/
|
|
55
|
+
function getInstallCommerceEnv(params) {
|
|
56
|
+
return parseOrThrow(_adobe_aio_commerce_lib_core_commerce.CommerceEnvSchema, params.AIO_COMMERCE_API_FLAVOR, "Missing or unknown commerce environment");
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Filters a provider list to the given environment: each provider keeps only its
|
|
60
|
+
* applicable events, and providers left with no events are dropped entirely.
|
|
61
|
+
*/
|
|
62
|
+
function filterProvidersByEnv(providers, env) {
|
|
63
|
+
return providers.map((provider) => ({
|
|
64
|
+
...provider,
|
|
65
|
+
events: provider.events.filter((event) => appliesToEnv(event, env))
|
|
66
|
+
})).filter((provider) => provider.events.length > 0);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Returns a copy of a validated app config scoped to the given Commerce environment:
|
|
70
|
+
* business-config fields and webhooks not applicable to the environment are removed,
|
|
71
|
+
* each event provider keeps only its applicable events, and providers left with no
|
|
72
|
+
* events are dropped. Uses the same `appliesToEnv` keep-rule as the `config` action,
|
|
73
|
+
* so the `app-config` action renders the same scoped set that the rest of the SDK
|
|
74
|
+
* (install and `config`) applies.
|
|
75
|
+
*
|
|
76
|
+
* @param config - The validated app config.
|
|
77
|
+
* @param env - The target Commerce environment (e.g. `"paas"` or `"saas"`).
|
|
78
|
+
*/
|
|
79
|
+
function filterAppConfigByEnv(config, env) {
|
|
80
|
+
const filtered = { ...config };
|
|
81
|
+
if (filtered.businessConfig && Array.isArray(filtered.businessConfig.schema)) filtered.businessConfig = {
|
|
82
|
+
...filtered.businessConfig,
|
|
83
|
+
schema: filtered.businessConfig.schema.filter((field) => appliesToEnv(field, env))
|
|
84
|
+
};
|
|
85
|
+
if (Array.isArray(filtered.webhooks)) filtered.webhooks = filtered.webhooks.filter((webhook) => appliesToEnv(webhook, env));
|
|
86
|
+
if (filtered.eventing) filtered.eventing = {
|
|
87
|
+
...filtered.eventing,
|
|
88
|
+
...filtered.eventing.commerce && { commerce: filterProvidersByEnv(filtered.eventing.commerce, env) },
|
|
89
|
+
...filtered.eventing.external && { external: filterProvidersByEnv(filtered.eventing.external, env) }
|
|
90
|
+
};
|
|
91
|
+
return filtered;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Filters a business configuration schema to the fields applicable to the
|
|
95
|
+
* given Commerce environment. Fields without an `env` property apply to all
|
|
96
|
+
* environments and are always included.
|
|
97
|
+
*
|
|
98
|
+
* @param schema - The business configuration schema to filter.
|
|
99
|
+
* @param env - The Commerce environment to filter by.
|
|
100
|
+
*/
|
|
101
|
+
function filterSchemaByEnv(schema, env) {
|
|
102
|
+
return schema.filter((field) => appliesToEnv(field, env));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
//#endregion
|
|
106
|
+
Object.defineProperty(exports, 'appliesToEnv', {
|
|
107
|
+
enumerable: true,
|
|
108
|
+
get: function () {
|
|
109
|
+
return appliesToEnv;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
Object.defineProperty(exports, 'filterAppConfigByEnv', {
|
|
113
|
+
enumerable: true,
|
|
114
|
+
get: function () {
|
|
115
|
+
return filterAppConfigByEnv;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
Object.defineProperty(exports, 'filterSchemaByEnv', {
|
|
119
|
+
enumerable: true,
|
|
120
|
+
get: function () {
|
|
121
|
+
return filterSchemaByEnv;
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
Object.defineProperty(exports, 'getInstallCommerceEnv', {
|
|
125
|
+
enumerable: true,
|
|
126
|
+
get: function () {
|
|
127
|
+
return getInstallCommerceEnv;
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
Object.defineProperty(exports, 'parseOrThrow', {
|
|
131
|
+
enumerable: true,
|
|
132
|
+
get: function () {
|
|
133
|
+
return parseOrThrow;
|
|
134
|
+
}
|
|
135
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2026 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
|
|
16
|
+
import AioLogger from "@adobe/aio-lib-core-logging";
|
|
@@ -12,9 +12,178 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
15
|
+
import { r as CommerceAppConfigOutputModel } from "./app-D3P-Z6uY.cjs";
|
|
16
|
+
import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
|
|
17
|
+
import AioLogger from "@adobe/aio-lib-core-logging";
|
|
18
|
+
import * as v from "valibot";
|
|
17
19
|
|
|
20
|
+
//#region source/management/installation/schema.d.ts
|
|
21
|
+
/** Schema for validating Adobe I/O app credentials required for installation. */
|
|
22
|
+
declare const AppDataSchema: v.ObjectSchema<{
|
|
23
|
+
readonly consumerOrgId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
24
|
+
readonly orgName: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
25
|
+
readonly projectId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
26
|
+
readonly projectName: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
27
|
+
readonly projectTitle: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
28
|
+
readonly workspaceId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
29
|
+
readonly workspaceName: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
30
|
+
readonly workspaceTitle: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.NonEmptyAction<string, `The value of "${string}" must not be empty`>]>;
|
|
31
|
+
}, undefined>;
|
|
32
|
+
/** Type for Adobe I/O app credentials. */
|
|
33
|
+
type AppData = v.InferOutput<typeof AppDataSchema>;
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region source/management/installation/workflow/step.d.ts
|
|
36
|
+
/** Severity level of a validation issue. */
|
|
37
|
+
type ValidationIssueSeverity = "error" | "warning" | "info";
|
|
38
|
+
/** A single validation issue reported by a step's validate handler. */
|
|
39
|
+
type ValidationIssue = {
|
|
40
|
+
/** Machine-readable code identifying the issue type. */code: string; /** Human-readable description of the issue. */
|
|
41
|
+
message: string; /** Severity of the issue. Only "error" severity blocks installation. */
|
|
42
|
+
severity: ValidationIssueSeverity; /** Optional additional context about the issue. */
|
|
43
|
+
details?: Record<string, unknown>;
|
|
44
|
+
};
|
|
45
|
+
/** Shared context available to all steps during installation. */
|
|
46
|
+
type InstallationContext = {
|
|
47
|
+
/** The credentials of the app being installed */appData: AppData; /** The raw action parameters from the App Builder runtime action. */
|
|
48
|
+
params: RuntimeActionParams & {
|
|
49
|
+
AIO_COMMERCE_AUTH_IMS_CLIENT_ID: string;
|
|
50
|
+
AIO_COMMERCE_AUTH_IMS_CLIENT_SECRETS: string | string[];
|
|
51
|
+
AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_ID: string;
|
|
52
|
+
AIO_COMMERCE_AUTH_IMS_TECHNICAL_ACCOUNT_EMAIL: string;
|
|
53
|
+
AIO_COMMERCE_AUTH_IMS_ORG_ID: string;
|
|
54
|
+
AIO_COMMERCE_AUTH_IMS_SCOPES: string | string[];
|
|
55
|
+
}; /** Logger instance for installation logging. */
|
|
56
|
+
logger: ReturnType<typeof AioLogger>; /** Custom scripts defined in the configuration (if any). */
|
|
57
|
+
customScripts?: Record<string, unknown>;
|
|
58
|
+
};
|
|
59
|
+
/** Factory function type for creating step-specific context. */
|
|
60
|
+
type StepContextFactory<TStepCtx extends Record<string, unknown> = Record<string, unknown>> = (context: InstallationContext) => TStepCtx | Promise<TStepCtx>;
|
|
61
|
+
/** The execution context passed to leaf step run handlers. */
|
|
62
|
+
type ExecutionContext<TStepCtx extends Record<string, unknown> = Record<string, unknown>> = InstallationContext & TStepCtx;
|
|
63
|
+
/**
|
|
64
|
+
* A narrowed context available to step `validate` handlers.
|
|
65
|
+
* Excludes `customScripts` — those only apply during installation, not pre-flight validation.
|
|
66
|
+
*/
|
|
67
|
+
type ValidationContext = Omit<InstallationContext, "customScripts">;
|
|
68
|
+
/** The context passed to step `validate` handlers (base validation context merged with step-level context). */
|
|
69
|
+
type ValidationExecutionContext<TStepCtx extends Record<string, unknown> = Record<string, unknown>> = ValidationContext & TStepCtx;
|
|
70
|
+
/** Metadata info for a step (used for UI display). */
|
|
71
|
+
type StepMetaInfo = {
|
|
72
|
+
label: string;
|
|
73
|
+
description?: string;
|
|
74
|
+
};
|
|
75
|
+
/** Step metadata keyed by execution mode. */
|
|
76
|
+
type StepMeta = {
|
|
77
|
+
install: StepMetaInfo;
|
|
78
|
+
uninstall?: StepMetaInfo;
|
|
79
|
+
};
|
|
80
|
+
/** Defines the base properties of a step. */
|
|
81
|
+
type StepBase<TName extends string = string, TConfig extends CommerceAppConfigOutputModel = CommerceAppConfigOutputModel> = {
|
|
82
|
+
/** The name of this step. */name: TName; /** Metadata associated with the step, keyed by execution mode. */
|
|
83
|
+
meta: StepMeta; /** Whether the step should be taken into consideration. */
|
|
84
|
+
when?: (config: CommerceAppConfigOutputModel) => config is TConfig;
|
|
85
|
+
};
|
|
86
|
+
/** A leaf step that executes work (no children). */
|
|
87
|
+
type LeafStep<TName extends string = string, TConfig extends CommerceAppConfigOutputModel = CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TOutput = unknown> = StepBase<TName, TConfig> & {
|
|
88
|
+
type: "leaf"; /** The execution handler for the step. */
|
|
89
|
+
install: (config: TConfig, context: ExecutionContext<TStepCtx>) => TOutput | Promise<TOutput>;
|
|
90
|
+
/**
|
|
91
|
+
* Optional pre-installation validation handler.
|
|
92
|
+
* Called before installation begins to surface issues (errors or warnings).
|
|
93
|
+
* Returning an empty array means the step has no issues.
|
|
94
|
+
*/
|
|
95
|
+
validate?: (config: TConfig, context: ValidationExecutionContext<TStepCtx>) => ValidationIssue[] | Promise<ValidationIssue[]>;
|
|
96
|
+
/**
|
|
97
|
+
* Optional uninstall handler for the step.
|
|
98
|
+
* Called during uninstallation to reverse the work done by `install`.
|
|
99
|
+
* If absent, the step is silently skipped during uninstallation.
|
|
100
|
+
*/
|
|
101
|
+
uninstall?: (config: TConfig, context: ExecutionContext<TStepCtx>) => void | Promise<void>;
|
|
102
|
+
};
|
|
103
|
+
/** A branch step that contains children (no execution). */
|
|
104
|
+
type BranchStep<TName extends string = string, TConfig extends CommerceAppConfigOutputModel = CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TChildren extends AnyStep[] = AnyStep[]> = StepBase<TName, TConfig> & {
|
|
105
|
+
type: "branch"; /** An optional factory function to setup shared context for the children steps. */
|
|
106
|
+
context?: StepContextFactory<TStepCtx>; /** The children steps of this branch. */
|
|
107
|
+
children: TChildren;
|
|
108
|
+
/**
|
|
109
|
+
* Optional pre-installation validation handler for the branch itself.
|
|
110
|
+
* Called before children are validated. Returning an empty array means
|
|
111
|
+
* the branch has no issues at this level.
|
|
112
|
+
*/
|
|
113
|
+
validate?: (config: TConfig, context: ValidationExecutionContext<TStepCtx>) => ValidationIssue[] | Promise<ValidationIssue[]>;
|
|
114
|
+
};
|
|
115
|
+
/** A step in the installation tree (discriminated union by `type`). */
|
|
116
|
+
type Step<TName extends string = string, TConfig extends CommerceAppConfigOutputModel = CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TOutput = unknown> = LeafStep<TName, TConfig, TStepCtx, TOutput> | BranchStep<TName, TConfig, TStepCtx>;
|
|
117
|
+
/** Loosely-typed step for use in non type-safe contexts. */
|
|
118
|
+
type AnyStep = {
|
|
119
|
+
children?: AnyStep[];
|
|
120
|
+
context?: (context: InstallationContext) => any;
|
|
121
|
+
install?: (config: any, context: any) => unknown | Promise<unknown>;
|
|
122
|
+
meta: StepMeta;
|
|
123
|
+
name: string;
|
|
124
|
+
type: "leaf" | "branch";
|
|
125
|
+
uninstall?: (config: any, context: any) => void | Promise<void>;
|
|
126
|
+
validate?: (config: any, context: any) => ValidationIssue[] | Promise<ValidationIssue[]>;
|
|
127
|
+
when?: (config: CommerceAppConfigOutputModel) => boolean;
|
|
128
|
+
};
|
|
129
|
+
/** Check if a step is a leaf step. */
|
|
130
|
+
declare function isLeafStep(step: AnyStep): step is LeafStep;
|
|
131
|
+
/** Check if a step is a branch step. */
|
|
132
|
+
declare function isBranchStep(step: AnyStep): step is BranchStep;
|
|
133
|
+
/** Options for defining a leaf step. */
|
|
134
|
+
type LeafStepOptions<TName extends string, TConfig extends CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TOutput = unknown> = Omit<LeafStep<TName, TConfig, TStepCtx, TOutput>, "type">;
|
|
135
|
+
/** Options for defining a branch step. */
|
|
136
|
+
type BranchStepOptions<TName extends string, TConfig extends CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TChildren extends AnyStep[] = AnyStep[]> = Omit<BranchStep<TName, TConfig, TStepCtx, TChildren>, "type">;
|
|
137
|
+
/**
|
|
138
|
+
* Define a leaf step (executable, no children).
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* const createProviders = defineLeafStep({
|
|
143
|
+
* name: "providers",
|
|
144
|
+
* meta: { install: { label: "Create Providers", description: "Creates I/O Events providers" } },
|
|
145
|
+
* install: async ({ config, stepContext }) => {
|
|
146
|
+
* const { eventsClient } = stepContext;
|
|
147
|
+
* return eventsClient.createProvider(config.eventing);
|
|
148
|
+
* },
|
|
149
|
+
* });
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
declare function defineLeafStep<TName extends string, TConfig extends CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, TOutput = unknown>(options: LeafStepOptions<TName, TConfig, TStepCtx, TOutput>): {
|
|
153
|
+
install: (config: TConfig, context: ExecutionContext<TStepCtx>) => TOutput | Promise<TOutput>;
|
|
154
|
+
meta: StepMeta;
|
|
155
|
+
name: TName;
|
|
156
|
+
type: "leaf";
|
|
157
|
+
uninstall: ((config: TConfig, context: ExecutionContext<TStepCtx>) => void | Promise<void>) | undefined;
|
|
158
|
+
validate: ((config: TConfig, context: ValidationExecutionContext<TStepCtx>) => ValidationIssue[] | Promise<ValidationIssue[]>) | undefined;
|
|
159
|
+
when: ((config: CommerceAppConfigOutputModel) => config is TConfig) | undefined;
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Define a branch step (container with children, no runner).
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```typescript
|
|
166
|
+
* const eventing = defineBranchStep({
|
|
167
|
+
* name: "eventing",
|
|
168
|
+
* meta: { install: { label: "Eventing", description: "Sets up I/O Events" } },
|
|
169
|
+
* when: hasEventing,
|
|
170
|
+
* context: async (ctx) => ({ eventsClient: await createEventsClient(ctx) }),
|
|
171
|
+
* children: [commerceEventsStep, externalEventsStep],
|
|
172
|
+
* });
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
declare function defineBranchStep<TName extends string, TConfig extends CommerceAppConfigOutputModel, TStepCtx extends Record<string, unknown> = Record<string, unknown>, const TChildren extends AnyStep[] = AnyStep[]>(options: BranchStepOptions<TName, TConfig, TStepCtx, TChildren>): {
|
|
176
|
+
children: TChildren;
|
|
177
|
+
context: StepContextFactory<TStepCtx> | undefined;
|
|
178
|
+
meta: StepMeta;
|
|
179
|
+
name: TName;
|
|
180
|
+
type: "branch";
|
|
181
|
+
validate: ((config: TConfig, context: ValidationExecutionContext<TStepCtx>) => ValidationIssue[] | Promise<ValidationIssue[]>) | undefined;
|
|
182
|
+
when: ((config: CommerceAppConfigOutputModel) => config is TConfig) | undefined;
|
|
183
|
+
};
|
|
184
|
+
/** Infer the output type from a leaf step. */
|
|
185
|
+
type InferStepOutput<TStep> = TStep extends LeafStep<infer _TName, infer _TConfig, infer _TStepCtx, infer TOutput> ? Awaited<TOutput> : never;
|
|
186
|
+
//#endregion
|
|
18
187
|
//#region source/management/installation/workflow/types.d.ts
|
|
19
188
|
/** Status of a step execution. */
|
|
20
189
|
type ExecutionStatus = "pending" | "in-progress" | "succeeded" | "failed";
|
|
@@ -45,6 +214,11 @@ type InstallationStateBase = {
|
|
|
45
214
|
/** Unique installation identifier. */id: string; /** Root step status. */
|
|
46
215
|
step: StepStatus; /** Results from executed leaf steps, keyed by path. */
|
|
47
216
|
data: InstallationData | null;
|
|
217
|
+
/**
|
|
218
|
+
* The validated app configuration that drove this workflow. May be
|
|
219
|
+
* undefined on states persisted before this field was introduced.
|
|
220
|
+
*/
|
|
221
|
+
config?: CommerceAppConfigOutputModel;
|
|
48
222
|
};
|
|
49
223
|
/** Installation state when in progress. */
|
|
50
224
|
type InProgressInstallationState = InstallationStateBase & {
|
|
@@ -309,4 +483,4 @@ type RunValidationOptions = {
|
|
|
309
483
|
*/
|
|
310
484
|
declare function runValidation(options: RunValidationOptions): Promise<ValidationResult>;
|
|
311
485
|
//#endregion
|
|
312
|
-
export { ExecutionStatus as A, isCompletedState as B, executeUninstallWorkflow as C, StepFailedEvent as D, StepEvent as E, InstallationRetryMetadata as F, isInProgressState as H, InstallationState as I, InstallationStatus as L, InProgressInstallationState as M, InstallationData as N, StepStartedEvent as O, InstallationError as P, StepStatus as R, createRetryState as S, InstallationHooks as T, isSucceededState as U, isFailedState as V, ValidationSummary as _, RunValidationOptions as a, ExecuteWorkflowOptions as b, runInstallation as c, CustomInstallationStepDefinition as d, CustomInstallationStepHandler as f, ValidationResult as g, ValidateStepTreeOptions as h, RunUninstallationOptions as i, FailedInstallationState as j, StepSucceededEvent as k, runUninstallation as l, StepValidationResult as m, CreateInitialUninstallationStateOptions as n, createInitialInstallationState as o, defineCustomInstallationStep as p, RunInstallationOptions as r, createInitialUninstallationState as s, CreateInitialInstallationStateOptions as t, runValidation as u, validateStepTree as v, executeWorkflow as w, createInitialState as x, CreateInitialStateOptions as y, SucceededInstallationState as z };
|
|
486
|
+
export { StepContextFactory as $, ExecutionStatus as A, isCompletedState as B, executeUninstallWorkflow as C, StepFailedEvent as D, StepEvent as E, InstallationRetryMetadata as F, BranchStep as G, isInProgressState as H, InstallationState as I, InferStepOutput as J, BranchStepOptions as K, InstallationStatus as L, InProgressInstallationState as M, InstallationData as N, StepStartedEvent as O, InstallationError as P, Step as Q, StepStatus as R, createRetryState as S, InstallationHooks as T, isSucceededState as U, isFailedState as V, AnyStep as W, LeafStep as X, InstallationContext as Y, LeafStepOptions as Z, ValidationSummary as _, RunValidationOptions as a, ValidationIssueSeverity as at, ExecuteWorkflowOptions as b, runInstallation as c, isBranchStep as ct, CustomInstallationStepDefinition as d, StepMeta as et, CustomInstallationStepHandler as f, ValidationResult as g, ValidateStepTreeOptions as h, RunUninstallationOptions as i, ValidationIssue as it, FailedInstallationState as j, StepSucceededEvent as k, runUninstallation as l, isLeafStep as lt, StepValidationResult as m, CreateInitialUninstallationStateOptions as n, ValidationContext as nt, createInitialInstallationState as o, defineBranchStep as ot, defineCustomInstallationStep as p, ExecutionContext as q, RunInstallationOptions as r, ValidationExecutionContext as rt, createInitialUninstallationState as s, defineLeafStep as st, CreateInitialInstallationStateOptions as t, StepMetaInfo as tt, runValidation as u, validateStepTree as v, executeWorkflow as w, createInitialState as x, CreateInitialStateOptions as y, SucceededInstallationState as z };
|