@clicktap/state 0.13.15 → 0.13.17
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/index.js +23 -23
- package/index.mjs +953 -766
- package/package.json +1 -1
- package/quote/QuoteProvider.d.ts +147 -12
- package/quote/actions/addItems.d.ts +10 -1
- package/quote/actions/index.d.ts +4 -0
- package/quote/actions/notifyAddItems.d.ts +6 -0
- package/quote/actions/notifyRemoveItems.d.ts +6 -0
- package/quote/actions/notifyUpdateItems.d.ts +6 -0
- package/quote/actions/refresh.d.ts +9 -1
- package/quote/actions/removeItems.d.ts +10 -1
- package/quote/actions/updateItems.d.ts +91 -0
- package/quote/actors/addItems.d.ts +4 -0
- package/quote/actors/index.d.ts +1 -0
- package/quote/actors/removeItems.d.ts +4 -0
- package/quote/actors/updateItems.d.ts +23 -0
- package/quote/quote.d.ts +49 -4
- package/quote/types.d.ts +39 -2
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { UpdateItemsEvent, UpdateItemsSuccessEvent, QuoteMachineContext } from '../types';
|
|
2
|
+
export type UpdateItemsInput = {
|
|
3
|
+
endpoint: QuoteMachineContext['endpoints']['client'];
|
|
4
|
+
items: UpdateItemsEvent['items'];
|
|
5
|
+
document: QuoteMachineContext['graphql']['updateItems']['document'];
|
|
6
|
+
requestHeaders?: QuoteMachineContext['graphql']['updateItems']['requestHeaders'];
|
|
7
|
+
};
|
|
8
|
+
export type UpdateItemsOutput = Partial<{
|
|
9
|
+
quoteUpdateItem: {
|
|
10
|
+
quote: object;
|
|
11
|
+
itemsUpdated: Array<{
|
|
12
|
+
item: Array<Record<string, any>>;
|
|
13
|
+
previousQuantity: number;
|
|
14
|
+
}>;
|
|
15
|
+
userErrors: Array<{
|
|
16
|
+
code: string;
|
|
17
|
+
field: string;
|
|
18
|
+
message: string;
|
|
19
|
+
}>;
|
|
20
|
+
};
|
|
21
|
+
}>;
|
|
22
|
+
export declare const updateItems: import("xstate").PromiseActorLogic<UpdateItemsSuccessEvent, UpdateItemsInput>;
|
|
23
|
+
export default updateItems;
|
package/quote/quote.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
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>, {
|
|
2
|
+
export declare const quoteMachine: import("xstate").StateMachine<QuoteMachineContext, import("./types").SetEmptyEvent | import("./types").SetActiveEvent | import("./types").AddItemsEvent | import("./types").RemoveItemsEvent | import("./types").UpdateItemsEvent | 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").UpdateItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./types").ClearItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./types").RefreshSuccessEvent>, {
|
|
3
3
|
[x: string]: import("xstate").ActorRef<import("xstate").PromiseSnapshot<import("./types").AddItemsSuccessEvent, import("./actors").AddItemsInput>, {
|
|
4
4
|
[k: string]: unknown;
|
|
5
5
|
type: string;
|
|
@@ -9,6 +9,9 @@ export declare const quoteMachine: import("xstate").StateMachine<QuoteMachineCon
|
|
|
9
9
|
}, import("xstate").EventObject> | import("xstate").ActorRef<import("xstate").PromiseSnapshot<import("./types").RefreshSuccessEvent, import("./actors").RefreshInput>, {
|
|
10
10
|
[k: string]: unknown;
|
|
11
11
|
type: string;
|
|
12
|
+
}, import("xstate").EventObject> | import("xstate").ActorRef<import("xstate").PromiseSnapshot<import("./types").UpdateItemsSuccessEvent, import("./actors").UpdateItemsInput>, {
|
|
13
|
+
[k: string]: unknown;
|
|
14
|
+
type: string;
|
|
12
15
|
}, import("xstate").EventObject> | undefined;
|
|
13
16
|
}, import("xstate").Values<{
|
|
14
17
|
addItems: {
|
|
@@ -26,11 +29,28 @@ export declare const quoteMachine: import("xstate").StateMachine<QuoteMachineCon
|
|
|
26
29
|
logic: import("xstate").PromiseActorLogic<import("./types").RefreshSuccessEvent, import("./actors").RefreshInput>;
|
|
27
30
|
id: string | undefined;
|
|
28
31
|
};
|
|
32
|
+
updateItems: {
|
|
33
|
+
src: "updateItems";
|
|
34
|
+
logic: import("xstate").PromiseActorLogic<import("./types").UpdateItemsSuccessEvent, import("./actors").UpdateItemsInput>;
|
|
35
|
+
id: string | undefined;
|
|
36
|
+
};
|
|
29
37
|
}>, import("xstate").Values<{
|
|
30
38
|
addItems: {
|
|
31
39
|
type: "addItems";
|
|
32
40
|
params: import("xstate").NonReducibleUnknown;
|
|
33
41
|
};
|
|
42
|
+
notifyAddItems: {
|
|
43
|
+
type: "notifyAddItems";
|
|
44
|
+
params: import("xstate").NonReducibleUnknown;
|
|
45
|
+
};
|
|
46
|
+
notifyRemoveItems: {
|
|
47
|
+
type: "notifyRemoveItems";
|
|
48
|
+
params: import("xstate").NonReducibleUnknown;
|
|
49
|
+
};
|
|
50
|
+
notifyUpdateItems: {
|
|
51
|
+
type: "notifyUpdateItems";
|
|
52
|
+
params: import("xstate").NonReducibleUnknown;
|
|
53
|
+
};
|
|
34
54
|
removeItems: {
|
|
35
55
|
type: "removeItems";
|
|
36
56
|
params: import("xstate").NonReducibleUnknown;
|
|
@@ -39,6 +59,10 @@ export declare const quoteMachine: import("xstate").StateMachine<QuoteMachineCon
|
|
|
39
59
|
type: "refresh";
|
|
40
60
|
params: import("xstate").NonReducibleUnknown;
|
|
41
61
|
};
|
|
62
|
+
updateItems: {
|
|
63
|
+
type: "updateItems";
|
|
64
|
+
params: import("xstate").NonReducibleUnknown;
|
|
65
|
+
};
|
|
42
66
|
}>, import("xstate").Values<{
|
|
43
67
|
canRefresh: {
|
|
44
68
|
type: "canRefresh";
|
|
@@ -48,10 +72,10 @@ export declare const quoteMachine: import("xstate").StateMachine<QuoteMachineCon
|
|
|
48
72
|
type: "hasItems";
|
|
49
73
|
params: unknown;
|
|
50
74
|
};
|
|
51
|
-
}>, never, "active" | "refreshing" | "initializing" | "uninitialized" | "empty" | "addingItems" | "removingItems" | "checkingItems", string, {
|
|
75
|
+
}>, never, "active" | "refreshing" | "initializing" | "uninitialized" | "empty" | "addingItems" | "updatingItems" | "removingItems" | "checkingItems", string, {
|
|
52
76
|
initialContext: DeepPartial<QuoteMachineContext>;
|
|
53
77
|
initialState?: string | undefined;
|
|
54
|
-
}, import("xstate").NonReducibleUnknown, import("
|
|
78
|
+
}, import("xstate").NonReducibleUnknown, import("./types").AddItemsEmittedEvent | import("./types").RemoveItemsEmittedEvent | import("./types").UpdateItemsEmittedEvent, import("xstate").MetaObject, import("xstate").ResolveTypegenMeta<import("xstate").TypegenDisabled, import("./types").SetEmptyEvent | import("./types").SetActiveEvent | import("./types").AddItemsEvent | import("./types").RemoveItemsEvent | import("./types").UpdateItemsEvent | 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").UpdateItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./types").ClearItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./types").RefreshSuccessEvent>, import("xstate").Values<{
|
|
55
79
|
addItems: {
|
|
56
80
|
src: "addItems";
|
|
57
81
|
logic: import("xstate").PromiseActorLogic<import("./types").AddItemsSuccessEvent, import("./actors").AddItemsInput>;
|
|
@@ -67,11 +91,28 @@ export declare const quoteMachine: import("xstate").StateMachine<QuoteMachineCon
|
|
|
67
91
|
logic: import("xstate").PromiseActorLogic<import("./types").RefreshSuccessEvent, import("./actors").RefreshInput>;
|
|
68
92
|
id: string | undefined;
|
|
69
93
|
};
|
|
94
|
+
updateItems: {
|
|
95
|
+
src: "updateItems";
|
|
96
|
+
logic: import("xstate").PromiseActorLogic<import("./types").UpdateItemsSuccessEvent, import("./actors").UpdateItemsInput>;
|
|
97
|
+
id: string | undefined;
|
|
98
|
+
};
|
|
70
99
|
}>, import("xstate").Values<{
|
|
71
100
|
addItems: {
|
|
72
101
|
type: "addItems";
|
|
73
102
|
params: import("xstate").NonReducibleUnknown;
|
|
74
103
|
};
|
|
104
|
+
notifyAddItems: {
|
|
105
|
+
type: "notifyAddItems";
|
|
106
|
+
params: import("xstate").NonReducibleUnknown;
|
|
107
|
+
};
|
|
108
|
+
notifyRemoveItems: {
|
|
109
|
+
type: "notifyRemoveItems";
|
|
110
|
+
params: import("xstate").NonReducibleUnknown;
|
|
111
|
+
};
|
|
112
|
+
notifyUpdateItems: {
|
|
113
|
+
type: "notifyUpdateItems";
|
|
114
|
+
params: import("xstate").NonReducibleUnknown;
|
|
115
|
+
};
|
|
75
116
|
removeItems: {
|
|
76
117
|
type: "removeItems";
|
|
77
118
|
params: import("xstate").NonReducibleUnknown;
|
|
@@ -80,6 +121,10 @@ export declare const quoteMachine: import("xstate").StateMachine<QuoteMachineCon
|
|
|
80
121
|
type: "refresh";
|
|
81
122
|
params: import("xstate").NonReducibleUnknown;
|
|
82
123
|
};
|
|
124
|
+
updateItems: {
|
|
125
|
+
type: "updateItems";
|
|
126
|
+
params: import("xstate").NonReducibleUnknown;
|
|
127
|
+
};
|
|
83
128
|
}>, import("xstate").Values<{
|
|
84
129
|
canRefresh: {
|
|
85
130
|
type: "canRefresh";
|
|
@@ -89,5 +134,5 @@ export declare const quoteMachine: import("xstate").StateMachine<QuoteMachineCon
|
|
|
89
134
|
type: "hasItems";
|
|
90
135
|
params: unknown;
|
|
91
136
|
};
|
|
92
|
-
}>, never, string, import("
|
|
137
|
+
}>, never, string, import("./types").AddItemsEmittedEvent | import("./types").RemoveItemsEmittedEvent | import("./types").UpdateItemsEmittedEvent>>;
|
|
93
138
|
export default quoteMachine;
|
package/quote/types.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ export interface QuoteMachineContext {
|
|
|
38
38
|
rewards: Array<Record<string, any>> | null;
|
|
39
39
|
giftCards: Array<Record<string, any>> | null;
|
|
40
40
|
};
|
|
41
|
+
errors: Array<string>;
|
|
41
42
|
endpoints: {
|
|
42
43
|
client?: string;
|
|
43
44
|
server?: string;
|
|
@@ -51,8 +52,15 @@ export interface QuoteMachineContext {
|
|
|
51
52
|
document: RequestDocument | TypedDocumentNode<unknown, {}>;
|
|
52
53
|
requestHeaders?: GraphQLClientRequestHeaders | undefined;
|
|
53
54
|
};
|
|
55
|
+
removeItems: {
|
|
56
|
+
document: RequestDocument | TypedDocumentNode<unknown, {}>;
|
|
57
|
+
requestHeaders?: GraphQLClientRequestHeaders | undefined;
|
|
58
|
+
};
|
|
59
|
+
updateItems: {
|
|
60
|
+
document: RequestDocument | TypedDocumentNode<unknown, {}>;
|
|
61
|
+
requestHeaders?: GraphQLClientRequestHeaders | undefined;
|
|
62
|
+
};
|
|
54
63
|
};
|
|
55
|
-
errors: Array<string>;
|
|
56
64
|
}
|
|
57
65
|
export interface SetEmptyEvent {
|
|
58
66
|
type: 'SET_EMPTY';
|
|
@@ -78,6 +86,15 @@ export interface RemoveItemsEvent {
|
|
|
78
86
|
quantity: number;
|
|
79
87
|
}>;
|
|
80
88
|
}
|
|
89
|
+
export interface UpdateItemsEvent {
|
|
90
|
+
type: 'UPDATE_ITEMS';
|
|
91
|
+
items: Array<{
|
|
92
|
+
product: {
|
|
93
|
+
sku: string;
|
|
94
|
+
};
|
|
95
|
+
quantity: number;
|
|
96
|
+
}>;
|
|
97
|
+
}
|
|
81
98
|
export interface ClearItemsEvent {
|
|
82
99
|
type: 'CLEAR_ITEMS';
|
|
83
100
|
}
|
|
@@ -120,10 +137,17 @@ export interface RemoveGiftCardEvent {
|
|
|
120
137
|
export interface AddItemsSuccessEvent {
|
|
121
138
|
type: 'ADD_ITEMS_SUCCESS';
|
|
122
139
|
quote: Partial<QuoteMachineContext>;
|
|
140
|
+
itemsAdded: QuoteMachineContext['quote']['items'];
|
|
123
141
|
}
|
|
124
142
|
export interface RemoveItemsSuccessEvent {
|
|
125
143
|
type: 'REMOVE_ITEMS_SUCCESS';
|
|
126
144
|
quote: Partial<QuoteMachineContext>;
|
|
145
|
+
itemsRemoved: QuoteMachineContext['quote']['items'];
|
|
146
|
+
}
|
|
147
|
+
export interface UpdateItemsSuccessEvent {
|
|
148
|
+
type: 'UPDATE_ITEMS_SUCCESS';
|
|
149
|
+
quote: Partial<QuoteMachineContext>;
|
|
150
|
+
itemsUpdated: QuoteMachineContext['quote']['items'];
|
|
127
151
|
}
|
|
128
152
|
export interface ClearItemsSuccessEvent {
|
|
129
153
|
type: 'CLEAR_ITEMS_SUCCESS';
|
|
@@ -132,7 +156,20 @@ export interface RefreshSuccessEvent {
|
|
|
132
156
|
type: 'REFRESH_SUCCESS';
|
|
133
157
|
quote: Partial<QuoteMachineContext>;
|
|
134
158
|
}
|
|
135
|
-
export type QuoteMachineEvents = SetEmptyEvent | SetActiveEvent | AddItemsEvent | RemoveItemsEvent | ClearItemsEvent | RefreshEvent | ApplyPromotionEvent | RemovePromotionEvent | AddAddressEvent | RemoveAddressEvent | ApplyPaymentMethodEvent | AddRewardEvent | RemoveRewardEvent | AddStoreCreditEvent | RemoveStoreCreditEvent | AddGiftCardEvent | RemoveGiftCardEvent | DoneActorEvent<AddItemsSuccessEvent> | DoneActorEvent<RemoveItemsSuccessEvent> | DoneActorEvent<ClearItemsSuccessEvent> | DoneActorEvent<RefreshSuccessEvent>;
|
|
159
|
+
export type QuoteMachineEvents = SetEmptyEvent | SetActiveEvent | AddItemsEvent | RemoveItemsEvent | UpdateItemsEvent | ClearItemsEvent | RefreshEvent | ApplyPromotionEvent | RemovePromotionEvent | AddAddressEvent | RemoveAddressEvent | ApplyPaymentMethodEvent | AddRewardEvent | RemoveRewardEvent | AddStoreCreditEvent | RemoveStoreCreditEvent | AddGiftCardEvent | RemoveGiftCardEvent | DoneActorEvent<AddItemsSuccessEvent> | DoneActorEvent<RemoveItemsSuccessEvent> | DoneActorEvent<UpdateItemsSuccessEvent> | DoneActorEvent<ClearItemsSuccessEvent> | DoneActorEvent<RefreshSuccessEvent>;
|
|
160
|
+
export interface AddItemsEmittedEvent {
|
|
161
|
+
type: 'EMIT_ADD_ITEMS';
|
|
162
|
+
itemsAdded: QuoteMachineContext['quote']['items'];
|
|
163
|
+
}
|
|
164
|
+
export interface RemoveItemsEmittedEvent {
|
|
165
|
+
type: 'EMIT_REMOVE_ITEMS';
|
|
166
|
+
itemsRemoved: QuoteMachineContext['quote']['items'];
|
|
167
|
+
}
|
|
168
|
+
export interface UpdateItemsEmittedEvent {
|
|
169
|
+
type: 'EMIT_UPDATE_ITEMS';
|
|
170
|
+
itemsUpdated: QuoteMachineContext['quote']['items'];
|
|
171
|
+
}
|
|
172
|
+
export type QuoteMachineEmittedEvents = AddItemsEmittedEvent | RemoveItemsEmittedEvent | UpdateItemsEmittedEvent;
|
|
136
173
|
export type AddItemsResponse = {
|
|
137
174
|
message?: string;
|
|
138
175
|
success: boolean;
|