Skip to content

Commit d192622

Browse files
author
Crhistian Ramirez
committed
🐛 fix bug where type parameters on models are wrong
Type parameters are wrong for models that have properties that are complex types that have their own type parameters due to an ordering bug
1 parent e7b162e commit d192622

10 files changed

Lines changed: 48 additions & 11 deletions

File tree

codegen/hooks.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ function inspectModelForTypeParams(
223223
}
224224
if (prop.isXp) {
225225
if (!rootProp) {
226+
// first level of properties, only the xp for that resource will exist
227+
// move it to front for convention where first xp is always that resource's xp
226228
const typeParam = `T${inspectModel.name}Xp`
227229
rootModel['typeParams'].unshift(typeParam)
228230
prop['typeParams'].unshift(typeParam)
@@ -260,4 +262,20 @@ function inspectModelForTypeParams(
260262
}
261263
}
262264
})
265+
266+
// This is a little hacky but basically we want the first type parameter to be the type for the xp of the model
267+
// for example ShipEstimate<ShipEstimateXp...> otherwise, the xp type would be at the end of the list
268+
// lke so: ShipEstimate<SomeXp, SomeOtherXp...ShipEstimateXp>
269+
if (
270+
rootProp &&
271+
rootProp['typeParams'] &&
272+
rootProp['typeParams'].length > 1 &&
273+
rootProp['typeParams'].includes(`T${rootProp.name}Xp`)
274+
) {
275+
const toMoveIndex = rootProp['typeParams'].findIndex(
276+
p => p === `T${rootProp.name}Xp`
277+
)
278+
const toMove = rootProp['typeParams'].splice(toMoveIndex, 1)
279+
rootProp['typeParams'].unshift(toMove[0])
280+
}
263281
}

docs/assets/js/search.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/classes/me.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,6 +1326,12 @@ <h5><span class="tsd-flag ts-flagOptional">Optional</span> search<wbr>On<span cl
13261326
<p>Comma-delimited list of fields to search on.</p>
13271327
</div>
13281328
</li>
1329+
<li class="tsd-parameter">
1330+
<h5><span class="tsd-flag ts-flagOptional">Optional</span> search<wbr>Type<span class="tsd-signature-symbol">?: </span><a href="../index.html#searchtype" class="tsd-signature-type">SearchType</a></h5>
1331+
<div class="tsd-comment tsd-typography">
1332+
<p>Type of search to perform. Possible values: AnyTerm (default), AllTermsAnyField, AllTermsSameField, ExactPhrase, ExactPhrasePrefix.</p>
1333+
</div>
1334+
</li>
13291335
<li class="tsd-parameter">
13301336
<h5><span class="tsd-flag ts-flagOptional">Optional</span> sort<wbr>By<span class="tsd-signature-symbol">?: </span><a href="../index.html#sortable" class="tsd-signature-type">Sortable</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">"Me.ListOrders"</span><span class="tsd-signature-symbol">&gt;</span></h5>
13311337
<div class="tsd-comment tsd-typography">

docs/interfaces/lineitemproduct.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ <h2>API Reference</h2>
5858
<section class="tsd-index-section ">
5959
<h3>Properties</h3>
6060
<ul class="tsd-index-list">
61+
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="lineitemproduct.html#defaultsupplierid" class="tsd-kind-icon">Default<wbr>SupplierID</a></li>
6162
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="lineitemproduct.html#description" class="tsd-kind-icon">Description</a></li>
6263
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="lineitemproduct.html#id" class="tsd-kind-icon">ID</a></li>
6364
<li class="tsd-kind-property tsd-parent-kind-interface"><a href="lineitemproduct.html#name" class="tsd-kind-icon">Name</a></li>
@@ -74,6 +75,13 @@ <h3>Properties</h3>
7475
</section>
7576
<section class="tsd-panel-group tsd-member-group ">
7677
<h2>Properties</h2>
78+
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
79+
<a name="defaultsupplierid" class="tsd-anchor"></a>
80+
<h3><span class="tsd-flag ts-flagOptional">Optional</span> Default<wbr>SupplierID</h3>
81+
<div class="tsd-signature tsd-kind-icon">Default<wbr>SupplierID<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div>
82+
<aside class="tsd-sources">
83+
</aside>
84+
</section>
7785
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
7886
<a name="description" class="tsd-anchor"></a>
7987
<h3><span class="tsd-flag ts-flagOptional">Optional</span> Description</h3>
@@ -151,6 +159,9 @@ <h3><span class="tsd-flag ts-flagOptional">Optional</span> xp</h3>
151159
<li class="current tsd-kind-interface tsd-has-type-parameter">
152160
<a href="lineitemproduct.html" class="tsd-kind-icon">Line<wbr>Item<wbr>Product</a>
153161
<ul>
162+
<li class=" tsd-kind-property tsd-parent-kind-interface">
163+
<a href="lineitemproduct.html#defaultsupplierid" class="tsd-kind-icon">Default<wbr>SupplierID</a>
164+
</li>
154165
<li class=" tsd-kind-property tsd-parent-kind-interface">
155166
<a href="lineitemproduct.html#description" class="tsd-kind-icon">Description</a>
156167
</li>

docs/interfaces/ordersplitresult.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ <h2>Properties</h2>
7676
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
7777
<a name="outgoingorders" class="tsd-anchor"></a>
7878
<h3><span class="tsd-flag ts-flagOptional">Optional</span> Outgoing<wbr>Orders</h3>
79-
<div class="tsd-signature tsd-kind-icon">Outgoing<wbr>Orders<span class="tsd-signature-symbol">:</span> <a href="order.html" class="tsd-signature-type">Order</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">TFromUserXp</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">TBillingAddressXp</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">TOutgoingOrdersXp</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">[]</span></div>
79+
<div class="tsd-signature tsd-kind-icon">Outgoing<wbr>Orders<span class="tsd-signature-symbol">:</span> <a href="order.html" class="tsd-signature-type">Order</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">TOutgoingOrdersXp</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">TFromUserXp</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">TBillingAddressXp</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">[]</span></div>
8080
<aside class="tsd-sources">
8181
</aside>
8282
</section>

docs/interfaces/orderworksheet.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,14 @@ <h2>Properties</h2>
114114
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
115115
<a name="lineitems" class="tsd-anchor"></a>
116116
<h3><span class="tsd-flag ts-flagOptional">Optional</span> Line<wbr>Items</h3>
117-
<div class="tsd-signature tsd-kind-icon">Line<wbr>Items<span class="tsd-signature-symbol">:</span> <a href="lineitem.html" class="tsd-signature-type">LineItem</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">TProductXp</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">TVariantXp</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">TShippingAddressXp</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">TShipFromAddressXp</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">TLineItemsXp</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">[]</span></div>
117+
<div class="tsd-signature tsd-kind-icon">Line<wbr>Items<span class="tsd-signature-symbol">:</span> <a href="lineitem.html" class="tsd-signature-type">LineItem</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">TLineItemsXp</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">TProductXp</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">TVariantXp</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">TShippingAddressXp</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">TShipFromAddressXp</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">[]</span></div>
118118
<aside class="tsd-sources">
119119
</aside>
120120
</section>
121121
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
122122
<a name="order" class="tsd-anchor"></a>
123123
<h3><span class="tsd-flag ts-flagOptional">Optional</span> Order</h3>
124-
<div class="tsd-signature tsd-kind-icon">Order<span class="tsd-signature-symbol">:</span> <a href="order.html" class="tsd-signature-type">Order</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">TFromUserXp</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">TBillingAddressXp</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">TOrderXp</span><span class="tsd-signature-symbol">&gt;</span></div>
124+
<div class="tsd-signature tsd-kind-icon">Order<span class="tsd-signature-symbol">:</span> <a href="order.html" class="tsd-signature-type">Order</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">TOrderXp</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">TFromUserXp</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">TBillingAddressXp</span><span class="tsd-signature-symbol">&gt;</span></div>
125125
<aside class="tsd-sources">
126126
</aside>
127127
</section>
@@ -156,7 +156,7 @@ <h3><span class="tsd-flag ts-flagOptional">Optional</span> Order<wbr>Submit<wbr>
156156
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface">
157157
<a name="shipestimateresponse" class="tsd-anchor"></a>
158158
<h3><span class="tsd-flag ts-flagOptional">Optional</span> Ship<wbr>Estimate<wbr>Response</h3>
159-
<div class="tsd-signature tsd-kind-icon">Ship<wbr>Estimate<wbr>Response<span class="tsd-signature-symbol">:</span> <a href="shipestimateresponse.html" class="tsd-signature-type">ShipEstimateResponse</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">TShipEstimatesXp</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">TShipEstimateResponseXp</span><span class="tsd-signature-symbol">&gt;</span></div>
159+
<div class="tsd-signature tsd-kind-icon">Ship<wbr>Estimate<wbr>Response<span class="tsd-signature-symbol">:</span> <a href="shipestimateresponse.html" class="tsd-signature-type">ShipEstimateResponse</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">TShipEstimateResponseXp</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">TShipEstimatesXp</span><span class="tsd-signature-symbol">&gt;</span></div>
160160
<aside class="tsd-sources">
161161
</aside>
162162
</section>

src/api/Me.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import { Category } from '../models/Category';
99
import { CostCenter } from '../models/CostCenter';
1010
import { BuyerCreditCard } from '../models/BuyerCreditCard';
1111
import { Order } from '../models/Order';
12+
import { SearchType } from '../models/SearchType';
1213
import { TokenPasswordReset } from '../models/TokenPasswordReset';
1314
import { ListPageWithFacets } from '../models/ListPageWithFacets';
1415
import { BuyerProduct } from '../models/BuyerProduct';
15-
import { SearchType } from '../models/SearchType';
1616
import { Spec } from '../models/Spec';
1717
import { Variant } from '../models/Variant';
1818
import { Promotion } from '../models/Promotion';
@@ -539,6 +539,7 @@ class Me {
539539
* @param listOptions.to Upper bound of date range that the order was created (if outgoing) or submitted (if incoming).
540540
* @param listOptions.search Word or phrase to search for.
541541
* @param listOptions.searchOn Comma-delimited list of fields to search on.
542+
* @param listOptions.searchType Type of search to perform. Possible values: AnyTerm (default), AllTermsAnyField, AllTermsSameField, ExactPhrase, ExactPhrasePrefix.
542543
* @param listOptions.sortBy Comma-delimited list of fields to sort by.
543544
* @param listOptions.page Page of results to return. Default: 1. When paginating through many items (> page 30), we recommend the "Last ID" method, as outlined in the Advanced Querying documentation.
544545
* @param listOptions.pageSize Number of results to return per page. Default: 20, max: 100.
@@ -547,7 +548,7 @@ class Me {
547548
* @param requestOptions.cancelToken Provide an [axios cancelToken](https://github.com/axios/axios#cancellation) that can be used to cancel the request.
548549
* @param requestOptions.requestType Provide a value that can be used to identify the type of request. Useful for error logs.
549550
*/
550-
public async ListOrders<TOrder extends Order>(listOptions: { from?: string, to?: string, search?: string, searchOn?: Searchable<'Me.ListOrders'>, sortBy?: Sortable<'Me.ListOrders'>, page?: number, pageSize?: number, filters?: Filters } = {}, requestOptions: RequestOptions = {} ): Promise<RequiredDeep<ListPage<TOrder>>>{
551+
public async ListOrders<TOrder extends Order>(listOptions: { from?: string, to?: string, search?: string, searchOn?: Searchable<'Me.ListOrders'>, searchType?: SearchType, sortBy?: Sortable<'Me.ListOrders'>, page?: number, pageSize?: number, filters?: Filters } = {}, requestOptions: RequestOptions = {} ): Promise<RequiredDeep<ListPage<TOrder>>>{
551552
const impersonating = this.impersonating;
552553
this.impersonating = false;
553554
return await http.get(`/me/orders`, { ...requestOptions, impersonating, params: listOptions } )

src/models/LineItemProduct.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ export interface LineItemProduct<TLineItemProductXp = any> {
88
ShipHeight?: number
99
ShipWidth?: number
1010
ShipLength?: number
11+
DefaultSupplierID?: string
1112
xp?: TLineItemProductXp
1213
}

src/models/OrderSplitResult.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Order } from './Order';
22

33
export interface OrderSplitResult<TFromUserXp = any, TBillingAddressXp = any, TOutgoingOrdersXp = any> {
4-
OutgoingOrders?: Order<TFromUserXp,TBillingAddressXp,TOutgoingOrdersXp>[]
4+
OutgoingOrders?: Order<TOutgoingOrdersXp,TFromUserXp,TBillingAddressXp>[]
55
RemainingLineItemIDs?: string[]
66
}

src/models/OrderWorksheet.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import { OrderSubmitForApprovalResponse } from './OrderSubmitForApprovalResponse
77
import { OrderApprovedResponse } from './OrderApprovedResponse';
88

99
export interface OrderWorksheet<TFromUserXp = any, TBillingAddressXp = any, TOrderXp = any, TProductXp = any, TVariantXp = any, TShippingAddressXp = any, TShipFromAddressXp = any, TLineItemsXp = any, TShipEstimatesXp = any, TShipEstimateResponseXp = any, TOrderCalculateResponseXp = any, TOrderSubmitResponseXp = any, TOrderSubmitForApprovalResponseXp = any, TOrderApprovedResponseXp = any> {
10-
Order?: Order<TFromUserXp,TBillingAddressXp,TOrderXp>
11-
LineItems?: LineItem<TProductXp,TVariantXp,TShippingAddressXp,TShipFromAddressXp,TLineItemsXp>[]
12-
ShipEstimateResponse?: ShipEstimateResponse<TShipEstimatesXp,TShipEstimateResponseXp>
10+
Order?: Order<TOrderXp,TFromUserXp,TBillingAddressXp>
11+
LineItems?: LineItem<TLineItemsXp,TProductXp,TVariantXp,TShippingAddressXp,TShipFromAddressXp>[]
12+
ShipEstimateResponse?: ShipEstimateResponse<TShipEstimateResponseXp,TShipEstimatesXp>
1313
OrderCalculateResponse?: OrderCalculateResponse<TOrderCalculateResponseXp>
1414
OrderSubmitResponse?: OrderSubmitResponse<TOrderSubmitResponseXp>
1515
OrderSubmitForApprovalResponse?: OrderSubmitForApprovalResponse<TOrderSubmitForApprovalResponseXp>

0 commit comments

Comments
 (0)