@adobe/aio-commerce-lib-app 0.3.2 → 1.0.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.
Files changed (78) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +1 -4
  3. package/bin/cli.mjs +24 -0
  4. package/dist/cjs/actions/app-config.cjs +27 -0
  5. package/dist/cjs/actions/app-config.d.cts +15 -0
  6. package/dist/cjs/actions/config.cjs +79 -0
  7. package/dist/cjs/actions/config.d.cts +15 -0
  8. package/dist/cjs/actions/installation.cjs +424 -0
  9. package/dist/cjs/actions/{index.d.cts → installation.d.cts} +4 -3
  10. package/dist/cjs/actions/scope-tree.cjs +97 -0
  11. package/dist/cjs/actions/scope-tree.d.cts +8 -0
  12. package/dist/cjs/{app-Dx0ca6oL.d.cts → app-PTKvEBea.d.cts} +6 -6
  13. package/dist/cjs/commands/generate/actions/templates/app-management/app-config.js.template +22 -0
  14. package/dist/cjs/commands/generate/actions/templates/app-management/installation.js.template +1 -1
  15. package/dist/cjs/commands/generate/actions/templates/business-configuration/config.js.template +22 -0
  16. package/dist/cjs/commands/generate/actions/templates/business-configuration/scope-tree.js.template +18 -0
  17. package/dist/cjs/commands/index.cjs +91 -106
  18. package/dist/cjs/config/index.cjs +21 -19
  19. package/dist/cjs/config/index.d.cts +32 -332
  20. package/dist/cjs/error-DJ2UAPH2.cjs +24 -0
  21. package/dist/cjs/installation-nwF2RC7F.cjs +241 -0
  22. package/dist/cjs/{logging-DYwr5WQk.cjs → logging-IDRQG0as.cjs} +2 -2
  23. package/dist/cjs/management/index.cjs +9 -8
  24. package/dist/cjs/management/index.d.cts +2 -2
  25. package/dist/cjs/parser-DIchX9SL.cjs +267 -0
  26. package/dist/cjs/router-DCw7oEQ9.cjs +417 -0
  27. package/dist/cjs/{management-Dm5h0E6l.cjs → runner-CUJ8RHzY.cjs} +24 -30
  28. package/dist/{es/index-Bxr3zvCT.d.mts → cjs/runner-Ds2m27Q4.d.cts} +49 -95
  29. package/dist/cjs/schemas-CZ6c8Id9.cjs +98 -0
  30. package/dist/cjs/validate-BegMfe-i.cjs +235 -0
  31. package/dist/es/actions/app-config.d.mts +15 -0
  32. package/dist/es/actions/app-config.mjs +25 -0
  33. package/dist/es/actions/config.d.mts +15 -0
  34. package/dist/es/actions/config.mjs +77 -0
  35. package/dist/es/actions/{index.d.mts → installation.d.mts} +4 -3
  36. package/dist/es/actions/{index.mjs → installation.mjs} +27 -427
  37. package/dist/es/actions/scope-tree.d.mts +8 -0
  38. package/dist/es/actions/scope-tree.mjs +95 -0
  39. package/dist/es/{app-Cx1-6dn0.d.mts → app-vKXaAr6f.d.mts} +6 -6
  40. package/dist/es/commands/generate/actions/templates/app-management/app-config.js.template +22 -0
  41. package/dist/es/commands/generate/actions/templates/app-management/installation.js.template +1 -1
  42. package/dist/es/commands/generate/actions/templates/business-configuration/config.js.template +22 -0
  43. package/dist/es/commands/generate/actions/templates/business-configuration/scope-tree.js.template +18 -0
  44. package/dist/es/commands/index.mjs +68 -84
  45. package/dist/es/config/index.d.mts +32 -332
  46. package/dist/es/config/index.mjs +3 -2
  47. package/dist/es/error-CMV3IjBz.mjs +18 -0
  48. package/dist/es/{error-P7JgUTds.mjs → installation-SWIwhpKT.mjs} +72 -124
  49. package/dist/es/management/index.d.mts +2 -3
  50. package/dist/es/management/index.mjs +1 -1
  51. package/dist/es/parser-CKQyrTB7.mjs +201 -0
  52. package/dist/es/router-CJ4VWoCt.mjs +404 -0
  53. package/dist/es/{management-Y7pwEbNI.mjs → runner-DB2tDBQS.mjs} +17 -24
  54. package/dist/{cjs/index-C5SutkJQ.d.cts → es/runner-Uk7263hG.d.mts} +49 -95
  55. package/dist/es/schemas-B8yIv0_b.mjs +41 -0
  56. package/dist/es/validate-DXI6gwZ2.mjs +187 -0
  57. package/package.json +38 -24
  58. package/dist/cjs/actions/index.cjs +0 -824
  59. package/dist/cjs/commands/generate/actions/templates/app-management/get-app-config.js.template +0 -62
  60. package/dist/cjs/commands/generate/actions/templates/business-configuration/get-config-schema.js.template +0 -63
  61. package/dist/cjs/commands/generate/actions/templates/business-configuration/get-configuration.js.template +0 -104
  62. package/dist/cjs/commands/generate/actions/templates/business-configuration/get-scope-tree.js.template +0 -69
  63. package/dist/cjs/commands/generate/actions/templates/business-configuration/set-configuration.js.template +0 -125
  64. package/dist/cjs/commands/generate/actions/templates/business-configuration/set-custom-scope-tree.js.template +0 -83
  65. package/dist/cjs/commands/generate/actions/templates/business-configuration/sync-commerce-scopes.js.template +0 -113
  66. package/dist/cjs/commands/generate/actions/templates/business-configuration/unsync-commerce-scopes.js.template +0 -56
  67. package/dist/cjs/config-JQ_n-5Nk.cjs +0 -565
  68. package/dist/cjs/error-Byj1DVHZ.cjs +0 -344
  69. package/dist/es/commands/generate/actions/templates/app-management/get-app-config.js.template +0 -62
  70. package/dist/es/commands/generate/actions/templates/business-configuration/get-config-schema.js.template +0 -63
  71. package/dist/es/commands/generate/actions/templates/business-configuration/get-configuration.js.template +0 -104
  72. package/dist/es/commands/generate/actions/templates/business-configuration/get-scope-tree.js.template +0 -69
  73. package/dist/es/commands/generate/actions/templates/business-configuration/set-configuration.js.template +0 -125
  74. package/dist/es/commands/generate/actions/templates/business-configuration/set-custom-scope-tree.js.template +0 -83
  75. package/dist/es/commands/generate/actions/templates/business-configuration/sync-commerce-scopes.js.template +0 -113
  76. package/dist/es/commands/generate/actions/templates/business-configuration/unsync-commerce-scopes.js.template +0 -56
  77. package/dist/es/config-BSGerqCG.mjs +0 -457
  78. /package/dist/es/{logging-VgerMhp6.mjs → logging-CzmXDzxI.mjs} +0 -0
@@ -1,125 +0,0 @@
1
- // @ts-check
2
-
3
- /*
4
- * Copyright 2025 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
- // This file has been auto-generated by `@adobe/aio-commerce-lib-config`
16
- // Do not modify this file directly
17
-
18
- import util from "node:util";
19
-
20
- import {
21
- byCodeAndLevel,
22
- byScopeId,
23
- setConfiguration,
24
- setGlobalLibConfigOptions,
25
- } from "@adobe/aio-commerce-lib-config";
26
- import {
27
- badRequest,
28
- internalServerError,
29
- ok,
30
- } from "@adobe/aio-commerce-sdk/core/responses";
31
- import AioLogger from "@adobe/aio-lib-core-logging";
32
-
33
- // Shorthand to inspect an object.
34
- const inspect = (obj) => util.inspect(obj, { depth: null });
35
-
36
- /**
37
- * Get the configuration.
38
- * @param params - The input parameters.
39
- * @returns The response object containing the updated configuration values.
40
- */
41
- export async function main(params) {
42
- const logger = AioLogger("set-configuration", {
43
- level: params.LOG_LEVEL || "info",
44
- });
45
-
46
- try {
47
- if (params.AIO_COMMERCE_CONFIG_ENCRYPTION_KEY) {
48
- setGlobalLibConfigOptions({
49
- encryptionKey: params.AIO_COMMERCE_CONFIG_ENCRYPTION_KEY,
50
- });
51
- }
52
- let body;
53
-
54
- if (
55
- params &&
56
- typeof params === "object" &&
57
- Object.keys(params).length === 0
58
- ) {
59
- body = {};
60
- }
61
-
62
- const id = params.id;
63
- const code = params.code;
64
- const level = params.level;
65
-
66
- logger.debug(
67
- `Setting configuration with params: ${inspect({ id, code, level })}`,
68
- );
69
-
70
- if (!(id || (code && level))) {
71
- logger.warn(
72
- "Invalid params: Either id or both code and level query params are required",
73
- );
74
-
75
- return badRequest({
76
- body: {
77
- code: "INVALID_PARAMS",
78
- message: "Either id or both code and level query params are required",
79
- },
80
- });
81
- }
82
-
83
- const candidateConfig = params.config ?? body?.config;
84
- if (!(candidateConfig && Array.isArray(candidateConfig))) {
85
- logger.warn(
86
- "Invalid body: request must include a config array in params.config or body.config",
87
- );
88
-
89
- return badRequest({
90
- body: {
91
- code: "INVALID_BODY",
92
- message:
93
- "request must include a config array in params.config or body.config",
94
- },
95
- });
96
- }
97
-
98
- const payload = { config: candidateConfig };
99
- logger.debug(`Setting configuration with payload: ${inspect(payload)}`);
100
-
101
- const result = id
102
- ? await setConfiguration(payload, byScopeId(id))
103
- : await setConfiguration(payload, byCodeAndLevel(code, level));
104
-
105
- logger.debug(`Successfully set configuration: ${inspect(result)}`);
106
- return ok({
107
- body: { result },
108
- headers: {
109
- "Cache-Control": "no-store",
110
- },
111
- });
112
- } catch (error) {
113
- logger.error(
114
- `Something went wrong while setting configuration: ${inspect(error)}`,
115
- );
116
-
117
- return internalServerError({
118
- body: {
119
- code: "INTERNAL_ERROR",
120
- message: "An internal server error occurred",
121
- details: error instanceof Error ? error.message : "Unknown error",
122
- },
123
- });
124
- }
125
- }
@@ -1,83 +0,0 @@
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 { setCustomScopeTree } from "@adobe/aio-commerce-lib-config";
19
- import {
20
- badRequest,
21
- internalServerError,
22
- ok,
23
- } from "@adobe/aio-commerce-sdk/core/responses";
24
- import AioLogger from "@adobe/aio-lib-core-logging";
25
-
26
- // Shorthand to inspect an object.
27
- const inspect = (obj) => util.inspect(obj, { depth: null });
28
-
29
- /**
30
- * Set custom scope tree - replace all custom scopes with provided ones
31
- * @param params - The input parameters containing scopes array
32
- * @returns The response object containing updated custom scopes
33
- */
34
- export async function main(params) {
35
- const logger = AioLogger("set-custom-scope-tree", {
36
- level: params.LOG_LEVEL || "info",
37
- });
38
-
39
- try {
40
- const scopes = params.scopes;
41
- logger.debug(
42
- `Setting custom scope tree with ${scopes?.length || 0} scopes`,
43
- );
44
-
45
- if (!scopes) {
46
- logger.warn("Invalid request: Request must include scopes parameter");
47
- return badRequest({
48
- body: {
49
- code: "INVALID_REQUEST",
50
- message: "Request must include scopes parameter",
51
- details: "Expected: { scopes: [array of scope objects] }",
52
- },
53
- });
54
- }
55
-
56
- const request = { scopes };
57
- logger.debug(`Setting custom scope tree: ${inspect(request)}`);
58
-
59
- const result = await setCustomScopeTree(request);
60
- logger.debug(`Successfully set custom scope tree: ${inspect(result)}`);
61
-
62
- return ok({
63
- body: { result },
64
- headers: {
65
- "Cache-Control": "no-store",
66
- },
67
- });
68
- } catch (error) {
69
- logger.error(
70
- `Something went wrong while updating custom scope tree: ${inspect(error)}`,
71
- );
72
-
73
- return internalServerError({
74
- body: {
75
- code: "INTERNAL_ERROR",
76
- details: error instanceof Error ? error.message : "Unknown error",
77
-
78
- message:
79
- "An internal server error occurred while updating custom scope tree",
80
- },
81
- });
82
- }
83
- }
@@ -1,113 +0,0 @@
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
- }
@@ -1,56 +0,0 @@
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
- }