@adobe/aio-commerce-lib-webhooks 0.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 +15 -0
- package/LICENSE +201 -0
- package/README.md +20 -0
- package/dist/cjs/api/index.cjs +201 -0
- package/dist/cjs/api/index.d.cts +199 -0
- package/dist/cjs/responses/index.cjs +151 -0
- package/dist/cjs/responses/index.d.cts +175 -0
- package/dist/es/api/index.d.mts +199 -0
- package/dist/es/api/index.mjs +166 -0
- package/dist/es/responses/index.d.mts +175 -0
- package/dist/es/responses/index.mjs +144 -0
- package/package.json +95 -0
|
@@ -0,0 +1,151 @@
|
|
|
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
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
16
|
+
const require_api_index = require('../api/index.cjs');
|
|
17
|
+
let _adobe_aio_commerce_lib_core_responses = require("@adobe/aio-commerce-lib-core/responses");
|
|
18
|
+
|
|
19
|
+
//#region source/responses/operations/presets.ts
|
|
20
|
+
/**
|
|
21
|
+
* Creates a success operation response
|
|
22
|
+
* The process that triggered the original event continues without any changes.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* return successOperation();
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
const successOperation = () => ({ op: "success" });
|
|
30
|
+
/**
|
|
31
|
+
* Creates an exception operation response with a message
|
|
32
|
+
* Causes Commerce to terminate the process that triggered the original event.
|
|
33
|
+
*
|
|
34
|
+
* @param message - Exception message
|
|
35
|
+
* @param exceptionClass - Optional exception class name
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* return exceptionOperation("The product cannot be added to the cart because it is out of stock");
|
|
40
|
+
*
|
|
41
|
+
* return exceptionOperation(
|
|
42
|
+
* "Custom error occurred",
|
|
43
|
+
* "Path\\To\\Exception\\Class"
|
|
44
|
+
* );
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
const exceptionOperation = (message, exceptionClass) => {
|
|
48
|
+
return {
|
|
49
|
+
op: "exception",
|
|
50
|
+
...message && { message },
|
|
51
|
+
...exceptionClass && { class: exceptionClass }
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Creates an add operation response
|
|
56
|
+
* Causes Commerce to add the provided value to the provided path in the triggered event arguments.
|
|
57
|
+
*
|
|
58
|
+
* @template TValue - The type of the value to be added
|
|
59
|
+
* @param path - Path at which the value should be added
|
|
60
|
+
* @param value - Value to be added
|
|
61
|
+
* @param instance - Optional DataObject class name
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* return addOperation(
|
|
66
|
+
* "result",
|
|
67
|
+
* { data: { amount: "5", carrier_code: "newshipmethod" } },
|
|
68
|
+
* "Magento\\Quote\\Api\\Data\\ShippingMethodInterface"
|
|
69
|
+
* );
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
const addOperation = (path, value, instance) => ({
|
|
73
|
+
op: "add",
|
|
74
|
+
path,
|
|
75
|
+
value,
|
|
76
|
+
...instance && { instance }
|
|
77
|
+
});
|
|
78
|
+
/**
|
|
79
|
+
* Creates a replace operation response
|
|
80
|
+
* Causes Commerce to replace a value in triggered event arguments for the provided path.
|
|
81
|
+
*
|
|
82
|
+
* @template TValue - The type of the replacement value
|
|
83
|
+
* @param path - Path at which the value should be replaced
|
|
84
|
+
* @param value - Replacement value
|
|
85
|
+
* @param instance - Optional DataObject class name
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* return replaceOperation("result/shipping_methods/shipping_method_one/amount", 6);
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
const replaceOperation = (path, value, instance) => ({
|
|
93
|
+
op: "replace",
|
|
94
|
+
path,
|
|
95
|
+
value,
|
|
96
|
+
...instance && { instance }
|
|
97
|
+
});
|
|
98
|
+
/**
|
|
99
|
+
* Creates a remove operation response
|
|
100
|
+
* Causes Commerce to remove a value or node in triggered event arguments by the provided path.
|
|
101
|
+
*
|
|
102
|
+
* @param path - Path at which the value should be removed
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* return removeOperation("result/key2");
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
const removeOperation = (path) => ({
|
|
110
|
+
op: "remove",
|
|
111
|
+
path
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
//#endregion
|
|
115
|
+
//#region source/responses/presets.ts
|
|
116
|
+
/**
|
|
117
|
+
* Creates an HTTP 200 OK response with webhook operation(s)
|
|
118
|
+
* Webhook-optimized version of ok() that automatically wraps operations in the response body.
|
|
119
|
+
*
|
|
120
|
+
* This function shadows the core library's ok() to provide a cleaner API for webhook actions.
|
|
121
|
+
* Instead of `ok({ body: operation })`, you can simply use `ok(operation)`.
|
|
122
|
+
*
|
|
123
|
+
* @template TValue - The type of the value for add/replace operations (defaults to unknown)
|
|
124
|
+
* @param operations - Single webhook operation or array of operations
|
|
125
|
+
* @returns Success response with operations in body
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* import { ok, successOperation } from "@adobe/aio-commerce-lib-webhooks/responses";
|
|
130
|
+
*
|
|
131
|
+
* // Single operation
|
|
132
|
+
* return ok(successOperation());
|
|
133
|
+
*
|
|
134
|
+
* // Array of operations
|
|
135
|
+
* return ok([
|
|
136
|
+
* addOperation("result", data),
|
|
137
|
+
* removeOperation("result/old_field")
|
|
138
|
+
* ]);
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
function ok(operations) {
|
|
142
|
+
return (0, _adobe_aio_commerce_lib_core_responses.ok)({ body: operations });
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
//#endregion
|
|
146
|
+
exports.addOperation = addOperation;
|
|
147
|
+
exports.exceptionOperation = exceptionOperation;
|
|
148
|
+
exports.ok = ok;
|
|
149
|
+
exports.removeOperation = removeOperation;
|
|
150
|
+
exports.replaceOperation = replaceOperation;
|
|
151
|
+
exports.successOperation = successOperation;
|
|
@@ -0,0 +1,175 @@
|
|
|
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 { SuccessResponse } from "@adobe/aio-commerce-lib-core/responses";
|
|
16
|
+
|
|
17
|
+
//#region source/responses/operations/types.d.ts
|
|
18
|
+
/**
|
|
19
|
+
* Success operation response
|
|
20
|
+
* The process that triggered the original event continues without any changes.
|
|
21
|
+
*/
|
|
22
|
+
type SuccessOperation = {
|
|
23
|
+
op: "success";
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Exception operation response
|
|
27
|
+
* Causes Commerce to terminate the process that triggered the original event.
|
|
28
|
+
*/
|
|
29
|
+
type ExceptionOperation = {
|
|
30
|
+
op: "exception"; /** Specifies the exception class. If not set, \Magento\Framework\Exception\LocalizedException will be thrown. */
|
|
31
|
+
class?: string; /** Specifies the exception message. If not set, fallbackErrorMessage or system default will be used. */
|
|
32
|
+
message?: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Add operation response
|
|
36
|
+
* Causes Commerce to add the provided value to the provided path in the triggered event arguments.
|
|
37
|
+
* @template TValue - The type of the value to be added (defaults to unknown)
|
|
38
|
+
*/
|
|
39
|
+
type AddOperation<TValue = unknown> = {
|
|
40
|
+
op: "add"; /** Specifies the path at which the value should be added to the triggered event arguments. */
|
|
41
|
+
path: string; /** Specifies the value to be added. This can be a single value or in an array format. */
|
|
42
|
+
value: TValue; /** Specifies the DataObject class name to create, based on the value and added to the provided path. */
|
|
43
|
+
instance?: string;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Replace operation response
|
|
47
|
+
* Causes Commerce to replace a value in triggered event arguments for the provided path.
|
|
48
|
+
* @template TValue - The type of the replacement value (defaults to unknown)
|
|
49
|
+
*/
|
|
50
|
+
type ReplaceOperation<TValue = unknown> = {
|
|
51
|
+
op: "replace"; /** Specifies the path at which the value should be replaced with the provided value. */
|
|
52
|
+
path: string; /** Specifies the replacement value. This can be a single value or in an array format. */
|
|
53
|
+
value: TValue; /** Specifies the DataObject class name to create, based on the value and added to the provided path. */
|
|
54
|
+
instance?: string;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Remove operation response
|
|
58
|
+
* Causes Commerce to remove a value or node in triggered event arguments by the provided path.
|
|
59
|
+
*/
|
|
60
|
+
type RemoveOperation = {
|
|
61
|
+
op: "remove"; /** Specifies the path at which the value should be removed. */
|
|
62
|
+
path: string;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Union type representing any webhook operation response
|
|
66
|
+
*
|
|
67
|
+
* @template TValue - The type of the value for operations that carry a value (defaults to unknown)
|
|
68
|
+
*/
|
|
69
|
+
type WebhookOperationResponse<TValue = unknown> = SuccessOperation | ExceptionOperation | AddOperation<TValue> | ReplaceOperation<TValue> | RemoveOperation;
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region source/responses/operations/presets.d.ts
|
|
72
|
+
/**
|
|
73
|
+
* Creates a success operation response
|
|
74
|
+
* The process that triggered the original event continues without any changes.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* return successOperation();
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
declare const successOperation: () => SuccessOperation;
|
|
82
|
+
/**
|
|
83
|
+
* Creates an exception operation response with a message
|
|
84
|
+
* Causes Commerce to terminate the process that triggered the original event.
|
|
85
|
+
*
|
|
86
|
+
* @param message - Exception message
|
|
87
|
+
* @param exceptionClass - Optional exception class name
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* return exceptionOperation("The product cannot be added to the cart because it is out of stock");
|
|
92
|
+
*
|
|
93
|
+
* return exceptionOperation(
|
|
94
|
+
* "Custom error occurred",
|
|
95
|
+
* "Path\\To\\Exception\\Class"
|
|
96
|
+
* );
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
declare const exceptionOperation: (message: string, exceptionClass?: string) => ExceptionOperation;
|
|
100
|
+
/**
|
|
101
|
+
* Creates an add operation response
|
|
102
|
+
* Causes Commerce to add the provided value to the provided path in the triggered event arguments.
|
|
103
|
+
*
|
|
104
|
+
* @template TValue - The type of the value to be added
|
|
105
|
+
* @param path - Path at which the value should be added
|
|
106
|
+
* @param value - Value to be added
|
|
107
|
+
* @param instance - Optional DataObject class name
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* return addOperation(
|
|
112
|
+
* "result",
|
|
113
|
+
* { data: { amount: "5", carrier_code: "newshipmethod" } },
|
|
114
|
+
* "Magento\\Quote\\Api\\Data\\ShippingMethodInterface"
|
|
115
|
+
* );
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
declare const addOperation: <TValue = unknown>(path: string, value: TValue, instance?: string) => AddOperation<TValue>;
|
|
119
|
+
/**
|
|
120
|
+
* Creates a replace operation response
|
|
121
|
+
* Causes Commerce to replace a value in triggered event arguments for the provided path.
|
|
122
|
+
*
|
|
123
|
+
* @template TValue - The type of the replacement value
|
|
124
|
+
* @param path - Path at which the value should be replaced
|
|
125
|
+
* @param value - Replacement value
|
|
126
|
+
* @param instance - Optional DataObject class name
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* return replaceOperation("result/shipping_methods/shipping_method_one/amount", 6);
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
declare const replaceOperation: <TValue = unknown>(path: string, value: TValue, instance?: string) => ReplaceOperation<TValue>;
|
|
134
|
+
/**
|
|
135
|
+
* Creates a remove operation response
|
|
136
|
+
* Causes Commerce to remove a value or node in triggered event arguments by the provided path.
|
|
137
|
+
*
|
|
138
|
+
* @param path - Path at which the value should be removed
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* return removeOperation("result/key2");
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
declare const removeOperation: (path: string) => RemoveOperation;
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region source/responses/presets.d.ts
|
|
148
|
+
/**
|
|
149
|
+
* Creates an HTTP 200 OK response with webhook operation(s)
|
|
150
|
+
* Webhook-optimized version of ok() that automatically wraps operations in the response body.
|
|
151
|
+
*
|
|
152
|
+
* This function shadows the core library's ok() to provide a cleaner API for webhook actions.
|
|
153
|
+
* Instead of `ok({ body: operation })`, you can simply use `ok(operation)`.
|
|
154
|
+
*
|
|
155
|
+
* @template TValue - The type of the value for add/replace operations (defaults to unknown)
|
|
156
|
+
* @param operations - Single webhook operation or array of operations
|
|
157
|
+
* @returns Success response with operations in body
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```typescript
|
|
161
|
+
* import { ok, successOperation } from "@adobe/aio-commerce-lib-webhooks/responses";
|
|
162
|
+
*
|
|
163
|
+
* // Single operation
|
|
164
|
+
* return ok(successOperation());
|
|
165
|
+
*
|
|
166
|
+
* // Array of operations
|
|
167
|
+
* return ok([
|
|
168
|
+
* addOperation("result", data),
|
|
169
|
+
* removeOperation("result/old_field")
|
|
170
|
+
* ]);
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
declare function ok<TValue = unknown>(operations: WebhookOperationResponse<TValue> | WebhookOperationResponse[]): SuccessResponse;
|
|
174
|
+
//#endregion
|
|
175
|
+
export { type AddOperation, type ExceptionOperation, type RemoveOperation, type ReplaceOperation, type SuccessOperation, type WebhookOperationResponse, addOperation, exceptionOperation, ok, removeOperation, replaceOperation, successOperation };
|
|
@@ -0,0 +1,199 @@
|
|
|
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 * as _adobe_aio_commerce_lib_api0 from "@adobe/aio-commerce-lib-api";
|
|
16
|
+
import { AdobeCommerceHttpClient, ApiFunction, CommerceHttpClientParams } from "@adobe/aio-commerce-lib-api";
|
|
17
|
+
import * as v from "valibot";
|
|
18
|
+
import { Options } from "ky";
|
|
19
|
+
|
|
20
|
+
//#region source/api/webhooks/schema.d.ts
|
|
21
|
+
/**
|
|
22
|
+
* Schema for the webhook payload sent to POST /webhooks/subscribe.
|
|
23
|
+
* Matches the `webhook` property of the request body.
|
|
24
|
+
* Required fields per the Commerce API: webhook_method, webhook_type, batch_name, hook_name, url.
|
|
25
|
+
*/
|
|
26
|
+
declare const WebhookSubscribeParamsSchema: v.ObjectSchema<{
|
|
27
|
+
readonly webhook_method: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string for ${string}`>, v.NonEmptyAction<string, `${string} must not be empty`>]>;
|
|
28
|
+
readonly webhook_type: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string for ${string}`>, v.NonEmptyAction<string, `${string} must not be empty`>]>;
|
|
29
|
+
readonly batch_name: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string for ${string}`>, v.NonEmptyAction<string, `${string} must not be empty`>]>;
|
|
30
|
+
readonly batch_order: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
31
|
+
readonly hook_name: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string for ${string}`>, v.NonEmptyAction<string, `${string} must not be empty`>]>;
|
|
32
|
+
readonly url: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string for ${string}`>, v.NonEmptyAction<string, `${string} must not be empty`>]>;
|
|
33
|
+
readonly priority: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
34
|
+
readonly required: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
35
|
+
readonly soft_timeout: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
36
|
+
readonly timeout: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
37
|
+
readonly method: v.OptionalSchema<v.StringSchema<`Expected a string for ${string}`>, undefined>;
|
|
38
|
+
readonly fallback_error_message: v.OptionalSchema<v.StringSchema<`Expected a string for ${string}`>, undefined>;
|
|
39
|
+
readonly ttl: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
40
|
+
readonly fields: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
41
|
+
readonly name: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string for ${string}`>, v.NonEmptyAction<string, `${string} must not be empty`>]>;
|
|
42
|
+
readonly source: v.OptionalSchema<v.StringSchema<`Expected a string for ${string}`>, undefined>;
|
|
43
|
+
}, undefined>, "Expected an array of field objects">, undefined>;
|
|
44
|
+
readonly rules: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
45
|
+
readonly field: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string for ${string}`>, v.NonEmptyAction<string, `${string} must not be empty`>]>;
|
|
46
|
+
readonly operator: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string for ${string}`>, v.NonEmptyAction<string, `${string} must not be empty`>]>;
|
|
47
|
+
readonly value: v.StringSchema<"Expected a string for rule value">;
|
|
48
|
+
}, undefined>, "Expected an array of rule objects">, undefined>;
|
|
49
|
+
readonly headers: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
50
|
+
readonly name: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string for ${string}`>, v.NonEmptyAction<string, `${string} must not be empty`>]>;
|
|
51
|
+
readonly value: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string for ${string}`>, v.NonEmptyAction<string, `${string} must not be empty`>]>;
|
|
52
|
+
}, undefined>, "Expected an array of header objects">, undefined>;
|
|
53
|
+
readonly developer_console_oauth: v.OptionalSchema<v.ObjectSchema<{
|
|
54
|
+
readonly client_id: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string for ${string}`>, v.NonEmptyAction<string, `${string} must not be empty`>]>;
|
|
55
|
+
readonly client_secret: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string for ${string}`>, v.NonEmptyAction<string, `${string} must not be empty`>]>;
|
|
56
|
+
readonly org_id: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string for ${string}`>, v.NonEmptyAction<string, `${string} must not be empty`>]>;
|
|
57
|
+
readonly environment: v.OptionalSchema<v.StringSchema<`Expected a string for ${string}`>, undefined>;
|
|
58
|
+
}, undefined>, undefined>;
|
|
59
|
+
}, undefined>;
|
|
60
|
+
/**
|
|
61
|
+
* Schema for the parameters sent to POST /webhooks/unsubscribe.
|
|
62
|
+
* Required: webhook_method, webhook_type, batch_name, hook_name.
|
|
63
|
+
*/
|
|
64
|
+
declare const WebhookUnsubscribeParamsSchema: v.ObjectSchema<{
|
|
65
|
+
readonly webhook_method: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string for ${string}`>, v.NonEmptyAction<string, `${string} must not be empty`>]>;
|
|
66
|
+
readonly webhook_type: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string for ${string}`>, v.NonEmptyAction<string, `${string} must not be empty`>]>;
|
|
67
|
+
readonly batch_name: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string for ${string}`>, v.NonEmptyAction<string, `${string} must not be empty`>]>;
|
|
68
|
+
readonly hook_name: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string for ${string}`>, v.NonEmptyAction<string, `${string} must not be empty`>]>;
|
|
69
|
+
}, undefined>;
|
|
70
|
+
/**
|
|
71
|
+
* The parameters for POST /webhooks/subscribe.
|
|
72
|
+
* @see https://developer.adobe.com/commerce/extensibility/webhooks/api/#subscribe-a-webhook
|
|
73
|
+
*/
|
|
74
|
+
type WebhookSubscribeParams = v.InferInput<typeof WebhookSubscribeParamsSchema>;
|
|
75
|
+
/**
|
|
76
|
+
* The parameters for POST /webhooks/unsubscribe.
|
|
77
|
+
* @see https://developer.adobe.com/commerce/extensibility/webhooks/api/#unsubscribe-a-webhook
|
|
78
|
+
*/
|
|
79
|
+
type WebhookUnsubscribeParams = v.InferInput<typeof WebhookUnsubscribeParamsSchema>;
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region source/api/webhooks/types.d.ts
|
|
82
|
+
/** A field mapping in a Commerce webhook subscription. */
|
|
83
|
+
type CommerceWebhookField = {
|
|
84
|
+
name: string;
|
|
85
|
+
source?: string;
|
|
86
|
+
};
|
|
87
|
+
/** A conditional rule in a Commerce webhook subscription. */
|
|
88
|
+
type CommerceWebhookRule = {
|
|
89
|
+
field: string;
|
|
90
|
+
operator: string;
|
|
91
|
+
value: string;
|
|
92
|
+
};
|
|
93
|
+
/** A custom HTTP header in a Commerce webhook subscription. */
|
|
94
|
+
type CommerceWebhookHeader = {
|
|
95
|
+
name: string;
|
|
96
|
+
value: string;
|
|
97
|
+
};
|
|
98
|
+
/** Developer Console OAuth credentials attached to a webhook. */
|
|
99
|
+
type CommerceWebhookDeveloperConsoleOAuth = {
|
|
100
|
+
client_id: string;
|
|
101
|
+
client_secret: string;
|
|
102
|
+
org_id: string;
|
|
103
|
+
environment?: string;
|
|
104
|
+
};
|
|
105
|
+
/** A single Commerce webhook subscription as returned by GET /webhooks/list. */
|
|
106
|
+
type CommerceWebhook = {
|
|
107
|
+
webhook_method: string;
|
|
108
|
+
webhook_type: string;
|
|
109
|
+
batch_name: string;
|
|
110
|
+
batch_order?: number;
|
|
111
|
+
hook_name: string;
|
|
112
|
+
url: string;
|
|
113
|
+
priority?: number;
|
|
114
|
+
required?: boolean;
|
|
115
|
+
soft_timeout?: number;
|
|
116
|
+
timeout?: number;
|
|
117
|
+
method?: string;
|
|
118
|
+
fallback_error_message?: string;
|
|
119
|
+
ttl?: number;
|
|
120
|
+
fields?: CommerceWebhookField[];
|
|
121
|
+
rules?: CommerceWebhookRule[];
|
|
122
|
+
headers?: CommerceWebhookHeader[];
|
|
123
|
+
developer_console_oauth?: CommerceWebhookDeveloperConsoleOAuth;
|
|
124
|
+
};
|
|
125
|
+
/** The response type for GET /webhooks/list. */
|
|
126
|
+
type CommerceWebhookManyResponse = CommerceWebhook[];
|
|
127
|
+
/** A single entry from GET /webhooks/supportedList (SaaS only). */
|
|
128
|
+
type CommerceSupportedWebhook = {
|
|
129
|
+
name: string;
|
|
130
|
+
};
|
|
131
|
+
/** The response type for GET /webhooks/supportedList. */
|
|
132
|
+
type CommerceSupportedWebhookManyResponse = CommerceSupportedWebhook[];
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region source/api/webhooks/endpoints.d.ts
|
|
135
|
+
/**
|
|
136
|
+
* Returns a list of all subscribed webhooks in the Commerce instance.
|
|
137
|
+
* @see https://developer.adobe.com/commerce/extensibility/webhooks/api/#get-a-list-of-all-subscribed-webhooks
|
|
138
|
+
*
|
|
139
|
+
* @param httpClient - The {@link AdobeCommerceHttpClient} to use to make the request.
|
|
140
|
+
* @param fetchOptions - The {@link Options} to use to make the request.
|
|
141
|
+
*/
|
|
142
|
+
declare function getWebhookList(httpClient: AdobeCommerceHttpClient, fetchOptions?: Options): Promise<CommerceWebhookManyResponse>;
|
|
143
|
+
/**
|
|
144
|
+
* Subscribes a webhook in the Commerce instance.
|
|
145
|
+
* @see https://developer.adobe.com/commerce/extensibility/webhooks/api/#subscribe-a-webhook
|
|
146
|
+
*
|
|
147
|
+
* @param httpClient - The {@link AdobeCommerceHttpClient} to use to make the request.
|
|
148
|
+
* @param params - The webhook payload (webhook_method, webhook_type, batch_name, hook_name, url, etc.).
|
|
149
|
+
* @param fetchOptions - The {@link Options} to use to make the request.
|
|
150
|
+
*
|
|
151
|
+
* @throws A {@link CommerceSdkValidationError} If the parameters are in the wrong format.
|
|
152
|
+
* @throws An {@link HTTPError} If the status code is not 2XX.
|
|
153
|
+
*/
|
|
154
|
+
declare function subscribeWebhook(httpClient: AdobeCommerceHttpClient, params: WebhookSubscribeParams, fetchOptions?: Options): Promise<void>;
|
|
155
|
+
/**
|
|
156
|
+
* Unsubscribes a webhook from the Commerce instance.
|
|
157
|
+
* @see https://developer.adobe.com/commerce/extensibility/webhooks/api/#unsubscribe-a-webhook
|
|
158
|
+
*
|
|
159
|
+
* @param httpClient - The {@link AdobeCommerceHttpClient} to use to make the request.
|
|
160
|
+
* @param params - The webhook identifiers (webhook_method, webhook_type, batch_name, hook_name).
|
|
161
|
+
* @param fetchOptions - The {@link Options} to use to make the request.
|
|
162
|
+
*
|
|
163
|
+
* @throws A {@link CommerceSdkValidationError} If the parameters are in the wrong format.
|
|
164
|
+
* @throws An {@link HTTPError} If the status code is not 2XX.
|
|
165
|
+
*/
|
|
166
|
+
declare function unsubscribeWebhook(httpClient: AdobeCommerceHttpClient, params: WebhookUnsubscribeParams, fetchOptions?: Options): Promise<void>;
|
|
167
|
+
/**
|
|
168
|
+
* Returns the list of webhooks supported in Adobe Commerce as a Cloud Service (SaaS only).
|
|
169
|
+
* @see https://developer.adobe.com/commerce/extensibility/webhooks/api/#get-supported-webhooks-for-saas
|
|
170
|
+
*
|
|
171
|
+
* @param httpClient - The {@link AdobeCommerceHttpClient} to use to make the request.
|
|
172
|
+
* @param fetchOptions - The {@link Options} to use to make the request.
|
|
173
|
+
*/
|
|
174
|
+
declare function getSupportedWebhookList(httpClient: AdobeCommerceHttpClient, fetchOptions?: Options): Promise<CommerceSupportedWebhookManyResponse>;
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region source/lib/api-client.d.ts
|
|
177
|
+
/**
|
|
178
|
+
* Creates a new API client for the Commerce Webhooks API.
|
|
179
|
+
* @param params - The parameters to build the Commerce HTTP client.
|
|
180
|
+
*/
|
|
181
|
+
declare function createCommerceWebhooksApiClient(params: CommerceHttpClientParams): _adobe_aio_commerce_lib_api0.ApiClientRecord<AdobeCommerceHttpClient, {
|
|
182
|
+
getWebhookList: typeof getWebhookList;
|
|
183
|
+
subscribeWebhook: typeof subscribeWebhook;
|
|
184
|
+
unsubscribeWebhook: typeof unsubscribeWebhook;
|
|
185
|
+
getSupportedWebhookList: typeof getSupportedWebhookList;
|
|
186
|
+
}>;
|
|
187
|
+
/**
|
|
188
|
+
* An API client for the Commerce Webhooks API.
|
|
189
|
+
* @see {@link createCommerceWebhooksApiClient}
|
|
190
|
+
*/
|
|
191
|
+
type CommerceWebhooksApiClient = ReturnType<typeof createCommerceWebhooksApiClient>;
|
|
192
|
+
/**
|
|
193
|
+
* Creates a customized Commerce Webhooks API client with a user-specified set of endpoint functions.
|
|
194
|
+
* @param params - The parameters to build the Commerce HTTP client.
|
|
195
|
+
* @param functions - The API functions to include in the client.
|
|
196
|
+
*/
|
|
197
|
+
declare function createCustomCommerceWebhooksApiClient<TFunctions extends Record<string, ApiFunction<AdobeCommerceHttpClient, any[], any>>>(params: CommerceHttpClientParams, functions: TFunctions): _adobe_aio_commerce_lib_api0.ApiClientRecord<AdobeCommerceHttpClient, TFunctions>;
|
|
198
|
+
//#endregion
|
|
199
|
+
export { type CommerceSupportedWebhook, type CommerceSupportedWebhookManyResponse, type CommerceWebhook, type CommerceWebhookDeveloperConsoleOAuth, type CommerceWebhookField, type CommerceWebhookHeader, type CommerceWebhookManyResponse, type CommerceWebhookRule, type CommerceWebhooksApiClient, type WebhookSubscribeParams, type WebhookUnsubscribeParams, createCommerceWebhooksApiClient, createCustomCommerceWebhooksApiClient, getSupportedWebhookList, getWebhookList, subscribeWebhook, unsubscribeWebhook };
|