@adobe/aio-commerce-lib-app 1.6.0 → 1.7.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 +23 -0
- package/dist/cjs/actions/app-config/index.cjs +202 -0
- package/dist/cjs/actions/app-config/index.d.cts +31 -0
- package/dist/cjs/actions/{config.cjs → config/index.cjs} +61 -33
- package/dist/{es/actions/config.d.mts → cjs/actions/config/index.d.cts} +10 -7
- package/dist/cjs/actions/{installation.cjs → installation/index.cjs} +43 -30
- package/dist/{es/actions/installation.d.mts → cjs/actions/installation/index.d.cts} +10 -8
- package/dist/cjs/actions/{registration.cjs → registration/index.cjs} +16 -6
- package/dist/cjs/actions/{registration.d.cts → registration/index.d.cts} +8 -8
- package/dist/cjs/actions/{scope-tree.cjs → scope-tree/index.cjs} +51 -14
- package/dist/cjs/actions/{scope-tree.d.cts → scope-tree/index.d.cts} +1 -1
- package/dist/cjs/{admin-ui-sdk-DZZJCrdT.d.cts → admin-ui-sdk-EU915zlR.d.cts} +7 -8
- package/dist/cjs/app-DrYHK-z1.d.cts +1629 -0
- package/dist/cjs/commands/index.cjs +12 -18
- package/dist/cjs/config/index.cjs +2 -2
- package/dist/cjs/config/index.d.cts +36 -976
- package/dist/cjs/{config-FNMclIFO.cjs → config-D-s0GSep.cjs} +1 -1
- package/dist/cjs/{index-Dw2NvVOY.d.cts → index-B5gJ-q4U.d.cts} +172 -3
- package/dist/{es/actions/app-config.d.mts → cjs/index-BXm8UbK7.d.cts} +1 -13
- package/dist/cjs/management/index.cjs +1 -1
- package/dist/cjs/management/index.d.cts +1 -2
- package/dist/cjs/{management-Cvsz4VMf.cjs → management-Dehz9qSJ.cjs} +81 -43
- package/dist/cjs/openapi-Cux6K4ZD.cjs +3072 -0
- package/dist/cjs/{validate-DydOAZha.cjs → validate-oAOpyFyb.cjs} +46 -14
- package/dist/es/actions/app-config/index.d.mts +31 -0
- package/dist/es/actions/app-config/index.mjs +199 -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} +60 -32
- package/dist/{cjs/actions/installation.d.cts → es/actions/installation/index.d.mts} +10 -8
- package/dist/es/actions/{installation.mjs → installation/index.mjs} +42 -30
- package/dist/es/actions/{registration.d.mts → registration/index.d.mts} +8 -8
- package/dist/es/actions/{registration.mjs → registration/index.mjs} +16 -6
- 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} +50 -13
- package/dist/es/{admin-ui-sdk-hu6iWr0A.d.mts → admin-ui-sdk-BwnD0xjK.d.mts} +6 -9
- package/dist/es/app-DrYHK-z1.d.mts +1629 -0
- package/dist/es/commands/index.mjs +12 -18
- package/dist/es/config/index.d.mts +36 -975
- package/dist/es/config/index.mjs +2 -2
- package/dist/es/{config-CcE0EBG7.mjs → config-3I4eLyyR.mjs} +1 -1
- package/dist/{cjs/actions/app-config.d.cts → es/index-B0XqHwY5.d.mts} +2 -14
- package/dist/es/{index-Bo0tQsVq.d.mts → index-DLMbTtKS.d.mts} +172 -3
- package/dist/es/management/index.d.mts +1 -2
- package/dist/es/management/index.mjs +1 -1
- package/dist/es/{management-BZ4Y6lVp.mjs → management-BUX-w2Ji.mjs} +81 -44
- package/dist/es/openapi-B6uP0SRn.mjs +3024 -0
- package/dist/es/{validate-Du3LhCre.mjs → validate-Dfajrp99.mjs} +35 -15
- package/package.json +17 -10
- package/dist/cjs/actions/app-config.cjs +0 -54
- package/dist/cjs/app-CakwxQvs.d.cts +0 -673
- package/dist/cjs/step-CKVE0aJi.d.cts +0 -187
- package/dist/es/actions/app-config.mjs +0 -53
- package/dist/es/app-CakwxQvs.d.mts +0 -673
- package/dist/es/step-D64mMPrt.d.mts +0 -187
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @adobe/aio-commerce-lib-app
|
|
2
2
|
|
|
3
|
+
## 1.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#481](https://github.com/adobe/aio-commerce-sdk/pull/481) [`cffcc6a`](https://github.com/adobe/aio-commerce-sdk/commit/cffcc6af58c734486de4447c1f1eaa7a4784a4e2) Thanks [@iivvaannxx](https://github.com/iivvaannxx)! - Introduce a new `GET /openapi.json` for `lib-app` in `app-config`.
|
|
8
|
+
|
|
9
|
+
- [#471](https://github.com/adobe/aio-commerce-sdk/pull/471) [`82adf80`](https://github.com/adobe/aio-commerce-sdk/commit/82adf8002e693166fe0d285f9b901750dbad2f5e) Thanks [@obarcelonap](https://github.com/obarcelonap)! - Default generated actions to `nodejs:24`, the latest App Builder Runtime version with prewarm support.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#489](https://github.com/adobe/aio-commerce-sdk/pull/489) [`d227e47`](https://github.com/adobe/aio-commerce-sdk/commit/d227e475ec0b513ca06e4e7950497b2a20ee4674) Thanks [@oshmyheliuk](https://github.com/oshmyheliuk)! - Refactor Admin UI SDK extension registration and unregistration to use `@adobe/aio-commerce-lib-admin-ui` client instead of raw HTTP calls.
|
|
14
|
+
|
|
15
|
+
- [#481](https://github.com/adobe/aio-commerce-sdk/pull/481) [`cffcc6a`](https://github.com/adobe/aio-commerce-sdk/commit/cffcc6af58c734486de4447c1f1eaa7a4784a4e2) Thanks [@iivvaannxx](https://github.com/iivvaannxx)! - Fix `scopes` body validation in the scope tree action to use the proper recursive `CustomScopeInput` schema instead of `v.any()`.
|
|
16
|
+
|
|
17
|
+
- [#495](https://github.com/adobe/aio-commerce-sdk/pull/495) [`c8d8c3a`](https://github.com/adobe/aio-commerce-sdk/commit/c8d8c3a1f1279493d12bd1403e5fd71f18ee9dc1) Thanks [@iivvaannxx](https://github.com/iivvaannxx)! - Fix an issue where developers could not define custom installation scripts via `module.exports` when using CJS.
|
|
18
|
+
|
|
19
|
+
- [#481](https://github.com/adobe/aio-commerce-sdk/pull/481) [`cffcc6a`](https://github.com/adobe/aio-commerce-sdk/commit/cffcc6af58c734486de4447c1f1eaa7a4784a4e2) Thanks [@iivvaannxx](https://github.com/iivvaannxx)! - Return `400` instead of `500` when a custom scope tree fails validation (reserved or duplicate scope codes, invalid fields).
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [[`f6aec01`](https://github.com/adobe/aio-commerce-sdk/commit/f6aec01a22ed185fe130170751353fae881c0f2d), [`9b41376`](https://github.com/adobe/aio-commerce-sdk/commit/9b413761fd857a2e75c3f5210efb83ce2b1b4b6e), [`d227e47`](https://github.com/adobe/aio-commerce-sdk/commit/d227e475ec0b513ca06e4e7950497b2a20ee4674)]:
|
|
22
|
+
- @adobe/aio-commerce-lib-webhooks@1.1.2
|
|
23
|
+
- @adobe/aio-commerce-lib-config@1.5.1
|
|
24
|
+
- @adobe/aio-commerce-lib-admin-ui@0.1.0
|
|
25
|
+
|
|
3
26
|
## 1.6.0
|
|
4
27
|
|
|
5
28
|
### Minor Changes
|
|
@@ -0,0 +1,202 @@
|
|
|
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
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
16
|
+
const require_chunk = require('../../chunk-Cozy-1ZF.cjs');
|
|
17
|
+
const require_validate = require('../../validate-oAOpyFyb.cjs');
|
|
18
|
+
const require_router = require('../../router-BOR7T6qR.cjs');
|
|
19
|
+
let _adobe_aio_commerce_lib_config = require("@adobe/aio-commerce-lib-config");
|
|
20
|
+
let valibot = require("valibot");
|
|
21
|
+
valibot = require_chunk.__toESM(valibot, 1);
|
|
22
|
+
let _adobe_aio_commerce_lib_core_responses = require("@adobe/aio-commerce-lib-core/responses");
|
|
23
|
+
let crypto = require("crypto");
|
|
24
|
+
|
|
25
|
+
//#region source/actions/app-config/openapi.ts
|
|
26
|
+
/**
|
|
27
|
+
* Loads the committed OpenAPI spec via dynamic import so it
|
|
28
|
+
* lands in its own chunk and is not parsed on every cold start.
|
|
29
|
+
*/
|
|
30
|
+
const importOpenApi = () => Promise.resolve().then(() => require("../../openapi-Cux6K4ZD.cjs"));
|
|
31
|
+
/** Matches component schema `$ref` strings, capturing the schema name. */
|
|
32
|
+
const SCHEMA_REF_PATTERN = /"#\/components\/schemas\/(\w+)"/g;
|
|
33
|
+
/**
|
|
34
|
+
* Collects the names of every component schema referenced via `$ref` in a value
|
|
35
|
+
* Scans the serialized JSON, so it catches refs at any depth.
|
|
36
|
+
*
|
|
37
|
+
* @param value - Any part of the spec to scan.
|
|
38
|
+
*/
|
|
39
|
+
function collectSchemaRefs(value) {
|
|
40
|
+
return [...(JSON.stringify(value) ?? "").matchAll(SCHEMA_REF_PATTERN)].map((match) => match[1]);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Deletes component schemas not reachable from the remaining paths, in place.
|
|
44
|
+
*
|
|
45
|
+
* Follows `$ref`s transitively from `spec.paths`; the visited set handles
|
|
46
|
+
* recursive schemas (e.g. `ScopeNode`).
|
|
47
|
+
*
|
|
48
|
+
* @param spec - The spec to prune, after paths have been stripped.
|
|
49
|
+
*/
|
|
50
|
+
function pruneUnusedSchemas(spec) {
|
|
51
|
+
const schemas = spec.components.schemas;
|
|
52
|
+
const reachable = new Set(collectSchemaRefs(spec.paths));
|
|
53
|
+
const pending = [...reachable];
|
|
54
|
+
while (pending.length > 0) {
|
|
55
|
+
const name = pending.pop();
|
|
56
|
+
if (name === void 0) continue;
|
|
57
|
+
for (const ref of collectSchemaRefs(schemas[name])) if (!reachable.has(ref)) {
|
|
58
|
+
reachable.add(ref);
|
|
59
|
+
pending.push(ref);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
for (const name of Object.keys(schemas)) if (!reachable.has(name)) delete schemas[name];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Removes top-level tags no longer referenced by any remaining path operation, in place.
|
|
66
|
+
* @param spec - The spec to prune, after paths have been stripped.
|
|
67
|
+
*/
|
|
68
|
+
function pruneUnusedTags(spec) {
|
|
69
|
+
const usedTags = /* @__PURE__ */ new Set();
|
|
70
|
+
for (const pathItem of Object.values(spec.paths)) for (const operation of Object.values(pathItem)) for (const tag of operation.tags ?? []) usedTags.add(tag);
|
|
71
|
+
for (let i = spec.tags.length - 1; i >= 0; i--) if (!usedTags.has(spec.tags[i].name)) spec.tags.splice(i, 1);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Computes a short hash identifying the spec served for the given config domains.
|
|
75
|
+
* Changes whenever the served spec would: with the OpenAPI spec version (`info.version`),
|
|
76
|
+
* the package version, or the domains that drive pruning.
|
|
77
|
+
*
|
|
78
|
+
* @param domains - The active config domains.
|
|
79
|
+
*/
|
|
80
|
+
function getOpenApiCacheKey(domains) {
|
|
81
|
+
const input = `1.7.0:${[...domains].sort().join(",")}:1.0.0`;
|
|
82
|
+
return (0, crypto.createHash)("sha256").update(input).digest("hex").slice(0, 8);
|
|
83
|
+
}
|
|
84
|
+
/** Returns the server URL to be set in the OpenAPI spec, based on the current namespace. */
|
|
85
|
+
function getServerUrl() {
|
|
86
|
+
return `https://${process.env.__OW_NAMESPACE}.adobeioruntime.net/api/v1/web/app-management`;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Builds the OpenAPI spec served by `GET /openapi.json`, tailored to the app's
|
|
90
|
+
* capabilities: unused paths are stripped, along with the schemas they leave
|
|
91
|
+
* unreferenced.
|
|
92
|
+
*
|
|
93
|
+
* Works on a fresh copy so the shared module import is never mutated. The
|
|
94
|
+
* committed `docs/openapi.json` always describes the full surface.
|
|
95
|
+
*
|
|
96
|
+
* @param domains - The active config domains that drive path trimming.
|
|
97
|
+
* @param logger - Logger used to report which paths get stripped.
|
|
98
|
+
*/
|
|
99
|
+
async function buildOpenApiSpec(domains, logger) {
|
|
100
|
+
const { default: openAPISpec } = await importOpenApi();
|
|
101
|
+
const spec = structuredClone(openAPISpec);
|
|
102
|
+
const stripPath = (path) => {
|
|
103
|
+
if (spec.paths[path]) {
|
|
104
|
+
logger.debug(`Stripping OpenAPI spec path: ${path}`);
|
|
105
|
+
delete spec.paths[path];
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
if (!domains.has("businessConfig.schema")) {
|
|
109
|
+
logger.debug("Application doesn't define business configuration, stripping references...");
|
|
110
|
+
stripPath("/config");
|
|
111
|
+
stripPath("/scope-tree");
|
|
112
|
+
stripPath("/scope-tree/commerce");
|
|
113
|
+
}
|
|
114
|
+
if (!domains.has("adminUiSdk")) {
|
|
115
|
+
logger.debug("Application doesn't define Admin UI SDK registration, stripping references...");
|
|
116
|
+
stripPath("/registration");
|
|
117
|
+
}
|
|
118
|
+
if (!require_validate.requiresInstallationFromDomains(domains)) {
|
|
119
|
+
logger.debug("Application doesn't require installation, stripping references...");
|
|
120
|
+
stripPath("/installation");
|
|
121
|
+
stripPath("/installation/validation");
|
|
122
|
+
stripPath("/installation/uninstallation");
|
|
123
|
+
}
|
|
124
|
+
pruneUnusedSchemas(spec);
|
|
125
|
+
pruneUnusedTags(spec);
|
|
126
|
+
spec.servers[0].url = getServerUrl();
|
|
127
|
+
return spec;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
//#endregion
|
|
131
|
+
//#region source/actions/app-config/router.ts
|
|
132
|
+
/**
|
|
133
|
+
* App Config action router.
|
|
134
|
+
*
|
|
135
|
+
* Routes:
|
|
136
|
+
* - GET / Retrieve the Commerce App configuration.
|
|
137
|
+
* - GET /openapi.json Returns the OpenAPI spec for all SDK actions
|
|
138
|
+
*/
|
|
139
|
+
const router = new require_router.HttpActionRouter().use(require_router.logger({ name: () => "app-config" }));
|
|
140
|
+
/** GET / - Get app config */
|
|
141
|
+
router.get("/", { handler: async (_req, { logger, rawParams }) => {
|
|
142
|
+
const rawAppConfig = rawParams.appConfig;
|
|
143
|
+
if (!rawAppConfig) return (0, _adobe_aio_commerce_lib_core_responses.internalServerError)("The app config is missing. Does the action receive it as a parameter?");
|
|
144
|
+
let appConfig = rawAppConfig;
|
|
145
|
+
if (require_validate.hasBusinessConfigSchema(rawAppConfig)) {
|
|
146
|
+
logger.debug("Resolving business config schema...");
|
|
147
|
+
const schema = await (0, _adobe_aio_commerce_lib_config.resolveBusinessConfigSchema)(rawAppConfig.businessConfig.schema, rawParams);
|
|
148
|
+
appConfig = {
|
|
149
|
+
...rawAppConfig,
|
|
150
|
+
businessConfig: {
|
|
151
|
+
...rawAppConfig.businessConfig,
|
|
152
|
+
schema
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
logger.debug("Validating app config...");
|
|
157
|
+
const config = require_validate.validateCommerceAppConfig(appConfig);
|
|
158
|
+
logger.debug("Successfully validated the app config");
|
|
159
|
+
const domains = require_validate.getConfigDomains(rawParams.appConfig);
|
|
160
|
+
const openApiSpecUrl = `${getServerUrl()}/app-config/openapi.json?ck=${getOpenApiCacheKey(domains)}`;
|
|
161
|
+
return (0, _adobe_aio_commerce_lib_core_responses.ok)({ body: {
|
|
162
|
+
...config,
|
|
163
|
+
openApiSpecUrl
|
|
164
|
+
} });
|
|
165
|
+
} });
|
|
166
|
+
/**
|
|
167
|
+
* GET /openapi.json - Returns the OpenAPI spec for all SDK actions
|
|
168
|
+
* @internal - Do not add to OpenAPI Spec.
|
|
169
|
+
*/
|
|
170
|
+
router.get("/openapi.json", {
|
|
171
|
+
query: valibot.object({ ck: valibot.optional(valibot.string()) }),
|
|
172
|
+
handler: async (req, { logger, rawParams }) => {
|
|
173
|
+
const { ck } = req.query;
|
|
174
|
+
const domains = require_validate.getConfigDomains(rawParams.appConfig);
|
|
175
|
+
if (ck && getOpenApiCacheKey(domains) === ck) {
|
|
176
|
+
logger.debug(`Received request for OpenAPI spec with cache key query param: ${ck}`);
|
|
177
|
+
return (0, _adobe_aio_commerce_lib_core_responses.ok)({
|
|
178
|
+
body: await buildOpenApiSpec(domains, logger),
|
|
179
|
+
headers: { "Cache-Control": "public, max-age=31536000, immutable" }
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
return (0, _adobe_aio_commerce_lib_core_responses.ok)({ body: await buildOpenApiSpec(domains, logger) });
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
//#endregion
|
|
187
|
+
//#region source/actions/app-config/index.ts
|
|
188
|
+
/**
|
|
189
|
+
* Factory to create the route handler for the `app-config` action.
|
|
190
|
+
* @param args - The arguments required to create the runtime action.
|
|
191
|
+
*/
|
|
192
|
+
const appConfigRuntimeAction = (args) => async (params) => {
|
|
193
|
+
const handler = router.handler();
|
|
194
|
+
const { appConfig } = args;
|
|
195
|
+
return await handler({
|
|
196
|
+
...params,
|
|
197
|
+
appConfig
|
|
198
|
+
});
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
//#endregion
|
|
202
|
+
exports.appConfigRuntimeAction = appConfigRuntimeAction;
|
|
@@ -0,0 +1,31 @@
|
|
|
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-DrYHK-z1.cjs";
|
|
16
|
+
import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
|
|
17
|
+
|
|
18
|
+
//#region source/actions/app-config/router.d.ts
|
|
19
|
+
/** The arguments required to create the runtime action for the app-config action. */
|
|
20
|
+
type RuntimeActionFactoryArgs = {
|
|
21
|
+
appConfig: CommerceAppConfig;
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region source/actions/app-config/index.d.ts
|
|
25
|
+
/**
|
|
26
|
+
* Factory to create the route handler for the `app-config` action.
|
|
27
|
+
* @param args - The arguments required to create the runtime action.
|
|
28
|
+
*/
|
|
29
|
+
declare const appConfigRuntimeAction: (args: RuntimeActionFactoryArgs) => (params: RuntimeActionParams) => Promise<import("@adobe/aio-commerce-lib-core/responses").ActionResponse>;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { appConfigRuntimeAction };
|
|
@@ -13,22 +13,52 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
16
|
-
const require_chunk = require('
|
|
17
|
-
const
|
|
18
|
-
const
|
|
16
|
+
const require_chunk = require('../../chunk-Cozy-1ZF.cjs');
|
|
17
|
+
const require_schemas = require('../../schemas-FngDuIeo.cjs');
|
|
18
|
+
const require_router = require('../../router-BOR7T6qR.cjs');
|
|
19
19
|
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
20
|
let valibot = require("valibot");
|
|
22
21
|
valibot = require_chunk.__toESM(valibot, 1);
|
|
22
|
+
let _adobe_aio_commerce_lib_core_responses = require("@adobe/aio-commerce-lib-core/responses");
|
|
23
23
|
|
|
24
|
-
//#region source/actions/config.ts
|
|
25
|
-
const
|
|
24
|
+
//#region source/actions/config/schema.ts
|
|
25
|
+
const AcceptedConfigurationValuesSchema = valibot.union([
|
|
26
|
+
valibot.boolean(),
|
|
27
|
+
valibot.string(),
|
|
28
|
+
valibot.array(valibot.string())
|
|
29
|
+
]);
|
|
26
30
|
/** The set of valid Commerce environments a configuration field can be scoped to. */
|
|
27
31
|
const COMMERCE_ENVS = ["paas", "saas"];
|
|
32
|
+
/** Query parameters for GET / */
|
|
33
|
+
const GetConfigurationQuerySchema = valibot.object({
|
|
34
|
+
scopeId: require_schemas.nonEmptyStringValueSchema("scopeId"),
|
|
35
|
+
commerceEnv: valibot.optional(valibot.picklist(COMMERCE_ENVS))
|
|
36
|
+
});
|
|
37
|
+
/** Request body for PUT / */
|
|
38
|
+
const PutConfigBodySchema = valibot.object({
|
|
39
|
+
scopeId: require_schemas.nonEmptyStringValueSchema("scopeId"),
|
|
40
|
+
config: valibot.array(valibot.object({
|
|
41
|
+
name: require_schemas.nonEmptyStringValueSchema("config[i].name"),
|
|
42
|
+
value: valibot.union([valibot.string(), valibot.array(valibot.string())])
|
|
43
|
+
}))
|
|
44
|
+
});
|
|
45
|
+
/** Request body for PATCH / */
|
|
46
|
+
const PatchConfigBodySchema = valibot.object({
|
|
47
|
+
scopeId: require_schemas.nonEmptyStringValueSchema("scopeId"),
|
|
48
|
+
config: valibot.array(valibot.object({
|
|
49
|
+
name: require_schemas.nonEmptyStringValueSchema("config[i].name"),
|
|
50
|
+
value: valibot.nullable(AcceptedConfigurationValuesSchema)
|
|
51
|
+
}))
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region source/actions/config/router.ts
|
|
56
|
+
const MASKED_PASSWORD_VALUE = "*****";
|
|
28
57
|
/**
|
|
29
58
|
* Filters a business configuration schema to the fields applicable to the
|
|
30
59
|
* given Commerce environment. Fields without an `env` property apply to all
|
|
31
60
|
* environments and are always included.
|
|
61
|
+
*
|
|
32
62
|
* @param schema - The business configuration schema to filter.
|
|
33
63
|
* @param env - The Commerce environment to filter by.
|
|
34
64
|
*/
|
|
@@ -37,9 +67,9 @@ function filterSchemaByEnv(schema, env) {
|
|
|
37
67
|
}
|
|
38
68
|
/**
|
|
39
69
|
* Filters password fields from the configuration values.
|
|
70
|
+
*
|
|
40
71
|
* @param schema - The schema to use to filter the values.
|
|
41
72
|
* @param values - The values to filter.
|
|
42
|
-
* @returns The filtered values.
|
|
43
73
|
*/
|
|
44
74
|
function filterPasswordFields(schema, values) {
|
|
45
75
|
return values.map((item) => {
|
|
@@ -50,13 +80,18 @@ function filterPasswordFields(schema, values) {
|
|
|
50
80
|
return item;
|
|
51
81
|
});
|
|
52
82
|
}
|
|
53
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Config action router.
|
|
85
|
+
*
|
|
86
|
+
* Routes:
|
|
87
|
+
* - GET / Get current configuration values for a given scope
|
|
88
|
+
* - POST / Set configuration (overrides all values for the scope) (deprecated)
|
|
89
|
+
* - PATCH / Partially update configuration (only updates provided fields, allows unsetting)
|
|
90
|
+
*/
|
|
91
|
+
const router = new require_router.HttpActionRouter().use(require_router.logger({ name: () => "config" }));
|
|
54
92
|
/** GET / - Retrieve configuration */
|
|
55
93
|
router.get("/", {
|
|
56
|
-
query:
|
|
57
|
-
scopeId: require_schemas.nonEmptyStringValueSchema("scopeId"),
|
|
58
|
-
commerceEnv: valibot.optional(valibot.picklist(COMMERCE_ENVS))
|
|
59
|
-
}),
|
|
94
|
+
query: GetConfigurationQuerySchema,
|
|
60
95
|
handler: async (req, ctx) => {
|
|
61
96
|
const { logger, rawParams } = ctx;
|
|
62
97
|
const { configSchema: rawConfigSchema } = rawParams;
|
|
@@ -80,17 +115,12 @@ router.get("/", {
|
|
|
80
115
|
});
|
|
81
116
|
/**
|
|
82
117
|
* PUT / - Set configuration (deprecated)
|
|
118
|
+
*
|
|
83
119
|
* @deprecated Use PATCH instead. This endpoint overwrites all values for the scope
|
|
84
120
|
* and does not support partial updates or unset semantics.
|
|
85
121
|
*/
|
|
86
122
|
router.put("/", {
|
|
87
|
-
body:
|
|
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
|
-
}),
|
|
123
|
+
body: PutConfigBodySchema,
|
|
94
124
|
handler: async (req, ctx) => {
|
|
95
125
|
const { logger, rawParams } = ctx;
|
|
96
126
|
logger.debug(`Setting configuration with scope id: ${req.body.scopeId}`);
|
|
@@ -112,17 +142,7 @@ router.put("/", {
|
|
|
112
142
|
});
|
|
113
143
|
/** PATCH / - Partially update configuration */
|
|
114
144
|
router.patch("/", {
|
|
115
|
-
body:
|
|
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
|
-
}),
|
|
145
|
+
body: PatchConfigBodySchema,
|
|
126
146
|
handler: async (req, ctx) => {
|
|
127
147
|
const { logger, rawParams } = ctx;
|
|
128
148
|
logger.debug(`Patching configuration with scope id: ${req.body.scopeId}`);
|
|
@@ -139,9 +159,17 @@ router.patch("/", {
|
|
|
139
159
|
});
|
|
140
160
|
}
|
|
141
161
|
});
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
162
|
+
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region source/actions/config/index.ts
|
|
165
|
+
/**
|
|
166
|
+
* Factory to create the route handler for the `config` action.
|
|
167
|
+
* @param args - The arguments required to create the runtime action.
|
|
168
|
+
*/
|
|
169
|
+
const configRuntimeAction = (args) => async (params) => {
|
|
170
|
+
const handler = router.handler();
|
|
171
|
+
const { configSchema } = args;
|
|
172
|
+
return await handler({
|
|
145
173
|
...params,
|
|
146
174
|
configSchema
|
|
147
175
|
});
|
|
@@ -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
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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,14 +13,14 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
16
|
-
const require_chunk = require('
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const require_validate = require('
|
|
20
|
-
const
|
|
21
|
-
let _adobe_aio_commerce_lib_core_responses = require("@adobe/aio-commerce-lib-core/responses");
|
|
16
|
+
const require_chunk = require('../../chunk-Cozy-1ZF.cjs');
|
|
17
|
+
const require_schemas = require('../../schemas-FngDuIeo.cjs');
|
|
18
|
+
const require_management = require('../../management-Dehz9qSJ.cjs');
|
|
19
|
+
const require_validate = require('../../validate-oAOpyFyb.cjs');
|
|
20
|
+
const require_router = require('../../router-BOR7T6qR.cjs');
|
|
22
21
|
let valibot = require("valibot");
|
|
23
22
|
valibot = require_chunk.__toESM(valibot, 1);
|
|
23
|
+
let _adobe_aio_commerce_lib_core_responses = require("@adobe/aio-commerce-lib-core/responses");
|
|
24
24
|
let _adobe_aio_lib_files = require("@adobe/aio-lib-files");
|
|
25
25
|
let _adobe_aio_lib_state = require("@adobe/aio-lib-state");
|
|
26
26
|
let openwhisk = require("openwhisk");
|
|
@@ -260,16 +260,19 @@ const AppDataSchema = valibot.object({
|
|
|
260
260
|
});
|
|
261
261
|
|
|
262
262
|
//#endregion
|
|
263
|
-
//#region source/actions/installation.ts
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
const InstallationRequestBodySchema = (0, valibot.object)({
|
|
263
|
+
//#region source/actions/installation/schema.ts
|
|
264
|
+
/** Request body for POST / and POST /validation (shared shape) */
|
|
265
|
+
const InstallationRequestBodySchema = valibot.object({
|
|
267
266
|
appData: AppDataSchema,
|
|
268
|
-
commerceBaseUrl:
|
|
269
|
-
commerceEnv:
|
|
270
|
-
ioEventsUrl:
|
|
271
|
-
ioEventsEnv:
|
|
267
|
+
commerceBaseUrl: valibot.string(),
|
|
268
|
+
commerceEnv: valibot.string(),
|
|
269
|
+
ioEventsUrl: valibot.string(),
|
|
270
|
+
ioEventsEnv: valibot.string()
|
|
272
271
|
});
|
|
272
|
+
|
|
273
|
+
//#endregion
|
|
274
|
+
//#region source/actions/installation/router.ts
|
|
275
|
+
const DEFAULT_ACTION_NAME = "app-management/installation";
|
|
273
276
|
/** Creates a workflow state store with the given prefix. */
|
|
274
277
|
function createWorkflowStore(prefix) {
|
|
275
278
|
return createCombinedStore({
|
|
@@ -352,14 +355,14 @@ function createInstallationHooks(store, logFn) {
|
|
|
352
355
|
* Installation action router.
|
|
353
356
|
*
|
|
354
357
|
* Routes:
|
|
355
|
-
* - GET /
|
|
356
|
-
* - POST /
|
|
357
|
-
* - POST /
|
|
358
|
-
* - POST /
|
|
359
|
-
* - POST /
|
|
360
|
-
* - GET /
|
|
361
|
-
* - POST /
|
|
362
|
-
* - DELETE /
|
|
358
|
+
* - GET / Get current installation status
|
|
359
|
+
* - POST / Start installation (creates plan, invokes execution async)
|
|
360
|
+
* - POST /execution Execute installation (internal, called async)
|
|
361
|
+
* - POST /validation Pre-installation validation
|
|
362
|
+
* - POST /uninstallation Start uninstallation (creates plan, invokes execution async)
|
|
363
|
+
* - GET /uninstallation Get current uninstallation status
|
|
364
|
+
* - POST /uninstallation/execution Execute uninstallation (internal, called async)
|
|
365
|
+
* - DELETE /uninstallation Clear uninstallation state only (no offboarding)
|
|
363
366
|
*/
|
|
364
367
|
const router = new require_router.HttpActionRouter().use(require_router.logger({ name: () => "installation" }));
|
|
365
368
|
/**
|
|
@@ -401,7 +404,7 @@ router.post("/", {
|
|
|
401
404
|
logger.debug("Previous installation failed, allowing retry");
|
|
402
405
|
}
|
|
403
406
|
const rawAppConfig = rawParams.appConfig;
|
|
404
|
-
if (!rawAppConfig) return (0, _adobe_aio_commerce_lib_core_responses.internalServerError)("
|
|
407
|
+
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
408
|
const appConfig = require_validate.validateCommerceAppConfig(rawAppConfig);
|
|
406
409
|
const initialState = require_management.createInitialInstallationState({ config: appConfig });
|
|
407
410
|
logger.debug(`Created initial state: ${initialState.id}`);
|
|
@@ -429,7 +432,8 @@ router.post("/", {
|
|
|
429
432
|
}
|
|
430
433
|
});
|
|
431
434
|
/**
|
|
432
|
-
* POST /installation/execution - Execute installation
|
|
435
|
+
* POST /installation/execution - Execute installation
|
|
436
|
+
* @internal - Do not add to OpenAPI Spec.
|
|
433
437
|
*
|
|
434
438
|
* This endpoint is called asynchronously by POST /installation.
|
|
435
439
|
* It runs the actual installation workflow and saves state.
|
|
@@ -476,7 +480,7 @@ router.post("/validation", {
|
|
|
476
480
|
handler: async (req, { logger, rawParams }) => {
|
|
477
481
|
logger.debug("Running pre-installation validation...");
|
|
478
482
|
const rawAppConfig = rawParams.appConfig;
|
|
479
|
-
if (!rawAppConfig) return (0, _adobe_aio_commerce_lib_core_responses.internalServerError)("
|
|
483
|
+
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
484
|
const appConfig = require_validate.validateCommerceAppConfig(rawAppConfig);
|
|
481
485
|
const { appData, ...params } = buildWorkflowParams(req.body, rawParams);
|
|
482
486
|
const result = await require_management.runValidation({
|
|
@@ -516,7 +520,7 @@ router.post("/uninstallation", {
|
|
|
516
520
|
const { appData, commerceBaseUrl } = req.body;
|
|
517
521
|
logger.debug(`Starting uninstallation for app "${appData.projectName}" (workspace: "${appData.workspaceName}", commerce: "${commerceBaseUrl}")`);
|
|
518
522
|
const rawAppConfig = rawParams.appConfig;
|
|
519
|
-
if (!rawAppConfig) return (0, _adobe_aio_commerce_lib_core_responses.internalServerError)("
|
|
523
|
+
if (!rawAppConfig) return (0, _adobe_aio_commerce_lib_core_responses.internalServerError)("The app config is missing. Does the action receive it as a parameter?");
|
|
520
524
|
const appConfig = require_validate.validateCommerceAppConfig(rawAppConfig);
|
|
521
525
|
const store = await createUninstallationStore();
|
|
522
526
|
const existingState = await store.get(getStorageKey());
|
|
@@ -549,7 +553,8 @@ router.post("/uninstallation", {
|
|
|
549
553
|
}
|
|
550
554
|
});
|
|
551
555
|
/**
|
|
552
|
-
* POST /uninstallation/execution - Execute uninstallation
|
|
556
|
+
* POST /uninstallation/execution - Execute uninstallation
|
|
557
|
+
* @internal - Do not add to OpenAPI Spec.
|
|
553
558
|
*
|
|
554
559
|
* Flow:
|
|
555
560
|
* 1. Build InstallationContext from params
|
|
@@ -598,9 +603,17 @@ router.delete("/uninstallation", { handler: async (_req, { logger }) => {
|
|
|
598
603
|
logger.debug("Uninstallation state cleared");
|
|
599
604
|
return (0, _adobe_aio_commerce_lib_core_responses.noContent)();
|
|
600
605
|
} });
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
606
|
+
|
|
607
|
+
//#endregion
|
|
608
|
+
//#region source/actions/installation/index.ts
|
|
609
|
+
/**
|
|
610
|
+
* Factory to create the route handler for the `installation` action.
|
|
611
|
+
* @param args - The arguments required to create the runtime action.
|
|
612
|
+
*/
|
|
613
|
+
const installationRuntimeAction = (args) => async (params) => {
|
|
614
|
+
const handler = router.handler();
|
|
615
|
+
const { appConfig, customScriptsLoader } = args;
|
|
616
|
+
return await handler({
|
|
604
617
|
...params,
|
|
605
618
|
appConfig,
|
|
606
619
|
customScriptsLoader
|
|
@@ -12,21 +12,23 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import { n as
|
|
16
|
-
import {
|
|
15
|
+
import { n as CommerceAppConfig, r as CommerceAppConfigOutputModel } from "../../app-DrYHK-z1.cjs";
|
|
16
|
+
import { Y as InstallationContext } from "../../index-B5gJ-q4U.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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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 };
|
|
@@ -13,24 +13,34 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
16
|
-
const require_router = require('
|
|
16
|
+
const require_router = require('../../router-BOR7T6qR.cjs');
|
|
17
17
|
let _adobe_aio_commerce_lib_core_responses = require("@adobe/aio-commerce-lib-core/responses");
|
|
18
18
|
|
|
19
|
-
//#region source/actions/registration.ts
|
|
20
|
-
/**
|
|
19
|
+
//#region source/actions/registration/router.ts
|
|
20
|
+
/**
|
|
21
|
+
* Registration action router.
|
|
22
|
+
*
|
|
23
|
+
* Routes:
|
|
24
|
+
* - GET / Retrieve the Admin UI SDK registration.
|
|
25
|
+
*/
|
|
21
26
|
const router = new require_router.HttpActionRouter().use(require_router.logger({ name: () => "registration" }));
|
|
22
27
|
/** GET / - Return Admin UI SDK registration object */
|
|
23
28
|
router.get("/", { handler: async (_req, { logger, rawParams }) => {
|
|
24
29
|
logger.debug("Returning Admin UI SDK registration...");
|
|
25
30
|
return (0, _adobe_aio_commerce_lib_core_responses.ok)({ body: { registration: rawParams.registration } });
|
|
26
31
|
} });
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region source/actions/registration/index.ts
|
|
27
35
|
/**
|
|
28
36
|
* Factory to create the route handler for the `registration` action.
|
|
29
|
-
* @param args - The
|
|
37
|
+
* @param args - The arguments required to create the runtime action.
|
|
30
38
|
* @experimental
|
|
31
39
|
*/
|
|
32
|
-
const registrationRuntimeAction = (
|
|
33
|
-
|
|
40
|
+
const registrationRuntimeAction = (args) => async (params) => {
|
|
41
|
+
const handler = router.handler();
|
|
42
|
+
const { registration } = args;
|
|
43
|
+
return await handler({
|
|
34
44
|
...params,
|
|
35
45
|
registration
|
|
36
46
|
});
|