@adobe/aio-commerce-lib-events 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.
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright 2025 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
+ var __create=Object.create,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from==`object`||typeof from==`function`)for(var keys=__getOwnPropNames(from),i=0,n=keys.length,key;i<n;i++)key=keys[i],!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:(k=>from[k]).bind(null,key),enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__toESM=(mod,isNodeMode,target)=>(target=mod==null?{}:__create(__getProtoOf(mod)),__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,`default`,{value:mod,enumerable:!0}):target,mod));const __adobe_aio_commerce_lib_core_error=__toESM(require(`@adobe/aio-commerce-lib-core/error`)),valibot=__toESM(require(`valibot`)),__adobe_aio_commerce_lib_auth=__toESM(require(`@adobe/aio-commerce-lib-auth`)),UPPERCASE=/[\p{Lu}]/u,LOWERCASE=/[\p{Ll}]/u,LEADING_CAPITAL=/^[\p{Lu}](?![\p{Lu}])/gu,IDENTIFIER=/([\p{Alpha}\p{N}_]|$)/u,SEPARATORS=/[_.\- ]+/,LEADING_SEPARATORS=RegExp(`^`+SEPARATORS.source),SEPARATORS_AND_IDENTIFIER=new RegExp(SEPARATORS.source+IDENTIFIER.source,`gu`),NUMBERS_AND_IDENTIFIER=RegExp(`\\d+`+IDENTIFIER.source,`gu`),preserveCamelCase=(string,toLowerCase,toUpperCase,preserveConsecutiveUppercase$1)=>{let isLastCharLower=!1,isLastCharUpper=!1,isLastLastCharUpper=!1,isLastLastCharPreserved=!1;for(let index=0;index<string.length;index++){let character=string[index];isLastLastCharPreserved=index>2?string[index-3]===`-`:!0,isLastCharLower&&UPPERCASE.test(character)?(string=string.slice(0,index)+`-`+string.slice(index),isLastCharLower=!1,isLastLastCharUpper=isLastCharUpper,isLastCharUpper=!0,index++):isLastCharUpper&&isLastLastCharUpper&&LOWERCASE.test(character)&&(!isLastLastCharPreserved||preserveConsecutiveUppercase$1)?(string=string.slice(0,index-1)+`-`+string.slice(index-1),isLastLastCharUpper=isLastCharUpper,isLastCharUpper=!1,isLastCharLower=!0):(isLastCharLower=toLowerCase(character)===character&&toUpperCase(character)!==character,isLastLastCharUpper=isLastCharUpper,isLastCharUpper=toUpperCase(character)===character&&toLowerCase(character)!==character)}return string},preserveConsecutiveUppercase=(input,toLowerCase)=>(LEADING_CAPITAL.lastIndex=0,input.replaceAll(LEADING_CAPITAL,match=>toLowerCase(match))),postProcess=(input,toUpperCase)=>(SEPARATORS_AND_IDENTIFIER.lastIndex=0,NUMBERS_AND_IDENTIFIER.lastIndex=0,input.replaceAll(NUMBERS_AND_IDENTIFIER,(match,pattern,offset)=>[`_`,`-`].includes(input.charAt(offset+match.length))?match:toUpperCase(match)).replaceAll(SEPARATORS_AND_IDENTIFIER,(_,identifier)=>toUpperCase(identifier)));function camelCase(input,options){if(!(typeof input==`string`||Array.isArray(input)))throw TypeError("Expected the input to be `string | string[]`");if(options={pascalCase:!1,preserveConsecutiveUppercase:!1,...options},input=Array.isArray(input)?input.map(x=>x.trim()).filter(x=>x.length).join(`-`):input.trim(),input.length===0)return``;let toLowerCase=options.locale===!1?string=>string.toLowerCase():string=>string.toLocaleLowerCase(options.locale),toUpperCase=options.locale===!1?string=>string.toUpperCase():string=>string.toLocaleUpperCase(options.locale);if(input.length===1)return SEPARATORS.test(input)?``:options.pascalCase?toUpperCase(input):toLowerCase(input);let hasUpperCase=input!==toLowerCase(input);return hasUpperCase&&(input=preserveCamelCase(input,toLowerCase,toUpperCase,options.preserveConsecutiveUppercase)),input=input.replace(LEADING_SEPARATORS,``),input=options.preserveConsecutiveUppercase?preserveConsecutiveUppercase(input,toLowerCase):toLowerCase(input),options.pascalCase&&(input=toUpperCase(input.charAt(0))+input.slice(1)),postProcess(input,toUpperCase)}function buildObjectKeyTransformerResponseHook(transformer,recursive=!0){let transformObject=obj=>{if(typeof obj!=`object`||!obj)return obj;if(Array.isArray(obj))return recursive?obj.map(transformObject):obj;let transformedData=Object.fromEntries(Object.entries(obj).map(([key,value])=>{let transformedKey=transformer(key),transformedValue=recursive?transformObject(value):value;return[transformedKey,transformedValue]}));return transformedData};return(_req,_opt,response)=>response.json().then(data=>{let transformedData=transformObject(data);return new Response(JSON.stringify(transformedData),response)})}function buildCamelCaseKeysResponseHook(){return buildObjectKeyTransformerResponseHook(camelCase)}function parseOrThrow(schema,input){let result=valibot.safeParse(schema,input);if(!result.success)throw new __adobe_aio_commerce_lib_core_error.CommerceSdkValidationError(`Invalid input`,{issues:result.issues});return result.output}const ALPHANUMERIC_OR_UNDERSCORE_REGEX=/^[a-zA-Z0-9_]+$/,ALPHANUMERIC_OR_UNDERSCORE_OR_HYPHEN_REGEX=/^[a-zA-Z0-9_-]+$/;function stringValueSchema(propertyName){return valibot.string(`Expected a string value for property '${propertyName}'`)}function booleanValueSchema(propertyName){return valibot.boolean(`Expected a boolean value for property '${propertyName}'`)}function alphaNumericOrUnderscoreSchema(name){return valibot.pipe(stringValueSchema(name),valibot.regex(ALPHANUMERIC_OR_UNDERSCORE_REGEX,`Only alphanumeric characters and underscores are allowed for "${name}"`))}function alphaNumericOrUnderscoreOrHyphenSchema(name){return valibot.pipe(stringValueSchema(name),valibot.regex(ALPHANUMERIC_OR_UNDERSCORE_OR_HYPHEN_REGEX,`Only alphanumeric characters, underscores, and hyphens are allowed for property "${name}"`))}var ApiClient=class{static create(client,functions){let wrapped={};for(let key in functions)if(Object.hasOwn(functions,key)){let fn=functions[key];wrapped[key]=((...args)=>fn(client,...args))}return wrapped}},HttpClientBase=class HttpClientBase{#httpClient;constructor(config,httpClient){this.#httpClient=Object.freeze(httpClient),this.config=Object.freeze(config),this.get=this.#httpClient.get.bind(this.#httpClient),this.post=this.#httpClient.post.bind(this.#httpClient),this.put=this.#httpClient.put.bind(this.#httpClient),this.delete=this.#httpClient.delete.bind(this.#httpClient),this.patch=this.#httpClient.patch.bind(this.#httpClient),this.head=this.#httpClient.head.bind(this.#httpClient),this.stop=this.#httpClient.stop}extend(options){let client=Object.freeze(this.#httpClient.extend(options));return new HttpClientBase(this.config,client)}};function isAuthProvider(auth){return`getHeaders`in auth}function buildIntegrationAuthBeforeRequestHook(integrationAuth){let integrationAuthProvider=isAuthProvider(integrationAuth)?integrationAuth:(0,__adobe_aio_commerce_lib_auth.getIntegrationAuthProvider)(integrationAuth);return request=>{let headers=integrationAuthProvider.getHeaders(request.method.toUpperCase(),request.url);request.headers.set(`Authorization`,headers.Authorization)}}function buildImsAuthBeforeRequestHook(imsAuth){let imsAuthProvider=isAuthProvider(imsAuth)?imsAuth:(0,__adobe_aio_commerce_lib_auth.getImsAuthProvider)(imsAuth);return async request=>{let headers=await imsAuthProvider.getHeaders();request.headers.set(`Authorization`,headers.Authorization),request.headers.set(`x-api-key`,headers[`x-api-key`])}}function ensureImsScopes(imsAuth,requiredScopes){let scopes=new Set([...imsAuth.scopes??[],...requiredScopes]);return{...imsAuth,scopes:Array.from(scopes)}}function optionallyExtendKy(ky,options){return options?ky.extend(options):ky}Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return optionallyExtendKy}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return ensureImsScopes}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return buildImsAuthBeforeRequestHook}}),Object.defineProperty(exports,`e`,{enumerable:!0,get:function(){return buildIntegrationAuthBeforeRequestHook}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return isAuthProvider}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return HttpClientBase}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return ApiClient}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return alphaNumericOrUnderscoreOrHyphenSchema}}),Object.defineProperty(exports,`j`,{enumerable:!0,get:function(){return alphaNumericOrUnderscoreSchema}}),Object.defineProperty(exports,`k`,{enumerable:!0,get:function(){return booleanValueSchema}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return stringValueSchema}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return parseOrThrow}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return buildCamelCaseKeysResponseHook}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return __export}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return __toESM}});
@@ -0,0 +1,316 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright 2025 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 v from "valibot";
16
+ import * as ky0 from "ky";
17
+ import { Options } from "ky";
18
+ import { CamelCasedPropertiesDeep } from "type-fest";
19
+
20
+ //#region source/commerce/api/event-providers/schema.d.ts
21
+ declare const EventProviderGetByIdParamsSchema: v.ObjectSchema<{
22
+ readonly providerId: v.StringSchema<`Expected a string value for property '${string}'`>;
23
+ }, undefined>;
24
+ declare const EventProviderCreateParamsSchema: v.ObjectSchema<{
25
+ readonly providerId: v.StringSchema<`Expected a string value for property '${string}'`>;
26
+ readonly instanceId: v.StringSchema<`Expected a string value for property '${string}'`>;
27
+ readonly label: v.OptionalSchema<v.StringSchema<`Expected a string value for property '${string}'`>, undefined>;
28
+ readonly description: v.OptionalSchema<v.StringSchema<`Expected a string value for property '${string}'`>, undefined>;
29
+ readonly associatedWorkspaceConfiguration: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for property '${string}'`>, v.EmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for property '${string}'`>, v.ParseJsonAction<string, undefined, `Expected valid JSON string for property '${string}'`>, v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, v.StringifyJsonAction<{
30
+ [x: string]: unknown;
31
+ }, undefined, undefined>]>, v.SchemaWithPipe<readonly [v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, v.StringifyJsonAction<{
32
+ [x: string]: unknown;
33
+ }, undefined, `Expected valid JSON data for property '${string}'`>]>], undefined>, undefined>;
34
+ }, undefined>;
35
+ /**
36
+ * The schema of the parameters received by the GET `eventing/eventProvider/:id` Commerce API endpoint.
37
+ * @see https://developer.adobe.com/commerce/extensibility/events/api/#get-event-provider-by-id
38
+ */
39
+ type EventProviderGetByIdParams = v.InferInput<typeof EventProviderGetByIdParamsSchema>;
40
+ /**
41
+ * The schema of the parameters received by the POST `eventing/eventProvider` Commerce API endpoint.
42
+ * @see https://developer.adobe.com/commerce/extensibility/events/api/#create-an-event-provider
43
+ */
44
+ type EventProviderCreateParams = v.InferInput<typeof EventProviderCreateParamsSchema>;
45
+ //#endregion
46
+ //#region source/commerce/api/event-providers/types.d.ts
47
+ /** Defines the structure of a Commerce event provider. */
48
+ type CommerceEventProvider = {
49
+ id: string;
50
+ provider_id: string;
51
+ instance_id?: string;
52
+ label?: string;
53
+ description?: string;
54
+ workspace_configuration?: string;
55
+ };
56
+ /** Defines the fields of an event provider entity returned by the Commerce API. */
57
+ type CommerceEventProviderOneResponse = CamelCasedPropertiesDeep<CommerceEventProvider>;
58
+ /** Defines the fields of many event provider entities returned by the Commerce API. */
59
+ type CommerceEventProviderManyResponse = CommerceEventProviderOneResponse[];
60
+ //#endregion
61
+ //#region source/commerce/api/event-providers/endpoints.d.ts
62
+ /**
63
+ * Lists all event providers of the Commerce instance bound to the given {@link AdobeCommerceHttpClient}.
64
+ * @see https://developer.adobe.com/commerce/extensibility/events/api/#get-list-of-all-event-providers
65
+ *
66
+ * @param httpClient - The {@link AdobeCommerceHttpClient} to use to make the request.
67
+ * @param params - The parameters to list the event providers with.
68
+ * @param fetchOptions - The {@link Options} to use to make the request.
69
+ *
70
+ * @throws An {@link HTTPError} If the status code is not 2XX.
71
+ */
72
+ declare function getAllEventProviders(httpClient: AdobeCommerceHttpClient$3, fetchOptions?: Options): Promise<CommerceEventProviderManyResponse>;
73
+ /**
74
+ * Gets the info of the event provider with the given ID of the Commerce instance bound to the given {@link AdobeCommerceHttpClient}.
75
+ * @see https://developer.adobe.com/commerce/extensibility/events/api/#get-event-provider-by-id
76
+ *
77
+ * @param httpClient - The {@link AdobeCommerceHttpClient} to use to make the request.
78
+ * @param params - The parameters to get the event provider by.
79
+ * @param fetchOptions - The {@link Options} to use to make the request.
80
+ *
81
+ * @throws A {@link CommerceSdkValidationError} If the parameters are in the wrong format.
82
+ * @throws An {@link HTTPError} If the status code is not 2XX.
83
+ */
84
+ declare function getEventProviderById(httpClient: AdobeCommerceHttpClient$3, params: EventProviderGetByIdParams, fetchOptions?: Options): Promise<{
85
+ id: string;
86
+ providerId: string;
87
+ instanceId?: string | undefined;
88
+ label?: string | undefined;
89
+ description?: string | undefined;
90
+ workspaceConfiguration?: string | undefined;
91
+ }>;
92
+ /**
93
+ * Creates an event provider in the Commerce instance bound to the given {@link AdobeCommerceHttpClient}.
94
+ * @see https://developer.adobe.com/commerce/extensibility/events/api/#create-an-event-provider
95
+ *
96
+ * @param httpClient - The {@link AdobeCommerceHttpClient} to use to make the request.
97
+ * @param params - The parameters to create the event provider with.
98
+ * @param fetchOptions - The {@link Options} to use to make the request.
99
+ *
100
+ * @throws A {@link CommerceSdkValidationError} If the parameters are in the wrong format.
101
+ * @throws An {@link HTTPError} If the status code is not 2XX.
102
+ */
103
+ declare function createEventProvider(httpClient: AdobeCommerceHttpClient$3, params: EventProviderCreateParams, fetchOptions?: Options): Promise<{
104
+ id: string;
105
+ providerId: string;
106
+ instanceId?: string | undefined;
107
+ label?: string | undefined;
108
+ description?: string | undefined;
109
+ workspaceConfiguration?: string | undefined;
110
+ }>;
111
+ //#endregion
112
+ //#region source/commerce/api/event-subscriptions/schema.d.ts
113
+ declare const EventSubscriptionCreateParamsSchema: v.ObjectSchema<{
114
+ readonly name: v.StringSchema<`Expected a string value for property '${string}'`>;
115
+ readonly providerId: v.OptionalSchema<v.StringSchema<`Expected a string value for property '${string}'`>, undefined>;
116
+ readonly parent: v.OptionalSchema<v.StringSchema<`Expected a string value for property '${string}'`>, undefined>;
117
+ readonly fields: v.ArraySchema<v.ObjectSchema<{
118
+ readonly name: v.StringSchema<`Expected a string value for property '${string}'`>;
119
+ }, undefined>, `Expected an array of objects with a 'name' property for the property "${string}"`>;
120
+ readonly destination: v.OptionalSchema<v.StringSchema<`Expected a string value for property '${string}'`>, undefined>;
121
+ readonly hipaaAuditRequired: v.OptionalSchema<v.BooleanSchema<`Expected a boolean value for property '${string}'`>, undefined>;
122
+ readonly prioritary: v.OptionalSchema<v.BooleanSchema<`Expected a boolean value for property '${string}'`>, undefined>;
123
+ readonly force: v.OptionalSchema<v.BooleanSchema<`Expected a boolean value for property '${string}'`>, undefined>;
124
+ }, undefined>;
125
+ /**
126
+ * The schema of the parameters received by the POST `eventing/eventSubscribe` Commerce API endpoint.
127
+ * @see https://developer.adobe.com/commerce/extensibility/events/api/#subscribe-to-events
128
+ */
129
+ type EventSubscriptionCreateParams = v.InferInput<typeof EventSubscriptionCreateParamsSchema>;
130
+ //#endregion
131
+ //#region source/commerce/api/event-subscriptions/types.d.ts
132
+ /** Defines the structure of a field in a Commerce event subscription. */
133
+ type CommerceEventSubscriptionField = {
134
+ name: string;
135
+ converter?: string;
136
+ };
137
+ /** Defines the structure of a filtering rule in a Commerce event subscription. */
138
+ type CommerceEventSubscriptionRule = {
139
+ field: string;
140
+ value: string;
141
+ operator: string;
142
+ };
143
+ /** Defines the structure of a Commerce event subscription. */
144
+ type CommerceEventSubscription = {
145
+ name: string;
146
+ parent: string;
147
+ provider_id: "default" | string;
148
+ fields: CommerceEventSubscriptionField[];
149
+ rules: CommerceEventSubscriptionRule[];
150
+ destination: "default" | string;
151
+ priority: boolean;
152
+ hipaa_audit_required: boolean;
153
+ };
154
+ /** Defines the fields of an event subscription entity returned by the Commerce API. */
155
+ type CommerceEventSubscriptionOneResponse = CamelCasedPropertiesDeep<CommerceEventSubscription>;
156
+ /** Defines the fields of many event subscription entities returned by the Commerce API. */
157
+ type CommerceEventSubscriptionManyResponse = CommerceEventSubscriptionOneResponse[];
158
+ //#endregion
159
+ //#region source/commerce/api/event-subscriptions/endpoints.d.ts
160
+ /**
161
+ * Gets all event subscriptions in the Commerce instance bound to the given {@link AdobeCommerceHttpClient}.
162
+ * @see https://developer.adobe.com/commerce/extensibility/events/api/#get-a-list-of-all-subscribed-events
163
+ *
164
+ * @param httpClient - The {@link AdobeCommerceHttpClient} to use to make the request.
165
+ * @param fetchOptions - The {@link Options} to use to make the request.
166
+ */
167
+ declare function getAllEventSubscriptions(httpClient: AdobeCommerceHttpClient$2, fetchOptions?: Options): Promise<CommerceEventSubscriptionManyResponse>;
168
+ /**
169
+ * Creates an event subscription in the Commerce instance bound to the given {@link AdobeCommerceHttpClient}.
170
+ * @see https://developer.adobe.com/commerce/extensibility/events/api/#subscribe-to-events
171
+ *
172
+ * @param httpClient - The {@link AdobeCommerceHttpClient} to use to make the request.
173
+ * @param params - The parameters to create the event subscription with.
174
+ * @param fetchOptions - The {@link Options} to use to make the request.
175
+ *
176
+ * @throws A {@link CommerceSdkValidationError} If the parameters are in the wrong format.
177
+ * @throws An {@link HTTPError} If the status code is not 2XX.
178
+ */
179
+ declare function createEventSubscription(httpClient: AdobeCommerceHttpClient$2, params: EventSubscriptionCreateParams, fetchOptions?: Options): void;
180
+ //#endregion
181
+ //#region source/commerce/api/eventing-configuration/schema.d.ts
182
+ /** The schema of the parameters received by the `updateConfiguration` Commerce Eventing API endpoint. */
183
+ declare const UpdateEventingConfigurationParamsSchema: Omit<v.ObjectSchema<{
184
+ readonly enabled: v.BooleanSchema<`Expected a boolean value for property '${string}'`>;
185
+ readonly providerId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for property '${string}'`>, v.RegexAction<string, `Only alphanumeric characters, underscores, and hyphens are allowed for property "${string}"`>]>;
186
+ readonly instanceId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for property '${string}'`>, v.RegexAction<string, `Only alphanumeric characters, underscores, and hyphens are allowed for property "${string}"`>]>;
187
+ readonly merchantId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for property '${string}'`>, v.RegexAction<string, `Only alphanumeric characters and underscores are allowed for "${string}"`>]>;
188
+ readonly environmentId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for property '${string}'`>, v.RegexAction<string, `Only alphanumeric characters and underscores are allowed for "${string}"`>]>;
189
+ readonly workspaceConfiguration: v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for property '${string}'`>, v.EmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for property '${string}'`>, v.ParseJsonAction<string, undefined, `Expected valid JSON string for property '${string}'`>, v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, v.StringifyJsonAction<{
190
+ [x: string]: unknown;
191
+ }, undefined, undefined>]>, v.SchemaWithPipe<readonly [v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, v.StringifyJsonAction<{
192
+ [x: string]: unknown;
193
+ }, undefined, `Expected valid JSON data for property '${string}'`>]>], undefined>;
194
+ }, undefined>, "~types" | "~run" | "~standard" | "entries"> & {
195
+ readonly entries: {
196
+ readonly enabled: v.OptionalSchema<v.BooleanSchema<`Expected a boolean value for property '${string}'`>, undefined>;
197
+ readonly providerId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for property '${string}'`>, v.RegexAction<string, `Only alphanumeric characters, underscores, and hyphens are allowed for property "${string}"`>]>, undefined>;
198
+ readonly instanceId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for property '${string}'`>, v.RegexAction<string, `Only alphanumeric characters, underscores, and hyphens are allowed for property "${string}"`>]>, undefined>;
199
+ readonly merchantId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for property '${string}'`>, v.RegexAction<string, `Only alphanumeric characters and underscores are allowed for "${string}"`>]>, undefined>;
200
+ readonly environmentId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for property '${string}'`>, v.RegexAction<string, `Only alphanumeric characters and underscores are allowed for "${string}"`>]>, undefined>;
201
+ readonly workspaceConfiguration: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for property '${string}'`>, v.EmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for property '${string}'`>, v.ParseJsonAction<string, undefined, `Expected valid JSON string for property '${string}'`>, v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, v.StringifyJsonAction<{
202
+ [x: string]: unknown;
203
+ }, undefined, undefined>]>, v.SchemaWithPipe<readonly [v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, v.StringifyJsonAction<{
204
+ [x: string]: unknown;
205
+ }, undefined, `Expected valid JSON data for property '${string}'`>]>], undefined>, undefined>;
206
+ };
207
+ readonly '~standard': v.StandardProps<{
208
+ enabled?: boolean | undefined;
209
+ providerId?: string | undefined;
210
+ instanceId?: string | undefined;
211
+ merchantId?: string | undefined;
212
+ environmentId?: string | undefined;
213
+ workspaceConfiguration?: string | {
214
+ [x: string]: unknown;
215
+ } | undefined;
216
+ }, {
217
+ enabled?: boolean | undefined;
218
+ providerId?: string | undefined;
219
+ instanceId?: string | undefined;
220
+ merchantId?: string | undefined;
221
+ environmentId?: string | undefined;
222
+ workspaceConfiguration?: string | undefined;
223
+ }>;
224
+ readonly '~run': (dataset: v.UnknownDataset, config: v.Config<v.BaseIssue<unknown>>) => v.OutputDataset<{
225
+ enabled?: boolean | undefined;
226
+ providerId?: string | undefined;
227
+ instanceId?: string | undefined;
228
+ merchantId?: string | undefined;
229
+ environmentId?: string | undefined;
230
+ workspaceConfiguration?: string | undefined;
231
+ }, v.StringIssue | v.EmptyIssue<string> | v.ParseJsonIssue<string> | v.RecordIssue | v.StringifyJsonIssue<{
232
+ [x: string]: unknown;
233
+ }> | v.UnionIssue<v.StringIssue | v.EmptyIssue<string> | v.ParseJsonIssue<string> | v.RecordIssue | v.StringifyJsonIssue<{
234
+ [x: string]: unknown;
235
+ }>> | v.ObjectIssue | v.BooleanIssue | v.RegexIssue<string>>;
236
+ readonly '~types'?: {
237
+ readonly input: {
238
+ enabled?: boolean | undefined;
239
+ providerId?: string | undefined;
240
+ instanceId?: string | undefined;
241
+ merchantId?: string | undefined;
242
+ environmentId?: string | undefined;
243
+ workspaceConfiguration?: string | {
244
+ [x: string]: unknown;
245
+ } | undefined;
246
+ };
247
+ readonly output: {
248
+ enabled?: boolean | undefined;
249
+ providerId?: string | undefined;
250
+ instanceId?: string | undefined;
251
+ merchantId?: string | undefined;
252
+ environmentId?: string | undefined;
253
+ workspaceConfiguration?: string | undefined;
254
+ };
255
+ readonly issue: v.StringIssue | v.EmptyIssue<string> | v.ParseJsonIssue<string> | v.RecordIssue | v.StringifyJsonIssue<{
256
+ [x: string]: unknown;
257
+ }> | v.UnionIssue<v.StringIssue | v.EmptyIssue<string> | v.ParseJsonIssue<string> | v.RecordIssue | v.StringifyJsonIssue<{
258
+ [x: string]: unknown;
259
+ }>> | v.ObjectIssue | v.BooleanIssue | v.RegexIssue<string>;
260
+ } | undefined;
261
+ };
262
+ /**
263
+ * Defines the parameters received by the `updateConfiguration` Commerce Eventing API endpoint.
264
+ * @see https://developer.adobe.com/commerce/extensibility/events/api/#configure-commerce-eventing
265
+ */
266
+ type UpdateEventingConfigurationParams = v.InferInput<typeof UpdateEventingConfigurationParamsSchema>;
267
+ //#endregion
268
+ //#region source/commerce/api/eventing-configuration/endpoints.d.ts
269
+ /**
270
+ * Updates the configuration of the Commerce Eventing API.
271
+ * @see https://developer.adobe.com/commerce/extensibility/events/api/#configure-commerce-eventing
272
+ *
273
+ * @param httpClient - The {@link CommerceHttpClient} to use to make the request.
274
+ * @param params - The parameters to update the configuration with.
275
+ * @param fetchOptions - The {@link Options} to use to make the request.
276
+ *
277
+ * @throws A {@link CommerceSdkValidationError} If the parameters are in the wrong format.
278
+ * @throws An {@link HTTPError} If the status code is not 2XX.
279
+ */
280
+ declare function updateEventingConfiguration(httpClient: AdobeCommerceHttpClient$1, params: UpdateEventingConfigurationParams, fetchOptions?: Options): Promise<boolean>;
281
+ //#endregion
282
+ //#region source/commerce/lib/api-client.d.ts
283
+ /**
284
+ * Creates a new API client for the Commerce Events API client.
285
+ * @param params - The parameters to build the Commerce HTTP client that will communicate with the Commerce Events API.
286
+ */
287
+ declare function createCommerceEventsApiClient(params: CommerceHttpClientParams): void 0<AdobeCommerceHttpClient, {
288
+ updateEventingConfiguration: typeof updateEventingConfiguration;
289
+ getAllEventSubscriptions(httpClient: AdobeCommerceHttpClient, fetchOptions?: ky0.Options): Promise<CommerceEventSubscriptionManyResponse>;
290
+ createEventSubscription(httpClient: AdobeCommerceHttpClient, params: EventSubscriptionCreateParams, fetchOptions?: ky0.Options): void;
291
+ getAllEventProviders(httpClient: AdobeCommerceHttpClient, fetchOptions?: ky0.Options): Promise<CommerceEventProviderManyResponse>;
292
+ getEventProviderById(httpClient: AdobeCommerceHttpClient, params: EventProviderGetByIdParams, fetchOptions?: ky0.Options): Promise<{
293
+ id: string;
294
+ providerId: string;
295
+ instanceId?: string | undefined;
296
+ label?: string | undefined;
297
+ description?: string | undefined;
298
+ workspaceConfiguration?: string | undefined;
299
+ }>;
300
+ createEventProvider(httpClient: AdobeCommerceHttpClient, params: EventProviderCreateParams, fetchOptions?: ky0.Options): Promise<{
301
+ id: string;
302
+ providerId: string;
303
+ instanceId?: string | undefined;
304
+ label?: string | undefined;
305
+ description?: string | undefined;
306
+ workspaceConfiguration?: string | undefined;
307
+ }>;
308
+ }>;
309
+ /**
310
+ * Creates a customized Commerce Events API client.
311
+ * @param params - The parameters to build the Commerce HTTP client that will communicate with the Commerce Events API.
312
+ * @param functions - The API functions to include in the client.
313
+ */
314
+ declare function createCustomCommerceEventsApiClient<TFunctions extends Record<string, ApiFunction<AdobeCommerceHttpClient, unknown[], unknown>>>(params: CommerceHttpClientParams, functions: TFunctions): void 0<AdobeCommerceHttpClient, TFunctions>;
315
+ //#endregion
316
+ export { type CommerceEventProvider, type CommerceEventProviderManyResponse, type CommerceEventProviderOneResponse, type CommerceEventSubscription, type CommerceEventSubscriptionField, type CommerceEventSubscriptionManyResponse, type CommerceEventSubscriptionOneResponse, type CommerceEventSubscriptionRule, EventProviderCreateParams, EventProviderCreateParamsSchema, EventProviderGetByIdParams, EventProviderGetByIdParamsSchema, EventSubscriptionCreateParams, EventSubscriptionCreateParamsSchema, UpdateEventingConfigurationParams, UpdateEventingConfigurationParamsSchema, createCommerceEventsApiClient, createCustomCommerceEventsApiClient, createEventProvider, createEventSubscription, getAllEventProviders, getAllEventSubscriptions, getEventProviderById, updateEventingConfiguration };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright 2025 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
+ import{b as optionallyExtendKy,c as ensureImsScopes,d as buildImsAuthBeforeRequestHook,e as buildIntegrationAuthBeforeRequestHook,f as isAuthProvider,g as HttpClientBase,h as ApiClient,i as alphaNumericOrUnderscoreOrHyphenSchema,j as alphaNumericOrUnderscoreSchema,k as booleanValueSchema,l as stringValueSchema,m as parseOrThrow,n as buildCamelCaseKeysResponseHook,o as __export}from"../ky-6HcrUVIg.js";import{CommerceSdkValidationError}from"@adobe/aio-commerce-lib-core/error";import*as v from"valibot";import ky from"ky";function workspaceConfigurationSchema(propertyName){return v.union([v.pipe(stringValueSchema(propertyName),v.empty()),v.pipe(stringValueSchema(propertyName),v.parseJson(void 0,`Expected valid JSON string for property '${propertyName}'`),v.record(v.string(),v.unknown()),v.stringifyJson()),v.pipe(v.record(v.string(),v.unknown()),v.stringifyJson(void 0,`Expected valid JSON data for property '${propertyName}'`))])}const EventProviderGetByIdParamsSchema=v.object({providerId:stringValueSchema(`providerId`)}),EventProviderCreateParamsSchema=v.object({providerId:stringValueSchema(`providerId`),instanceId:stringValueSchema(`instanceId`),label:v.optional(stringValueSchema(`label`)),description:v.optional(stringValueSchema(`description`)),associatedWorkspaceConfiguration:v.optional(workspaceConfigurationSchema(`associatedWorkspaceConfiguration`))});var endpoints_exports={};__export(endpoints_exports,{createEventProvider:()=>createEventProvider,getAllEventProviders:()=>getAllEventProviders,getEventProviderById:()=>getEventProviderById});function getAllEventProviders(httpClient,fetchOptions){let withHooksClient=httpClient.extend({hooks:{afterResponse:[buildCamelCaseKeysResponseHook()]}});return withHooksClient.get(`eventing/eventProvider`,fetchOptions).json()}function getEventProviderById(httpClient,params,fetchOptions){let validatedParams=parseOrThrow(EventProviderGetByIdParamsSchema,params),withHooksClient=httpClient.extend({hooks:{afterResponse:[buildCamelCaseKeysResponseHook()]}});return withHooksClient.get(`eventing/eventProvider/${validatedParams.providerId}`,fetchOptions).json()}function createEventProvider(httpClient,params,fetchOptions){let validatedParams=parseOrThrow(EventProviderCreateParamsSchema,params),withHooksClient=httpClient.extend({hooks:{afterResponse:[buildCamelCaseKeysResponseHook()]}});return withHooksClient.post(`eventing/eventProvider`,{...fetchOptions,json:{eventProvider:{provider_id:validatedParams.providerId,instance_id:validatedParams.instanceId,label:validatedParams.label,description:validatedParams.description,workspace_configuration:validatedParams.associatedWorkspaceConfiguration}}}).json()}function fieldsSchema(propertyName){return v.array(v.object({name:stringValueSchema(`${propertyName}[i].name`)}),`Expected an array of objects with a 'name' property for the property "${propertyName}"`)}const EventSubscriptionCreateParamsSchema=v.object({name:stringValueSchema(`name`),providerId:v.optional(stringValueSchema(`providerId`)),parent:v.optional(stringValueSchema(`parent`)),fields:fieldsSchema(`fields`),destination:v.optional(stringValueSchema(`destination`)),hipaaAuditRequired:v.optional(booleanValueSchema(`hipaaAuditRequired`)),prioritary:v.optional(booleanValueSchema(`prioritary`)),force:v.optional(booleanValueSchema(`force`))});var endpoints_exports$1={};__export(endpoints_exports$1,{createEventSubscription:()=>createEventSubscription,getAllEventSubscriptions:()=>getAllEventSubscriptions});function getAllEventSubscriptions(httpClient,fetchOptions){let withHooksClient=httpClient.extend({hooks:{afterResponse:[buildCamelCaseKeysResponseHook()]}});return withHooksClient.get(`eventing/getEventSubscriptions`,fetchOptions).json()}function createEventSubscription(httpClient,params,fetchOptions){let validatedParams=parseOrThrow(EventSubscriptionCreateParamsSchema,params),{force,...event}=validatedParams;httpClient.post(`eventing/eventSubscribe`,{...fetchOptions,json:{force,event:{name:event.name,parent:event.parent,fields:event.fields,destination:event.destination,hipaa_audit_required:event.hipaaAuditRequired,priority:event.prioritary,provider_id:event.providerId}}}).json()}const UpdateEventingConfigurationParamsSchema=v.partial(v.object({enabled:booleanValueSchema(`enabled`),providerId:alphaNumericOrUnderscoreOrHyphenSchema(`providerId`),instanceId:alphaNumericOrUnderscoreOrHyphenSchema(`instanceId`),merchantId:alphaNumericOrUnderscoreSchema(`merchantId`),environmentId:alphaNumericOrUnderscoreSchema(`environmentId`),workspaceConfiguration:workspaceConfigurationSchema(`workspaceConfiguration`)}));function updateEventingConfiguration(httpClient,params,fetchOptions){let validatedParams=parseOrThrow(UpdateEventingConfigurationParamsSchema,params);return httpClient.put(`eventing/updateConfiguration`,{...fetchOptions,json:{config:validatedParams}}).json()}const COMMERCE_SAAS_IMS_REQUIRED_SCOPES=[`openid`,`additional_info.projectedProductContext`,`commerce.accs`];function getCommerceUrl(config){let{baseUrl,storeViewCode,version}=config,commerceUrl=new URL(baseUrl),uppercasedVersion=version?.toUpperCase();return config.flavor===`paas`?commerceUrl.pathname+=`rest/${storeViewCode}/${uppercasedVersion}`:config.flavor===`saas`&&(commerceUrl.pathname+=`/${uppercasedVersion}`),commerceUrl.toString()}function buildCommerceHttpClientPaaS(params){let{auth,config,fetchOptions}=params,commerceUrl=getCommerceUrl(config),beforeRequestAuthHook=buildIntegrationAuthBeforeRequestHook(auth),httpClient=ky.create({prefixUrl:commerceUrl,hooks:{beforeRequest:[beforeRequestAuthHook]}});return optionallyExtendKy(httpClient,fetchOptions)}function buildCommerceHttpClientSaaS(params){let{auth,config,fetchOptions}=params,commerceUrl=getCommerceUrl(config),beforeRequestAuthHook=isAuthProvider(auth)?buildImsAuthBeforeRequestHook(auth):buildImsAuthBeforeRequestHook(ensureImsScopes(auth,COMMERCE_SAAS_IMS_REQUIRED_SCOPES)),httpClient=ky.create({prefixUrl:commerceUrl,hooks:{beforeRequest:[beforeRequestAuthHook,request=>{request.headers.set(`Store`,config.storeViewCode)}]}});return optionallyExtendKy(httpClient,fetchOptions)}function isPaaSParams(params){return params.config.flavor===`paas`}function isSaaSParams(params){return params.config.flavor===`saas`}function buildCommerceHttpClient(params){let flavor=params.config.flavor;if(isPaaSParams(params))return buildCommerceHttpClientPaaS(params);if(isSaaSParams(params))return buildCommerceHttpClientSaaS(params);throw Error(`Invalid Commerce configuration. Unknown flavor: ${flavor}`)}var AdobeCommerceHttpClient=class extends HttpClientBase{constructor(params){let config={...params.config,storeViewCode:params.config.storeViewCode??`all`,version:params.config.version??`V1`},requiredParams={...params,config},httpClient=buildCommerceHttpClient(requiredParams);super(config,httpClient)}};function createCommerceEventsApiClient(params){return ApiClient.create(new AdobeCommerceHttpClient(params),{...endpoints_exports,...endpoints_exports$1,updateEventingConfiguration})}function createCustomCommerceEventsApiClient(params,functions){return ApiClient.create(new AdobeCommerceHttpClient(params),functions)}export{createCommerceEventsApiClient,createCustomCommerceEventsApiClient,createEventProvider,createEventSubscription,getAllEventProviders,getAllEventSubscriptions,getEventProviderById,updateEventingConfiguration};