@adobe/aio-commerce-lib-events 0.3.4 → 0.3.6
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 +18 -0
- package/dist/cjs/commerce/index.cjs +1 -1
- package/dist/cjs/commerce/index.d.cts +4 -4
- package/dist/cjs/io-events/index.cjs +1 -1
- package/dist/cjs/schemas-CwY-HoKq.cjs +14 -0
- package/dist/es/commerce/{index.d.ts → index.d.mts} +13 -13
- package/dist/es/commerce/index.mjs +14 -0
- package/dist/es/io-events/{index.d.ts → index.d.mts} +14 -14
- package/dist/es/io-events/index.mjs +14 -0
- package/dist/es/schemas-D5c1tsDe.mjs +14 -0
- package/package.json +11 -19
- package/dist/cjs/schemas-wR6n5bUK.cjs +0 -14
- package/dist/es/commerce/index.js +0 -14
- package/dist/es/io-events/index.js +0 -14
- package/dist/es/schemas-BLvngVRY.js +0 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @adobe/aio-commerce-lib-events
|
|
2
2
|
|
|
3
|
+
## 0.3.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#171](https://github.com/adobe/aio-commerce-sdk/pull/171) [`9e4ad33`](https://github.com/adobe/aio-commerce-sdk/commit/9e4ad3363508e89878292ac898c81690f52ba456) Thanks [@iivvaannxx](https://github.com/iivvaannxx)! - Fix `exports` in `package.json` for proper resolution
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`9e4ad33`](https://github.com/adobe/aio-commerce-sdk/commit/9e4ad3363508e89878292ac898c81690f52ba456)]:
|
|
10
|
+
- @adobe/aio-commerce-lib-api@0.4.1
|
|
11
|
+
|
|
12
|
+
## 0.3.5
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#167](https://github.com/adobe/aio-commerce-sdk/pull/167) [`2745786`](https://github.com/adobe/aio-commerce-sdk/commit/274578686e07261b68d912adfa4bae040a807c3a) Thanks [@iivvaannxx](https://github.com/iivvaannxx)! - Fixes the usages of the `utils` entrypoint of `lib-api`
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [[`2745786`](https://github.com/adobe/aio-commerce-sdk/commit/274578686e07261b68d912adfa4bae040a807c3a)]:
|
|
19
|
+
- @adobe/aio-commerce-lib-api@0.4.0
|
|
20
|
+
|
|
3
21
|
## 0.3.4
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -11,4 +11,4 @@
|
|
|
11
11
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
|
-
const require_schemas=require(`../schemas-
|
|
14
|
+
const require_schemas=require(`../schemas-CwY-HoKq.cjs`);let __adobe_aio_commerce_lib_api_utils=require(`@adobe/aio-commerce-lib-api/utils`),__adobe_aio_commerce_lib_core_error=require(`@adobe/aio-commerce-lib-core/error`),valibot=require(`valibot`);valibot=require_schemas.s(valibot);let __adobe_aio_commerce_lib_api=require(`@adobe/aio-commerce-lib-api`);function workspaceConfigurationSchema(propertyName){return valibot.union([valibot.pipe(require_schemas.i(propertyName),valibot.empty()),valibot.pipe(require_schemas.i(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_schemas.i(`providerId`)}),EventProviderCreateParamsSchema=valibot.object({providerId:require_schemas.i(`providerId`),instanceId:require_schemas.i(`instanceId`),label:valibot.optional(require_schemas.i(`label`)),description:valibot.optional(require_schemas.i(`description`)),associatedWorkspaceConfiguration:valibot.optional(workspaceConfigurationSchema(`associatedWorkspaceConfiguration`))});var endpoints_exports=require_schemas.o({createEventProvider:()=>createEventProvider,getAllEventProviders:()=>getAllEventProviders,getEventProviderById:()=>getEventProviderById});async function getAllEventProviders(httpClient,fetchOptions){return httpClient.extend({hooks:{afterResponse:[(0,__adobe_aio_commerce_lib_api_utils.buildCamelCaseKeysResponseHook)()]}}).get(`eventing/eventProvider`,fetchOptions).json()}async function getEventProviderById(httpClient,params,fetchOptions){let validatedParams=require_schemas.a(EventProviderGetByIdParamsSchema,params);return httpClient.extend({hooks:{afterResponse:[(0,__adobe_aio_commerce_lib_api_utils.buildCamelCaseKeysResponseHook)()]}}).get(`eventing/eventProvider/${validatedParams.providerId}`,fetchOptions).json()}async function createEventProvider(httpClient,params,fetchOptions){let validatedParams=require_schemas.a(EventProviderCreateParamsSchema,params);return httpClient.extend({hooks:{afterResponse:[(0,__adobe_aio_commerce_lib_api_utils.buildCamelCaseKeysResponseHook)()]}}).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_schemas.i(`${propertyName}[i].name`)}),`Expected an array of objects with a 'name' property for the property "${propertyName}"`)}const EventSubscriptionCreateParamsSchema=valibot.object({name:require_schemas.i(`name`),providerId:valibot.optional(require_schemas.i(`providerId`)),parent:valibot.optional(require_schemas.i(`parent`)),fields:fieldsSchema(`fields`),destination:valibot.optional(require_schemas.i(`destination`)),hipaaAuditRequired:valibot.optional(require_schemas.r(`hipaaAuditRequired`)),prioritary:valibot.optional(require_schemas.r(`prioritary`)),force:valibot.optional(require_schemas.r(`force`))});var endpoints_exports$1=require_schemas.o({createEventSubscription:()=>createEventSubscription,getAllEventSubscriptions:()=>getAllEventSubscriptions});async function getAllEventSubscriptions(httpClient,fetchOptions){return httpClient.extend({hooks:{afterResponse:[(0,__adobe_aio_commerce_lib_api_utils.buildCamelCaseKeysResponseHook)()]}}).get(`eventing/getEventSubscriptions`,fetchOptions).json()}async function createEventSubscription(httpClient,params,fetchOptions){let{force,...event}=require_schemas.a(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_schemas.r(`enabled`),providerId:require_schemas.t(`providerId`),instanceId:require_schemas.t(`instanceId`),merchantId:require_schemas.n(`merchantId`),environmentId:require_schemas.n(`environmentId`),workspaceConfiguration:workspaceConfigurationSchema(`workspaceConfiguration`)}));async function updateEventingConfiguration(httpClient,params,fetchOptions){let validatedParams=require_schemas.a(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,...endpoints_exports$1,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;
|
|
@@ -229,9 +229,9 @@ declare const UpdateEventingConfigurationParamsSchema: Omit<v.ObjectSchema<{
|
|
|
229
229
|
merchantId?: string | undefined;
|
|
230
230
|
environmentId?: string | undefined;
|
|
231
231
|
workspaceConfiguration?: string | undefined;
|
|
232
|
-
}, v.
|
|
232
|
+
}, v.StringIssue | v.ObjectIssue | v.ParseJsonIssue<string> | v.RecordIssue | v.BooleanIssue | v.RegexIssue<string> | v.EmptyIssue<string> | v.StringifyJsonIssue<{
|
|
233
233
|
[x: string]: unknown;
|
|
234
|
-
}> | v.UnionIssue<v.StringIssue | v.
|
|
234
|
+
}> | v.UnionIssue<v.StringIssue | v.ParseJsonIssue<string> | v.RecordIssue | v.EmptyIssue<string> | v.StringifyJsonIssue<{
|
|
235
235
|
[x: string]: unknown;
|
|
236
236
|
}>>>;
|
|
237
237
|
readonly '~types'?: {
|
|
@@ -253,9 +253,9 @@ declare const UpdateEventingConfigurationParamsSchema: Omit<v.ObjectSchema<{
|
|
|
253
253
|
environmentId?: string | undefined;
|
|
254
254
|
workspaceConfiguration?: string | undefined;
|
|
255
255
|
};
|
|
256
|
-
readonly issue: v.
|
|
256
|
+
readonly issue: v.StringIssue | v.ObjectIssue | v.ParseJsonIssue<string> | v.RecordIssue | v.BooleanIssue | v.RegexIssue<string> | v.EmptyIssue<string> | v.StringifyJsonIssue<{
|
|
257
257
|
[x: string]: unknown;
|
|
258
|
-
}> | v.UnionIssue<v.StringIssue | v.
|
|
258
|
+
}> | v.UnionIssue<v.StringIssue | v.ParseJsonIssue<string> | v.RecordIssue | v.EmptyIssue<string> | v.StringifyJsonIssue<{
|
|
259
259
|
[x: string]: unknown;
|
|
260
260
|
}>>;
|
|
261
261
|
} | undefined;
|
|
@@ -11,4 +11,4 @@
|
|
|
11
11
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
|
-
const require_schemas=require(`../schemas-
|
|
14
|
+
const require_schemas=require(`../schemas-CwY-HoKq.cjs`);let __adobe_aio_commerce_lib_api_utils=require(`@adobe/aio-commerce-lib-api/utils`),valibot=require(`valibot`);valibot=require_schemas.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_schemas.i(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_schemas.i(`providerId`)}),GetEventMetadataForEventAndProviderSchema=valibot.object({eventCode:require_schemas.i(`eventCode`),providerId:require_schemas.i(`providerId`)}),CreateEventMetadataForProviderSchema=valibot.object({consumerOrgId:require_schemas.i(`consumerOrgId`),projectId:require_schemas.i(`projectId`),workspaceId:require_schemas.i(`workspaceId`),providerId:require_schemas.i(`providerId`),label:require_schemas.i(`label`),description:require_schemas.i(`description`),eventCode:require_schemas.i(`eventCode`),sampleEventTemplate:valibot.optional(sampleEventTemplateSchema(`sampleEventTemplate`))});var endpoints_exports=require_schemas.o({createEventMetadataForProvider:()=>createEventMetadataForProvider,getAllEventMetadataForProvider:()=>getAllEventMetadataForProvider,getEventMetadataForEventAndProvider:()=>getEventMetadataForEventAndProvider});async function getAllEventMetadataForProvider(httpClient,params,fetchOptions){let validatedParams=require_schemas.a(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=require_schemas.a(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=require_schemas.a(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:require_schemas.i(`consumerOrgId`),withEventMetadata:valibot.optional(require_schemas.r(`withEventMetadata`)),filterBy:valibot.optional(valibot.object({instanceId:valibot.optional(require_schemas.i(`instanceId`)),providerTypes:valibot.optional(valibot.union([valibot.array(EventProviderTypeSchema,`Expected an array of event provider types`)]))}))}),EventProviderGetByIdParamsSchema=valibot.object({providerId:require_schemas.i(`providerId`),withEventMetadata:valibot.optional(require_schemas.r(`withEventMetadata`))}),EventProviderCreateParamsSchema=valibot.object({consumerOrgId:require_schemas.i(`consumerOrgId`),projectId:require_schemas.i(`projectId`),workspaceId:require_schemas.i(`workspaceId`),label:require_schemas.i(`label`),description:valibot.optional(require_schemas.i(`description`)),docsUrl:valibot.optional(require_schemas.i(`docsUrl`)),instanceId:valibot.optional(require_schemas.i(`instanceId`)),providerType:valibot.optional(EventProviderTypeSchema),dataResidencyRegion:valibot.optional(DataResidencyRegionSchema)});var endpoints_exports$1=require_schemas.o({createEventProvider:()=>createEventProvider,getAllEventProviders:()=>getAllEventProviders,getEventProviderById:()=>getEventProviderById});async function getAllEventProviders(httpClient,params,fetchOptions){let validatedParams=require_schemas.a(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=require_schemas.a(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=require_schemas.a(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_schemas.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)}function createAdobeIoEventsApiClient(params){return __adobe_aio_commerce_lib_api.ApiClient.create(new __adobe_aio_commerce_lib_api.AdobeIoEventsHttpClient(params),{...endpoints_exports$1,...endpoints_exports,...shorthands_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.getAll3rdPartyCustomEventProviders=getAll3rdPartyCustomEventProviders,exports.getAllCommerceEventProviders=getAllCommerceEventProviders,exports.getAllEventMetadataForProvider=getAllEventMetadataForProvider,exports.getAllEventProviders=getAllEventProviders,exports.getEventMetadataForEventAndProvider=getEventMetadataForEventAndProvider,exports.getEventProviderById=getEventProviderById;
|
|
@@ -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=(all,symbols)=>{let target={};for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0});return symbols&&__defProp(target,Symbol.toStringTag,{value:`Module`}),target},__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));let __adobe_aio_commerce_lib_core_error=require(`@adobe/aio-commerce-lib-core/error`),valibot=require(`valibot`);valibot=__toESM(valibot);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}"`))}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return parseOrThrow}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return stringValueSchema}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return alphaNumericOrUnderscoreSchema}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return __export}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return booleanValueSchema}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return __toESM}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return alphaNumericOrUnderscoreOrHyphenSchema}});
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import * as v from "valibot";
|
|
16
|
-
import * as
|
|
16
|
+
import * as _adobe_aio_commerce_lib_api1 from "@adobe/aio-commerce-lib-api";
|
|
17
17
|
import { AdobeCommerceHttpClient, ApiFunction, CommerceHttpClientParams } from "@adobe/aio-commerce-lib-api";
|
|
18
18
|
import { Options } from "@adobe/aio-commerce-lib-api/ky";
|
|
19
19
|
import { CamelCasedPropertiesDeep } from "type-fest";
|
|
20
|
-
import * as
|
|
20
|
+
import * as ky9 from "ky";
|
|
21
21
|
|
|
22
22
|
//#region source/commerce/api/event-providers/schema.d.ts
|
|
23
23
|
declare const EventProviderGetByIdParamsSchema: v.ObjectSchema<{
|
|
@@ -229,9 +229,9 @@ declare const UpdateEventingConfigurationParamsSchema: Omit<v.ObjectSchema<{
|
|
|
229
229
|
merchantId?: string | undefined;
|
|
230
230
|
environmentId?: string | undefined;
|
|
231
231
|
workspaceConfiguration?: string | undefined;
|
|
232
|
-
}, v.
|
|
232
|
+
}, v.StringIssue | v.ObjectIssue | v.ParseJsonIssue<string> | v.RecordIssue | v.BooleanIssue | v.RegexIssue<string> | v.EmptyIssue<string> | v.StringifyJsonIssue<{
|
|
233
233
|
[x: string]: unknown;
|
|
234
|
-
}> | v.UnionIssue<v.StringIssue | v.
|
|
234
|
+
}> | v.UnionIssue<v.StringIssue | v.ParseJsonIssue<string> | v.RecordIssue | v.EmptyIssue<string> | v.StringifyJsonIssue<{
|
|
235
235
|
[x: string]: unknown;
|
|
236
236
|
}>>>;
|
|
237
237
|
readonly '~types'?: {
|
|
@@ -253,9 +253,9 @@ declare const UpdateEventingConfigurationParamsSchema: Omit<v.ObjectSchema<{
|
|
|
253
253
|
environmentId?: string | undefined;
|
|
254
254
|
workspaceConfiguration?: string | undefined;
|
|
255
255
|
};
|
|
256
|
-
readonly issue: v.
|
|
256
|
+
readonly issue: v.StringIssue | v.ObjectIssue | v.ParseJsonIssue<string> | v.RecordIssue | v.BooleanIssue | v.RegexIssue<string> | v.EmptyIssue<string> | v.StringifyJsonIssue<{
|
|
257
257
|
[x: string]: unknown;
|
|
258
|
-
}> | v.UnionIssue<v.StringIssue | v.
|
|
258
|
+
}> | v.UnionIssue<v.StringIssue | v.ParseJsonIssue<string> | v.RecordIssue | v.EmptyIssue<string> | v.StringifyJsonIssue<{
|
|
259
259
|
[x: string]: unknown;
|
|
260
260
|
}>>;
|
|
261
261
|
} | undefined;
|
|
@@ -285,12 +285,12 @@ declare function updateEventingConfiguration(httpClient: AdobeCommerceHttpClient
|
|
|
285
285
|
* Creates a new API client for the Commerce Events API client.
|
|
286
286
|
* @param params - The parameters to build the Commerce HTTP client that will communicate with the Commerce Events API.
|
|
287
287
|
*/
|
|
288
|
-
declare function createCommerceEventsApiClient(params: CommerceHttpClientParams):
|
|
288
|
+
declare function createCommerceEventsApiClient(params: CommerceHttpClientParams): _adobe_aio_commerce_lib_api1.ApiClientRecord<AdobeCommerceHttpClient, {
|
|
289
289
|
updateEventingConfiguration: typeof updateEventingConfiguration;
|
|
290
|
-
getAllEventSubscriptions(httpClient: AdobeCommerceHttpClient, fetchOptions?:
|
|
291
|
-
createEventSubscription(httpClient: AdobeCommerceHttpClient, params: EventSubscriptionCreateParams, fetchOptions?:
|
|
292
|
-
getAllEventProviders(httpClient: AdobeCommerceHttpClient, fetchOptions?:
|
|
293
|
-
getEventProviderById(httpClient: AdobeCommerceHttpClient, params: EventProviderGetByIdParams, fetchOptions?:
|
|
290
|
+
getAllEventSubscriptions(httpClient: AdobeCommerceHttpClient, fetchOptions?: ky9.Options): Promise<CommerceEventSubscriptionManyResponse>;
|
|
291
|
+
createEventSubscription(httpClient: AdobeCommerceHttpClient, params: EventSubscriptionCreateParams, fetchOptions?: ky9.Options): Promise<void>;
|
|
292
|
+
getAllEventProviders(httpClient: AdobeCommerceHttpClient, fetchOptions?: ky9.Options): Promise<CommerceEventProviderManyResponse>;
|
|
293
|
+
getEventProviderById(httpClient: AdobeCommerceHttpClient, params: EventProviderGetByIdParams, fetchOptions?: ky9.Options): Promise<{
|
|
294
294
|
id: string;
|
|
295
295
|
providerId: string;
|
|
296
296
|
instanceId?: string | undefined;
|
|
@@ -298,7 +298,7 @@ declare function createCommerceEventsApiClient(params: CommerceHttpClientParams)
|
|
|
298
298
|
description?: string | undefined;
|
|
299
299
|
workspaceConfiguration?: string | undefined;
|
|
300
300
|
}>;
|
|
301
|
-
createEventProvider(httpClient: AdobeCommerceHttpClient, params: EventProviderCreateParams, fetchOptions?:
|
|
301
|
+
createEventProvider(httpClient: AdobeCommerceHttpClient, params: EventProviderCreateParams, fetchOptions?: ky9.Options): Promise<{
|
|
302
302
|
id: string;
|
|
303
303
|
providerId: string;
|
|
304
304
|
instanceId?: string | undefined;
|
|
@@ -312,6 +312,6 @@ declare function createCommerceEventsApiClient(params: CommerceHttpClientParams)
|
|
|
312
312
|
* @param params - The parameters to build the Commerce HTTP client that will communicate with the Commerce Events API.
|
|
313
313
|
* @param functions - The API functions to include in the client.
|
|
314
314
|
*/
|
|
315
|
-
declare function createCustomCommerceEventsApiClient<TFunctions extends Record<string, ApiFunction<AdobeCommerceHttpClient, any[], any>>>(params: CommerceHttpClientParams, functions: TFunctions):
|
|
315
|
+
declare function createCustomCommerceEventsApiClient<TFunctions extends Record<string, ApiFunction<AdobeCommerceHttpClient, any[], any>>>(params: CommerceHttpClientParams, functions: TFunctions): _adobe_aio_commerce_lib_api1.ApiClientRecord<AdobeCommerceHttpClient, TFunctions>;
|
|
316
316
|
//#endregion
|
|
317
317
|
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{a as parseOrThrow,i as stringValueSchema,n as alphaNumericOrUnderscoreSchema,o as __export,r as booleanValueSchema,t as alphaNumericOrUnderscoreOrHyphenSchema}from"../schemas-D5c1tsDe.mjs";import{buildCamelCaseKeysResponseHook}from"@adobe/aio-commerce-lib-api/utils";import{CommerceSdkValidationError}from"@adobe/aio-commerce-lib-core/error";import*as v from"valibot";import{AdobeCommerceHttpClient,ApiClient}from"@adobe/aio-commerce-lib-api";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({createEventProvider:()=>createEventProvider,getAllEventProviders:()=>getAllEventProviders,getEventProviderById:()=>getEventProviderById});async function getAllEventProviders(httpClient,fetchOptions){return httpClient.extend({hooks:{afterResponse:[buildCamelCaseKeysResponseHook()]}}).get(`eventing/eventProvider`,fetchOptions).json()}async function getEventProviderById(httpClient,params,fetchOptions){let validatedParams=parseOrThrow(EventProviderGetByIdParamsSchema,params);return httpClient.extend({hooks:{afterResponse:[buildCamelCaseKeysResponseHook()]}}).get(`eventing/eventProvider/${validatedParams.providerId}`,fetchOptions).json()}async function createEventProvider(httpClient,params,fetchOptions){let validatedParams=parseOrThrow(EventProviderCreateParamsSchema,params);return httpClient.extend({hooks:{afterResponse:[buildCamelCaseKeysResponseHook()]}}).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({createEventSubscription:()=>createEventSubscription,getAllEventSubscriptions:()=>getAllEventSubscriptions});async function getAllEventSubscriptions(httpClient,fetchOptions){return httpClient.extend({hooks:{afterResponse:[buildCamelCaseKeysResponseHook()]}}).get(`eventing/getEventSubscriptions`,fetchOptions).json()}async function createEventSubscription(httpClient,params,fetchOptions){let{force,...event}=parseOrThrow(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=v.partial(v.object({enabled:booleanValueSchema(`enabled`),providerId:alphaNumericOrUnderscoreOrHyphenSchema(`providerId`),instanceId:alphaNumericOrUnderscoreOrHyphenSchema(`instanceId`),merchantId:alphaNumericOrUnderscoreSchema(`merchantId`),environmentId:alphaNumericOrUnderscoreSchema(`environmentId`),workspaceConfiguration:workspaceConfigurationSchema(`workspaceConfiguration`)}));async function updateEventingConfiguration(httpClient,params,fetchOptions){let validatedParams=parseOrThrow(UpdateEventingConfigurationParamsSchema,params);return httpClient.put(`eventing/updateConfiguration`,{...fetchOptions,json:{config:validatedParams}}).json()}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};
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import * as v from "valibot";
|
|
16
|
-
import * as
|
|
16
|
+
import * as _adobe_aio_commerce_lib_api0 from "@adobe/aio-commerce-lib-api";
|
|
17
17
|
import { AdobeIoEventsHttpClient, ApiFunction, IoEventsHttpClientParams } from "@adobe/aio-commerce-lib-api";
|
|
18
18
|
import { Options } from "@adobe/aio-commerce-lib-api/ky";
|
|
19
19
|
import * as type_fest0 from "type-fest";
|
|
20
20
|
import { CamelCasedPropertiesDeep, OmitDeep } from "type-fest";
|
|
21
|
-
import * as
|
|
21
|
+
import * as ky0 from "ky";
|
|
22
22
|
|
|
23
23
|
//#region source/io-events/api/event-metadata/schema.d.ts
|
|
24
24
|
/** The schema of the parameters received by the GET `providers/:id/eventmetadata` Adobe I/O Events API endpoint. */
|
|
@@ -1119,8 +1119,8 @@ declare function create3rdPartyCustomEventProvider(httpClient: AdobeIoEventsHttp
|
|
|
1119
1119
|
* Creates a new API client for the Adobe I/O Events API client.
|
|
1120
1120
|
* @param params - The parameters to build the Adobe I/O Events HTTP client that will communicate with the Adobe I/O Events API.
|
|
1121
1121
|
*/
|
|
1122
|
-
declare function createAdobeIoEventsApiClient(params: IoEventsHttpClientParams):
|
|
1123
|
-
getAllCommerceEventProviders(httpClient: AdobeIoEventsHttpClient, params: type_fest0.OmitDeep<EventProviderListAllParams, "filterBy.providerType">, fetchOptions?:
|
|
1122
|
+
declare function createAdobeIoEventsApiClient(params: IoEventsHttpClientParams): _adobe_aio_commerce_lib_api0.ApiClientRecord<AdobeIoEventsHttpClient, {
|
|
1123
|
+
getAllCommerceEventProviders(httpClient: AdobeIoEventsHttpClient, params: type_fest0.OmitDeep<EventProviderListAllParams, "filterBy.providerType">, fetchOptions?: ky0.Options): Promise<{
|
|
1124
1124
|
embedded: {
|
|
1125
1125
|
providers: {
|
|
1126
1126
|
id: string;
|
|
@@ -1233,7 +1233,7 @@ declare function createAdobeIoEventsApiClient(params: IoEventsHttpClientParams):
|
|
|
1233
1233
|
};
|
|
1234
1234
|
};
|
|
1235
1235
|
}>;
|
|
1236
|
-
getAll3rdPartyCustomEventProviders(httpClient: AdobeIoEventsHttpClient, params: type_fest0.OmitDeep<EventProviderListAllParams, "filterBy.providerType">, fetchOptions?:
|
|
1236
|
+
getAll3rdPartyCustomEventProviders(httpClient: AdobeIoEventsHttpClient, params: type_fest0.OmitDeep<EventProviderListAllParams, "filterBy.providerType">, fetchOptions?: ky0.Options): Promise<{
|
|
1237
1237
|
embedded: {
|
|
1238
1238
|
providers: {
|
|
1239
1239
|
id: string;
|
|
@@ -1346,7 +1346,7 @@ declare function createAdobeIoEventsApiClient(params: IoEventsHttpClientParams):
|
|
|
1346
1346
|
};
|
|
1347
1347
|
};
|
|
1348
1348
|
}>;
|
|
1349
|
-
createCommerceEventProvider(httpClient: AdobeIoEventsHttpClient, params: type_fest0.OmitDeep<EventProviderCreateParams, "providerType">, fetchOptions?:
|
|
1349
|
+
createCommerceEventProvider(httpClient: AdobeIoEventsHttpClient, params: type_fest0.OmitDeep<EventProviderCreateParams, "providerType">, fetchOptions?: ky0.Options): Promise<{
|
|
1350
1350
|
id: string;
|
|
1351
1351
|
instanceId?: string | undefined;
|
|
1352
1352
|
label: string;
|
|
@@ -1442,7 +1442,7 @@ declare function createAdobeIoEventsApiClient(params: IoEventsHttpClientParams):
|
|
|
1442
1442
|
} | undefined;
|
|
1443
1443
|
};
|
|
1444
1444
|
}>;
|
|
1445
|
-
create3rdPartyCustomEventProvider(httpClient: AdobeIoEventsHttpClient, params: type_fest0.OmitDeep<EventProviderCreateParams, "providerType">, fetchOptions?:
|
|
1445
|
+
create3rdPartyCustomEventProvider(httpClient: AdobeIoEventsHttpClient, params: type_fest0.OmitDeep<EventProviderCreateParams, "providerType">, fetchOptions?: ky0.Options): Promise<{
|
|
1446
1446
|
id: string;
|
|
1447
1447
|
instanceId?: string | undefined;
|
|
1448
1448
|
label: string;
|
|
@@ -1538,7 +1538,7 @@ declare function createAdobeIoEventsApiClient(params: IoEventsHttpClientParams):
|
|
|
1538
1538
|
} | undefined;
|
|
1539
1539
|
};
|
|
1540
1540
|
}>;
|
|
1541
|
-
getAllEventMetadataForProvider(httpClient: AdobeIoEventsHttpClient, params: GetAllEventMetadataForProviderParams, fetchOptions?:
|
|
1541
|
+
getAllEventMetadataForProvider(httpClient: AdobeIoEventsHttpClient, params: GetAllEventMetadataForProviderParams, fetchOptions?: ky0.Options): Promise<{
|
|
1542
1542
|
embedded: {
|
|
1543
1543
|
description: string;
|
|
1544
1544
|
label: string;
|
|
@@ -1599,7 +1599,7 @@ declare function createAdobeIoEventsApiClient(params: IoEventsHttpClientParams):
|
|
|
1599
1599
|
};
|
|
1600
1600
|
}[];
|
|
1601
1601
|
}>;
|
|
1602
|
-
getEventMetadataForEventAndProvider(httpClient: AdobeIoEventsHttpClient, params: GetEventMetadataForEventAndProviderParams, fetchOptions?:
|
|
1602
|
+
getEventMetadataForEventAndProvider(httpClient: AdobeIoEventsHttpClient, params: GetEventMetadataForEventAndProviderParams, fetchOptions?: ky0.Options): Promise<{
|
|
1603
1603
|
description: string;
|
|
1604
1604
|
label: string;
|
|
1605
1605
|
eventCode: string;
|
|
@@ -1658,7 +1658,7 @@ declare function createAdobeIoEventsApiClient(params: IoEventsHttpClientParams):
|
|
|
1658
1658
|
};
|
|
1659
1659
|
};
|
|
1660
1660
|
}>;
|
|
1661
|
-
createEventMetadataForProvider(httpClient: AdobeIoEventsHttpClient, params: CreateEventMetadataForProviderParams, fetchOptions?:
|
|
1661
|
+
createEventMetadataForProvider(httpClient: AdobeIoEventsHttpClient, params: CreateEventMetadataForProviderParams, fetchOptions?: ky0.Options): Promise<{
|
|
1662
1662
|
description: string;
|
|
1663
1663
|
label: string;
|
|
1664
1664
|
eventCode: string;
|
|
@@ -1717,7 +1717,7 @@ declare function createAdobeIoEventsApiClient(params: IoEventsHttpClientParams):
|
|
|
1717
1717
|
};
|
|
1718
1718
|
};
|
|
1719
1719
|
}>;
|
|
1720
|
-
getAllEventProviders(httpClient: AdobeIoEventsHttpClient, params: EventProviderListAllParams, fetchOptions?:
|
|
1720
|
+
getAllEventProviders(httpClient: AdobeIoEventsHttpClient, params: EventProviderListAllParams, fetchOptions?: ky0.Options): Promise<{
|
|
1721
1721
|
embedded: {
|
|
1722
1722
|
providers: {
|
|
1723
1723
|
id: string;
|
|
@@ -1830,7 +1830,7 @@ declare function createAdobeIoEventsApiClient(params: IoEventsHttpClientParams):
|
|
|
1830
1830
|
};
|
|
1831
1831
|
};
|
|
1832
1832
|
}>;
|
|
1833
|
-
getEventProviderById(httpClient: AdobeIoEventsHttpClient, params: EventProviderGetByIdParams, fetchOptions?:
|
|
1833
|
+
getEventProviderById(httpClient: AdobeIoEventsHttpClient, params: EventProviderGetByIdParams, fetchOptions?: ky0.Options): Promise<{
|
|
1834
1834
|
id: string;
|
|
1835
1835
|
instanceId?: string | undefined;
|
|
1836
1836
|
label: string;
|
|
@@ -1926,7 +1926,7 @@ declare function createAdobeIoEventsApiClient(params: IoEventsHttpClientParams):
|
|
|
1926
1926
|
} | undefined;
|
|
1927
1927
|
};
|
|
1928
1928
|
}>;
|
|
1929
|
-
createEventProvider(httpClient: AdobeIoEventsHttpClient, params: EventProviderCreateParams, fetchOptions?:
|
|
1929
|
+
createEventProvider(httpClient: AdobeIoEventsHttpClient, params: EventProviderCreateParams, fetchOptions?: ky0.Options): Promise<{
|
|
1930
1930
|
id: string;
|
|
1931
1931
|
instanceId?: string | undefined;
|
|
1932
1932
|
label: string;
|
|
@@ -2028,7 +2028,7 @@ declare function createAdobeIoEventsApiClient(params: IoEventsHttpClientParams):
|
|
|
2028
2028
|
* @param params - The parameters to build the Adobe I/O Events HTTP client that will communicate with the Adobe I/O Events API.
|
|
2029
2029
|
* @param functions - The API functions to include in the client.
|
|
2030
2030
|
*/
|
|
2031
|
-
declare function createCustomAdobeIoEventsApiClient<TFunctions extends Record<string, ApiFunction<AdobeIoEventsHttpClient, any[], any>>>(params: IoEventsHttpClientParams, functions: TFunctions):
|
|
2031
|
+
declare function createCustomAdobeIoEventsApiClient<TFunctions extends Record<string, ApiFunction<AdobeIoEventsHttpClient, any[], any>>>(params: IoEventsHttpClientParams, functions: TFunctions): _adobe_aio_commerce_lib_api0.ApiClientRecord<AdobeIoEventsHttpClient, TFunctions>;
|
|
2032
2032
|
//#endregion
|
|
2033
2033
|
//#region source/io-events/types.d.ts
|
|
2034
2034
|
type HALLink = {
|
|
@@ -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{a as parseOrThrow,i as stringValueSchema,o as __export,r as booleanValueSchema}from"../schemas-D5c1tsDe.mjs";import{buildCamelCaseKeysResponseHook}from"@adobe/aio-commerce-lib-api/utils";import*as v from"valibot";import{AdobeIoEventsHttpClient,ApiClient}from"@adobe/aio-commerce-lib-api";const BASE64_ENCODED_STRING_REGEX=/^[A-Za-z0-9+/]*={0,2}$/;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 v.pipe(v.union([v.pipe(stringValueSchema(fieldName),v.transform(tryDecodeFromBase64),v.parseJson(void 0,`Expected valid JSON string for property '${fieldName}'`),v.record(v.string(),v.unknown())),v.record(v.string(),v.unknown()),v.array(v.unknown())]),v.stringifyJson(void 0,`Expected valid JSON data for property '${fieldName}'`),v.transform(encodeToBase64))}const GetAllEventMetadataForProviderSchema=v.object({providerId:stringValueSchema(`providerId`)}),GetEventMetadataForEventAndProviderSchema=v.object({eventCode:stringValueSchema(`eventCode`),providerId:stringValueSchema(`providerId`)}),CreateEventMetadataForProviderSchema=v.object({consumerOrgId:stringValueSchema(`consumerOrgId`),projectId:stringValueSchema(`projectId`),workspaceId:stringValueSchema(`workspaceId`),providerId:stringValueSchema(`providerId`),label:stringValueSchema(`label`),description:stringValueSchema(`description`),eventCode:stringValueSchema(`eventCode`),sampleEventTemplate:v.optional(sampleEventTemplateSchema(`sampleEventTemplate`))});var endpoints_exports=__export({createEventMetadataForProvider:()=>createEventMetadataForProvider,getAllEventMetadataForProvider:()=>getAllEventMetadataForProvider,getEventMetadataForEventAndProvider:()=>getEventMetadataForEventAndProvider});async function getAllEventMetadataForProvider(httpClient,params,fetchOptions){let validatedParams=parseOrThrow(GetAllEventMetadataForProviderSchema,params);return httpClient.extend({hooks:{afterResponse:[buildCamelCaseKeysResponseHook()]}}).get(`providers/${validatedParams.providerId}/eventmetadata`,fetchOptions).json()}async function getEventMetadataForEventAndProvider(httpClient,params,fetchOptions){let validatedParams=parseOrThrow(GetEventMetadataForEventAndProviderSchema,params);return httpClient.extend({hooks:{afterResponse:[buildCamelCaseKeysResponseHook()]}}).get(`providers/${validatedParams.providerId}/eventmetadata/${validatedParams.eventCode}`,fetchOptions).json()}async function createEventMetadataForProvider(httpClient,params,fetchOptions){let validatedParams=parseOrThrow(CreateEventMetadataForProviderSchema,params);return httpClient.extend({hooks:{afterResponse:[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=v.picklist(VALID_EVENT_PROVIDER_TYPES),DataResidencyRegionSchema=v.picklist(VALID_DATA_RESIDENCY_REGIONS),EventProviderListAllParamsSchema=v.object({consumerOrgId:stringValueSchema(`consumerOrgId`),withEventMetadata:v.optional(booleanValueSchema(`withEventMetadata`)),filterBy:v.optional(v.object({instanceId:v.optional(stringValueSchema(`instanceId`)),providerTypes:v.optional(v.union([v.array(EventProviderTypeSchema,`Expected an array of event provider types`)]))}))}),EventProviderGetByIdParamsSchema=v.object({providerId:stringValueSchema(`providerId`),withEventMetadata:v.optional(booleanValueSchema(`withEventMetadata`))}),EventProviderCreateParamsSchema=v.object({consumerOrgId:stringValueSchema(`consumerOrgId`),projectId:stringValueSchema(`projectId`),workspaceId:stringValueSchema(`workspaceId`),label:stringValueSchema(`label`),description:v.optional(stringValueSchema(`description`)),docsUrl:v.optional(stringValueSchema(`docsUrl`)),instanceId:v.optional(stringValueSchema(`instanceId`)),providerType:v.optional(EventProviderTypeSchema),dataResidencyRegion:v.optional(DataResidencyRegionSchema)});var endpoints_exports$1=__export({createEventProvider:()=>createEventProvider,getAllEventProviders:()=>getAllEventProviders,getEventProviderById:()=>getEventProviderById});async function getAllEventProviders(httpClient,params,fetchOptions){let validatedParams=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:[buildCamelCaseKeysResponseHook()]}}).get(`${validatedParams.consumerOrgId}/providers`,{...fetchOptions,searchParams:queryParams}).json()}async function getEventProviderById(httpClient,params,fetchOptions){let validatedParams=parseOrThrow(EventProviderGetByIdParamsSchema,params),searchParams=new URLSearchParams;return setQueryParamIfTruthy(searchParams,`eventmetadata`,validatedParams.withEventMetadata),httpClient.extend({hooks:{afterResponse:[buildCamelCaseKeysResponseHook()]}}).get(`providers/${params.providerId}`,{...fetchOptions,searchParams}).json()}async function createEventProvider(httpClient,params,fetchOptions){let validatedParams=parseOrThrow(EventProviderCreateParamsSchema,params);return httpClient.extend({hooks:{afterResponse:[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=__export({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)}function createAdobeIoEventsApiClient(params){return ApiClient.create(new AdobeIoEventsHttpClient(params),{...endpoints_exports$1,...endpoints_exports,...shorthands_exports})}function createCustomAdobeIoEventsApiClient(params,functions){return ApiClient.create(new AdobeIoEventsHttpClient(params),functions)}export{create3rdPartyCustomEventProvider,createAdobeIoEventsApiClient,createCommerceEventProvider,createCustomAdobeIoEventsApiClient,createEventMetadataForProvider,createEventProvider,getAll3rdPartyCustomEventProviders,getAllCommerceEventProviders,getAllEventMetadataForProvider,getAllEventProviders,getEventMetadataForEventAndProvider,getEventProviderById};
|
|
@@ -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{CommerceSdkValidationError}from"@adobe/aio-commerce-lib-core/error";import*as v from"valibot";var __defProp=Object.defineProperty,__export=(all,symbols)=>{let target={};for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0});return symbols&&__defProp(target,Symbol.toStringTag,{value:`Module`}),target};function parseOrThrow(schema,input){let result=v.safeParse(schema,input);if(!result.success)throw new 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 v.string(`Expected a string value for property '${propertyName}'`)}function booleanValueSchema(propertyName){return v.boolean(`Expected a boolean value for property '${propertyName}'`)}function alphaNumericOrUnderscoreSchema(name){return v.pipe(stringValueSchema(name),v.regex(ALPHANUMERIC_OR_UNDERSCORE_REGEX,`Only alphanumeric characters and underscores are allowed for "${name}"`))}function alphaNumericOrUnderscoreOrHyphenSchema(name){return v.pipe(stringValueSchema(name),v.regex(ALPHANUMERIC_OR_UNDERSCORE_OR_HYPHEN_REGEX,`Only alphanumeric characters, underscores, and hyphens are allowed for property "${name}"`))}export{parseOrThrow as a,stringValueSchema as i,alphaNumericOrUnderscoreSchema as n,__export as o,booleanValueSchema as r,alphaNumericOrUnderscoreOrHyphenSchema as t};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@adobe/aio-commerce-lib-events",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"author": "Adobe Inc.",
|
|
5
|
-
"version": "0.3.
|
|
5
|
+
"version": "0.3.6",
|
|
6
6
|
"private": false,
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=20 <=24"
|
|
@@ -18,14 +18,11 @@
|
|
|
18
18
|
"url": "git+https://github.com/adobe/aio-commerce-sdk.git",
|
|
19
19
|
"directory": "packages/aio-commerce-lib-events"
|
|
20
20
|
},
|
|
21
|
-
"main": "./dist/cjs/index.cjs",
|
|
22
|
-
"module": "./dist/es/index.js",
|
|
23
|
-
"types": "./dist/cjs/index.d.cts",
|
|
24
21
|
"exports": {
|
|
25
22
|
"./commerce": {
|
|
26
23
|
"import": {
|
|
27
|
-
"types": "./dist/es/commerce/index.d.
|
|
28
|
-
"default": "./dist/es/commerce/index.
|
|
24
|
+
"types": "./dist/es/commerce/index.d.mts",
|
|
25
|
+
"default": "./dist/es/commerce/index.mjs"
|
|
29
26
|
},
|
|
30
27
|
"require": {
|
|
31
28
|
"types": "./dist/cjs/commerce/index.d.cts",
|
|
@@ -34,8 +31,8 @@
|
|
|
34
31
|
},
|
|
35
32
|
"./io-events": {
|
|
36
33
|
"import": {
|
|
37
|
-
"types": "./dist/es/io-events/index.d.
|
|
38
|
-
"default": "./dist/es/io-events/index.
|
|
34
|
+
"types": "./dist/es/io-events/index.d.mts",
|
|
35
|
+
"default": "./dist/es/io-events/index.mjs"
|
|
39
36
|
},
|
|
40
37
|
"require": {
|
|
41
38
|
"types": "./dist/cjs/io-events/index.d.cts",
|
|
@@ -45,14 +42,8 @@
|
|
|
45
42
|
"./package.json": "./package.json"
|
|
46
43
|
},
|
|
47
44
|
"imports": {
|
|
48
|
-
"#*":
|
|
49
|
-
|
|
50
|
-
"./source/*/index.ts"
|
|
51
|
-
],
|
|
52
|
-
"#test/*": [
|
|
53
|
-
"./test/*.ts",
|
|
54
|
-
"./test/*/index.ts"
|
|
55
|
-
]
|
|
45
|
+
"#*": "./source/*.ts",
|
|
46
|
+
"#test/*": "./test/*.ts"
|
|
56
47
|
},
|
|
57
48
|
"files": [
|
|
58
49
|
"dist",
|
|
@@ -64,18 +55,19 @@
|
|
|
64
55
|
"valibot": "^1.1.0",
|
|
65
56
|
"@adobe/aio-commerce-lib-auth": "0.6.2",
|
|
66
57
|
"@adobe/aio-commerce-lib-core": "0.5.1",
|
|
67
|
-
"@adobe/aio-commerce-lib-api": "0.
|
|
58
|
+
"@adobe/aio-commerce-lib-api": "0.4.1"
|
|
68
59
|
},
|
|
69
60
|
"devDependencies": {
|
|
70
61
|
"msw": "^2.11.1",
|
|
71
62
|
"@aio-commerce-sdk/config-tsdown": "1.0.0",
|
|
63
|
+
"@aio-commerce-sdk/config-typedoc": "1.0.0",
|
|
72
64
|
"@aio-commerce-sdk/config-typescript": "1.0.0",
|
|
73
|
-
"@aio-commerce-sdk/config-vitest": "1.0.0"
|
|
74
|
-
"@aio-commerce-sdk/config-typedoc": "1.0.0"
|
|
65
|
+
"@aio-commerce-sdk/config-vitest": "1.0.0"
|
|
75
66
|
},
|
|
76
67
|
"sideEffects": false,
|
|
77
68
|
"scripts": {
|
|
78
69
|
"build": "tsdown",
|
|
70
|
+
"publint": "publint",
|
|
79
71
|
"docs": "typedoc && prettier --write '**/*.md'",
|
|
80
72
|
"assist": "biome check --formatter-enabled=false --linter-enabled=false --assist-enabled=true --no-errors-on-unmatched",
|
|
81
73
|
"assist:apply": "biome check --write --formatter-enabled=false --linter-enabled=false --assist-enabled=true --no-errors-on-unmatched",
|
|
@@ -1,14 +0,0 @@
|
|
|
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=all=>{let target={};for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0});return target},__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));let __adobe_aio_commerce_lib_core_error=require(`@adobe/aio-commerce-lib-core/error`);__adobe_aio_commerce_lib_core_error=__toESM(__adobe_aio_commerce_lib_core_error);let valibot=require(`valibot`);valibot=__toESM(valibot);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}"`))}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return parseOrThrow}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return stringValueSchema}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return alphaNumericOrUnderscoreSchema}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return __export}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return booleanValueSchema}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return __toESM}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return alphaNumericOrUnderscoreOrHyphenSchema}});
|
|
@@ -1,14 +0,0 @@
|
|
|
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{a as parseOrThrow,i as stringValueSchema,n as alphaNumericOrUnderscoreSchema,o as __export,r as booleanValueSchema,t as alphaNumericOrUnderscoreOrHyphenSchema}from"../schemas-BLvngVRY.js";import{buildCamelCaseKeysResponseHook}from"@adobe/aio-commerce-lib-api/utils/transformations";import{CommerceSdkValidationError}from"@adobe/aio-commerce-lib-core/error";import*as v from"valibot";import{AdobeCommerceHttpClient,ApiClient}from"@adobe/aio-commerce-lib-api";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({createEventProvider:()=>createEventProvider,getAllEventProviders:()=>getAllEventProviders,getEventProviderById:()=>getEventProviderById});async function getAllEventProviders(httpClient,fetchOptions){return httpClient.extend({hooks:{afterResponse:[buildCamelCaseKeysResponseHook()]}}).get(`eventing/eventProvider`,fetchOptions).json()}async function getEventProviderById(httpClient,params,fetchOptions){let validatedParams=parseOrThrow(EventProviderGetByIdParamsSchema,params);return httpClient.extend({hooks:{afterResponse:[buildCamelCaseKeysResponseHook()]}}).get(`eventing/eventProvider/${validatedParams.providerId}`,fetchOptions).json()}async function createEventProvider(httpClient,params,fetchOptions){let validatedParams=parseOrThrow(EventProviderCreateParamsSchema,params);return httpClient.extend({hooks:{afterResponse:[buildCamelCaseKeysResponseHook()]}}).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({createEventSubscription:()=>createEventSubscription,getAllEventSubscriptions:()=>getAllEventSubscriptions});async function getAllEventSubscriptions(httpClient,fetchOptions){return httpClient.extend({hooks:{afterResponse:[buildCamelCaseKeysResponseHook()]}}).get(`eventing/getEventSubscriptions`,fetchOptions).json()}async function createEventSubscription(httpClient,params,fetchOptions){let{force,...event}=parseOrThrow(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=v.partial(v.object({enabled:booleanValueSchema(`enabled`),providerId:alphaNumericOrUnderscoreOrHyphenSchema(`providerId`),instanceId:alphaNumericOrUnderscoreOrHyphenSchema(`instanceId`),merchantId:alphaNumericOrUnderscoreSchema(`merchantId`),environmentId:alphaNumericOrUnderscoreSchema(`environmentId`),workspaceConfiguration:workspaceConfigurationSchema(`workspaceConfiguration`)}));async function updateEventingConfiguration(httpClient,params,fetchOptions){let validatedParams=parseOrThrow(UpdateEventingConfigurationParamsSchema,params);return httpClient.put(`eventing/updateConfiguration`,{...fetchOptions,json:{config:validatedParams}}).json()}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};
|
|
@@ -1,14 +0,0 @@
|
|
|
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{a as parseOrThrow,i as stringValueSchema,o as __export,r as booleanValueSchema}from"../schemas-BLvngVRY.js";import{buildCamelCaseKeysResponseHook}from"@adobe/aio-commerce-lib-api/utils/transformations";import*as v from"valibot";import{AdobeIoEventsHttpClient,ApiClient}from"@adobe/aio-commerce-lib-api";const BASE64_ENCODED_STRING_REGEX=/^[A-Za-z0-9+/]*={0,2}$/;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 v.pipe(v.union([v.pipe(stringValueSchema(fieldName),v.transform(tryDecodeFromBase64),v.parseJson(void 0,`Expected valid JSON string for property '${fieldName}'`),v.record(v.string(),v.unknown())),v.record(v.string(),v.unknown()),v.array(v.unknown())]),v.stringifyJson(void 0,`Expected valid JSON data for property '${fieldName}'`),v.transform(encodeToBase64))}const GetAllEventMetadataForProviderSchema=v.object({providerId:stringValueSchema(`providerId`)}),GetEventMetadataForEventAndProviderSchema=v.object({eventCode:stringValueSchema(`eventCode`),providerId:stringValueSchema(`providerId`)}),CreateEventMetadataForProviderSchema=v.object({consumerOrgId:stringValueSchema(`consumerOrgId`),projectId:stringValueSchema(`projectId`),workspaceId:stringValueSchema(`workspaceId`),providerId:stringValueSchema(`providerId`),label:stringValueSchema(`label`),description:stringValueSchema(`description`),eventCode:stringValueSchema(`eventCode`),sampleEventTemplate:v.optional(sampleEventTemplateSchema(`sampleEventTemplate`))});var endpoints_exports=__export({createEventMetadataForProvider:()=>createEventMetadataForProvider,getAllEventMetadataForProvider:()=>getAllEventMetadataForProvider,getEventMetadataForEventAndProvider:()=>getEventMetadataForEventAndProvider});async function getAllEventMetadataForProvider(httpClient,params,fetchOptions){let validatedParams=parseOrThrow(GetAllEventMetadataForProviderSchema,params);return httpClient.extend({hooks:{afterResponse:[buildCamelCaseKeysResponseHook()]}}).get(`providers/${validatedParams.providerId}/eventmetadata`,fetchOptions).json()}async function getEventMetadataForEventAndProvider(httpClient,params,fetchOptions){let validatedParams=parseOrThrow(GetEventMetadataForEventAndProviderSchema,params);return httpClient.extend({hooks:{afterResponse:[buildCamelCaseKeysResponseHook()]}}).get(`providers/${validatedParams.providerId}/eventmetadata/${validatedParams.eventCode}`,fetchOptions).json()}async function createEventMetadataForProvider(httpClient,params,fetchOptions){let validatedParams=parseOrThrow(CreateEventMetadataForProviderSchema,params);return httpClient.extend({hooks:{afterResponse:[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=v.picklist(VALID_EVENT_PROVIDER_TYPES),DataResidencyRegionSchema=v.picklist(VALID_DATA_RESIDENCY_REGIONS),EventProviderListAllParamsSchema=v.object({consumerOrgId:stringValueSchema(`consumerOrgId`),withEventMetadata:v.optional(booleanValueSchema(`withEventMetadata`)),filterBy:v.optional(v.object({instanceId:v.optional(stringValueSchema(`instanceId`)),providerTypes:v.optional(v.union([v.array(EventProviderTypeSchema,`Expected an array of event provider types`)]))}))}),EventProviderGetByIdParamsSchema=v.object({providerId:stringValueSchema(`providerId`),withEventMetadata:v.optional(booleanValueSchema(`withEventMetadata`))}),EventProviderCreateParamsSchema=v.object({consumerOrgId:stringValueSchema(`consumerOrgId`),projectId:stringValueSchema(`projectId`),workspaceId:stringValueSchema(`workspaceId`),label:stringValueSchema(`label`),description:v.optional(stringValueSchema(`description`)),docsUrl:v.optional(stringValueSchema(`docsUrl`)),instanceId:v.optional(stringValueSchema(`instanceId`)),providerType:v.optional(EventProviderTypeSchema),dataResidencyRegion:v.optional(DataResidencyRegionSchema)});var endpoints_exports$1=__export({createEventProvider:()=>createEventProvider,getAllEventProviders:()=>getAllEventProviders,getEventProviderById:()=>getEventProviderById});async function getAllEventProviders(httpClient,params,fetchOptions){let validatedParams=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:[buildCamelCaseKeysResponseHook()]}}).get(`${validatedParams.consumerOrgId}/providers`,{...fetchOptions,searchParams:queryParams}).json()}async function getEventProviderById(httpClient,params,fetchOptions){let validatedParams=parseOrThrow(EventProviderGetByIdParamsSchema,params),searchParams=new URLSearchParams;return setQueryParamIfTruthy(searchParams,`eventmetadata`,validatedParams.withEventMetadata),httpClient.extend({hooks:{afterResponse:[buildCamelCaseKeysResponseHook()]}}).get(`providers/${params.providerId}`,{...fetchOptions,searchParams}).json()}async function createEventProvider(httpClient,params,fetchOptions){let validatedParams=parseOrThrow(EventProviderCreateParamsSchema,params);return httpClient.extend({hooks:{afterResponse:[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=__export({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)}function createAdobeIoEventsApiClient(params){return ApiClient.create(new AdobeIoEventsHttpClient(params),{...endpoints_exports$1,...endpoints_exports,...shorthands_exports})}function createCustomAdobeIoEventsApiClient(params,functions){return ApiClient.create(new AdobeIoEventsHttpClient(params),functions)}export{create3rdPartyCustomEventProvider,createAdobeIoEventsApiClient,createCommerceEventProvider,createCustomAdobeIoEventsApiClient,createEventMetadataForProvider,createEventProvider,getAll3rdPartyCustomEventProviders,getAllCommerceEventProviders,getAllEventMetadataForProvider,getAllEventProviders,getEventMetadataForEventAndProvider,getEventProviderById};
|
|
@@ -1,14 +0,0 @@
|
|
|
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{CommerceSdkValidationError}from"@adobe/aio-commerce-lib-core/error";import*as v from"valibot";var __defProp=Object.defineProperty,__export=all=>{let target={};for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0});return target};function parseOrThrow(schema,input){let result=v.safeParse(schema,input);if(!result.success)throw new 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 v.string(`Expected a string value for property '${propertyName}'`)}function booleanValueSchema(propertyName){return v.boolean(`Expected a boolean value for property '${propertyName}'`)}function alphaNumericOrUnderscoreSchema(name){return v.pipe(stringValueSchema(name),v.regex(ALPHANUMERIC_OR_UNDERSCORE_REGEX,`Only alphanumeric characters and underscores are allowed for "${name}"`))}function alphaNumericOrUnderscoreOrHyphenSchema(name){return v.pipe(stringValueSchema(name),v.regex(ALPHANUMERIC_OR_UNDERSCORE_OR_HYPHEN_REGEX,`Only alphanumeric characters, underscores, and hyphens are allowed for property "${name}"`))}export{parseOrThrow as a,stringValueSchema as i,alphaNumericOrUnderscoreSchema as n,__export as o,booleanValueSchema as r,alphaNumericOrUnderscoreOrHyphenSchema as t};
|