The objective of this guide is to document the breaking changes and updates required to migrate from one major version to the next.
-
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: '[email protected]', Username: 'test' } PasswordResets.SendVerificationCode(resetRequest)
After:
const resetRequest = { ClientID: 'my-client-id', Email: '[email protected]', 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.