@adobe/aio-commerce-lib-app 1.7.0 → 1.8.0-alpha-20260722091448

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.
Files changed (93) hide show
  1. package/CHANGELOG.md +92 -0
  2. package/dist/cjs/actions/app-config/index.cjs +41 -38
  3. package/dist/cjs/actions/app-config/index.d.cts +1 -1
  4. package/dist/cjs/actions/association/index.cjs +85 -0
  5. package/dist/cjs/actions/{registration → association}/index.d.cts +9 -13
  6. package/dist/cjs/actions/config/index.cjs +21 -32
  7. package/dist/cjs/actions/installation/index.cjs +72 -51
  8. package/dist/cjs/actions/installation/index.d.cts +2 -2
  9. package/dist/cjs/actions/scope-tree/index.cjs +18 -17
  10. package/dist/{es/app-DrYHK-z1.d.mts → cjs/app-BwehWeu1.d.cts} +1237 -1031
  11. package/dist/cjs/commands/index.cjs +523 -301
  12. package/dist/cjs/commands/templates/admin-ui/tsconfig.json +14 -0
  13. package/dist/cjs/commands/templates/admin-ui/web-src/index.css +5 -0
  14. package/dist/cjs/commands/templates/admin-ui/web-src/index.html +17 -0
  15. package/dist/cjs/commands/templates/admin-ui/web-src/src/app.jsx +12 -0
  16. package/dist/cjs/commands/templates/admin-ui/web-src/src/components/welcome.jsx +16 -0
  17. package/dist/cjs/commands/templates/admin-ui/web-src/src/pages/main-page.jsx +10 -0
  18. package/dist/cjs/commands/templates/{admin-ui-sdk/registration.js.template → admin-ui/web-src-template.d.ts} +11 -6
  19. package/dist/cjs/commands/templates/app-management/app-config.js.template +1 -14
  20. package/dist/cjs/commands/templates/app-management/association.js.template +6 -0
  21. package/dist/cjs/commands/templates/app-management/installation.js.template +1 -13
  22. package/dist/cjs/commands/templates/business-configuration/config.js.template +2 -15
  23. package/dist/cjs/commands/templates/business-configuration/scope-tree.js.template +0 -12
  24. package/dist/cjs/config/index.browser.cjs +18 -0
  25. package/dist/cjs/config/index.browser.d.cts +16 -0
  26. package/dist/cjs/config/{index.cjs → index.node.cjs} +9 -8
  27. package/dist/{es/config/index.d.mts → cjs/config/index.node.d.cts} +1065 -394
  28. package/dist/cjs/define-DOqVyexT.d.cts +34 -0
  29. package/dist/cjs/define-hlcQw7Cv.cjs +41 -0
  30. package/dist/cjs/environment-B7EnozSg.cjs +135 -0
  31. package/dist/cjs/{index-B5gJ-q4U.d.cts → index-B3ISkC54.d.cts} +17 -12
  32. package/dist/cjs/index.cjs +268 -0
  33. package/dist/cjs/index.d.cts +230 -0
  34. package/dist/cjs/{config-D-s0GSep.cjs → index.node-BWZuZLgs.cjs} +144 -44
  35. package/dist/cjs/{logging-BVz3weoC.cjs → logging-udPuAJPt.cjs} +2 -2
  36. package/dist/cjs/management/index.cjs +1 -1
  37. package/dist/cjs/management/index.d.cts +1 -1
  38. package/dist/cjs/{management-Dehz9qSJ.cjs → management-DEsRVP2L.cjs} +385 -582
  39. package/dist/cjs/{openapi-Cux6K4ZD.cjs → openapi-CwytYdWl.cjs} +476 -600
  40. package/dist/cjs/repository-CbceYZqc.cjs +69 -0
  41. package/dist/cjs/{router-BOR7T6qR.cjs → router-hA_Y9gZ1.cjs} +42 -44
  42. package/dist/cjs/{schemas-FngDuIeo.cjs → schemas-mLxMh_ko.cjs} +2 -2
  43. package/dist/cjs/utils-DSCmZ_iJ.cjs +408 -0
  44. package/dist/cjs/{validate-oAOpyFyb.cjs → validate-C_eCKp21.cjs} +21 -21
  45. package/dist/cjs/{webhooks-tbZy9G3p.cjs → webhooks-L4DWHSOl.cjs} +159 -151
  46. package/dist/es/actions/app-config/index.d.mts +1 -1
  47. package/dist/es/actions/app-config/index.mjs +39 -36
  48. package/dist/es/actions/{registration → association}/index.d.mts +9 -13
  49. package/dist/es/actions/association/index.mjs +82 -0
  50. package/dist/es/actions/config/index.mjs +17 -28
  51. package/dist/es/actions/installation/index.d.mts +2 -2
  52. package/dist/es/actions/installation/index.mjs +69 -48
  53. package/dist/es/actions/scope-tree/index.mjs +14 -13
  54. package/dist/{cjs/app-DrYHK-z1.d.cts → es/app-BwehWeu1.d.mts} +1237 -1031
  55. package/dist/es/commands/index.mjs +556 -332
  56. package/dist/es/commands/templates/admin-ui/tsconfig.json +14 -0
  57. package/dist/es/commands/templates/admin-ui/web-src/index.css +5 -0
  58. package/dist/es/commands/templates/admin-ui/web-src/index.html +17 -0
  59. package/dist/es/commands/templates/admin-ui/web-src/src/app.jsx +12 -0
  60. package/dist/es/commands/templates/admin-ui/web-src/src/components/welcome.jsx +16 -0
  61. package/dist/es/commands/templates/admin-ui/web-src/src/pages/main-page.jsx +10 -0
  62. package/dist/es/commands/templates/{admin-ui-sdk/registration.js.template → admin-ui/web-src-template.d.ts} +11 -6
  63. package/dist/es/commands/templates/app-management/app-config.js.template +1 -14
  64. package/dist/es/commands/templates/app-management/association.js.template +6 -0
  65. package/dist/es/commands/templates/app-management/installation.js.template +1 -13
  66. package/dist/es/commands/templates/business-configuration/config.js.template +2 -15
  67. package/dist/es/commands/templates/business-configuration/scope-tree.js.template +0 -12
  68. package/dist/es/config/index.browser.d.mts +16 -0
  69. package/dist/es/config/index.browser.mjs +17 -0
  70. package/dist/{cjs/config/index.d.cts → es/config/index.node.d.mts} +1066 -393
  71. package/dist/es/config/{index.mjs → index.node.mjs} +5 -4
  72. package/dist/es/define-DxH1BFia.d.mts +34 -0
  73. package/dist/es/define-Z_Glf1-_.mjs +35 -0
  74. package/dist/es/environment-C84BPRJZ.mjs +104 -0
  75. package/dist/es/{index-DLMbTtKS.d.mts → index-DSk-RmwM.d.mts} +17 -12
  76. package/dist/es/index.d.mts +230 -0
  77. package/dist/es/index.mjs +259 -0
  78. package/dist/es/{config-3I4eLyyR.mjs → index.node-DuvW9Sha.mjs} +113 -39
  79. package/dist/es/management/index.d.mts +1 -1
  80. package/dist/es/management/index.mjs +1 -1
  81. package/dist/es/{management-BUX-w2Ji.mjs → management-D5pmBBec.mjs} +353 -550
  82. package/dist/es/{openapi-B6uP0SRn.mjs → openapi-CXonvevE.mjs} +476 -600
  83. package/dist/es/repository-BGmy0YeZ.mjs +52 -0
  84. package/dist/es/{router-D58JJHHA.mjs → router-B_h0cvjc.mjs} +40 -42
  85. package/dist/es/utils-_gj8L6eN.mjs +289 -0
  86. package/dist/es/{validate-Dfajrp99.mjs → validate-t0T0F2MF.mjs} +18 -18
  87. package/dist/es/{webhooks-B5oq9ULL.mjs → webhooks-D7DExIDM.mjs} +150 -142
  88. package/package.json +40 -17
  89. package/dist/cjs/actions/registration/index.cjs +0 -50
  90. package/dist/cjs/admin-ui-sdk-EU915zlR.d.cts +0 -664
  91. package/dist/es/actions/registration/index.mjs +0 -49
  92. package/dist/es/admin-ui-sdk-BwnD0xjK.d.mts +0 -664
  93. /package/dist/cjs/{chunk-Cozy-1ZF.cjs → rolldown-runtime-Cozy-1ZF.cjs} +0 -0
@@ -0,0 +1,230 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright 2026 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+
15
+ import { AdobeCommerceHttpClient, CommerceHttpClientParams } from "@adobe/aio-commerce-lib-api";
16
+ import { ImsAuthParams, ImsAuthProvider } from "@adobe/aio-commerce-lib-auth";
17
+ import { CommerceEnv } from "@adobe/aio-commerce-lib-core/commerce";
18
+ import { CommerceSdkErrorBase, CommerceSdkErrorBaseOptions } from "@adobe/aio-commerce-lib-core/error";
19
+ import { AdobeIoEventsApiClient } from "@adobe/aio-commerce-lib-events/io-events";
20
+
21
+ //#region source/management/association/types.d.ts
22
+ /** The Commerce instance data an app is associated with. */
23
+ type AssociatedCommerceData = {
24
+ /** Commerce API base URL. */baseUrl: string; /** Deployment type of the Commerce instance. */
25
+ env: CommerceEnv;
26
+ };
27
+ //#endregion
28
+ //#region source/lib/commerce.d.ts
29
+ /**
30
+ * Returns the Commerce instance this app is currently associated with.
31
+ *
32
+ * @throws {AssociationRecordNotFoundError} If the app is not associated, was
33
+ * unassociated, or was associated by an older SDK that did not store this
34
+ * data. Re-associating the app resolves the error.
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * import { getCommerceInstance } from "@adobe/aio-commerce-lib-app";
39
+ *
40
+ * export async function main() {
41
+ * const instance = await getCommerceInstance();
42
+ *
43
+ * // instance.baseUrl — e.g. "https://my-store.example.com"
44
+ * // instance.env — "saas" | "paas"
45
+ * }
46
+ * ```
47
+ */
48
+ declare function getCommerceInstance(): Promise<AssociatedCommerceData>;
49
+ /**
50
+ * Returns an initialised `AdobeCommerceHttpClient` for the Commerce instance
51
+ * this app is currently associated with.
52
+ *
53
+ * The base URL and flavor come from the stored association data
54
+ * ({@link getCommerceInstance}); the caller supplies the resolved IMS auth.
55
+ *
56
+ * @param auth - Resolved IMS auth params or an IMS auth provider.
57
+ * @param fetchOptions - Optional global fetch options forwarded to the
58
+ * underlying `AdobeCommerceHttpClient` (e.g. `headers`, `timeout`, `retry`).
59
+ * @throws {AssociationRecordNotFoundError} If the app is not associated, was
60
+ * unassociated, or was associated by an older SDK that did not store this
61
+ * data. Re-associating the app resolves the error.
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * import { getCommerceClient } from "@adobe/aio-commerce-lib-app";
66
+ * import { resolveImsAuthParams } from "@adobe/aio-commerce-lib-auth";
67
+ *
68
+ * export async function main(params) {
69
+ * const client = await getCommerceClient(resolveImsAuthParams(params));
70
+ * const products = await client.get("products").json();
71
+ * }
72
+ * ```
73
+ */
74
+ declare function getCommerceClient(auth: ImsAuthParams | ImsAuthProvider, fetchOptions?: CommerceHttpClientParams["fetchOptions"]): Promise<AdobeCommerceHttpClient>;
75
+ //#endregion
76
+ //#region source/lib/errors.d.ts
77
+ /**
78
+ * Thrown when a runtime action needs the app's stored association record but it
79
+ * is missing or incomplete — for example, when the app has never been
80
+ * associated, has been unassociated, or was associated by an older SDK that did
81
+ * not store the data being read.
82
+ *
83
+ * Re-associating the app resolves the error.
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * import { getCommerceClient, AssociationRecordNotFoundError } from "@adobe/aio-commerce-lib-app";
88
+ * import { resolveImsAuthParams } from "@adobe/aio-commerce-lib-auth";
89
+ *
90
+ * try {
91
+ * const client = await getCommerceClient(resolveImsAuthParams(params));
92
+ * // ... use client
93
+ * } catch (error) {
94
+ * if (error instanceof AssociationRecordNotFoundError) {
95
+ * // handle the unassociated case (e.g. return a 400 response)
96
+ * }
97
+ * throw error;
98
+ * }
99
+ * ```
100
+ */
101
+ declare class AssociationRecordNotFoundError extends CommerceSdkErrorBase {
102
+ constructor(message?: string, options?: CommerceSdkErrorBaseOptions);
103
+ }
104
+ /**
105
+ * Base error thrown by {@link publishEvent} when event resolution or publishing fails.
106
+ * Catch this to handle all publish-event failures in a single clause.
107
+ */
108
+ declare class PublishEventError extends CommerceSdkErrorBase {}
109
+ /**
110
+ * Thrown when {@link publishEvent} cannot find the eventing installation data in system storage.
111
+ *
112
+ * This typically means the app installation has not run yet, or ran with an older SDK version
113
+ * that did not write event provider metadata to storage. Re-running the installation resolves it.
114
+ *
115
+ * @example
116
+ * ```ts
117
+ * try {
118
+ * await publishEvent({ client, provider: "order-events", event: "order.created", payload });
119
+ * } catch (error) {
120
+ * if (error instanceof EventsDataNotInitializedError) {
121
+ * // Prompt re-installation
122
+ * }
123
+ * }
124
+ * ```
125
+ */
126
+ declare class EventsDataNotInitializedError extends PublishEventError {
127
+ constructor(options?: CommerceSdkErrorBaseOptions);
128
+ }
129
+ /**
130
+ * Thrown when the provider key passed to {@link publishEvent} does not match any provider
131
+ * declared in the app's eventing configuration.
132
+ *
133
+ * @example
134
+ * ```ts
135
+ * try {
136
+ * await publishEvent({ client, provider: "order-events", event: "order.created", payload });
137
+ * } catch (error) {
138
+ * if (error instanceof ProviderNotFoundError) {
139
+ * // "order-events" was not found — check app.commerce.config.ts
140
+ * }
141
+ * }
142
+ * ```
143
+ */
144
+ declare class ProviderNotFoundError extends PublishEventError {
145
+ constructor(providerKey: string, options?: CommerceSdkErrorBaseOptions);
146
+ }
147
+ /**
148
+ * Thrown when the event name passed to {@link publishEvent} does not match any event
149
+ * declared under the given provider in the app's eventing configuration.
150
+ *
151
+ * @example
152
+ * ```ts
153
+ * try {
154
+ * await publishEvent({ client, provider: "order-events", event: "order.created", payload });
155
+ * } catch (error) {
156
+ * if (error instanceof EventNotFoundError) {
157
+ * // "order.created" was not found under "order-events" — check app.commerce.config.ts
158
+ * }
159
+ * }
160
+ * ```
161
+ */
162
+ declare class EventNotFoundError extends PublishEventError {
163
+ constructor(eventName: string, providerKey: string, options?: CommerceSdkErrorBaseOptions);
164
+ }
165
+ //#endregion
166
+ //#region source/lib/events.d.ts
167
+ /**
168
+ * Publishes an event declared in the app's eventing configuration.
169
+ *
170
+ * Resolves the provider key and event name to their respective I/O Events IDs from
171
+ * data written to system storage at installation time, then delegates the HTTP call
172
+ * to the given client. No management API round-trip is needed at runtime.
173
+ *
174
+ * @param params.client - An {@link AdobeIoEventsApiClient} configured with the correct IMS auth.
175
+ * @param params.provider - The `key` of an event provider declared in `app.commerce.config.ts`.
176
+ * @param params.event - The `name` of an event within that provider.
177
+ * @param params.payload - The event payload. Must be a JSON object.
178
+ *
179
+ * @throws {EventsDataNotInitializedError} If no eventing installation data is found in system storage.
180
+ * @throws {ProviderNotFoundError} If the provider key is not found in the stored data.
181
+ * @throws {EventNotFoundError} If the event name is not found under the given provider.
182
+ *
183
+ * @example
184
+ * ```ts
185
+ * import { publishEvent } from "@adobe/aio-commerce-lib-app";
186
+ * import { createAdobeIoEventsApiClient } from "@adobe/aio-commerce-lib-events";
187
+ * import { resolveImsAuthParams } from "@adobe/aio-commerce-lib-auth";
188
+ *
189
+ * export async function main(params) {
190
+ * const client = createAdobeIoEventsApiClient({
191
+ * auth: resolveImsAuthParams(params),
192
+ * config: { ingressBaseUrl: params.AIO_EVENTS_INGRESS_BASE_URL },
193
+ * });
194
+ *
195
+ * await publishEvent({
196
+ * client,
197
+ * provider: "order-events",
198
+ * event: "order.created",
199
+ * payload: { orderId: "100000123", total: 149.99 },
200
+ * });
201
+ * }
202
+ * ```
203
+ */
204
+ declare function publishEvent<TPayload extends Record<string, unknown> = Record<string, unknown>>(params: {
205
+ client: AdobeIoEventsApiClient;
206
+ provider: string;
207
+ event: string;
208
+ payload: TPayload;
209
+ }): Promise<void>;
210
+ /**
211
+ * Resolves the I/O Events event code for an event. Applies the same app-ID namespacing and Commerce-provider prefixing rules used at installation time.
212
+ *
213
+ * @param appId - The application's `metadata.id`, as declared in `app.commerce.config`.
214
+ * @param eventName - The `name` of the event, as declared in `app.commerce.config`.
215
+ * @param providerType - Whether the event belongs to a `"commerce"` or `"external"` provider.
216
+ *
217
+ * @example
218
+ * ```ts
219
+ * import { resolveIoEventCode } from "@adobe/aio-commerce-lib-app";
220
+ *
221
+ * resolveIoEventCode("my-app", "observer.order_placed", "commerce");
222
+ * // => "com.adobe.commerce.my_app.observer.order_placed"
223
+ *
224
+ * resolveIoEventCode("my-app", "webhook.received", "external");
225
+ * // => "my_app.webhook.received"
226
+ * ```
227
+ */
228
+ declare function resolveIoEventCode(appId: string, eventName: string, providerType: "commerce" | "external"): string;
229
+ //#endregion
230
+ export { type AssociatedCommerceData, AssociationRecordNotFoundError, EventNotFoundError, EventsDataNotInitializedError, ProviderNotFoundError, PublishEventError, getCommerceClient, getCommerceInstance, publishEvent, resolveIoEventCode };
@@ -12,34 +12,19 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
+ const require_rolldown_runtime = require('./rolldown-runtime-Cozy-1ZF.cjs');
15
16
  const require_error = require('./error-D-N0PKSl.cjs');
16
- const require_validate = require('./validate-oAOpyFyb.cjs');
17
+ const require_validate = require('./validate-C_eCKp21.cjs');
17
18
  let path = require("path");
18
19
  let fs = require("fs");
19
20
  let fs_promises = require("fs/promises");
21
+ let _npmcli_package_json = require("@npmcli/package-json");
22
+ _npmcli_package_json = require_rolldown_runtime.__toESM(_npmcli_package_json, 1);
23
+ let local_pkg = require("local-pkg");
20
24
  let package_manager_detector = require("package-manager-detector");
21
25
  let package_manager_detector_detect = require("package-manager-detector/detect");
26
+ let semver = require("semver");
22
27
 
23
- //#region source/config/lib/define.ts
24
- /**
25
- * Helper to type-safely define the app config.
26
- * @param config - The app config to define.
27
- *
28
- * @example
29
- * ```typescript
30
- * import { defineConfig } from "@adobe/aio-commerce-lib-app";
31
- *
32
- * // In app.commerce.config.js
33
- * export default defineConfig({
34
- * // You get autocompletion and type-safety for the config object.
35
- * businessConfig: { ... }
36
- * });
37
- */
38
- function defineConfig(config) {
39
- return config;
40
- }
41
-
42
- //#endregion
43
28
  //#region ../../packages-private/scripting-utils/source/project.ts
44
29
  /**
45
30
  * This module exports shared project utilities for the AIO Commerce SDK.
@@ -57,7 +42,7 @@ async function findUp(name, options = {}) {
57
42
  const { root } = (0, path.parse)(cwd);
58
43
  const stopAt = options.stopAt || root;
59
44
  let currentDir = cwd;
60
- while (true) {
45
+ for (;;) {
61
46
  for (const fileName of names) {
62
47
  const filePath = (0, path.join)(currentDir, fileName);
63
48
  try {
@@ -88,6 +73,72 @@ async function readPackageJson(cwd = process.cwd()) {
88
73
  return JSON.parse(await (0, fs_promises.readFile)(packageJsonPath, "utf-8"));
89
74
  }
90
75
  /**
76
+ * Load the nearest package.json file with npmcli's package.json helper.
77
+ * @param cwd The current working directory
78
+ */
79
+ async function loadPackageJson(cwd = process.cwd()) {
80
+ const packageJsonPath = await findNearestPackageJson(cwd);
81
+ if (!packageJsonPath) return null;
82
+ return _npmcli_package_json.default.load((0, path.dirname)(packageJsonPath));
83
+ }
84
+ /**
85
+ * Convert package.json dependencies into a dependency map that can be written back.
86
+ * @param dependencies - Dependency map read from package.json.
87
+ */
88
+ function toWritablePackageJsonDependencies(dependencies) {
89
+ return Object.fromEntries(Object.entries(dependencies).filter((entry) => Boolean(entry[1])));
90
+ }
91
+ /**
92
+ * Resolve the installed package version from a project root.
93
+ * @param packageName - Package name to resolve.
94
+ * @param cwd - Project directory to resolve from.
95
+ */
96
+ async function getInstalledPackageVersion(packageName, cwd = process.cwd()) {
97
+ return (await (0, local_pkg.getPackageInfo)(packageName, { paths: [cwd] }))?.version ?? null;
98
+ }
99
+ /**
100
+ * Resolve which dependencies are missing or installed with incompatible versions.
101
+ *
102
+ * Installed package versions are compared with `semver.satisfies`. Declared
103
+ * package.json ranges are not used as compatibility proof because they can
104
+ * differ from what is actually installed.
105
+ *
106
+ * @param requiredDependencies - Dependencies that should exist.
107
+ * @param cwd - Project directory to resolve installed packages from.
108
+ */
109
+ async function getPackageDependencyInstallPlan(requiredDependencies, cwd = process.cwd()) {
110
+ const plan = {
111
+ incompatible: [],
112
+ missing: []
113
+ };
114
+ const installedVersions = await Promise.all(requiredDependencies.map((dependency) => getInstalledPackageVersion(dependency.name, cwd)));
115
+ requiredDependencies.forEach((dependency, index) => {
116
+ const installedVersion = installedVersions[index];
117
+ if (installedVersion === null) {
118
+ plan.missing.push(dependency);
119
+ return;
120
+ }
121
+ if ((0, semver.validRange)(dependency.version) === null) return;
122
+ if (!(0, semver.satisfies)(installedVersion, dependency.version, { includePrerelease: true })) plan.incompatible.push({
123
+ ...dependency,
124
+ installedVersion
125
+ });
126
+ });
127
+ return plan;
128
+ }
129
+ /**
130
+ * Merge required dependencies into a package.json dependency map when they are missing.
131
+ *
132
+ * @param dependencies - Dependency map to update.
133
+ * @param requiredDependencies - Dependencies that should exist.
134
+ * @param dependencyMaps - Package dependency maps to compare against.
135
+ */
136
+ function mergePackageJsonDependencies(dependencies, requiredDependencies, dependencyMaps = [dependencies]) {
137
+ const nextDependencies = toWritablePackageJsonDependencies(dependencies);
138
+ for (const { name, version } of requiredDependencies) if (!dependencyMaps.some((dependencyMap) => name in dependencyMap)) nextDependencies[name] = version;
139
+ return nextDependencies;
140
+ }
141
+ /**
91
142
  * Check if the current working directory is an ESM project.
92
143
  * @param cwd The current working directory
93
144
  */
@@ -120,6 +171,12 @@ const VALID_PACKAGE_MANAGERS = [
120
171
  "yarn",
121
172
  "bun"
122
173
  ];
174
+ const DEV_DEPENDENCY_INSTALL_FLAGS = {
175
+ bun: "--dev",
176
+ npm: "--save-dev",
177
+ pnpm: "--save-dev",
178
+ yarn: "--dev"
179
+ };
123
180
  /**
124
181
  * Type guard asserting that a value is a supported `PackageManager`.
125
182
  * @param value - The value to check
@@ -153,16 +210,25 @@ function getExecCommand(packageManager) {
153
210
  * manager (e.g. `pnpm add foo bar`, `npm i foo bar`).
154
211
  * @param packageManager - The detected package manager
155
212
  * @param packages - Package specifiers to install (e.g. `["foo@^1.0"]`)
213
+ * @param options - Install command options.
156
214
  */
157
- function getInstallCommand(packageManager, packages) {
158
- const resolved = (0, package_manager_detector.resolveCommand)(packageManager, "add", packages);
159
- if (!resolved) return {
160
- command: "npm",
161
- args: ["install", ...packages]
215
+ function getInstallCommand(packageManager, packages, options = {}) {
216
+ const installArgs = options.dev ? [DEV_DEPENDENCY_INSTALL_FLAGS[packageManager], ...packages] : packages;
217
+ const resolved = (0, package_manager_detector.resolveCommand)(packageManager, "add", installArgs);
218
+ return {
219
+ args: resolved?.args.filter(Boolean) ?? ["install", ...installArgs],
220
+ command: resolved?.command ?? "npm"
162
221
  };
222
+ }
223
+ /**
224
+ * Get the command that installs a project's declared dependencies.
225
+ * @param packageManager - The detected package manager
226
+ */
227
+ function getProjectInstallCommand(packageManager) {
228
+ const resolved = (0, package_manager_detector.resolveCommand)(packageManager, "install", []);
163
229
  return {
164
- args: resolved.args.filter((a) => Boolean(a)),
165
- command: resolved.command
230
+ args: resolved?.args.filter(Boolean) ?? ["install"],
231
+ command: resolved?.command ?? "npm"
166
232
  };
167
233
  }
168
234
 
@@ -203,6 +269,16 @@ async function resolveCommerceAppConfig(cwd = process.cwd()) {
203
269
  }
204
270
  return null;
205
271
  }
272
+ /** Import a commerce app config module. */
273
+ async function importCommerceAppConfig(configFilePath) {
274
+ try {
275
+ const { createJiti } = await import("jiti");
276
+ return await createJiti(require("url").pathToFileURL(__filename).href).import(configFilePath);
277
+ } catch (error) {
278
+ const message = require_error.stringifyError(error);
279
+ throw new Error(`Failed to read commerce app config file at ${configFilePath}: ${message}`, { cause: error });
280
+ }
281
+ }
206
282
  /**
207
283
  * Read the commerce app config file as-is, without validating it.
208
284
  *
@@ -216,17 +292,17 @@ async function resolveCommerceAppConfig(cwd = process.cwd()) {
216
292
  async function readCommerceAppConfig(cwd = process.cwd()) {
217
293
  const configFilePath = await resolveCommerceAppConfig(cwd);
218
294
  if (!configFilePath) throw new Error("Could not find a commerce app config file in the current working directory or its parents.");
219
- let config = null;
220
- try {
221
- const { createJiti } = await import("jiti");
222
- config = await createJiti(require("url").pathToFileURL(__filename).href).import(configFilePath);
223
- } catch (error) {
224
- const message = require_error.stringifyError(error);
225
- throw new Error(`Failed to read commerce app config file at ${configFilePath}: ${message}`, { cause: error });
226
- }
227
- 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 or exports an empty object. Make sure you use `export default` or `module.exports = { /* your config */ }`");
295
+ const config = await importCommerceAppConfig(configFilePath);
296
+ if (!("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 or exports an empty object. Make sure you use `export default` or `module.exports = { /* your config */ }`");
228
297
  return config.default;
229
298
  }
299
+ /** Whether the app config module exports any named symbols alongside its default export. */
300
+ async function hasNamedCommerceAppConfigExports(cwd = process.cwd()) {
301
+ const configFilePath = await resolveCommerceAppConfig(cwd);
302
+ if (!configFilePath) return false;
303
+ const config = await importCommerceAppConfig(configFilePath);
304
+ return Object.keys(config).some((exportName) => exportName !== "default");
305
+ }
230
306
  /**
231
307
  * Read the commerce app config file and parse its contents into its schema.
232
308
  *
@@ -242,12 +318,6 @@ async function parseCommerceAppConfig(cwd = process.cwd()) {
242
318
  }
243
319
 
244
320
  //#endregion
245
- Object.defineProperty(exports, 'defineConfig', {
246
- enumerable: true,
247
- get: function () {
248
- return defineConfig;
249
- }
250
- });
251
321
  Object.defineProperty(exports, 'detectPackageManager', {
252
322
  enumerable: true,
253
323
  get: function () {
@@ -266,24 +336,54 @@ Object.defineProperty(exports, 'getInstallCommand', {
266
336
  return getInstallCommand;
267
337
  }
268
338
  });
339
+ Object.defineProperty(exports, 'getPackageDependencyInstallPlan', {
340
+ enumerable: true,
341
+ get: function () {
342
+ return getPackageDependencyInstallPlan;
343
+ }
344
+ });
345
+ Object.defineProperty(exports, 'getProjectInstallCommand', {
346
+ enumerable: true,
347
+ get: function () {
348
+ return getProjectInstallCommand;
349
+ }
350
+ });
269
351
  Object.defineProperty(exports, 'getProjectRootDirectory', {
270
352
  enumerable: true,
271
353
  get: function () {
272
354
  return getProjectRootDirectory;
273
355
  }
274
356
  });
357
+ Object.defineProperty(exports, 'hasNamedCommerceAppConfigExports', {
358
+ enumerable: true,
359
+ get: function () {
360
+ return hasNamedCommerceAppConfigExports;
361
+ }
362
+ });
275
363
  Object.defineProperty(exports, 'isESM', {
276
364
  enumerable: true,
277
365
  get: function () {
278
366
  return isESM;
279
367
  }
280
368
  });
369
+ Object.defineProperty(exports, 'loadPackageJson', {
370
+ enumerable: true,
371
+ get: function () {
372
+ return loadPackageJson;
373
+ }
374
+ });
281
375
  Object.defineProperty(exports, 'makeOutputDirFor', {
282
376
  enumerable: true,
283
377
  get: function () {
284
378
  return makeOutputDirFor;
285
379
  }
286
380
  });
381
+ Object.defineProperty(exports, 'mergePackageJsonDependencies', {
382
+ enumerable: true,
383
+ get: function () {
384
+ return mergePackageJsonDependencies;
385
+ }
386
+ });
287
387
  Object.defineProperty(exports, 'parseCommerceAppConfig', {
288
388
  enumerable: true,
289
389
  get: function () {
@@ -12,9 +12,9 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
- const require_chunk = require('./chunk-Cozy-1ZF.cjs');
15
+ const require_rolldown_runtime = require('./rolldown-runtime-Cozy-1ZF.cjs');
16
16
  let util = require("util");
17
- util = require_chunk.__toESM(util, 1);
17
+ util = require_rolldown_runtime.__toESM(util, 1);
18
18
 
19
19
  //#region ../../packages-private/common-utils/source/logging.ts
20
20
  /**
@@ -13,7 +13,7 @@
13
13
  */
14
14
 
15
15
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
16
- const require_management = require('../management-Dehz9qSJ.cjs');
16
+ const require_management = require('../management-DEsRVP2L.cjs');
17
17
 
18
18
  exports.createInitialInstallationState = require_management.createInitialInstallationState;
19
19
  exports.createInitialUninstallationState = require_management.createInitialUninstallationState;
@@ -12,5 +12,5 @@
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
14
 
15
- import { $ as StepContextFactory, A as ExecutionStatus, B as isCompletedState, C as executeUninstallWorkflow, D as StepFailedEvent, E as StepEvent, F as InstallationRetryMetadata, G as BranchStep, H as isInProgressState, I as InstallationState, J as InferStepOutput, K as BranchStepOptions, L as InstallationStatus, M as InProgressInstallationState, N as InstallationData, O as StepStartedEvent, P as InstallationError, Q as Step, R as StepStatus, S as createRetryState, T as InstallationHooks, U as isSucceededState, V as isFailedState, W as AnyStep, X as LeafStep, Y as InstallationContext, Z as LeafStepOptions, _ as ValidationSummary, a as RunValidationOptions, at as ValidationIssueSeverity, b as ExecuteWorkflowOptions, c as runInstallation, ct as isBranchStep, d as CustomInstallationStepDefinition, et as StepMeta, f as CustomInstallationStepHandler, g as ValidationResult, h as ValidateStepTreeOptions, i as RunUninstallationOptions, it as ValidationIssue, j as FailedInstallationState, k as StepSucceededEvent, l as runUninstallation, lt as isLeafStep, m as StepValidationResult, n as CreateInitialUninstallationStateOptions, nt as ValidationContext, o as createInitialInstallationState, ot as defineBranchStep, p as defineCustomInstallationStep, q as ExecutionContext, r as RunInstallationOptions, rt as ValidationExecutionContext, s as createInitialUninstallationState, st as defineLeafStep, t as CreateInitialInstallationStateOptions, tt as StepMetaInfo, u as runValidation, v as validateStepTree, w as executeWorkflow, x as createInitialState, y as CreateInitialStateOptions, z as SucceededInstallationState } from "../index-B5gJ-q4U.cjs";
15
+ import { $ as StepContextFactory, A as ExecutionStatus, B as isCompletedState, C as executeUninstallWorkflow, D as StepFailedEvent, E as StepEvent, F as InstallationRetryMetadata, G as BranchStep, H as isInProgressState, I as InstallationState, J as InferStepOutput, K as BranchStepOptions, L as InstallationStatus, M as InProgressInstallationState, N as InstallationData, O as StepStartedEvent, P as InstallationError, Q as Step, R as StepStatus, S as createRetryState, T as InstallationHooks, U as isSucceededState, V as isFailedState, W as AnyStep, X as LeafStep, Y as InstallationContext, Z as LeafStepOptions, _ as ValidationSummary, a as RunValidationOptions, at as ValidationIssueSeverity, b as ExecuteWorkflowOptions, c as runInstallation, ct as isBranchStep, d as CustomInstallationStepDefinition, et as StepMeta, f as CustomInstallationStepHandler, g as ValidationResult, h as ValidateStepTreeOptions, i as RunUninstallationOptions, it as ValidationIssue, j as FailedInstallationState, k as StepSucceededEvent, l as runUninstallation, lt as isLeafStep, m as StepValidationResult, n as CreateInitialUninstallationStateOptions, nt as ValidationContext, o as createInitialInstallationState, ot as defineBranchStep, p as defineCustomInstallationStep, q as ExecutionContext, r as RunInstallationOptions, rt as ValidationExecutionContext, s as createInitialUninstallationState, st as defineLeafStep, t as CreateInitialInstallationStateOptions, tt as StepMetaInfo, u as runValidation, v as validateStepTree, w as executeWorkflow, x as createInitialState, y as CreateInitialStateOptions, z as SucceededInstallationState } from "../index-B3ISkC54.cjs";
16
16
  export { type AnyStep, type BranchStep, type BranchStepOptions, type CreateInitialInstallationStateOptions, type CreateInitialStateOptions, type CreateInitialUninstallationStateOptions, type CustomInstallationStepDefinition, type CustomInstallationStepHandler, type ExecuteWorkflowOptions, type ExecutionContext, type ExecutionStatus, type FailedInstallationState, type InProgressInstallationState, type InferStepOutput, type InstallationContext, type InstallationData, type InstallationError, type InstallationHooks, type InstallationRetryMetadata, type InstallationState, type InstallationStatus, type LeafStep, type LeafStepOptions, type RunInstallationOptions, type RunUninstallationOptions, type RunValidationOptions, type Step, type StepContextFactory, type StepEvent, type StepFailedEvent, type StepMeta, type StepMetaInfo, type StepStartedEvent, type StepStatus, type StepSucceededEvent, type StepValidationResult, type SucceededInstallationState, type ValidateStepTreeOptions, type ValidationContext, type ValidationExecutionContext, type ValidationIssue, type ValidationIssueSeverity, type ValidationResult, type ValidationSummary, createInitialInstallationState, type createInitialState, createInitialUninstallationState, type createRetryState, type defineBranchStep, defineCustomInstallationStep, type defineLeafStep, type executeUninstallWorkflow, type executeWorkflow, type isBranchStep, isCompletedState, isFailedState, isInProgressState, type isLeafStep, isSucceededState, runInstallation, runUninstallation, runValidation, type validateStepTree };