@adobe/aio-commerce-lib-app 0.3.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -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 +91 -106
- 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 +68 -84
- 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 +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
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
const require_schemas = require('./schemas-CZ6c8Id9.cjs');
|
|
2
|
+
let valibot = require("valibot");
|
|
3
|
+
valibot = require_schemas.__toESM(valibot);
|
|
4
|
+
|
|
5
|
+
//#region source/config/schema/eventing.ts
|
|
6
|
+
const MAX_DESCRIPTION_LENGTH$1 = 255;
|
|
7
|
+
const MAX_LABEL_LENGTH = 100;
|
|
8
|
+
const MAX_KEY_LENGTH = 50;
|
|
9
|
+
const MAX_EVENT_NAME_LENGTH = 180;
|
|
10
|
+
/**
|
|
11
|
+
* Regex for Commerce event names that must start with "plugin." or "observer."
|
|
12
|
+
* followed by lowercase letters and underscores only.
|
|
13
|
+
* Examples: "plugin.order_placed", "observer.catalog_update"
|
|
14
|
+
*/
|
|
15
|
+
const COMMERCE_EVENT_NAME_REGEX = /^(?:plugin|observer)\.[a-z_]+$/;
|
|
16
|
+
/**
|
|
17
|
+
* Regex for external event names.
|
|
18
|
+
* Allows word characters (letters, digits, underscore), hyphens, underscores, and dots.
|
|
19
|
+
* Examples: "external_event", "webhook.received", "my-event_123"
|
|
20
|
+
*/
|
|
21
|
+
const EXTERNAL_EVENT_NAME_REGEX = /^[\w\-_.]+$/;
|
|
22
|
+
/**
|
|
23
|
+
* Regex for field names according to XSD fieldName pattern.
|
|
24
|
+
* Field name can either contain only [a-zA-Z0-9_\-\.\[\]] or be set to *.
|
|
25
|
+
*/
|
|
26
|
+
const FIELD_NAME_REGEX = /^([a-zA-Z0-9_\-.[\]]+|\*)$/;
|
|
27
|
+
/**
|
|
28
|
+
* Schema for Commerce event names.
|
|
29
|
+
* Validates that the event name starts with "plugin." or "observer."
|
|
30
|
+
* followed by lowercase letters and underscores only.
|
|
31
|
+
*/
|
|
32
|
+
function commerceEventNameSchema() {
|
|
33
|
+
return valibot.pipe(require_schemas.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\")"), valibot.maxLength(MAX_EVENT_NAME_LENGTH, `The event name must not be longer than ${MAX_EVENT_NAME_LENGTH} characters`));
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Schema for external event names.
|
|
37
|
+
* Validates that the event name contains only word characters (letters, digits, underscore),
|
|
38
|
+
* hyphens, underscores, and dots.
|
|
39
|
+
*/
|
|
40
|
+
function externalEventNameSchema() {
|
|
41
|
+
return valibot.pipe(require_schemas.nonEmptyStringValueSchema("event name"), valibot.regex(EXTERNAL_EVENT_NAME_REGEX, "Event name must contain only letters, digits, underscores, hyphens, and dots (e.g., \"external_event\", \"webhook.received\", \"my-event_123\")"), valibot.maxLength(MAX_EVENT_NAME_LENGTH, `The event name must not be longer than ${MAX_EVENT_NAME_LENGTH} characters`));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Schema for field names.
|
|
45
|
+
* Validates that the field name matches the XSD fieldName pattern:
|
|
46
|
+
* can either contain only [a-zA-Z0-9_\-\.\[\]] or be set to *.
|
|
47
|
+
*/
|
|
48
|
+
function fieldNameSchema() {
|
|
49
|
+
return valibot.pipe(require_schemas.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 \"*\""));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Schema for field objects in Commerce events.
|
|
53
|
+
* Each field has a required name and an optional source.
|
|
54
|
+
*/
|
|
55
|
+
function commerceEventFieldSchema() {
|
|
56
|
+
return valibot.object({
|
|
57
|
+
name: fieldNameSchema(),
|
|
58
|
+
source: valibot.optional(require_schemas.stringValueSchema("field source"))
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/** Schema for event provider configuration */
|
|
62
|
+
const ProviderSchema = valibot.object({
|
|
63
|
+
label: valibot.pipe(require_schemas.nonEmptyStringValueSchema("provider label"), valibot.maxLength(MAX_LABEL_LENGTH, `The provider label must not be longer than ${MAX_LABEL_LENGTH} characters`)),
|
|
64
|
+
description: valibot.pipe(require_schemas.nonEmptyStringValueSchema("provider description"), valibot.maxLength(MAX_DESCRIPTION_LENGTH$1, `The provider description must not be longer than ${MAX_DESCRIPTION_LENGTH$1} characters`)),
|
|
65
|
+
key: valibot.optional(valibot.pipe(require_schemas.alphaNumericOrHyphenSchema("provider key"), valibot.maxLength(MAX_KEY_LENGTH, `The provider key must not be longer than ${MAX_KEY_LENGTH} characters`)))
|
|
66
|
+
});
|
|
67
|
+
/** Schema for base shared properties between event types. */
|
|
68
|
+
const BaseEventSchema = valibot.object({
|
|
69
|
+
label: valibot.pipe(require_schemas.nonEmptyStringValueSchema("event label"), valibot.maxLength(MAX_LABEL_LENGTH, `The event label must not be longer than ${MAX_LABEL_LENGTH} characters`)),
|
|
70
|
+
description: valibot.pipe(require_schemas.nonEmptyStringValueSchema("event description"), valibot.maxLength(MAX_DESCRIPTION_LENGTH$1, `The event description must not be longer than ${MAX_DESCRIPTION_LENGTH$1} characters`)),
|
|
71
|
+
runtimeActions: valibot.array(valibot.pipe(require_schemas.nonEmptyStringValueSchema("runtime action"), valibot.regex(/^[a-z0-9-]+\/[a-z0-9-]+$/i, "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>")
|
|
72
|
+
});
|
|
73
|
+
/**
|
|
74
|
+
* Schema for rule operator values.
|
|
75
|
+
* Valid operators for Commerce event filtering rules.
|
|
76
|
+
*/
|
|
77
|
+
const OPERATORS = [
|
|
78
|
+
"greaterThan",
|
|
79
|
+
"lessThan",
|
|
80
|
+
"equal",
|
|
81
|
+
"regex",
|
|
82
|
+
"in",
|
|
83
|
+
"onChange"
|
|
84
|
+
];
|
|
85
|
+
const ruleOperatorSchema = valibot.union(OPERATORS.map((op) => valibot.literal(op)), `Operator must be one of: ${OPERATORS.join(", ")}`);
|
|
86
|
+
/** Schema for Commerce event rule configuration */
|
|
87
|
+
const CommerceEventRuleSchema = valibot.object({
|
|
88
|
+
field: require_schemas.nonEmptyStringValueSchema("rule field"),
|
|
89
|
+
operator: ruleOperatorSchema,
|
|
90
|
+
value: require_schemas.nonEmptyStringValueSchema("rule value")
|
|
91
|
+
});
|
|
92
|
+
/** Schema for Commerce event configuration */
|
|
93
|
+
const CommerceEventSchema = valibot.object({
|
|
94
|
+
...BaseEventSchema.entries,
|
|
95
|
+
name: commerceEventNameSchema(),
|
|
96
|
+
fields: valibot.array(commerceEventFieldSchema(), "Expected an array of event field objects with a 'name' property"),
|
|
97
|
+
rules: valibot.optional(valibot.array(CommerceEventRuleSchema, "Expected an array of event rules with field, operator, and value")),
|
|
98
|
+
destination: valibot.optional(require_schemas.nonEmptyStringValueSchema("destination")),
|
|
99
|
+
hipaa_audit_required: valibot.optional(require_schemas.booleanValueSchema("hipaa_audit_required")),
|
|
100
|
+
priority: valibot.optional(require_schemas.booleanValueSchema("priority")),
|
|
101
|
+
force: valibot.optional(require_schemas.booleanValueSchema("force"))
|
|
102
|
+
});
|
|
103
|
+
/** Schema for external event configuration */
|
|
104
|
+
const ExternalEventSchema = valibot.object({
|
|
105
|
+
...BaseEventSchema.entries,
|
|
106
|
+
name: externalEventNameSchema()
|
|
107
|
+
});
|
|
108
|
+
/** Schema for Commerce event source configuration */
|
|
109
|
+
const CommerceEventSourceSchema = valibot.object({
|
|
110
|
+
provider: ProviderSchema,
|
|
111
|
+
events: valibot.array(CommerceEventSchema, "Expected an array of Commerce events")
|
|
112
|
+
});
|
|
113
|
+
/** Schema for external event source configuration */
|
|
114
|
+
const ExternalEventSourceSchema = valibot.object({
|
|
115
|
+
provider: ProviderSchema,
|
|
116
|
+
events: valibot.array(ExternalEventSchema, "Expected an array of external events")
|
|
117
|
+
});
|
|
118
|
+
/** Schema for eventing configuration with separate commerce and external arrays */
|
|
119
|
+
const EventingSchema = valibot.object({
|
|
120
|
+
commerce: valibot.optional(valibot.array(CommerceEventSourceSchema, "Expected an array of Commerce event sources")),
|
|
121
|
+
external: valibot.optional(valibot.array(ExternalEventSourceSchema, "Expected an array of external event sources"))
|
|
122
|
+
});
|
|
123
|
+
/**
|
|
124
|
+
* Check if config has commerce event sources.
|
|
125
|
+
* @param config - The configuration to check.
|
|
126
|
+
*/
|
|
127
|
+
function hasCommerceEvents(config) {
|
|
128
|
+
return Array.isArray(config?.eventing?.commerce) && config.eventing.commerce.length > 0;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Check if config has external event sources.
|
|
132
|
+
* @param config - The configuration to check.
|
|
133
|
+
*/
|
|
134
|
+
function hasExternalEvents(config) {
|
|
135
|
+
return Array.isArray(config?.eventing?.external) && config.eventing.external.length > 0;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Check if config has any eventing configuration.
|
|
139
|
+
* @param config - The configuration to check.
|
|
140
|
+
*/
|
|
141
|
+
function hasEventing(config) {
|
|
142
|
+
return config.eventing !== void 0;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region source/config/schema/installation.ts
|
|
147
|
+
const MAX_DESCRIPTION_LENGTH = 255;
|
|
148
|
+
const MAX_NAME_LENGTH = 255;
|
|
149
|
+
const MAX_MESSAGE_LENGTH = 1e3;
|
|
150
|
+
/**
|
|
151
|
+
* Regex for script paths that can be relative or absolute.
|
|
152
|
+
* Must end with .js extension
|
|
153
|
+
* Examples:
|
|
154
|
+
* - "./scripts/setup.js"
|
|
155
|
+
* - "./setup.js"
|
|
156
|
+
* - "../../scripts/setup.js"
|
|
157
|
+
*/
|
|
158
|
+
const SCRIPT_PATH_REGEX = /^(?:\.{0,2}\/)*[\w-/]*[\w-]+\.js$/;
|
|
159
|
+
/**
|
|
160
|
+
* Schema for custom installation step configuration
|
|
161
|
+
*/
|
|
162
|
+
const CustomInstallationStepSchema = valibot.object({
|
|
163
|
+
script: valibot.pipe(require_schemas.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\")")),
|
|
164
|
+
name: valibot.pipe(require_schemas.nonEmptyStringValueSchema("step name"), valibot.maxLength(MAX_NAME_LENGTH, `The step name must not be longer than ${MAX_NAME_LENGTH} characters`)),
|
|
165
|
+
description: valibot.pipe(require_schemas.nonEmptyStringValueSchema("step description"), valibot.maxLength(MAX_DESCRIPTION_LENGTH, `The step description must not be longer than ${MAX_DESCRIPTION_LENGTH} characters`))
|
|
166
|
+
});
|
|
167
|
+
/**
|
|
168
|
+
* Schema for installation messages configuration
|
|
169
|
+
*/
|
|
170
|
+
const MessagesSchema = valibot.object({
|
|
171
|
+
preInstallation: valibot.optional(valibot.pipe(require_schemas.nonEmptyStringValueSchema("preInstallation message"), valibot.maxLength(MAX_MESSAGE_LENGTH, `The preInstallation message must not be longer than ${MAX_MESSAGE_LENGTH} characters`))),
|
|
172
|
+
postInstallation: valibot.optional(valibot.pipe(require_schemas.nonEmptyStringValueSchema("postInstallation message"), valibot.maxLength(MAX_MESSAGE_LENGTH, `The postInstallation message must not be longer than ${MAX_MESSAGE_LENGTH} characters`)))
|
|
173
|
+
});
|
|
174
|
+
/**
|
|
175
|
+
* Schema for installation configuration
|
|
176
|
+
*/
|
|
177
|
+
const InstallationSchema = valibot.object({
|
|
178
|
+
messages: valibot.optional(MessagesSchema),
|
|
179
|
+
customInstallationSteps: valibot.pipe(valibot.optional(valibot.array(CustomInstallationStepSchema, "Expected an array of custom installation steps")), valibot.check((input) => {
|
|
180
|
+
const steps = input || [];
|
|
181
|
+
return new Set(steps.map((step) => step.name)).size === steps.length;
|
|
182
|
+
}, "Duplicate step names detected in custom installation steps. Each step must have a unique name."))
|
|
183
|
+
});
|
|
184
|
+
/**
|
|
185
|
+
* Check if config has custom installation settings.
|
|
186
|
+
* @param config - The configuration to check.
|
|
187
|
+
*/
|
|
188
|
+
function hasCustomInstallation(config) {
|
|
189
|
+
return config.installation !== void 0;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Check if config has custom installation steps.
|
|
193
|
+
* @param config - The configuration to check.
|
|
194
|
+
*/
|
|
195
|
+
function hasCustomInstallationSteps(config) {
|
|
196
|
+
return Array.isArray(config?.installation?.customInstallationSteps) && config.installation.customInstallationSteps.length > 0;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
//#endregion
|
|
200
|
+
Object.defineProperty(exports, 'EventingSchema', {
|
|
201
|
+
enumerable: true,
|
|
202
|
+
get: function () {
|
|
203
|
+
return EventingSchema;
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
Object.defineProperty(exports, 'InstallationSchema', {
|
|
207
|
+
enumerable: true,
|
|
208
|
+
get: function () {
|
|
209
|
+
return InstallationSchema;
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
Object.defineProperty(exports, 'hasCommerceEvents', {
|
|
213
|
+
enumerable: true,
|
|
214
|
+
get: function () {
|
|
215
|
+
return hasCommerceEvents;
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
Object.defineProperty(exports, 'hasCustomInstallation', {
|
|
219
|
+
enumerable: true,
|
|
220
|
+
get: function () {
|
|
221
|
+
return hasCustomInstallation;
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
Object.defineProperty(exports, 'hasCustomInstallationSteps', {
|
|
225
|
+
enumerable: true,
|
|
226
|
+
get: function () {
|
|
227
|
+
return hasCustomInstallationSteps;
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
Object.defineProperty(exports, 'hasEventing', {
|
|
231
|
+
enumerable: true,
|
|
232
|
+
get: function () {
|
|
233
|
+
return hasEventing;
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
Object.defineProperty(exports, 'hasExternalEvents', {
|
|
237
|
+
enumerable: true,
|
|
238
|
+
get: function () {
|
|
239
|
+
return hasExternalEvents;
|
|
240
|
+
}
|
|
241
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_schemas = require('./schemas-CZ6c8Id9.cjs');
|
|
2
2
|
let util = require("util");
|
|
3
|
-
util =
|
|
3
|
+
util = require_schemas.__toESM(util);
|
|
4
4
|
|
|
5
5
|
//#region ../../packages-private/common-utils/source/logging.ts
|
|
6
6
|
/**
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runner = require('../runner-CUJ8RHzY.cjs');
|
|
2
3
|
|
|
3
|
-
exports.createInitialInstallationState =
|
|
4
|
-
exports.defineCustomInstallationStep =
|
|
5
|
-
exports.isCompletedState =
|
|
6
|
-
exports.isFailedState =
|
|
7
|
-
exports.isInProgressState =
|
|
8
|
-
exports.isSucceededState =
|
|
9
|
-
exports.runInstallation =
|
|
4
|
+
exports.createInitialInstallationState = require_runner.createInitialInstallationState;
|
|
5
|
+
exports.defineCustomInstallationStep = require_runner.defineCustomInstallationStep;
|
|
6
|
+
exports.isCompletedState = require_runner.isCompletedState;
|
|
7
|
+
exports.isFailedState = require_runner.isFailedState;
|
|
8
|
+
exports.isInProgressState = require_runner.isInProgressState;
|
|
9
|
+
exports.isSucceededState = require_runner.isSucceededState;
|
|
10
|
+
exports.runInstallation = require_runner.runInstallation;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as BranchStep, B as defineBranchStep, C as StepStatus, D as isInProgressState, E as isFailedState, F as LeafStep, H as isBranchStep, I as LeafStepOptions, L as Step, M as ExecutionContext, N as InferStepOutput, O as isSucceededState, P as InstallationContext, R as StepContextFactory, S as InstallationStatus, T as isCompletedState, U as isLeafStep, V as defineLeafStep, _ as FailedInstallationState, a as CustomInstallationStepHandler, b as InstallationError, c as ExecuteWorkflowOptions, d as InstallationHooks, f as StepEvent, g as ExecutionStatus, h as StepSucceededEvent, i as runInstallation, j as BranchStepOptions, k as AnyStep, l as createInitialState, m as StepStartedEvent, n as RunInstallationOptions, o as defineCustomInstallationStep, p as StepFailedEvent, r as createInitialInstallationState, s as CreateInitialStateOptions, t as CreateInitialInstallationStateOptions, u as executeWorkflow, v as InProgressInstallationState, w as SucceededInstallationState, x as InstallationState, y as InstallationData, z as StepMeta } from "../
|
|
2
|
-
export { AnyStep, BranchStep, BranchStepOptions, CreateInitialInstallationStateOptions, CreateInitialStateOptions, CustomInstallationStepHandler, ExecuteWorkflowOptions, ExecutionContext, ExecutionStatus, FailedInstallationState, InProgressInstallationState, InferStepOutput, InstallationContext, InstallationData, InstallationError, InstallationHooks, InstallationState, InstallationStatus, LeafStep, LeafStepOptions, RunInstallationOptions, Step, StepContextFactory, StepEvent, StepFailedEvent, StepMeta, StepStartedEvent, StepStatus, StepSucceededEvent, SucceededInstallationState, createInitialInstallationState, createInitialState, defineBranchStep, defineCustomInstallationStep, defineLeafStep, executeWorkflow, isBranchStep, isCompletedState, isFailedState, isInProgressState, isLeafStep, isSucceededState, runInstallation };
|
|
1
|
+
import { A as BranchStep, B as defineBranchStep, C as StepStatus, D as isInProgressState, E as isFailedState, F as LeafStep, H as isBranchStep, I as LeafStepOptions, L as Step, M as ExecutionContext, N as InferStepOutput, O as isSucceededState, P as InstallationContext, R as StepContextFactory, S as InstallationStatus, T as isCompletedState, U as isLeafStep, V as defineLeafStep, _ as FailedInstallationState, a as CustomInstallationStepHandler, b as InstallationError, c as ExecuteWorkflowOptions, d as InstallationHooks, f as StepEvent, g as ExecutionStatus, h as StepSucceededEvent, i as runInstallation, j as BranchStepOptions, k as AnyStep, l as createInitialState, m as StepStartedEvent, n as RunInstallationOptions, o as defineCustomInstallationStep, p as StepFailedEvent, r as createInitialInstallationState, s as CreateInitialStateOptions, t as CreateInitialInstallationStateOptions, u as executeWorkflow, v as InProgressInstallationState, w as SucceededInstallationState, x as InstallationState, y as InstallationData, z as StepMeta } from "../runner-Ds2m27Q4.cjs";
|
|
2
|
+
export { AnyStep, BranchStep, BranchStepOptions, type CreateInitialInstallationStateOptions, CreateInitialStateOptions, type CustomInstallationStepHandler, ExecuteWorkflowOptions, ExecutionContext, ExecutionStatus, FailedInstallationState, InProgressInstallationState, InferStepOutput, InstallationContext, InstallationData, InstallationError, InstallationHooks, InstallationState, InstallationStatus, LeafStep, LeafStepOptions, type RunInstallationOptions, Step, StepContextFactory, StepEvent, StepFailedEvent, StepMeta, StepStartedEvent, StepStatus, StepSucceededEvent, SucceededInstallationState, createInitialInstallationState, createInitialState, defineBranchStep, defineCustomInstallationStep, defineLeafStep, executeWorkflow, isBranchStep, isCompletedState, isFailedState, isInProgressState, isLeafStep, isSucceededState, runInstallation };
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
const require_schemas = require('./schemas-CZ6c8Id9.cjs');
|
|
2
|
+
const require_validate = require('./validate-BegMfe-i.cjs');
|
|
3
|
+
const require_error = require('./error-DJ2UAPH2.cjs');
|
|
4
|
+
let path = require("path");
|
|
5
|
+
let fs = require("fs");
|
|
6
|
+
let fs_promises = require("fs/promises");
|
|
7
|
+
let jiti = require("jiti");
|
|
8
|
+
|
|
9
|
+
//#region source/config/lib/define.ts
|
|
10
|
+
/**
|
|
11
|
+
* Helper to type-safely define the app config.
|
|
12
|
+
* @param config - The app config to define.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { defineConfig } from "@adobe/aio-commerce-lib-app";
|
|
17
|
+
*
|
|
18
|
+
* // In app.commerce.config.js
|
|
19
|
+
* export default defineConfig({
|
|
20
|
+
* // You get autocompletion and type-safety for the config object.
|
|
21
|
+
* businessConfig: { ... }
|
|
22
|
+
* });
|
|
23
|
+
*/
|
|
24
|
+
function defineConfig(config) {
|
|
25
|
+
return config;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region ../../packages-private/scripting-utils/source/project.ts
|
|
30
|
+
/**
|
|
31
|
+
* This module exports shared project utilities for the AIO Commerce SDK.
|
|
32
|
+
* @packageDocumentation
|
|
33
|
+
*/
|
|
34
|
+
/**
|
|
35
|
+
* Find a file by walking up parent directories
|
|
36
|
+
* @param name - The file name to search for (or array of file names)
|
|
37
|
+
* @param options - Search options
|
|
38
|
+
* @returns The path to the file, or undefined if not found
|
|
39
|
+
*/
|
|
40
|
+
async function findUp(name, options = {}) {
|
|
41
|
+
const names = Array.isArray(name) ? name : [name];
|
|
42
|
+
const cwd = options.cwd || process.cwd();
|
|
43
|
+
const { root } = (0, path.parse)(cwd);
|
|
44
|
+
const stopAt = options.stopAt || root;
|
|
45
|
+
let currentDir = cwd;
|
|
46
|
+
while (true) {
|
|
47
|
+
for (const fileName of names) {
|
|
48
|
+
const filePath = (0, path.join)(currentDir, fileName);
|
|
49
|
+
try {
|
|
50
|
+
await (0, fs_promises.access)(filePath);
|
|
51
|
+
return filePath;
|
|
52
|
+
} catch {}
|
|
53
|
+
}
|
|
54
|
+
if (currentDir === stopAt || currentDir === root) return;
|
|
55
|
+
currentDir = (0, path.dirname)(currentDir);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Find the nearest package.json file in the current working directory or its parents
|
|
60
|
+
* @param cwd The current working directory
|
|
61
|
+
*/
|
|
62
|
+
async function findNearestPackageJson(cwd = process.cwd()) {
|
|
63
|
+
const packageJsonPath = await findUp("package.json", { cwd });
|
|
64
|
+
if (!packageJsonPath) return null;
|
|
65
|
+
return packageJsonPath;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Read the package.json file
|
|
69
|
+
* @param cwd The current working directory
|
|
70
|
+
*/
|
|
71
|
+
async function readPackageJson(cwd = process.cwd()) {
|
|
72
|
+
const packageJsonPath = await findNearestPackageJson(cwd);
|
|
73
|
+
if (!packageJsonPath) return null;
|
|
74
|
+
return JSON.parse(await (0, fs_promises.readFile)(packageJsonPath, "utf-8"));
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Check if the current working directory is an ESM project.
|
|
78
|
+
* @param cwd The current working directory
|
|
79
|
+
*/
|
|
80
|
+
async function isESM(cwd = process.cwd()) {
|
|
81
|
+
const packageJson = await readPackageJson(cwd);
|
|
82
|
+
if (!packageJson) throw new Error("Could not find a `package.json` file in the current working directory or its parents.");
|
|
83
|
+
return packageJson.type === "module";
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get the root directory of the project
|
|
87
|
+
* @param cwd The current working directory
|
|
88
|
+
*/
|
|
89
|
+
async function getProjectRootDirectory(cwd = process.cwd()) {
|
|
90
|
+
const packageJsonPath = await findNearestPackageJson(cwd);
|
|
91
|
+
if (!packageJsonPath) throw new Error("Could not find a the root directory of the project. `package.json` file not found.");
|
|
92
|
+
return (0, path.dirname)(packageJsonPath);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Create the output directory for the given file or folder (relative to the project root)
|
|
96
|
+
* @param fileOrFolder - The file or folder to create
|
|
97
|
+
*/
|
|
98
|
+
async function makeOutputDirFor(fileOrFolder) {
|
|
99
|
+
const outputDir = (0, path.join)(await getProjectRootDirectory(), fileOrFolder);
|
|
100
|
+
if (!(0, fs.existsSync)(outputDir)) await (0, fs_promises.mkdir)(outputDir, { recursive: true });
|
|
101
|
+
return outputDir;
|
|
102
|
+
}
|
|
103
|
+
/** Detect the package manager by checking for lock files */
|
|
104
|
+
async function detectPackageManager(cwd = process.cwd()) {
|
|
105
|
+
const rootDirectory = await getProjectRootDirectory(cwd);
|
|
106
|
+
const lockFileMap = {
|
|
107
|
+
"bun.lockb": "bun",
|
|
108
|
+
"pnpm-lock.yaml": "pnpm",
|
|
109
|
+
"yarn.lock": "yarn",
|
|
110
|
+
"package-lock.json": "npm"
|
|
111
|
+
};
|
|
112
|
+
const lockFileName = Object.keys(lockFileMap).find((name) => (0, fs.existsSync)((0, path.join)(rootDirectory, name)));
|
|
113
|
+
if (!lockFileName) return "npm";
|
|
114
|
+
return lockFileMap[lockFileName];
|
|
115
|
+
}
|
|
116
|
+
/** Get the appropriate exec command based on package manager */
|
|
117
|
+
function getExecCommand(packageManager) {
|
|
118
|
+
return {
|
|
119
|
+
pnpm: "pnpx",
|
|
120
|
+
yarn: "yarn dlx",
|
|
121
|
+
bun: "bunx",
|
|
122
|
+
npm: "npx"
|
|
123
|
+
}[packageManager];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region source/config/lib/parser.ts
|
|
128
|
+
const jiti$1 = (0, jiti.createJiti)(require("url").pathToFileURL(__filename).href);
|
|
129
|
+
const configPaths = Object.freeze([
|
|
130
|
+
"app.commerce.config.js",
|
|
131
|
+
"app.commerce.config.ts",
|
|
132
|
+
"app.commerce.config.cjs",
|
|
133
|
+
"app.commerce.config.mjs",
|
|
134
|
+
"app.commerce.config.mts",
|
|
135
|
+
"app.commerce.config.cts"
|
|
136
|
+
]);
|
|
137
|
+
/**
|
|
138
|
+
* Try to find (up to the nearest package.json file) the app config file.
|
|
139
|
+
*
|
|
140
|
+
* Searches for config files in the following order of priority:
|
|
141
|
+
* 1. `app.commerce.config.js` - JavaScript (CommonJS or ESM)
|
|
142
|
+
* 2. `app.commerce.config.ts` - TypeScript
|
|
143
|
+
* 3. `app.commerce.config.cjs` - CommonJS
|
|
144
|
+
* 4. `app.commerce.config.mjs` - ES Module
|
|
145
|
+
* 5. `app.commerce.config.mts` - ES Module TypeScript
|
|
146
|
+
* 6. `app.commerce.config.cts` - CommonJS TypeScript
|
|
147
|
+
*
|
|
148
|
+
* @param cwd The current working directory
|
|
149
|
+
* @returns The path to the config file, or null if not found
|
|
150
|
+
*/
|
|
151
|
+
async function resolveCommerceAppConfig(cwd = process.cwd()) {
|
|
152
|
+
const packageJsonPath = await findNearestPackageJson(cwd);
|
|
153
|
+
if (!packageJsonPath) return null;
|
|
154
|
+
const rootDirectory = (0, path.dirname)(packageJsonPath);
|
|
155
|
+
for (const configPath of configPaths) {
|
|
156
|
+
const configFilePath = await findUp(configPath, {
|
|
157
|
+
cwd,
|
|
158
|
+
stopAt: rootDirectory
|
|
159
|
+
});
|
|
160
|
+
if (configFilePath) return configFilePath;
|
|
161
|
+
}
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Read the commerce app config file as-is, without validating it.
|
|
166
|
+
*
|
|
167
|
+
* Supports multiple config file formats (see {@link resolveCommerceAppConfig} for the list).
|
|
168
|
+
* The config file must export a default export with the configuration object.
|
|
169
|
+
*
|
|
170
|
+
* @param cwd The current working directory
|
|
171
|
+
* @returns The raw config object from the file
|
|
172
|
+
* @throws {Error} If no config file is found or if the file doesn't export a default export
|
|
173
|
+
*/
|
|
174
|
+
async function readCommerceAppConfig(cwd = process.cwd()) {
|
|
175
|
+
const configFilePath = await resolveCommerceAppConfig(cwd);
|
|
176
|
+
if (!configFilePath) throw new Error("Could not find a commerce app config file in the current working directory or its parents.");
|
|
177
|
+
let config = null;
|
|
178
|
+
try {
|
|
179
|
+
config = await jiti$1.import(configFilePath);
|
|
180
|
+
} catch (error) {
|
|
181
|
+
const message = require_error.stringifyError(error);
|
|
182
|
+
throw new Error(`Failed to read commerce app config file at ${configFilePath}: ${message}`, { cause: error });
|
|
183
|
+
}
|
|
184
|
+
if (!(config && "default" in config) || config.default === void 0 || config.default === null || typeof config.default === "object" && Object.keys(config.default).length === 0) throw new Error("Commerce app config file does not export a default export. Make sure you use `export default` or `module.exports = { /* your config */ }`");
|
|
185
|
+
return config.default;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Read the commerce app config file and parse its contents into its schema.
|
|
189
|
+
*
|
|
190
|
+
* Supports multiple config file formats (see {@link resolveCommerceAppConfig} for the list).
|
|
191
|
+
* The config file must export a default export with the configuration object.
|
|
192
|
+
*
|
|
193
|
+
* @param cwd The current working directory
|
|
194
|
+
* @returns The validated and parsed config object
|
|
195
|
+
* @throws {Error} If no config file is found, if the file doesn't export a default export, or if validation fails
|
|
196
|
+
*/
|
|
197
|
+
async function parseCommerceAppConfig(cwd = process.cwd()) {
|
|
198
|
+
return require_validate.validateCommerceAppConfig(await readCommerceAppConfig(cwd));
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
//#endregion
|
|
202
|
+
Object.defineProperty(exports, 'defineConfig', {
|
|
203
|
+
enumerable: true,
|
|
204
|
+
get: function () {
|
|
205
|
+
return defineConfig;
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
Object.defineProperty(exports, 'detectPackageManager', {
|
|
209
|
+
enumerable: true,
|
|
210
|
+
get: function () {
|
|
211
|
+
return detectPackageManager;
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
Object.defineProperty(exports, 'findNearestPackageJson', {
|
|
215
|
+
enumerable: true,
|
|
216
|
+
get: function () {
|
|
217
|
+
return findNearestPackageJson;
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
Object.defineProperty(exports, 'getExecCommand', {
|
|
221
|
+
enumerable: true,
|
|
222
|
+
get: function () {
|
|
223
|
+
return getExecCommand;
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
Object.defineProperty(exports, 'getProjectRootDirectory', {
|
|
227
|
+
enumerable: true,
|
|
228
|
+
get: function () {
|
|
229
|
+
return getProjectRootDirectory;
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
Object.defineProperty(exports, 'isESM', {
|
|
233
|
+
enumerable: true,
|
|
234
|
+
get: function () {
|
|
235
|
+
return isESM;
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
Object.defineProperty(exports, 'makeOutputDirFor', {
|
|
239
|
+
enumerable: true,
|
|
240
|
+
get: function () {
|
|
241
|
+
return makeOutputDirFor;
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
Object.defineProperty(exports, 'parseCommerceAppConfig', {
|
|
245
|
+
enumerable: true,
|
|
246
|
+
get: function () {
|
|
247
|
+
return parseCommerceAppConfig;
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
Object.defineProperty(exports, 'readCommerceAppConfig', {
|
|
251
|
+
enumerable: true,
|
|
252
|
+
get: function () {
|
|
253
|
+
return readCommerceAppConfig;
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
Object.defineProperty(exports, 'readPackageJson', {
|
|
257
|
+
enumerable: true,
|
|
258
|
+
get: function () {
|
|
259
|
+
return readPackageJson;
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
Object.defineProperty(exports, 'resolveCommerceAppConfig', {
|
|
263
|
+
enumerable: true,
|
|
264
|
+
get: function () {
|
|
265
|
+
return resolveCommerceAppConfig;
|
|
266
|
+
}
|
|
267
|
+
});
|