@clicktap/state 0.16.2 → 0.16.4
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 +133 -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 +54 -0
- package/auth/types.d.ts +50 -0
- package/helpers/request.d.ts +2 -0
- package/index.js +41 -34
- package/index.mjs +1979 -1636
- package/package.json +2 -2
- package/quote/CheckoutProvider.d.ts +159 -0
- package/quote/QuoteProvider.d.ts +242 -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 +46 -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 +72 -0
- package/quote/types.d.ts +5 -0
- package/toast/ToastProvider.d.ts +80 -0
- package/toast/timer.d.ts +23 -0
- package/toast/toast.d.ts +69 -0
- package/toast/types.d.ts +58 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { CheckoutMachineContext, CheckoutMachineEvents } from '../types';
|
|
2
|
+
export declare function updateQuote({ context, event, }: {
|
|
3
|
+
context: CheckoutMachineContext;
|
|
4
|
+
event: CheckoutMachineEvents;
|
|
5
|
+
}): CheckoutMachineContext | {
|
|
6
|
+
quote: {
|
|
7
|
+
quote?: Partial<{
|
|
8
|
+
id: string | null;
|
|
9
|
+
accessToken: string | null;
|
|
10
|
+
locale: string | null;
|
|
11
|
+
checkoutSteps: Array<import('../../..').CheckoutStep>;
|
|
12
|
+
baseCurrency: string | null;
|
|
13
|
+
currency: string | null;
|
|
14
|
+
currencyConversionRate: number | null;
|
|
15
|
+
dateCreated: Date | null;
|
|
16
|
+
dateLastUpdated: Date | null;
|
|
17
|
+
items: Array<Record<string, any>> | null;
|
|
18
|
+
promotions: Array<Record<string, any>> | null;
|
|
19
|
+
shippingAddresses: {
|
|
20
|
+
available: Array<import('../../..').QuoteAddress>;
|
|
21
|
+
applied: Array<{
|
|
22
|
+
availableAddressId?: string;
|
|
23
|
+
address: import('../../..').QuoteAddress;
|
|
24
|
+
itemIds: Array<Record<string, any>>;
|
|
25
|
+
}>;
|
|
26
|
+
};
|
|
27
|
+
paymentMethods: {
|
|
28
|
+
available: Array<import('../../..').PaymentMethod>;
|
|
29
|
+
applied: Array<{
|
|
30
|
+
paymentMethod: import('../../..').PaymentMethod;
|
|
31
|
+
options: Array<Record<string, any>>;
|
|
32
|
+
amount: number;
|
|
33
|
+
}>;
|
|
34
|
+
};
|
|
35
|
+
shipments: Array<{
|
|
36
|
+
id: string;
|
|
37
|
+
shippingAddress: {
|
|
38
|
+
id: string;
|
|
39
|
+
address: import('../../..').QuoteAddress;
|
|
40
|
+
};
|
|
41
|
+
items: Array<Record<string, any>>;
|
|
42
|
+
shippingMethods: {
|
|
43
|
+
available: Array<{
|
|
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: Array<Record<string, any>> | null;
|
|
88
|
+
appliedPromotions: Array<Record<string, any>> | null;
|
|
89
|
+
shippingMethods: Array<Record<string, any>> | null;
|
|
90
|
+
storeCredit: Array<Record<string, any>> | null;
|
|
91
|
+
rewards: Array<Record<string, any>> | null;
|
|
92
|
+
giftCards: Array<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;
|
|
103
|
+
server?: string;
|
|
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('../../..').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: Array<import('../../..').QuoteAddress>;
|
|
136
|
+
applied: Array<{
|
|
137
|
+
availableAddressId?: string;
|
|
138
|
+
address: import('../../..').QuoteAddress;
|
|
139
|
+
itemIds: Array<Record<string, any>>;
|
|
140
|
+
}>;
|
|
141
|
+
} | undefined;
|
|
142
|
+
paymentMethods?: {
|
|
143
|
+
available: Array<import('../../..').PaymentMethod>;
|
|
144
|
+
applied: Array<{
|
|
145
|
+
paymentMethod: import('../../..').PaymentMethod;
|
|
146
|
+
options: Array<Record<string, any>>;
|
|
147
|
+
amount: number;
|
|
148
|
+
}>;
|
|
149
|
+
} | undefined;
|
|
150
|
+
shipments?: {
|
|
151
|
+
id: string;
|
|
152
|
+
shippingAddress: {
|
|
153
|
+
id: string;
|
|
154
|
+
address: import('../../..').QuoteAddress;
|
|
155
|
+
};
|
|
156
|
+
items: Array<Record<string, any>>;
|
|
157
|
+
shippingMethods: {
|
|
158
|
+
available: Array<{
|
|
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
|
+
};
|
|
216
|
+
export default updateQuote;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CheckoutMachineContext, CheckoutMachineEvents } from '../types';
|
|
2
|
+
export declare function updateSuccessId({ context, event, }: {
|
|
3
|
+
context: CheckoutMachineContext;
|
|
4
|
+
event: CheckoutMachineEvents;
|
|
5
|
+
}): CheckoutMachineContext | {
|
|
6
|
+
successId: string;
|
|
7
|
+
};
|
|
8
|
+
export default updateSuccessId;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CheckoutMachineContext, PlaceOrderSuccessEvent } from '../types';
|
|
2
|
+
export type PlaceOrderDataInput = {
|
|
3
|
+
endpoint: CheckoutMachineContext['endpoints']['client'];
|
|
4
|
+
document: CheckoutMachineContext['graphql']['placeOrder']['document'];
|
|
5
|
+
requestHeaders?: CheckoutMachineContext['graphql']['placeOrder']['requestHeaders'];
|
|
6
|
+
};
|
|
7
|
+
export type PlaceOrderDataOutput = Partial<{
|
|
8
|
+
placeOrder: {
|
|
9
|
+
checkoutSuccess: {
|
|
10
|
+
id: string;
|
|
11
|
+
};
|
|
12
|
+
userErrors: Array<{
|
|
13
|
+
code: string;
|
|
14
|
+
field: string;
|
|
15
|
+
message: string;
|
|
16
|
+
}>;
|
|
17
|
+
};
|
|
18
|
+
}>;
|
|
19
|
+
export declare const placeOrder: import('xstate').PromiseActorLogic<PlaceOrderSuccessEvent, PlaceOrderDataInput, import('xstate').EventObject>;
|
|
20
|
+
export default placeOrder;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CheckoutMachineContext, SubmitStepDataEvent, SubmitStepDataSuccessEvent } from '../types';
|
|
2
|
+
export type SubmitStepDataInput = {
|
|
3
|
+
endpoint: CheckoutMachineContext['endpoints']['client'];
|
|
4
|
+
data: SubmitStepDataEvent['data'];
|
|
5
|
+
document: CheckoutMachineContext['graphql']['submitStepData']['document'];
|
|
6
|
+
requestHeaders?: CheckoutMachineContext['graphql']['submitStepData']['requestHeaders'];
|
|
7
|
+
};
|
|
8
|
+
export type SubmitStepDataOutput = Partial<{
|
|
9
|
+
checkoutStep: {
|
|
10
|
+
quote: object;
|
|
11
|
+
userErrors: Array<{
|
|
12
|
+
code: string;
|
|
13
|
+
field: string;
|
|
14
|
+
message: string;
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
17
|
+
}>;
|
|
18
|
+
export declare const submitStepData: import('xstate').PromiseActorLogic<SubmitStepDataSuccessEvent, SubmitStepDataInput, import('xstate').EventObject>;
|
|
19
|
+
export default submitStepData;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './quoteExists';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CheckoutMachineContext } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Used for initializing quote.
|
|
4
|
+
* Checks whether the quote is an empty object since an initialized quote
|
|
5
|
+
* will never be empty
|
|
6
|
+
*/
|
|
7
|
+
export declare const quoteExists: ({ context }: {
|
|
8
|
+
context: CheckoutMachineContext;
|
|
9
|
+
}) => boolean;
|
|
10
|
+
export default quoteExists;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { RequestDocument } from 'graphql-request';
|
|
2
|
+
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
3
|
+
import { GraphQLClientRequestHeaders } from 'graphql-request/build/esm/types';
|
|
4
|
+
import { DoneActorEvent } from 'xstate';
|
|
5
|
+
import { QuoteMachineContext, CheckoutStep } from '../quote/types';
|
|
6
|
+
export interface CheckoutMachineContext {
|
|
7
|
+
currentStep: string;
|
|
8
|
+
/** @todo DeepPartial should play nicer with props like steps */
|
|
9
|
+
steps?: Array<CheckoutStep>;
|
|
10
|
+
isLoggedIn: boolean;
|
|
11
|
+
quote: QuoteMachineContext['quote'];
|
|
12
|
+
endpoints: {
|
|
13
|
+
client?: string;
|
|
14
|
+
server?: string;
|
|
15
|
+
};
|
|
16
|
+
successId: string;
|
|
17
|
+
graphql: {
|
|
18
|
+
placeOrder: {
|
|
19
|
+
document: RequestDocument | TypedDocumentNode<unknown, object>;
|
|
20
|
+
requestHeaders?: GraphQLClientRequestHeaders;
|
|
21
|
+
};
|
|
22
|
+
submitStepData: {
|
|
23
|
+
document: RequestDocument | TypedDocumentNode<unknown, object>;
|
|
24
|
+
requestHeaders?: GraphQLClientRequestHeaders;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export interface ChangeStepEvent {
|
|
29
|
+
type: 'CHANGE_STEP';
|
|
30
|
+
step: string;
|
|
31
|
+
}
|
|
32
|
+
export interface PlaceOrderEvent {
|
|
33
|
+
type: 'PLACE_ORDER';
|
|
34
|
+
}
|
|
35
|
+
export interface ResetCheckoutEvent {
|
|
36
|
+
type: 'RESET_CHECKOUT';
|
|
37
|
+
data: {
|
|
38
|
+
currentStep: string;
|
|
39
|
+
steps: Array<CheckoutStep>;
|
|
40
|
+
quote: QuoteMachineContext['quote'];
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export interface SubmitStepDataEvent {
|
|
44
|
+
type: 'SUBMIT_STEP_DATA';
|
|
45
|
+
data: Record<string, any>;
|
|
46
|
+
}
|
|
47
|
+
export interface SubmitStepDataSuccessEvent {
|
|
48
|
+
type: 'SUBMIT_STEP_DATA_SUCCESS';
|
|
49
|
+
quote: Partial<QuoteMachineContext>;
|
|
50
|
+
}
|
|
51
|
+
export interface PlaceOrderSuccessEvent {
|
|
52
|
+
type: 'PLACE_ORDER_SUCCESS';
|
|
53
|
+
successId: string;
|
|
54
|
+
}
|
|
55
|
+
export type CheckoutMachineEvents = ChangeStepEvent | PlaceOrderEvent | ResetCheckoutEvent | SubmitStepDataEvent | DoneActorEvent<PlaceOrderSuccessEvent> | DoneActorEvent<SubmitStepDataSuccessEvent>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { CheckoutMachineContext } from './checkout/types';
|
|
2
|
+
import { DeepPartial } from './types';
|
|
3
|
+
export declare const checkoutMachine: import('xstate').StateMachine<CheckoutMachineContext, import('./checkout/types').ChangeStepEvent | import('./checkout/types').PlaceOrderEvent | import('./checkout/types').ResetCheckoutEvent | import('./checkout/types').SubmitStepDataEvent | import('xstate').DoneActorEvent<import('./checkout/types').PlaceOrderSuccessEvent, string> | import('xstate').DoneActorEvent<import('./checkout/types').SubmitStepDataSuccessEvent, string>, {
|
|
4
|
+
[x: string]: import('xstate').ActorRefFromLogic<import('xstate').PromiseActorLogic<import('./checkout/types').PlaceOrderSuccessEvent, import('./checkout/actors').PlaceOrderDataInput, import('xstate').EventObject>> | import('xstate').ActorRefFromLogic<import('xstate').PromiseActorLogic<import('./checkout/types').SubmitStepDataSuccessEvent, import('./checkout/actors').SubmitStepDataInput, import('xstate').EventObject>> | undefined;
|
|
5
|
+
}, {
|
|
6
|
+
src: "placeOrder";
|
|
7
|
+
logic: import('xstate').PromiseActorLogic<import('./checkout/types').PlaceOrderSuccessEvent, import('./checkout/actors').PlaceOrderDataInput, import('xstate').EventObject>;
|
|
8
|
+
id: string | undefined;
|
|
9
|
+
} | {
|
|
10
|
+
src: "submitStepData";
|
|
11
|
+
logic: import('xstate').PromiseActorLogic<import('./checkout/types').SubmitStepDataSuccessEvent, import('./checkout/actors').SubmitStepDataInput, import('xstate').EventObject>;
|
|
12
|
+
id: string | undefined;
|
|
13
|
+
}, {
|
|
14
|
+
type: "changeStep";
|
|
15
|
+
params: import('xstate').NonReducibleUnknown;
|
|
16
|
+
} | {
|
|
17
|
+
type: "nextStep";
|
|
18
|
+
params: import('xstate').NonReducibleUnknown;
|
|
19
|
+
} | {
|
|
20
|
+
type: "resetCheckout";
|
|
21
|
+
params: import('xstate').NonReducibleUnknown;
|
|
22
|
+
} | {
|
|
23
|
+
type: "updateQuote";
|
|
24
|
+
params: import('xstate').NonReducibleUnknown;
|
|
25
|
+
} | {
|
|
26
|
+
type: "updateSuccessId";
|
|
27
|
+
params: import('xstate').NonReducibleUnknown;
|
|
28
|
+
}, {
|
|
29
|
+
type: "quoteExists";
|
|
30
|
+
params: unknown;
|
|
31
|
+
}, never, "uninitialized" | "initializing" | "showStep" | "submittingStepData" | "changingStep" | "placingOrder" | "success", string, {
|
|
32
|
+
initialContext: DeepPartial<CheckoutMachineContext>;
|
|
33
|
+
initialState?: string;
|
|
34
|
+
}, import('xstate').NonReducibleUnknown, import('xstate').EventObject, import('xstate').MetaObject, {
|
|
35
|
+
id: "checkout";
|
|
36
|
+
states: {
|
|
37
|
+
readonly uninitialized: {};
|
|
38
|
+
readonly initializing: {};
|
|
39
|
+
readonly showStep: {};
|
|
40
|
+
readonly submittingStepData: {};
|
|
41
|
+
readonly changingStep: {};
|
|
42
|
+
readonly placingOrder: {};
|
|
43
|
+
readonly success: {};
|
|
44
|
+
};
|
|
45
|
+
}>;
|
|
46
|
+
export default checkoutMachine;
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { QuoteMachineContext, QuoteMachineEvents } from '../types';
|
|
2
|
+
export declare function addItems({ 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: Array<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: Array<Record<string, any>> | null;
|
|
18
|
+
promotions: Array<Record<string, any>> | null;
|
|
19
|
+
shippingAddresses: {
|
|
20
|
+
available: Array<import('../types').QuoteAddress>;
|
|
21
|
+
applied: Array<{
|
|
22
|
+
availableAddressId?: string;
|
|
23
|
+
address: import('../types').QuoteAddress;
|
|
24
|
+
itemIds: Array<Record<string, any>>;
|
|
25
|
+
}>;
|
|
26
|
+
};
|
|
27
|
+
paymentMethods: {
|
|
28
|
+
available: Array<import('../types').PaymentMethod>;
|
|
29
|
+
applied: Array<{
|
|
30
|
+
paymentMethod: import('../types').PaymentMethod;
|
|
31
|
+
options: Array<Record<string, any>>;
|
|
32
|
+
amount: number;
|
|
33
|
+
}>;
|
|
34
|
+
};
|
|
35
|
+
shipments: Array<{
|
|
36
|
+
id: string;
|
|
37
|
+
shippingAddress: {
|
|
38
|
+
id: string;
|
|
39
|
+
address: import('../types').QuoteAddress;
|
|
40
|
+
};
|
|
41
|
+
items: Array<Record<string, any>>;
|
|
42
|
+
shippingMethods: {
|
|
43
|
+
available: Array<{
|
|
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: Array<Record<string, any>> | null;
|
|
88
|
+
appliedPromotions: Array<Record<string, any>> | null;
|
|
89
|
+
shippingMethods: Array<Record<string, any>> | null;
|
|
90
|
+
storeCredit: Array<Record<string, any>> | null;
|
|
91
|
+
rewards: Array<Record<string, any>> | null;
|
|
92
|
+
giftCards: Array<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;
|
|
103
|
+
server?: string;
|
|
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: Array<import('../types').QuoteAddress>;
|
|
136
|
+
applied: Array<{
|
|
137
|
+
availableAddressId?: string;
|
|
138
|
+
address: import('../types').QuoteAddress;
|
|
139
|
+
itemIds: Array<Record<string, any>>;
|
|
140
|
+
}>;
|
|
141
|
+
} | undefined;
|
|
142
|
+
paymentMethods?: {
|
|
143
|
+
available: Array<import('../types').PaymentMethod>;
|
|
144
|
+
applied: Array<{
|
|
145
|
+
paymentMethod: import('../types').PaymentMethod;
|
|
146
|
+
options: Array<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: Array<Record<string, any>>;
|
|
157
|
+
shippingMethods: {
|
|
158
|
+
available: Array<{
|
|
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
|
+
itemsAdded: Record<string, any>[] | null | undefined;
|
|
216
|
+
};
|
|
217
|
+
export default addItems;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './addItems';
|
|
2
|
+
export * from './notifyAddItems';
|
|
3
|
+
export * from './notifyRemoveItems';
|
|
4
|
+
export * from './notifyUpdateItems';
|
|
5
|
+
export * from './removeItems';
|
|
6
|
+
export * from './refresh';
|
|
7
|
+
export * from './reset';
|
|
8
|
+
export * from './syncAccessToken';
|
|
9
|
+
export * from './updateItems';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { RemoveItemsEmittedEvent, QuoteMachineContext, QuoteMachineEvents } from '../types';
|
|
2
|
+
export declare function notifyRemoveItems({ event, }: {
|
|
3
|
+
context: QuoteMachineContext;
|
|
4
|
+
event: QuoteMachineEvents;
|
|
5
|
+
}): RemoveItemsEmittedEvent;
|
|
6
|
+
export default notifyRemoveItems;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { UpdateItemsEmittedEvent, QuoteMachineContext, QuoteMachineEvents } from '../types';
|
|
2
|
+
export declare function notifyUpdateItems({ event, }: {
|
|
3
|
+
context: QuoteMachineContext;
|
|
4
|
+
event: QuoteMachineEvents;
|
|
5
|
+
}): UpdateItemsEmittedEvent;
|
|
6
|
+
export default notifyUpdateItems;
|