@adobe/aio-commerce-lib-app 0.3.1 → 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.
- package/CHANGELOG.md +39 -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/cjs/{app-Dx0ca6oL.d.cts → app-PTKvEBea.d.cts} +6 -6
- 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 +105 -113
- package/dist/cjs/config/index.cjs +21 -19
- package/dist/cjs/config/index.d.cts +32 -332
- package/dist/cjs/error-DJ2UAPH2.cjs +24 -0
- package/dist/cjs/installation-nwF2RC7F.cjs +241 -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-DIchX9SL.cjs +267 -0
- package/dist/cjs/router-DCw7oEQ9.cjs +417 -0
- package/dist/cjs/{management-Dm5h0E6l.cjs → runner-CUJ8RHzY.cjs} +24 -30
- package/dist/{es/index-Bxr3zvCT.d.mts → cjs/runner-Ds2m27Q4.d.cts} +49 -95
- package/dist/cjs/schemas-CZ6c8Id9.cjs +98 -0
- package/dist/cjs/validate-BegMfe-i.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/es/{app-Cx1-6dn0.d.mts → app-vKXaAr6f.d.mts} +6 -6
- 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 +82 -91
- package/dist/es/config/index.d.mts +32 -332
- package/dist/es/config/index.mjs +3 -2
- package/dist/es/error-CMV3IjBz.mjs +18 -0
- package/dist/es/{error-P7JgUTds.mjs → installation-SWIwhpKT.mjs} +72 -124
- package/dist/es/management/index.d.mts +2 -3
- package/dist/es/management/index.mjs +1 -1
- package/dist/es/parser-CKQyrTB7.mjs +201 -0
- package/dist/es/router-CJ4VWoCt.mjs +404 -0
- package/dist/es/{management-Y7pwEbNI.mjs → runner-DB2tDBQS.mjs} +17 -24
- package/dist/{cjs/index-C5SutkJQ.d.cts → es/runner-Uk7263hG.d.mts} +49 -95
- package/dist/es/schemas-B8yIv0_b.mjs +41 -0
- package/dist/es/validate-DXI6gwZ2.mjs +187 -0
- package/package.json +39 -25
- 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,344 +0,0 @@
|
|
|
1
|
-
//#region rolldown:runtime
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
-
key = keys[i];
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
-
__defProp(to, key, {
|
|
14
|
-
get: ((k) => from[k]).bind(null, key),
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
-
value: mod,
|
|
24
|
-
enumerable: true
|
|
25
|
-
}) : target, mod));
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
|
-
let valibot = require("valibot");
|
|
29
|
-
valibot = __toESM(valibot);
|
|
30
|
-
let _adobe_aio_commerce_lib_core_error = require("@adobe/aio-commerce-lib-core/error");
|
|
31
|
-
|
|
32
|
-
//#region ../../packages-private/common-utils/source/valibot/schemas.ts
|
|
33
|
-
const ALPHANUMERIC_OR_UNDERSCORE_REGEX = {
|
|
34
|
-
any: /^[a-zA-Z0-9_]+$/,
|
|
35
|
-
lowercase: /^[a-z0-9_]+$/,
|
|
36
|
-
uppercase: /^[A-Z0-9_]+$/
|
|
37
|
-
};
|
|
38
|
-
const ALPHANUMERIC_OR_HYPHEN_REGEX = {
|
|
39
|
-
any: /^[a-zA-Z0-9-]+$/,
|
|
40
|
-
lowercase: /^[a-z0-9-]+$/,
|
|
41
|
-
uppercase: /^[A-Z0-9-]+$/
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* A schema for a string value.
|
|
45
|
-
* @param name The name of the field this schema refers to.
|
|
46
|
-
*/
|
|
47
|
-
function stringValueSchema(name) {
|
|
48
|
-
return valibot.string(`Expected a string value for '${name}'`);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* A schema for a non-empty string value.
|
|
52
|
-
* @param name The name of the field this schema refers to.
|
|
53
|
-
*/
|
|
54
|
-
function nonEmptyStringValueSchema(name) {
|
|
55
|
-
return valibot.pipe(stringValueSchema(name), valibot.nonEmpty(`The value of "${name}" must not be empty`));
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* A schema for a boolean value.
|
|
59
|
-
* @param name The name of the field this schema refers to.
|
|
60
|
-
*/
|
|
61
|
-
function booleanValueSchema(name) {
|
|
62
|
-
return valibot.boolean(`Expected a boolean value for '${name}'`);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* A schema for a string that only contains alphanumeric characters and underscores.
|
|
66
|
-
* @param name The name of the field this schema refers to.
|
|
67
|
-
* @param casing The allowed casing for the string (default: "any").
|
|
68
|
-
*/
|
|
69
|
-
function alphaNumericOrUnderscoreSchema(name, casing = "any") {
|
|
70
|
-
const casingLabel = casing === "any" ? "" : ` (${casing} only)`;
|
|
71
|
-
return valibot.pipe(stringValueSchema(name), valibot.regex(ALPHANUMERIC_OR_UNDERSCORE_REGEX[casing], `Only alphanumeric characters and underscores are allowed in string value of "${name}"${casingLabel}`));
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* A schema for a string that only contains alphanumeric characters and hyphens.
|
|
75
|
-
* @param name The name of the field this schema refers to.
|
|
76
|
-
* @param casing The allowed casing for the string (default: "any").
|
|
77
|
-
*/
|
|
78
|
-
function alphaNumericOrHyphenSchema(name, casing = "any") {
|
|
79
|
-
const casingLabel = casing === "any" ? "" : ` (${casing} only)`;
|
|
80
|
-
return valibot.pipe(stringValueSchema(name), valibot.regex(ALPHANUMERIC_OR_HYPHEN_REGEX[casing], `Only alphanumeric characters and hyphens are allowed in string value of "${name}"${casingLabel}`));
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
//#endregion
|
|
84
|
-
//#region source/config/schema/installation.ts
|
|
85
|
-
const MAX_DESCRIPTION_LENGTH$1 = 255;
|
|
86
|
-
const MAX_NAME_LENGTH = 255;
|
|
87
|
-
const MAX_MESSAGE_LENGTH = 1e3;
|
|
88
|
-
/**
|
|
89
|
-
* Regex for script paths that can be relative or absolute.
|
|
90
|
-
* Must end with .js extension
|
|
91
|
-
* Examples:
|
|
92
|
-
* - "./scripts/setup.js"
|
|
93
|
-
* - "./setup.js"
|
|
94
|
-
* - "../../scripts/setup.js"
|
|
95
|
-
*/
|
|
96
|
-
const SCRIPT_PATH_REGEX = /^(?:\.{0,2}\/)*[\w-/]*[\w-]+\.js$/;
|
|
97
|
-
/**
|
|
98
|
-
* Schema for custom installation step configuration
|
|
99
|
-
*/
|
|
100
|
-
const CustomInstallationStepSchema = valibot.object({
|
|
101
|
-
script: valibot.pipe(nonEmptyStringValueSchema("script path"), valibot.regex(SCRIPT_PATH_REGEX, "Script path must end with .js (e.g., \"./setup.js\", \"./scripts/setup.js\", or \"../../scripts/setup.js\")")),
|
|
102
|
-
name: valibot.pipe(nonEmptyStringValueSchema("step name"), valibot.maxLength(MAX_NAME_LENGTH, `The step name must not be longer than ${MAX_NAME_LENGTH} characters`)),
|
|
103
|
-
description: valibot.pipe(nonEmptyStringValueSchema("step description"), valibot.maxLength(MAX_DESCRIPTION_LENGTH$1, `The step description must not be longer than ${MAX_DESCRIPTION_LENGTH$1} characters`))
|
|
104
|
-
});
|
|
105
|
-
/**
|
|
106
|
-
* Schema for installation messages configuration
|
|
107
|
-
*/
|
|
108
|
-
const MessagesSchema = valibot.object({
|
|
109
|
-
preInstallation: valibot.optional(valibot.pipe(nonEmptyStringValueSchema("preInstallation message"), valibot.maxLength(MAX_MESSAGE_LENGTH, `The preInstallation message must not be longer than ${MAX_MESSAGE_LENGTH} characters`))),
|
|
110
|
-
postInstallation: valibot.optional(valibot.pipe(nonEmptyStringValueSchema("postInstallation message"), valibot.maxLength(MAX_MESSAGE_LENGTH, `The postInstallation message must not be longer than ${MAX_MESSAGE_LENGTH} characters`)))
|
|
111
|
-
});
|
|
112
|
-
/**
|
|
113
|
-
* Schema for installation configuration
|
|
114
|
-
*/
|
|
115
|
-
const InstallationSchema = valibot.object({
|
|
116
|
-
messages: valibot.optional(MessagesSchema),
|
|
117
|
-
customInstallationSteps: valibot.pipe(valibot.optional(valibot.array(CustomInstallationStepSchema, "Expected an array of custom installation steps")), valibot.check((input) => {
|
|
118
|
-
const steps = input || [];
|
|
119
|
-
return new Set(steps.map((step) => step.name)).size === steps.length;
|
|
120
|
-
}, "Duplicate step names detected in custom installation steps. Each step must have a unique name."))
|
|
121
|
-
});
|
|
122
|
-
/**
|
|
123
|
-
* Check if config has custom installation settings.
|
|
124
|
-
* @param config - The configuration to check.
|
|
125
|
-
*/
|
|
126
|
-
function hasCustomInstallation(config) {
|
|
127
|
-
return config.installation !== void 0;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Check if config has custom installation steps.
|
|
131
|
-
* @param config - The configuration to check.
|
|
132
|
-
*/
|
|
133
|
-
function hasCustomInstallationSteps(config) {
|
|
134
|
-
return Array.isArray(config?.installation?.customInstallationSteps) && config.installation.customInstallationSteps.length > 0;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
//#endregion
|
|
138
|
-
//#region source/config/schema/eventing.ts
|
|
139
|
-
const MAX_DESCRIPTION_LENGTH = 255;
|
|
140
|
-
const MAX_LABEL_LENGTH = 100;
|
|
141
|
-
const MAX_KEY_LENGTH = 50;
|
|
142
|
-
/**
|
|
143
|
-
* Regex for Commerce event names that must start with "plugin." or "observer."
|
|
144
|
-
* followed by lowercase letters and underscores only.
|
|
145
|
-
* Examples: "plugin.order_placed", "observer.catalog_update"
|
|
146
|
-
*/
|
|
147
|
-
const COMMERCE_EVENT_NAME_REGEX = /^(?:plugin|observer)\.[a-z_]+$/;
|
|
148
|
-
/**
|
|
149
|
-
* Regex for field names according to XSD fieldName pattern.
|
|
150
|
-
* Field name can either contain only [a-zA-Z0-9_\-\.\[\]] or be set to *.
|
|
151
|
-
*/
|
|
152
|
-
const FIELD_NAME_REGEX = /^([a-zA-Z0-9_\-.[\]]+|\*)$/;
|
|
153
|
-
/**
|
|
154
|
-
* Schema for Commerce event names.
|
|
155
|
-
* Validates that the event name starts with "plugin." or "observer."
|
|
156
|
-
* followed by lowercase letters and underscores only.
|
|
157
|
-
*/
|
|
158
|
-
function commerceEventNameSchema() {
|
|
159
|
-
return valibot.pipe(nonEmptyStringValueSchema("event name"), valibot.regex(COMMERCE_EVENT_NAME_REGEX, "Event name must start with \"plugin.\" or \"observer.\" followed by lowercase letters and underscores only (e.g., \"plugin.order_placed\")"));
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Schema for field names.
|
|
163
|
-
* Validates that the field name matches the XSD fieldName pattern:
|
|
164
|
-
* can either contain only [a-zA-Z0-9_\-\.\[\]] or be set to *.
|
|
165
|
-
*/
|
|
166
|
-
function fieldNameSchema() {
|
|
167
|
-
return valibot.pipe(nonEmptyStringValueSchema("field name"), valibot.regex(FIELD_NAME_REGEX, "Field name must contain only letters (a-z, A-Z), numbers (0-9), underscores (_), dashes (-), dots (.), and square brackets ([, ]), or be exactly \"*\""));
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Schema for field objects in Commerce events.
|
|
171
|
-
* Each field has a required name and an optional source.
|
|
172
|
-
*/
|
|
173
|
-
function commerceEventFieldSchema() {
|
|
174
|
-
return valibot.object({
|
|
175
|
-
name: fieldNameSchema(),
|
|
176
|
-
source: valibot.optional(stringValueSchema("field source"))
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
/** Schema for event provider configuration */
|
|
180
|
-
const ProviderSchema = valibot.object({
|
|
181
|
-
label: valibot.pipe(nonEmptyStringValueSchema("provider label"), valibot.maxLength(MAX_LABEL_LENGTH, `The provider label must not be longer than ${MAX_LABEL_LENGTH} characters`)),
|
|
182
|
-
description: valibot.pipe(nonEmptyStringValueSchema("provider description"), valibot.maxLength(MAX_DESCRIPTION_LENGTH, `The provider description must not be longer than ${MAX_DESCRIPTION_LENGTH} characters`)),
|
|
183
|
-
key: valibot.optional(valibot.pipe(alphaNumericOrHyphenSchema("provider key"), valibot.maxLength(MAX_KEY_LENGTH, `The provider key must not be longer than ${MAX_KEY_LENGTH} characters`)))
|
|
184
|
-
});
|
|
185
|
-
/** Schema for base shared properties between event types. */
|
|
186
|
-
const BaseEventSchema = valibot.object({
|
|
187
|
-
label: valibot.pipe(nonEmptyStringValueSchema("event label"), valibot.maxLength(MAX_LABEL_LENGTH, `The event label must not be longer than ${MAX_LABEL_LENGTH} characters`)),
|
|
188
|
-
description: valibot.pipe(nonEmptyStringValueSchema("event description"), valibot.maxLength(MAX_DESCRIPTION_LENGTH, `The event description must not be longer than ${MAX_DESCRIPTION_LENGTH} characters`)),
|
|
189
|
-
runtimeActions: valibot.array(valibot.pipe(nonEmptyStringValueSchema("runtime action"), valibot.regex(/^[a-z0-9-]+\/[a-z0-9-]+$/, "Runtime action must be in the format \"<package>/<action>\" (e.g., \"my-package/my-action\")")), "Expected an array of runtime actions in the format <package>/<action>")
|
|
190
|
-
});
|
|
191
|
-
/**
|
|
192
|
-
* Schema for rule operator values.
|
|
193
|
-
* Valid operators for Commerce event filtering rules.
|
|
194
|
-
*/
|
|
195
|
-
const OPERATORS = [
|
|
196
|
-
"greaterThan",
|
|
197
|
-
"lessThan",
|
|
198
|
-
"equal",
|
|
199
|
-
"regex",
|
|
200
|
-
"in",
|
|
201
|
-
"onChange"
|
|
202
|
-
];
|
|
203
|
-
const ruleOperatorSchema = valibot.union(OPERATORS.map((op) => valibot.literal(op)), `Operator must be one of: ${OPERATORS.join(", ")}`);
|
|
204
|
-
/** Schema for Commerce event rule configuration */
|
|
205
|
-
const CommerceEventRuleSchema = valibot.object({
|
|
206
|
-
field: nonEmptyStringValueSchema("rule field"),
|
|
207
|
-
operator: ruleOperatorSchema,
|
|
208
|
-
value: nonEmptyStringValueSchema("rule value")
|
|
209
|
-
});
|
|
210
|
-
/** Schema for Commerce event configuration */
|
|
211
|
-
const CommerceEventSchema = valibot.object({
|
|
212
|
-
...BaseEventSchema.entries,
|
|
213
|
-
name: commerceEventNameSchema(),
|
|
214
|
-
fields: valibot.array(commerceEventFieldSchema(), "Expected an array of event field objects with a 'name' property"),
|
|
215
|
-
rules: valibot.optional(valibot.array(CommerceEventRuleSchema, "Expected an array of event rules with field, operator, and value")),
|
|
216
|
-
destination: valibot.optional(nonEmptyStringValueSchema("destination")),
|
|
217
|
-
hipaaAuditRequired: valibot.optional(booleanValueSchema("hipaaAuditRequired")),
|
|
218
|
-
prioritary: valibot.optional(booleanValueSchema("prioritary")),
|
|
219
|
-
force: valibot.optional(booleanValueSchema("force"))
|
|
220
|
-
});
|
|
221
|
-
/** Schema for external event configuration */
|
|
222
|
-
const ExternalEventSchema = valibot.object({
|
|
223
|
-
...BaseEventSchema.entries,
|
|
224
|
-
name: alphaNumericOrUnderscoreSchema("event name", "lowercase")
|
|
225
|
-
});
|
|
226
|
-
/** Schema for Commerce event source configuration */
|
|
227
|
-
const CommerceEventSourceSchema = valibot.object({
|
|
228
|
-
provider: ProviderSchema,
|
|
229
|
-
events: valibot.array(CommerceEventSchema, "Expected an array of Commerce events")
|
|
230
|
-
});
|
|
231
|
-
/** Schema for external event source configuration */
|
|
232
|
-
const ExternalEventSourceSchema = valibot.object({
|
|
233
|
-
provider: ProviderSchema,
|
|
234
|
-
events: valibot.array(ExternalEventSchema, "Expected an array of external events")
|
|
235
|
-
});
|
|
236
|
-
/** Schema for eventing configuration with separate commerce and external arrays */
|
|
237
|
-
const EventingSchema = valibot.object({
|
|
238
|
-
commerce: valibot.optional(valibot.array(CommerceEventSourceSchema, "Expected an array of Commerce event sources")),
|
|
239
|
-
external: valibot.optional(valibot.array(ExternalEventSourceSchema, "Expected an array of external event sources"))
|
|
240
|
-
});
|
|
241
|
-
/**
|
|
242
|
-
* Check if config has commerce event sources.
|
|
243
|
-
* @param config - The configuration to check.
|
|
244
|
-
*/
|
|
245
|
-
function hasCommerceEvents(config) {
|
|
246
|
-
return Array.isArray(config?.eventing?.commerce) && config.eventing.commerce.length > 0;
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Check if config has external event sources.
|
|
250
|
-
* @param config - The configuration to check.
|
|
251
|
-
*/
|
|
252
|
-
function hasExternalEvents(config) {
|
|
253
|
-
return Array.isArray(config?.eventing?.external) && config.eventing.external.length > 0;
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* Check if config has any eventing configuration.
|
|
257
|
-
* @param config - The configuration to check.
|
|
258
|
-
*/
|
|
259
|
-
function hasEventing(config) {
|
|
260
|
-
return config.eventing !== void 0;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
//#endregion
|
|
264
|
-
//#region ../../packages-private/scripting-utils/source/error.ts
|
|
265
|
-
/**
|
|
266
|
-
* This module exports shared error utilities for the AIO Commerce SDK.
|
|
267
|
-
* @packageDocumentation
|
|
268
|
-
*/
|
|
269
|
-
/**
|
|
270
|
-
* Stringify an error to a human-friendly string.
|
|
271
|
-
* @param error - The error to stringify.
|
|
272
|
-
*/
|
|
273
|
-
function stringifyError(error) {
|
|
274
|
-
if (error instanceof _adobe_aio_commerce_lib_core_error.CommerceSdkValidationError) return error.display();
|
|
275
|
-
return error instanceof Error ? error.message : String(error);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
//#endregion
|
|
279
|
-
Object.defineProperty(exports, 'EventingSchema', {
|
|
280
|
-
enumerable: true,
|
|
281
|
-
get: function () {
|
|
282
|
-
return EventingSchema;
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
Object.defineProperty(exports, 'InstallationSchema', {
|
|
286
|
-
enumerable: true,
|
|
287
|
-
get: function () {
|
|
288
|
-
return InstallationSchema;
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
Object.defineProperty(exports, '__toESM', {
|
|
292
|
-
enumerable: true,
|
|
293
|
-
get: function () {
|
|
294
|
-
return __toESM;
|
|
295
|
-
}
|
|
296
|
-
});
|
|
297
|
-
Object.defineProperty(exports, 'alphaNumericOrHyphenSchema', {
|
|
298
|
-
enumerable: true,
|
|
299
|
-
get: function () {
|
|
300
|
-
return alphaNumericOrHyphenSchema;
|
|
301
|
-
}
|
|
302
|
-
});
|
|
303
|
-
Object.defineProperty(exports, 'hasCommerceEvents', {
|
|
304
|
-
enumerable: true,
|
|
305
|
-
get: function () {
|
|
306
|
-
return hasCommerceEvents;
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
Object.defineProperty(exports, 'hasCustomInstallation', {
|
|
310
|
-
enumerable: true,
|
|
311
|
-
get: function () {
|
|
312
|
-
return hasCustomInstallation;
|
|
313
|
-
}
|
|
314
|
-
});
|
|
315
|
-
Object.defineProperty(exports, 'hasCustomInstallationSteps', {
|
|
316
|
-
enumerable: true,
|
|
317
|
-
get: function () {
|
|
318
|
-
return hasCustomInstallationSteps;
|
|
319
|
-
}
|
|
320
|
-
});
|
|
321
|
-
Object.defineProperty(exports, 'hasEventing', {
|
|
322
|
-
enumerable: true,
|
|
323
|
-
get: function () {
|
|
324
|
-
return hasEventing;
|
|
325
|
-
}
|
|
326
|
-
});
|
|
327
|
-
Object.defineProperty(exports, 'hasExternalEvents', {
|
|
328
|
-
enumerable: true,
|
|
329
|
-
get: function () {
|
|
330
|
-
return hasExternalEvents;
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
Object.defineProperty(exports, 'nonEmptyStringValueSchema', {
|
|
334
|
-
enumerable: true,
|
|
335
|
-
get: function () {
|
|
336
|
-
return nonEmptyStringValueSchema;
|
|
337
|
-
}
|
|
338
|
-
});
|
|
339
|
-
Object.defineProperty(exports, 'stringifyError', {
|
|
340
|
-
enumerable: true,
|
|
341
|
-
get: function () {
|
|
342
|
-
return stringifyError;
|
|
343
|
-
}
|
|
344
|
-
});
|
package/dist/es/commands/generate/actions/templates/app-management/get-app-config.js.template
DELETED
|
@@ -1,62 +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-app`
|
|
14
|
-
// Do not modify this file directly
|
|
15
|
-
|
|
16
|
-
import util from "node:util";
|
|
17
|
-
|
|
18
|
-
import { validateCommerceAppConfig } from "@adobe/aio-commerce-lib-app/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
|
-
// The manifest is always at this relative constant path from the action.
|
|
26
|
-
import commerceAppManifest from "../../app.commerce.manifest.json" with { type: "json" };
|
|
27
|
-
|
|
28
|
-
// Shorthand to inspect an object.
|
|
29
|
-
const inspect = (obj) => util.inspect(obj, { depth: null });
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Get the app config.
|
|
33
|
-
* @returns The response object containing the app config.
|
|
34
|
-
*/
|
|
35
|
-
export function main(params) {
|
|
36
|
-
const logger = AioLogger("get-app-config", {
|
|
37
|
-
level: params.LOG_LEVEL || "info",
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
try {
|
|
41
|
-
logger.debug("Validating app config...");
|
|
42
|
-
|
|
43
|
-
const appConfig = validateCommerceAppConfig(commerceAppManifest);
|
|
44
|
-
logger.debug("Successfully validated the app config");
|
|
45
|
-
|
|
46
|
-
return ok({
|
|
47
|
-
body: appConfig,
|
|
48
|
-
});
|
|
49
|
-
} catch (error) {
|
|
50
|
-
logger.error(
|
|
51
|
-
`Something went wrong while validating app config: ${inspect(error)}`,
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
return internalServerError({
|
|
55
|
-
body: {
|
|
56
|
-
code: "INTERNAL_ERROR",
|
|
57
|
-
details: error instanceof Error ? error.message : "Unknown error",
|
|
58
|
-
message: "An internal server error occurred",
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
@@ -1,63 +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 { getConfigSchema } 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
|
-
// Shorthand to inspect an object.
|
|
26
|
-
const inspect = (obj) => util.inspect(obj, { depth: null });
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Get the configuration schema.
|
|
30
|
-
* @returns The response object containing the configuration schema.
|
|
31
|
-
*/
|
|
32
|
-
export async function main(params) {
|
|
33
|
-
const logger = AioLogger("get-config-schema", {
|
|
34
|
-
level: params.LOG_LEVEL || "info",
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
try {
|
|
38
|
-
logger.debug("Retrieving configuration schema...");
|
|
39
|
-
const configSchema = await getConfigSchema();
|
|
40
|
-
|
|
41
|
-
logger.debug(
|
|
42
|
-
`Successfully retrieved configSchema: ${inspect(configSchema)}`,
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
return ok({
|
|
46
|
-
body: {
|
|
47
|
-
configSchema,
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
} catch (error) {
|
|
51
|
-
logger.error(
|
|
52
|
-
`Something wen't wrong while retrieving config schema: ${inspect(error)}`,
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
return internalServerError({
|
|
56
|
-
body: {
|
|
57
|
-
code: "INTERNAL_ERROR",
|
|
58
|
-
details: error instanceof Error ? error.message : "Unknown error",
|
|
59
|
-
message: "An internal server error occurred",
|
|
60
|
-
},
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
@@ -1,104 +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 {
|
|
19
|
-
byCode,
|
|
20
|
-
byCodeAndLevel,
|
|
21
|
-
byScopeId,
|
|
22
|
-
getConfiguration,
|
|
23
|
-
setGlobalLibConfigOptions,
|
|
24
|
-
} from "@adobe/aio-commerce-lib-config";
|
|
25
|
-
import {
|
|
26
|
-
badRequest,
|
|
27
|
-
internalServerError,
|
|
28
|
-
ok,
|
|
29
|
-
} from "@adobe/aio-commerce-sdk/core/responses";
|
|
30
|
-
import AioLogger from "@adobe/aio-lib-core-logging";
|
|
31
|
-
|
|
32
|
-
// Shorthand to inspect an object.
|
|
33
|
-
const inspect = (obj) => util.inspect(obj, { depth: null });
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Get the configuration.
|
|
37
|
-
* @param params - The input parameters.
|
|
38
|
-
* @returns The response object containing the configuration data.
|
|
39
|
-
*/
|
|
40
|
-
export async function main(params) {
|
|
41
|
-
const logger = AioLogger("get-configuration", {
|
|
42
|
-
level: params.LOG_LEVEL || "info",
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
try {
|
|
46
|
-
if (params.AIO_COMMERCE_CONFIG_ENCRYPTION_KEY) {
|
|
47
|
-
setGlobalLibConfigOptions({
|
|
48
|
-
encryptionKey: params.AIO_COMMERCE_CONFIG_ENCRYPTION_KEY,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const id = params.id;
|
|
53
|
-
const code = params.code;
|
|
54
|
-
const level = params.level;
|
|
55
|
-
|
|
56
|
-
logger.debug(
|
|
57
|
-
`Retrieving configuration with params: ${inspect({ id, code, level })}`,
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
if (!(id || code)) {
|
|
61
|
-
logger.warn("Invalid params: Either id or code query param is required");
|
|
62
|
-
return badRequest({
|
|
63
|
-
body: {
|
|
64
|
-
code: "INVALID_PARAMS",
|
|
65
|
-
message: "Either id or code query param is required",
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
let appConfiguration;
|
|
71
|
-
if (id) {
|
|
72
|
-
logger.debug(`Retrieving configuration by id: ${id}`);
|
|
73
|
-
appConfiguration = await getConfiguration(byScopeId(id));
|
|
74
|
-
} else if (level) {
|
|
75
|
-
logger.debug(
|
|
76
|
-
`Retrieving configuration by code: ${code}, level: ${level}`,
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
appConfiguration = await getConfiguration(byCodeAndLevel(code, level));
|
|
80
|
-
} else {
|
|
81
|
-
logger.debug(`Retrieving configuration by code: ${code}`);
|
|
82
|
-
appConfiguration = await getConfiguration(byCode(code));
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
logger.debug(
|
|
86
|
-
`Successfully retrieved configuration: ${inspect(appConfiguration)}`,
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
return ok({ body: appConfiguration });
|
|
90
|
-
} catch (error) {
|
|
91
|
-
logger.error(
|
|
92
|
-
`Something went wrong while retrieving configuration: ${inspect(error)}`,
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
return internalServerError({
|
|
96
|
-
body: {
|
|
97
|
-
code: "INTERNAL_ERROR",
|
|
98
|
-
details: error instanceof Error ? error.message : "Unknown error",
|
|
99
|
-
|
|
100
|
-
message: "An internal server error occurred",
|
|
101
|
-
},
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
}
|
|
@@ -1,69 +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 { getScopeTree } from "@adobe/aio-commerce-lib-config";
|
|
19
|
-
import {
|
|
20
|
-
internalServerError,
|
|
21
|
-
nonAuthoritativeInformation,
|
|
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
|
-
* Get scope tree.
|
|
31
|
-
* @returns The response object containing persisted scope tree configuration from cache/storage.
|
|
32
|
-
*/
|
|
33
|
-
export async function main(params) {
|
|
34
|
-
const logger = AioLogger("get-scope-tree", {
|
|
35
|
-
level: params.LOG_LEVEL || "info",
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
try {
|
|
39
|
-
logger.debug("Retrieving scope tree...");
|
|
40
|
-
|
|
41
|
-
const result = await getScopeTree();
|
|
42
|
-
logger.debug(
|
|
43
|
-
`Successfully retrieved scope tree (cached: ${result.isCachedData}): ${inspect(result.scopeTree)}`,
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
if (result.isCachedData) {
|
|
47
|
-
return nonAuthoritativeInformation({
|
|
48
|
-
headers: { "x-cache": "hit" },
|
|
49
|
-
body: { scopes: result.scopeTree },
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return ok({
|
|
54
|
-
body: { scopes: result.scopeTree },
|
|
55
|
-
});
|
|
56
|
-
} catch (error) {
|
|
57
|
-
logger.error(
|
|
58
|
-
`Something went wrong while retrieving scope tree: ${inspect(error)}`,
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
return internalServerError({
|
|
62
|
-
body: {
|
|
63
|
-
code: "INTERNAL_ERROR",
|
|
64
|
-
message: "An internal server error occurred",
|
|
65
|
-
details: error instanceof Error ? error.message : "Unknown error",
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
}
|