Skip to content

Commit a9ba013

Browse files
authored
TS fixes (#280)
1 parent 71f7a00 commit a9ba013

File tree

5 files changed

+34
-10
lines changed

5 files changed

+34
-10
lines changed

.changeset/witty-suns-hunt.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@voucherify/sdk': patch
3+
---
4+
5+
TS fixes (VouchersListTransactionsRequestQuery, LoyaltiesListCardTransactionsRequestQuery, ProductCollectionsCreateRequestBody) - backwards compatible

packages/sdk/src/types/Loyalties.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,11 @@ export interface LoyaltiesGetPointsExpirationResponseBody {
602602

603603
export interface LoyaltiesListCardTransactionsRequestQuery {
604604
limit?: number
605+
starting_after_id?: string
606+
order?: 'id' | '-id' // default -id
607+
/**
608+
* @deprecated Use starting_after_id
609+
*/
605610
page?: number
606611
}
607612

@@ -610,6 +615,7 @@ export interface LoyaltiesListCardTransactionsResponseBody {
610615
data_ref: 'data'
611616
data: LoyaltyCardTransaction[]
612617
has_more: boolean
618+
more_starting_after?: string
613619
}
614620

615621
export type LoyaltiesExportCardTransactionsRequestBody = VouchersExportTransactionsRequestBody
@@ -711,13 +717,6 @@ export interface LoyaltiesListCardTransactionsRequestQuery {
711717
page?: number
712718
}
713719

714-
export interface LoyaltiesListCardTransactionsResponseBody {
715-
object: 'list'
716-
data_ref: 'data'
717-
data: LoyaltyCardTransaction[]
718-
has_more: boolean
719-
}
720-
721720
export type LoyaltiesExportCardTransactionsResponseBody = VouchersExportTransactionsResponseBody
722721

723722
export interface LoyaltiesAddOrRemoveCardBalanceRequestBody {

packages/sdk/src/types/ProductCollections.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,18 @@ export interface DynamicProductCollectionBase {
7070

7171
export type ProductCollection = ProductCollectionBase & ProductCollectionIdentity & ProductCollectionSaved
7272

73-
export type Filter = {
74-
junction: Junction
75-
} & Partial<Record<AllowedFiltersKeys, { conditions: Partial<Record<FiltersCondition, unknown>> }>>
73+
export type Filter = Partial<
74+
Record<string, Junction | { conditions: Partial<Record<FiltersCondition, unknown>> }>
75+
> /*
76+
junction: Junction;
77+
'id'| 'name'| 'attributes'| 'source_id'| 'price'| 'image_url'| 'product_id'| 'skus'| 'created_at'| 'updated_at'| 'object' | `metadata.${string}`: { conditions: Partial<Record<FiltersCondition, unknown>> }
78+
*/
7679

7780
export declare type Junction = 'and' | 'AND' | 'or' | 'OR'
7881

82+
/**
83+
* @deprecated
84+
*/
7985
export type AllowedFiltersKeys =
8086
| 'id'
8187
| 'name'

packages/sdk/src/types/Vouchers.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,11 @@ export type VoucherTransactionsExportFields =
388388
// List transactions
389389
export interface VouchersListTransactionsRequestQuery {
390390
limit?: number
391+
starting_after_id?: string
392+
order?: 'id' | '-id' // default -id
393+
/**
394+
* @deprecated Use starting_after_id
395+
*/
391396
page?: number
392397
}
393398

@@ -396,6 +401,7 @@ export interface VouchersListTransactionsResponseBody {
396401
data_ref: 'data'
397402
data: VoucherTransaction[]
398403
has_more: boolean
404+
more_starting_after?: string
399405
}
400406

401407
// Export transactions

packages/sdk/test/productCollections.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,12 @@ describe('Product Collections API', () => {
159159
} as ProductCollectionsCreateResponseBody),
160160
)
161161
})
162+
163+
it('should create AUTO_UPDATE collection based on product metadata', async () => {
164+
await client.productCollections.create({
165+
name: 'xxx',
166+
type: 'AUTO_UPDATE',
167+
filter: { junction: 'AND', 'metadata.isAwesome': { conditions: { $is: [true] } } },
168+
})
169+
})
162170
})

0 commit comments

Comments
 (0)