@adobe/aio-commerce-lib-app 0.3.2 → 1.0.1
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 +44 -0
- package/README.md +1 -4
- package/bin/cli.mjs +24 -0
- package/dist/cjs/actions/app-config.cjs +27 -0
- package/dist/cjs/actions/app-config.d.cts +15 -0
- package/dist/cjs/actions/config.cjs +79 -0
- package/dist/cjs/actions/config.d.cts +15 -0
- package/dist/cjs/actions/installation.cjs +424 -0
- package/dist/cjs/actions/{index.d.cts → installation.d.cts} +4 -3
- package/dist/cjs/actions/scope-tree.cjs +97 -0
- package/dist/cjs/actions/scope-tree.d.cts +8 -0
- package/dist/{es/app-Cx1-6dn0.d.mts → cjs/app-DWX5-Hsf.d.cts} +14 -14
- package/dist/cjs/commands/generate/actions/templates/app-management/app-config.js.template +22 -0
- package/dist/cjs/commands/generate/actions/templates/app-management/installation.js.template +1 -1
- package/dist/cjs/commands/generate/actions/templates/business-configuration/config.js.template +22 -0
- package/dist/cjs/commands/generate/actions/templates/business-configuration/scope-tree.js.template +18 -0
- package/dist/cjs/commands/index.cjs +91 -106
- package/dist/cjs/config/index.cjs +21 -19
- package/dist/cjs/config/index.d.cts +52 -352
- package/dist/cjs/error-DJ2UAPH2.cjs +24 -0
- package/dist/cjs/installation-CLbceU9F.cjs +243 -0
- package/dist/cjs/{logging-DYwr5WQk.cjs → logging-IDRQG0as.cjs} +2 -2
- package/dist/cjs/management/index.cjs +9 -8
- package/dist/cjs/management/index.d.cts +2 -2
- package/dist/cjs/parser-BPpg_9QB.cjs +267 -0
- package/dist/cjs/router-DCw7oEQ9.cjs +417 -0
- package/dist/{es/index-Bxr3zvCT.d.mts → cjs/runner-DemKouFJ.d.cts} +49 -95
- package/dist/cjs/{management-Dm5h0E6l.cjs → runner-NHMvoMO2.cjs} +24 -30
- package/dist/cjs/schemas-CZ6c8Id9.cjs +98 -0
- package/dist/cjs/validate-Btzn9ilZ.cjs +235 -0
- package/dist/es/actions/app-config.d.mts +15 -0
- package/dist/es/actions/app-config.mjs +25 -0
- package/dist/es/actions/config.d.mts +15 -0
- package/dist/es/actions/config.mjs +77 -0
- package/dist/es/actions/{index.d.mts → installation.d.mts} +4 -3
- package/dist/es/actions/{index.mjs → installation.mjs} +27 -427
- package/dist/es/actions/scope-tree.d.mts +8 -0
- package/dist/es/actions/scope-tree.mjs +95 -0
- package/dist/{cjs/app-Dx0ca6oL.d.cts → es/app-BAiyvNo2.d.mts} +14 -14
- package/dist/es/commands/generate/actions/templates/app-management/app-config.js.template +22 -0
- package/dist/es/commands/generate/actions/templates/app-management/installation.js.template +1 -1
- package/dist/es/commands/generate/actions/templates/business-configuration/config.js.template +22 -0
- package/dist/es/commands/generate/actions/templates/business-configuration/scope-tree.js.template +18 -0
- package/dist/es/commands/index.mjs +68 -84
- package/dist/es/config/index.d.mts +52 -352
- package/dist/es/config/index.mjs +3 -2
- package/dist/es/error-CMV3IjBz.mjs +18 -0
- package/dist/es/{error-P7JgUTds.mjs → installation-BTL9X7iv.mjs} +78 -128
- package/dist/es/management/index.d.mts +2 -3
- package/dist/es/management/index.mjs +1 -1
- package/dist/es/parser-CQZTVG6i.mjs +201 -0
- package/dist/es/router-CJ4VWoCt.mjs +404 -0
- package/dist/{cjs/index-C5SutkJQ.d.cts → es/runner-BD-lItnK.d.mts} +49 -95
- package/dist/es/{management-Y7pwEbNI.mjs → runner-vwAhjD5r.mjs} +17 -24
- package/dist/es/schemas-B8yIv0_b.mjs +41 -0
- package/dist/es/validate-DKnju9-R.mjs +187 -0
- package/package.json +38 -24
- package/dist/cjs/actions/index.cjs +0 -824
- package/dist/cjs/commands/generate/actions/templates/app-management/get-app-config.js.template +0 -62
- package/dist/cjs/commands/generate/actions/templates/business-configuration/get-config-schema.js.template +0 -63
- package/dist/cjs/commands/generate/actions/templates/business-configuration/get-configuration.js.template +0 -104
- package/dist/cjs/commands/generate/actions/templates/business-configuration/get-scope-tree.js.template +0 -69
- package/dist/cjs/commands/generate/actions/templates/business-configuration/set-configuration.js.template +0 -125
- package/dist/cjs/commands/generate/actions/templates/business-configuration/set-custom-scope-tree.js.template +0 -83
- package/dist/cjs/commands/generate/actions/templates/business-configuration/sync-commerce-scopes.js.template +0 -113
- package/dist/cjs/commands/generate/actions/templates/business-configuration/unsync-commerce-scopes.js.template +0 -56
- package/dist/cjs/config-JQ_n-5Nk.cjs +0 -565
- package/dist/cjs/error-Byj1DVHZ.cjs +0 -344
- package/dist/es/commands/generate/actions/templates/app-management/get-app-config.js.template +0 -62
- package/dist/es/commands/generate/actions/templates/business-configuration/get-config-schema.js.template +0 -63
- package/dist/es/commands/generate/actions/templates/business-configuration/get-configuration.js.template +0 -104
- package/dist/es/commands/generate/actions/templates/business-configuration/get-scope-tree.js.template +0 -69
- package/dist/es/commands/generate/actions/templates/business-configuration/set-configuration.js.template +0 -125
- package/dist/es/commands/generate/actions/templates/business-configuration/set-custom-scope-tree.js.template +0 -83
- package/dist/es/commands/generate/actions/templates/business-configuration/sync-commerce-scopes.js.template +0 -113
- package/dist/es/commands/generate/actions/templates/business-configuration/unsync-commerce-scopes.js.template +0 -56
- package/dist/es/config-BSGerqCG.mjs +0 -457
- /package/dist/es/{logging-VgerMhp6.mjs → logging-CzmXDzxI.mjs} +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { t as
|
|
1
|
+
import { a as hasCommerceEvents, o as hasEventing, r as hasCustomInstallationSteps, s as hasExternalEvents } from "./installation-BTL9X7iv.mjs";
|
|
2
|
+
import { t as stringifyError } from "./error-CMV3IjBz.mjs";
|
|
3
|
+
import { t as inspect } from "./logging-CzmXDzxI.mjs";
|
|
3
4
|
import camelcase from "camelcase";
|
|
4
5
|
import { resolveAuthParams } from "@adobe/aio-commerce-lib-auth";
|
|
5
6
|
import { resolveCommerceHttpClientParams, resolveIoEventsHttpClientParams } from "@adobe/aio-commerce-lib-api";
|
|
@@ -558,9 +559,9 @@ async function getIoEventsExistingData(context) {
|
|
|
558
559
|
});
|
|
559
560
|
const providersWithMetadata = existingProviders.map((providerHal) => {
|
|
560
561
|
const { _embedded, _links, ...providerData } = providerHal;
|
|
561
|
-
const actualMetadata = (_embedded?.eventmetadata ?? []).map(({ _embedded
|
|
562
|
+
const actualMetadata = (_embedded?.eventmetadata ?? []).map(({ _embedded, _links, ...meta }) => ({
|
|
562
563
|
...meta,
|
|
563
|
-
sample: _embedded
|
|
564
|
+
sample: _embedded?.sample_event ?? null
|
|
564
565
|
}));
|
|
565
566
|
return {
|
|
566
567
|
...providerData,
|
|
@@ -749,13 +750,13 @@ async function configureCommerceEventing(params, existingData) {
|
|
|
749
750
|
enabled: true
|
|
750
751
|
};
|
|
751
752
|
if (existingData.isDefaultWorkspaceConfigurationEmpty) {
|
|
752
|
-
if (!config.
|
|
753
|
+
if (!config.workspace_configuration) {
|
|
753
754
|
const message = "Workspace configuration is required to enable Commerce Eventing when there is not an existing one.";
|
|
754
755
|
logger.error(message);
|
|
755
756
|
throw new Error(message);
|
|
756
757
|
}
|
|
757
758
|
logger.info("Default provider workspace configuration already present, it will not be overriden");
|
|
758
|
-
const {
|
|
759
|
+
const { workspace_configuration, ...rest } = updateParams;
|
|
759
760
|
updateParams = rest;
|
|
760
761
|
}
|
|
761
762
|
logger.info("Updating Commerce Eventing configuration with provided workspace configuration.");
|
|
@@ -779,11 +780,8 @@ async function createCommerceProvider(params) {
|
|
|
779
780
|
const { commerceEventsClient, logger } = context;
|
|
780
781
|
logger.info(`Creating Commerce provider "${provider.label}" with instance ID "${provider.instance_id}"`);
|
|
781
782
|
return commerceEventsClient.createEventProvider({
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
label: provider.label,
|
|
785
|
-
description: provider.description,
|
|
786
|
-
associatedWorkspaceConfiguration: provider.workspaceConfiguration
|
|
783
|
+
...provider,
|
|
784
|
+
provider_id: provider.id
|
|
787
785
|
}).then((res) => {
|
|
788
786
|
logger.info(`Commerce provider "${provider.label}" created with ID '${res.provider_id}'`);
|
|
789
787
|
return res;
|
|
@@ -820,10 +818,10 @@ async function createCommerceEventSubscription(params) {
|
|
|
820
818
|
name: eventName,
|
|
821
819
|
parent: event.config.name,
|
|
822
820
|
fields: event.config.fields,
|
|
823
|
-
|
|
821
|
+
provider_id: provider.id,
|
|
824
822
|
destination: event.config.destination,
|
|
825
|
-
|
|
826
|
-
|
|
823
|
+
hipaa_audit_required: event.config.hipaa_audit_required,
|
|
824
|
+
priority: event.config.priority,
|
|
827
825
|
force: event.config.force
|
|
828
826
|
};
|
|
829
827
|
logger.debug(`Event subscription specification for event "${event.config.name}": ${inspect(eventSpec)}`);
|
|
@@ -846,12 +844,7 @@ async function createOrGetCommerceEventSubscription(params, existingData) {
|
|
|
846
844
|
const existing = findExistingSubscription(existingData, getNamespacedEvent(metadata, event.config.name));
|
|
847
845
|
if (existing) {
|
|
848
846
|
logger.info(`Subscription for event "${event.config.name}" already exists, skipping creation.`);
|
|
849
|
-
return
|
|
850
|
-
name: existing.name,
|
|
851
|
-
parent: existing.parent,
|
|
852
|
-
fields: existing.fields,
|
|
853
|
-
providerId: existing.provider_id
|
|
854
|
-
};
|
|
847
|
+
return existing;
|
|
855
848
|
}
|
|
856
849
|
return createCommerceEventSubscription(params);
|
|
857
850
|
}
|
|
@@ -920,7 +913,7 @@ async function onboardCommerceEventing(params, existingData) {
|
|
|
920
913
|
const subscriptions = [];
|
|
921
914
|
await configureCommerceEventing({
|
|
922
915
|
context,
|
|
923
|
-
config: { workspaceConfiguration }
|
|
916
|
+
config: { workspace_configuration: workspaceConfiguration }
|
|
924
917
|
}, existingData);
|
|
925
918
|
const { workspace_configuration: _, ...commerceProviderData } = await createOrGetCommerceProvider({
|
|
926
919
|
context,
|
|
@@ -929,7 +922,7 @@ async function onboardCommerceEventing(params, existingData) {
|
|
|
929
922
|
instance_id: instanceId,
|
|
930
923
|
label: provider.label,
|
|
931
924
|
description: provider.description,
|
|
932
|
-
workspaceConfiguration
|
|
925
|
+
workspace_configuration: workspaceConfiguration
|
|
933
926
|
}
|
|
934
927
|
}, existingData.providers);
|
|
935
928
|
for (const event of events) subscriptions.push(await createOrGetCommerceEventSubscription({
|
|
@@ -984,9 +977,9 @@ const commerceEventsStep = defineLeafStep({
|
|
|
984
977
|
data: {
|
|
985
978
|
ioEvents: providerData,
|
|
986
979
|
commerce: commerceProvider,
|
|
987
|
-
events: eventsData.map(({ config
|
|
980
|
+
events: eventsData.map(({ config, data }, index) => {
|
|
988
981
|
return {
|
|
989
|
-
config
|
|
982
|
+
config,
|
|
990
983
|
data: {
|
|
991
984
|
...data,
|
|
992
985
|
subscription: subscriptions[index]
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
|
|
3
|
+
//#region ../../packages-private/common-utils/source/valibot/schemas.ts
|
|
4
|
+
const ALPHANUMERIC_OR_HYPHEN_REGEX = {
|
|
5
|
+
any: /^[a-zA-Z0-9-]+$/,
|
|
6
|
+
lowercase: /^[a-z0-9-]+$/,
|
|
7
|
+
uppercase: /^[A-Z0-9-]+$/
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* A schema for a string value.
|
|
11
|
+
* @param name The name of the field this schema refers to.
|
|
12
|
+
*/
|
|
13
|
+
function stringValueSchema(name) {
|
|
14
|
+
return v.string(`Expected a string value for '${name}'`);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A schema for a non-empty string value.
|
|
18
|
+
* @param name The name of the field this schema refers to.
|
|
19
|
+
*/
|
|
20
|
+
function nonEmptyStringValueSchema(name) {
|
|
21
|
+
return v.pipe(stringValueSchema(name), v.nonEmpty(`The value of "${name}" must not be empty`));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A schema for a boolean value.
|
|
25
|
+
* @param name The name of the field this schema refers to.
|
|
26
|
+
*/
|
|
27
|
+
function booleanValueSchema(name) {
|
|
28
|
+
return v.boolean(`Expected a boolean value for '${name}'`);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A schema for a string that only contains alphanumeric characters and hyphens.
|
|
32
|
+
* @param name The name of the field this schema refers to.
|
|
33
|
+
* @param casing The allowed casing for the string (default: "any").
|
|
34
|
+
*/
|
|
35
|
+
function alphaNumericOrHyphenSchema(name, casing = "any") {
|
|
36
|
+
const casingLabel = casing === "any" ? "" : ` (${casing} only)`;
|
|
37
|
+
return v.pipe(stringValueSchema(name), v.regex(ALPHANUMERIC_OR_HYPHEN_REGEX[casing], `Only alphanumeric characters and hyphens are allowed in string value of "${name}"${casingLabel}`));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
export { stringValueSchema as i, booleanValueSchema as n, nonEmptyStringValueSchema as r, alphaNumericOrHyphenSchema as t };
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { t as alphaNumericOrHyphenSchema } from "./schemas-B8yIv0_b.mjs";
|
|
2
|
+
import { a as hasCommerceEvents, i as EventingSchema, n as hasCustomInstallation, r as hasCustomInstallationSteps, s as hasExternalEvents, t as InstallationSchema } from "./installation-BTL9X7iv.mjs";
|
|
3
|
+
import { CommerceSdkValidationError } from "@adobe/aio-commerce-lib-core/error";
|
|
4
|
+
import * as v from "valibot";
|
|
5
|
+
import { SchemaBusinessConfig } from "@adobe/aio-commerce-lib-config";
|
|
6
|
+
|
|
7
|
+
//#region source/config/schema/business-configuration.ts
|
|
8
|
+
/**
|
|
9
|
+
* Check if config has business config.
|
|
10
|
+
* @param config - The configuration to check.
|
|
11
|
+
*/
|
|
12
|
+
function hasBusinessConfig(config) {
|
|
13
|
+
return config.businessConfig !== void 0;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Check if config has business config schema.
|
|
17
|
+
* @param config - The configuration to check.
|
|
18
|
+
*/
|
|
19
|
+
function hasBusinessConfigSchema(config) {
|
|
20
|
+
return config.businessConfig?.schema !== void 0 && config.businessConfig.schema.length > 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region source/config/schema/metadata.ts
|
|
25
|
+
const MAX_DESCRIPTION_LENGTH = 255;
|
|
26
|
+
const MAX_DISPLAY_NAME_LENGTH = 50;
|
|
27
|
+
const NUMERIC_IDENTIFIER = "(0|[1-9]\\d*)";
|
|
28
|
+
const SEMVER_REGEX = new RegExp(`^${NUMERIC_IDENTIFIER}\\.${NUMERIC_IDENTIFIER}\\.${NUMERIC_IDENTIFIER}$`);
|
|
29
|
+
function nonEmptyString(fieldName) {
|
|
30
|
+
return v.pipe(v.string(`Expected a string for the ${fieldName}`), v.nonEmpty(`The ${fieldName} must not be empty`));
|
|
31
|
+
}
|
|
32
|
+
/** The schema for the metadata of the application. */
|
|
33
|
+
const MetadataSchema = v.object({
|
|
34
|
+
id: alphaNumericOrHyphenSchema("application id (metadata.id)"),
|
|
35
|
+
displayName: v.pipe(nonEmptyString("application display name"), v.maxLength(MAX_DISPLAY_NAME_LENGTH, `The application display name must not be longer than ${MAX_DISPLAY_NAME_LENGTH} characters`)),
|
|
36
|
+
description: v.pipe(nonEmptyString("metadata description"), v.maxLength(MAX_DESCRIPTION_LENGTH, `The metadata description must not be longer than ${MAX_DESCRIPTION_LENGTH} characters`)),
|
|
37
|
+
version: v.pipe(nonEmptyString("version"), v.regex(SEMVER_REGEX, "The version must follow semantic versioning (semver) format"))
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* Check if config has metadata.
|
|
41
|
+
* @param config - The configuration to check.
|
|
42
|
+
*/
|
|
43
|
+
function hasMetadata(config) {
|
|
44
|
+
return config.metadata !== void 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region source/config/schema/app.ts
|
|
49
|
+
/** biome-ignore-all lint/performance/noBarrelFile: We want to have all the schema exports in one file. */
|
|
50
|
+
/** The schema used to validate the commerce app config file. */
|
|
51
|
+
const CommerceAppConfigSchema = v.looseObject({
|
|
52
|
+
metadata: MetadataSchema,
|
|
53
|
+
businessConfig: v.optional(SchemaBusinessConfig),
|
|
54
|
+
eventing: v.optional(EventingSchema),
|
|
55
|
+
installation: v.optional(InstallationSchema)
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region source/config/schema/domains.ts
|
|
60
|
+
/** The individual validatable domains of the app config. */
|
|
61
|
+
const CommerceAppConfigSchemas = {
|
|
62
|
+
metadata: MetadataSchema,
|
|
63
|
+
businessConfig: SchemaBusinessConfig,
|
|
64
|
+
eventing: EventingSchema,
|
|
65
|
+
installation: InstallationSchema,
|
|
66
|
+
"businessConfig.schema": v.unwrap(SchemaBusinessConfig.entries.schema),
|
|
67
|
+
"eventing.commerce": v.unwrap(EventingSchema.entries.commerce),
|
|
68
|
+
"eventing.external": v.unwrap(EventingSchema.entries.external),
|
|
69
|
+
"installation.customInstallationSteps": v.unwrap(InstallationSchema.entries.customInstallationSteps)
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Get the config domains that are present in the config.
|
|
73
|
+
* @param config - The configuration to check.
|
|
74
|
+
*/
|
|
75
|
+
function getConfigDomains(config) {
|
|
76
|
+
const withCommerceEvents = hasCommerceEvents(config);
|
|
77
|
+
const withExternalEvents = hasExternalEvents(config);
|
|
78
|
+
const domains = {
|
|
79
|
+
metadata: hasMetadata(config),
|
|
80
|
+
businessConfig: hasBusinessConfig(config),
|
|
81
|
+
eventing: withCommerceEvents || withExternalEvents,
|
|
82
|
+
installation: hasCustomInstallation(config),
|
|
83
|
+
"businessConfig.schema": hasBusinessConfigSchema(config),
|
|
84
|
+
"eventing.commerce": withCommerceEvents,
|
|
85
|
+
"eventing.external": withExternalEvents,
|
|
86
|
+
"installation.customInstallationSteps": hasCustomInstallationSteps(config)
|
|
87
|
+
};
|
|
88
|
+
const domainsList = Object.entries(domains).filter(([_, value]) => value).map(([key]) => key);
|
|
89
|
+
return new Set(domainsList);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Check if the config has a specific domain.
|
|
93
|
+
* @param config - The configuration to check.
|
|
94
|
+
* @param domain - The domain to check.
|
|
95
|
+
*/
|
|
96
|
+
function hasConfigDomain(config, domain) {
|
|
97
|
+
return getConfigDomains(config).has(domain);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region source/config/lib/validate.ts
|
|
102
|
+
const commerceAppConfigDomainsSchema = v.picklist(Object.keys(CommerceAppConfigSchemas));
|
|
103
|
+
/**
|
|
104
|
+
* Validates a complete commerce app configuration object against the schema.
|
|
105
|
+
*
|
|
106
|
+
* @param config - The configuration object to validate.
|
|
107
|
+
* @returns The validated and typed configuration output model.
|
|
108
|
+
*
|
|
109
|
+
* @throws {CommerceSdkValidationError} If the configuration is invalid, with
|
|
110
|
+
* detailed validation issues included.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* const config = {
|
|
115
|
+
* businessConfiguration: {
|
|
116
|
+
* // ... configuration data
|
|
117
|
+
* }
|
|
118
|
+
* };
|
|
119
|
+
*
|
|
120
|
+
* try {
|
|
121
|
+
* const validatedConfig = validateCommerceAppConfig(config);
|
|
122
|
+
* // Use validatedConfig safely
|
|
123
|
+
* } catch (error) {
|
|
124
|
+
* if (error instanceof CommerceSdkValidationError) {
|
|
125
|
+
* console.error('Validation failed:', error.display());
|
|
126
|
+
* }
|
|
127
|
+
* }
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
function validateCommerceAppConfig(config) {
|
|
131
|
+
const validatedConfig = v.safeParse(CommerceAppConfigSchema, config);
|
|
132
|
+
if (!validatedConfig.success) throw new CommerceSdkValidationError("Invalid commerce app config", { issues: validatedConfig.issues });
|
|
133
|
+
return validatedConfig.output;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Validates a specific domain configuration within the commerce app config.
|
|
137
|
+
*
|
|
138
|
+
* This function validates only a specific domain's configuration rather than
|
|
139
|
+
* the entire commerce app configuration object. It first validates that the
|
|
140
|
+
* domain name is valid, then validates the configuration data against the
|
|
141
|
+
* schema for that specific domain.
|
|
142
|
+
*
|
|
143
|
+
* @template T - The type of the domain, constrained to valid domain names.
|
|
144
|
+
*
|
|
145
|
+
* @param config - The domain configuration object to validate.
|
|
146
|
+
* @param domain - The name of the domain to validate (e.g., 'businessConfiguration').
|
|
147
|
+
* @returns The validated and typed configuration for the specified domain.
|
|
148
|
+
*
|
|
149
|
+
* @throws {CommerceSdkValidationError} If the domain name is invalid or if the
|
|
150
|
+
* configuration doesn't match the domain's schema.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```typescript
|
|
154
|
+
* const businessConfig = {
|
|
155
|
+
* fields: [
|
|
156
|
+
* {
|
|
157
|
+
* name: 'category',
|
|
158
|
+
* type: 'dropdown',
|
|
159
|
+
* // ... field configuration
|
|
160
|
+
* }
|
|
161
|
+
* ]
|
|
162
|
+
* };
|
|
163
|
+
*
|
|
164
|
+
* try {
|
|
165
|
+
* const validatedConfig = validateCommerceAppConfigDomain(
|
|
166
|
+
* businessConfig,
|
|
167
|
+
* 'businessConfig'
|
|
168
|
+
* );
|
|
169
|
+
* // Use validatedConfig safely
|
|
170
|
+
* } catch (error) {
|
|
171
|
+
* if (error instanceof CommerceSdkValidationError) {
|
|
172
|
+
* console.error('Domain validation failed:', error.issues);
|
|
173
|
+
* }
|
|
174
|
+
* }
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
function validateCommerceAppConfigDomain(config, domain) {
|
|
178
|
+
const domainSchema = v.safeParse(commerceAppConfigDomainsSchema, domain);
|
|
179
|
+
if (!domainSchema.success) throw new CommerceSdkValidationError("Invalid commerce app config domain", { issues: domainSchema.issues });
|
|
180
|
+
const domainConfigSchema = CommerceAppConfigSchemas[domain];
|
|
181
|
+
const validatedConfig = v.safeParse(domainConfigSchema, config);
|
|
182
|
+
if (!validatedConfig.success) throw new CommerceSdkValidationError(`Invalid commerce app config: ${domain}`, { issues: validatedConfig.issues });
|
|
183
|
+
return validatedConfig.output;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
//#endregion
|
|
187
|
+
export { hasConfigDomain as a, hasBusinessConfigSchema as c, getConfigDomains as i, validateCommerceAppConfigDomain as n, hasMetadata as o, CommerceAppConfigSchemas as r, hasBusinessConfig as s, validateCommerceAppConfig as t };
|
package/package.json
CHANGED
|
@@ -2,13 +2,24 @@
|
|
|
2
2
|
"name": "@adobe/aio-commerce-lib-app",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"author": "Adobe Inc.",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "1.0.1",
|
|
6
6
|
"private": false,
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=20 <=24"
|
|
9
9
|
},
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"description": "App configuration management library for Adobe Commerce applications",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"aio",
|
|
14
|
+
"adobe-io",
|
|
15
|
+
"commerce",
|
|
16
|
+
"adobe-commerce",
|
|
17
|
+
"adobe-commerce-sdk",
|
|
18
|
+
"aio-commerce-sdk",
|
|
19
|
+
"aio-commerce-lib-app",
|
|
20
|
+
"configuration",
|
|
21
|
+
"app-builder"
|
|
22
|
+
],
|
|
12
23
|
"bugs": {
|
|
13
24
|
"url": "https://github.com/adobe/aio-commerce-sdk/issues"
|
|
14
25
|
},
|
|
@@ -18,17 +29,17 @@
|
|
|
18
29
|
"directory": "packages/aio-commerce-lib-app"
|
|
19
30
|
},
|
|
20
31
|
"bin": {
|
|
21
|
-
"@adobe/aio-commerce-lib-app": "./
|
|
32
|
+
"@adobe/aio-commerce-lib-app": "./bin/cli.mjs"
|
|
22
33
|
},
|
|
23
34
|
"exports": {
|
|
24
|
-
"./actions": {
|
|
35
|
+
"./actions/*": {
|
|
25
36
|
"import": {
|
|
26
|
-
"types": "./dist/es/actions
|
|
27
|
-
"default": "./dist/es/actions
|
|
37
|
+
"types": "./dist/es/actions/*.d.mts",
|
|
38
|
+
"default": "./dist/es/actions/*.mjs"
|
|
28
39
|
},
|
|
29
40
|
"require": {
|
|
30
|
-
"types": "./dist/cjs/actions
|
|
31
|
-
"default": "./dist/cjs/actions
|
|
41
|
+
"types": "./dist/cjs/actions/*.d.cts",
|
|
42
|
+
"default": "./dist/cjs/actions/*.cjs"
|
|
32
43
|
}
|
|
33
44
|
},
|
|
34
45
|
"./config": {
|
|
@@ -59,41 +70,44 @@
|
|
|
59
70
|
"#templates/*": "./source/commands/generate/actions/templates/*.template"
|
|
60
71
|
},
|
|
61
72
|
"files": [
|
|
73
|
+
"bin",
|
|
62
74
|
"dist",
|
|
63
75
|
"package.json",
|
|
64
76
|
"CHANGELOG.md",
|
|
65
77
|
"README.md"
|
|
66
78
|
],
|
|
67
79
|
"dependencies": {
|
|
80
|
+
"@adobe/aio-lib-core-config": "^5.0.1",
|
|
81
|
+
"@adobe/aio-lib-core-logging": "^3.0.2",
|
|
82
|
+
"@adobe/aio-lib-files": "^4.1.2",
|
|
83
|
+
"@adobe/aio-lib-ims": "^8.1.1",
|
|
84
|
+
"@adobe/aio-lib-state": "^5.3.1",
|
|
68
85
|
"camelcase": "^8.0.0",
|
|
69
86
|
"consola": "^3.4.2",
|
|
87
|
+
"dotenv": "^17.2.3",
|
|
70
88
|
"jiti": "^2.6.1",
|
|
71
89
|
"openwhisk": "^3.21.8",
|
|
72
90
|
"prettier": "^3.8.1",
|
|
91
|
+
"regexparam": "^3.0.0",
|
|
73
92
|
"safe-stable-stringify": "^2.5.0",
|
|
93
|
+
"type-fest": "^5.0.0",
|
|
74
94
|
"valibot": "^1.1.0",
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"@adobe/aio-lib-
|
|
78
|
-
"@adobe/aio-lib-
|
|
79
|
-
"@adobe/aio-lib-core
|
|
80
|
-
"@adobe/aio-lib-
|
|
81
|
-
"@adobe/aio-lib-state": "^5.3.1",
|
|
82
|
-
"@standard-schema/spec": "^1.1.0",
|
|
83
|
-
"yaml": "^2.8.2",
|
|
84
|
-
"@adobe/aio-commerce-lib-api": "0.6.1",
|
|
85
|
-
"@adobe/aio-commerce-lib-auth": "0.8.1",
|
|
86
|
-
"@adobe/aio-commerce-lib-core": "0.6.1",
|
|
87
|
-
"@adobe/aio-commerce-lib-events": "0.6.0"
|
|
95
|
+
"yaml": "^2.8.1",
|
|
96
|
+
"@adobe/aio-commerce-lib-api": "1.0.0",
|
|
97
|
+
"@adobe/aio-commerce-lib-auth": "1.0.0",
|
|
98
|
+
"@adobe/aio-commerce-lib-config": "1.0.1",
|
|
99
|
+
"@adobe/aio-commerce-lib-core": "1.0.0",
|
|
100
|
+
"@adobe/aio-commerce-lib-events": "1.0.0"
|
|
88
101
|
},
|
|
89
102
|
"devDependencies": {
|
|
90
|
-
"
|
|
91
|
-
"@aio-commerce-sdk/common-utils": "0.2.
|
|
92
|
-
"@aio-commerce-sdk/config-tsdown": "1.0.0",
|
|
103
|
+
"typescript": "^5.9.2",
|
|
104
|
+
"@aio-commerce-sdk/common-utils": "0.2.2",
|
|
93
105
|
"@aio-commerce-sdk/config-typedoc": "1.0.0",
|
|
94
106
|
"@aio-commerce-sdk/config-typescript": "1.0.0",
|
|
107
|
+
"@aio-commerce-sdk/config-tsdown": "1.0.1",
|
|
95
108
|
"@aio-commerce-sdk/config-vitest": "1.0.0",
|
|
96
|
-
"@aio-commerce-sdk/scripting-utils": "0.
|
|
109
|
+
"@aio-commerce-sdk/scripting-utils": "0.3.0",
|
|
110
|
+
"@aio-commerce-sdk/scripts": "0.1.0"
|
|
97
111
|
},
|
|
98
112
|
"sideEffects": false,
|
|
99
113
|
"scripts": {
|