@clicktap/state 0.12.16 → 0.13.0
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/auth/AuthProvider.d.ts +2 -2
- package/auth/auth.d.ts +1 -1
- package/index.d.ts +2 -0
- package/index.js +51 -5
- package/index.mjs +4592 -2493
- package/package.json +3 -2
- package/quote/QuoteProvider.d.ts +205 -0
- package/quote/actions/addItems.d.ts +80 -0
- package/quote/actions/index.d.ts +3 -0
- package/quote/actions/refresh.d.ts +82 -0
- package/quote/actions/removeItems.d.ts +80 -0
- package/quote/actors/addItems.d.ts +19 -0
- package/quote/actors/index.d.ts +3 -0
- package/quote/actors/refresh.d.ts +21 -0
- package/quote/actors/removeItems.d.ts +17 -0
- package/quote/guards/canRefresh.d.ts +10 -0
- package/quote/guards/hasItems.d.ts +5 -0
- package/quote/guards/index.d.ts +1 -0
- package/quote/quote.d.ts +93 -0
- package/quote/types.d.ts +147 -0
- package/toast/ToastProvider.d.ts +8 -8
- package/toast/timer.d.ts +1 -1
- package/toast/toast.d.ts +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clicktap/state",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Clicktap",
|
|
6
6
|
"description": "A state management library for Clicktap reference frontend.",
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"xstate": "^5.9.1",
|
|
18
18
|
"@xstate/react": "^4.1.0",
|
|
19
19
|
"cookie": "^0.5.0",
|
|
20
|
-
"
|
|
20
|
+
"graphql": "^16.6.0",
|
|
21
|
+
"graphql-request": "^6.1.0",
|
|
21
22
|
"nanoid": "^4.0.2"
|
|
22
23
|
},
|
|
23
24
|
"devDependencies": {
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Actor, InspectionEvent, Observer } from 'xstate';
|
|
3
|
+
import { quoteMachine } from './quote';
|
|
4
|
+
import { DeepPartial, QuoteMachineContext } from './types';
|
|
5
|
+
export interface QuoteContextType {
|
|
6
|
+
quoteActor: Actor<typeof quoteMachine>;
|
|
7
|
+
}
|
|
8
|
+
export declare const QuoteContext: import("react").Context<Actor<import("xstate").StateMachine<QuoteMachineContext, import("./types").SetEmptyEvent | import("./types").SetActiveEvent | import("./types").AddItemsEvent | import("./types").RemoveItemsEvent | import("./types").ClearItemsEvent | import("./types").RefreshEvent | import("./types").ApplyPromotionEvent | import("./types").RemovePromotionEvent | import("./types").AddAddressEvent | import("./types").RemoveAddressEvent | import("./types").ApplyPaymentMethodEvent | import("./types").AddRewardEvent | import("./types").RemoveRewardEvent | import("./types").AddStoreCreditEvent | import("./types").RemoveStoreCreditEvent | import("./types").AddGiftCardEvent | import("./types").RemoveGiftCardEvent | import("xstate").DoneActorEvent<import("./types").AddItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./types").RemoveItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./types").ClearItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./types").RefreshSuccessEvent>, {
|
|
9
|
+
[x: string]: import("xstate").ActorRef<import("xstate").PromiseSnapshot<import("./types").AddItemsSuccessEvent, import("./actors").AddItemsInput>, {
|
|
10
|
+
[k: string]: unknown;
|
|
11
|
+
type: string;
|
|
12
|
+
}, import("xstate").EventObject> | import("xstate").ActorRef<import("xstate").PromiseSnapshot<import("./types").RemoveItemsSuccessEvent, import("./actors").RemoveItemsInput>, {
|
|
13
|
+
[k: string]: unknown;
|
|
14
|
+
type: string;
|
|
15
|
+
}, import("xstate").EventObject> | import("xstate").ActorRef<import("xstate").PromiseSnapshot<import("./types").RefreshSuccessEvent, import("./actors").RefreshInput>, {
|
|
16
|
+
[k: string]: unknown;
|
|
17
|
+
type: string;
|
|
18
|
+
}, import("xstate").EventObject> | undefined;
|
|
19
|
+
}, import("xstate").Values<{
|
|
20
|
+
addItems: {
|
|
21
|
+
src: "addItems";
|
|
22
|
+
logic: import("xstate").PromiseActorLogic<import("./types").AddItemsSuccessEvent, import("./actors").AddItemsInput>;
|
|
23
|
+
id: string | undefined;
|
|
24
|
+
};
|
|
25
|
+
removeItems: {
|
|
26
|
+
src: "removeItems";
|
|
27
|
+
logic: import("xstate").PromiseActorLogic<import("./types").RemoveItemsSuccessEvent, import("./actors").RemoveItemsInput>;
|
|
28
|
+
id: string | undefined;
|
|
29
|
+
};
|
|
30
|
+
refresh: {
|
|
31
|
+
src: "refresh";
|
|
32
|
+
logic: import("xstate").PromiseActorLogic<import("./types").RefreshSuccessEvent, import("./actors").RefreshInput>;
|
|
33
|
+
id: string | undefined;
|
|
34
|
+
};
|
|
35
|
+
}>, import("xstate").Values<{
|
|
36
|
+
addItems: {
|
|
37
|
+
type: "addItems";
|
|
38
|
+
params: import("xstate").NonReducibleUnknown;
|
|
39
|
+
};
|
|
40
|
+
removeItems: {
|
|
41
|
+
type: "removeItems";
|
|
42
|
+
params: import("xstate").NonReducibleUnknown;
|
|
43
|
+
};
|
|
44
|
+
refresh: {
|
|
45
|
+
type: "refresh";
|
|
46
|
+
params: import("xstate").NonReducibleUnknown;
|
|
47
|
+
};
|
|
48
|
+
}>, import("xstate").Values<{
|
|
49
|
+
canRefresh: {
|
|
50
|
+
type: "canRefresh";
|
|
51
|
+
params: unknown;
|
|
52
|
+
};
|
|
53
|
+
hasItems: {
|
|
54
|
+
type: "hasItems";
|
|
55
|
+
params: unknown;
|
|
56
|
+
};
|
|
57
|
+
}>, never, "active" | "refreshing" | "initializing" | "uninitialized" | "empty" | "addingItems" | "removingItems", string, {
|
|
58
|
+
initialContext: DeepPartial<QuoteMachineContext>;
|
|
59
|
+
initialState?: string | undefined;
|
|
60
|
+
}, import("xstate").NonReducibleUnknown, import("xstate").EventObject, import("xstate").MetaObject, import("xstate").ResolveTypegenMeta<import("xstate").TypegenDisabled, import("./types").SetEmptyEvent | import("./types").SetActiveEvent | import("./types").AddItemsEvent | import("./types").RemoveItemsEvent | import("./types").ClearItemsEvent | import("./types").RefreshEvent | import("./types").ApplyPromotionEvent | import("./types").RemovePromotionEvent | import("./types").AddAddressEvent | import("./types").RemoveAddressEvent | import("./types").ApplyPaymentMethodEvent | import("./types").AddRewardEvent | import("./types").RemoveRewardEvent | import("./types").AddStoreCreditEvent | import("./types").RemoveStoreCreditEvent | import("./types").AddGiftCardEvent | import("./types").RemoveGiftCardEvent | import("xstate").DoneActorEvent<import("./types").AddItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./types").RemoveItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./types").ClearItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./types").RefreshSuccessEvent>, import("xstate").Values<{
|
|
61
|
+
addItems: {
|
|
62
|
+
src: "addItems";
|
|
63
|
+
logic: import("xstate").PromiseActorLogic<import("./types").AddItemsSuccessEvent, import("./actors").AddItemsInput>;
|
|
64
|
+
id: string | undefined;
|
|
65
|
+
};
|
|
66
|
+
removeItems: {
|
|
67
|
+
src: "removeItems";
|
|
68
|
+
logic: import("xstate").PromiseActorLogic<import("./types").RemoveItemsSuccessEvent, import("./actors").RemoveItemsInput>;
|
|
69
|
+
id: string | undefined;
|
|
70
|
+
};
|
|
71
|
+
refresh: {
|
|
72
|
+
src: "refresh";
|
|
73
|
+
logic: import("xstate").PromiseActorLogic<import("./types").RefreshSuccessEvent, import("./actors").RefreshInput>;
|
|
74
|
+
id: string | undefined;
|
|
75
|
+
};
|
|
76
|
+
}>, import("xstate").Values<{
|
|
77
|
+
addItems: {
|
|
78
|
+
type: "addItems";
|
|
79
|
+
params: import("xstate").NonReducibleUnknown;
|
|
80
|
+
};
|
|
81
|
+
removeItems: {
|
|
82
|
+
type: "removeItems";
|
|
83
|
+
params: import("xstate").NonReducibleUnknown;
|
|
84
|
+
};
|
|
85
|
+
refresh: {
|
|
86
|
+
type: "refresh";
|
|
87
|
+
params: import("xstate").NonReducibleUnknown;
|
|
88
|
+
};
|
|
89
|
+
}>, import("xstate").Values<{
|
|
90
|
+
canRefresh: {
|
|
91
|
+
type: "canRefresh";
|
|
92
|
+
params: unknown;
|
|
93
|
+
};
|
|
94
|
+
hasItems: {
|
|
95
|
+
type: "hasItems";
|
|
96
|
+
params: unknown;
|
|
97
|
+
};
|
|
98
|
+
}>, never, string, import("xstate").EventObject>>>>;
|
|
99
|
+
export declare const useQuote: () => QuoteContextType;
|
|
100
|
+
type QuoteOptions = {
|
|
101
|
+
inspect: Observer<InspectionEvent> | undefined;
|
|
102
|
+
quote: DeepPartial<QuoteMachineContext['quote']>;
|
|
103
|
+
endpoints?: Partial<QuoteMachineContext['endpoints']>;
|
|
104
|
+
graphql?: Partial<QuoteMachineContext['graphql']>;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* runs on server side as part of withQuote HOF
|
|
108
|
+
*/
|
|
109
|
+
export declare const getQuote: (options?: QuoteOptions) => Promise<Actor<import("xstate").StateMachine<QuoteMachineContext, import("./types").SetEmptyEvent | import("./types").SetActiveEvent | import("./types").AddItemsEvent | import("./types").RemoveItemsEvent | import("./types").ClearItemsEvent | import("./types").RefreshEvent | import("./types").ApplyPromotionEvent | import("./types").RemovePromotionEvent | import("./types").AddAddressEvent | import("./types").RemoveAddressEvent | import("./types").ApplyPaymentMethodEvent | import("./types").AddRewardEvent | import("./types").RemoveRewardEvent | import("./types").AddStoreCreditEvent | import("./types").RemoveStoreCreditEvent | import("./types").AddGiftCardEvent | import("./types").RemoveGiftCardEvent | import("xstate").DoneActorEvent<import("./types").AddItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./types").RemoveItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./types").ClearItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./types").RefreshSuccessEvent>, {
|
|
110
|
+
[x: string]: import("xstate").ActorRef<import("xstate").PromiseSnapshot<import("./types").AddItemsSuccessEvent, import("./actors").AddItemsInput>, {
|
|
111
|
+
[k: string]: unknown;
|
|
112
|
+
type: string;
|
|
113
|
+
}, import("xstate").EventObject> | import("xstate").ActorRef<import("xstate").PromiseSnapshot<import("./types").RemoveItemsSuccessEvent, import("./actors").RemoveItemsInput>, {
|
|
114
|
+
[k: string]: unknown;
|
|
115
|
+
type: string;
|
|
116
|
+
}, import("xstate").EventObject> | import("xstate").ActorRef<import("xstate").PromiseSnapshot<import("./types").RefreshSuccessEvent, import("./actors").RefreshInput>, {
|
|
117
|
+
[k: string]: unknown;
|
|
118
|
+
type: string;
|
|
119
|
+
}, import("xstate").EventObject> | undefined;
|
|
120
|
+
}, import("xstate").Values<{
|
|
121
|
+
addItems: {
|
|
122
|
+
src: "addItems";
|
|
123
|
+
logic: import("xstate").PromiseActorLogic<import("./types").AddItemsSuccessEvent, import("./actors").AddItemsInput>;
|
|
124
|
+
id: string | undefined;
|
|
125
|
+
};
|
|
126
|
+
removeItems: {
|
|
127
|
+
src: "removeItems";
|
|
128
|
+
logic: import("xstate").PromiseActorLogic<import("./types").RemoveItemsSuccessEvent, import("./actors").RemoveItemsInput>;
|
|
129
|
+
id: string | undefined;
|
|
130
|
+
};
|
|
131
|
+
refresh: {
|
|
132
|
+
src: "refresh";
|
|
133
|
+
logic: import("xstate").PromiseActorLogic<import("./types").RefreshSuccessEvent, import("./actors").RefreshInput>;
|
|
134
|
+
id: string | undefined;
|
|
135
|
+
};
|
|
136
|
+
}>, import("xstate").Values<{
|
|
137
|
+
addItems: {
|
|
138
|
+
type: "addItems";
|
|
139
|
+
params: import("xstate").NonReducibleUnknown;
|
|
140
|
+
};
|
|
141
|
+
removeItems: {
|
|
142
|
+
type: "removeItems";
|
|
143
|
+
params: import("xstate").NonReducibleUnknown;
|
|
144
|
+
};
|
|
145
|
+
refresh: {
|
|
146
|
+
type: "refresh";
|
|
147
|
+
params: import("xstate").NonReducibleUnknown;
|
|
148
|
+
};
|
|
149
|
+
}>, import("xstate").Values<{
|
|
150
|
+
canRefresh: {
|
|
151
|
+
type: "canRefresh";
|
|
152
|
+
params: unknown;
|
|
153
|
+
};
|
|
154
|
+
hasItems: {
|
|
155
|
+
type: "hasItems";
|
|
156
|
+
params: unknown;
|
|
157
|
+
};
|
|
158
|
+
}>, never, "active" | "refreshing" | "initializing" | "uninitialized" | "empty" | "addingItems" | "removingItems", string, {
|
|
159
|
+
initialContext: DeepPartial<QuoteMachineContext>;
|
|
160
|
+
initialState?: string | undefined;
|
|
161
|
+
}, import("xstate").NonReducibleUnknown, import("xstate").EventObject, import("xstate").MetaObject, import("xstate").ResolveTypegenMeta<import("xstate").TypegenDisabled, import("./types").SetEmptyEvent | import("./types").SetActiveEvent | import("./types").AddItemsEvent | import("./types").RemoveItemsEvent | import("./types").ClearItemsEvent | import("./types").RefreshEvent | import("./types").ApplyPromotionEvent | import("./types").RemovePromotionEvent | import("./types").AddAddressEvent | import("./types").RemoveAddressEvent | import("./types").ApplyPaymentMethodEvent | import("./types").AddRewardEvent | import("./types").RemoveRewardEvent | import("./types").AddStoreCreditEvent | import("./types").RemoveStoreCreditEvent | import("./types").AddGiftCardEvent | import("./types").RemoveGiftCardEvent | import("xstate").DoneActorEvent<import("./types").AddItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./types").RemoveItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./types").ClearItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./types").RefreshSuccessEvent>, import("xstate").Values<{
|
|
162
|
+
addItems: {
|
|
163
|
+
src: "addItems";
|
|
164
|
+
logic: import("xstate").PromiseActorLogic<import("./types").AddItemsSuccessEvent, import("./actors").AddItemsInput>;
|
|
165
|
+
id: string | undefined;
|
|
166
|
+
};
|
|
167
|
+
removeItems: {
|
|
168
|
+
src: "removeItems";
|
|
169
|
+
logic: import("xstate").PromiseActorLogic<import("./types").RemoveItemsSuccessEvent, import("./actors").RemoveItemsInput>;
|
|
170
|
+
id: string | undefined;
|
|
171
|
+
};
|
|
172
|
+
refresh: {
|
|
173
|
+
src: "refresh";
|
|
174
|
+
logic: import("xstate").PromiseActorLogic<import("./types").RefreshSuccessEvent, import("./actors").RefreshInput>;
|
|
175
|
+
id: string | undefined;
|
|
176
|
+
};
|
|
177
|
+
}>, import("xstate").Values<{
|
|
178
|
+
addItems: {
|
|
179
|
+
type: "addItems";
|
|
180
|
+
params: import("xstate").NonReducibleUnknown;
|
|
181
|
+
};
|
|
182
|
+
removeItems: {
|
|
183
|
+
type: "removeItems";
|
|
184
|
+
params: import("xstate").NonReducibleUnknown;
|
|
185
|
+
};
|
|
186
|
+
refresh: {
|
|
187
|
+
type: "refresh";
|
|
188
|
+
params: import("xstate").NonReducibleUnknown;
|
|
189
|
+
};
|
|
190
|
+
}>, import("xstate").Values<{
|
|
191
|
+
canRefresh: {
|
|
192
|
+
type: "canRefresh";
|
|
193
|
+
params: unknown;
|
|
194
|
+
};
|
|
195
|
+
hasItems: {
|
|
196
|
+
type: "hasItems";
|
|
197
|
+
params: unknown;
|
|
198
|
+
};
|
|
199
|
+
}>, never, string, import("xstate").EventObject>>>>;
|
|
200
|
+
type Props = {
|
|
201
|
+
children: ReactNode;
|
|
202
|
+
actor: Actor<typeof quoteMachine>;
|
|
203
|
+
};
|
|
204
|
+
export declare function QuoteProvider({ actor, children }: Props): import("react/jsx-runtime").JSX.Element;
|
|
205
|
+
export {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { QuoteMachineContext, QuoteMachineEvents } from '../types';
|
|
2
|
+
export declare function addItems({ context, event, }: {
|
|
3
|
+
context: QuoteMachineContext;
|
|
4
|
+
event: QuoteMachineEvents;
|
|
5
|
+
}): QuoteMachineContext | {
|
|
6
|
+
quote?: {
|
|
7
|
+
id: string | null;
|
|
8
|
+
locale: string | null;
|
|
9
|
+
baseCurrency: string | null;
|
|
10
|
+
currency: string | null;
|
|
11
|
+
currencyConversionRate: number | null;
|
|
12
|
+
dateCreated: Date | null;
|
|
13
|
+
dateLastUpdated: Date | null;
|
|
14
|
+
items: Record<string, any>[] | null;
|
|
15
|
+
promotions: Record<string, any>[] | null;
|
|
16
|
+
shippingAddresses: {
|
|
17
|
+
available: Record<string, any>[];
|
|
18
|
+
selected: string | null;
|
|
19
|
+
} | null;
|
|
20
|
+
totals: {
|
|
21
|
+
discount: number;
|
|
22
|
+
tax: number;
|
|
23
|
+
shipping: number;
|
|
24
|
+
shippingTax: number;
|
|
25
|
+
subtotal: number;
|
|
26
|
+
grandTotal: number;
|
|
27
|
+
} | null;
|
|
28
|
+
appliedPriceRules: Record<string, any>[] | null;
|
|
29
|
+
appliedPromotions: Record<string, any>[] | null;
|
|
30
|
+
shippingMethods: Record<string, any>[] | null;
|
|
31
|
+
paymentMethods: Record<string, any>[] | null;
|
|
32
|
+
storeCredit: Record<string, any>[] | null;
|
|
33
|
+
rewards: Record<string, any>[] | null;
|
|
34
|
+
giftCards: Record<string, any>[] | null;
|
|
35
|
+
} | undefined;
|
|
36
|
+
endpoints?: {
|
|
37
|
+
client?: string | undefined;
|
|
38
|
+
server?: string | undefined;
|
|
39
|
+
} | undefined;
|
|
40
|
+
graphql?: {
|
|
41
|
+
refresh: {
|
|
42
|
+
document: import("graphql-request").RequestDocument | import("@graphql-typed-document-node/core").TypedDocumentNode<unknown, {}>;
|
|
43
|
+
requestHeaders?: import("graphql-request/build/esm/types").GraphQLClientRequestHeaders | undefined;
|
|
44
|
+
};
|
|
45
|
+
addItems: {
|
|
46
|
+
document: import("graphql-request").RequestDocument | import("@graphql-typed-document-node/core").TypedDocumentNode<unknown, {}>;
|
|
47
|
+
requestHeaders?: import("graphql-request/build/esm/types").GraphQLClientRequestHeaders | undefined;
|
|
48
|
+
};
|
|
49
|
+
} | undefined;
|
|
50
|
+
errors?: string[] | undefined;
|
|
51
|
+
id: string | null;
|
|
52
|
+
locale: string | null;
|
|
53
|
+
baseCurrency: string | null;
|
|
54
|
+
currency: string | null;
|
|
55
|
+
currencyConversionRate: number | null;
|
|
56
|
+
dateCreated: Date | null;
|
|
57
|
+
dateLastUpdated: Date | null;
|
|
58
|
+
items: Record<string, any>[] | null;
|
|
59
|
+
promotions: Record<string, any>[] | null;
|
|
60
|
+
shippingAddresses: {
|
|
61
|
+
available: Record<string, any>[];
|
|
62
|
+
selected: string | null;
|
|
63
|
+
} | null;
|
|
64
|
+
totals: {
|
|
65
|
+
discount: number;
|
|
66
|
+
tax: number;
|
|
67
|
+
shipping: number;
|
|
68
|
+
shippingTax: number;
|
|
69
|
+
subtotal: number;
|
|
70
|
+
grandTotal: number;
|
|
71
|
+
} | null;
|
|
72
|
+
appliedPriceRules: Record<string, any>[] | null;
|
|
73
|
+
appliedPromotions: Record<string, any>[] | null;
|
|
74
|
+
shippingMethods: Record<string, any>[] | null;
|
|
75
|
+
paymentMethods: Record<string, any>[] | null;
|
|
76
|
+
storeCredit: Record<string, any>[] | null;
|
|
77
|
+
rewards: Record<string, any>[] | null;
|
|
78
|
+
giftCards: Record<string, any>[] | null;
|
|
79
|
+
};
|
|
80
|
+
export default addItems;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { QuoteMachineContext, QuoteMachineEvents } from '../types';
|
|
2
|
+
export declare function refresh({ context, event, }: {
|
|
3
|
+
context: QuoteMachineContext;
|
|
4
|
+
event: QuoteMachineEvents;
|
|
5
|
+
}): QuoteMachineContext | {
|
|
6
|
+
quote: {
|
|
7
|
+
quote?: {
|
|
8
|
+
id: string | null;
|
|
9
|
+
locale: string | null;
|
|
10
|
+
baseCurrency: string | null;
|
|
11
|
+
currency: string | null;
|
|
12
|
+
currencyConversionRate: number | null;
|
|
13
|
+
dateCreated: Date | null;
|
|
14
|
+
dateLastUpdated: Date | null;
|
|
15
|
+
items: Record<string, any>[] | null;
|
|
16
|
+
promotions: Record<string, any>[] | null;
|
|
17
|
+
shippingAddresses: {
|
|
18
|
+
available: Record<string, any>[];
|
|
19
|
+
selected: string | null;
|
|
20
|
+
} | null;
|
|
21
|
+
totals: {
|
|
22
|
+
discount: number;
|
|
23
|
+
tax: number;
|
|
24
|
+
shipping: number;
|
|
25
|
+
shippingTax: number;
|
|
26
|
+
subtotal: number;
|
|
27
|
+
grandTotal: number;
|
|
28
|
+
} | null;
|
|
29
|
+
appliedPriceRules: Record<string, any>[] | null;
|
|
30
|
+
appliedPromotions: Record<string, any>[] | null;
|
|
31
|
+
shippingMethods: Record<string, any>[] | null;
|
|
32
|
+
paymentMethods: Record<string, any>[] | null;
|
|
33
|
+
storeCredit: Record<string, any>[] | null;
|
|
34
|
+
rewards: Record<string, any>[] | null;
|
|
35
|
+
giftCards: Record<string, any>[] | null;
|
|
36
|
+
} | undefined;
|
|
37
|
+
endpoints?: {
|
|
38
|
+
client?: string | undefined;
|
|
39
|
+
server?: string | undefined;
|
|
40
|
+
} | undefined;
|
|
41
|
+
graphql?: {
|
|
42
|
+
refresh: {
|
|
43
|
+
document: import("graphql-request").RequestDocument | import("@graphql-typed-document-node/core").TypedDocumentNode<unknown, {}>;
|
|
44
|
+
requestHeaders?: import("graphql-request/build/esm/types").GraphQLClientRequestHeaders | undefined;
|
|
45
|
+
};
|
|
46
|
+
addItems: {
|
|
47
|
+
document: import("graphql-request").RequestDocument | import("@graphql-typed-document-node/core").TypedDocumentNode<unknown, {}>;
|
|
48
|
+
requestHeaders?: import("graphql-request/build/esm/types").GraphQLClientRequestHeaders | undefined;
|
|
49
|
+
};
|
|
50
|
+
} | undefined;
|
|
51
|
+
errors?: string[] | undefined;
|
|
52
|
+
id: string | null;
|
|
53
|
+
locale: string | null;
|
|
54
|
+
baseCurrency: string | null;
|
|
55
|
+
currency: string | null;
|
|
56
|
+
currencyConversionRate: number | null;
|
|
57
|
+
dateCreated: Date | null;
|
|
58
|
+
dateLastUpdated: Date | null;
|
|
59
|
+
items: Record<string, any>[] | null;
|
|
60
|
+
promotions: Record<string, any>[] | null;
|
|
61
|
+
shippingAddresses: {
|
|
62
|
+
available: Record<string, any>[];
|
|
63
|
+
selected: string | null;
|
|
64
|
+
} | null;
|
|
65
|
+
totals: {
|
|
66
|
+
discount: number;
|
|
67
|
+
tax: number;
|
|
68
|
+
shipping: number;
|
|
69
|
+
shippingTax: number;
|
|
70
|
+
subtotal: number;
|
|
71
|
+
grandTotal: number;
|
|
72
|
+
} | null;
|
|
73
|
+
appliedPriceRules: Record<string, any>[] | null;
|
|
74
|
+
appliedPromotions: Record<string, any>[] | null;
|
|
75
|
+
shippingMethods: Record<string, any>[] | null;
|
|
76
|
+
paymentMethods: Record<string, any>[] | null;
|
|
77
|
+
storeCredit: Record<string, any>[] | null;
|
|
78
|
+
rewards: Record<string, any>[] | null;
|
|
79
|
+
giftCards: Record<string, any>[] | null;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
export default refresh;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { QuoteMachineContext, QuoteMachineEvents } from '../types';
|
|
2
|
+
export declare function removeItems({ context, event, }: {
|
|
3
|
+
context: QuoteMachineContext;
|
|
4
|
+
event: QuoteMachineEvents;
|
|
5
|
+
}): QuoteMachineContext | {
|
|
6
|
+
quote?: {
|
|
7
|
+
id: string | null;
|
|
8
|
+
locale: string | null;
|
|
9
|
+
baseCurrency: string | null;
|
|
10
|
+
currency: string | null;
|
|
11
|
+
currencyConversionRate: number | null;
|
|
12
|
+
dateCreated: Date | null;
|
|
13
|
+
dateLastUpdated: Date | null;
|
|
14
|
+
items: Record<string, any>[] | null;
|
|
15
|
+
promotions: Record<string, any>[] | null;
|
|
16
|
+
shippingAddresses: {
|
|
17
|
+
available: Record<string, any>[];
|
|
18
|
+
selected: string | null;
|
|
19
|
+
} | null;
|
|
20
|
+
totals: {
|
|
21
|
+
discount: number;
|
|
22
|
+
tax: number;
|
|
23
|
+
shipping: number;
|
|
24
|
+
shippingTax: number;
|
|
25
|
+
subtotal: number;
|
|
26
|
+
grandTotal: number;
|
|
27
|
+
} | null;
|
|
28
|
+
appliedPriceRules: Record<string, any>[] | null;
|
|
29
|
+
appliedPromotions: Record<string, any>[] | null;
|
|
30
|
+
shippingMethods: Record<string, any>[] | null;
|
|
31
|
+
paymentMethods: Record<string, any>[] | null;
|
|
32
|
+
storeCredit: Record<string, any>[] | null;
|
|
33
|
+
rewards: Record<string, any>[] | null;
|
|
34
|
+
giftCards: Record<string, any>[] | null;
|
|
35
|
+
} | undefined;
|
|
36
|
+
endpoints?: {
|
|
37
|
+
client?: string | undefined;
|
|
38
|
+
server?: string | undefined;
|
|
39
|
+
} | undefined;
|
|
40
|
+
graphql?: {
|
|
41
|
+
refresh: {
|
|
42
|
+
document: import("graphql-request").RequestDocument | import("@graphql-typed-document-node/core").TypedDocumentNode<unknown, {}>;
|
|
43
|
+
requestHeaders?: import("graphql-request/build/esm/types").GraphQLClientRequestHeaders | undefined;
|
|
44
|
+
};
|
|
45
|
+
addItems: {
|
|
46
|
+
document: import("graphql-request").RequestDocument | import("@graphql-typed-document-node/core").TypedDocumentNode<unknown, {}>;
|
|
47
|
+
requestHeaders?: import("graphql-request/build/esm/types").GraphQLClientRequestHeaders | undefined;
|
|
48
|
+
};
|
|
49
|
+
} | undefined;
|
|
50
|
+
errors?: string[] | undefined;
|
|
51
|
+
id: string | null;
|
|
52
|
+
locale: string | null;
|
|
53
|
+
baseCurrency: string | null;
|
|
54
|
+
currency: string | null;
|
|
55
|
+
currencyConversionRate: number | null;
|
|
56
|
+
dateCreated: Date | null;
|
|
57
|
+
dateLastUpdated: Date | null;
|
|
58
|
+
items: Record<string, any>[] | null;
|
|
59
|
+
promotions: Record<string, any>[] | null;
|
|
60
|
+
shippingAddresses: {
|
|
61
|
+
available: Record<string, any>[];
|
|
62
|
+
selected: string | null;
|
|
63
|
+
} | null;
|
|
64
|
+
totals: {
|
|
65
|
+
discount: number;
|
|
66
|
+
tax: number;
|
|
67
|
+
shipping: number;
|
|
68
|
+
shippingTax: number;
|
|
69
|
+
subtotal: number;
|
|
70
|
+
grandTotal: number;
|
|
71
|
+
} | null;
|
|
72
|
+
appliedPriceRules: Record<string, any>[] | null;
|
|
73
|
+
appliedPromotions: Record<string, any>[] | null;
|
|
74
|
+
shippingMethods: Record<string, any>[] | null;
|
|
75
|
+
paymentMethods: Record<string, any>[] | null;
|
|
76
|
+
storeCredit: Record<string, any>[] | null;
|
|
77
|
+
rewards: Record<string, any>[] | null;
|
|
78
|
+
giftCards: Record<string, any>[] | null;
|
|
79
|
+
};
|
|
80
|
+
export default removeItems;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AddItemsEvent, AddItemsSuccessEvent, QuoteMachineContext } from '../types';
|
|
2
|
+
export type AddItemsInput = {
|
|
3
|
+
endpoint: QuoteMachineContext['endpoints']['client'];
|
|
4
|
+
items: AddItemsEvent['items'];
|
|
5
|
+
document: QuoteMachineContext['graphql']['addItems']['document'];
|
|
6
|
+
requestHeaders?: QuoteMachineContext['graphql']['addItems']['requestHeaders'];
|
|
7
|
+
};
|
|
8
|
+
export type AddItemsOutput = Partial<{
|
|
9
|
+
quoteAddItem: {
|
|
10
|
+
quote: object;
|
|
11
|
+
userErrors: Array<{
|
|
12
|
+
code: string;
|
|
13
|
+
field: string;
|
|
14
|
+
message: string;
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
17
|
+
}>;
|
|
18
|
+
export declare const addItems: import("xstate").PromiseActorLogic<AddItemsSuccessEvent, AddItemsInput>;
|
|
19
|
+
export default addItems;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RefreshSuccessEvent, QuoteMachineContext } from '../types';
|
|
2
|
+
export type RefreshInput = {
|
|
3
|
+
endpoint: QuoteMachineContext['endpoints']['client'];
|
|
4
|
+
endpointSsr: QuoteMachineContext['endpoints']['server'];
|
|
5
|
+
quoteId: QuoteMachineContext['quote']['id'];
|
|
6
|
+
locale: QuoteMachineContext['quote']['locale'];
|
|
7
|
+
document: QuoteMachineContext['graphql']['refresh']['document'];
|
|
8
|
+
requestHeaders?: QuoteMachineContext['graphql']['refresh']['requestHeaders'];
|
|
9
|
+
};
|
|
10
|
+
export type RefreshOutput = Partial<{
|
|
11
|
+
refreshQuote: {
|
|
12
|
+
quote: object;
|
|
13
|
+
userErrors: Array<{
|
|
14
|
+
code: string;
|
|
15
|
+
field: string;
|
|
16
|
+
message: string;
|
|
17
|
+
}>;
|
|
18
|
+
};
|
|
19
|
+
}>;
|
|
20
|
+
export declare const refresh: import("xstate").PromiseActorLogic<RefreshSuccessEvent, RefreshInput>;
|
|
21
|
+
export default refresh;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RemoveItemsEvent, RemoveItemsSuccessEvent, QuoteMachineContext } from '../types';
|
|
2
|
+
export type RemoveItemsInput = {
|
|
3
|
+
endpoint: QuoteMachineContext['endpoints']['client'];
|
|
4
|
+
items: RemoveItemsEvent['items'];
|
|
5
|
+
};
|
|
6
|
+
export type RemoveItemsOutput = Partial<{
|
|
7
|
+
quoteRemoveItem: {
|
|
8
|
+
quote: object;
|
|
9
|
+
userErrors: Array<{
|
|
10
|
+
code: string;
|
|
11
|
+
field: string;
|
|
12
|
+
message: string;
|
|
13
|
+
}>;
|
|
14
|
+
};
|
|
15
|
+
}>;
|
|
16
|
+
export declare const removeItems: import("xstate").PromiseActorLogic<RemoveItemsSuccessEvent, RemoveItemsInput>;
|
|
17
|
+
export default removeItems;
|
|
@@ -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 @@
|
|
|
1
|
+
export * from './hasItems';
|
package/quote/quote.d.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { DeepPartial, QuoteMachineContext } from './types';
|
|
2
|
+
export declare const quoteMachine: import("xstate").StateMachine<QuoteMachineContext, import("./types").SetEmptyEvent | import("./types").SetActiveEvent | import("./types").AddItemsEvent | import("./types").RemoveItemsEvent | import("./types").ClearItemsEvent | import("./types").RefreshEvent | import("./types").ApplyPromotionEvent | import("./types").RemovePromotionEvent | import("./types").AddAddressEvent | import("./types").RemoveAddressEvent | import("./types").ApplyPaymentMethodEvent | import("./types").AddRewardEvent | import("./types").RemoveRewardEvent | import("./types").AddStoreCreditEvent | import("./types").RemoveStoreCreditEvent | import("./types").AddGiftCardEvent | import("./types").RemoveGiftCardEvent | import("xstate").DoneActorEvent<import("./types").AddItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./types").RemoveItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./types").ClearItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./types").RefreshSuccessEvent>, {
|
|
3
|
+
[x: string]: import("xstate").ActorRef<import("xstate").PromiseSnapshot<import("./types").AddItemsSuccessEvent, import("./actors").AddItemsInput>, {
|
|
4
|
+
[k: string]: unknown;
|
|
5
|
+
type: string;
|
|
6
|
+
}, import("xstate").EventObject> | import("xstate").ActorRef<import("xstate").PromiseSnapshot<import("./types").RemoveItemsSuccessEvent, import("./actors").RemoveItemsInput>, {
|
|
7
|
+
[k: string]: unknown;
|
|
8
|
+
type: string;
|
|
9
|
+
}, import("xstate").EventObject> | import("xstate").ActorRef<import("xstate").PromiseSnapshot<import("./types").RefreshSuccessEvent, import("./actors").RefreshInput>, {
|
|
10
|
+
[k: string]: unknown;
|
|
11
|
+
type: string;
|
|
12
|
+
}, import("xstate").EventObject> | undefined;
|
|
13
|
+
}, import("xstate").Values<{
|
|
14
|
+
addItems: {
|
|
15
|
+
src: "addItems";
|
|
16
|
+
logic: import("xstate").PromiseActorLogic<import("./types").AddItemsSuccessEvent, import("./actors").AddItemsInput>;
|
|
17
|
+
id: string | undefined;
|
|
18
|
+
};
|
|
19
|
+
removeItems: {
|
|
20
|
+
src: "removeItems";
|
|
21
|
+
logic: import("xstate").PromiseActorLogic<import("./types").RemoveItemsSuccessEvent, import("./actors").RemoveItemsInput>;
|
|
22
|
+
id: string | undefined;
|
|
23
|
+
};
|
|
24
|
+
refresh: {
|
|
25
|
+
src: "refresh";
|
|
26
|
+
logic: import("xstate").PromiseActorLogic<import("./types").RefreshSuccessEvent, import("./actors").RefreshInput>;
|
|
27
|
+
id: string | undefined;
|
|
28
|
+
};
|
|
29
|
+
}>, import("xstate").Values<{
|
|
30
|
+
addItems: {
|
|
31
|
+
type: "addItems";
|
|
32
|
+
params: import("xstate").NonReducibleUnknown;
|
|
33
|
+
};
|
|
34
|
+
removeItems: {
|
|
35
|
+
type: "removeItems";
|
|
36
|
+
params: import("xstate").NonReducibleUnknown;
|
|
37
|
+
};
|
|
38
|
+
refresh: {
|
|
39
|
+
type: "refresh";
|
|
40
|
+
params: import("xstate").NonReducibleUnknown;
|
|
41
|
+
};
|
|
42
|
+
}>, import("xstate").Values<{
|
|
43
|
+
canRefresh: {
|
|
44
|
+
type: "canRefresh";
|
|
45
|
+
params: unknown;
|
|
46
|
+
};
|
|
47
|
+
hasItems: {
|
|
48
|
+
type: "hasItems";
|
|
49
|
+
params: unknown;
|
|
50
|
+
};
|
|
51
|
+
}>, never, "active" | "refreshing" | "initializing" | "uninitialized" | "empty" | "addingItems" | "removingItems", string, {
|
|
52
|
+
initialContext: DeepPartial<QuoteMachineContext>;
|
|
53
|
+
initialState?: string | undefined;
|
|
54
|
+
}, import("xstate").NonReducibleUnknown, import("xstate").EventObject, import("xstate").MetaObject, import("xstate").ResolveTypegenMeta<import("xstate").TypegenDisabled, import("./types").SetEmptyEvent | import("./types").SetActiveEvent | import("./types").AddItemsEvent | import("./types").RemoveItemsEvent | import("./types").ClearItemsEvent | import("./types").RefreshEvent | import("./types").ApplyPromotionEvent | import("./types").RemovePromotionEvent | import("./types").AddAddressEvent | import("./types").RemoveAddressEvent | import("./types").ApplyPaymentMethodEvent | import("./types").AddRewardEvent | import("./types").RemoveRewardEvent | import("./types").AddStoreCreditEvent | import("./types").RemoveStoreCreditEvent | import("./types").AddGiftCardEvent | import("./types").RemoveGiftCardEvent | import("xstate").DoneActorEvent<import("./types").AddItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./types").RemoveItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./types").ClearItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./types").RefreshSuccessEvent>, import("xstate").Values<{
|
|
55
|
+
addItems: {
|
|
56
|
+
src: "addItems";
|
|
57
|
+
logic: import("xstate").PromiseActorLogic<import("./types").AddItemsSuccessEvent, import("./actors").AddItemsInput>;
|
|
58
|
+
id: string | undefined;
|
|
59
|
+
};
|
|
60
|
+
removeItems: {
|
|
61
|
+
src: "removeItems";
|
|
62
|
+
logic: import("xstate").PromiseActorLogic<import("./types").RemoveItemsSuccessEvent, import("./actors").RemoveItemsInput>;
|
|
63
|
+
id: string | undefined;
|
|
64
|
+
};
|
|
65
|
+
refresh: {
|
|
66
|
+
src: "refresh";
|
|
67
|
+
logic: import("xstate").PromiseActorLogic<import("./types").RefreshSuccessEvent, import("./actors").RefreshInput>;
|
|
68
|
+
id: string | undefined;
|
|
69
|
+
};
|
|
70
|
+
}>, import("xstate").Values<{
|
|
71
|
+
addItems: {
|
|
72
|
+
type: "addItems";
|
|
73
|
+
params: import("xstate").NonReducibleUnknown;
|
|
74
|
+
};
|
|
75
|
+
removeItems: {
|
|
76
|
+
type: "removeItems";
|
|
77
|
+
params: import("xstate").NonReducibleUnknown;
|
|
78
|
+
};
|
|
79
|
+
refresh: {
|
|
80
|
+
type: "refresh";
|
|
81
|
+
params: import("xstate").NonReducibleUnknown;
|
|
82
|
+
};
|
|
83
|
+
}>, import("xstate").Values<{
|
|
84
|
+
canRefresh: {
|
|
85
|
+
type: "canRefresh";
|
|
86
|
+
params: unknown;
|
|
87
|
+
};
|
|
88
|
+
hasItems: {
|
|
89
|
+
type: "hasItems";
|
|
90
|
+
params: unknown;
|
|
91
|
+
};
|
|
92
|
+
}>, never, string, import("xstate").EventObject>>;
|
|
93
|
+
export default quoteMachine;
|