@clicktap/state 0.13.18 → 0.14.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.
Files changed (54) hide show
  1. package/auth/AuthProvider.d.ts +88 -184
  2. package/auth/actions/addError.d.ts +8 -0
  3. package/auth/actions/clearErrors.d.ts +5 -0
  4. package/auth/actions/index.d.ts +7 -0
  5. package/auth/actions/setAccessToken.d.ts +9 -0
  6. package/auth/actions/setIgnoreRefreshToken.d.ts +4 -0
  7. package/auth/actions/setUserContext.d.ts +9 -0
  8. package/auth/actions/unsetRefreshToken.d.ts +4 -0
  9. package/auth/actions/unsetUserContext.d.ts +8 -0
  10. package/auth/actors/authenticate.d.ts +16 -0
  11. package/auth/actors/index.d.ts +3 -0
  12. package/auth/actors/refreshAccessToken.d.ts +18 -0
  13. package/auth/actors/unauthenticate.d.ts +14 -0
  14. package/auth/auth.d.ts +45 -130
  15. package/auth/types.d.ts +42 -0
  16. package/helpers/request.d.ts +2 -0
  17. package/index.d.ts +2 -0
  18. package/index.js +33 -33
  19. package/index.mjs +1485 -1214
  20. package/package.json +2 -3
  21. package/quote/CheckoutProvider.d.ts +117 -0
  22. package/quote/QuoteProvider.d.ts +98 -97
  23. package/quote/checkout/actions/index.d.ts +1 -0
  24. package/quote/checkout/actions/nextStep.d.ts +8 -0
  25. package/quote/checkout/actors/index.d.ts +1 -0
  26. package/quote/checkout/actors/submitStepData.d.ts +19 -0
  27. package/quote/checkout/guards/index.d.ts +1 -0
  28. package/quote/checkout/guards/quoteExists.d.ts +10 -0
  29. package/quote/checkout/types.d.ts +36 -0
  30. package/quote/checkout.d.ts +32 -0
  31. package/quote/quote/actions/addItems.d.ts +211 -0
  32. package/quote/quote/actions/refresh.d.ts +210 -0
  33. package/quote/quote/actions/removeItems.d.ts +211 -0
  34. package/quote/quote/actions/updateItems.d.ts +211 -0
  35. package/quote/quote/types.d.ts +263 -0
  36. package/quote/quote.d.ts +34 -33
  37. package/quote/types.d.ts +1 -180
  38. package/toast/ToastProvider.d.ts +5 -81
  39. package/quote/actions/addItems.d.ts +0 -91
  40. package/quote/actions/refresh.d.ts +0 -90
  41. package/quote/actions/removeItems.d.ts +0 -91
  42. package/quote/actions/updateItems.d.ts +0 -91
  43. /package/quote/{actions → quote/actions}/index.d.ts +0 -0
  44. /package/quote/{actions → quote/actions}/notifyAddItems.d.ts +0 -0
  45. /package/quote/{actions → quote/actions}/notifyRemoveItems.d.ts +0 -0
  46. /package/quote/{actions → quote/actions}/notifyUpdateItems.d.ts +0 -0
  47. /package/quote/{actors → quote/actors}/addItems.d.ts +0 -0
  48. /package/quote/{actors → quote/actors}/index.d.ts +0 -0
  49. /package/quote/{actors → quote/actors}/refresh.d.ts +0 -0
  50. /package/quote/{actors → quote/actors}/removeItems.d.ts +0 -0
  51. /package/quote/{actors → quote/actors}/updateItems.d.ts +0 -0
  52. /package/quote/{guards → quote/guards}/canRefresh.d.ts +0 -0
  53. /package/quote/{guards → quote/guards}/hasItems.d.ts +0 -0
  54. /package/quote/{guards → quote/guards}/index.d.ts +0 -0
@@ -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>;
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,36 @@
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 } from '../quote/types';
6
+ export interface CheckoutStep {
7
+ name: string;
8
+ prev: string | null;
9
+ next: string | null;
10
+ }
11
+ export interface CheckoutMachineContext {
12
+ currentStep: string;
13
+ /** @todo DeepPartial should play nicer with props like steps */
14
+ steps?: Array<CheckoutStep>;
15
+ isLoggedIn: boolean;
16
+ quote: QuoteMachineContext['quote'];
17
+ endpoints: {
18
+ client?: string;
19
+ server?: string;
20
+ };
21
+ graphql: {
22
+ submitStepData: {
23
+ document: RequestDocument | TypedDocumentNode<unknown, {}>;
24
+ requestHeaders?: GraphQLClientRequestHeaders;
25
+ };
26
+ };
27
+ }
28
+ export interface SubmitStepDataEvent {
29
+ type: 'SUBMIT_STEP_DATA';
30
+ data: Record<string, any>;
31
+ }
32
+ export interface SubmitStepDataSuccessEvent {
33
+ type: 'SUBMIT_STEP_DATA_SUCCESS';
34
+ quote: Partial<QuoteMachineContext>;
35
+ }
36
+ export type CheckoutMachineEvents = SubmitStepDataEvent | DoneActorEvent<SubmitStepDataSuccessEvent>;
@@ -0,0 +1,32 @@
1
+ import { CheckoutMachineContext } from './checkout/types';
2
+ import { DeepPartial } from './types';
3
+ export declare const checkoutMachine: import("xstate").StateMachine<CheckoutMachineContext, 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>, {
5
+ [k: string]: unknown;
6
+ type: string;
7
+ }, 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
+ }, {
13
+ type: "nextStep";
14
+ params: import("xstate").NonReducibleUnknown;
15
+ }, {
16
+ type: "quoteExists";
17
+ params: unknown;
18
+ }, never, "uninitialized" | "initializing" | "showStep" | "submittingStepData" | "changingStep", string, {
19
+ initialContext: DeepPartial<CheckoutMachineContext>;
20
+ initialState?: string | undefined;
21
+ }, import("xstate").NonReducibleUnknown, import("xstate").EventObject, import("xstate").MetaObject, import("xstate").ResolveTypegenMeta<import("xstate").TypegenDisabled, import("./checkout/types").SubmitStepDataEvent | import("xstate").DoneActorEvent<import("./checkout/types").SubmitStepDataSuccessEvent>, {
22
+ src: "submitStepData";
23
+ logic: import("xstate").PromiseActorLogic<import("./checkout/types").SubmitStepDataSuccessEvent, import("./checkout/actors").SubmitStepDataInput>;
24
+ id: string | undefined;
25
+ }, {
26
+ type: "nextStep";
27
+ params: import("xstate").NonReducibleUnknown;
28
+ }, {
29
+ type: "quoteExists";
30
+ params: unknown;
31
+ }, never, string, import("xstate").EventObject>>;
32
+ export default checkoutMachine;
@@ -0,0 +1,211 @@
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
+ 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: import("../types").QuoteAddress[];
19
+ applied: (import("../types").QuoteAddress & {
20
+ availableAddressId?: string | undefined;
21
+ itemIds: Record<string, any>[];
22
+ })[];
23
+ };
24
+ paymentMethods: {
25
+ available: import("../types").PaymentMethod[];
26
+ applied: {
27
+ paymentMethod: import("../types").PaymentMethod;
28
+ options: Record<string, any>[];
29
+ amount: number;
30
+ }[];
31
+ };
32
+ shipments: {
33
+ id: string;
34
+ shippingAddress: {
35
+ id: string;
36
+ address: import("../types").QuoteAddress;
37
+ };
38
+ items: Record<string, any>[];
39
+ shippingMethods: {
40
+ available: {
41
+ shippingMethod: {
42
+ id: string;
43
+ code: string;
44
+ name: string;
45
+ carrier: {
46
+ id: string;
47
+ code: string;
48
+ name: string;
49
+ };
50
+ };
51
+ estimatedTotal: number;
52
+ earliestShipDate: Date;
53
+ latestShipDate: Date;
54
+ earliestArrivalDate: Date;
55
+ latestArrivalDate: Date;
56
+ }[];
57
+ applied: {
58
+ shippingMethod: {
59
+ id: string;
60
+ code: string;
61
+ name: string;
62
+ carrier: {
63
+ id: string;
64
+ code: string;
65
+ name: string;
66
+ };
67
+ };
68
+ estimatedTotal: number;
69
+ earliestShipDate: Date;
70
+ latestShipDate: Date;
71
+ earliestArrivalDate: Date;
72
+ latestArrivalDate: Date;
73
+ }[];
74
+ };
75
+ }[];
76
+ totals: {
77
+ discount: number;
78
+ tax: number;
79
+ shipping: number;
80
+ shippingTax: number;
81
+ subtotal: number;
82
+ grandTotal: number;
83
+ } | null;
84
+ appliedPriceRules: Record<string, any>[] | null;
85
+ appliedPromotions: Record<string, any>[] | null;
86
+ shippingMethods: Record<string, any>[] | null;
87
+ storeCredit: Record<string, any>[] | null;
88
+ rewards: Record<string, any>[] | null;
89
+ giftCards: Record<string, any>[] | null;
90
+ user: {
91
+ id: string | null;
92
+ email: string | null;
93
+ firstName: string | null;
94
+ lastName: string | null;
95
+ } | null;
96
+ }> | undefined;
97
+ errors?: string[] | undefined;
98
+ endpoints?: {
99
+ client?: string | undefined;
100
+ server?: string | undefined;
101
+ } | undefined;
102
+ graphql?: {
103
+ refresh: {
104
+ document: import("graphql-request").RequestDocument | import("@graphql-typed-document-node/core").TypedDocumentNode<unknown, {}>;
105
+ requestHeaders?: import("graphql-request/build/esm/types").GraphQLClientRequestHeaders | undefined;
106
+ };
107
+ addItems: {
108
+ document: import("graphql-request").RequestDocument | import("@graphql-typed-document-node/core").TypedDocumentNode<unknown, {}>;
109
+ requestHeaders?: import("graphql-request/build/esm/types").GraphQLClientRequestHeaders | undefined;
110
+ };
111
+ removeItems: {
112
+ document: import("graphql-request").RequestDocument | import("@graphql-typed-document-node/core").TypedDocumentNode<unknown, {}>;
113
+ requestHeaders?: import("graphql-request/build/esm/types").GraphQLClientRequestHeaders | undefined;
114
+ };
115
+ updateItems: {
116
+ document: import("graphql-request").RequestDocument | import("@graphql-typed-document-node/core").TypedDocumentNode<unknown, {}>;
117
+ requestHeaders?: import("graphql-request/build/esm/types").GraphQLClientRequestHeaders | undefined;
118
+ };
119
+ } | undefined;
120
+ id?: string | null | undefined;
121
+ locale?: string | null | undefined;
122
+ baseCurrency?: string | null | undefined;
123
+ currency?: string | null | undefined;
124
+ currencyConversionRate?: number | null | undefined;
125
+ dateCreated?: Date | null | undefined;
126
+ dateLastUpdated?: Date | null | undefined;
127
+ items?: Record<string, any>[] | null | undefined;
128
+ promotions?: Record<string, any>[] | null | undefined;
129
+ shippingAddresses?: {
130
+ available: import("../types").QuoteAddress[];
131
+ applied: (import("../types").QuoteAddress & {
132
+ availableAddressId?: string | undefined;
133
+ itemIds: Record<string, any>[];
134
+ })[];
135
+ } | undefined;
136
+ paymentMethods?: {
137
+ available: import("../types").PaymentMethod[];
138
+ applied: {
139
+ paymentMethod: import("../types").PaymentMethod;
140
+ options: Record<string, any>[];
141
+ amount: number;
142
+ }[];
143
+ } | undefined;
144
+ shipments?: {
145
+ id: string;
146
+ shippingAddress: {
147
+ id: string;
148
+ address: import("../types").QuoteAddress;
149
+ };
150
+ items: Record<string, any>[];
151
+ shippingMethods: {
152
+ available: {
153
+ shippingMethod: {
154
+ id: string;
155
+ code: string;
156
+ name: string;
157
+ carrier: {
158
+ id: string;
159
+ code: string;
160
+ name: string;
161
+ };
162
+ };
163
+ estimatedTotal: number;
164
+ earliestShipDate: Date;
165
+ latestShipDate: Date;
166
+ earliestArrivalDate: Date;
167
+ latestArrivalDate: Date;
168
+ }[];
169
+ applied: {
170
+ shippingMethod: {
171
+ id: string;
172
+ code: string;
173
+ name: string;
174
+ carrier: {
175
+ id: string;
176
+ code: string;
177
+ name: string;
178
+ };
179
+ };
180
+ estimatedTotal: number;
181
+ earliestShipDate: Date;
182
+ latestShipDate: Date;
183
+ earliestArrivalDate: Date;
184
+ latestArrivalDate: Date;
185
+ }[];
186
+ };
187
+ }[] | undefined;
188
+ totals?: {
189
+ discount: number;
190
+ tax: number;
191
+ shipping: number;
192
+ shippingTax: number;
193
+ subtotal: number;
194
+ grandTotal: number;
195
+ } | null | undefined;
196
+ appliedPriceRules?: Record<string, any>[] | null | undefined;
197
+ appliedPromotions?: Record<string, any>[] | null | undefined;
198
+ shippingMethods?: Record<string, any>[] | null | undefined;
199
+ storeCredit?: Record<string, any>[] | null | undefined;
200
+ rewards?: Record<string, any>[] | null | undefined;
201
+ giftCards?: Record<string, any>[] | null | undefined;
202
+ user?: {
203
+ id: string | null;
204
+ email: string | null;
205
+ firstName: string | null;
206
+ lastName: string | null;
207
+ } | null | undefined;
208
+ };
209
+ itemsAdded: Record<string, any>[] | null | undefined;
210
+ };
211
+ export default addItems;
@@ -0,0 +1,210 @@
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?: Partial<{
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: import("../types").QuoteAddress[];
19
+ applied: (import("../types").QuoteAddress & {
20
+ availableAddressId?: string | undefined;
21
+ itemIds: Record<string, any>[];
22
+ })[];
23
+ };
24
+ paymentMethods: {
25
+ available: import("../types").PaymentMethod[];
26
+ applied: {
27
+ paymentMethod: import("../types").PaymentMethod;
28
+ options: Record<string, any>[];
29
+ amount: number;
30
+ }[];
31
+ };
32
+ shipments: {
33
+ id: string;
34
+ shippingAddress: {
35
+ id: string;
36
+ address: import("../types").QuoteAddress;
37
+ };
38
+ items: Record<string, any>[];
39
+ shippingMethods: {
40
+ available: {
41
+ shippingMethod: {
42
+ id: string;
43
+ code: string;
44
+ name: string;
45
+ carrier: {
46
+ id: string;
47
+ code: string;
48
+ name: string;
49
+ };
50
+ };
51
+ estimatedTotal: number;
52
+ earliestShipDate: Date;
53
+ latestShipDate: Date;
54
+ earliestArrivalDate: Date;
55
+ latestArrivalDate: Date;
56
+ }[];
57
+ applied: {
58
+ shippingMethod: {
59
+ id: string;
60
+ code: string;
61
+ name: string;
62
+ carrier: {
63
+ id: string;
64
+ code: string;
65
+ name: string;
66
+ };
67
+ };
68
+ estimatedTotal: number;
69
+ earliestShipDate: Date;
70
+ latestShipDate: Date;
71
+ earliestArrivalDate: Date;
72
+ latestArrivalDate: Date;
73
+ }[];
74
+ };
75
+ }[];
76
+ totals: {
77
+ discount: number;
78
+ tax: number;
79
+ shipping: number;
80
+ shippingTax: number;
81
+ subtotal: number;
82
+ grandTotal: number;
83
+ } | null;
84
+ appliedPriceRules: Record<string, any>[] | null;
85
+ appliedPromotions: Record<string, any>[] | null;
86
+ shippingMethods: Record<string, any>[] | null;
87
+ storeCredit: Record<string, any>[] | null;
88
+ rewards: Record<string, any>[] | null;
89
+ giftCards: Record<string, any>[] | null;
90
+ user: {
91
+ id: string | null;
92
+ email: string | null;
93
+ firstName: string | null;
94
+ lastName: string | null;
95
+ } | null;
96
+ }> | undefined;
97
+ errors?: string[] | undefined;
98
+ endpoints?: {
99
+ client?: string | undefined;
100
+ server?: string | undefined;
101
+ } | undefined;
102
+ graphql?: {
103
+ refresh: {
104
+ document: import("graphql-request").RequestDocument | import("@graphql-typed-document-node/core").TypedDocumentNode<unknown, {}>;
105
+ requestHeaders?: import("graphql-request/build/esm/types").GraphQLClientRequestHeaders | undefined;
106
+ };
107
+ addItems: {
108
+ document: import("graphql-request").RequestDocument | import("@graphql-typed-document-node/core").TypedDocumentNode<unknown, {}>;
109
+ requestHeaders?: import("graphql-request/build/esm/types").GraphQLClientRequestHeaders | undefined;
110
+ };
111
+ removeItems: {
112
+ document: import("graphql-request").RequestDocument | import("@graphql-typed-document-node/core").TypedDocumentNode<unknown, {}>;
113
+ requestHeaders?: import("graphql-request/build/esm/types").GraphQLClientRequestHeaders | undefined;
114
+ };
115
+ updateItems: {
116
+ document: import("graphql-request").RequestDocument | import("@graphql-typed-document-node/core").TypedDocumentNode<unknown, {}>;
117
+ requestHeaders?: import("graphql-request/build/esm/types").GraphQLClientRequestHeaders | undefined;
118
+ };
119
+ } | undefined;
120
+ id?: string | null | undefined;
121
+ locale?: string | null | undefined;
122
+ baseCurrency?: string | null | undefined;
123
+ currency?: string | null | undefined;
124
+ currencyConversionRate?: number | null | undefined;
125
+ dateCreated?: Date | null | undefined;
126
+ dateLastUpdated?: Date | null | undefined;
127
+ items?: Record<string, any>[] | null | undefined;
128
+ promotions?: Record<string, any>[] | null | undefined;
129
+ shippingAddresses?: {
130
+ available: import("../types").QuoteAddress[];
131
+ applied: (import("../types").QuoteAddress & {
132
+ availableAddressId?: string | undefined;
133
+ itemIds: Record<string, any>[];
134
+ })[];
135
+ } | undefined;
136
+ paymentMethods?: {
137
+ available: import("../types").PaymentMethod[];
138
+ applied: {
139
+ paymentMethod: import("../types").PaymentMethod;
140
+ options: Record<string, any>[];
141
+ amount: number;
142
+ }[];
143
+ } | undefined;
144
+ shipments?: {
145
+ id: string;
146
+ shippingAddress: {
147
+ id: string;
148
+ address: import("../types").QuoteAddress;
149
+ };
150
+ items: Record<string, any>[];
151
+ shippingMethods: {
152
+ available: {
153
+ shippingMethod: {
154
+ id: string;
155
+ code: string;
156
+ name: string;
157
+ carrier: {
158
+ id: string;
159
+ code: string;
160
+ name: string;
161
+ };
162
+ };
163
+ estimatedTotal: number;
164
+ earliestShipDate: Date;
165
+ latestShipDate: Date;
166
+ earliestArrivalDate: Date;
167
+ latestArrivalDate: Date;
168
+ }[];
169
+ applied: {
170
+ shippingMethod: {
171
+ id: string;
172
+ code: string;
173
+ name: string;
174
+ carrier: {
175
+ id: string;
176
+ code: string;
177
+ name: string;
178
+ };
179
+ };
180
+ estimatedTotal: number;
181
+ earliestShipDate: Date;
182
+ latestShipDate: Date;
183
+ earliestArrivalDate: Date;
184
+ latestArrivalDate: Date;
185
+ }[];
186
+ };
187
+ }[] | undefined;
188
+ totals?: {
189
+ discount: number;
190
+ tax: number;
191
+ shipping: number;
192
+ shippingTax: number;
193
+ subtotal: number;
194
+ grandTotal: number;
195
+ } | null | undefined;
196
+ appliedPriceRules?: Record<string, any>[] | null | undefined;
197
+ appliedPromotions?: Record<string, any>[] | null | undefined;
198
+ shippingMethods?: Record<string, any>[] | null | undefined;
199
+ storeCredit?: Record<string, any>[] | null | undefined;
200
+ rewards?: Record<string, any>[] | null | undefined;
201
+ giftCards?: Record<string, any>[] | null | undefined;
202
+ user?: {
203
+ id: string | null;
204
+ email: string | null;
205
+ firstName: string | null;
206
+ lastName: string | null;
207
+ } | null | undefined;
208
+ };
209
+ };
210
+ export default refresh;