@adobe/aio-commerce-lib-app 1.5.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 +49 -0
- package/dist/cjs/actions/app-config/index.cjs +202 -0
- package/dist/cjs/actions/{app-config.d.cts → app-config/index.d.cts} +11 -9
- package/dist/cjs/actions/{config.cjs → config/index.cjs} +79 -46
- package/dist/{es/actions/config.d.mts → cjs/actions/config/index.d.cts} +10 -8
- package/dist/cjs/actions/{installation.cjs → installation/index.cjs} +55 -36
- package/dist/{es/actions/installation.d.mts → cjs/actions/installation/index.d.cts} +11 -10
- package/dist/cjs/actions/{registration.cjs → registration/index.cjs} +16 -7
- package/dist/cjs/actions/{registration.d.cts → registration/index.d.cts} +8 -9
- package/dist/cjs/actions/{scope-tree.cjs → scope-tree/index.cjs} +52 -15
- package/dist/{es/actions/scope-tree.d.mts → cjs/actions/scope-tree/index.d.cts} +2 -5
- package/dist/cjs/{admin-ui-sdk-BiSopnKI.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 +241 -56
- package/dist/cjs/commands/templates/app-management/app-config.js.template +2 -2
- package/dist/cjs/config/index.cjs +3 -3
- package/dist/cjs/config/index.d.cts +181 -1158
- package/dist/cjs/{config-ct-qMOGj.cjs → config-D-s0GSep.cjs} +4 -6
- package/dist/cjs/{error-C5LNOZ4f.cjs → error-D-N0PKSl.cjs} +0 -1
- package/dist/cjs/{index-B5WKJ3hJ.d.cts → index-B5gJ-q4U.d.cts} +172 -3
- package/dist/cjs/index-BXm8UbK7.d.cts +16 -0
- package/dist/cjs/{logging-BTevALnL.cjs → logging-BVz3weoC.cjs} +1 -1
- package/dist/cjs/management/index.cjs +1 -1
- package/dist/cjs/management/index.d.cts +2 -3
- package/dist/cjs/{management-D1QXg4YU.cjs → management-Dehz9qSJ.cjs} +114 -51
- package/dist/cjs/openapi-Cux6K4ZD.cjs +3072 -0
- package/dist/cjs/{router-CFErodHU.cjs → router-BOR7T6qR.cjs} +1 -1
- package/dist/cjs/{schemas-CukVpc19.cjs → schemas-FngDuIeo.cjs} +1 -1
- package/dist/cjs/{validate-b_bI4mDb.cjs → validate-oAOpyFyb.cjs} +49 -17
- package/dist/cjs/{webhooks-DS1BtgED.cjs → webhooks-tbZy9G3p.cjs} +4 -4
- package/dist/es/actions/{app-config.d.mts → app-config/index.d.mts} +11 -9
- package/dist/es/actions/app-config/index.mjs +199 -0
- package/dist/{cjs/actions/config.d.cts → es/actions/config/index.d.mts} +10 -8
- package/dist/es/actions/{config.mjs → config/index.mjs} +78 -45
- package/dist/{cjs/actions/installation.d.cts → es/actions/installation/index.d.mts} +11 -10
- package/dist/es/actions/{installation.mjs → installation/index.mjs} +54 -36
- package/dist/es/actions/{registration.d.mts → registration/index.d.mts} +8 -9
- package/dist/es/actions/{registration.mjs → registration/index.mjs} +16 -6
- package/dist/{cjs/actions/scope-tree.d.cts → es/actions/scope-tree/index.d.mts} +2 -5
- package/dist/es/actions/{scope-tree.mjs → scope-tree/index.mjs} +51 -14
- package/dist/es/{admin-ui-sdk-CCo2SWiL.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 +223 -38
- package/dist/es/commands/templates/app-management/app-config.js.template +2 -2
- package/dist/es/config/index.d.mts +181 -1157
- package/dist/es/config/index.mjs +3 -3
- package/dist/es/{config-DGPFTk6w.mjs → config-3I4eLyyR.mjs} +4 -5
- package/dist/es/index-B0XqHwY5.d.mts +16 -0
- package/dist/es/{index-CCov0odd.d.mts → index-DLMbTtKS.d.mts} +172 -3
- package/dist/es/management/index.d.mts +2 -3
- package/dist/es/management/index.mjs +1 -1
- package/dist/es/{management-CCsOfniv.mjs → management-BUX-w2Ji.mjs} +113 -51
- package/dist/es/openapi-B6uP0SRn.mjs +3024 -0
- package/dist/es/{validate-Dn3lLTGj.mjs → validate-Dfajrp99.mjs} +37 -17
- package/dist/es/{webhooks-Dhrkkip7.mjs → webhooks-B5oq9ULL.mjs} +3 -3
- package/package.json +29 -17
- package/dist/cjs/actions/app-config.cjs +0 -41
- package/dist/cjs/app-C6kImBl7.d.cts +0 -564
- package/dist/cjs/step-CWYnKbga.d.cts +0 -187
- package/dist/es/actions/app-config.mjs +0 -39
- package/dist/es/app-DcY6dJiQ.d.mts +0 -564
- package/dist/es/step-0eI2x4C9.d.mts +0 -187
- /package/dist/cjs/{chunk-DS2yp5vX.cjs → chunk-Cozy-1ZF.cjs} +0 -0
- /package/dist/es/{error-DHlYzkbb.mjs → error-_RMwtrUA.mjs} +0 -0
- /package/dist/es/{logging-XIUXDK5T.mjs → logging-DbJHXSKh.mjs} +0 -0
- /package/dist/es/{router-BxaxEEu3.mjs → router-D58JJHHA.mjs} +0 -0
- /package/dist/es/{schemas-DOcnD16x.mjs → schemas-hRovglBF.mjs} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,54 @@
|
|
|
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
|
+
|
|
26
|
+
## 1.6.0
|
|
27
|
+
|
|
28
|
+
### Minor Changes
|
|
29
|
+
|
|
30
|
+
- [#438](https://github.com/adobe/aio-commerce-sdk/pull/438) [`fbc70ea`](https://github.com/adobe/aio-commerce-sdk/commit/fbc70ea680e5f0f7da10fc1771e5327806aad4bc) Thanks [@iivvaannxx](https://github.com/iivvaannxx)! - Support `dynamicList` business configuration fields. The generated `config` and `app-config` actions will now resolve list options at request time.
|
|
31
|
+
|
|
32
|
+
- [#469](https://github.com/adobe/aio-commerce-sdk/pull/469) [`ad3d980`](https://github.com/adobe/aio-commerce-sdk/commit/ad3d980f0370e21c61f34426ab2638fb682e008d) Thanks [@aligent-lturner](https://github.com/aligent-lturner)! - Preserve a manually-set `runtime` on generated actions. Codegen no longer overwrites the `runtime` field in `ext.config.yaml`, so you can pin a different Node runtime (e.g. `nodejs:24`) and it survives regeneration.
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- [#470](https://github.com/adobe/aio-commerce-sdk/pull/470) [`ec2d426`](https://github.com/adobe/aio-commerce-sdk/commit/ec2d4262166bde68a434025667f38609313ad712) Thanks [@iivvaannxx](https://github.com/iivvaannxx)! - Fix CJS interop for ESM-only dependencies (`camelcase`, `ky`) on Node.js 22+
|
|
37
|
+
|
|
38
|
+
- [#456](https://github.com/adobe/aio-commerce-sdk/pull/456) [`dac5c04`](https://github.com/adobe/aio-commerce-sdk/commit/dac5c04bbb33cf4e42de819b21fb4a5bc932a586) Thanks [@oshmyheliuk](https://github.com/oshmyheliuk)! - Add validation on unique event provider label.
|
|
39
|
+
|
|
40
|
+
- [#456](https://github.com/adobe/aio-commerce-sdk/pull/456) [`dac5c04`](https://github.com/adobe/aio-commerce-sdk/commit/dac5c04bbb33cf4e42de819b21fb4a5bc932a586) Thanks [@oshmyheliuk](https://github.com/oshmyheliuk)! - Fix only one I/O Events registration being created when multiple event providers share the same runtime action.
|
|
41
|
+
|
|
42
|
+
- [#457](https://github.com/adobe/aio-commerce-sdk/pull/457) [`6bc80bc`](https://github.com/adobe/aio-commerce-sdk/commit/6bc80bcf6fb28219998c2f0f7ff0f66f5f4457c0) Thanks [@obarcelonap](https://github.com/obarcelonap)! - Fix event subscription rules not being forwarded to Commerce when installing an app
|
|
43
|
+
|
|
44
|
+
- Updated dependencies [[`ec2d426`](https://github.com/adobe/aio-commerce-sdk/commit/ec2d4262166bde68a434025667f38609313ad712), [`705b3b8`](https://github.com/adobe/aio-commerce-sdk/commit/705b3b89b2bb0f1cee421434be4bc92b71ddc0a9), [`fb28949`](https://github.com/adobe/aio-commerce-sdk/commit/fb2894915c6fa411ed24f3501a7fc600e4eb88ee), [`fbc70ea`](https://github.com/adobe/aio-commerce-sdk/commit/fbc70ea680e5f0f7da10fc1771e5327806aad4bc)]:
|
|
45
|
+
- @adobe/aio-commerce-lib-api@1.2.1
|
|
46
|
+
- @adobe/aio-commerce-lib-core@1.1.1
|
|
47
|
+
- @adobe/aio-commerce-lib-config@1.5.0
|
|
48
|
+
- @adobe/aio-commerce-lib-events@1.2.1
|
|
49
|
+
- @adobe/aio-commerce-lib-webhooks@1.1.1
|
|
50
|
+
- @adobe/aio-commerce-lib-auth@1.1.1
|
|
51
|
+
|
|
3
52
|
## 1.5.0
|
|
4
53
|
|
|
5
54
|
### 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;
|
|
@@ -12,18 +12,20 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import { n as
|
|
16
|
-
import * as _$_adobe_aio_commerce_lib_core_responses0 from "@adobe/aio-commerce-lib-core/responses";
|
|
15
|
+
import { n as CommerceAppConfig } from "../../app-DrYHK-z1.cjs";
|
|
17
16
|
import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
|
|
18
17
|
|
|
19
|
-
//#region source/actions/app-config.d.ts
|
|
20
|
-
/**
|
|
18
|
+
//#region source/actions/app-config/router.d.ts
|
|
19
|
+
/** The arguments required to create the runtime action for the app-config action. */
|
|
21
20
|
type RuntimeActionFactoryArgs = {
|
|
22
|
-
appConfig:
|
|
21
|
+
appConfig: CommerceAppConfig;
|
|
23
22
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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>;
|
|
28
30
|
//#endregion
|
|
29
31
|
export { appConfigRuntimeAction };
|
|
@@ -13,23 +13,52 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
16
|
-
const require_chunk = require('
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
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_router = require('../../router-BOR7T6qR.cjs');
|
|
19
|
+
let _adobe_aio_commerce_lib_config = require("@adobe/aio-commerce-lib-config");
|
|
21
20
|
let valibot = require("valibot");
|
|
22
21
|
valibot = require_chunk.__toESM(valibot, 1);
|
|
23
|
-
let
|
|
22
|
+
let _adobe_aio_commerce_lib_core_responses = require("@adobe/aio-commerce-lib-core/responses");
|
|
24
23
|
|
|
25
|
-
//#region source/actions/config.ts
|
|
26
|
-
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
|
+
]);
|
|
27
30
|
/** The set of valid Commerce environments a configuration field can be scoped to. */
|
|
28
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 = "*****";
|
|
29
57
|
/**
|
|
30
58
|
* Filters a business configuration schema to the fields applicable to the
|
|
31
59
|
* given Commerce environment. Fields without an `env` property apply to all
|
|
32
60
|
* environments and are always included.
|
|
61
|
+
*
|
|
33
62
|
* @param schema - The business configuration schema to filter.
|
|
34
63
|
* @param env - The Commerce environment to filter by.
|
|
35
64
|
*/
|
|
@@ -38,9 +67,9 @@ function filterSchemaByEnv(schema, env) {
|
|
|
38
67
|
}
|
|
39
68
|
/**
|
|
40
69
|
* Filters password fields from the configuration values.
|
|
70
|
+
*
|
|
41
71
|
* @param schema - The schema to use to filter the values.
|
|
42
72
|
* @param values - The values to filter.
|
|
43
|
-
* @returns The filtered values.
|
|
44
73
|
*/
|
|
45
74
|
function filterPasswordFields(schema, values) {
|
|
46
75
|
return values.map((item) => {
|
|
@@ -51,51 +80,55 @@ function filterPasswordFields(schema, values) {
|
|
|
51
80
|
return item;
|
|
52
81
|
});
|
|
53
82
|
}
|
|
54
|
-
|
|
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" }));
|
|
55
92
|
/** GET / - Retrieve configuration */
|
|
56
93
|
router.get("/", {
|
|
57
|
-
query:
|
|
58
|
-
scopeId: require_schemas.nonEmptyStringValueSchema("scopeId"),
|
|
59
|
-
commerceEnv: valibot.optional(valibot.picklist(COMMERCE_ENVS))
|
|
60
|
-
}),
|
|
94
|
+
query: GetConfigurationQuerySchema,
|
|
61
95
|
handler: async (req, ctx) => {
|
|
62
96
|
const { logger, rawParams } = ctx;
|
|
63
|
-
const configSchema = rawParams
|
|
64
|
-
logger.debug("Validating configuration schema...");
|
|
65
|
-
const validatedSchema = require_validate.validateCommerceAppConfigDomain(configSchema, "businessConfig.schema");
|
|
97
|
+
const { configSchema: rawConfigSchema } = rawParams;
|
|
66
98
|
const env = req.query.commerceEnv;
|
|
67
|
-
const
|
|
68
|
-
|
|
99
|
+
const envFilteredSchema = env ? filterSchemaByEnv(rawConfigSchema, env) : rawConfigSchema;
|
|
100
|
+
logger.debug("Initializing configuration");
|
|
101
|
+
const { configSchema } = await (0, _adobe_aio_commerce_lib_config.initialize)({
|
|
102
|
+
schema: envFilteredSchema,
|
|
103
|
+
params: rawParams
|
|
104
|
+
});
|
|
69
105
|
const { scopeId } = req.query;
|
|
70
106
|
logger.debug(`Retrieving configuration with scope id: ${scopeId}`);
|
|
71
107
|
const appConfiguration = await (0, _adobe_aio_commerce_lib_config.getConfiguration)((0, _adobe_aio_commerce_lib_config.byScopeId)(scopeId), { encryptionKey: rawParams.AIO_COMMERCE_CONFIG_ENCRYPTION_KEY });
|
|
72
108
|
logger.debug("Masking password values...");
|
|
73
|
-
appConfiguration.config = filterPasswordFields(
|
|
109
|
+
appConfiguration.config = filterPasswordFields(configSchema, appConfiguration.config);
|
|
74
110
|
return (0, _adobe_aio_commerce_lib_core_responses.ok)({ body: {
|
|
75
|
-
schema:
|
|
111
|
+
schema: configSchema,
|
|
76
112
|
values: appConfiguration
|
|
77
113
|
} });
|
|
78
114
|
}
|
|
79
115
|
});
|
|
80
116
|
/**
|
|
81
117
|
* PUT / - Set configuration (deprecated)
|
|
118
|
+
*
|
|
82
119
|
* @deprecated Use PATCH instead. This endpoint overwrites all values for the scope
|
|
83
120
|
* and does not support partial updates or unset semantics.
|
|
84
121
|
*/
|
|
85
122
|
router.put("/", {
|
|
86
|
-
body:
|
|
87
|
-
scopeId: require_schemas.nonEmptyStringValueSchema("scopeId"),
|
|
88
|
-
config: valibot.array(valibot.object({
|
|
89
|
-
name: require_schemas.nonEmptyStringValueSchema("config.name"),
|
|
90
|
-
value: valibot.union([valibot.string(), valibot.array(valibot.string())])
|
|
91
|
-
}))
|
|
92
|
-
}),
|
|
123
|
+
body: PutConfigBodySchema,
|
|
93
124
|
handler: async (req, ctx) => {
|
|
94
125
|
const { logger, rawParams } = ctx;
|
|
95
|
-
const { configSchema } = rawParams;
|
|
96
126
|
logger.debug(`Setting configuration with scope id: ${req.body.scopeId}`);
|
|
97
127
|
const { scopeId, config } = req.body;
|
|
98
|
-
(0, _adobe_aio_commerce_lib_config.initialize)({
|
|
128
|
+
const { configSchema } = await (0, _adobe_aio_commerce_lib_config.initialize)({
|
|
129
|
+
schema: rawParams.configSchema,
|
|
130
|
+
params: rawParams
|
|
131
|
+
});
|
|
99
132
|
const result = await (0, _adobe_aio_commerce_lib_config.setConfiguration)({ config: config.filter((item) => item.value !== MASKED_PASSWORD_VALUE) }, (0, _adobe_aio_commerce_lib_config.byScopeId)(scopeId), { encryptionKey: rawParams.AIO_COMMERCE_CONFIG_ENCRYPTION_KEY });
|
|
100
133
|
result.config = filterPasswordFields(configSchema, result.config);
|
|
101
134
|
return (0, _adobe_aio_commerce_lib_core_responses.ok)({
|
|
@@ -109,23 +142,15 @@ router.put("/", {
|
|
|
109
142
|
});
|
|
110
143
|
/** PATCH / - Partially update configuration */
|
|
111
144
|
router.patch("/", {
|
|
112
|
-
body:
|
|
113
|
-
scopeId: require_schemas.nonEmptyStringValueSchema("scopeId"),
|
|
114
|
-
config: valibot.array(valibot.object({
|
|
115
|
-
name: require_schemas.nonEmptyStringValueSchema("config.name"),
|
|
116
|
-
value: valibot.nullable(valibot.union([
|
|
117
|
-
valibot.boolean(),
|
|
118
|
-
valibot.string(),
|
|
119
|
-
valibot.array(valibot.string())
|
|
120
|
-
]))
|
|
121
|
-
}))
|
|
122
|
-
}),
|
|
145
|
+
body: PatchConfigBodySchema,
|
|
123
146
|
handler: async (req, ctx) => {
|
|
124
147
|
const { logger, rawParams } = ctx;
|
|
125
|
-
const { configSchema } = rawParams;
|
|
126
148
|
logger.debug(`Patching configuration with scope id: ${req.body.scopeId}`);
|
|
127
149
|
const { scopeId, config } = req.body;
|
|
128
|
-
(0, _adobe_aio_commerce_lib_config.initialize)({
|
|
150
|
+
const { configSchema } = await (0, _adobe_aio_commerce_lib_config.initialize)({
|
|
151
|
+
schema: rawParams.configSchema,
|
|
152
|
+
params: rawParams
|
|
153
|
+
});
|
|
129
154
|
const result = await (0, _adobe_aio_commerce_lib_config.setConfiguration)({ config }, (0, _adobe_aio_commerce_lib_config.byScopeId)(scopeId), { encryptionKey: rawParams.AIO_COMMERCE_CONFIG_ENCRYPTION_KEY });
|
|
130
155
|
result.config = filterPasswordFields(configSchema, result.config);
|
|
131
156
|
return (0, _adobe_aio_commerce_lib_core_responses.ok)({
|
|
@@ -134,9 +159,17 @@ router.patch("/", {
|
|
|
134
159
|
});
|
|
135
160
|
}
|
|
136
161
|
});
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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({
|
|
140
173
|
...params,
|
|
141
174
|
configSchema
|
|
142
175
|
});
|
|
@@ -12,18 +12,20 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import * as _$_adobe_aio_commerce_lib_core_responses0 from "@adobe/aio-commerce-lib-core/responses";
|
|
16
|
-
import { BusinessConfigSchema } from "@adobe/aio-commerce-lib-config";
|
|
17
15
|
import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
|
|
16
|
+
import { BusinessConfigSchema } from "@adobe/aio-commerce-lib-config";
|
|
18
17
|
|
|
19
|
-
//#region source/actions/config.d.ts
|
|
20
|
-
/** 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. */
|
|
21
20
|
type ConfigActionFactoryArgs = {
|
|
22
21
|
configSchema: BusinessConfigSchema;
|
|
23
22
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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>;
|
|
28
30
|
//#endregion
|
|
29
31
|
export { configRuntimeAction };
|