@clicktap/state 0.14.7 → 0.14.8

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.
@@ -13,7 +13,12 @@ export interface CheckoutMachineContext {
13
13
  client?: string;
14
14
  server?: string;
15
15
  };
16
+ successId: string;
16
17
  graphql: {
18
+ placeOrder: {
19
+ document: RequestDocument | TypedDocumentNode<unknown, {}>;
20
+ requestHeaders?: GraphQLClientRequestHeaders;
21
+ };
17
22
  submitStepData: {
18
23
  document: RequestDocument | TypedDocumentNode<unknown, {}>;
19
24
  requestHeaders?: GraphQLClientRequestHeaders;
@@ -24,6 +29,17 @@ export interface ChangeStepEvent {
24
29
  type: 'CHANGE_STEP';
25
30
  step: string;
26
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
+ }
27
43
  export interface SubmitStepDataEvent {
28
44
  type: 'SUBMIT_STEP_DATA';
29
45
  data: Record<string, any>;
@@ -32,4 +48,8 @@ export interface SubmitStepDataSuccessEvent {
32
48
  type: 'SUBMIT_STEP_DATA_SUCCESS';
33
49
  quote: Partial<QuoteMachineContext>;
34
50
  }
35
- export type CheckoutMachineEvents = ChangeStepEvent | SubmitStepDataEvent | DoneActorEvent<SubmitStepDataSuccessEvent>;
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>;
@@ -1,15 +1,25 @@
1
1
  import { CheckoutMachineContext } from './checkout/types';
2
2
  import { DeepPartial } from './types';
3
- export declare const checkoutMachine: import("xstate").StateMachine<CheckoutMachineContext, import("./checkout/types").ChangeStepEvent | import("./checkout/types").SubmitStepDataEvent | import("xstate").DoneActorEvent<import("./checkout/types").SubmitStepDataSuccessEvent>, {
4
- [x: string]: import("xstate").ActorRef<import("xstate").PromiseSnapshot<import("./checkout/types").SubmitStepDataSuccessEvent, import("./checkout/actors").SubmitStepDataInput>, {
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> | import("xstate").DoneActorEvent<import("./checkout/types").SubmitStepDataSuccessEvent>, {
4
+ [x: string]: import("xstate").ActorRef<import("xstate").PromiseSnapshot<import("./checkout/types").PlaceOrderSuccessEvent, import("./checkout/actors").PlaceOrderDataInput>, {
5
+ [k: string]: unknown;
6
+ type: string;
7
+ }, import("xstate").EventObject> | import("xstate").ActorRef<import("xstate").PromiseSnapshot<import("./checkout/types").SubmitStepDataSuccessEvent, import("./checkout/actors").SubmitStepDataInput>, {
5
8
  [k: string]: unknown;
6
9
  type: string;
7
10
  }, import("xstate").EventObject> | undefined;
8
- }, {
9
- src: "submitStepData";
10
- logic: import("xstate").PromiseActorLogic<import("./checkout/types").SubmitStepDataSuccessEvent, import("./checkout/actors").SubmitStepDataInput>;
11
- id: string | undefined;
12
11
  }, import("xstate").Values<{
12
+ placeOrder: {
13
+ src: "placeOrder";
14
+ logic: import("xstate").PromiseActorLogic<import("./checkout/types").PlaceOrderSuccessEvent, import("./checkout/actors").PlaceOrderDataInput>;
15
+ id: string | undefined;
16
+ };
17
+ submitStepData: {
18
+ src: "submitStepData";
19
+ logic: import("xstate").PromiseActorLogic<import("./checkout/types").SubmitStepDataSuccessEvent, import("./checkout/actors").SubmitStepDataInput>;
20
+ id: string | undefined;
21
+ };
22
+ }>, import("xstate").Values<{
13
23
  changeStep: {
14
24
  type: "changeStep";
15
25
  params: import("xstate").NonReducibleUnknown;
@@ -18,21 +28,36 @@ export declare const checkoutMachine: import("xstate").StateMachine<CheckoutMach
18
28
  type: "nextStep";
19
29
  params: import("xstate").NonReducibleUnknown;
20
30
  };
31
+ resetCheckout: {
32
+ type: "resetCheckout";
33
+ params: import("xstate").NonReducibleUnknown;
34
+ };
21
35
  updateQuote: {
22
36
  type: "updateQuote";
23
37
  params: import("xstate").NonReducibleUnknown;
24
38
  };
39
+ updateSuccessId: {
40
+ type: "updateSuccessId";
41
+ params: import("xstate").NonReducibleUnknown;
42
+ };
25
43
  }>, {
26
44
  type: "quoteExists";
27
45
  params: unknown;
28
- }, never, "uninitialized" | "initializing" | "showStep" | "submittingStepData" | "changingStep", string, {
46
+ }, never, "uninitialized" | "initializing" | "showStep" | "submittingStepData" | "changingStep" | "placingOrder" | "success", string, {
29
47
  initialContext: DeepPartial<CheckoutMachineContext>;
30
48
  initialState?: string | undefined;
31
- }, import("xstate").NonReducibleUnknown, import("xstate").EventObject, import("xstate").MetaObject, import("xstate").ResolveTypegenMeta<import("xstate").TypegenDisabled, import("./checkout/types").ChangeStepEvent | import("./checkout/types").SubmitStepDataEvent | import("xstate").DoneActorEvent<import("./checkout/types").SubmitStepDataSuccessEvent>, {
32
- src: "submitStepData";
33
- logic: import("xstate").PromiseActorLogic<import("./checkout/types").SubmitStepDataSuccessEvent, import("./checkout/actors").SubmitStepDataInput>;
34
- id: string | undefined;
35
- }, import("xstate").Values<{
49
+ }, import("xstate").NonReducibleUnknown, import("xstate").EventObject, import("xstate").MetaObject, import("xstate").ResolveTypegenMeta<import("xstate").TypegenDisabled, import("./checkout/types").ChangeStepEvent | import("./checkout/types").PlaceOrderEvent | import("./checkout/types").ResetCheckoutEvent | import("./checkout/types").SubmitStepDataEvent | import("xstate").DoneActorEvent<import("./checkout/types").PlaceOrderSuccessEvent> | import("xstate").DoneActorEvent<import("./checkout/types").SubmitStepDataSuccessEvent>, import("xstate").Values<{
50
+ placeOrder: {
51
+ src: "placeOrder";
52
+ logic: import("xstate").PromiseActorLogic<import("./checkout/types").PlaceOrderSuccessEvent, import("./checkout/actors").PlaceOrderDataInput>;
53
+ id: string | undefined;
54
+ };
55
+ submitStepData: {
56
+ src: "submitStepData";
57
+ logic: import("xstate").PromiseActorLogic<import("./checkout/types").SubmitStepDataSuccessEvent, import("./checkout/actors").SubmitStepDataInput>;
58
+ id: string | undefined;
59
+ };
60
+ }>, import("xstate").Values<{
36
61
  changeStep: {
37
62
  type: "changeStep";
38
63
  params: import("xstate").NonReducibleUnknown;
@@ -41,10 +66,18 @@ export declare const checkoutMachine: import("xstate").StateMachine<CheckoutMach
41
66
  type: "nextStep";
42
67
  params: import("xstate").NonReducibleUnknown;
43
68
  };
69
+ resetCheckout: {
70
+ type: "resetCheckout";
71
+ params: import("xstate").NonReducibleUnknown;
72
+ };
44
73
  updateQuote: {
45
74
  type: "updateQuote";
46
75
  params: import("xstate").NonReducibleUnknown;
47
76
  };
77
+ updateSuccessId: {
78
+ type: "updateSuccessId";
79
+ params: import("xstate").NonReducibleUnknown;
80
+ };
48
81
  }>, {
49
82
  type: "quoteExists";
50
83
  params: unknown;
@@ -72,7 +72,7 @@ export declare function addItems({ context, event, }: {
72
72
  latestShipDate: Date;
73
73
  earliestArrivalDate: Date;
74
74
  latestArrivalDate: Date;
75
- }[];
75
+ };
76
76
  };
77
77
  }[];
78
78
  totals: {
@@ -186,7 +186,7 @@ export declare function addItems({ context, event, }: {
186
186
  latestShipDate: Date;
187
187
  earliestArrivalDate: Date;
188
188
  latestArrivalDate: Date;
189
- }[];
189
+ };
190
190
  };
191
191
  }[] | undefined;
192
192
  totals?: {
@@ -4,4 +4,5 @@ export * from './notifyRemoveItems';
4
4
  export * from './notifyUpdateItems';
5
5
  export * from './removeItems';
6
6
  export * from './refresh';
7
+ export * from './reset';
7
8
  export * from './updateItems';
@@ -72,7 +72,7 @@ export declare function refresh({ context, event, }: {
72
72
  latestShipDate: Date;
73
73
  earliestArrivalDate: Date;
74
74
  latestArrivalDate: Date;
75
- }[];
75
+ };
76
76
  };
77
77
  }[];
78
78
  totals: {
@@ -186,7 +186,7 @@ export declare function refresh({ context, event, }: {
186
186
  latestShipDate: Date;
187
187
  earliestArrivalDate: Date;
188
188
  latestArrivalDate: Date;
189
- }[];
189
+ };
190
190
  };
191
191
  }[] | undefined;
192
192
  totals?: {
@@ -72,7 +72,7 @@ export declare function removeItems({ context, event, }: {
72
72
  latestShipDate: Date;
73
73
  earliestArrivalDate: Date;
74
74
  latestArrivalDate: Date;
75
- }[];
75
+ };
76
76
  };
77
77
  }[];
78
78
  totals: {
@@ -186,7 +186,7 @@ export declare function removeItems({ context, event, }: {
186
186
  latestShipDate: Date;
187
187
  earliestArrivalDate: Date;
188
188
  latestArrivalDate: Date;
189
- }[];
189
+ };
190
190
  };
191
191
  }[] | undefined;
192
192
  totals?: {
@@ -0,0 +1,40 @@
1
+ import { QuoteMachineContext, QuoteMachineEvents } from '../types';
2
+ export declare function reset({ context, event, }: {
3
+ context: QuoteMachineContext;
4
+ event: QuoteMachineEvents;
5
+ }): QuoteMachineContext | {
6
+ quote: {
7
+ id: string;
8
+ locale: string;
9
+ baseCurrency: string;
10
+ currencyConversionRate: number;
11
+ dateCreated: null;
12
+ dateLastUpdated: null;
13
+ currency: string;
14
+ items: never[];
15
+ promotions: never[];
16
+ shippingAddresses: {
17
+ available: never[];
18
+ applied: never[];
19
+ };
20
+ paymentMethods: {
21
+ available: never[];
22
+ applied: never[];
23
+ };
24
+ totals: {
25
+ discount: number;
26
+ taxAmount: number;
27
+ shippingAmount: number;
28
+ shippingTaxAmount: number;
29
+ subtotal: number;
30
+ grandTotal: number;
31
+ };
32
+ appliedPriceRules: never[];
33
+ appliedPromotions: never[];
34
+ shippingMethods: never[];
35
+ storeCredit: never[];
36
+ rewards: never[];
37
+ giftCards: never[];
38
+ };
39
+ };
40
+ export default reset;
@@ -72,7 +72,7 @@ export declare function updateItems({ context, event, }: {
72
72
  latestShipDate: Date;
73
73
  earliestArrivalDate: Date;
74
74
  latestArrivalDate: Date;
75
- }[];
75
+ };
76
76
  };
77
77
  }[];
78
78
  totals: {
@@ -186,7 +186,7 @@ export declare function updateItems({ context, event, }: {
186
186
  latestShipDate: Date;
187
187
  earliestArrivalDate: Date;
188
188
  latestArrivalDate: Date;
189
- }[];
189
+ };
190
190
  };
191
191
  }[] | undefined;
192
192
  totals?: {
@@ -28,6 +28,7 @@ export type PaymentMethod = {
28
28
  };
29
29
  export type CheckoutStep = {
30
30
  code: string;
31
+ name: string;
31
32
  isAvailable: boolean;
32
33
  isComplete: boolean;
33
34
  prev?: string;
@@ -86,7 +87,7 @@ export interface QuoteMachineContext {
86
87
  earliestArrivalDate: Date;
87
88
  latestArrivalDate: Date;
88
89
  }>;
89
- applied: Array<{
90
+ applied: {
90
91
  shippingMethod: {
91
92
  id: string;
92
93
  code: string;
@@ -102,7 +103,7 @@ export interface QuoteMachineContext {
102
103
  latestShipDate: Date;
103
104
  earliestArrivalDate: Date;
104
105
  latestArrivalDate: Date;
105
- }>;
106
+ };
106
107
  };
107
108
  }>;
108
109
  totals: {
@@ -189,6 +190,12 @@ export interface ClearItemsEvent {
189
190
  export interface RefreshEvent {
190
191
  type: 'REFRESH';
191
192
  }
193
+ export interface ResetEvent {
194
+ type: 'RESET';
195
+ data: {
196
+ locale: string;
197
+ };
198
+ }
192
199
  export interface ApplyPromotionEvent {
193
200
  type: 'APPLY_PROMOTION';
194
201
  }
@@ -244,7 +251,7 @@ export interface RefreshSuccessEvent {
244
251
  type: 'REFRESH_SUCCESS';
245
252
  quote: Partial<QuoteMachineContext>;
246
253
  }
247
- export type QuoteMachineEvents = SetQuoteEmptyEvent | SetQuoteActiveEvent | 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>;
254
+ export type QuoteMachineEvents = SetQuoteEmptyEvent | SetQuoteActiveEvent | AddItemsEvent | RemoveItemsEvent | UpdateItemsEvent | ClearItemsEvent | RefreshEvent | ResetEvent | ApplyPromotionEvent | RemovePromotionEvent | AddAddressEvent | RemoveAddressEvent | ApplyPaymentMethodEvent | AddRewardEvent | RemoveRewardEvent | AddStoreCreditEvent | RemoveStoreCreditEvent | AddGiftCardEvent | RemoveGiftCardEvent | DoneActorEvent<AddItemsSuccessEvent> | DoneActorEvent<RemoveItemsSuccessEvent> | DoneActorEvent<UpdateItemsSuccessEvent> | DoneActorEvent<ClearItemsSuccessEvent> | DoneActorEvent<RefreshSuccessEvent>;
248
255
  export interface AddItemsEmittedEvent {
249
256
  type: 'EMIT_ADD_ITEMS';
250
257
  itemsAdded: QuoteMachineContext['quote']['items'];
package/quote/quote.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { DeepPartial } from './types';
2
2
  import { QuoteMachineContext } from './quote/types';
3
- export declare const quoteMachine: import("xstate").StateMachine<QuoteMachineContext, import("./quote/types").SetQuoteEmptyEvent | import("./quote/types").SetQuoteActiveEvent | import("./quote/types").AddItemsEvent | import("./quote/types").RemoveItemsEvent | import("./quote/types").UpdateItemsEvent | import("./quote/types").ClearItemsEvent | import("./quote/types").RefreshEvent | import("./quote/types").ApplyPromotionEvent | import("./quote/types").RemovePromotionEvent | import("./quote/types").AddAddressEvent | import("./quote/types").RemoveAddressEvent | import("./quote/types").ApplyPaymentMethodEvent | import("./quote/types").AddRewardEvent | import("./quote/types").RemoveRewardEvent | import("./quote/types").AddStoreCreditEvent | import("./quote/types").RemoveStoreCreditEvent | import("./quote/types").AddGiftCardEvent | import("./quote/types").RemoveGiftCardEvent | import("xstate").DoneActorEvent<import("./quote/types").AddItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./quote/types").RemoveItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./quote/types").UpdateItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./quote/types").ClearItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./quote/types").RefreshSuccessEvent>, {
3
+ export declare const quoteMachine: import("xstate").StateMachine<QuoteMachineContext, import("./quote/types").SetQuoteEmptyEvent | import("./quote/types").SetQuoteActiveEvent | import("./quote/types").AddItemsEvent | import("./quote/types").RemoveItemsEvent | import("./quote/types").UpdateItemsEvent | import("./quote/types").ClearItemsEvent | import("./quote/types").RefreshEvent | import("./quote/types").ResetEvent | import("./quote/types").ApplyPromotionEvent | import("./quote/types").RemovePromotionEvent | import("./quote/types").AddAddressEvent | import("./quote/types").RemoveAddressEvent | import("./quote/types").ApplyPaymentMethodEvent | import("./quote/types").AddRewardEvent | import("./quote/types").RemoveRewardEvent | import("./quote/types").AddStoreCreditEvent | import("./quote/types").RemoveStoreCreditEvent | import("./quote/types").AddGiftCardEvent | import("./quote/types").RemoveGiftCardEvent | import("xstate").DoneActorEvent<import("./quote/types").AddItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./quote/types").RemoveItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./quote/types").UpdateItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./quote/types").ClearItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./quote/types").RefreshSuccessEvent>, {
4
4
  [x: string]: import("xstate").ActorRef<import("xstate").PromiseSnapshot<import("./quote/types").RefreshSuccessEvent, import("./quote/actors").RefreshInput>, {
5
5
  [k: string]: unknown;
6
6
  type: string;
@@ -60,6 +60,10 @@ export declare const quoteMachine: import("xstate").StateMachine<QuoteMachineCon
60
60
  type: "removeItems";
61
61
  params: import("xstate").NonReducibleUnknown;
62
62
  };
63
+ reset: {
64
+ type: "reset";
65
+ params: import("xstate").NonReducibleUnknown;
66
+ };
63
67
  updateItems: {
64
68
  type: "updateItems";
65
69
  params: import("xstate").NonReducibleUnknown;
@@ -73,10 +77,10 @@ export declare const quoteMachine: import("xstate").StateMachine<QuoteMachineCon
73
77
  type: "hasItems";
74
78
  params: unknown;
75
79
  };
76
- }>, never, "active" | "refreshing" | "uninitialized" | "initializing" | "empty" | "addingItems" | "updatingItems" | "removingItems" | "checkingItems", string, {
80
+ }>, never, "active" | "refreshing" | "uninitialized" | "initializing" | "empty" | "addingItems" | "updatingItems" | "removingItems" | "resetting" | "checkingItems", string, {
77
81
  initialContext: DeepPartial<QuoteMachineContext>;
78
82
  initialState?: string | undefined;
79
- }, import("xstate").NonReducibleUnknown, import("./quote/types").AddItemsEmittedEvent | import("./quote/types").RemoveItemsEmittedEvent | import("./quote/types").UpdateItemsEmittedEvent, import("xstate").MetaObject, import("xstate").ResolveTypegenMeta<import("xstate").TypegenDisabled, import("./quote/types").SetQuoteEmptyEvent | import("./quote/types").SetQuoteActiveEvent | import("./quote/types").AddItemsEvent | import("./quote/types").RemoveItemsEvent | import("./quote/types").UpdateItemsEvent | import("./quote/types").ClearItemsEvent | import("./quote/types").RefreshEvent | import("./quote/types").ApplyPromotionEvent | import("./quote/types").RemovePromotionEvent | import("./quote/types").AddAddressEvent | import("./quote/types").RemoveAddressEvent | import("./quote/types").ApplyPaymentMethodEvent | import("./quote/types").AddRewardEvent | import("./quote/types").RemoveRewardEvent | import("./quote/types").AddStoreCreditEvent | import("./quote/types").RemoveStoreCreditEvent | import("./quote/types").AddGiftCardEvent | import("./quote/types").RemoveGiftCardEvent | import("xstate").DoneActorEvent<import("./quote/types").AddItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./quote/types").RemoveItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./quote/types").UpdateItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./quote/types").ClearItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./quote/types").RefreshSuccessEvent>, import("xstate").Values<{
83
+ }, import("xstate").NonReducibleUnknown, import("./quote/types").AddItemsEmittedEvent | import("./quote/types").RemoveItemsEmittedEvent | import("./quote/types").UpdateItemsEmittedEvent, import("xstate").MetaObject, import("xstate").ResolveTypegenMeta<import("xstate").TypegenDisabled, import("./quote/types").SetQuoteEmptyEvent | import("./quote/types").SetQuoteActiveEvent | import("./quote/types").AddItemsEvent | import("./quote/types").RemoveItemsEvent | import("./quote/types").UpdateItemsEvent | import("./quote/types").ClearItemsEvent | import("./quote/types").RefreshEvent | import("./quote/types").ResetEvent | import("./quote/types").ApplyPromotionEvent | import("./quote/types").RemovePromotionEvent | import("./quote/types").AddAddressEvent | import("./quote/types").RemoveAddressEvent | import("./quote/types").ApplyPaymentMethodEvent | import("./quote/types").AddRewardEvent | import("./quote/types").RemoveRewardEvent | import("./quote/types").AddStoreCreditEvent | import("./quote/types").RemoveStoreCreditEvent | import("./quote/types").AddGiftCardEvent | import("./quote/types").RemoveGiftCardEvent | import("xstate").DoneActorEvent<import("./quote/types").AddItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./quote/types").RemoveItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./quote/types").UpdateItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./quote/types").ClearItemsSuccessEvent> | import("xstate").DoneActorEvent<import("./quote/types").RefreshSuccessEvent>, import("xstate").Values<{
80
84
  refresh: {
81
85
  src: "refresh";
82
86
  logic: import("xstate").PromiseActorLogic<import("./quote/types").RefreshSuccessEvent, import("./quote/actors").RefreshInput>;
@@ -122,6 +126,10 @@ export declare const quoteMachine: import("xstate").StateMachine<QuoteMachineCon
122
126
  type: "removeItems";
123
127
  params: import("xstate").NonReducibleUnknown;
124
128
  };
129
+ reset: {
130
+ type: "reset";
131
+ params: import("xstate").NonReducibleUnknown;
132
+ };
125
133
  updateItems: {
126
134
  type: "updateItems";
127
135
  params: import("xstate").NonReducibleUnknown;