@adobe/aio-commerce-lib-app 1.0.2 → 1.1.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 +23 -0
- package/dist/cjs/actions/app-config.cjs +18 -4
- package/dist/cjs/actions/app-config.d.cts +15 -1
- package/dist/cjs/actions/config.cjs +17 -3
- package/dist/cjs/actions/config.d.cts +14 -0
- package/dist/cjs/actions/installation.cjs +70 -16
- package/dist/cjs/actions/installation.d.cts +16 -2
- package/dist/cjs/actions/scope-tree.cjs +17 -3
- package/dist/cjs/actions/scope-tree.d.cts +14 -0
- package/dist/cjs/{app-DWX5-Hsf.d.cts → app-lymFcs59.d.cts} +146 -1
- package/dist/cjs/commands/index.cjs +41 -27
- package/dist/cjs/commands/index.d.cts +14 -0
- package/dist/cjs/config/index.cjs +27 -12
- package/dist/cjs/config/index.d.cts +576 -4
- package/dist/cjs/{parser-BPpg_9QB.cjs → config-YEeaEqzi.cjs} +17 -3
- package/dist/cjs/error-Dn7ool6k.cjs +38 -0
- package/dist/{es/runner-BD-lItnK.d.mts → cjs/index-DRhLtRrX.d.cts} +102 -4
- package/dist/cjs/logging-4s36JTiN.cjs +39 -0
- package/dist/cjs/management/index.cjs +23 -8
- package/dist/cjs/management/index.d.cts +16 -2
- package/dist/cjs/{runner-NHMvoMO2.cjs → management-PZtLe4Ji.cjs} +371 -30
- package/dist/cjs/{router-DCw7oEQ9.cjs → router-KeQRduO3.cjs} +15 -1
- package/dist/cjs/{schemas-CZ6c8Id9.cjs → schemas-nkIxa8sL.cjs} +34 -0
- package/dist/cjs/{validate-Btzn9ilZ.cjs → validate-CwwYD8aC.cjs} +31 -14
- package/dist/cjs/{installation-CLbceU9F.cjs → webhooks-CbZpv9y_.cjs} +105 -1
- package/dist/es/actions/app-config.d.mts +15 -1
- package/dist/es/actions/app-config.mjs +17 -3
- package/dist/es/actions/config.d.mts +14 -0
- package/dist/es/actions/config.mjs +17 -3
- package/dist/es/actions/installation.d.mts +16 -2
- package/dist/es/actions/installation.mjs +64 -10
- package/dist/es/actions/scope-tree.d.mts +14 -0
- package/dist/es/actions/scope-tree.mjs +17 -3
- package/dist/es/{app-BAiyvNo2.d.mts → app-Ct7Y0NP8.d.mts} +146 -1
- package/dist/es/commands/index.d.mts +14 -0
- package/dist/es/commands/index.mjs +21 -7
- package/dist/es/config/index.d.mts +576 -4
- package/dist/es/config/index.mjs +18 -4
- package/dist/es/{parser-CQZTVG6i.mjs → config-BbrkH0Xt.mjs} +16 -2
- package/dist/es/error-DHlYzkbb.mjs +32 -0
- package/dist/{cjs/runner-DemKouFJ.d.cts → es/index-D33OCH0D.d.mts} +102 -4
- package/dist/es/logging-XIUXDK5T.mjs +32 -0
- package/dist/es/management/index.d.mts +16 -2
- package/dist/es/management/index.mjs +16 -2
- package/dist/es/{runner-vwAhjD5r.mjs → management-CIoVWirU.mjs} +360 -25
- package/dist/es/{router-CJ4VWoCt.mjs → router-BxaxEEu3.mjs} +14 -0
- package/dist/es/{schemas-B8yIv0_b.mjs → schemas-BvPxQwgQ.mjs} +29 -1
- package/dist/es/{validate-DKnju9-R.mjs → validate-qRpfubPo.mjs} +21 -4
- package/dist/es/{installation-BTL9X7iv.mjs → webhooks-NgM6k3_r.mjs} +94 -2
- package/package.json +10 -7
- package/dist/cjs/error-DJ2UAPH2.cjs +0 -24
- package/dist/cjs/logging-IDRQG0as.cjs +0 -25
- package/dist/es/error-CMV3IjBz.mjs +0 -18
- package/dist/es/logging-CzmXDzxI.mjs +0 -18
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
|
|
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 { a as stringValueSchema, i as positiveNumberValueSchema, n as booleanValueSchema, r as nonEmptyStringValueSchema, t as alphaNumericOrHyphenSchema } from "./schemas-BvPxQwgQ.mjs";
|
|
2
16
|
import * as v from "valibot";
|
|
3
17
|
|
|
4
18
|
//#region source/config/schema/eventing.ts
|
|
@@ -198,4 +212,82 @@ function hasCustomInstallationSteps(config) {
|
|
|
198
212
|
}
|
|
199
213
|
|
|
200
214
|
//#endregion
|
|
201
|
-
|
|
215
|
+
//#region source/config/schema/webhooks.ts
|
|
216
|
+
/** Schema for webhook field configuration (name and optional source). */
|
|
217
|
+
const WebhookFieldSchema = v.object({
|
|
218
|
+
name: nonEmptyStringValueSchema("field name"),
|
|
219
|
+
source: v.optional(stringValueSchema("field source"))
|
|
220
|
+
});
|
|
221
|
+
/** Schema for webhook rule configuration (field, operator, value). */
|
|
222
|
+
const WebhookRuleSchema = v.object({
|
|
223
|
+
field: nonEmptyStringValueSchema("rule field"),
|
|
224
|
+
operator: nonEmptyStringValueSchema("rule operator"),
|
|
225
|
+
value: nonEmptyStringValueSchema("rule value")
|
|
226
|
+
});
|
|
227
|
+
/** Schema for webhook header configuration (name, value). */
|
|
228
|
+
const WebhookHeaderSchema = v.object({
|
|
229
|
+
name: nonEmptyStringValueSchema("header name"),
|
|
230
|
+
value: nonEmptyStringValueSchema("header value")
|
|
231
|
+
});
|
|
232
|
+
/** batch_name and hook_name must contain only letters, numbers, and underscores. */
|
|
233
|
+
const WEBHOOK_IDENTIFIER_REGEX = /^[a-zA-Z0-9_]+$/;
|
|
234
|
+
/** Category for conflict detection: validation, append, or modification. */
|
|
235
|
+
const CATEGORIES = [
|
|
236
|
+
"validation",
|
|
237
|
+
"append",
|
|
238
|
+
"modification"
|
|
239
|
+
];
|
|
240
|
+
const CategorySchema = v.picklist(CATEGORIES, `Webhook category must be one of: ${CATEGORIES.join(", ")}`);
|
|
241
|
+
/** Schema for the nested webhook payload without url — used when runtimeAction resolves the URL at runtime. */
|
|
242
|
+
const WebhookDefinitionBaseSchema = v.object({
|
|
243
|
+
webhook_method: nonEmptyStringValueSchema("webhook_method"),
|
|
244
|
+
webhook_type: nonEmptyStringValueSchema("webhook_type"),
|
|
245
|
+
batch_name: v.pipe(nonEmptyStringValueSchema("batch_name"), v.regex(WEBHOOK_IDENTIFIER_REGEX, "batch_name must contain only letters, numbers, and underscores")),
|
|
246
|
+
batch_order: v.optional(positiveNumberValueSchema("batch_order")),
|
|
247
|
+
hook_name: v.pipe(nonEmptyStringValueSchema("hook_name"), v.regex(WEBHOOK_IDENTIFIER_REGEX, "hook_name must contain only letters, numbers, and underscores")),
|
|
248
|
+
priority: v.optional(positiveNumberValueSchema("priority")),
|
|
249
|
+
required: v.optional(booleanValueSchema("required")),
|
|
250
|
+
soft_timeout: v.optional(positiveNumberValueSchema("soft_timeout")),
|
|
251
|
+
timeout: v.optional(positiveNumberValueSchema("timeout")),
|
|
252
|
+
method: nonEmptyStringValueSchema("HTTP method"),
|
|
253
|
+
fallback_error_message: v.optional(stringValueSchema("fallback_error_message")),
|
|
254
|
+
ttl: v.optional(positiveNumberValueSchema("ttl")),
|
|
255
|
+
fields: v.optional(v.array(WebhookFieldSchema, "Expected an array of webhook field objects")),
|
|
256
|
+
rules: v.optional(v.array(WebhookRuleSchema, "Expected an array of webhook rule objects")),
|
|
257
|
+
headers: v.optional(v.array(WebhookHeaderSchema, "Expected an array of webhook header objects"))
|
|
258
|
+
});
|
|
259
|
+
/** Schema for the nested webhook payload with a required url. */
|
|
260
|
+
const WebhookDefinitionWithUrlSchema = v.object({
|
|
261
|
+
...WebhookDefinitionBaseSchema.entries,
|
|
262
|
+
url: v.pipe(stringValueSchema("webhook URL"), v.url("The 'url' field must be a valid absolute URL (e.g., 'https://example.com/webhook')"))
|
|
263
|
+
});
|
|
264
|
+
/** Schema for a webhook entry that resolves its URL from a runtime action. */
|
|
265
|
+
const WebhookEntryWithRuntimeActionSchema = v.object({
|
|
266
|
+
label: nonEmptyStringValueSchema("webhook label"),
|
|
267
|
+
description: nonEmptyStringValueSchema("webhook description"),
|
|
268
|
+
category: v.optional(CategorySchema),
|
|
269
|
+
runtimeAction: nonEmptyStringValueSchema("runtimeAction"),
|
|
270
|
+
requireAdobeAuth: v.optional(booleanValueSchema("requireAdobeAuth")),
|
|
271
|
+
webhook: WebhookDefinitionBaseSchema
|
|
272
|
+
});
|
|
273
|
+
/** Schema for a webhook entry that provides an explicit URL. */
|
|
274
|
+
const WebhookEntryWithUrlSchema = v.object({
|
|
275
|
+
label: nonEmptyStringValueSchema("webhook label"),
|
|
276
|
+
description: nonEmptyStringValueSchema("webhook description"),
|
|
277
|
+
category: v.optional(CategorySchema),
|
|
278
|
+
webhook: WebhookDefinitionWithUrlSchema
|
|
279
|
+
});
|
|
280
|
+
/** Schema for a single webhook entry — either runtimeAction (no url) or explicit url (no runtimeAction). */
|
|
281
|
+
const WebhookEntrySchema = v.union([WebhookEntryWithRuntimeActionSchema, WebhookEntryWithUrlSchema], "Each webhook entry must define either a 'runtimeAction' (to resolve the URL from a runtime action) or an explicit 'url' inside the 'webhook' object, but not both");
|
|
282
|
+
/** Schema for the optional webhooks array (when present, must have at least one item). */
|
|
283
|
+
const WebhooksSchema = v.optional(v.pipe(v.array(WebhookEntrySchema, "Expected an array of webhook entries"), v.minLength(1, "webhooks array must contain at least one webhook when present")));
|
|
284
|
+
/**
|
|
285
|
+
* Check if config has webhooks (non-empty array).
|
|
286
|
+
* @param config - The configuration to check.
|
|
287
|
+
*/
|
|
288
|
+
function hasWebhooks(config) {
|
|
289
|
+
return Array.isArray(config?.webhooks) && config.webhooks.length > 0;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
//#endregion
|
|
293
|
+
export { hasCustomInstallationSteps as a, hasEventing as c, hasCustomInstallation as i, hasExternalEvents as l, hasWebhooks as n, EventingSchema as o, InstallationSchema as r, hasCommerceEvents as s, WebhooksSchema as t };
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@adobe/aio-commerce-lib-app",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"author": "Adobe Inc.",
|
|
5
|
-
"version": "1.0
|
|
5
|
+
"version": "1.1.0",
|
|
6
6
|
"private": false,
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=20 <=24"
|
|
@@ -86,6 +86,7 @@
|
|
|
86
86
|
"consola": "^3.4.2",
|
|
87
87
|
"dotenv": "^17.2.3",
|
|
88
88
|
"jiti": "^2.6.1",
|
|
89
|
+
"ky": "^1.9.0",
|
|
89
90
|
"openwhisk": "^3.21.8",
|
|
90
91
|
"prettier": "^3.8.1",
|
|
91
92
|
"regexparam": "^3.0.0",
|
|
@@ -93,20 +94,21 @@
|
|
|
93
94
|
"type-fest": "^5.0.0",
|
|
94
95
|
"valibot": "^1.1.0",
|
|
95
96
|
"yaml": "^2.8.1",
|
|
96
|
-
"@adobe/aio-commerce-lib-api": "1.0.
|
|
97
|
-
"@adobe/aio-commerce-lib-auth": "1.0.
|
|
98
|
-
"@adobe/aio-commerce-lib-config": "1.0.
|
|
97
|
+
"@adobe/aio-commerce-lib-api": "1.0.1",
|
|
98
|
+
"@adobe/aio-commerce-lib-auth": "1.0.1",
|
|
99
|
+
"@adobe/aio-commerce-lib-config": "1.0.3",
|
|
99
100
|
"@adobe/aio-commerce-lib-core": "1.0.0",
|
|
100
|
-
"@adobe/aio-commerce-lib-events": "1.0.
|
|
101
|
+
"@adobe/aio-commerce-lib-events": "1.0.1",
|
|
102
|
+
"@adobe/aio-commerce-lib-webhooks": "0.1.0"
|
|
101
103
|
},
|
|
102
104
|
"devDependencies": {
|
|
103
|
-
"typescript": "^5.9.
|
|
105
|
+
"typescript": "^5.9.3",
|
|
106
|
+
"@aio-commerce-sdk/common-utils": "0.2.3",
|
|
104
107
|
"@aio-commerce-sdk/config-tsdown": "1.0.1",
|
|
105
108
|
"@aio-commerce-sdk/config-typedoc": "1.0.0",
|
|
106
109
|
"@aio-commerce-sdk/config-typescript": "1.0.0",
|
|
107
110
|
"@aio-commerce-sdk/config-vitest": "1.0.0",
|
|
108
111
|
"@aio-commerce-sdk/scripting-utils": "0.3.0",
|
|
109
|
-
"@aio-commerce-sdk/common-utils": "0.2.2",
|
|
110
112
|
"@aio-commerce-sdk/scripts": "0.1.0"
|
|
111
113
|
},
|
|
112
114
|
"sideEffects": false,
|
|
@@ -118,6 +120,7 @@
|
|
|
118
120
|
"assist": "biome check --formatter-enabled=false --linter-enabled=false --assist-enabled=true --no-errors-on-unmatched",
|
|
119
121
|
"assist:apply": "biome check --write --formatter-enabled=false --linter-enabled=false --assist-enabled=true --no-errors-on-unmatched",
|
|
120
122
|
"check:ci": "biome ci --formatter-enabled=true --linter-enabled=true --assist-enabled=true --no-errors-on-unmatched",
|
|
123
|
+
"code:fix": "pnpm run lint:fix && pnpm run assist:apply && pnpm run format && pnpm run format:markdown",
|
|
121
124
|
"format": "biome format --write --no-errors-on-unmatched",
|
|
122
125
|
"format:markdown": "prettier --no-error-on-unmatched-pattern --write '**/*.md' \"!**/{CODE_OF_CONDUCT.md,COPYRIGHT,LICENSE,SECURITY.md,CONTRIBUTING.md}\"",
|
|
123
126
|
"format:check": "biome format --no-errors-on-unmatched",
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
const require_schemas = require('./schemas-CZ6c8Id9.cjs');
|
|
2
|
-
let _adobe_aio_commerce_lib_core_error = require("@adobe/aio-commerce-lib-core/error");
|
|
3
|
-
|
|
4
|
-
//#region ../../packages-private/scripting-utils/source/error.ts
|
|
5
|
-
/**
|
|
6
|
-
* This module exports shared error utilities for the AIO Commerce SDK.
|
|
7
|
-
* @packageDocumentation
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Stringify an error to a human-friendly string.
|
|
11
|
-
* @param error - The error to stringify.
|
|
12
|
-
*/
|
|
13
|
-
function stringifyError(error) {
|
|
14
|
-
if (error instanceof _adobe_aio_commerce_lib_core_error.CommerceSdkValidationError) return error.display();
|
|
15
|
-
return error instanceof Error ? error.message : String(error);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
Object.defineProperty(exports, 'stringifyError', {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
get: function () {
|
|
22
|
-
return stringifyError;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const require_schemas = require('./schemas-CZ6c8Id9.cjs');
|
|
2
|
-
let util = require("util");
|
|
3
|
-
util = require_schemas.__toESM(util);
|
|
4
|
-
|
|
5
|
-
//#region ../../packages-private/common-utils/source/logging.ts
|
|
6
|
-
/**
|
|
7
|
-
* Shorthand to inspect an object.
|
|
8
|
-
*
|
|
9
|
-
* @param obj - The object to inspect.
|
|
10
|
-
* @returns A string representation of the object.
|
|
11
|
-
*/
|
|
12
|
-
function inspect(obj, params = {}) {
|
|
13
|
-
return util.default.inspect(obj, {
|
|
14
|
-
depth: null,
|
|
15
|
-
...params
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
//#endregion
|
|
20
|
-
Object.defineProperty(exports, 'inspect', {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
get: function () {
|
|
23
|
-
return inspect;
|
|
24
|
-
}
|
|
25
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { CommerceSdkValidationError } from "@adobe/aio-commerce-lib-core/error";
|
|
2
|
-
|
|
3
|
-
//#region ../../packages-private/scripting-utils/source/error.ts
|
|
4
|
-
/**
|
|
5
|
-
* This module exports shared error utilities for the AIO Commerce SDK.
|
|
6
|
-
* @packageDocumentation
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Stringify an error to a human-friendly string.
|
|
10
|
-
* @param error - The error to stringify.
|
|
11
|
-
*/
|
|
12
|
-
function stringifyError(error) {
|
|
13
|
-
if (error instanceof CommerceSdkValidationError) return error.display();
|
|
14
|
-
return error instanceof Error ? error.message : String(error);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
//#endregion
|
|
18
|
-
export { stringifyError as t };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import util from "util";
|
|
2
|
-
|
|
3
|
-
//#region ../../packages-private/common-utils/source/logging.ts
|
|
4
|
-
/**
|
|
5
|
-
* Shorthand to inspect an object.
|
|
6
|
-
*
|
|
7
|
-
* @param obj - The object to inspect.
|
|
8
|
-
* @returns A string representation of the object.
|
|
9
|
-
*/
|
|
10
|
-
function inspect(obj, params = {}) {
|
|
11
|
-
return util.inspect(obj, {
|
|
12
|
-
depth: null,
|
|
13
|
-
...params
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
//#endregion
|
|
18
|
-
export { inspect as t };
|