@adobe/aio-commerce-lib-app 0.2.0 → 0.3.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 +14 -0
- package/dist/cjs/actions/index.cjs +815 -170
- package/dist/cjs/actions/index.d.cts +2 -2
- package/dist/cjs/app-Dx0ca6oL.d.cts +181 -0
- package/dist/cjs/commands/generate/actions/templates/business-configuration/get-config-schema.js.template +63 -0
- package/dist/cjs/commands/generate/actions/templates/business-configuration/get-configuration.js.template +104 -0
- package/dist/cjs/commands/generate/actions/templates/business-configuration/get-scope-tree.js.template +69 -0
- package/dist/cjs/commands/generate/actions/templates/business-configuration/set-configuration.js.template +125 -0
- package/dist/cjs/commands/generate/actions/templates/business-configuration/set-custom-scope-tree.js.template +83 -0
- package/dist/cjs/commands/generate/actions/templates/business-configuration/sync-commerce-scopes.js.template +113 -0
- package/dist/cjs/commands/generate/actions/templates/business-configuration/unsync-commerce-scopes.js.template +56 -0
- package/dist/cjs/commands/index.cjs +1075 -119
- package/dist/cjs/config/index.cjs +20 -1
- package/dist/cjs/config/index.d.cts +532 -3
- package/dist/cjs/config-JQ_n-5Nk.cjs +565 -0
- package/dist/cjs/error-Byj1DVHZ.cjs +344 -0
- package/dist/cjs/{index-DS3IlISO.d.cts → index-C5SutkJQ.d.cts} +1 -1
- package/dist/cjs/logging-DYwr5WQk.cjs +25 -0
- package/dist/cjs/management/index.cjs +9 -1
- package/dist/cjs/management/index.d.cts +1 -1
- package/dist/cjs/management-Dm5h0E6l.cjs +1246 -0
- package/dist/es/actions/index.d.mts +2 -2
- package/dist/es/actions/index.mjs +813 -170
- package/dist/es/app-Cx1-6dn0.d.mts +181 -0
- package/dist/es/commands/generate/actions/templates/business-configuration/get-config-schema.js.template +63 -0
- package/dist/es/commands/generate/actions/templates/business-configuration/get-configuration.js.template +104 -0
- package/dist/es/commands/generate/actions/templates/business-configuration/get-scope-tree.js.template +69 -0
- package/dist/es/commands/generate/actions/templates/business-configuration/set-configuration.js.template +125 -0
- package/dist/es/commands/generate/actions/templates/business-configuration/set-custom-scope-tree.js.template +83 -0
- package/dist/es/commands/generate/actions/templates/business-configuration/sync-commerce-scopes.js.template +113 -0
- package/dist/es/commands/generate/actions/templates/business-configuration/unsync-commerce-scopes.js.template +56 -0
- package/dist/es/commands/index.mjs +1070 -119
- package/dist/es/config/index.d.mts +532 -3
- package/dist/es/config/index.mjs +4 -1
- package/dist/es/config-BSGerqCG.mjs +457 -0
- package/dist/es/error-P7JgUTds.mjs +251 -0
- package/dist/es/{index-DQepSWYP.d.mts → index-Bxr3zvCT.d.mts} +2 -2
- package/dist/es/logging-VgerMhp6.mjs +18 -0
- package/dist/es/management/index.d.mts +2 -2
- package/dist/es/management/index.mjs +3 -1
- package/dist/es/management-Y7pwEbNI.mjs +1204 -0
- package/package.json +20 -8
- package/dist/cjs/app-C4HhkXbP.d.cts +0 -451
- package/dist/cjs/error-yAk1zzvx.cjs +0 -1
- package/dist/cjs/management-CE3_DJw4.cjs +0 -2
- package/dist/cjs/parser-Dovux8ce.cjs +0 -1
- package/dist/cjs/schemas-CdaP-Exw.cjs +0 -1
- package/dist/es/app-CMpx3D7Y.d.mts +0 -451
- package/dist/es/chunk-VmiN0kV1.mjs +0 -1
- package/dist/es/error-hBHRgZ9R.mjs +0 -1
- package/dist/es/management-BM2WcbV6.mjs +0 -2
- package/dist/es/parser-DOVfvr9l.mjs +0 -1
- package/dist/es/schemas-eemlD-xS.mjs +0 -1
- /package/dist/cjs/commands/generate/actions/templates/{custom-scripts.js.template → app-management/custom-scripts.js.template} +0 -0
- /package/dist/cjs/commands/generate/actions/templates/{get-app-config.js.template → app-management/get-app-config.js.template} +0 -0
- /package/dist/cjs/commands/generate/actions/templates/{installation.js.template → app-management/installation.js.template} +0 -0
- /package/dist/es/commands/generate/actions/templates/{custom-scripts.js.template → app-management/custom-scripts.js.template} +0 -0
- /package/dist/es/commands/generate/actions/templates/{get-app-config.js.template → app-management/get-app-config.js.template} +0 -0
- /package/dist/es/commands/generate/actions/templates/{installation.js.template → app-management/installation.js.template} +0 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// This file has been auto-generated by `@adobe/aio-commerce-lib-config`
|
|
14
|
+
// Do not modify this file directly
|
|
15
|
+
|
|
16
|
+
import util from "node:util";
|
|
17
|
+
|
|
18
|
+
import { syncCommerceScopes } from "@adobe/aio-commerce-lib-config";
|
|
19
|
+
import { resolveCommerceHttpClientParams } from "@adobe/aio-commerce-sdk/api";
|
|
20
|
+
import { allNonEmpty } from "@adobe/aio-commerce-sdk/core/params";
|
|
21
|
+
import {
|
|
22
|
+
badRequest,
|
|
23
|
+
internalServerError,
|
|
24
|
+
nonAuthoritativeInformation,
|
|
25
|
+
ok,
|
|
26
|
+
} from "@adobe/aio-commerce-sdk/core/responses";
|
|
27
|
+
import AioLogger from "@adobe/aio-lib-core-logging";
|
|
28
|
+
|
|
29
|
+
// Shorthand to inspect an object.
|
|
30
|
+
const inspect = (obj) => util.inspect(obj, { depth: null });
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Sync commerce scopes.
|
|
34
|
+
* @param params - The input parameters.
|
|
35
|
+
* @returns The response object containing updated scope tree.
|
|
36
|
+
*/
|
|
37
|
+
export async function main(params) {
|
|
38
|
+
const logger = AioLogger("sync-commerce-scopes", {
|
|
39
|
+
level: params.LOG_LEVEL || "info",
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
try {
|
|
43
|
+
logger.debug("Syncing commerce scopes...");
|
|
44
|
+
|
|
45
|
+
if (!allNonEmpty(params, ["commerceBaseUrl"])) {
|
|
46
|
+
logger.error("Missing required parameter: commerceBaseUrl");
|
|
47
|
+
return badRequest("Missing required parameter: commerceBaseUrl");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const paramsWithCommerceConfig = {
|
|
51
|
+
...params,
|
|
52
|
+
AIO_COMMERCE_API_BASE_URL: params.commerceBaseUrl,
|
|
53
|
+
|
|
54
|
+
...(params.commerceEnv && {
|
|
55
|
+
AIO_COMMERCE_API_FLAVOR: params.commerceEnv,
|
|
56
|
+
}),
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const commerceConfig = resolveCommerceHttpClientParams(
|
|
60
|
+
paramsWithCommerceConfig,
|
|
61
|
+
{ tryForwardAuthProvider: true },
|
|
62
|
+
);
|
|
63
|
+
const result = await syncCommerceScopes(commerceConfig);
|
|
64
|
+
|
|
65
|
+
if (result.error) {
|
|
66
|
+
logger.error(`Error syncing commerce scopes: ${inspect(result.error)}`);
|
|
67
|
+
return internalServerError({
|
|
68
|
+
body: {
|
|
69
|
+
code: "INTERNAL_ERROR",
|
|
70
|
+
message: "An internal server error occurred",
|
|
71
|
+
error: result.error,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (!result.synced) {
|
|
77
|
+
logger.debug(
|
|
78
|
+
`Commerce scopes not synced (cached): ${inspect(result.scopeTree)}`,
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
return nonAuthoritativeInformation({
|
|
82
|
+
headers: { "x-cache": "hit" },
|
|
83
|
+
body: {
|
|
84
|
+
scopes: result.scopeTree,
|
|
85
|
+
synced: false,
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
logger.debug(
|
|
91
|
+
`Successfully synced commerce scopes: ${inspect(result.scopeTree)}`,
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
return ok({
|
|
95
|
+
body: {
|
|
96
|
+
scopes: result.scopeTree,
|
|
97
|
+
synced: true,
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
} catch (error) {
|
|
101
|
+
logger.error(
|
|
102
|
+
`Something went wrong while syncing commerce scopes: ${inspect(error)}`,
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
return internalServerError({
|
|
106
|
+
body: {
|
|
107
|
+
code: "INTERNAL_ERROR",
|
|
108
|
+
message: "An internal server error occurred",
|
|
109
|
+
details: error instanceof Error ? error.message : "Unknown error",
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// This file has been auto-generated by `@adobe/aio-commerce-lib-config`
|
|
14
|
+
// Do not modify this file directly
|
|
15
|
+
|
|
16
|
+
import util from "node:util";
|
|
17
|
+
|
|
18
|
+
import { unsyncCommerceScopes } from "@adobe/aio-commerce-lib-config";
|
|
19
|
+
import {
|
|
20
|
+
internalServerError,
|
|
21
|
+
ok,
|
|
22
|
+
} from "@adobe/aio-commerce-sdk/core/responses";
|
|
23
|
+
import AioLogger from "@adobe/aio-lib-core-logging";
|
|
24
|
+
|
|
25
|
+
const inspect = (obj) => util.inspect(obj, { depth: null });
|
|
26
|
+
/**
|
|
27
|
+
* Unsync commerce scopes - removes commerce scope from the persisted scope tree.
|
|
28
|
+
* @param params - The input parameters.
|
|
29
|
+
* @returns The response object with appropriate status based on the operation result.
|
|
30
|
+
*/
|
|
31
|
+
export async function main(params) {
|
|
32
|
+
const logger = AioLogger("unsync-commerce-scopes", {
|
|
33
|
+
level: params.LOG_LEVEL || "info",
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
const result = await unsyncCommerceScopes();
|
|
38
|
+
|
|
39
|
+
if (result) {
|
|
40
|
+
return ok("Commerce scope unsynced successfully");
|
|
41
|
+
} else {
|
|
42
|
+
logger.warn("Failed to unsync commerce scopes. Commerce scopes not found.");
|
|
43
|
+
return ok("Failed to unsync commerce scopes. Commerce scopes not found.");
|
|
44
|
+
}
|
|
45
|
+
} catch (error) {
|
|
46
|
+
logger.error(`Error unsyncing commerce scopes: ${inspect(error)}`);
|
|
47
|
+
|
|
48
|
+
return internalServerError({
|
|
49
|
+
body: {
|
|
50
|
+
code: "INTERNAL_ERROR",
|
|
51
|
+
message: "An internal server error occurred",
|
|
52
|
+
details: error instanceof Error ? error.message : "Unknown error",
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|