@adobe/aio-commerce-lib-app 1.7.0 → 1.8.0-beta-20260714082406
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 +83 -0
- package/dist/cjs/actions/app-config/index.cjs +41 -38
- package/dist/cjs/actions/app-config/index.d.cts +1 -1
- package/dist/cjs/actions/association/index.cjs +85 -0
- package/dist/cjs/actions/{registration → association}/index.d.cts +9 -13
- package/dist/cjs/actions/config/index.cjs +21 -32
- package/dist/cjs/actions/installation/index.cjs +72 -51
- package/dist/cjs/actions/installation/index.d.cts +2 -2
- package/dist/cjs/actions/scope-tree/index.cjs +18 -17
- package/dist/{es/app-DrYHK-z1.d.mts → cjs/app-D3P-Z6uY.d.cts} +1085 -1035
- package/dist/cjs/association-repository-BAs3-VkW.cjs +69 -0
- package/dist/cjs/commands/index.cjs +512 -298
- package/dist/cjs/commands/templates/admin-ui/tsconfig.json +14 -0
- package/dist/cjs/commands/templates/admin-ui/web-src/index.css +5 -0
- package/dist/cjs/commands/templates/admin-ui/web-src/index.html +17 -0
- package/dist/cjs/commands/templates/admin-ui/web-src/src/app.jsx +13 -0
- package/dist/cjs/commands/templates/admin-ui/web-src/src/components/welcome.jsx +12 -0
- package/dist/cjs/commands/templates/admin-ui/web-src/src/pages/main-page.jsx +10 -0
- package/dist/cjs/commands/templates/{admin-ui-sdk/registration.js.template → admin-ui/web-src-template.d.ts} +11 -6
- package/dist/cjs/commands/templates/app-management/app-config.js.template +1 -14
- package/dist/cjs/commands/templates/app-management/association.js.template +6 -0
- package/dist/cjs/commands/templates/app-management/installation.js.template +1 -13
- package/dist/cjs/commands/templates/business-configuration/config.js.template +2 -15
- package/dist/cjs/commands/templates/business-configuration/scope-tree.js.template +0 -12
- package/dist/cjs/config/index.browser.cjs +18 -0
- package/dist/cjs/config/index.browser.d.cts +16 -0
- package/dist/cjs/config/{index.cjs → index.node.cjs} +9 -8
- package/dist/cjs/config/{index.d.cts → index.node.d.cts} +954 -386
- package/dist/cjs/define-DBxAlJfN.d.cts +34 -0
- package/dist/cjs/define-hlcQw7Cv.cjs +41 -0
- package/dist/cjs/environment-B7EnozSg.cjs +135 -0
- package/dist/cjs/{index-B5gJ-q4U.d.cts → index-CzReNwbF.d.cts} +17 -12
- package/dist/cjs/index.cjs +250 -0
- package/dist/cjs/index.d.cts +217 -0
- package/dist/cjs/{config-D-s0GSep.cjs → index.node-Dz4lV4qe.cjs} +119 -35
- package/dist/cjs/{logging-BVz3weoC.cjs → logging-udPuAJPt.cjs} +2 -2
- package/dist/cjs/management/index.cjs +1 -1
- package/dist/cjs/management/index.d.cts +1 -1
- package/dist/cjs/{management-Dehz9qSJ.cjs → management-B9ItB80R.cjs} +385 -582
- package/dist/cjs/{openapi-Cux6K4ZD.cjs → openapi-CwytYdWl.cjs} +476 -600
- package/dist/cjs/{router-BOR7T6qR.cjs → router-hA_Y9gZ1.cjs} +42 -44
- package/dist/cjs/{schemas-FngDuIeo.cjs → schemas-mLxMh_ko.cjs} +2 -2
- package/dist/cjs/utils-DSCmZ_iJ.cjs +408 -0
- package/dist/cjs/{validate-oAOpyFyb.cjs → validate-BfxhZ5Wv.cjs} +20 -20
- package/dist/cjs/{webhooks-tbZy9G3p.cjs → webhooks-B5tb9NeF.cjs} +159 -151
- package/dist/es/actions/app-config/index.d.mts +1 -1
- package/dist/es/actions/app-config/index.mjs +39 -36
- package/dist/es/actions/{registration → association}/index.d.mts +9 -13
- package/dist/es/actions/association/index.mjs +82 -0
- package/dist/es/actions/config/index.mjs +17 -28
- package/dist/es/actions/installation/index.d.mts +2 -2
- package/dist/es/actions/installation/index.mjs +69 -48
- package/dist/es/actions/scope-tree/index.mjs +14 -13
- package/dist/{cjs/app-DrYHK-z1.d.cts → es/app-D3P-Z6uY.d.mts} +1085 -1035
- package/dist/es/association-repository-BbQv9WCl.mjs +52 -0
- package/dist/es/commands/index.mjs +544 -328
- package/dist/es/commands/templates/admin-ui/tsconfig.json +14 -0
- package/dist/es/commands/templates/admin-ui/web-src/index.css +5 -0
- package/dist/es/commands/templates/admin-ui/web-src/index.html +17 -0
- package/dist/es/commands/templates/admin-ui/web-src/src/app.jsx +13 -0
- package/dist/es/commands/templates/admin-ui/web-src/src/components/welcome.jsx +12 -0
- package/dist/es/commands/templates/admin-ui/web-src/src/pages/main-page.jsx +10 -0
- package/dist/es/commands/templates/{admin-ui-sdk/registration.js.template → admin-ui/web-src-template.d.ts} +11 -6
- package/dist/es/commands/templates/app-management/app-config.js.template +1 -14
- package/dist/es/commands/templates/app-management/association.js.template +6 -0
- package/dist/es/commands/templates/app-management/installation.js.template +1 -13
- package/dist/es/commands/templates/business-configuration/config.js.template +2 -15
- package/dist/es/commands/templates/business-configuration/scope-tree.js.template +0 -12
- package/dist/es/config/index.browser.d.mts +16 -0
- package/dist/es/config/index.browser.mjs +17 -0
- package/dist/es/config/{index.d.mts → index.node.d.mts} +954 -386
- package/dist/es/config/{index.mjs → index.node.mjs} +5 -4
- package/dist/es/define-EoYRZbpe.d.mts +34 -0
- package/dist/es/define-Z_Glf1-_.mjs +35 -0
- package/dist/es/environment-C84BPRJZ.mjs +104 -0
- package/dist/es/{index-DLMbTtKS.d.mts → index-D52xglhZ.d.mts} +17 -12
- package/dist/es/index.d.mts +217 -0
- package/dist/es/index.mjs +242 -0
- package/dist/es/{config-3I4eLyyR.mjs → index.node-CDH5gwJE.mjs} +94 -30
- package/dist/es/management/index.d.mts +1 -1
- package/dist/es/management/index.mjs +1 -1
- package/dist/es/{management-BUX-w2Ji.mjs → management-B89ApQVY.mjs} +353 -550
- package/dist/es/{openapi-B6uP0SRn.mjs → openapi-CXonvevE.mjs} +476 -600
- package/dist/es/{router-D58JJHHA.mjs → router-B_h0cvjc.mjs} +40 -42
- package/dist/es/utils-_gj8L6eN.mjs +289 -0
- package/dist/es/{validate-Dfajrp99.mjs → validate-9cRZWGrA.mjs} +17 -17
- package/dist/es/{webhooks-B5oq9ULL.mjs → webhooks-BBPbY2mb.mjs} +150 -142
- package/package.json +40 -17
- package/dist/cjs/actions/registration/index.cjs +0 -50
- package/dist/cjs/admin-ui-sdk-EU915zlR.d.cts +0 -664
- package/dist/es/actions/registration/index.mjs +0 -49
- package/dist/es/admin-ui-sdk-BwnD0xjK.d.mts +0 -664
- /package/dist/cjs/{chunk-Cozy-1ZF.cjs → rolldown-runtime-Cozy-1ZF.cjs} +0 -0
|
@@ -13,18 +13,19 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
16
|
-
const
|
|
17
|
-
const require_schemas = require('../../schemas-
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const require_router = require('../../router-
|
|
16
|
+
const require_rolldown_runtime = require('../../rolldown-runtime-Cozy-1ZF.cjs');
|
|
17
|
+
const require_schemas = require('../../schemas-mLxMh_ko.cjs');
|
|
18
|
+
const require_validate = require('../../validate-BfxhZ5Wv.cjs');
|
|
19
|
+
const require_management = require('../../management-B9ItB80R.cjs');
|
|
20
|
+
const require_router = require('../../router-hA_Y9gZ1.cjs');
|
|
21
|
+
let _adobe_aio_lib_state = require("@adobe/aio-lib-state");
|
|
21
22
|
let valibot = require("valibot");
|
|
22
|
-
valibot =
|
|
23
|
+
valibot = require_rolldown_runtime.__toESM(valibot, 1);
|
|
24
|
+
let _adobe_aio_commerce_lib_core_commerce = require("@adobe/aio-commerce-lib-core/commerce");
|
|
23
25
|
let _adobe_aio_commerce_lib_core_responses = require("@adobe/aio-commerce-lib-core/responses");
|
|
24
26
|
let _adobe_aio_lib_files = require("@adobe/aio-lib-files");
|
|
25
|
-
let _adobe_aio_lib_state = require("@adobe/aio-lib-state");
|
|
26
27
|
let openwhisk = require("openwhisk");
|
|
27
|
-
openwhisk =
|
|
28
|
+
openwhisk = require_rolldown_runtime.__toESM(openwhisk, 1);
|
|
28
29
|
|
|
29
30
|
//#region ../../packages-private/common-utils/source/storage/files-store.ts
|
|
30
31
|
/** Default directory prefix. */
|
|
@@ -55,12 +56,15 @@ const DEFAULT_DIR_PREFIX = "store";
|
|
|
55
56
|
*/
|
|
56
57
|
async function createFilesStore(options = {}) {
|
|
57
58
|
const { dirPrefix = DEFAULT_DIR_PREFIX } = options;
|
|
58
|
-
|
|
59
|
+
const files = await (0, _adobe_aio_lib_files.init)();
|
|
60
|
+
return new FilesStore(files, dirPrefix);
|
|
59
61
|
}
|
|
60
62
|
/**
|
|
61
63
|
* Key-value store implementation using @adobe/aio-lib-files.
|
|
62
64
|
*/
|
|
63
65
|
var FilesStore = class {
|
|
66
|
+
files;
|
|
67
|
+
dirPrefix;
|
|
64
68
|
constructor(files, dirPrefix) {
|
|
65
69
|
this.files = files;
|
|
66
70
|
this.dirPrefix = dirPrefix;
|
|
@@ -125,12 +129,16 @@ const DEFAULT_KEY_PREFIX = "store";
|
|
|
125
129
|
*/
|
|
126
130
|
async function createStateStore(options = {}) {
|
|
127
131
|
const { keyPrefix = DEFAULT_KEY_PREFIX, ttlSeconds = DEFAULT_TTL_SECONDS } = options;
|
|
128
|
-
|
|
132
|
+
const state = await (0, _adobe_aio_lib_state.init)();
|
|
133
|
+
return new StateStore(state, keyPrefix, ttlSeconds);
|
|
129
134
|
}
|
|
130
135
|
/**
|
|
131
136
|
* Key-value store implementation using @adobe/aio-lib-state.
|
|
132
137
|
*/
|
|
133
138
|
var StateStore = class {
|
|
139
|
+
state;
|
|
140
|
+
keyPrefix;
|
|
141
|
+
ttlSeconds;
|
|
134
142
|
constructor(state, keyPrefix, ttlSeconds) {
|
|
135
143
|
this.state = state;
|
|
136
144
|
this.keyPrefix = keyPrefix;
|
|
@@ -220,6 +228,9 @@ async function createCombinedStore(options = {}) {
|
|
|
220
228
|
* Uses lib-state for cache and lib-files for persistence.
|
|
221
229
|
*/
|
|
222
230
|
var CombinedStore = class {
|
|
231
|
+
cache;
|
|
232
|
+
persistent;
|
|
233
|
+
shouldPersist;
|
|
223
234
|
constructor(cache, persistent, shouldPersist) {
|
|
224
235
|
this.cache = cache;
|
|
225
236
|
this.persistent = persistent;
|
|
@@ -240,7 +251,7 @@ var CombinedStore = class {
|
|
|
240
251
|
if (!this.shouldPersist || this.shouldPersist(data)) await this.persistent.put(key, data);
|
|
241
252
|
}
|
|
242
253
|
async delete(key) {
|
|
243
|
-
const [cacheDeleted, persistentDeleted] = await Promise.all([this.cache.delete
|
|
254
|
+
const [cacheDeleted, persistentDeleted] = await Promise.all([this.cache.delete(key), this.persistent.delete(key)]);
|
|
244
255
|
return cacheDeleted || persistentDeleted;
|
|
245
256
|
}
|
|
246
257
|
};
|
|
@@ -265,9 +276,9 @@ const AppDataSchema = valibot.object({
|
|
|
265
276
|
const InstallationRequestBodySchema = valibot.object({
|
|
266
277
|
appData: AppDataSchema,
|
|
267
278
|
commerceBaseUrl: valibot.string(),
|
|
268
|
-
commerceEnv:
|
|
269
|
-
|
|
270
|
-
|
|
279
|
+
commerceEnv: _adobe_aio_commerce_lib_core_commerce.CommerceEnvSchema,
|
|
280
|
+
ioEventsEnv: valibot.string(),
|
|
281
|
+
ioEventsUrl: valibot.string()
|
|
271
282
|
});
|
|
272
283
|
|
|
273
284
|
//#endregion
|
|
@@ -302,11 +313,11 @@ function getStorageKey() {
|
|
|
302
313
|
function buildWorkflowParams(body, rawParams) {
|
|
303
314
|
return {
|
|
304
315
|
...rawParams,
|
|
305
|
-
appData: body.appData,
|
|
306
|
-
AIO_EVENTS_API_BASE_URL: body.ioEventsUrl,
|
|
307
|
-
AIO_COMMERCE_AUTH_IMS_ENVIRONMENT: body.ioEventsEnv,
|
|
308
316
|
AIO_COMMERCE_API_BASE_URL: body.commerceBaseUrl,
|
|
309
|
-
AIO_COMMERCE_API_FLAVOR: body.commerceEnv
|
|
317
|
+
AIO_COMMERCE_API_FLAVOR: body.commerceEnv,
|
|
318
|
+
AIO_COMMERCE_AUTH_IMS_ENVIRONMENT: body.ioEventsEnv,
|
|
319
|
+
AIO_EVENTS_API_BASE_URL: body.ioEventsUrl,
|
|
320
|
+
appData: body.appData
|
|
310
321
|
};
|
|
311
322
|
}
|
|
312
323
|
/**
|
|
@@ -316,9 +327,9 @@ function buildWorkflowParams(body, rawParams) {
|
|
|
316
327
|
function buildInstallationContext(params, appConfig, logFn) {
|
|
317
328
|
return {
|
|
318
329
|
appData: params.appData,
|
|
319
|
-
params,
|
|
330
|
+
customScripts: params.customScriptsLoader?.(appConfig, logFn) ?? {},
|
|
320
331
|
logger: logFn,
|
|
321
|
-
|
|
332
|
+
params
|
|
322
333
|
};
|
|
323
334
|
}
|
|
324
335
|
/**
|
|
@@ -343,12 +354,12 @@ function createInstallationHooks(store, logFn) {
|
|
|
343
354
|
await store.put(getStorageKey(), data);
|
|
344
355
|
};
|
|
345
356
|
return {
|
|
346
|
-
onInstallationStart: (state) => logAndSave("Installation started", state),
|
|
347
357
|
onInstallationFailure: (state) => logAndSave("Installation failed", state),
|
|
358
|
+
onInstallationStart: (state) => logAndSave("Installation started", state),
|
|
348
359
|
onInstallationSuccess: (state) => logAndSave(state.status === "succeeded" && state.metadata?.isRetry ? "Installation succeeded on retry" : "Installation succeeded", state),
|
|
360
|
+
onStepFailure: (event, state) => logAndSave(`Step failed: ${event.stepName} — ${event.error.message ?? `(key: ${event.error.key})`}`, state),
|
|
349
361
|
onStepStart: (event, state) => logAndSave(`Step started: ${event.stepName}`, state),
|
|
350
|
-
onStepSuccess: (event, state) => logAndSave(`Step succeeded: ${event.stepName}`, state)
|
|
351
|
-
onStepFailure: (event, state) => logAndSave(`Step failed: ${event.stepName} — ${event.error.message ?? `(key: ${event.error.key})`}`, state)
|
|
362
|
+
onStepSuccess: (event, state) => logAndSave(`Step succeeded: ${event.stepName}`, state)
|
|
352
363
|
};
|
|
353
364
|
}
|
|
354
365
|
/**
|
|
@@ -412,21 +423,21 @@ router.post("/", {
|
|
|
412
423
|
const ow = (0, openwhisk.default)();
|
|
413
424
|
const mergedParams = buildWorkflowParams(req.body, rawParams);
|
|
414
425
|
const activation = await ow.actions.invoke({
|
|
415
|
-
name: DEFAULT_ACTION_NAME,
|
|
416
426
|
blocking: false,
|
|
417
|
-
|
|
427
|
+
name: DEFAULT_ACTION_NAME,
|
|
418
428
|
params: {
|
|
419
429
|
...mergedParams,
|
|
420
|
-
|
|
421
|
-
appConfig,
|
|
430
|
+
__ow_method: "post",
|
|
422
431
|
__ow_path: "/execution",
|
|
423
|
-
|
|
424
|
-
|
|
432
|
+
appConfig,
|
|
433
|
+
initialState
|
|
434
|
+
},
|
|
435
|
+
result: false
|
|
425
436
|
});
|
|
426
437
|
logger.debug(`Async execution started: ${activation.activationId}`);
|
|
427
438
|
return (0, _adobe_aio_commerce_lib_core_responses.accepted)({ body: {
|
|
428
|
-
message: "Installation started",
|
|
429
439
|
activationId: activation.activationId,
|
|
440
|
+
message: "Installation started",
|
|
430
441
|
...initialState
|
|
431
442
|
} });
|
|
432
443
|
}
|
|
@@ -449,16 +460,16 @@ router.post("/execution", { handler: async (_req, { logger, rawParams }) => {
|
|
|
449
460
|
const installationContext = buildInstallationContext(params, appConfig, logger);
|
|
450
461
|
logger.debug(`Executing installation ${initialState.id} for app "${appData.projectName}" (workspace: "${appData.workspaceName}", commerce: "${AIO_COMMERCE_API_BASE_URL}")`);
|
|
451
462
|
const result = await require_management.runInstallation({
|
|
452
|
-
installationContext,
|
|
453
463
|
config: appConfig,
|
|
464
|
+
hooks,
|
|
454
465
|
initialState,
|
|
455
|
-
|
|
466
|
+
installationContext
|
|
456
467
|
});
|
|
457
468
|
await store.put(getStorageKey(), result);
|
|
458
469
|
logger.debug(`Installation completed: ${result.status}`);
|
|
459
470
|
if (require_management.isFailedState(result)) return (0, _adobe_aio_commerce_lib_core_responses.internalServerError)({ body: {
|
|
460
|
-
message: "Installation failed",
|
|
461
471
|
error: result.error,
|
|
472
|
+
message: "Installation failed",
|
|
462
473
|
state: result
|
|
463
474
|
} });
|
|
464
475
|
return (0, _adobe_aio_commerce_lib_core_responses.ok)({ body: result });
|
|
@@ -484,12 +495,12 @@ router.post("/validation", {
|
|
|
484
495
|
const appConfig = require_validate.validateCommerceAppConfig(rawAppConfig);
|
|
485
496
|
const { appData, ...params } = buildWorkflowParams(req.body, rawParams);
|
|
486
497
|
const result = await require_management.runValidation({
|
|
498
|
+
config: appConfig,
|
|
487
499
|
validationContext: {
|
|
488
500
|
appData,
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
}
|
|
492
|
-
config: appConfig
|
|
501
|
+
logger,
|
|
502
|
+
params
|
|
503
|
+
}
|
|
493
504
|
});
|
|
494
505
|
logger.debug(`Validation complete — valid: ${result.valid}, errors: ${result.summary.errors}, warnings: ${result.summary.warnings}`);
|
|
495
506
|
return (0, _adobe_aio_commerce_lib_core_responses.ok)({ body: result });
|
|
@@ -519,35 +530,36 @@ router.post("/uninstallation", {
|
|
|
519
530
|
handler: async (req, { logger, rawParams }) => {
|
|
520
531
|
const { appData, commerceBaseUrl } = req.body;
|
|
521
532
|
logger.debug(`Starting uninstallation for app "${appData.projectName}" (workspace: "${appData.workspaceName}", commerce: "${commerceBaseUrl}")`);
|
|
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);
|
|
525
533
|
const store = await createUninstallationStore();
|
|
526
534
|
const existingState = await store.get(getStorageKey());
|
|
527
535
|
if (existingState && require_management.isInProgressState(existingState)) {
|
|
528
536
|
logger.debug(`Uninstallation already in progress: ${existingState.status}`);
|
|
529
537
|
return (0, _adobe_aio_commerce_lib_core_responses.conflict)("Uninstallation is already in progress. Wait for it to complete.");
|
|
530
538
|
}
|
|
531
|
-
const
|
|
539
|
+
const installAppConfig = (await getInstallationSnapshot())?.config;
|
|
540
|
+
const uninstallConfig = installAppConfig ?? rawParams.appConfig;
|
|
541
|
+
if (!uninstallConfig) return (0, _adobe_aio_commerce_lib_core_responses.internalServerError)("Cannot determine what to uninstall: no recorded installation snapshot and no app config was provided.");
|
|
542
|
+
logger.debug(installAppConfig ? "Sourcing uninstallation from recorded install snapshot" : "No recorded install config found; falling back to request config");
|
|
543
|
+
const initialState = require_management.createInitialUninstallationState({ config: require_validate.validateCommerceAppConfig(uninstallConfig) });
|
|
532
544
|
logger.debug(`Created initial uninstall state: ${initialState.id}`);
|
|
533
545
|
await store.put(getStorageKey(), initialState);
|
|
534
546
|
const workflowParams = buildWorkflowParams(req.body, rawParams);
|
|
535
547
|
const activation = await (0, openwhisk.default)().actions.invoke({
|
|
536
|
-
name: DEFAULT_ACTION_NAME,
|
|
537
548
|
blocking: false,
|
|
538
|
-
|
|
549
|
+
name: DEFAULT_ACTION_NAME,
|
|
539
550
|
params: {
|
|
540
551
|
...workflowParams,
|
|
541
|
-
|
|
542
|
-
appConfig,
|
|
552
|
+
__ow_method: "post",
|
|
543
553
|
__ow_path: "/uninstallation/execution",
|
|
544
|
-
|
|
545
|
-
|
|
554
|
+
appConfig: uninstallConfig,
|
|
555
|
+
initialState
|
|
556
|
+
},
|
|
557
|
+
result: false
|
|
546
558
|
});
|
|
547
559
|
logger.debug(`Async uninstallation started: ${activation.activationId}`);
|
|
548
560
|
return (0, _adobe_aio_commerce_lib_core_responses.accepted)({ body: {
|
|
549
|
-
message: "Uninstallation started",
|
|
550
561
|
activationId: activation.activationId,
|
|
562
|
+
message: "Uninstallation started",
|
|
551
563
|
...initialState
|
|
552
564
|
} });
|
|
553
565
|
}
|
|
@@ -574,10 +586,10 @@ router.post("/uninstallation/execution", { handler: async (_req, { logger, rawPa
|
|
|
574
586
|
const installationContext = buildInstallationContext(params, appConfig, logger);
|
|
575
587
|
logger.debug(`Executing uninstallation ${initialState.id} for app "${appData.projectName}" (workspace: "${appData.workspaceName}", commerce: "${AIO_COMMERCE_API_BASE_URL}")`);
|
|
576
588
|
const result = await require_management.runUninstallation({
|
|
577
|
-
installationContext,
|
|
578
589
|
config: appConfig,
|
|
590
|
+
hooks,
|
|
579
591
|
initialState,
|
|
580
|
-
|
|
592
|
+
installationContext
|
|
581
593
|
});
|
|
582
594
|
await store.put(getStorageKey(), result);
|
|
583
595
|
logger.debug(`Uninstallation completed: ${result.status}`);
|
|
@@ -586,8 +598,8 @@ router.post("/uninstallation/execution", { handler: async (_req, { logger, rawPa
|
|
|
586
598
|
logger.debug("Cleared installation state after successful uninstallation");
|
|
587
599
|
}
|
|
588
600
|
if (require_management.isFailedState(result)) return (0, _adobe_aio_commerce_lib_core_responses.internalServerError)({ body: {
|
|
589
|
-
message: "Uninstallation failed",
|
|
590
601
|
error: result.error,
|
|
602
|
+
message: "Uninstallation failed",
|
|
591
603
|
state: result
|
|
592
604
|
} });
|
|
593
605
|
return (0, _adobe_aio_commerce_lib_core_responses.ok)({ body: result });
|
|
@@ -603,6 +615,15 @@ router.delete("/uninstallation", { handler: async (_req, { logger }) => {
|
|
|
603
615
|
logger.debug("Uninstallation state cleared");
|
|
604
616
|
return (0, _adobe_aio_commerce_lib_core_responses.noContent)();
|
|
605
617
|
} });
|
|
618
|
+
/**
|
|
619
|
+
* Returns the completed installation snapshot that recorded its config, or null
|
|
620
|
+
* when none is authoritative (no install, an in-progress install, or a legacy
|
|
621
|
+
* record persisted before the config was recorded).
|
|
622
|
+
*/
|
|
623
|
+
async function getInstallationSnapshot() {
|
|
624
|
+
const installSnapshot = await (await createInstallationStore()).get(getStorageKey());
|
|
625
|
+
return installSnapshot && require_management.isCompletedState(installSnapshot) && installSnapshot.config ? installSnapshot : null;
|
|
626
|
+
}
|
|
606
627
|
|
|
607
628
|
//#endregion
|
|
608
629
|
//#region source/actions/installation/index.ts
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import { n as CommerceAppConfig, r as CommerceAppConfigOutputModel } from "../../app-
|
|
16
|
-
import { Y as InstallationContext } from "../../index-
|
|
15
|
+
import { n as CommerceAppConfig, r as CommerceAppConfigOutputModel } from "../../app-D3P-Z6uY.cjs";
|
|
16
|
+
import { Y as InstallationContext } from "../../index-CzReNwbF.cjs";
|
|
17
17
|
import { RuntimeActionParams } from "@adobe/aio-commerce-lib-core/params";
|
|
18
18
|
|
|
19
19
|
//#region source/actions/installation/router.d.ts
|
|
@@ -13,32 +13,33 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
16
|
-
const
|
|
17
|
-
const require_schemas = require('../../schemas-
|
|
18
|
-
const require_logging = require('../../logging-
|
|
19
|
-
const require_router = require('../../router-
|
|
16
|
+
const require_rolldown_runtime = require('../../rolldown-runtime-Cozy-1ZF.cjs');
|
|
17
|
+
const require_schemas = require('../../schemas-mLxMh_ko.cjs');
|
|
18
|
+
const require_logging = require('../../logging-udPuAJPt.cjs');
|
|
19
|
+
const require_router = require('../../router-hA_Y9gZ1.cjs');
|
|
20
|
+
let _adobe_aio_commerce_lib_api = require("@adobe/aio-commerce-lib-api");
|
|
20
21
|
let _adobe_aio_commerce_lib_config = require("@adobe/aio-commerce-lib-config");
|
|
21
22
|
let valibot = require("valibot");
|
|
22
|
-
valibot =
|
|
23
|
-
let
|
|
23
|
+
valibot = require_rolldown_runtime.__toESM(valibot, 1);
|
|
24
|
+
let _adobe_aio_commerce_lib_core_commerce = require("@adobe/aio-commerce-lib-core/commerce");
|
|
24
25
|
let _adobe_aio_commerce_lib_core_responses = require("@adobe/aio-commerce-lib-core/responses");
|
|
25
26
|
|
|
26
27
|
//#region source/actions/scope-tree/schema.ts
|
|
27
28
|
const CustomScopeInputSchema = valibot.object({
|
|
28
|
-
|
|
29
|
+
children: valibot.optional(valibot.array(valibot.lazy(() => CustomScopeInputSchema))),
|
|
29
30
|
code: valibot.string(),
|
|
30
|
-
|
|
31
|
-
level: valibot.optional(valibot.string()),
|
|
31
|
+
id: valibot.optional(valibot.string()),
|
|
32
32
|
is_editable: valibot.boolean(),
|
|
33
33
|
is_final: valibot.boolean(),
|
|
34
|
-
|
|
34
|
+
label: valibot.string(),
|
|
35
|
+
level: valibot.optional(valibot.string())
|
|
35
36
|
});
|
|
36
37
|
/** Request body for PUT / */
|
|
37
38
|
const SetCustomScopeTreeBodySchema = valibot.object({ scopes: valibot.array(CustomScopeInputSchema) });
|
|
38
39
|
/** Request body for POST /commerce */
|
|
39
40
|
const SyncCommerceScopesBodySchema = valibot.object({
|
|
40
41
|
commerceBaseUrl: require_schemas.nonEmptyStringValueSchema("commerceBaseUrl"),
|
|
41
|
-
commerceEnv: valibot.optional(
|
|
42
|
+
commerceEnv: valibot.optional(_adobe_aio_commerce_lib_core_commerce.CommerceEnvSchema)
|
|
42
43
|
});
|
|
43
44
|
|
|
44
45
|
//#endregion
|
|
@@ -59,8 +60,8 @@ router.get("/", { handler: async (_req, ctx) => {
|
|
|
59
60
|
const result = await (0, _adobe_aio_commerce_lib_config.getScopeTree)();
|
|
60
61
|
logger.debug(`Successfully retrieved scope tree (cached: ${result.isCachedData}): ${require_logging.inspect(result.scopeTree)}`);
|
|
61
62
|
if (result.isCachedData) return (0, _adobe_aio_commerce_lib_core_responses.nonAuthoritativeInformation)({
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
body: { scopes: result.scopeTree },
|
|
64
|
+
headers: { "x-cache": "hit" }
|
|
64
65
|
});
|
|
65
66
|
return (0, _adobe_aio_commerce_lib_core_responses.ok)({ body: { scopes: result.scopeTree } });
|
|
66
67
|
} });
|
|
@@ -104,18 +105,18 @@ router.post("/commerce", {
|
|
|
104
105
|
if (result.error) {
|
|
105
106
|
logger.error(`Error syncing commerce scopes: ${require_logging.inspect(result.error)}`);
|
|
106
107
|
return (0, _adobe_aio_commerce_lib_core_responses.internalServerError)({ body: {
|
|
107
|
-
|
|
108
|
-
|
|
108
|
+
error: result.error,
|
|
109
|
+
message: "An internal server error occurred"
|
|
109
110
|
} });
|
|
110
111
|
}
|
|
111
112
|
if (!result.synced) {
|
|
112
113
|
logger.debug(`Commerce scopes not synced (cached): ${require_logging.inspect(result.scopeTree)}`);
|
|
113
114
|
return (0, _adobe_aio_commerce_lib_core_responses.nonAuthoritativeInformation)({
|
|
114
|
-
headers: { "x-cache": "hit" },
|
|
115
115
|
body: {
|
|
116
116
|
scopes: result.scopeTree,
|
|
117
117
|
synced: false
|
|
118
|
-
}
|
|
118
|
+
},
|
|
119
|
+
headers: { "x-cache": "hit" }
|
|
119
120
|
});
|
|
120
121
|
}
|
|
121
122
|
logger.debug(`Successfully synced commerce scopes: ${require_logging.inspect(result.scopeTree)}`);
|