@pinelab/vendure-order-client
Advanced tools
Comparing version 2.8.0 to 2.8.1
@@ -0,1 +1,5 @@ | ||
# 2.8.1 (2023-12-01) | ||
- Added `pollOrderByCode` to poll for order every second | ||
# 2.8.0 (2024-01-04) | ||
@@ -2,0 +6,0 @@ |
@@ -694,2 +694,18 @@ import { gql, GraphQLClient } from 'graphql-request'; | ||
} | ||
/** | ||
* Poll order by code for a given poll amount of times. And Poll for x seconds | ||
*/ | ||
async pollOrderByCode(code, pollFor = 10, acceptedStates = ['PaymentSettled', 'PaymentAuthorized']) { | ||
let order; | ||
let pollingCount = 0; | ||
while (!order || !acceptedStates.includes(order === null || order === void 0 ? void 0 : order.state)) { | ||
if (pollingCount > pollFor) { | ||
throw Error(`Order not found after polling ${pollFor} times`); | ||
} | ||
order = await this.getOrderByCode(code); | ||
await new Promise((resolve) => setTimeout(resolve, 1000)); | ||
pollingCount++; | ||
} | ||
return order; | ||
} | ||
async registerCustomerAccount(input) { | ||
@@ -847,2 +863,8 @@ const { registerCustomerAccount } = await this.rawRequest(this.queries.REGISTER_CUSTOMER_ACCOUNT, { input }); | ||
], VendureOrderClient.prototype, "getOrderByCode", null); | ||
__decorate([ | ||
HandleLoadingState('$activeOrder'), | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", [String, Number, Array]), | ||
__metadata("design:returntype", Promise) | ||
], VendureOrderClient.prototype, "pollOrderByCode", null); | ||
@@ -849,0 +871,0 @@ var AdjustmentType; |
@@ -48,2 +48,6 @@ import { GraphQLClient } from 'graphql-request'; | ||
getOrderByCode(code: string): Promise<ActiveOrder<A>>; | ||
/** | ||
* Poll order by code for a given poll amount of times. And Poll for x seconds | ||
*/ | ||
pollOrderByCode(code: string, pollFor?: number, acceptedStates?: string[]): Promise<ActiveOrder<A>>; | ||
registerCustomerAccount(input: RegisterCustomerInput): Promise<Success | ErrorResult>; | ||
@@ -50,0 +54,0 @@ requestPasswordReset(emailAddress: string): Promise<Success | ErrorResult | undefined>; |
{ | ||
"name": "@pinelab/vendure-order-client", | ||
"version": "2.8.0", | ||
"version": "2.8.1", | ||
"description": "A tiny, framework agnostic client for managing active orders and checkout with Vendure.", | ||
@@ -40,3 +40,3 @@ "author": "Martijn van de Brug <martijn@pinelab.studio>", | ||
}, | ||
"gitHead": "d934dca456447058c062f371fafb8d3206c1405a" | ||
"gitHead": "8e39c6ecc3e5acdca075411566f989e3b910a422" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
237493
6824