@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
|
@@ -13,13 +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
|
|
20
|
-
|
|
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');
|
|
21
21
|
let valibot = require("valibot");
|
|
22
22
|
valibot = require_chunk.__toESM(valibot, 1);
|
|
23
|
+
let _adobe_aio_commerce_lib_core_responses = require("@adobe/aio-commerce-lib-core/responses");
|
|
23
24
|
let _adobe_aio_lib_files = require("@adobe/aio-lib-files");
|
|
24
25
|
let _adobe_aio_lib_state = require("@adobe/aio-lib-state");
|
|
25
26
|
let openwhisk = require("openwhisk");
|
|
@@ -259,16 +260,19 @@ const AppDataSchema = valibot.object({
|
|
|
259
260
|
});
|
|
260
261
|
|
|
261
262
|
//#endregion
|
|
262
|
-
//#region source/actions/installation.ts
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
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({
|
|
266
266
|
appData: AppDataSchema,
|
|
267
|
-
commerceBaseUrl:
|
|
268
|
-
commerceEnv:
|
|
269
|
-
ioEventsUrl:
|
|
270
|
-
ioEventsEnv:
|
|
267
|
+
commerceBaseUrl: valibot.string(),
|
|
268
|
+
commerceEnv: valibot.string(),
|
|
269
|
+
ioEventsUrl: valibot.string(),
|
|
270
|
+
ioEventsEnv: valibot.string()
|
|
271
271
|
});
|
|
272
|
+
|
|
273
|
+
//#endregion
|
|
274
|
+
//#region source/actions/installation/router.ts
|
|
275
|
+
const DEFAULT_ACTION_NAME = "app-management/installation";
|
|
272
276
|
/** Creates a workflow state store with the given prefix. */
|
|
273
277
|
function createWorkflowStore(prefix) {
|
|
274
278
|
return createCombinedStore({
|
|
@@ -351,14 +355,14 @@ function createInstallationHooks(store, logFn) {
|
|
|
351
355
|
* Installation action router.
|
|
352
356
|
*
|
|
353
357
|
* Routes:
|
|
354
|
-
* - GET /
|
|
355
|
-
* - POST /
|
|
356
|
-
* - POST /
|
|
357
|
-
* - POST /
|
|
358
|
-
* - POST /
|
|
359
|
-
* - GET /
|
|
360
|
-
* - POST /
|
|
361
|
-
* - 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)
|
|
362
366
|
*/
|
|
363
367
|
const router = new require_router.HttpActionRouter().use(require_router.logger({ name: () => "installation" }));
|
|
364
368
|
/**
|
|
@@ -399,8 +403,9 @@ router.post("/", {
|
|
|
399
403
|
}
|
|
400
404
|
logger.debug("Previous installation failed, allowing retry");
|
|
401
405
|
}
|
|
402
|
-
const
|
|
403
|
-
if (!
|
|
406
|
+
const rawAppConfig = rawParams.appConfig;
|
|
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?");
|
|
408
|
+
const appConfig = require_validate.validateCommerceAppConfig(rawAppConfig);
|
|
404
409
|
const initialState = require_management.createInitialInstallationState({ config: appConfig });
|
|
405
410
|
logger.debug(`Created initial state: ${initialState.id}`);
|
|
406
411
|
await store.put(getStorageKey(), initialState);
|
|
@@ -427,16 +432,18 @@ router.post("/", {
|
|
|
427
432
|
}
|
|
428
433
|
});
|
|
429
434
|
/**
|
|
430
|
-
* POST /installation/execution - Execute installation
|
|
435
|
+
* POST /installation/execution - Execute installation
|
|
436
|
+
* @internal - Do not add to OpenAPI Spec.
|
|
431
437
|
*
|
|
432
438
|
* This endpoint is called asynchronously by POST /installation.
|
|
433
439
|
* It runs the actual installation workflow and saves state.
|
|
434
440
|
*/
|
|
435
441
|
router.post("/execution", { handler: async (_req, { logger, rawParams }) => {
|
|
436
442
|
const params = rawParams;
|
|
437
|
-
const { initialState, appConfig, appData, AIO_COMMERCE_API_BASE_URL } = params;
|
|
443
|
+
const { initialState, appConfig: rawAppConfig, appData, AIO_COMMERCE_API_BASE_URL } = params;
|
|
438
444
|
if (!initialState) return (0, _adobe_aio_commerce_lib_core_responses.badRequest)("initialState is required for execution");
|
|
439
|
-
if (!
|
|
445
|
+
if (!rawAppConfig) return (0, _adobe_aio_commerce_lib_core_responses.badRequest)("appConfig is required for execution");
|
|
446
|
+
const appConfig = require_validate.validateCommerceAppConfig(rawAppConfig);
|
|
440
447
|
const store = await createInstallationStore();
|
|
441
448
|
const hooks = createInstallationHooks(store, (msg) => logger.debug(msg));
|
|
442
449
|
const installationContext = buildInstallationContext(params, appConfig, logger);
|
|
@@ -472,8 +479,9 @@ router.post("/validation", {
|
|
|
472
479
|
body: InstallationRequestBodySchema,
|
|
473
480
|
handler: async (req, { logger, rawParams }) => {
|
|
474
481
|
logger.debug("Running pre-installation validation...");
|
|
475
|
-
const
|
|
476
|
-
if (!
|
|
482
|
+
const rawAppConfig = rawParams.appConfig;
|
|
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?");
|
|
484
|
+
const appConfig = require_validate.validateCommerceAppConfig(rawAppConfig);
|
|
477
485
|
const { appData, ...params } = buildWorkflowParams(req.body, rawParams);
|
|
478
486
|
const result = await require_management.runValidation({
|
|
479
487
|
validationContext: {
|
|
@@ -511,8 +519,9 @@ router.post("/uninstallation", {
|
|
|
511
519
|
handler: async (req, { logger, rawParams }) => {
|
|
512
520
|
const { appData, commerceBaseUrl } = req.body;
|
|
513
521
|
logger.debug(`Starting uninstallation for app "${appData.projectName}" (workspace: "${appData.workspaceName}", commerce: "${commerceBaseUrl}")`);
|
|
514
|
-
const
|
|
515
|
-
if (!
|
|
522
|
+
const rawAppConfig = rawParams.appConfig;
|
|
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?");
|
|
524
|
+
const appConfig = require_validate.validateCommerceAppConfig(rawAppConfig);
|
|
516
525
|
const store = await createUninstallationStore();
|
|
517
526
|
const existingState = await store.get(getStorageKey());
|
|
518
527
|
if (existingState && require_management.isInProgressState(existingState)) {
|
|
@@ -544,7 +553,8 @@ router.post("/uninstallation", {
|
|
|
544
553
|
}
|
|
545
554
|
});
|
|
546
555
|
/**
|
|
547
|
-
* POST /uninstallation/execution - Execute uninstallation
|
|
556
|
+
* POST /uninstallation/execution - Execute uninstallation
|
|
557
|
+
* @internal - Do not add to OpenAPI Spec.
|
|
548
558
|
*
|
|
549
559
|
* Flow:
|
|
550
560
|
* 1. Build InstallationContext from params
|
|
@@ -555,9 +565,10 @@ router.post("/uninstallation", {
|
|
|
555
565
|
*/
|
|
556
566
|
router.post("/uninstallation/execution", { handler: async (_req, { logger, rawParams }) => {
|
|
557
567
|
const params = rawParams;
|
|
558
|
-
const { initialState, appConfig, appData, AIO_COMMERCE_API_BASE_URL } = params;
|
|
568
|
+
const { initialState, appConfig: rawAppConfig, appData, AIO_COMMERCE_API_BASE_URL } = params;
|
|
559
569
|
if (!initialState) return (0, _adobe_aio_commerce_lib_core_responses.badRequest)("initialState is required for execution");
|
|
560
|
-
if (!
|
|
570
|
+
if (!rawAppConfig) return (0, _adobe_aio_commerce_lib_core_responses.badRequest)("appConfig is required for execution");
|
|
571
|
+
const appConfig = require_validate.validateCommerceAppConfig(rawAppConfig);
|
|
561
572
|
const store = await createUninstallationStore();
|
|
562
573
|
const hooks = createInstallationHooks(store, (msg) => logger.debug(msg));
|
|
563
574
|
const installationContext = buildInstallationContext(params, appConfig, logger);
|
|
@@ -592,9 +603,17 @@ router.delete("/uninstallation", { handler: async (_req, { logger }) => {
|
|
|
592
603
|
logger.debug("Uninstallation state cleared");
|
|
593
604
|
return (0, _adobe_aio_commerce_lib_core_responses.noContent)();
|
|
594
605
|
} });
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
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({
|
|
598
617
|
...params,
|
|
599
618
|
appConfig,
|
|
600
619
|
customScriptsLoader
|
|
@@ -12,22 +12,23 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import { n as CommerceAppConfigOutputModel } from "
|
|
16
|
-
import {
|
|
17
|
-
import * as _$_adobe_aio_commerce_lib_core_responses0 from "@adobe/aio-commerce-lib-core/responses";
|
|
15
|
+
import { n as CommerceAppConfig, r as CommerceAppConfigOutputModel } from "../../app-DrYHK-z1.cjs";
|
|
16
|
+
import { Y as InstallationContext } from "../../index-B5gJ-q4U.cjs";
|
|
18
17
|
import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
|
|
19
18
|
|
|
20
|
-
//#region source/actions/installation.d.ts
|
|
19
|
+
//#region source/actions/installation/router.d.ts
|
|
21
20
|
type CustomScriptsLoader = (config: CommerceAppConfigOutputModel, logger: InstallationContext["logger"]) => Record<string, unknown>;
|
|
22
21
|
/** Arguments for the runtime action factory. */
|
|
23
22
|
type RuntimeActionFactoryArgs = {
|
|
24
|
-
appConfig:
|
|
23
|
+
appConfig: CommerceAppConfig;
|
|
25
24
|
customScriptsLoader?: CustomScriptsLoader;
|
|
26
25
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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>;
|
|
32
33
|
//#endregion
|
|
33
34
|
export { installationRuntimeAction };
|
|
@@ -13,25 +13,34 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
16
|
-
const
|
|
17
|
-
const require_router = require('../router-CFErodHU.cjs');
|
|
16
|
+
const require_router = require('../../router-BOR7T6qR.cjs');
|
|
18
17
|
let _adobe_aio_commerce_lib_core_responses = require("@adobe/aio-commerce-lib-core/responses");
|
|
19
18
|
|
|
20
|
-
//#region source/actions/registration.ts
|
|
21
|
-
/**
|
|
19
|
+
//#region source/actions/registration/router.ts
|
|
20
|
+
/**
|
|
21
|
+
* Registration action router.
|
|
22
|
+
*
|
|
23
|
+
* Routes:
|
|
24
|
+
* - GET / Retrieve the Admin UI SDK registration.
|
|
25
|
+
*/
|
|
22
26
|
const router = new require_router.HttpActionRouter().use(require_router.logger({ name: () => "registration" }));
|
|
23
27
|
/** GET / - Return Admin UI SDK registration object */
|
|
24
28
|
router.get("/", { handler: async (_req, { logger, rawParams }) => {
|
|
25
29
|
logger.debug("Returning Admin UI SDK registration...");
|
|
26
30
|
return (0, _adobe_aio_commerce_lib_core_responses.ok)({ body: { registration: rawParams.registration } });
|
|
27
31
|
} });
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region source/actions/registration/index.ts
|
|
28
35
|
/**
|
|
29
36
|
* Factory to create the route handler for the `registration` action.
|
|
30
|
-
* @param args - The
|
|
37
|
+
* @param args - The arguments required to create the runtime action.
|
|
31
38
|
* @experimental
|
|
32
39
|
*/
|
|
33
|
-
const registrationRuntimeAction = (
|
|
34
|
-
|
|
40
|
+
const registrationRuntimeAction = (args) => async (params) => {
|
|
41
|
+
const handler = router.handler();
|
|
42
|
+
const { registration } = args;
|
|
43
|
+
return await handler({
|
|
35
44
|
...params,
|
|
36
45
|
registration
|
|
37
46
|
});
|
|
@@ -12,22 +12,21 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import { n as AdminUiSdkRegistration } from "
|
|
16
|
-
import * as _$_adobe_aio_commerce_lib_core_responses0 from "@adobe/aio-commerce-lib-core/responses";
|
|
15
|
+
import { n as AdminUiSdkRegistration } from "../../admin-ui-sdk-EU915zlR.cjs";
|
|
17
16
|
import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
|
|
18
17
|
|
|
19
|
-
//#region source/actions/registration.d.ts
|
|
20
|
-
/**
|
|
21
|
-
type
|
|
18
|
+
//#region source/actions/registration/router.d.ts
|
|
19
|
+
/** The arguments required to create the runtime action for the registration action. */
|
|
20
|
+
type RuntimeActionFactoryArgs = {
|
|
22
21
|
registration: AdminUiSdkRegistration;
|
|
23
22
|
};
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region source/actions/registration/index.d.ts
|
|
24
25
|
/**
|
|
25
26
|
* Factory to create the route handler for the `registration` action.
|
|
26
|
-
* @param args - The
|
|
27
|
+
* @param args - The arguments required to create the runtime action.
|
|
27
28
|
* @experimental
|
|
28
29
|
*/
|
|
29
|
-
declare const registrationRuntimeAction: (
|
|
30
|
-
registration
|
|
31
|
-
}: RegistrationActionArgs) => (params: RuntimeActionParams) => Promise<_$_adobe_aio_commerce_lib_core_responses0.ActionResponse>;
|
|
30
|
+
declare const registrationRuntimeAction: (args: RuntimeActionFactoryArgs) => (params: RuntimeActionParams) => Promise<import("@adobe/aio-commerce-lib-core/responses").ActionResponse>;
|
|
32
31
|
//#endregion
|
|
33
32
|
export { registrationRuntimeAction };
|
|
@@ -13,18 +13,46 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
16
|
-
const require_chunk = require('
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
let
|
|
16
|
+
const require_chunk = require('../../chunk-Cozy-1ZF.cjs');
|
|
17
|
+
const require_schemas = require('../../schemas-FngDuIeo.cjs');
|
|
18
|
+
const require_logging = require('../../logging-BVz3weoC.cjs');
|
|
19
|
+
const require_router = require('../../router-BOR7T6qR.cjs');
|
|
20
|
+
let _adobe_aio_commerce_lib_config = require("@adobe/aio-commerce-lib-config");
|
|
21
21
|
let valibot = require("valibot");
|
|
22
22
|
valibot = require_chunk.__toESM(valibot, 1);
|
|
23
|
-
let _adobe_aio_commerce_lib_config = require("@adobe/aio-commerce-lib-config");
|
|
24
23
|
let _adobe_aio_commerce_lib_api = require("@adobe/aio-commerce-lib-api");
|
|
24
|
+
let _adobe_aio_commerce_lib_core_responses = require("@adobe/aio-commerce-lib-core/responses");
|
|
25
|
+
|
|
26
|
+
//#region source/actions/scope-tree/schema.ts
|
|
27
|
+
const CustomScopeInputSchema = valibot.object({
|
|
28
|
+
id: valibot.optional(valibot.string()),
|
|
29
|
+
code: valibot.string(),
|
|
30
|
+
label: valibot.string(),
|
|
31
|
+
level: valibot.optional(valibot.string()),
|
|
32
|
+
is_editable: valibot.boolean(),
|
|
33
|
+
is_final: valibot.boolean(),
|
|
34
|
+
children: valibot.optional(valibot.array(valibot.lazy(() => CustomScopeInputSchema)))
|
|
35
|
+
});
|
|
36
|
+
/** Request body for PUT / */
|
|
37
|
+
const SetCustomScopeTreeBodySchema = valibot.object({ scopes: valibot.array(CustomScopeInputSchema) });
|
|
38
|
+
/** Request body for POST /commerce */
|
|
39
|
+
const SyncCommerceScopesBodySchema = valibot.object({
|
|
40
|
+
commerceBaseUrl: require_schemas.nonEmptyStringValueSchema("commerceBaseUrl"),
|
|
41
|
+
commerceEnv: valibot.optional(require_schemas.nonEmptyStringValueSchema("commerceEnv"))
|
|
42
|
+
});
|
|
25
43
|
|
|
26
|
-
//#
|
|
27
|
-
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region source/actions/scope-tree/router.ts
|
|
46
|
+
/**
|
|
47
|
+
* Scope Tree action router.
|
|
48
|
+
*
|
|
49
|
+
* Routes:
|
|
50
|
+
* - GET / Retrieve the scope tree.
|
|
51
|
+
* - PUT / Set custom scope tree.
|
|
52
|
+
* - POST /commerce Sync commerce scopes
|
|
53
|
+
* - DELETE /commerce Unsync commerce scopes
|
|
54
|
+
*/
|
|
55
|
+
const router = new require_router.HttpActionRouter().use(require_router.logger({ name: () => "scope-tree" }));
|
|
28
56
|
/** GET / - Get scope tree */
|
|
29
57
|
router.get("/", { handler: async (_req, ctx) => {
|
|
30
58
|
const { logger } = ctx;
|
|
@@ -36,15 +64,24 @@ router.get("/", { handler: async (_req, ctx) => {
|
|
|
36
64
|
});
|
|
37
65
|
return (0, _adobe_aio_commerce_lib_core_responses.ok)({ body: { scopes: result.scopeTree } });
|
|
38
66
|
} });
|
|
39
|
-
/**
|
|
67
|
+
/** PUT / - Set custom scope tree */
|
|
40
68
|
router.put("/", {
|
|
41
|
-
body:
|
|
69
|
+
body: SetCustomScopeTreeBodySchema,
|
|
42
70
|
handler: async (req, ctx) => {
|
|
43
71
|
const { logger } = ctx;
|
|
44
72
|
logger.debug(`Setting custom scope tree with ${req.body.scopes?.length || 0} scopes`);
|
|
45
73
|
const request = { scopes: req.body.scopes };
|
|
74
|
+
let result;
|
|
46
75
|
logger.debug(`Setting custom scope tree: ${require_logging.inspect(request)}`);
|
|
47
|
-
|
|
76
|
+
try {
|
|
77
|
+
result = await (0, _adobe_aio_commerce_lib_config.setCustomScopeTree)(request);
|
|
78
|
+
} catch (err) {
|
|
79
|
+
if (err instanceof Error && "isValidationError" in err) {
|
|
80
|
+
logger.debug(`Custom scope tree validation failed: ${err.message}`);
|
|
81
|
+
return (0, _adobe_aio_commerce_lib_core_responses.badRequest)({ body: { message: err.message } });
|
|
82
|
+
}
|
|
83
|
+
throw err;
|
|
84
|
+
}
|
|
48
85
|
logger.debug(`Successfully set custom scope tree: ${require_logging.inspect(result)}`);
|
|
49
86
|
return (0, _adobe_aio_commerce_lib_core_responses.ok)({
|
|
50
87
|
body: { result },
|
|
@@ -54,10 +91,7 @@ router.put("/", {
|
|
|
54
91
|
});
|
|
55
92
|
/** POST /commerce - Sync commerce scopes */
|
|
56
93
|
router.post("/commerce", {
|
|
57
|
-
body:
|
|
58
|
-
commerceBaseUrl: require_schemas.nonEmptyStringValueSchema("commerceBaseUrl"),
|
|
59
|
-
commerceEnv: valibot.optional(require_schemas.nonEmptyStringValueSchema("commerceEnv"))
|
|
60
|
-
}),
|
|
94
|
+
body: SyncCommerceScopesBodySchema,
|
|
61
95
|
handler: async (req, ctx) => {
|
|
62
96
|
const { logger } = ctx;
|
|
63
97
|
logger.debug("Syncing commerce scopes...");
|
|
@@ -105,6 +139,9 @@ router.delete("/commerce", { handler: async (_req, ctx) => {
|
|
|
105
139
|
logger.debug(message);
|
|
106
140
|
return (0, _adobe_aio_commerce_lib_core_responses.ok)(message);
|
|
107
141
|
} });
|
|
142
|
+
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region source/actions/scope-tree/index.ts
|
|
108
145
|
/** The handler method for the `scope-tree` action. */
|
|
109
146
|
const scopeTreeRuntimeAction = router.handler();
|
|
110
147
|
|
|
@@ -12,11 +12,8 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
import * as _$_adobe_aio_commerce_lib_core_params0 from "@adobe/aio-commerce-lib-core/params";
|
|
17
|
-
|
|
18
|
-
//#region source/actions/scope-tree.d.ts
|
|
15
|
+
//#region source/actions/scope-tree/index.d.ts
|
|
19
16
|
/** The handler method for the `scope-tree` action. */
|
|
20
|
-
declare const scopeTreeRuntimeAction: (args:
|
|
17
|
+
declare const scopeTreeRuntimeAction: (args: import("@adobe/aio-commerce-lib-core/params").RuntimeActionParams) => Promise<import("@adobe/aio-commerce-lib-core/responses").ActionResponse>;
|
|
21
18
|
//#endregion
|
|
22
19
|
export { scopeTreeRuntimeAction };
|
|
@@ -12,14 +12,9 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import { r as CommerceAppConfigOutputModel, t as AnyCommerceAppConfig } from "./app-DrYHK-z1.cjs";
|
|
16
16
|
import * as v from "valibot";
|
|
17
|
-
|
|
18
|
-
/** Config type when Admin UI SDK registration is configured. */
|
|
19
|
-
type AdminUiSdkConfig = CommerceAppConfigOutputModel & {
|
|
20
|
-
adminUiSdk: NonNullable<CommerceAppConfigOutputModel["adminUiSdk"]>;
|
|
21
|
-
};
|
|
22
|
-
//#endregion
|
|
17
|
+
|
|
23
18
|
//#region source/config/schema/admin-ui-sdk.d.ts
|
|
24
19
|
declare const GridColumnsSchema: v.ObjectSchema<{
|
|
25
20
|
readonly data: v.ObjectSchema<{
|
|
@@ -656,10 +651,14 @@ type BannerNotification = v.InferInput<typeof BannerNotificationSchema>;
|
|
|
656
651
|
* @experimental
|
|
657
652
|
*/
|
|
658
653
|
type MenuItem = v.InferInput<typeof MenuItemSchema>;
|
|
654
|
+
/** Config type when Admin UI SDK registration is configured. */
|
|
655
|
+
type AppConfigWithAdminUiSdk<T extends AnyCommerceAppConfig = CommerceAppConfigOutputModel> = T & {
|
|
656
|
+
adminUiSdk: NonNullable<T["adminUiSdk"]>;
|
|
657
|
+
};
|
|
659
658
|
/**
|
|
660
659
|
* Check if config has Admin UI SDK registration configuration.
|
|
661
660
|
* @experimental
|
|
662
661
|
*/
|
|
663
|
-
declare function hasAdminUiSdk(config:
|
|
662
|
+
declare function hasAdminUiSdk<T extends AnyCommerceAppConfig>(config: T): config is T & AppConfigWithAdminUiSdk<T>;
|
|
664
663
|
//#endregion
|
|
665
664
|
export { CustomerMassAction as a, OrderMassAction as c, hasAdminUiSdk as d, CustomFee as i, OrderViewButton as l, AdminUiSdkRegistration as n, GridColumns as o, BannerNotification as r, MenuItem as s, AdminUiSdkConfiguration as t, ProductMassAction as u };
|