@clicktap/state 0.16.2 → 0.16.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__mocks__/nanoid.d.ts +7 -0
- package/auth/AuthProvider.d.ts +255 -0
- package/auth/actions/addError.d.ts +8 -0
- package/auth/actions/clearErrors.d.ts +5 -0
- package/auth/actions/index.d.ts +8 -0
- package/auth/actions/notifyAuthenticated.d.ts +6 -0
- package/auth/actions/setAccessToken.d.ts +9 -0
- package/auth/actions/setIgnoreRefreshToken.d.ts +4 -0
- package/auth/actions/setUserContext.d.ts +9 -0
- package/auth/actions/unsetRefreshToken.d.ts +4 -0
- package/auth/actions/unsetUserContext.d.ts +8 -0
- package/auth/actors/authenticate.d.ts +16 -0
- package/auth/actors/index.d.ts +3 -0
- package/auth/actors/refreshAccessToken.d.ts +18 -0
- package/auth/actors/unauthenticate.d.ts +14 -0
- package/auth/auth.d.ts +115 -0
- package/auth/types.d.ts +50 -0
- package/helpers/request.d.ts +2 -0
- package/package.json +1 -1
- package/quote/CheckoutProvider.d.ts +276 -0
- package/quote/QuoteProvider.d.ts +491 -0
- package/quote/checkout/actions/changeStep.d.ts +8 -0
- package/quote/checkout/actions/index.d.ts +5 -0
- package/quote/checkout/actions/nextStep.d.ts +8 -0
- package/quote/checkout/actions/resetCheckout.d.ts +104 -0
- package/quote/checkout/actions/updateQuote.d.ts +216 -0
- package/quote/checkout/actions/updateSuccessId.d.ts +8 -0
- package/quote/checkout/actors/index.d.ts +2 -0
- package/quote/checkout/actors/placeOrder.d.ts +20 -0
- package/quote/checkout/actors/submitStepData.d.ts +19 -0
- package/quote/checkout/guards/index.d.ts +1 -0
- package/quote/checkout/guards/quoteExists.d.ts +10 -0
- package/quote/checkout/types.d.ts +55 -0
- package/quote/checkout.d.ts +85 -0
- package/quote/quote/actions/addItems.d.ts +217 -0
- package/quote/quote/actions/index.d.ts +9 -0
- package/quote/quote/actions/notifyAddItems.d.ts +6 -0
- package/quote/quote/actions/notifyRemoveItems.d.ts +6 -0
- package/quote/quote/actions/notifyUpdateItems.d.ts +6 -0
- package/quote/quote/actions/refresh.d.ts +216 -0
- package/quote/quote/actions/removeItems.d.ts +217 -0
- package/quote/quote/actions/reset.d.ts +40 -0
- package/quote/quote/actions/syncAccessToken.d.ts +100 -0
- package/quote/quote/actions/updateItems.d.ts +217 -0
- package/quote/quote/actors/addItems.d.ts +24 -0
- package/quote/quote/actors/index.d.ts +4 -0
- package/quote/quote/actors/refresh.d.ts +22 -0
- package/quote/quote/actors/removeItems.d.ts +24 -0
- package/quote/quote/actors/updateItems.d.ts +24 -0
- package/quote/quote/guards/canRefresh.d.ts +10 -0
- package/quote/quote/guards/hasItems.d.ts +5 -0
- package/quote/quote/guards/index.d.ts +2 -0
- package/quote/quote/types.d.ts +291 -0
- package/quote/quote.d.ts +155 -0
- package/quote/types.d.ts +5 -0
- package/toast/ToastProvider.d.ts +93 -0
- package/toast/timer.d.ts +22 -0
- package/toast/toast.d.ts +82 -0
- package/toast/types.d.ts +58 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { QuoteMachineContext, QuoteMachineEvents } from '../types';
|
|
2
|
+
export declare function updateItems({ context, event, }: {
|
|
3
|
+
context: QuoteMachineContext;
|
|
4
|
+
event: QuoteMachineEvents;
|
|
5
|
+
}): QuoteMachineContext | {
|
|
6
|
+
quote: {
|
|
7
|
+
quote?: Partial<{
|
|
8
|
+
id: string | null;
|
|
9
|
+
accessToken: string | null;
|
|
10
|
+
locale: string | null;
|
|
11
|
+
checkoutSteps: import('../types').CheckoutStep[];
|
|
12
|
+
baseCurrency: string | null;
|
|
13
|
+
currency: string | null;
|
|
14
|
+
currencyConversionRate: number | null;
|
|
15
|
+
dateCreated: Date | null;
|
|
16
|
+
dateLastUpdated: Date | null;
|
|
17
|
+
items: Record<string, any>[] | null;
|
|
18
|
+
promotions: Record<string, any>[] | null;
|
|
19
|
+
shippingAddresses: {
|
|
20
|
+
available: import('../types').QuoteAddress[];
|
|
21
|
+
applied: {
|
|
22
|
+
availableAddressId?: string | undefined;
|
|
23
|
+
address: import('../types').QuoteAddress;
|
|
24
|
+
itemIds: Record<string, any>[];
|
|
25
|
+
}[];
|
|
26
|
+
};
|
|
27
|
+
paymentMethods: {
|
|
28
|
+
available: import('../types').PaymentMethod[];
|
|
29
|
+
applied: {
|
|
30
|
+
paymentMethod: import('../types').PaymentMethod;
|
|
31
|
+
options: Record<string, any>[];
|
|
32
|
+
amount: number;
|
|
33
|
+
}[];
|
|
34
|
+
};
|
|
35
|
+
shipments: {
|
|
36
|
+
id: string;
|
|
37
|
+
shippingAddress: {
|
|
38
|
+
id: string;
|
|
39
|
+
address: import('../types').QuoteAddress;
|
|
40
|
+
};
|
|
41
|
+
items: Record<string, any>[];
|
|
42
|
+
shippingMethods: {
|
|
43
|
+
available: {
|
|
44
|
+
shippingMethod: {
|
|
45
|
+
id: string;
|
|
46
|
+
code: string;
|
|
47
|
+
name: string;
|
|
48
|
+
carrier: {
|
|
49
|
+
id: string;
|
|
50
|
+
code: string;
|
|
51
|
+
name: string;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
estimatedTotal: number;
|
|
55
|
+
earliestShipDate: Date;
|
|
56
|
+
latestShipDate: Date;
|
|
57
|
+
earliestArrivalDate: Date;
|
|
58
|
+
latestArrivalDate: Date;
|
|
59
|
+
}[];
|
|
60
|
+
applied: {
|
|
61
|
+
shippingMethod: {
|
|
62
|
+
id: string;
|
|
63
|
+
code: string;
|
|
64
|
+
name: string;
|
|
65
|
+
carrier: {
|
|
66
|
+
id: string;
|
|
67
|
+
code: string;
|
|
68
|
+
name: string;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
estimatedTotal: number;
|
|
72
|
+
earliestShipDate: Date;
|
|
73
|
+
latestShipDate: Date;
|
|
74
|
+
earliestArrivalDate: Date;
|
|
75
|
+
latestArrivalDate: Date;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
}[];
|
|
79
|
+
totals: {
|
|
80
|
+
discount: number;
|
|
81
|
+
taxAmount: number;
|
|
82
|
+
shippingAmount: number;
|
|
83
|
+
shippingTaxAmount: number;
|
|
84
|
+
subtotal: number;
|
|
85
|
+
grandTotal: number;
|
|
86
|
+
} | null;
|
|
87
|
+
appliedPriceRules: Record<string, any>[] | null;
|
|
88
|
+
appliedPromotions: Record<string, any>[] | null;
|
|
89
|
+
shippingMethods: Record<string, any>[] | null;
|
|
90
|
+
storeCredit: Record<string, any>[] | null;
|
|
91
|
+
rewards: Record<string, any>[] | null;
|
|
92
|
+
giftCards: Record<string, any>[] | null;
|
|
93
|
+
user: {
|
|
94
|
+
id: string | null;
|
|
95
|
+
email: string | null;
|
|
96
|
+
firstName: string | null;
|
|
97
|
+
lastName: string | null;
|
|
98
|
+
} | null;
|
|
99
|
+
}> | undefined;
|
|
100
|
+
errors?: string[] | undefined;
|
|
101
|
+
endpoints?: {
|
|
102
|
+
client?: string | undefined;
|
|
103
|
+
server?: string | undefined;
|
|
104
|
+
} | undefined;
|
|
105
|
+
graphql?: {
|
|
106
|
+
refresh: {
|
|
107
|
+
document: import('graphql-request').RequestDocument | import('@graphql-typed-document-node/core').TypedDocumentNode<unknown, object>;
|
|
108
|
+
requestHeaders?: import('graphql-request/build/esm/types').GraphQLClientRequestHeaders | undefined;
|
|
109
|
+
};
|
|
110
|
+
addItems: {
|
|
111
|
+
document: import('graphql-request').RequestDocument | import('@graphql-typed-document-node/core').TypedDocumentNode<unknown, object>;
|
|
112
|
+
requestHeaders?: import('graphql-request/build/esm/types').GraphQLClientRequestHeaders | undefined;
|
|
113
|
+
};
|
|
114
|
+
removeItems: {
|
|
115
|
+
document: import('graphql-request').RequestDocument | import('@graphql-typed-document-node/core').TypedDocumentNode<unknown, object>;
|
|
116
|
+
requestHeaders?: import('graphql-request/build/esm/types').GraphQLClientRequestHeaders | undefined;
|
|
117
|
+
};
|
|
118
|
+
updateItems: {
|
|
119
|
+
document: import('graphql-request').RequestDocument | import('@graphql-typed-document-node/core').TypedDocumentNode<unknown, object>;
|
|
120
|
+
requestHeaders?: import('graphql-request/build/esm/types').GraphQLClientRequestHeaders | undefined;
|
|
121
|
+
};
|
|
122
|
+
} | undefined;
|
|
123
|
+
id?: string | null | undefined;
|
|
124
|
+
accessToken?: string | null | undefined;
|
|
125
|
+
locale?: string | null | undefined;
|
|
126
|
+
checkoutSteps?: import('../types').CheckoutStep[] | undefined;
|
|
127
|
+
baseCurrency?: string | null | undefined;
|
|
128
|
+
currency?: string | null | undefined;
|
|
129
|
+
currencyConversionRate?: number | null | undefined;
|
|
130
|
+
dateCreated?: Date | null | undefined;
|
|
131
|
+
dateLastUpdated?: Date | null | undefined;
|
|
132
|
+
items?: Record<string, any>[] | null | undefined;
|
|
133
|
+
promotions?: Record<string, any>[] | null | undefined;
|
|
134
|
+
shippingAddresses?: {
|
|
135
|
+
available: import('../types').QuoteAddress[];
|
|
136
|
+
applied: {
|
|
137
|
+
availableAddressId?: string | undefined;
|
|
138
|
+
address: import('../types').QuoteAddress;
|
|
139
|
+
itemIds: Record<string, any>[];
|
|
140
|
+
}[];
|
|
141
|
+
} | undefined;
|
|
142
|
+
paymentMethods?: {
|
|
143
|
+
available: import('../types').PaymentMethod[];
|
|
144
|
+
applied: {
|
|
145
|
+
paymentMethod: import('../types').PaymentMethod;
|
|
146
|
+
options: Record<string, any>[];
|
|
147
|
+
amount: number;
|
|
148
|
+
}[];
|
|
149
|
+
} | undefined;
|
|
150
|
+
shipments?: {
|
|
151
|
+
id: string;
|
|
152
|
+
shippingAddress: {
|
|
153
|
+
id: string;
|
|
154
|
+
address: import('../types').QuoteAddress;
|
|
155
|
+
};
|
|
156
|
+
items: Record<string, any>[];
|
|
157
|
+
shippingMethods: {
|
|
158
|
+
available: {
|
|
159
|
+
shippingMethod: {
|
|
160
|
+
id: string;
|
|
161
|
+
code: string;
|
|
162
|
+
name: string;
|
|
163
|
+
carrier: {
|
|
164
|
+
id: string;
|
|
165
|
+
code: string;
|
|
166
|
+
name: string;
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
estimatedTotal: number;
|
|
170
|
+
earliestShipDate: Date;
|
|
171
|
+
latestShipDate: Date;
|
|
172
|
+
earliestArrivalDate: Date;
|
|
173
|
+
latestArrivalDate: Date;
|
|
174
|
+
}[];
|
|
175
|
+
applied: {
|
|
176
|
+
shippingMethod: {
|
|
177
|
+
id: string;
|
|
178
|
+
code: string;
|
|
179
|
+
name: string;
|
|
180
|
+
carrier: {
|
|
181
|
+
id: string;
|
|
182
|
+
code: string;
|
|
183
|
+
name: string;
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
estimatedTotal: number;
|
|
187
|
+
earliestShipDate: Date;
|
|
188
|
+
latestShipDate: Date;
|
|
189
|
+
earliestArrivalDate: Date;
|
|
190
|
+
latestArrivalDate: Date;
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
}[] | undefined;
|
|
194
|
+
totals?: {
|
|
195
|
+
discount: number;
|
|
196
|
+
taxAmount: number;
|
|
197
|
+
shippingAmount: number;
|
|
198
|
+
shippingTaxAmount: number;
|
|
199
|
+
subtotal: number;
|
|
200
|
+
grandTotal: number;
|
|
201
|
+
} | null | undefined;
|
|
202
|
+
appliedPriceRules?: Record<string, any>[] | null | undefined;
|
|
203
|
+
appliedPromotions?: Record<string, any>[] | null | undefined;
|
|
204
|
+
shippingMethods?: Record<string, any>[] | null | undefined;
|
|
205
|
+
storeCredit?: Record<string, any>[] | null | undefined;
|
|
206
|
+
rewards?: Record<string, any>[] | null | undefined;
|
|
207
|
+
giftCards?: Record<string, any>[] | null | undefined;
|
|
208
|
+
user?: {
|
|
209
|
+
id: string | null;
|
|
210
|
+
email: string | null;
|
|
211
|
+
firstName: string | null;
|
|
212
|
+
lastName: string | null;
|
|
213
|
+
} | null | undefined;
|
|
214
|
+
};
|
|
215
|
+
itemsUpdated: Record<string, any>[] | null | undefined;
|
|
216
|
+
};
|
|
217
|
+
export default updateItems;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AddItemsEvent, AddItemsSuccessEvent, QuoteMachineContext } from '../types';
|
|
2
|
+
export type AddItemsInput = {
|
|
3
|
+
accessToken: QuoteMachineContext['quote']['accessToken'];
|
|
4
|
+
endpoint: QuoteMachineContext['endpoints']['client'];
|
|
5
|
+
items: AddItemsEvent['items'];
|
|
6
|
+
document: QuoteMachineContext['graphql']['addItems']['document'];
|
|
7
|
+
requestHeaders?: QuoteMachineContext['graphql']['addItems']['requestHeaders'];
|
|
8
|
+
};
|
|
9
|
+
export type AddItemsOutput = Partial<{
|
|
10
|
+
quoteAddItem: {
|
|
11
|
+
quote: object;
|
|
12
|
+
itemsAdded: Array<{
|
|
13
|
+
item: Array<Record<string, any>>;
|
|
14
|
+
previousQuantity: number;
|
|
15
|
+
}>;
|
|
16
|
+
userErrors: Array<{
|
|
17
|
+
code: string;
|
|
18
|
+
field: string;
|
|
19
|
+
message: string;
|
|
20
|
+
}>;
|
|
21
|
+
};
|
|
22
|
+
}>;
|
|
23
|
+
export declare const addItems: import('xstate').PromiseActorLogic<AddItemsSuccessEvent, AddItemsInput>;
|
|
24
|
+
export default addItems;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { RefreshSuccessEvent, QuoteMachineContext } from '../types';
|
|
2
|
+
export type RefreshInput = {
|
|
3
|
+
accessToken: QuoteMachineContext['quote']['accessToken'];
|
|
4
|
+
endpoint: QuoteMachineContext['endpoints']['client'];
|
|
5
|
+
endpointSsr: QuoteMachineContext['endpoints']['server'];
|
|
6
|
+
quoteId: QuoteMachineContext['quote']['id'];
|
|
7
|
+
locale: QuoteMachineContext['quote']['locale'];
|
|
8
|
+
document: QuoteMachineContext['graphql']['refresh']['document'];
|
|
9
|
+
requestHeaders?: QuoteMachineContext['graphql']['refresh']['requestHeaders'];
|
|
10
|
+
};
|
|
11
|
+
export type RefreshOutput = Partial<{
|
|
12
|
+
refreshQuote: {
|
|
13
|
+
quote: object;
|
|
14
|
+
userErrors: Array<{
|
|
15
|
+
code: string;
|
|
16
|
+
field: string;
|
|
17
|
+
message: string;
|
|
18
|
+
}>;
|
|
19
|
+
};
|
|
20
|
+
}>;
|
|
21
|
+
export declare const refresh: import('xstate').PromiseActorLogic<RefreshSuccessEvent, RefreshInput>;
|
|
22
|
+
export default refresh;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RemoveItemsEvent, RemoveItemsSuccessEvent, QuoteMachineContext } from '../types';
|
|
2
|
+
export type RemoveItemsInput = {
|
|
3
|
+
accessToken: QuoteMachineContext['quote']['accessToken'];
|
|
4
|
+
endpoint: QuoteMachineContext['endpoints']['client'];
|
|
5
|
+
items: RemoveItemsEvent['items'];
|
|
6
|
+
document: QuoteMachineContext['graphql']['removeItems']['document'];
|
|
7
|
+
requestHeaders?: QuoteMachineContext['graphql']['removeItems']['requestHeaders'];
|
|
8
|
+
};
|
|
9
|
+
export type RemoveItemsOutput = Partial<{
|
|
10
|
+
quoteRemoveItem: {
|
|
11
|
+
quote: object;
|
|
12
|
+
itemsRemoved: Array<{
|
|
13
|
+
item: Array<Record<string, any>>;
|
|
14
|
+
previousQuantity: number;
|
|
15
|
+
}>;
|
|
16
|
+
userErrors: Array<{
|
|
17
|
+
code: string;
|
|
18
|
+
field: string;
|
|
19
|
+
message: string;
|
|
20
|
+
}>;
|
|
21
|
+
};
|
|
22
|
+
}>;
|
|
23
|
+
export declare const removeItems: import('xstate').PromiseActorLogic<RemoveItemsSuccessEvent, RemoveItemsInput>;
|
|
24
|
+
export default removeItems;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { UpdateItemsEvent, UpdateItemsSuccessEvent, QuoteMachineContext } from '../types';
|
|
2
|
+
export type UpdateItemsInput = {
|
|
3
|
+
accessToken: QuoteMachineContext['quote']['accessToken'];
|
|
4
|
+
endpoint: QuoteMachineContext['endpoints']['client'];
|
|
5
|
+
items: UpdateItemsEvent['items'];
|
|
6
|
+
document: QuoteMachineContext['graphql']['updateItems']['document'];
|
|
7
|
+
requestHeaders?: QuoteMachineContext['graphql']['updateItems']['requestHeaders'];
|
|
8
|
+
};
|
|
9
|
+
export type UpdateItemsOutput = Partial<{
|
|
10
|
+
quoteUpdateItem: {
|
|
11
|
+
quote: object;
|
|
12
|
+
itemsUpdated: Array<{
|
|
13
|
+
item: Array<Record<string, any>>;
|
|
14
|
+
previousQuantity: number;
|
|
15
|
+
}>;
|
|
16
|
+
userErrors: Array<{
|
|
17
|
+
code: string;
|
|
18
|
+
field: string;
|
|
19
|
+
message: string;
|
|
20
|
+
}>;
|
|
21
|
+
};
|
|
22
|
+
}>;
|
|
23
|
+
export declare const updateItems: import('xstate').PromiseActorLogic<UpdateItemsSuccessEvent, UpdateItemsInput>;
|
|
24
|
+
export default updateItems;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { QuoteMachineContext } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Used for initializing quote.
|
|
4
|
+
* Allow quote to be refreshed if on server side and quote cookie present OR
|
|
5
|
+
* if on client side regardless of quote cookie
|
|
6
|
+
*/
|
|
7
|
+
export declare const canRefresh: ({ context }: {
|
|
8
|
+
context: QuoteMachineContext;
|
|
9
|
+
}) => boolean;
|
|
10
|
+
export default canRefresh;
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
2
|
+
import { RequestDocument } from 'graphql-request';
|
|
3
|
+
import { GraphQLClientRequestHeaders } from 'graphql-request/build/esm/types';
|
|
4
|
+
import { DoneActorEvent } from 'xstate';
|
|
5
|
+
/** @todo how do we want to handle quote items? */
|
|
6
|
+
export type QuoteAddress = {
|
|
7
|
+
id?: string;
|
|
8
|
+
country: {
|
|
9
|
+
code: string;
|
|
10
|
+
name: string;
|
|
11
|
+
};
|
|
12
|
+
firstName: string;
|
|
13
|
+
lastName: string;
|
|
14
|
+
company?: string;
|
|
15
|
+
addressLine1: string;
|
|
16
|
+
addressLine2?: string;
|
|
17
|
+
city: string;
|
|
18
|
+
region: {
|
|
19
|
+
code: string;
|
|
20
|
+
shortCode: string;
|
|
21
|
+
name: string;
|
|
22
|
+
};
|
|
23
|
+
postalCode: string;
|
|
24
|
+
phone?: string;
|
|
25
|
+
availableAddress?: {
|
|
26
|
+
id?: string;
|
|
27
|
+
isDefault?: boolean;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export type PaymentMethod = {
|
|
31
|
+
id: string;
|
|
32
|
+
code: string;
|
|
33
|
+
name: string;
|
|
34
|
+
sortOrder: number;
|
|
35
|
+
};
|
|
36
|
+
export type CheckoutStep = {
|
|
37
|
+
code: string;
|
|
38
|
+
name: string;
|
|
39
|
+
isAvailable: boolean;
|
|
40
|
+
isComplete: boolean;
|
|
41
|
+
prev?: string;
|
|
42
|
+
next?: string;
|
|
43
|
+
};
|
|
44
|
+
export interface QuoteMachineContext {
|
|
45
|
+
quote: Partial<{
|
|
46
|
+
id: string | null;
|
|
47
|
+
accessToken: string | null;
|
|
48
|
+
locale: string | null;
|
|
49
|
+
checkoutSteps: Array<CheckoutStep>;
|
|
50
|
+
baseCurrency: string | null;
|
|
51
|
+
currency: string | null;
|
|
52
|
+
currencyConversionRate: number | null;
|
|
53
|
+
dateCreated: Date | null;
|
|
54
|
+
dateLastUpdated: Date | null;
|
|
55
|
+
items: Array<Record<string, any>> | null;
|
|
56
|
+
promotions: Array<Record<string, any>> | null;
|
|
57
|
+
shippingAddresses: {
|
|
58
|
+
available: Array<QuoteAddress>;
|
|
59
|
+
applied: Array<{
|
|
60
|
+
availableAddressId?: string;
|
|
61
|
+
address: QuoteAddress;
|
|
62
|
+
itemIds: Array<Record<string, any>>;
|
|
63
|
+
}>;
|
|
64
|
+
};
|
|
65
|
+
paymentMethods: {
|
|
66
|
+
available: Array<PaymentMethod>;
|
|
67
|
+
applied: Array<{
|
|
68
|
+
paymentMethod: PaymentMethod;
|
|
69
|
+
options: Array<Record<string, any>>;
|
|
70
|
+
amount: number;
|
|
71
|
+
}>;
|
|
72
|
+
};
|
|
73
|
+
shipments: Array<{
|
|
74
|
+
id: string;
|
|
75
|
+
shippingAddress: {
|
|
76
|
+
id: string;
|
|
77
|
+
address: QuoteAddress;
|
|
78
|
+
};
|
|
79
|
+
items: Array<Record<string, any>>;
|
|
80
|
+
shippingMethods: {
|
|
81
|
+
available: Array<{
|
|
82
|
+
shippingMethod: {
|
|
83
|
+
id: string;
|
|
84
|
+
code: string;
|
|
85
|
+
name: string;
|
|
86
|
+
carrier: {
|
|
87
|
+
id: string;
|
|
88
|
+
code: string;
|
|
89
|
+
name: string;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
estimatedTotal: number;
|
|
93
|
+
earliestShipDate: Date;
|
|
94
|
+
latestShipDate: Date;
|
|
95
|
+
earliestArrivalDate: Date;
|
|
96
|
+
latestArrivalDate: Date;
|
|
97
|
+
}>;
|
|
98
|
+
applied: {
|
|
99
|
+
shippingMethod: {
|
|
100
|
+
id: string;
|
|
101
|
+
code: string;
|
|
102
|
+
name: string;
|
|
103
|
+
carrier: {
|
|
104
|
+
id: string;
|
|
105
|
+
code: string;
|
|
106
|
+
name: string;
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
estimatedTotal: number;
|
|
110
|
+
earliestShipDate: Date;
|
|
111
|
+
latestShipDate: Date;
|
|
112
|
+
earliestArrivalDate: Date;
|
|
113
|
+
latestArrivalDate: Date;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
}>;
|
|
117
|
+
totals: {
|
|
118
|
+
discount: number;
|
|
119
|
+
taxAmount: number;
|
|
120
|
+
shippingAmount: number;
|
|
121
|
+
shippingTaxAmount: number;
|
|
122
|
+
subtotal: number;
|
|
123
|
+
grandTotal: number;
|
|
124
|
+
} | null;
|
|
125
|
+
appliedPriceRules: Array<Record<string, any>> | null;
|
|
126
|
+
appliedPromotions: Array<Record<string, any>> | null;
|
|
127
|
+
shippingMethods: Array<Record<string, any>> | null;
|
|
128
|
+
storeCredit: Array<Record<string, any>> | null;
|
|
129
|
+
rewards: Array<Record<string, any>> | null;
|
|
130
|
+
giftCards: Array<Record<string, any>> | null;
|
|
131
|
+
user: {
|
|
132
|
+
id: string | null;
|
|
133
|
+
email: string | null;
|
|
134
|
+
firstName: string | null;
|
|
135
|
+
lastName: string | null;
|
|
136
|
+
} | null;
|
|
137
|
+
}>;
|
|
138
|
+
errors: Array<string>;
|
|
139
|
+
endpoints: {
|
|
140
|
+
client?: string;
|
|
141
|
+
server?: string;
|
|
142
|
+
};
|
|
143
|
+
graphql: {
|
|
144
|
+
refresh: {
|
|
145
|
+
document: RequestDocument | TypedDocumentNode<unknown, object>;
|
|
146
|
+
requestHeaders?: GraphQLClientRequestHeaders | undefined;
|
|
147
|
+
};
|
|
148
|
+
addItems: {
|
|
149
|
+
document: RequestDocument | TypedDocumentNode<unknown, object>;
|
|
150
|
+
requestHeaders?: GraphQLClientRequestHeaders | undefined;
|
|
151
|
+
};
|
|
152
|
+
removeItems: {
|
|
153
|
+
document: RequestDocument | TypedDocumentNode<unknown, object>;
|
|
154
|
+
requestHeaders?: GraphQLClientRequestHeaders | undefined;
|
|
155
|
+
};
|
|
156
|
+
updateItems: {
|
|
157
|
+
document: RequestDocument | TypedDocumentNode<unknown, object>;
|
|
158
|
+
requestHeaders?: GraphQLClientRequestHeaders | undefined;
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
export interface SetQuoteEmptyEvent {
|
|
163
|
+
type: 'SET_EMPTY';
|
|
164
|
+
}
|
|
165
|
+
export interface SetQuoteActiveEvent {
|
|
166
|
+
type: 'SET_ACTIVE';
|
|
167
|
+
}
|
|
168
|
+
export interface AddItemsEvent {
|
|
169
|
+
type: 'ADD_ITEMS';
|
|
170
|
+
items: Array<{
|
|
171
|
+
product: {
|
|
172
|
+
sku: string;
|
|
173
|
+
};
|
|
174
|
+
quantity: number;
|
|
175
|
+
}>;
|
|
176
|
+
}
|
|
177
|
+
export interface RemoveItemsEvent {
|
|
178
|
+
type: 'REMOVE_ITEMS';
|
|
179
|
+
items: Array<{
|
|
180
|
+
product: {
|
|
181
|
+
sku: string;
|
|
182
|
+
};
|
|
183
|
+
quantity: number;
|
|
184
|
+
}>;
|
|
185
|
+
}
|
|
186
|
+
export interface UpdateItemsEvent {
|
|
187
|
+
type: 'UPDATE_ITEMS';
|
|
188
|
+
items: Array<{
|
|
189
|
+
item: {
|
|
190
|
+
id: string;
|
|
191
|
+
};
|
|
192
|
+
quantity: number;
|
|
193
|
+
}>;
|
|
194
|
+
}
|
|
195
|
+
export interface ClearItemsEvent {
|
|
196
|
+
type: 'CLEAR_ITEMS';
|
|
197
|
+
}
|
|
198
|
+
export interface RefreshEvent {
|
|
199
|
+
type: 'REFRESH';
|
|
200
|
+
}
|
|
201
|
+
export interface ResetEvent {
|
|
202
|
+
type: 'RESET';
|
|
203
|
+
data: {
|
|
204
|
+
locale: string;
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
export interface ApplyPromotionEvent {
|
|
208
|
+
type: 'APPLY_PROMOTION';
|
|
209
|
+
}
|
|
210
|
+
export interface RemovePromotionEvent {
|
|
211
|
+
type: 'REMOVE_PROMOTION';
|
|
212
|
+
}
|
|
213
|
+
export interface AddAddressEvent {
|
|
214
|
+
type: 'ADD_ADDRESS';
|
|
215
|
+
}
|
|
216
|
+
export interface RemoveAddressEvent {
|
|
217
|
+
type: 'REMOVE_ADDRESS';
|
|
218
|
+
}
|
|
219
|
+
export interface ApplyPaymentMethodEvent {
|
|
220
|
+
type: 'APPLY_PAYMENT_METHOD';
|
|
221
|
+
}
|
|
222
|
+
export interface AddRewardEvent {
|
|
223
|
+
type: 'ADD_REWARD';
|
|
224
|
+
}
|
|
225
|
+
export interface RemoveRewardEvent {
|
|
226
|
+
type: 'REMOVE_REWARD';
|
|
227
|
+
}
|
|
228
|
+
export interface AddStoreCreditEvent {
|
|
229
|
+
type: 'ADD_STORE_CREDIT';
|
|
230
|
+
}
|
|
231
|
+
export interface RemoveStoreCreditEvent {
|
|
232
|
+
type: 'REMOVE_STORE_CREDIT';
|
|
233
|
+
}
|
|
234
|
+
export interface AddGiftCardEvent {
|
|
235
|
+
type: 'ADD_GIFT_CARD';
|
|
236
|
+
}
|
|
237
|
+
export interface RemoveGiftCardEvent {
|
|
238
|
+
type: 'REMOVE_GIFT_CARD';
|
|
239
|
+
}
|
|
240
|
+
export interface AddItemsSuccessEvent {
|
|
241
|
+
type: 'ADD_ITEMS_SUCCESS';
|
|
242
|
+
quote: Partial<QuoteMachineContext>;
|
|
243
|
+
itemsAdded: QuoteMachineContext['quote']['items'];
|
|
244
|
+
}
|
|
245
|
+
export interface RemoveItemsSuccessEvent {
|
|
246
|
+
type: 'REMOVE_ITEMS_SUCCESS';
|
|
247
|
+
quote: Partial<QuoteMachineContext>;
|
|
248
|
+
itemsRemoved: QuoteMachineContext['quote']['items'];
|
|
249
|
+
}
|
|
250
|
+
export interface UpdateItemsSuccessEvent {
|
|
251
|
+
type: 'UPDATE_ITEMS_SUCCESS';
|
|
252
|
+
quote: Partial<QuoteMachineContext>;
|
|
253
|
+
itemsUpdated: QuoteMachineContext['quote']['items'];
|
|
254
|
+
}
|
|
255
|
+
export interface ClearItemsSuccessEvent {
|
|
256
|
+
type: 'CLEAR_ITEMS_SUCCESS';
|
|
257
|
+
}
|
|
258
|
+
export interface RefreshSuccessEvent {
|
|
259
|
+
type: 'REFRESH_SUCCESS';
|
|
260
|
+
quote: Partial<QuoteMachineContext>;
|
|
261
|
+
}
|
|
262
|
+
export interface SyncAccessTokenEvent {
|
|
263
|
+
type: 'SYNC_ACCESS_TOKEN';
|
|
264
|
+
accessToken: string;
|
|
265
|
+
}
|
|
266
|
+
export type QuoteMachineEvents = SetQuoteEmptyEvent | SetQuoteActiveEvent | AddItemsEvent | RemoveItemsEvent | UpdateItemsEvent | ClearItemsEvent | RefreshEvent | ResetEvent | ApplyPromotionEvent | RemovePromotionEvent | AddAddressEvent | RemoveAddressEvent | ApplyPaymentMethodEvent | AddRewardEvent | RemoveRewardEvent | AddStoreCreditEvent | RemoveStoreCreditEvent | AddGiftCardEvent | RemoveGiftCardEvent | SyncAccessTokenEvent | DoneActorEvent<AddItemsSuccessEvent> | DoneActorEvent<RemoveItemsSuccessEvent> | DoneActorEvent<UpdateItemsSuccessEvent> | DoneActorEvent<ClearItemsSuccessEvent> | DoneActorEvent<RefreshSuccessEvent>;
|
|
267
|
+
export interface AddItemsEmittedEvent {
|
|
268
|
+
type: 'EMIT_ADD_ITEMS';
|
|
269
|
+
itemsAdded: QuoteMachineContext['quote']['items'];
|
|
270
|
+
}
|
|
271
|
+
export interface RemoveItemsEmittedEvent {
|
|
272
|
+
type: 'EMIT_REMOVE_ITEMS';
|
|
273
|
+
itemsRemoved: QuoteMachineContext['quote']['items'];
|
|
274
|
+
}
|
|
275
|
+
export interface UpdateItemsEmittedEvent {
|
|
276
|
+
type: 'EMIT_UPDATE_ITEMS';
|
|
277
|
+
itemsUpdated: QuoteMachineContext['quote']['items'];
|
|
278
|
+
}
|
|
279
|
+
export type QuoteMachineEmittedEvents = AddItemsEmittedEvent | RemoveItemsEmittedEvent | UpdateItemsEmittedEvent;
|
|
280
|
+
export type AddItemsResponse = {
|
|
281
|
+
message?: string;
|
|
282
|
+
success: boolean;
|
|
283
|
+
};
|
|
284
|
+
export type RemoveItemsResponse = {
|
|
285
|
+
message?: string;
|
|
286
|
+
success: boolean;
|
|
287
|
+
};
|
|
288
|
+
export type RefreshResponse = {
|
|
289
|
+
message?: string;
|
|
290
|
+
success: boolean;
|
|
291
|
+
};
|