@adobe/aio-commerce-lib-events 0.4.0 → 0.5.1
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 +19 -0
- package/dist/cjs/commerce/index.cjs +1 -1
- package/dist/cjs/commerce/index.d.cts +47 -76
- package/dist/cjs/io-events/index.cjs +1 -1
- package/dist/cjs/io-events/index.d.cts +273 -3007
- package/dist/cjs/utils-rfIzwBMe.cjs +1 -0
- package/dist/es/commerce/index.d.mts +47 -76
- package/dist/es/commerce/index.mjs +1 -1
- package/dist/es/io-events/index.d.mts +273 -3007
- package/dist/es/io-events/index.mjs +1 -1
- package/dist/es/utils-yparxucz.mjs +1 -0
- package/package.json +5 -5
- package/dist/cjs/chunk-BZ64pZp-.cjs +0 -1
- package/dist/es/chunk-BKfb2J6I.mjs +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @adobe/aio-commerce-lib-events
|
|
2
2
|
|
|
3
|
+
## 0.5.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#230](https://github.com/adobe/aio-commerce-sdk/pull/230) [`0d17bcc`](https://github.com/adobe/aio-commerce-sdk/commit/0d17bcc22c3c556c95975dd3df5969b74e765e67) Thanks [@iivvaannxx](https://github.com/iivvaannxx)! - Fix common-utils should be a private development only dependency
|
|
8
|
+
|
|
9
|
+
## 0.5.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#220](https://github.com/adobe/aio-commerce-sdk/pull/220) [`43cd7d1`](https://github.com/adobe/aio-commerce-sdk/commit/43cd7d16ae676e59ee501ccbe89a38c20d777740) Thanks [@iivvaannxx](https://github.com/iivvaannxx)! - [BREAKING]: Remove camel case transformations on responses
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [[`43cd7d1`](https://github.com/adobe/aio-commerce-sdk/commit/43cd7d16ae676e59ee501ccbe89a38c20d777740), [`6063a97`](https://github.com/adobe/aio-commerce-sdk/commit/6063a97299c9b44f663314420b59cee7998b2f89), [`6063a97`](https://github.com/adobe/aio-commerce-sdk/commit/6063a97299c9b44f663314420b59cee7998b2f89)]:
|
|
18
|
+
- @adobe/aio-commerce-lib-api@0.6.0
|
|
19
|
+
- @aio-commerce-sdk/common-utils@0.1.0
|
|
20
|
+
- @adobe/aio-commerce-lib-auth@0.8.0
|
|
21
|
+
|
|
3
22
|
## 0.4.0
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_utils=require(`../utils-rfIzwBMe.cjs`);let _adobe_aio_commerce_lib_core_error=require(`@adobe/aio-commerce-lib-core/error`),valibot=require(`valibot`);valibot=require_utils.s(valibot);let _adobe_aio_commerce_lib_api=require(`@adobe/aio-commerce-lib-api`);function workspaceConfigurationSchema(propertyName){return valibot.union([valibot.pipe(require_utils.a(propertyName),valibot.empty()),valibot.pipe(require_utils.a(propertyName),valibot.parseJson(void 0,`Expected valid JSON string for property '${propertyName}'`),valibot.record(valibot.string(),valibot.unknown()),valibot.stringifyJson()),valibot.pipe(valibot.record(valibot.string(),valibot.unknown()),valibot.stringifyJson(void 0,`Expected valid JSON data for property '${propertyName}'`))])}const EventProviderGetByIdParamsSchema=valibot.object({providerId:require_utils.a(`providerId`)}),EventProviderCreateParamsSchema=valibot.object({providerId:require_utils.a(`providerId`),instanceId:require_utils.a(`instanceId`),label:valibot.optional(require_utils.a(`label`)),description:valibot.optional(require_utils.a(`description`)),associatedWorkspaceConfiguration:valibot.optional(workspaceConfigurationSchema(`associatedWorkspaceConfiguration`))});var endpoints_exports$1=require_utils.o({createEventProvider:()=>createEventProvider,getAllEventProviders:()=>getAllEventProviders,getEventProviderById:()=>getEventProviderById});async function getAllEventProviders(httpClient,fetchOptions){return httpClient.get(`eventing/eventProvider`,fetchOptions).json()}async function getEventProviderById(httpClient,params,fetchOptions){let validatedParams=require_utils.t(EventProviderGetByIdParamsSchema,params);return httpClient.get(`eventing/eventProvider/${validatedParams.providerId}`,fetchOptions).json()}async function createEventProvider(httpClient,params,fetchOptions){let validatedParams=require_utils.t(EventProviderCreateParamsSchema,params);return httpClient.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 valibot.array(valibot.object({name:require_utils.a(`${propertyName}[i].name`)}),`Expected an array of objects with a 'name' property for the property "${propertyName}"`)}const EventSubscriptionCreateParamsSchema=valibot.object({name:require_utils.a(`name`),providerId:valibot.optional(require_utils.a(`providerId`)),parent:valibot.optional(require_utils.a(`parent`)),fields:fieldsSchema(`fields`),destination:valibot.optional(require_utils.a(`destination`)),hipaaAuditRequired:valibot.optional(require_utils.i(`hipaaAuditRequired`)),prioritary:valibot.optional(require_utils.i(`prioritary`)),force:valibot.optional(require_utils.i(`force`))});var endpoints_exports=require_utils.o({createEventSubscription:()=>createEventSubscription,getAllEventSubscriptions:()=>getAllEventSubscriptions});async function getAllEventSubscriptions(httpClient,fetchOptions){return httpClient.get(`eventing/getEventSubscriptions`,fetchOptions).json()}async function createEventSubscription(httpClient,params,fetchOptions){let{force,...event}=require_utils.t(EventSubscriptionCreateParamsSchema,params);return 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().then(_res=>{})}const UpdateEventingConfigurationParamsSchema=valibot.partial(valibot.object({enabled:require_utils.i(`enabled`),providerId:require_utils.n(`providerId`),instanceId:require_utils.n(`instanceId`),merchantId:require_utils.r(`merchantId`),environmentId:require_utils.r(`environmentId`),workspaceConfiguration:workspaceConfigurationSchema(`workspaceConfiguration`)}));async function updateEventingConfiguration(httpClient,params,fetchOptions){let validatedParams=require_utils.t(UpdateEventingConfigurationParamsSchema,params);return httpClient.put(`eventing/updateConfiguration`,{...fetchOptions,json:{config:validatedParams}}).json()}function createCommerceEventsApiClient(params){return _adobe_aio_commerce_lib_api.ApiClient.create(new _adobe_aio_commerce_lib_api.AdobeCommerceHttpClient(params),{...endpoints_exports$1,...endpoints_exports,updateEventingConfiguration})}function createCustomCommerceEventsApiClient(params,functions){return _adobe_aio_commerce_lib_api.ApiClient.create(new _adobe_aio_commerce_lib_api.AdobeCommerceHttpClient(params),functions)}exports.createCommerceEventsApiClient=createCommerceEventsApiClient,exports.createCustomCommerceEventsApiClient=createCustomCommerceEventsApiClient,exports.createEventProvider=createEventProvider,exports.createEventSubscription=createEventSubscription,exports.getAllEventProviders=getAllEventProviders,exports.getAllEventSubscriptions=getAllEventSubscriptions,exports.getEventProviderById=getEventProviderById,exports.updateEventingConfiguration=updateEventingConfiguration;
|
|
@@ -2,19 +2,33 @@ import * as _adobe_aio_commerce_lib_api0 from "@adobe/aio-commerce-lib-api";
|
|
|
2
2
|
import { AdobeCommerceHttpClient, ApiFunction, CommerceHttpClientParams } from "@adobe/aio-commerce-lib-api";
|
|
3
3
|
import { Options } from "@adobe/aio-commerce-lib-api/ky";
|
|
4
4
|
import * as v from "valibot";
|
|
5
|
-
import { CamelCasedPropertiesDeep } from "type-fest";
|
|
6
5
|
import * as ky0 from "ky";
|
|
7
6
|
|
|
7
|
+
//#region source/commerce/api/event-providers/types.d.ts
|
|
8
|
+
/** Defines the structure of a Commerce event provider. */
|
|
9
|
+
type CommerceEventProvider = {
|
|
10
|
+
id: string;
|
|
11
|
+
provider_id: string;
|
|
12
|
+
instance_id?: string;
|
|
13
|
+
label?: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
workspace_configuration?: string;
|
|
16
|
+
};
|
|
17
|
+
/** Defines the fields of an event provider entity returned by the Commerce API. */
|
|
18
|
+
type CommerceEventProviderOneResponse = CommerceEventProvider;
|
|
19
|
+
/** Defines the fields of many event provider entities returned by the Commerce API. */
|
|
20
|
+
type CommerceEventProviderManyResponse = CommerceEventProvider[];
|
|
21
|
+
//#endregion
|
|
8
22
|
//#region source/commerce/api/event-providers/schema.d.ts
|
|
9
23
|
declare const EventProviderGetByIdParamsSchema: v.ObjectSchema<{
|
|
10
|
-
readonly providerId: v.StringSchema<`Expected a string value for
|
|
24
|
+
readonly providerId: v.StringSchema<`Expected a string value for '${string}'`>;
|
|
11
25
|
}, undefined>;
|
|
12
26
|
declare const EventProviderCreateParamsSchema: v.ObjectSchema<{
|
|
13
|
-
readonly providerId: v.StringSchema<`Expected a string value for
|
|
14
|
-
readonly instanceId: v.StringSchema<`Expected a string value for
|
|
15
|
-
readonly label: v.OptionalSchema<v.StringSchema<`Expected a string value for
|
|
16
|
-
readonly description: v.OptionalSchema<v.StringSchema<`Expected a string value for
|
|
17
|
-
readonly associatedWorkspaceConfiguration: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for
|
|
27
|
+
readonly providerId: v.StringSchema<`Expected a string value for '${string}'`>;
|
|
28
|
+
readonly instanceId: v.StringSchema<`Expected a string value for '${string}'`>;
|
|
29
|
+
readonly label: v.OptionalSchema<v.StringSchema<`Expected a string value for '${string}'`>, undefined>;
|
|
30
|
+
readonly description: v.OptionalSchema<v.StringSchema<`Expected a string value for '${string}'`>, undefined>;
|
|
31
|
+
readonly associatedWorkspaceConfiguration: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.EmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.ParseJsonAction<string, undefined, `Expected valid JSON string for property '${string}'`>, v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, v.StringifyJsonAction<{
|
|
18
32
|
[x: string]: unknown;
|
|
19
33
|
}, undefined, undefined>]>, v.SchemaWithPipe<readonly [v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, v.StringifyJsonAction<{
|
|
20
34
|
[x: string]: unknown;
|
|
@@ -31,21 +45,6 @@ type EventProviderGetByIdParams = v.InferInput<typeof EventProviderGetByIdParams
|
|
|
31
45
|
*/
|
|
32
46
|
type EventProviderCreateParams = v.InferInput<typeof EventProviderCreateParamsSchema>;
|
|
33
47
|
//#endregion
|
|
34
|
-
//#region source/commerce/api/event-providers/types.d.ts
|
|
35
|
-
/** Defines the structure of a Commerce event provider. */
|
|
36
|
-
type CommerceEventProvider = {
|
|
37
|
-
id: string;
|
|
38
|
-
provider_id: string;
|
|
39
|
-
instance_id?: string;
|
|
40
|
-
label?: string;
|
|
41
|
-
description?: string;
|
|
42
|
-
workspace_configuration?: string;
|
|
43
|
-
};
|
|
44
|
-
/** Defines the fields of an event provider entity returned by the Commerce API. */
|
|
45
|
-
type CommerceEventProviderOneResponse = CamelCasedPropertiesDeep<CommerceEventProvider>;
|
|
46
|
-
/** Defines the fields of many event provider entities returned by the Commerce API. */
|
|
47
|
-
type CommerceEventProviderManyResponse = CommerceEventProviderOneResponse[];
|
|
48
|
-
//#endregion
|
|
49
48
|
//#region source/commerce/api/event-providers/endpoints.d.ts
|
|
50
49
|
/**
|
|
51
50
|
* Lists all event providers of the Commerce instance bound to the given {@link AdobeCommerceHttpClient}.
|
|
@@ -68,14 +67,7 @@ declare function getAllEventProviders(httpClient: AdobeCommerceHttpClient, fetch
|
|
|
68
67
|
* @throws A {@link CommerceSdkValidationError} If the parameters are in the wrong format.
|
|
69
68
|
* @throws An {@link HTTPError} If the status code is not 2XX.
|
|
70
69
|
*/
|
|
71
|
-
declare function getEventProviderById(httpClient: AdobeCommerceHttpClient, params: EventProviderGetByIdParams, fetchOptions?: Options): Promise<
|
|
72
|
-
id: string;
|
|
73
|
-
providerId: string;
|
|
74
|
-
instanceId?: string | undefined;
|
|
75
|
-
label?: string | undefined;
|
|
76
|
-
description?: string | undefined;
|
|
77
|
-
workspaceConfiguration?: string | undefined;
|
|
78
|
-
}>;
|
|
70
|
+
declare function getEventProviderById(httpClient: AdobeCommerceHttpClient, params: EventProviderGetByIdParams, fetchOptions?: Options): Promise<CommerceEventProvider>;
|
|
79
71
|
/**
|
|
80
72
|
* Creates an event provider in the Commerce instance bound to the given {@link AdobeCommerceHttpClient}.
|
|
81
73
|
* @see https://developer.adobe.com/commerce/extensibility/events/api/#create-an-event-provider
|
|
@@ -87,27 +79,20 @@ declare function getEventProviderById(httpClient: AdobeCommerceHttpClient, param
|
|
|
87
79
|
* @throws A {@link CommerceSdkValidationError} If the parameters are in the wrong format.
|
|
88
80
|
* @throws An {@link HTTPError} If the status code is not 2XX.
|
|
89
81
|
*/
|
|
90
|
-
declare function createEventProvider(httpClient: AdobeCommerceHttpClient, params: EventProviderCreateParams, fetchOptions?: Options): Promise<
|
|
91
|
-
id: string;
|
|
92
|
-
providerId: string;
|
|
93
|
-
instanceId?: string | undefined;
|
|
94
|
-
label?: string | undefined;
|
|
95
|
-
description?: string | undefined;
|
|
96
|
-
workspaceConfiguration?: string | undefined;
|
|
97
|
-
}>;
|
|
82
|
+
declare function createEventProvider(httpClient: AdobeCommerceHttpClient, params: EventProviderCreateParams, fetchOptions?: Options): Promise<CommerceEventProvider>;
|
|
98
83
|
//#endregion
|
|
99
84
|
//#region source/commerce/api/event-subscriptions/schema.d.ts
|
|
100
85
|
declare const EventSubscriptionCreateParamsSchema: v.ObjectSchema<{
|
|
101
|
-
readonly name: v.StringSchema<`Expected a string value for
|
|
102
|
-
readonly providerId: v.OptionalSchema<v.StringSchema<`Expected a string value for
|
|
103
|
-
readonly parent: v.OptionalSchema<v.StringSchema<`Expected a string value for
|
|
86
|
+
readonly name: v.StringSchema<`Expected a string value for '${string}'`>;
|
|
87
|
+
readonly providerId: v.OptionalSchema<v.StringSchema<`Expected a string value for '${string}'`>, undefined>;
|
|
88
|
+
readonly parent: v.OptionalSchema<v.StringSchema<`Expected a string value for '${string}'`>, undefined>;
|
|
104
89
|
readonly fields: v.ArraySchema<v.ObjectSchema<{
|
|
105
|
-
readonly name: v.StringSchema<`Expected a string value for
|
|
90
|
+
readonly name: v.StringSchema<`Expected a string value for '${string}'`>;
|
|
106
91
|
}, undefined>, `Expected an array of objects with a 'name' property for the property "${string}"`>;
|
|
107
|
-
readonly destination: v.OptionalSchema<v.StringSchema<`Expected a string value for
|
|
108
|
-
readonly hipaaAuditRequired: v.OptionalSchema<v.BooleanSchema<`Expected a boolean value for
|
|
109
|
-
readonly prioritary: v.OptionalSchema<v.BooleanSchema<`Expected a boolean value for
|
|
110
|
-
readonly force: v.OptionalSchema<v.BooleanSchema<`Expected a boolean value for
|
|
92
|
+
readonly destination: v.OptionalSchema<v.StringSchema<`Expected a string value for '${string}'`>, undefined>;
|
|
93
|
+
readonly hipaaAuditRequired: v.OptionalSchema<v.BooleanSchema<`Expected a boolean value for '${string}'`>, undefined>;
|
|
94
|
+
readonly prioritary: v.OptionalSchema<v.BooleanSchema<`Expected a boolean value for '${string}'`>, undefined>;
|
|
95
|
+
readonly force: v.OptionalSchema<v.BooleanSchema<`Expected a boolean value for '${string}'`>, undefined>;
|
|
111
96
|
}, undefined>;
|
|
112
97
|
/**
|
|
113
98
|
* The schema of the parameters received by the POST `eventing/eventSubscribe` Commerce API endpoint.
|
|
@@ -139,9 +124,9 @@ type CommerceEventSubscription = {
|
|
|
139
124
|
hipaa_audit_required: boolean;
|
|
140
125
|
};
|
|
141
126
|
/** Defines the fields of an event subscription entity returned by the Commerce API. */
|
|
142
|
-
type CommerceEventSubscriptionOneResponse =
|
|
127
|
+
type CommerceEventSubscriptionOneResponse = CommerceEventSubscription;
|
|
143
128
|
/** Defines the fields of many event subscription entities returned by the Commerce API. */
|
|
144
|
-
type CommerceEventSubscriptionManyResponse =
|
|
129
|
+
type CommerceEventSubscriptionManyResponse = CommerceEventSubscription[];
|
|
145
130
|
//#endregion
|
|
146
131
|
//#region source/commerce/api/event-subscriptions/endpoints.d.ts
|
|
147
132
|
/**
|
|
@@ -168,24 +153,24 @@ declare function createEventSubscription(httpClient: AdobeCommerceHttpClient, pa
|
|
|
168
153
|
//#region source/commerce/api/eventing-configuration/schema.d.ts
|
|
169
154
|
/** The schema of the parameters received by the `updateConfiguration` Commerce Eventing API endpoint. */
|
|
170
155
|
declare const UpdateEventingConfigurationParamsSchema: Omit<v.ObjectSchema<{
|
|
171
|
-
readonly enabled: v.BooleanSchema<`Expected a boolean value for
|
|
172
|
-
readonly providerId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for
|
|
173
|
-
readonly instanceId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for
|
|
174
|
-
readonly merchantId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for
|
|
175
|
-
readonly environmentId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for
|
|
176
|
-
readonly workspaceConfiguration: v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for
|
|
156
|
+
readonly enabled: v.BooleanSchema<`Expected a boolean value for '${string}'`>;
|
|
157
|
+
readonly providerId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.RegexAction<string, `Only alphanumeric characters, underscores, and hyphens are allowed in string value of "${string}"${string}`>]>;
|
|
158
|
+
readonly instanceId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.RegexAction<string, `Only alphanumeric characters, underscores, and hyphens are allowed in string value of "${string}"${string}`>]>;
|
|
159
|
+
readonly merchantId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.RegexAction<string, `Only alphanumeric characters and underscores are allowed in string value of "${string}"${string}`>]>;
|
|
160
|
+
readonly environmentId: v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.RegexAction<string, `Only alphanumeric characters and underscores are allowed in string value of "${string}"${string}`>]>;
|
|
161
|
+
readonly workspaceConfiguration: v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.EmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.ParseJsonAction<string, undefined, `Expected valid JSON string for property '${string}'`>, v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, v.StringifyJsonAction<{
|
|
177
162
|
[x: string]: unknown;
|
|
178
163
|
}, undefined, undefined>]>, v.SchemaWithPipe<readonly [v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, v.StringifyJsonAction<{
|
|
179
164
|
[x: string]: unknown;
|
|
180
165
|
}, undefined, `Expected valid JSON data for property '${string}'`>]>], undefined>;
|
|
181
166
|
}, undefined>, "~types" | "~run" | "~standard" | "entries"> & {
|
|
182
167
|
readonly entries: {
|
|
183
|
-
readonly enabled: v.OptionalSchema<v.BooleanSchema<`Expected a boolean value for
|
|
184
|
-
readonly providerId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for
|
|
185
|
-
readonly instanceId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for
|
|
186
|
-
readonly merchantId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for
|
|
187
|
-
readonly environmentId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for
|
|
188
|
-
readonly workspaceConfiguration: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for
|
|
168
|
+
readonly enabled: v.OptionalSchema<v.BooleanSchema<`Expected a boolean value for '${string}'`>, undefined>;
|
|
169
|
+
readonly providerId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.RegexAction<string, `Only alphanumeric characters, underscores, and hyphens are allowed in string value of "${string}"${string}`>]>, undefined>;
|
|
170
|
+
readonly instanceId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.RegexAction<string, `Only alphanumeric characters, underscores, and hyphens are allowed in string value of "${string}"${string}`>]>, undefined>;
|
|
171
|
+
readonly merchantId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.RegexAction<string, `Only alphanumeric characters and underscores are allowed in string value of "${string}"${string}`>]>, undefined>;
|
|
172
|
+
readonly environmentId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.RegexAction<string, `Only alphanumeric characters and underscores are allowed in string value of "${string}"${string}`>]>, undefined>;
|
|
173
|
+
readonly workspaceConfiguration: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.EmptyAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.StringSchema<`Expected a string value for '${string}'`>, v.ParseJsonAction<string, undefined, `Expected valid JSON string for property '${string}'`>, v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, v.StringifyJsonAction<{
|
|
189
174
|
[x: string]: unknown;
|
|
190
175
|
}, undefined, undefined>]>, v.SchemaWithPipe<readonly [v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, v.StringifyJsonAction<{
|
|
191
176
|
[x: string]: unknown;
|
|
@@ -276,22 +261,8 @@ declare function createCommerceEventsApiClient(params: CommerceHttpClientParams)
|
|
|
276
261
|
getAllEventSubscriptions(httpClient: AdobeCommerceHttpClient, fetchOptions?: ky0.Options): Promise<CommerceEventSubscriptionManyResponse>;
|
|
277
262
|
createEventSubscription(httpClient: AdobeCommerceHttpClient, params: EventSubscriptionCreateParams, fetchOptions?: ky0.Options): Promise<void>;
|
|
278
263
|
getAllEventProviders(httpClient: AdobeCommerceHttpClient, fetchOptions?: ky0.Options): Promise<CommerceEventProviderManyResponse>;
|
|
279
|
-
getEventProviderById(httpClient: AdobeCommerceHttpClient, params: EventProviderGetByIdParams, fetchOptions?: ky0.Options): Promise<
|
|
280
|
-
|
|
281
|
-
providerId: string;
|
|
282
|
-
instanceId?: string | undefined;
|
|
283
|
-
label?: string | undefined;
|
|
284
|
-
description?: string | undefined;
|
|
285
|
-
workspaceConfiguration?: string | undefined;
|
|
286
|
-
}>;
|
|
287
|
-
createEventProvider(httpClient: AdobeCommerceHttpClient, params: EventProviderCreateParams, fetchOptions?: ky0.Options): Promise<{
|
|
288
|
-
id: string;
|
|
289
|
-
providerId: string;
|
|
290
|
-
instanceId?: string | undefined;
|
|
291
|
-
label?: string | undefined;
|
|
292
|
-
description?: string | undefined;
|
|
293
|
-
workspaceConfiguration?: string | undefined;
|
|
294
|
-
}>;
|
|
264
|
+
getEventProviderById(httpClient: AdobeCommerceHttpClient, params: EventProviderGetByIdParams, fetchOptions?: ky0.Options): Promise<CommerceEventProvider>;
|
|
265
|
+
createEventProvider(httpClient: AdobeCommerceHttpClient, params: EventProviderCreateParams, fetchOptions?: ky0.Options): Promise<CommerceEventProvider>;
|
|
295
266
|
}>;
|
|
296
267
|
/**
|
|
297
268
|
* An API Client for the Commerce Events API.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const require_chunk=require(`../chunk-BZ64pZp-.cjs`);let _adobe_aio_commerce_lib_api_utils=require(`@adobe/aio-commerce-lib-api/utils`),_aio_commerce_sdk_common_utils_valibot=require(`@aio-commerce-sdk/common-utils/valibot`),valibot=require(`valibot`);valibot=require_chunk.n(valibot);let _adobe_aio_commerce_lib_api=require(`@adobe/aio-commerce-lib-api`);const BASE64_ENCODED_STRING_REGEX=/^[A-Za-z0-9+/]*={0,2}$/,BASE64_ENCODED_STRING_LENGTH_REMAINDER=4;function isBase64EncodedString(value){return BASE64_ENCODED_STRING_REGEX.test(value)&&value.length%4==0}function encodeToBase64(value){return Buffer.from(value).toString(`base64`)}function tryDecodeFromBase64(value){return isBase64EncodedString(value)?Buffer.from(value,`base64`).toString(`utf-8`):value}function sampleEventTemplateSchema(fieldName){return valibot.pipe(valibot.union([valibot.pipe((0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(fieldName),valibot.transform(tryDecodeFromBase64),valibot.parseJson(void 0,`Expected valid JSON string for property '${fieldName}'`),valibot.record(valibot.string(),valibot.unknown())),valibot.record(valibot.string(),valibot.unknown()),valibot.array(valibot.unknown())]),valibot.stringifyJson(void 0,`Expected valid JSON data for property '${fieldName}'`),valibot.transform(encodeToBase64))}const GetAllEventMetadataForProviderSchema=valibot.object({providerId:(0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`providerId`)}),GetEventMetadataForEventAndProviderSchema=valibot.object({eventCode:(0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`eventCode`),providerId:(0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`providerId`)}),CreateEventMetadataForProviderSchema=valibot.object({consumerOrgId:(0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`consumerOrgId`),projectId:(0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`projectId`),workspaceId:(0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`workspaceId`),providerId:(0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`providerId`),label:(0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`label`),description:(0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`description`),eventCode:(0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`eventCode`),sampleEventTemplate:valibot.optional(sampleEventTemplateSchema(`sampleEventTemplate`))});var endpoints_exports$2=require_chunk.t({createEventMetadataForProvider:()=>createEventMetadataForProvider,getAllEventMetadataForProvider:()=>getAllEventMetadataForProvider,getEventMetadataForEventAndProvider:()=>getEventMetadataForEventAndProvider});async function getAllEventMetadataForProvider(httpClient,params,fetchOptions){let validatedParams=(0,_aio_commerce_sdk_common_utils_valibot.parseOrThrow)(GetAllEventMetadataForProviderSchema,params);return httpClient.extend({hooks:{afterResponse:[(0,_adobe_aio_commerce_lib_api_utils.buildCamelCaseKeysResponseHook)()]}}).get(`providers/${validatedParams.providerId}/eventmetadata`,fetchOptions).json()}async function getEventMetadataForEventAndProvider(httpClient,params,fetchOptions){let validatedParams=(0,_aio_commerce_sdk_common_utils_valibot.parseOrThrow)(GetEventMetadataForEventAndProviderSchema,params);return httpClient.extend({hooks:{afterResponse:[(0,_adobe_aio_commerce_lib_api_utils.buildCamelCaseKeysResponseHook)()]}}).get(`providers/${validatedParams.providerId}/eventmetadata/${validatedParams.eventCode}`,fetchOptions).json()}async function createEventMetadataForProvider(httpClient,params,fetchOptions){let validatedParams=(0,_aio_commerce_sdk_common_utils_valibot.parseOrThrow)(CreateEventMetadataForProviderSchema,params);return httpClient.extend({hooks:{afterResponse:[(0,_adobe_aio_commerce_lib_api_utils.buildCamelCaseKeysResponseHook)()]}}).post(`${validatedParams.consumerOrgId}/${validatedParams.projectId}/${validatedParams.workspaceId}/providers/${validatedParams.providerId}/eventmetadata`,{...fetchOptions,json:{label:validatedParams.label,description:validatedParams.description,event_code:validatedParams.eventCode,sample_event_template:validatedParams.sampleEventTemplate}}).json()}function setQueryParamIfTruthy(queryParams,key,value){value&&queryParams.set(key,`${value}`)}function setArrayQueryParam(queryParams,key,values){if(values!==void 0&&values.length>0)for(let value of values)queryParams.set(key,`${value}`)}const VALID_EVENT_PROVIDER_TYPES=[`dx_commerce_events`,`3rd_party_custom_events`],VALID_DATA_RESIDENCY_REGIONS=[`va6`,`irl1`],EventProviderTypeSchema=valibot.picklist(VALID_EVENT_PROVIDER_TYPES),DataResidencyRegionSchema=valibot.picklist(VALID_DATA_RESIDENCY_REGIONS),EventProviderListAllParamsSchema=valibot.object({consumerOrgId:(0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`consumerOrgId`),withEventMetadata:valibot.optional((0,_aio_commerce_sdk_common_utils_valibot.booleanValueSchema)(`withEventMetadata`)),filterBy:valibot.optional(valibot.object({instanceId:valibot.optional((0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`instanceId`)),providerTypes:valibot.optional(valibot.union([valibot.array(EventProviderTypeSchema,`Expected an array of event provider types`)]))}))}),EventProviderGetByIdParamsSchema=valibot.object({providerId:(0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`providerId`),withEventMetadata:valibot.optional((0,_aio_commerce_sdk_common_utils_valibot.booleanValueSchema)(`withEventMetadata`))}),EventProviderCreateParamsSchema=valibot.object({consumerOrgId:(0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`consumerOrgId`),projectId:(0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`projectId`),workspaceId:(0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`workspaceId`),label:(0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`label`),description:valibot.optional((0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`description`)),docsUrl:valibot.optional((0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`docsUrl`)),instanceId:valibot.optional((0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`instanceId`)),providerType:valibot.optional(EventProviderTypeSchema),dataResidencyRegion:valibot.optional(DataResidencyRegionSchema)});var endpoints_exports$1=require_chunk.t({createEventProvider:()=>createEventProvider,getAllEventProviders:()=>getAllEventProviders,getEventProviderById:()=>getEventProviderById});async function getAllEventProviders(httpClient,params,fetchOptions){let validatedParams=(0,_aio_commerce_sdk_common_utils_valibot.parseOrThrow)(EventProviderListAllParamsSchema,params),queryParams=new URLSearchParams,{providerTypes=[],instanceId}=validatedParams.filterBy??{};return setArrayQueryParam(queryParams,`providerMetadataIds`,providerTypes),setQueryParamIfTruthy(queryParams,`instanceId`,instanceId),setQueryParamIfTruthy(queryParams,`eventmetadata`,validatedParams.withEventMetadata),httpClient.extend({hooks:{afterResponse:[(0,_adobe_aio_commerce_lib_api_utils.buildCamelCaseKeysResponseHook)()]}}).get(`${validatedParams.consumerOrgId}/providers`,{...fetchOptions,searchParams:queryParams}).json()}async function getEventProviderById(httpClient,params,fetchOptions){let validatedParams=(0,_aio_commerce_sdk_common_utils_valibot.parseOrThrow)(EventProviderGetByIdParamsSchema,params),searchParams=new URLSearchParams;return setQueryParamIfTruthy(searchParams,`eventmetadata`,validatedParams.withEventMetadata),httpClient.extend({hooks:{afterResponse:[(0,_adobe_aio_commerce_lib_api_utils.buildCamelCaseKeysResponseHook)()]}}).get(`providers/${params.providerId}`,{...fetchOptions,searchParams}).json()}async function createEventProvider(httpClient,params,fetchOptions){let validatedParams=(0,_aio_commerce_sdk_common_utils_valibot.parseOrThrow)(EventProviderCreateParamsSchema,params);return httpClient.extend({hooks:{afterResponse:[(0,_adobe_aio_commerce_lib_api_utils.buildCamelCaseKeysResponseHook)()]}}).post(`${validatedParams.consumerOrgId}/${validatedParams.projectId}/${validatedParams.workspaceId}/providers`,{...fetchOptions,json:{...validatedParams,docs_url:validatedParams.docsUrl,provider_metadata:validatedParams.providerType,instance_id:validatedParams.instanceId,data_residency_region:validatedParams.dataResidencyRegion}}).json()}var shorthands_exports=require_chunk.t({create3rdPartyCustomEventProvider:()=>create3rdPartyCustomEventProvider,createCommerceEventProvider:()=>createCommerceEventProvider,getAll3rdPartyCustomEventProviders:()=>getAll3rdPartyCustomEventProviders,getAllCommerceEventProviders:()=>getAllCommerceEventProviders});async function getAllCommerceEventProviders(httpClient,params,fetchOptions){return getAllEventProviders(httpClient,{...params,filterBy:{...params.filterBy,providerTypes:[`dx_commerce_events`]}},fetchOptions)}async function getAll3rdPartyCustomEventProviders(httpClient,params,fetchOptions){return getAllEventProviders(httpClient,{...params,filterBy:{...params.filterBy,providerTypes:[`3rd_party_custom_events`]}},fetchOptions)}async function createCommerceEventProvider(httpClient,params,fetchOptions){return createEventProvider(httpClient,{...params,providerType:`dx_commerce_events`},fetchOptions)}async function create3rdPartyCustomEventProvider(httpClient,params,fetchOptions){return createEventProvider(httpClient,{...params,providerType:`3rd_party_custom_events`},fetchOptions)}const VALID_DELIVERY_TYPES=[`webhook`,`webhook_batch`,`journal`,`aws_eventbridge`],AWS_REGION_REGEX=/^(us|ca|eu|af|ap|cn|me|sa|il)-[a-z]+-\d$/,AWS_ACCOUNT_ID_REGEX=/^\d{12}$/,DeliveryTypeSchema=valibot.picklist(VALID_DELIVERY_TYPES,`Expected delivery type to be one of: ${VALID_DELIVERY_TYPES.join(`, `)}`),EventsOfInterestSchema=valibot.object({providerId:(0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`providerId`),eventCode:(0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`eventCode`),providerMetadataId:valibot.optional((0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`providerMetadataId`))}),DestinationMetadataSchema=valibot.object({awsRegion:valibot.optional(valibot.pipe((0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`awsRegion`),valibot.regex(AWS_REGION_REGEX,`Expected AWS region in format like 'us-east-1'`))),awsAccountId:valibot.optional(valibot.pipe((0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`awsAccountId`),valibot.regex(AWS_ACCOUNT_ID_REGEX,`Expected AWS account ID to be a 12-digit number`)))}),SubscriberFilterSchema=valibot.object({name:valibot.pipe((0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`name`),valibot.minLength(3,`Expected subscriber filter name to be at least 3 characters`),valibot.maxLength(80,`Expected subscriber filter name to be at most 80 characters`)),description:valibot.optional(valibot.pipe((0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`description`),valibot.maxLength(250,`Expected subscriber filter description to be at most 250 characters`))),subscriberFilter:(0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`subscriberFilter`)}),WorkspacePathParamsSchema=valibot.object({consumerOrgId:(0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`consumerOrgId`),projectId:(0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`projectId`),workspaceId:(0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`workspaceId`)}),EventsOfInterestArraySchema=valibot.pipe(valibot.array(EventsOfInterestSchema,`Expected eventsOfInterest to be an array of event interest objects`),valibot.minLength(1,`Expected at least one event of interest`)),RegistrationBodySchema=valibot.object({clientId:valibot.pipe((0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`clientId`),valibot.minLength(3,`Expected clientId to be at least 1 character`),valibot.maxLength(255,`Expected clientId to be at most 255 characters`)),name:valibot.pipe((0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`name`),valibot.minLength(3,`Expected registration name to be at least 3 characters`),valibot.maxLength(255,`Expected registration name to be at most 255 characters`)),description:valibot.optional(valibot.pipe((0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`description`),valibot.maxLength(5e3,`Expected description to be at most 5000 characters`))),webhookUrl:valibot.optional(valibot.pipe((0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`webhookUrl`),valibot.maxLength(4e3,`Expected webhook URL to be at most 4000 characters`))),eventsOfInterest:EventsOfInterestArraySchema,deliveryType:DeliveryTypeSchema,runtimeAction:valibot.optional(valibot.pipe((0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`runtimeAction`),valibot.maxLength(255,`Expected runtime action to be at most 255 characters`))),enabled:valibot.optional((0,_aio_commerce_sdk_common_utils_valibot.booleanValueSchema)(`enabled`)),destinationMetadata:valibot.optional(DestinationMetadataSchema),subscriberFilters:valibot.optional(valibot.pipe(valibot.array(SubscriberFilterSchema,`Expected subscriberFilters to be an array of subscriber filter objects`),valibot.maxLength(1,`Expected at most 1 subscriber filter`)))}),GetAllRegistrationsParamsSchema=WorkspacePathParamsSchema,GetAllRegistrationsByConsumerOrgParamsSchema=valibot.object({consumerOrgId:(0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`consumerOrgId`)}),GetRegistrationByIdParamsSchema=valibot.object({...WorkspacePathParamsSchema.entries,registrationId:(0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`registrationId`)}),CreateRegistrationParamsSchema=valibot.object({...WorkspacePathParamsSchema.entries,...RegistrationBodySchema.entries}),UpdateRegistrationParamsSchema=valibot.object({...WorkspacePathParamsSchema.entries,registrationId:(0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`registrationId`),...RegistrationBodySchema.entries}),DeleteRegistrationParamsSchema=valibot.object({...WorkspacePathParamsSchema.entries,registrationId:(0,_aio_commerce_sdk_common_utils_valibot.stringValueSchema)(`registrationId`)});var endpoints_exports=require_chunk.t({createRegistration:()=>createRegistration,deleteRegistration:()=>deleteRegistration,getAllRegistrations:()=>getAllRegistrations,getAllRegistrationsByConsumerOrg:()=>getAllRegistrationsByConsumerOrg,getRegistrationById:()=>getRegistrationById,updateRegistration:()=>updateRegistration});async function getAllRegistrationsByConsumerOrg(httpClient,params,fetchOptions){let validatedParams=(0,_aio_commerce_sdk_common_utils_valibot.parseOrThrow)(GetAllRegistrationsByConsumerOrgParamsSchema,params);return httpClient.extend({hooks:{afterResponse:[(0,_adobe_aio_commerce_lib_api_utils.buildCamelCaseKeysResponseHook)()]}}).get(`${validatedParams.consumerOrgId}/registrations`,fetchOptions).json()}async function getAllRegistrations(httpClient,params,fetchOptions){let validatedParams=(0,_aio_commerce_sdk_common_utils_valibot.parseOrThrow)(GetAllRegistrationsParamsSchema,params);return httpClient.extend({hooks:{afterResponse:[(0,_adobe_aio_commerce_lib_api_utils.buildCamelCaseKeysResponseHook)()]}}).get(`${validatedParams.consumerOrgId}/${validatedParams.projectId}/${validatedParams.workspaceId}/registrations`,fetchOptions).json()}async function getRegistrationById(httpClient,params,fetchOptions){let validatedParams=(0,_aio_commerce_sdk_common_utils_valibot.parseOrThrow)(GetRegistrationByIdParamsSchema,params);return httpClient.extend({hooks:{afterResponse:[(0,_adobe_aio_commerce_lib_api_utils.buildCamelCaseKeysResponseHook)()]}}).get(`${validatedParams.consumerOrgId}/${validatedParams.projectId}/${validatedParams.workspaceId}/registrations/${validatedParams.registrationId}`,fetchOptions).json()}async function createRegistration(httpClient,params,fetchOptions){let validatedParams=(0,_aio_commerce_sdk_common_utils_valibot.parseOrThrow)(CreateRegistrationParamsSchema,params);return httpClient.extend({hooks:{afterResponse:[(0,_adobe_aio_commerce_lib_api_utils.buildCamelCaseKeysResponseHook)()]}}).post(`${validatedParams.consumerOrgId}/${validatedParams.projectId}/${validatedParams.workspaceId}/registrations`,{...fetchOptions,json:{client_id:validatedParams.clientId,name:validatedParams.name,description:validatedParams.description,webhook_url:validatedParams.webhookUrl,events_of_interest:validatedParams.eventsOfInterest.map(event=>({provider_id:event.providerId,event_code:event.eventCode,provider_metadata_id:event.providerMetadataId})),delivery_type:validatedParams.deliveryType,runtime_action:validatedParams.runtimeAction,enabled:validatedParams.enabled,destination_metadata:validatedParams.destinationMetadata?{aws_region:validatedParams.destinationMetadata.awsRegion,aws_account_id:validatedParams.destinationMetadata.awsAccountId}:void 0,subscriber_filters:validatedParams.subscriberFilters?.map(filter=>({name:filter.name,description:filter.description,subscriber_filter:filter.subscriberFilter}))}}).json()}async function updateRegistration(httpClient,params,fetchOptions){let validatedParams=(0,_aio_commerce_sdk_common_utils_valibot.parseOrThrow)(UpdateRegistrationParamsSchema,params);return httpClient.extend({hooks:{afterResponse:[(0,_adobe_aio_commerce_lib_api_utils.buildCamelCaseKeysResponseHook)()]}}).put(`${validatedParams.consumerOrgId}/${validatedParams.projectId}/${validatedParams.workspaceId}/registrations/${validatedParams.registrationId}`,{...fetchOptions,json:{name:validatedParams.name,description:validatedParams.description,webhook_url:validatedParams.webhookUrl,events_of_interest:validatedParams.eventsOfInterest.map(event=>({provider_id:event.providerId,event_code:event.eventCode,provider_metadata_id:event.providerMetadataId})),delivery_type:validatedParams.deliveryType,runtime_action:validatedParams.runtimeAction,enabled:validatedParams.enabled,destination_metadata:validatedParams.destinationMetadata?{aws_region:validatedParams.destinationMetadata.awsRegion,aws_account_id:validatedParams.destinationMetadata.awsAccountId}:void 0,subscriber_filters:validatedParams.subscriberFilters?.map(filter=>({name:filter.name,description:filter.description,subscriber_filter:filter.subscriberFilter}))}}).json()}async function deleteRegistration(httpClient,params,fetchOptions){let validatedParams=(0,_aio_commerce_sdk_common_utils_valibot.parseOrThrow)(DeleteRegistrationParamsSchema,params);return httpClient.delete(`${validatedParams.consumerOrgId}/${validatedParams.projectId}/${validatedParams.workspaceId}/registrations/${validatedParams.registrationId}`,fetchOptions).then(_res=>{})}function createAdobeIoEventsApiClient(params){return _adobe_aio_commerce_lib_api.ApiClient.create(new _adobe_aio_commerce_lib_api.AdobeIoEventsHttpClient(params),{...endpoints_exports$1,...endpoints_exports$2,...shorthands_exports,...endpoints_exports})}function createCustomAdobeIoEventsApiClient(params,functions){return _adobe_aio_commerce_lib_api.ApiClient.create(new _adobe_aio_commerce_lib_api.AdobeIoEventsHttpClient(params),functions)}exports.create3rdPartyCustomEventProvider=create3rdPartyCustomEventProvider,exports.createAdobeIoEventsApiClient=createAdobeIoEventsApiClient,exports.createCommerceEventProvider=createCommerceEventProvider,exports.createCustomAdobeIoEventsApiClient=createCustomAdobeIoEventsApiClient,exports.createEventMetadataForProvider=createEventMetadataForProvider,exports.createEventProvider=createEventProvider,exports.createRegistration=createRegistration,exports.deleteRegistration=deleteRegistration,exports.getAll3rdPartyCustomEventProviders=getAll3rdPartyCustomEventProviders,exports.getAllCommerceEventProviders=getAllCommerceEventProviders,exports.getAllEventMetadataForProvider=getAllEventMetadataForProvider,exports.getAllEventProviders=getAllEventProviders,exports.getAllRegistrations=getAllRegistrations,exports.getAllRegistrationsByConsumerOrg=getAllRegistrationsByConsumerOrg,exports.getEventMetadataForEventAndProvider=getEventMetadataForEventAndProvider,exports.getEventProviderById=getEventProviderById,exports.getRegistrationById=getRegistrationById,exports.updateRegistration=updateRegistration;
|
|
1
|
+
const require_utils=require(`../utils-rfIzwBMe.cjs`);let valibot=require(`valibot`);valibot=require_utils.s(valibot);let _adobe_aio_commerce_lib_api=require(`@adobe/aio-commerce-lib-api`);const BASE64_ENCODED_STRING_REGEX=/^[A-Za-z0-9+/]*={0,2}$/,BASE64_ENCODED_STRING_LENGTH_REMAINDER=4;function isBase64EncodedString(value){return BASE64_ENCODED_STRING_REGEX.test(value)&&value.length%4==0}function encodeToBase64(value){return Buffer.from(value).toString(`base64`)}function tryDecodeFromBase64(value){return isBase64EncodedString(value)?Buffer.from(value,`base64`).toString(`utf-8`):value}function sampleEventTemplateSchema(fieldName){return valibot.pipe(valibot.union([valibot.pipe(require_utils.a(fieldName),valibot.transform(tryDecodeFromBase64),valibot.parseJson(void 0,`Expected valid JSON string for property '${fieldName}'`),valibot.record(valibot.string(),valibot.unknown())),valibot.record(valibot.string(),valibot.unknown()),valibot.array(valibot.unknown())]),valibot.stringifyJson(void 0,`Expected valid JSON data for property '${fieldName}'`),valibot.transform(encodeToBase64))}const GetAllEventMetadataForProviderSchema=valibot.object({providerId:require_utils.a(`providerId`)}),GetEventMetadataForEventAndProviderSchema=valibot.object({eventCode:require_utils.a(`eventCode`),providerId:require_utils.a(`providerId`)}),CreateEventMetadataForProviderSchema=valibot.object({consumerOrgId:require_utils.a(`consumerOrgId`),projectId:require_utils.a(`projectId`),workspaceId:require_utils.a(`workspaceId`),providerId:require_utils.a(`providerId`),label:require_utils.a(`label`),description:require_utils.a(`description`),eventCode:require_utils.a(`eventCode`),sampleEventTemplate:valibot.optional(sampleEventTemplateSchema(`sampleEventTemplate`))});var endpoints_exports$2=require_utils.o({createEventMetadataForProvider:()=>createEventMetadataForProvider,getAllEventMetadataForProvider:()=>getAllEventMetadataForProvider,getEventMetadataForEventAndProvider:()=>getEventMetadataForEventAndProvider});async function getAllEventMetadataForProvider(httpClient,params,fetchOptions){let validatedParams=require_utils.t(GetAllEventMetadataForProviderSchema,params);return httpClient.get(`providers/${validatedParams.providerId}/eventmetadata`,fetchOptions).json()}async function getEventMetadataForEventAndProvider(httpClient,params,fetchOptions){let validatedParams=require_utils.t(GetEventMetadataForEventAndProviderSchema,params);return httpClient.get(`providers/${validatedParams.providerId}/eventmetadata/${validatedParams.eventCode}`,fetchOptions).json()}async function createEventMetadataForProvider(httpClient,params,fetchOptions){let validatedParams=require_utils.t(CreateEventMetadataForProviderSchema,params);return httpClient.post(`${validatedParams.consumerOrgId}/${validatedParams.projectId}/${validatedParams.workspaceId}/providers/${validatedParams.providerId}/eventmetadata`,{...fetchOptions,json:{label:validatedParams.label,description:validatedParams.description,event_code:validatedParams.eventCode,sample_event_template:validatedParams.sampleEventTemplate}}).json()}function setQueryParamIfTruthy(queryParams,key,value){value&&queryParams.set(key,`${value}`)}function setArrayQueryParam(queryParams,key,values){if(values!==void 0&&values.length>0)for(let value of values)queryParams.set(key,`${value}`)}const VALID_EVENT_PROVIDER_TYPES=[`dx_commerce_events`,`3rd_party_custom_events`],VALID_DATA_RESIDENCY_REGIONS=[`va6`,`irl1`],EventProviderTypeSchema=valibot.picklist(VALID_EVENT_PROVIDER_TYPES),DataResidencyRegionSchema=valibot.picklist(VALID_DATA_RESIDENCY_REGIONS),EventProviderListAllParamsSchema=valibot.object({consumerOrgId:require_utils.a(`consumerOrgId`),withEventMetadata:valibot.optional(require_utils.i(`withEventMetadata`)),filterBy:valibot.optional(valibot.object({instanceId:valibot.optional(require_utils.a(`instanceId`)),providerTypes:valibot.optional(valibot.union([valibot.array(EventProviderTypeSchema,`Expected an array of event provider types`)]))}))}),EventProviderGetByIdParamsSchema=valibot.object({providerId:require_utils.a(`providerId`),withEventMetadata:valibot.optional(require_utils.i(`withEventMetadata`))}),EventProviderCreateParamsSchema=valibot.object({consumerOrgId:require_utils.a(`consumerOrgId`),projectId:require_utils.a(`projectId`),workspaceId:require_utils.a(`workspaceId`),label:require_utils.a(`label`),description:valibot.optional(require_utils.a(`description`)),docsUrl:valibot.optional(require_utils.a(`docsUrl`)),instanceId:valibot.optional(require_utils.a(`instanceId`)),providerType:valibot.optional(EventProviderTypeSchema),dataResidencyRegion:valibot.optional(DataResidencyRegionSchema)});var endpoints_exports$1=require_utils.o({createEventProvider:()=>createEventProvider,getAllEventProviders:()=>getAllEventProviders,getEventProviderById:()=>getEventProviderById});async function getAllEventProviders(httpClient,params,fetchOptions){let validatedParams=require_utils.t(EventProviderListAllParamsSchema,params),queryParams=new URLSearchParams,{providerTypes=[],instanceId}=validatedParams.filterBy??{};return setArrayQueryParam(queryParams,`providerMetadataIds`,providerTypes),setQueryParamIfTruthy(queryParams,`instanceId`,instanceId),setQueryParamIfTruthy(queryParams,`eventmetadata`,validatedParams.withEventMetadata),httpClient.get(`${validatedParams.consumerOrgId}/providers`,{...fetchOptions,searchParams:queryParams}).json()}async function getEventProviderById(httpClient,params,fetchOptions){let validatedParams=require_utils.t(EventProviderGetByIdParamsSchema,params),searchParams=new URLSearchParams;return setQueryParamIfTruthy(searchParams,`eventmetadata`,validatedParams.withEventMetadata),httpClient.get(`providers/${params.providerId}`,{...fetchOptions,searchParams}).json()}async function createEventProvider(httpClient,params,fetchOptions){let validatedParams=require_utils.t(EventProviderCreateParamsSchema,params);return httpClient.post(`${validatedParams.consumerOrgId}/${validatedParams.projectId}/${validatedParams.workspaceId}/providers`,{...fetchOptions,json:{...validatedParams,docs_url:validatedParams.docsUrl,provider_metadata:validatedParams.providerType,instance_id:validatedParams.instanceId,data_residency_region:validatedParams.dataResidencyRegion}}).json()}var shorthands_exports=require_utils.o({create3rdPartyCustomEventProvider:()=>create3rdPartyCustomEventProvider,createCommerceEventProvider:()=>createCommerceEventProvider,getAll3rdPartyCustomEventProviders:()=>getAll3rdPartyCustomEventProviders,getAllCommerceEventProviders:()=>getAllCommerceEventProviders});async function getAllCommerceEventProviders(httpClient,params,fetchOptions){return getAllEventProviders(httpClient,{...params,filterBy:{...params.filterBy,providerTypes:[`dx_commerce_events`]}},fetchOptions)}async function getAll3rdPartyCustomEventProviders(httpClient,params,fetchOptions){return getAllEventProviders(httpClient,{...params,filterBy:{...params.filterBy,providerTypes:[`3rd_party_custom_events`]}},fetchOptions)}async function createCommerceEventProvider(httpClient,params,fetchOptions){return createEventProvider(httpClient,{...params,providerType:`dx_commerce_events`},fetchOptions)}async function create3rdPartyCustomEventProvider(httpClient,params,fetchOptions){return createEventProvider(httpClient,{...params,providerType:`3rd_party_custom_events`},fetchOptions)}const VALID_DELIVERY_TYPES=[`webhook`,`webhook_batch`,`journal`,`aws_eventbridge`],AWS_REGION_REGEX=/^(us|ca|eu|af|ap|cn|me|sa|il)-[a-z]+-\d$/,AWS_ACCOUNT_ID_REGEX=/^\d{12}$/,DeliveryTypeSchema=valibot.picklist(VALID_DELIVERY_TYPES,`Expected delivery type to be one of: ${VALID_DELIVERY_TYPES.join(`, `)}`),EventsOfInterestSchema=valibot.object({providerId:require_utils.a(`providerId`),eventCode:require_utils.a(`eventCode`),providerMetadataId:valibot.optional(require_utils.a(`providerMetadataId`))}),DestinationMetadataSchema=valibot.object({awsRegion:valibot.optional(valibot.pipe(require_utils.a(`awsRegion`),valibot.regex(AWS_REGION_REGEX,`Expected AWS region in format like 'us-east-1'`))),awsAccountId:valibot.optional(valibot.pipe(require_utils.a(`awsAccountId`),valibot.regex(AWS_ACCOUNT_ID_REGEX,`Expected AWS account ID to be a 12-digit number`)))}),SubscriberFilterSchema=valibot.object({name:valibot.pipe(require_utils.a(`name`),valibot.minLength(3,`Expected subscriber filter name to be at least 3 characters`),valibot.maxLength(80,`Expected subscriber filter name to be at most 80 characters`)),description:valibot.optional(valibot.pipe(require_utils.a(`description`),valibot.maxLength(250,`Expected subscriber filter description to be at most 250 characters`))),subscriberFilter:require_utils.a(`subscriberFilter`)}),WorkspacePathParamsSchema=valibot.object({consumerOrgId:require_utils.a(`consumerOrgId`),projectId:require_utils.a(`projectId`),workspaceId:require_utils.a(`workspaceId`)}),EventsOfInterestArraySchema=valibot.pipe(valibot.array(EventsOfInterestSchema,`Expected eventsOfInterest to be an array of event interest objects`),valibot.minLength(1,`Expected at least one event of interest`)),RegistrationBodySchema=valibot.object({clientId:valibot.pipe(require_utils.a(`clientId`),valibot.minLength(3,`Expected clientId to be at least 1 character`),valibot.maxLength(255,`Expected clientId to be at most 255 characters`)),name:valibot.pipe(require_utils.a(`name`),valibot.minLength(3,`Expected registration name to be at least 3 characters`),valibot.maxLength(255,`Expected registration name to be at most 255 characters`)),description:valibot.optional(valibot.pipe(require_utils.a(`description`),valibot.maxLength(5e3,`Expected description to be at most 5000 characters`))),webhookUrl:valibot.optional(valibot.pipe(require_utils.a(`webhookUrl`),valibot.maxLength(4e3,`Expected webhook URL to be at most 4000 characters`))),eventsOfInterest:EventsOfInterestArraySchema,deliveryType:DeliveryTypeSchema,runtimeAction:valibot.optional(valibot.pipe(require_utils.a(`runtimeAction`),valibot.maxLength(255,`Expected runtime action to be at most 255 characters`))),enabled:valibot.optional(require_utils.i(`enabled`)),destinationMetadata:valibot.optional(DestinationMetadataSchema),subscriberFilters:valibot.optional(valibot.pipe(valibot.array(SubscriberFilterSchema,`Expected subscriberFilters to be an array of subscriber filter objects`),valibot.maxLength(1,`Expected at most 1 subscriber filter`)))}),GetAllRegistrationsParamsSchema=WorkspacePathParamsSchema,GetAllRegistrationsByConsumerOrgParamsSchema=valibot.object({consumerOrgId:require_utils.a(`consumerOrgId`)}),GetRegistrationByIdParamsSchema=valibot.object({...WorkspacePathParamsSchema.entries,registrationId:require_utils.a(`registrationId`)}),CreateRegistrationParamsSchema=valibot.object({...WorkspacePathParamsSchema.entries,...RegistrationBodySchema.entries}),UpdateRegistrationParamsSchema=valibot.object({...WorkspacePathParamsSchema.entries,registrationId:require_utils.a(`registrationId`),...RegistrationBodySchema.entries}),DeleteRegistrationParamsSchema=valibot.object({...WorkspacePathParamsSchema.entries,registrationId:require_utils.a(`registrationId`)});var endpoints_exports=require_utils.o({createRegistration:()=>createRegistration,deleteRegistration:()=>deleteRegistration,getAllRegistrations:()=>getAllRegistrations,getAllRegistrationsByConsumerOrg:()=>getAllRegistrationsByConsumerOrg,getRegistrationById:()=>getRegistrationById,updateRegistration:()=>updateRegistration});async function getAllRegistrationsByConsumerOrg(httpClient,params,fetchOptions){let validatedParams=require_utils.t(GetAllRegistrationsByConsumerOrgParamsSchema,params);return httpClient.get(`${validatedParams.consumerOrgId}/registrations`,fetchOptions).json()}async function getAllRegistrations(httpClient,params,fetchOptions){let validatedParams=require_utils.t(GetAllRegistrationsParamsSchema,params);return httpClient.get(`${validatedParams.consumerOrgId}/${validatedParams.projectId}/${validatedParams.workspaceId}/registrations`,fetchOptions).json()}async function getRegistrationById(httpClient,params,fetchOptions){let validatedParams=require_utils.t(GetRegistrationByIdParamsSchema,params);return httpClient.get(`${validatedParams.consumerOrgId}/${validatedParams.projectId}/${validatedParams.workspaceId}/registrations/${validatedParams.registrationId}`,fetchOptions).json()}async function createRegistration(httpClient,params,fetchOptions){let validatedParams=require_utils.t(CreateRegistrationParamsSchema,params);return httpClient.post(`${validatedParams.consumerOrgId}/${validatedParams.projectId}/${validatedParams.workspaceId}/registrations`,{...fetchOptions,json:{client_id:validatedParams.clientId,name:validatedParams.name,description:validatedParams.description,webhook_url:validatedParams.webhookUrl,events_of_interest:validatedParams.eventsOfInterest.map(event=>({provider_id:event.providerId,event_code:event.eventCode,provider_metadata_id:event.providerMetadataId})),delivery_type:validatedParams.deliveryType,runtime_action:validatedParams.runtimeAction,enabled:validatedParams.enabled,destination_metadata:validatedParams.destinationMetadata?{aws_region:validatedParams.destinationMetadata.awsRegion,aws_account_id:validatedParams.destinationMetadata.awsAccountId}:void 0,subscriber_filters:validatedParams.subscriberFilters?.map(filter=>({name:filter.name,description:filter.description,subscriber_filter:filter.subscriberFilter}))}}).json()}async function updateRegistration(httpClient,params,fetchOptions){let validatedParams=require_utils.t(UpdateRegistrationParamsSchema,params);return httpClient.put(`${validatedParams.consumerOrgId}/${validatedParams.projectId}/${validatedParams.workspaceId}/registrations/${validatedParams.registrationId}`,{...fetchOptions,json:{name:validatedParams.name,description:validatedParams.description,webhook_url:validatedParams.webhookUrl,events_of_interest:validatedParams.eventsOfInterest.map(event=>({provider_id:event.providerId,event_code:event.eventCode,provider_metadata_id:event.providerMetadataId})),delivery_type:validatedParams.deliveryType,runtime_action:validatedParams.runtimeAction,enabled:validatedParams.enabled,destination_metadata:validatedParams.destinationMetadata?{aws_region:validatedParams.destinationMetadata.awsRegion,aws_account_id:validatedParams.destinationMetadata.awsAccountId}:void 0,subscriber_filters:validatedParams.subscriberFilters?.map(filter=>({name:filter.name,description:filter.description,subscriber_filter:filter.subscriberFilter}))}}).json()}async function deleteRegistration(httpClient,params,fetchOptions){let validatedParams=require_utils.t(DeleteRegistrationParamsSchema,params);return httpClient.delete(`${validatedParams.consumerOrgId}/${validatedParams.projectId}/${validatedParams.workspaceId}/registrations/${validatedParams.registrationId}`,fetchOptions).then(_res=>{})}function createAdobeIoEventsApiClient(params){return _adobe_aio_commerce_lib_api.ApiClient.create(new _adobe_aio_commerce_lib_api.AdobeIoEventsHttpClient(params),{...endpoints_exports$1,...endpoints_exports$2,...shorthands_exports,...endpoints_exports})}function createCustomAdobeIoEventsApiClient(params,functions){return _adobe_aio_commerce_lib_api.ApiClient.create(new _adobe_aio_commerce_lib_api.AdobeIoEventsHttpClient(params),functions)}exports.create3rdPartyCustomEventProvider=create3rdPartyCustomEventProvider,exports.createAdobeIoEventsApiClient=createAdobeIoEventsApiClient,exports.createCommerceEventProvider=createCommerceEventProvider,exports.createCustomAdobeIoEventsApiClient=createCustomAdobeIoEventsApiClient,exports.createEventMetadataForProvider=createEventMetadataForProvider,exports.createEventProvider=createEventProvider,exports.createRegistration=createRegistration,exports.deleteRegistration=deleteRegistration,exports.getAll3rdPartyCustomEventProviders=getAll3rdPartyCustomEventProviders,exports.getAllCommerceEventProviders=getAllCommerceEventProviders,exports.getAllEventMetadataForProvider=getAllEventMetadataForProvider,exports.getAllEventProviders=getAllEventProviders,exports.getAllRegistrations=getAllRegistrations,exports.getAllRegistrationsByConsumerOrg=getAllRegistrationsByConsumerOrg,exports.getEventMetadataForEventAndProvider=getEventMetadataForEventAndProvider,exports.getEventProviderById=getEventProviderById,exports.getRegistrationById=getRegistrationById,exports.updateRegistration=updateRegistration;
|