The objective of this guide is to document the breaking changes and updates required to migrate from one major version to the next.
- The
URLandSharedKeyproperties have been removed from theMessageSendermodel, andDeliveryConfigIDis now required. Configuration must be provided via aDeliveryConfig(managed through the newDeliveryConfigurationsservice) using either aMailchimpConfigorMessageSenderConfigdelivery target. See the updated Message Senders KB article for more details.
Note: All existing Message Senders were migrated automatically
Before:
```typescript
const messageSender: MessageSender = {
Name: 'My Sender',
MessageTypes: ['OrderSubmitted'],
URL: 'https://my-endpoint.com',
SharedKey: 'my-secret-key',
}
```
After:
```typescript
// First, create a DeliveryConfig with the equivalent configuration
const deliveryConfig = await DeliveryConfigurations.Create({
Name: 'My Delivery Config',
DeliveryTargets: {
MessageSender: {
Endpoint: 'https://my-endpoint.com',
Secret: 'my-secret-key',
}
}
})
// Then reference it on the MessageSender
const messageSender: MessageSender = {
Name: 'My Sender',
MessageTypes: ['OrderSubmitted'],
DeliveryConfigID: deliveryConfig.ID,
}
```
-
The return type for the
Cart.ListEligiblePromotionsandOrders.ListEligiblePromotionsmethods have been updated fromOrderPromotiontoEligiblePromotionBefore:
Orders.ListEligiblePromotions<TOrderPromotion>(...) : Promise<RequiredDeep<ListPage<TOrderPromotion>>>
After:
Orders.ListEligiblePromotions<TEligiblePromotion>(...) : Promise<RequiredDeep<ListPage<TEligiblePromotion>>>
-
The
userIDparameter as well as the 'User' option in thelevelparameter have been removed from listOptions on serveral list assignment operations:Bundles.ListAssignments(), CostCenters.ListAssignments(), Categories.ListAssignments(), Locales.ListAssignments(), MessageSenders.ListAssignments(), InventoryRecords.ListAssignments(), InventoryRecords.ListVariantAssignments(), Products.ListAssignments(), Promotions.ListAssignments().Before:
Products.ListAssignments({ level: 'User'}); // 'Group' or 'Company' also valid
After:
Products.ListAssignments({ level: 'Group'}); // 'Company' also valid
-
The return type for the
Me.ListProductCollectionEntriesmethod has been updated fromBuyerProducttoProductCollectionBuyerProductBefore:
ListProductCollectionEntries<TBuyerProduct>(...) : Promise<RequiredDeep<ListPageWithFacets<TBuyerProduct>>>
After:
ListProductCollectionEntries<TProductCollectionBuyerProduct>(...) : Promise<RequiredDeep<ListPageWithFacets<TProductCollectionBuyerProduct>>>
- The return type for the
ProductCollections.ListEntriesmethod has been updated fromProducttoProductCollectionProduct
Before:
ListEntries<TProduct>(...) : Promise<RequiredDeep<ListPageWithFacets<TProduct>>>
After:
ListEntries<TProductCollectionBuyerProduct>(...) : Promise<RequiredDeep<ListPageWithFacets<TProductCollectionBuyerProduct>>>
- The return type for the
-
The return type for the
ListEligiblePromotionsmethod has been updated fromPromotiontoOrderPromotionBefore:
ListEligiblePromotions<TPromotion>(...) : Promise<RequiredDeep<ListPage<TPromotion>>>
After:
ListEligiblePromotions<TOrderPromotion>(...) : Promise<RequiredDeep<ListPage<TOrderPromotion>>>
-
The method names for the
EntitySynchronizationservice have been streamlined for improved clarity. The previous naming convention included the suffixEntitySyncConfig, which has now been removedBefore:
EntitySynchronization.GetInventoryRecordEntitySyncConfig(...)
After:
EntitySynchronization.GetInventoryRecords(...)
-
ForgottenPasswordservice renamed toForgottenCredentialsBefore:
ForgottenPassword.SendVerificationCode(...)
After:
ForgottenCredentials.SendVerificationCode(...)
-
Axios less than version 1.0.0 is no longer supported
-
The type for the
errorsproperty on the classOrderCloudErrorhas changedBefore:
errors?: ApiError[] | AuthError[]
After:
errors?: ApiError[]
-
There was a bug where ordercloud errors were incorrectly nested under an additional
Errorsproperty. This has been fixed to match the type aboveBefore:
catch(exception) { const ordercloudErrors = exception.errors.Errors; }
After:
catch(exception) { const ordercloudErrors = exception.errors; }
-
Axios is now a peer dependency. Peer dependencies are not installed automatically, they must be installed separately.
-
Interacting directly with the SDK instance is no longer possible. Configuration of the sdk is now done via the
Configurationservice and setting tokens is done via theTokensservice. Setting a token in a browser environment will set the token in cookies, and on the server they will be stored on the sdk instance.Before:
const defaultClient = OrderCloud.Sdk.instance; // configuring baseApiPath and baseAuthUrl defaultClient.baseApiPath = 'https://api.ordercloud.io/v1'; defaultClient.baseAuthPath = 'https://auth.ordercloud.io/oauth/token'; // setting the token defaultClient.authentications['oauth2'].accessToken = 'my-token'; // setting token
After:
Configuration.Set({ baseApiUrl: 'https://api.ordercloud.io', apiVersion: 'v1' }) Tokens.SetAccessToken('my-token');
-
The
As()method used for impersonation has been moved from being accessible from the sdk to each resource.Before:
OrderCloudSDK.As().Me.ListProducts();
After:
OrderCloudSDK.Me.As().ListProducts // OR (if using selective imports) Me.As().ListProducts
-
The
PasswordResetsservice has been renamed toForgottenPassword.Before:
const resetRequest = { ClientID: 'my-client-id', Email: 'test@test.com', Username: 'test' } PasswordResets.SendVerificationCode(resetRequest)
After:
const resetRequest = { ClientID: 'my-client-id', Email: 'test@test.com', Username: 'test' } ForgottenPassword.SendVerificationCode(resetRequest)
-
Auth.PasswordResetshas been renamed toAuth.ForgottenPasswordBeforeAuth.PasswordResets()
-
XpIndexsservice has been renamed toXpIndicesBefore:
XpIndexs.List()
After:
XpIndices.List()
-
searchOnandsortBynow accept an array of strings instead of a single comma delimited stringBefore:
Me.ListProducts({searchOn: 'ID,Name', sortBy: 'ID,Name'})
After:
Me.ListProducts({searchOn: ['ID', 'Name'], sortBy: ['ID', 'Name']})
-
The schema for errors has changed. Please refer to the error handling section in the readme.
The following are Typescript breaking changes. If you are not using Typescript you can safely ignore them.
-
The minimum compatible typescript version is now 3.5
-
Models previously were defined such that all properties were required. Now, properties are only required if the Create/Update operation requires them. Please see understanding ordercloud's models for more information.
-
List models have been replaced with a generic
ListPagemodel that takes a type parameter for the item.Before:
const orderList: ListOrder const ccList: ListCreditCard
After:
const orderList: ListPage<Order> const ccList: ListPage<CreditCard>
-
OrderDirection must be either
IncomingorOutgoingcase-sensitive.Before:
Orders.List('incoming')
After:
Orders.List('Incoming')
-
Auth.RefreshTokenno longer takes in ascopeparameter. This parameter didn't actually do anything, when you refresh a token you get a new access token with the same roles as the first one had.Before
Auth.RefreshToken('my-refresh-token', 'my-client-id', ['Shopper'])
After
Auth.RefreshToken('my-refresh-token', 'my-client-id')
-
ApiClientrenamed toSdkto prevent name clash with new API resource ApiClient.Before:
const defaultClient = OrderCloud.ApiClient.instance;
After:
const defaultClient = OrderCloud.Sdk.instance;
-
searchOnandsortBynow only accept a comma-delimited string. Previously accepted a comma-delimited string or an array of strings -
Renamed "Update" (used for PUT's) in favor of "Save" to clarify intent. For example
OrderCloudSDK.Orders.Updatenow becomesOrderCloudSDK.Orders.Save. This is for all resources.