@forgecart/sdk 1.0.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.
@@ -0,0 +1,3416 @@
1
+ /**
2
+ * @forgecart/sdk - Auto-generated TypeScript SDK
3
+ *
4
+ * This file was automatically generated and should not be manually edited.
5
+ * To regenerate, run: npm run codegen:ts
6
+ *
7
+ * Generated at: 2025-12-12T11:13:16.603Z
8
+ * Generator version: 1.0.0
9
+ *
10
+ * 🤖 Generated with ForgeCart SDK Generator
11
+ */
12
+
13
+
14
+ import * as Types from './shop-types.js';
15
+
16
+ import { GraphQLClient, RequestDocument, Variables } from 'graphql-request';
17
+ import { createClient, Client as WSClient, ClientOptions as WSClientOptions } from 'graphql-ws';
18
+
19
+ /**
20
+ * SDK Configuration
21
+ */
22
+ export interface SDKConfig {
23
+ /** GraphQL HTTP endpoint */
24
+ endpoint?: string;
25
+ /** WebSocket endpoint for subscriptions */
26
+ wsEndpoint?: string;
27
+ /** Custom HTTP headers */
28
+ headers?: Record<string, string>;
29
+ /** Custom WebSocket implementation (optional, auto-detected if not provided) */
30
+ webSocketImpl?: unknown;
31
+ }
32
+
33
+ export type AssetQueryVariables = Types.AssetQueryVariables;
34
+ export type AssetQuery = Types.AssetQuery;
35
+ export type AssetQueryResult = Types.AssetQuery;
36
+ export type AssetsQueryVariables = Types.AssetsQueryVariables;
37
+ export type AssetsQuery = Types.AssetsQuery;
38
+ export type AssetsQueryResult = Types.AssetsQuery;
39
+ export type MeQueryVariables = Types.MeQueryVariables;
40
+ export type MeQuery = Types.MeQuery;
41
+ export type MeQueryResult = Types.MeQuery;
42
+ export type AuthenticateMutationVariables = Types.AuthenticateMutationVariables;
43
+ export type AuthenticateMutation = Types.AuthenticateMutation;
44
+ export type AuthenticateMutationResult = Types.AuthenticateMutation;
45
+ export type GenerateOtpMutationVariables = Types.GenerateOtpMutationVariables;
46
+ export type GenerateOtpMutation = Types.GenerateOtpMutation;
47
+ export type GenerateOtpMutationResult = Types.GenerateOtpMutation;
48
+ export type VerifyOtpMutationVariables = Types.VerifyOtpMutationVariables;
49
+ export type VerifyOtpMutation = Types.VerifyOtpMutation;
50
+ export type VerifyOtpMutationResult = Types.VerifyOtpMutation;
51
+ export type RegisterCustomerAccountMutationVariables = Types.RegisterCustomerAccountMutationVariables;
52
+ export type RegisterCustomerAccountMutation = Types.RegisterCustomerAccountMutation;
53
+ export type RegisterCustomerAccountMutationResult = Types.RegisterCustomerAccountMutation;
54
+ export type VerifyCustomerAccountMutationVariables = Types.VerifyCustomerAccountMutationVariables;
55
+ export type VerifyCustomerAccountMutation = Types.VerifyCustomerAccountMutation;
56
+ export type VerifyCustomerAccountMutationResult = Types.VerifyCustomerAccountMutation;
57
+ export type RefreshCustomerVerificationMutationVariables = Types.RefreshCustomerVerificationMutationVariables;
58
+ export type RefreshCustomerVerificationMutation = Types.RefreshCustomerVerificationMutation;
59
+ export type RefreshCustomerVerificationMutationResult = Types.RefreshCustomerVerificationMutation;
60
+ export type UpdateCustomerMutationVariables = Types.UpdateCustomerMutationVariables;
61
+ export type UpdateCustomerMutation = Types.UpdateCustomerMutation;
62
+ export type UpdateCustomerMutationResult = Types.UpdateCustomerMutation;
63
+ export type UpdateCustomerPasswordMutationVariables = Types.UpdateCustomerPasswordMutationVariables;
64
+ export type UpdateCustomerPasswordMutation = Types.UpdateCustomerPasswordMutation;
65
+ export type UpdateCustomerPasswordMutationResult = Types.UpdateCustomerPasswordMutation;
66
+ export type UpdateCustomerEmailAddressMutationVariables = Types.UpdateCustomerEmailAddressMutationVariables;
67
+ export type UpdateCustomerEmailAddressMutation = Types.UpdateCustomerEmailAddressMutation;
68
+ export type UpdateCustomerEmailAddressMutationResult = Types.UpdateCustomerEmailAddressMutation;
69
+ export type RequestUpdateCustomerEmailAddressMutationVariables = Types.RequestUpdateCustomerEmailAddressMutationVariables;
70
+ export type RequestUpdateCustomerEmailAddressMutation = Types.RequestUpdateCustomerEmailAddressMutation;
71
+ export type RequestUpdateCustomerEmailAddressMutationResult = Types.RequestUpdateCustomerEmailAddressMutation;
72
+ export type RequestPasswordResetMutationVariables = Types.RequestPasswordResetMutationVariables;
73
+ export type RequestPasswordResetMutation = Types.RequestPasswordResetMutation;
74
+ export type RequestPasswordResetMutationResult = Types.RequestPasswordResetMutation;
75
+ export type BlogPostQueryVariables = Types.BlogPostQueryVariables;
76
+ export type BlogPostQuery = Types.BlogPostQuery;
77
+ export type BlogPostQueryResult = Types.BlogPostQuery;
78
+ export type BlogPostsQueryVariables = Types.BlogPostsQueryVariables;
79
+ export type BlogPostsQuery = Types.BlogPostsQuery;
80
+ export type BlogPostsQueryResult = Types.BlogPostsQuery;
81
+ export type BlogPostsByFacetsQueryVariables = Types.BlogPostsByFacetsQueryVariables;
82
+ export type BlogPostsByFacetsQuery = Types.BlogPostsByFacetsQuery;
83
+ export type BlogPostsByFacetsQueryResult = Types.BlogPostsByFacetsQuery;
84
+ export type ActiveChannelQueryVariables = Types.ActiveChannelQueryVariables;
85
+ export type ActiveChannelQuery = Types.ActiveChannelQuery;
86
+ export type ActiveChannelQueryResult = Types.ActiveChannelQuery;
87
+ export type CollectionQueryVariables = Types.CollectionQueryVariables;
88
+ export type CollectionQuery = Types.CollectionQuery;
89
+ export type CollectionQueryResult = Types.CollectionQuery;
90
+ export type CollectionsQueryVariables = Types.CollectionsQueryVariables;
91
+ export type CollectionsQuery = Types.CollectionsQuery;
92
+ export type CollectionsQueryResult = Types.CollectionsQuery;
93
+ export type AvailableCountriesQueryVariables = Types.AvailableCountriesQueryVariables;
94
+ export type AvailableCountriesQuery = Types.AvailableCountriesQuery;
95
+ export type AvailableCountriesQueryResult = Types.AvailableCountriesQuery;
96
+ export type GetAllFieldsQueryVariables = Types.GetAllFieldsQueryVariables;
97
+ export type GetAllFieldsQuery = Types.GetAllFieldsQuery;
98
+ export type GetAllFieldsQueryResult = Types.GetAllFieldsQuery;
99
+ export type GetAllValuesQueryVariables = Types.GetAllValuesQueryVariables;
100
+ export type GetAllValuesQuery = Types.GetAllValuesQuery;
101
+ export type GetAllValuesQueryResult = Types.GetAllValuesQuery;
102
+ export type GetBooleanValueQueryVariables = Types.GetBooleanValueQueryVariables;
103
+ export type GetBooleanValueQuery = Types.GetBooleanValueQuery;
104
+ export type GetBooleanValueQueryResult = Types.GetBooleanValueQuery;
105
+ export type GetDateValueQueryVariables = Types.GetDateValueQueryVariables;
106
+ export type GetDateValueQuery = Types.GetDateValueQuery;
107
+ export type GetDateValueQueryResult = Types.GetDateValueQuery;
108
+ export type GetFloatValueQueryVariables = Types.GetFloatValueQueryVariables;
109
+ export type GetFloatValueQuery = Types.GetFloatValueQuery;
110
+ export type GetFloatValueQueryResult = Types.GetFloatValueQuery;
111
+ export type GetGroupFieldDefinitionByIdQueryVariables = Types.GetGroupFieldDefinitionByIdQueryVariables;
112
+ export type GetGroupFieldDefinitionByIdQuery = Types.GetGroupFieldDefinitionByIdQuery;
113
+ export type GetGroupFieldDefinitionByIdQueryResult = Types.GetGroupFieldDefinitionByIdQuery;
114
+ export type GetGroupValueQueryVariables = Types.GetGroupValueQueryVariables;
115
+ export type GetGroupValueQuery = Types.GetGroupValueQuery;
116
+ export type GetGroupValueQueryResult = Types.GetGroupValueQuery;
117
+ export type GetIntegerValueQueryVariables = Types.GetIntegerValueQueryVariables;
118
+ export type GetIntegerValueQuery = Types.GetIntegerValueQuery;
119
+ export type GetIntegerValueQueryResult = Types.GetIntegerValueQuery;
120
+ export type GetRelationValueQueryVariables = Types.GetRelationValueQueryVariables;
121
+ export type GetRelationValueQuery = Types.GetRelationValueQuery;
122
+ export type GetRelationValueQueryResult = Types.GetRelationValueQuery;
123
+ export type GetRichTextValueQueryVariables = Types.GetRichTextValueQueryVariables;
124
+ export type GetRichTextValueQuery = Types.GetRichTextValueQuery;
125
+ export type GetRichTextValueQueryResult = Types.GetRichTextValueQuery;
126
+ export type GetStringValueQueryVariables = Types.GetStringValueQueryVariables;
127
+ export type GetStringValueQuery = Types.GetStringValueQuery;
128
+ export type GetStringValueQueryResult = Types.GetStringValueQuery;
129
+ export type GetTemplatesByEntityIdQueryVariables = Types.GetTemplatesByEntityIdQueryVariables;
130
+ export type GetTemplatesByEntityIdQuery = Types.GetTemplatesByEntityIdQuery;
131
+ export type GetTemplatesByEntityIdQueryResult = Types.GetTemplatesByEntityIdQuery;
132
+ export type GetUniqueTemplatesQueryVariables = Types.GetUniqueTemplatesQueryVariables;
133
+ export type GetUniqueTemplatesQuery = Types.GetUniqueTemplatesQuery;
134
+ export type GetUniqueTemplatesQueryResult = Types.GetUniqueTemplatesQuery;
135
+ export type CreateCustomerAddressMutationVariables = Types.CreateCustomerAddressMutationVariables;
136
+ export type CreateCustomerAddressMutation = Types.CreateCustomerAddressMutation;
137
+ export type CreateCustomerAddressMutationResult = Types.CreateCustomerAddressMutation;
138
+ export type UpdateCustomerAddressMutationVariables = Types.UpdateCustomerAddressMutationVariables;
139
+ export type UpdateCustomerAddressMutation = Types.UpdateCustomerAddressMutation;
140
+ export type UpdateCustomerAddressMutationResult = Types.UpdateCustomerAddressMutation;
141
+ export type DeleteCustomerAddressMutationVariables = Types.DeleteCustomerAddressMutationVariables;
142
+ export type DeleteCustomerAddressMutation = Types.DeleteCustomerAddressMutation;
143
+ export type DeleteCustomerAddressMutationResult = Types.DeleteCustomerAddressMutation;
144
+ export type FacetQueryVariables = Types.FacetQueryVariables;
145
+ export type FacetQuery = Types.FacetQuery;
146
+ export type FacetQueryResult = Types.FacetQuery;
147
+ export type FacetsQueryVariables = Types.FacetsQueryVariables;
148
+ export type FacetsQuery = Types.FacetsQuery;
149
+ export type FacetsQueryResult = Types.FacetsQuery;
150
+ export type GetOnboardingQueryVariables = Types.GetOnboardingQueryVariables;
151
+ export type GetOnboardingQuery = Types.GetOnboardingQuery;
152
+ export type GetOnboardingQueryResult = Types.GetOnboardingQuery;
153
+ export type CreateOnboardingMutationVariables = Types.CreateOnboardingMutationVariables;
154
+ export type CreateOnboardingMutation = Types.CreateOnboardingMutation;
155
+ export type CreateOnboardingMutationResult = Types.CreateOnboardingMutation;
156
+ export type UpdateOnboardingMutationVariables = Types.UpdateOnboardingMutationVariables;
157
+ export type UpdateOnboardingMutation = Types.UpdateOnboardingMutation;
158
+ export type UpdateOnboardingMutationResult = Types.UpdateOnboardingMutation;
159
+ export type ActiveOrderQueryVariables = Types.ActiveOrderQueryVariables;
160
+ export type ActiveOrderQuery = Types.ActiveOrderQuery;
161
+ export type ActiveOrderQueryResult = Types.ActiveOrderQuery;
162
+ export type OrderQueryVariables = Types.OrderQueryVariables;
163
+ export type OrderQuery = Types.OrderQuery;
164
+ export type OrderQueryResult = Types.OrderQuery;
165
+ export type OrderByCodeQueryVariables = Types.OrderByCodeQueryVariables;
166
+ export type OrderByCodeQuery = Types.OrderByCodeQuery;
167
+ export type OrderByCodeQueryResult = Types.OrderByCodeQuery;
168
+ export type NextOrderStatesQueryVariables = Types.NextOrderStatesQueryVariables;
169
+ export type NextOrderStatesQuery = Types.NextOrderStatesQuery;
170
+ export type NextOrderStatesQueryResult = Types.NextOrderStatesQuery;
171
+ export type AddItemToOrderMutationVariables = Types.AddItemToOrderMutationVariables;
172
+ export type AddItemToOrderMutation = Types.AddItemToOrderMutation;
173
+ export type AddItemToOrderMutationResult = Types.AddItemToOrderMutation;
174
+ export type AdjustOrderLineMutationVariables = Types.AdjustOrderLineMutationVariables;
175
+ export type AdjustOrderLineMutation = Types.AdjustOrderLineMutation;
176
+ export type AdjustOrderLineMutationResult = Types.AdjustOrderLineMutation;
177
+ export type RemoveOrderLineMutationVariables = Types.RemoveOrderLineMutationVariables;
178
+ export type RemoveOrderLineMutation = Types.RemoveOrderLineMutation;
179
+ export type RemoveOrderLineMutationResult = Types.RemoveOrderLineMutation;
180
+ export type RemoveAllOrderLinesMutationVariables = Types.RemoveAllOrderLinesMutationVariables;
181
+ export type RemoveAllOrderLinesMutation = Types.RemoveAllOrderLinesMutation;
182
+ export type RemoveAllOrderLinesMutationResult = Types.RemoveAllOrderLinesMutation;
183
+ export type ApplyCouponCodeMutationVariables = Types.ApplyCouponCodeMutationVariables;
184
+ export type ApplyCouponCodeMutation = Types.ApplyCouponCodeMutation;
185
+ export type ApplyCouponCodeMutationResult = Types.ApplyCouponCodeMutation;
186
+ export type RemoveCouponCodeMutationVariables = Types.RemoveCouponCodeMutationVariables;
187
+ export type RemoveCouponCodeMutation = Types.RemoveCouponCodeMutation;
188
+ export type RemoveCouponCodeMutationResult = Types.RemoveCouponCodeMutation;
189
+ export type SetOrderShippingAddressMutationVariables = Types.SetOrderShippingAddressMutationVariables;
190
+ export type SetOrderShippingAddressMutation = Types.SetOrderShippingAddressMutation;
191
+ export type SetOrderShippingAddressMutationResult = Types.SetOrderShippingAddressMutation;
192
+ export type UnsetOrderShippingAddressMutationVariables = Types.UnsetOrderShippingAddressMutationVariables;
193
+ export type UnsetOrderShippingAddressMutation = Types.UnsetOrderShippingAddressMutation;
194
+ export type UnsetOrderShippingAddressMutationResult = Types.UnsetOrderShippingAddressMutation;
195
+ export type SetOrderBillingAddressMutationVariables = Types.SetOrderBillingAddressMutationVariables;
196
+ export type SetOrderBillingAddressMutation = Types.SetOrderBillingAddressMutation;
197
+ export type SetOrderBillingAddressMutationResult = Types.SetOrderBillingAddressMutation;
198
+ export type UnsetOrderBillingAddressMutationVariables = Types.UnsetOrderBillingAddressMutationVariables;
199
+ export type UnsetOrderBillingAddressMutation = Types.UnsetOrderBillingAddressMutation;
200
+ export type UnsetOrderBillingAddressMutationResult = Types.UnsetOrderBillingAddressMutation;
201
+ export type EligibleShippingMethodsQueryVariables = Types.EligibleShippingMethodsQueryVariables;
202
+ export type EligibleShippingMethodsQuery = Types.EligibleShippingMethodsQuery;
203
+ export type EligibleShippingMethodsQueryResult = Types.EligibleShippingMethodsQuery;
204
+ export type ActiveShippingMethodsQueryVariables = Types.ActiveShippingMethodsQueryVariables;
205
+ export type ActiveShippingMethodsQuery = Types.ActiveShippingMethodsQuery;
206
+ export type ActiveShippingMethodsQueryResult = Types.ActiveShippingMethodsQuery;
207
+ export type SetOrderShippingMethodMutationVariables = Types.SetOrderShippingMethodMutationVariables;
208
+ export type SetOrderShippingMethodMutation = Types.SetOrderShippingMethodMutation;
209
+ export type SetOrderShippingMethodMutationResult = Types.SetOrderShippingMethodMutation;
210
+ export type EligiblePaymentMethodsQueryVariables = Types.EligiblePaymentMethodsQueryVariables;
211
+ export type EligiblePaymentMethodsQuery = Types.EligiblePaymentMethodsQuery;
212
+ export type EligiblePaymentMethodsQueryResult = Types.EligiblePaymentMethodsQuery;
213
+ export type ActivePaymentMethodsQueryVariables = Types.ActivePaymentMethodsQueryVariables;
214
+ export type ActivePaymentMethodsQuery = Types.ActivePaymentMethodsQuery;
215
+ export type ActivePaymentMethodsQueryResult = Types.ActivePaymentMethodsQuery;
216
+ export type AddPaymentToOrderMutationVariables = Types.AddPaymentToOrderMutationVariables;
217
+ export type AddPaymentToOrderMutation = Types.AddPaymentToOrderMutation;
218
+ export type AddPaymentToOrderMutationResult = Types.AddPaymentToOrderMutation;
219
+ export type TransitionOrderToStateMutationVariables = Types.TransitionOrderToStateMutationVariables;
220
+ export type TransitionOrderToStateMutation = Types.TransitionOrderToStateMutation;
221
+ export type TransitionOrderToStateMutationResult = Types.TransitionOrderToStateMutation;
222
+ export type SetCustomerForOrderMutationVariables = Types.SetCustomerForOrderMutationVariables;
223
+ export type SetCustomerForOrderMutation = Types.SetCustomerForOrderMutation;
224
+ export type SetCustomerForOrderMutationResult = Types.SetCustomerForOrderMutation;
225
+ export type SetOrderCustomFieldsMutationVariables = Types.SetOrderCustomFieldsMutationVariables;
226
+ export type SetOrderCustomFieldsMutation = Types.SetOrderCustomFieldsMutation;
227
+ export type SetOrderCustomFieldsMutationResult = Types.SetOrderCustomFieldsMutation;
228
+ export type ProductsQueryVariables = Types.ProductsQueryVariables;
229
+ export type ProductsQuery = Types.ProductsQuery;
230
+ export type ProductsQueryResult = Types.ProductsQuery;
231
+ export type ProductQueryVariables = Types.ProductQueryVariables;
232
+ export type ProductQuery = Types.ProductQuery;
233
+ export type ProductQueryResult = Types.ProductQuery;
234
+ export type SearchQueryVariables = Types.SearchQueryVariables;
235
+ export type SearchQuery = Types.SearchQuery;
236
+ export type SearchQueryResult = Types.SearchQuery;
237
+
238
+ const assetDocument = `query asset($id: ID!) {
239
+ asset(id: $id) {
240
+ id
241
+ createdAt
242
+ updatedAt
243
+ name
244
+ type
245
+ fileSize
246
+ mimeType
247
+ width
248
+ height
249
+ source
250
+ preview
251
+ thumbnail
252
+ focalPoint {
253
+ x
254
+ y
255
+ }
256
+ tags {
257
+ id
258
+ value
259
+ }
260
+ customFields
261
+ }
262
+ }`;
263
+
264
+ const assetsDocument = `query assets($options: AssetListOptions) {
265
+ assets(options: $options) {
266
+ items {
267
+ id
268
+ createdAt
269
+ updatedAt
270
+ name
271
+ type
272
+ fileSize
273
+ mimeType
274
+ width
275
+ height
276
+ source
277
+ preview
278
+ thumbnail
279
+ focalPoint {
280
+ x
281
+ y
282
+ }
283
+ tags {
284
+ id
285
+ value
286
+ }
287
+ }
288
+ totalItems
289
+ }
290
+ }`;
291
+
292
+ const meDocument = `query me {
293
+ me {
294
+ id
295
+ identifier
296
+ channels {
297
+ id
298
+ token
299
+ code
300
+ permissions
301
+ }
302
+ }
303
+ }`;
304
+
305
+ const authenticateDocument = `mutation authenticate($input: AuthenticationInput!, $rememberMe: Boolean) {
306
+ authenticate(input: $input, rememberMe: $rememberMe) {
307
+ ... on CurrentUser {
308
+ id
309
+ identifier
310
+ channels {
311
+ id
312
+ token
313
+ code
314
+ permissions
315
+ }
316
+ }
317
+ ... on InvalidCredentialsError {
318
+ errorCode
319
+ message
320
+ }
321
+ ... on NotVerifiedError {
322
+ errorCode
323
+ message
324
+ }
325
+ }
326
+ }`;
327
+
328
+ const generateOtpDocument = `mutation generateOtp($customerId: ID!) {
329
+ generateOtp(customerId: $customerId)
330
+ }`;
331
+
332
+ const verifyOtpDocument = `mutation verifyOtp($input: VerifyOtpInput!) {
333
+ verifyOtp(input: $input)
334
+ }`;
335
+
336
+ const registerCustomerAccountDocument = `mutation registerCustomerAccount($input: RegisterCustomerInput!) {
337
+ registerCustomerAccount(input: $input) {
338
+ ... on Success {
339
+ success
340
+ }
341
+ ... on MissingPasswordError {
342
+ errorCode
343
+ message
344
+ }
345
+ ... on PasswordValidationError {
346
+ errorCode
347
+ message
348
+ validationErrorMessage
349
+ }
350
+ ... on NativeAuthStrategyError {
351
+ errorCode
352
+ message
353
+ }
354
+ }
355
+ }`;
356
+
357
+ const verifyCustomerAccountDocument = `mutation verifyCustomerAccount($token: String!, $password: String) {
358
+ verifyCustomerAccount(token: $token, password: $password) {
359
+ ... on CurrentUser {
360
+ id
361
+ identifier
362
+ channels {
363
+ id
364
+ token
365
+ code
366
+ permissions
367
+ }
368
+ }
369
+ ... on VerificationTokenInvalidError {
370
+ errorCode
371
+ message
372
+ }
373
+ ... on VerificationTokenExpiredError {
374
+ errorCode
375
+ message
376
+ }
377
+ ... on MissingPasswordError {
378
+ errorCode
379
+ message
380
+ }
381
+ ... on PasswordValidationError {
382
+ errorCode
383
+ message
384
+ validationErrorMessage
385
+ }
386
+ ... on PasswordAlreadySetError {
387
+ errorCode
388
+ message
389
+ }
390
+ ... on NativeAuthStrategyError {
391
+ errorCode
392
+ message
393
+ }
394
+ }
395
+ }`;
396
+
397
+ const refreshCustomerVerificationDocument = `mutation refreshCustomerVerification($emailAddress: String!) {
398
+ refreshCustomerVerification(emailAddress: $emailAddress) {
399
+ ... on Success {
400
+ success
401
+ }
402
+ ... on NativeAuthStrategyError {
403
+ errorCode
404
+ message
405
+ }
406
+ }
407
+ }`;
408
+
409
+ const updateCustomerDocument = `mutation updateCustomer($input: UpdateCustomerInput!) {
410
+ updateCustomer(input: $input) {
411
+ id
412
+ title
413
+ firstName
414
+ lastName
415
+ phoneNumber
416
+ }
417
+ }`;
418
+
419
+ const updateCustomerPasswordDocument = `mutation updateCustomerPassword($currentPassword: String!, $newPassword: String!) {
420
+ updateCustomerPassword(
421
+ currentPassword: $currentPassword
422
+ newPassword: $newPassword
423
+ ) {
424
+ ... on Success {
425
+ success
426
+ }
427
+ ... on InvalidCredentialsError {
428
+ errorCode
429
+ message
430
+ }
431
+ ... on PasswordValidationError {
432
+ errorCode
433
+ message
434
+ validationErrorMessage
435
+ }
436
+ ... on NativeAuthStrategyError {
437
+ errorCode
438
+ message
439
+ }
440
+ }
441
+ }`;
442
+
443
+ const updateCustomerEmailAddressDocument = `mutation updateCustomerEmailAddress($token: String!) {
444
+ updateCustomerEmailAddress(token: $token) {
445
+ ... on Success {
446
+ success
447
+ }
448
+ ... on IdentifierChangeTokenInvalidError {
449
+ errorCode
450
+ message
451
+ }
452
+ ... on IdentifierChangeTokenExpiredError {
453
+ errorCode
454
+ message
455
+ }
456
+ ... on NativeAuthStrategyError {
457
+ errorCode
458
+ message
459
+ }
460
+ }
461
+ }`;
462
+
463
+ const requestUpdateCustomerEmailAddressDocument = `mutation requestUpdateCustomerEmailAddress($password: String!, $newEmailAddress: String!) {
464
+ requestUpdateCustomerEmailAddress(
465
+ password: $password
466
+ newEmailAddress: $newEmailAddress
467
+ ) {
468
+ ... on Success {
469
+ success
470
+ }
471
+ ... on InvalidCredentialsError {
472
+ errorCode
473
+ message
474
+ }
475
+ ... on EmailAddressConflictError {
476
+ errorCode
477
+ message
478
+ }
479
+ ... on NativeAuthStrategyError {
480
+ errorCode
481
+ message
482
+ }
483
+ }
484
+ }`;
485
+
486
+ const requestPasswordResetDocument = `mutation requestPasswordReset($emailAddress: String!) {
487
+ requestPasswordReset(emailAddress: $emailAddress) {
488
+ ... on Success {
489
+ success
490
+ }
491
+ ... on NativeAuthStrategyError {
492
+ errorCode
493
+ message
494
+ }
495
+ }
496
+ }`;
497
+
498
+ const blogPostDocument = `query blogPost($slug: String!) {
499
+ blogPost(slug: $slug) {
500
+ id
501
+ name
502
+ title
503
+ slug
504
+ content
505
+ excerpt
506
+ author
507
+ isPublished
508
+ publishedAt
509
+ createdAt
510
+ updatedAt
511
+ featuredAsset {
512
+ id
513
+ name
514
+ preview
515
+ source
516
+ fileSize
517
+ mimeType
518
+ }
519
+ facetValues {
520
+ id
521
+ code
522
+ name
523
+ }
524
+ meta {
525
+ id
526
+ title
527
+ description
528
+ keywords
529
+ structuredData
530
+ }
531
+ }
532
+ }`;
533
+
534
+ const blogPostsDocument = `query blogPosts($options: BlogPostListOptions) {
535
+ blogPosts(options: $options) {
536
+ items {
537
+ id
538
+ name
539
+ title
540
+ slug
541
+ content
542
+ excerpt
543
+ author
544
+ isPublished
545
+ publishedAt
546
+ createdAt
547
+ updatedAt
548
+ featuredAsset {
549
+ id
550
+ name
551
+ preview
552
+ source
553
+ }
554
+ facetValues {
555
+ id
556
+ code
557
+ name
558
+ }
559
+ meta {
560
+ id
561
+ title
562
+ description
563
+ keywords
564
+ }
565
+ }
566
+ totalItems
567
+ }
568
+ }`;
569
+
570
+ const blogPostsByFacetsDocument = `query blogPostsByFacets($facetValueIds: [ID!]!) {
571
+ blogPostsByFacets(facetValueIds: $facetValueIds) {
572
+ items {
573
+ id
574
+ name
575
+ title
576
+ slug
577
+ content
578
+ excerpt
579
+ author
580
+ isPublished
581
+ publishedAt
582
+ createdAt
583
+ updatedAt
584
+ featuredAsset {
585
+ id
586
+ name
587
+ preview
588
+ source
589
+ }
590
+ facetValues {
591
+ id
592
+ code
593
+ name
594
+ }
595
+ meta {
596
+ id
597
+ title
598
+ description
599
+ keywords
600
+ }
601
+ }
602
+ totalItems
603
+ }
604
+ }`;
605
+
606
+ const activeChannelDocument = `query activeChannel {
607
+ activeChannel {
608
+ id
609
+ code
610
+ token
611
+ defaultLanguageCode
612
+ availableLanguageCodes
613
+ defaultCurrencyCode
614
+ availableCurrencyCodes
615
+ pricesIncludeTax
616
+ defaultShippingZone {
617
+ id
618
+ name
619
+ }
620
+ defaultTaxZone {
621
+ id
622
+ name
623
+ }
624
+ seller {
625
+ id
626
+ name
627
+ }
628
+ customFields
629
+ createdAt
630
+ updatedAt
631
+ }
632
+ }`;
633
+
634
+ const collectionDocument = `query collection($id: ID, $slug: String) {
635
+ collection(id: $id, slug: $slug) {
636
+ id
637
+ createdAt
638
+ updatedAt
639
+ languageCode
640
+ name
641
+ slug
642
+ description
643
+ position
644
+ parentId
645
+ breadcrumbs {
646
+ id
647
+ name
648
+ slug
649
+ }
650
+ featuredAsset {
651
+ id
652
+ name
653
+ preview
654
+ source
655
+ fileSize
656
+ mimeType
657
+ }
658
+ assets {
659
+ id
660
+ name
661
+ preview
662
+ source
663
+ }
664
+ parent {
665
+ id
666
+ name
667
+ slug
668
+ }
669
+ children {
670
+ id
671
+ name
672
+ slug
673
+ }
674
+ translations {
675
+ id
676
+ languageCode
677
+ name
678
+ slug
679
+ description
680
+ }
681
+ }
682
+ }`;
683
+
684
+ const collectionsDocument = `query collections($options: CollectionListOptions) {
685
+ collections(options: $options) {
686
+ items {
687
+ id
688
+ createdAt
689
+ updatedAt
690
+ languageCode
691
+ name
692
+ slug
693
+ description
694
+ position
695
+ parentId
696
+ breadcrumbs {
697
+ id
698
+ name
699
+ slug
700
+ }
701
+ featuredAsset {
702
+ id
703
+ name
704
+ preview
705
+ source
706
+ }
707
+ assets {
708
+ id
709
+ name
710
+ preview
711
+ source
712
+ }
713
+ parent {
714
+ id
715
+ name
716
+ slug
717
+ }
718
+ children {
719
+ id
720
+ name
721
+ slug
722
+ }
723
+ }
724
+ totalItems
725
+ }
726
+ }`;
727
+
728
+ const availableCountriesDocument = `query availableCountries {
729
+ availableCountries {
730
+ id
731
+ createdAt
732
+ updatedAt
733
+ languageCode
734
+ code
735
+ type
736
+ name
737
+ enabled
738
+ translations {
739
+ id
740
+ createdAt
741
+ updatedAt
742
+ languageCode
743
+ name
744
+ }
745
+ }
746
+ }`;
747
+
748
+ const getAllFieldsDocument = `query getAllFields($input: GetAllFieldsInput!) {
749
+ getAllFields(input: $input) {
750
+ ... on BooleanFieldDefinition {
751
+ __typename
752
+ id
753
+ fieldName
754
+ title
755
+ description
756
+ required
757
+ sortOrder
758
+ template
759
+ }
760
+ ... on DateFieldDefinition {
761
+ __typename
762
+ id
763
+ fieldName
764
+ title
765
+ description
766
+ required
767
+ sortOrder
768
+ template
769
+ }
770
+ ... on FloatFieldDefinition {
771
+ __typename
772
+ id
773
+ fieldName
774
+ title
775
+ description
776
+ required
777
+ sortOrder
778
+ template
779
+ }
780
+ ... on GroupFieldDefinition {
781
+ __typename
782
+ id
783
+ fieldName
784
+ title
785
+ description
786
+ required
787
+ sortOrder
788
+ list
789
+ template
790
+ fields {
791
+ ... on BooleanFieldDefinition {
792
+ __typename
793
+ id
794
+ fieldName
795
+ title
796
+ }
797
+ ... on StringFieldDefinition {
798
+ __typename
799
+ id
800
+ fieldName
801
+ title
802
+ }
803
+ ... on IntegerFieldDefinition {
804
+ __typename
805
+ id
806
+ fieldName
807
+ title
808
+ }
809
+ }
810
+ }
811
+ ... on IntegerFieldDefinition {
812
+ __typename
813
+ id
814
+ fieldName
815
+ title
816
+ description
817
+ required
818
+ sortOrder
819
+ template
820
+ }
821
+ ... on RelationFieldDefinition {
822
+ __typename
823
+ id
824
+ fieldName
825
+ title
826
+ description
827
+ required
828
+ sortOrder
829
+ relatedEntityName
830
+ template
831
+ }
832
+ ... on RichTextFieldDefinition {
833
+ __typename
834
+ id
835
+ fieldName
836
+ title
837
+ description
838
+ required
839
+ sortOrder
840
+ template
841
+ }
842
+ ... on StringFieldDefinition {
843
+ __typename
844
+ id
845
+ fieldName
846
+ title
847
+ description
848
+ required
849
+ sortOrder
850
+ defaultValue
851
+ maxLength
852
+ template
853
+ }
854
+ }
855
+ }`;
856
+
857
+ const getAllValuesDocument = `query getAllValues($input: GetAllValuesInput!) {
858
+ getAllValues(input: $input) {
859
+ ... on BooleanValue {
860
+ __typename
861
+ id
862
+ template
863
+ booleanValue: value
864
+ field {
865
+ id
866
+ fieldName
867
+ title
868
+ }
869
+ }
870
+ ... on DateValue {
871
+ __typename
872
+ id
873
+ template
874
+ dateValue: value
875
+ field {
876
+ id
877
+ fieldName
878
+ title
879
+ }
880
+ }
881
+ ... on FloatValue {
882
+ __typename
883
+ id
884
+ template
885
+ floatValue: value
886
+ field {
887
+ id
888
+ fieldName
889
+ title
890
+ }
891
+ }
892
+ ... on IntegerValue {
893
+ __typename
894
+ id
895
+ template
896
+ integerValue: value
897
+ field {
898
+ id
899
+ fieldName
900
+ title
901
+ }
902
+ }
903
+ ... on RelationValue {
904
+ __typename
905
+ id
906
+ template
907
+ relationValue: value
908
+ entity
909
+ field {
910
+ id
911
+ fieldName
912
+ title
913
+ relatedEntityName
914
+ }
915
+ }
916
+ ... on RichTextValue {
917
+ __typename
918
+ id
919
+ template
920
+ richTextValue: value
921
+ field {
922
+ id
923
+ fieldName
924
+ title
925
+ }
926
+ }
927
+ ... on StringValue {
928
+ __typename
929
+ id
930
+ template
931
+ stringValue: value
932
+ field {
933
+ id
934
+ fieldName
935
+ title
936
+ }
937
+ }
938
+ ... on GroupValue {
939
+ __typename
940
+ id
941
+ template
942
+ field {
943
+ id
944
+ fieldName
945
+ title
946
+ }
947
+ members {
948
+ id
949
+ sortOrder
950
+ value {
951
+ ... on BooleanValue {
952
+ __typename
953
+ id
954
+ booleanValue: value
955
+ }
956
+ ... on StringValue {
957
+ __typename
958
+ id
959
+ stringValue: value
960
+ }
961
+ ... on IntegerValue {
962
+ __typename
963
+ id
964
+ integerValue: value
965
+ }
966
+ }
967
+ }
968
+ }
969
+ }
970
+ }`;
971
+
972
+ const getBooleanValueDocument = `query getBooleanValue($input: GetBooleanValueInput!) {
973
+ getBooleanValue(input: $input) {
974
+ id
975
+ template
976
+ value
977
+ field {
978
+ id
979
+ fieldName
980
+ title
981
+ description
982
+ required
983
+ sortOrder
984
+ template
985
+ }
986
+ }
987
+ }`;
988
+
989
+ const getDateValueDocument = `query getDateValue($input: GetDateValueInput!) {
990
+ getDateValue(input: $input) {
991
+ id
992
+ template
993
+ value
994
+ field {
995
+ id
996
+ fieldName
997
+ title
998
+ description
999
+ required
1000
+ sortOrder
1001
+ template
1002
+ }
1003
+ }
1004
+ }`;
1005
+
1006
+ const getFloatValueDocument = `query getFloatValue($input: GetFloatValueInput!) {
1007
+ getFloatValue(input: $input) {
1008
+ id
1009
+ template
1010
+ value
1011
+ field {
1012
+ id
1013
+ fieldName
1014
+ title
1015
+ description
1016
+ required
1017
+ sortOrder
1018
+ template
1019
+ }
1020
+ }
1021
+ }`;
1022
+
1023
+ const getGroupFieldDefinitionByIdDocument = `query getGroupFieldDefinitionById($id: String!) {
1024
+ getGroupFieldDefinitionById(id: $id) {
1025
+ id
1026
+ fieldName
1027
+ title
1028
+ description
1029
+ required
1030
+ sortOrder
1031
+ list
1032
+ template
1033
+ fields {
1034
+ ... on BooleanFieldDefinition {
1035
+ __typename
1036
+ id
1037
+ fieldName
1038
+ title
1039
+ description
1040
+ required
1041
+ sortOrder
1042
+ }
1043
+ ... on DateFieldDefinition {
1044
+ __typename
1045
+ id
1046
+ fieldName
1047
+ title
1048
+ description
1049
+ required
1050
+ sortOrder
1051
+ }
1052
+ ... on FloatFieldDefinition {
1053
+ __typename
1054
+ id
1055
+ fieldName
1056
+ title
1057
+ description
1058
+ required
1059
+ sortOrder
1060
+ }
1061
+ ... on IntegerFieldDefinition {
1062
+ __typename
1063
+ id
1064
+ fieldName
1065
+ title
1066
+ description
1067
+ required
1068
+ sortOrder
1069
+ }
1070
+ ... on RelationFieldDefinition {
1071
+ __typename
1072
+ id
1073
+ fieldName
1074
+ title
1075
+ description
1076
+ required
1077
+ sortOrder
1078
+ relatedEntityName
1079
+ }
1080
+ ... on RichTextFieldDefinition {
1081
+ __typename
1082
+ id
1083
+ fieldName
1084
+ title
1085
+ description
1086
+ required
1087
+ sortOrder
1088
+ }
1089
+ ... on StringFieldDefinition {
1090
+ __typename
1091
+ id
1092
+ fieldName
1093
+ title
1094
+ description
1095
+ required
1096
+ sortOrder
1097
+ defaultValue
1098
+ maxLength
1099
+ }
1100
+ }
1101
+ }
1102
+ }`;
1103
+
1104
+ const getGroupValueDocument = `query getGroupValue($input: GetGroupValueInput!) {
1105
+ getGroupValue(input: $input) {
1106
+ id
1107
+ template
1108
+ field {
1109
+ id
1110
+ fieldName
1111
+ title
1112
+ description
1113
+ required
1114
+ sortOrder
1115
+ list
1116
+ template
1117
+ fields {
1118
+ ... on BooleanFieldDefinition {
1119
+ __typename
1120
+ id
1121
+ fieldName
1122
+ title
1123
+ }
1124
+ ... on StringFieldDefinition {
1125
+ __typename
1126
+ id
1127
+ fieldName
1128
+ title
1129
+ }
1130
+ ... on IntegerFieldDefinition {
1131
+ __typename
1132
+ id
1133
+ fieldName
1134
+ title
1135
+ }
1136
+ }
1137
+ }
1138
+ members {
1139
+ id
1140
+ sortOrder
1141
+ value {
1142
+ ... on BooleanValue {
1143
+ __typename
1144
+ id
1145
+ booleanValue: value
1146
+ field {
1147
+ id
1148
+ fieldName
1149
+ title
1150
+ }
1151
+ }
1152
+ ... on DateValue {
1153
+ __typename
1154
+ id
1155
+ dateValue: value
1156
+ field {
1157
+ id
1158
+ fieldName
1159
+ title
1160
+ }
1161
+ }
1162
+ ... on FloatValue {
1163
+ __typename
1164
+ id
1165
+ floatValue: value
1166
+ field {
1167
+ id
1168
+ fieldName
1169
+ title
1170
+ }
1171
+ }
1172
+ ... on IntegerValue {
1173
+ __typename
1174
+ id
1175
+ integerValue: value
1176
+ field {
1177
+ id
1178
+ fieldName
1179
+ title
1180
+ }
1181
+ }
1182
+ ... on RelationValue {
1183
+ __typename
1184
+ id
1185
+ relationValue: value
1186
+ entity
1187
+ field {
1188
+ id
1189
+ fieldName
1190
+ title
1191
+ }
1192
+ }
1193
+ ... on RichTextValue {
1194
+ __typename
1195
+ id
1196
+ richTextValue: value
1197
+ field {
1198
+ id
1199
+ fieldName
1200
+ title
1201
+ }
1202
+ }
1203
+ ... on StringValue {
1204
+ __typename
1205
+ id
1206
+ stringValue: value
1207
+ field {
1208
+ id
1209
+ fieldName
1210
+ title
1211
+ }
1212
+ }
1213
+ }
1214
+ }
1215
+ }
1216
+ }`;
1217
+
1218
+ const getIntegerValueDocument = `query getIntegerValue($input: GetIntegerValueInput!) {
1219
+ getIntegerValue(input: $input) {
1220
+ id
1221
+ template
1222
+ value
1223
+ field {
1224
+ id
1225
+ fieldName
1226
+ title
1227
+ description
1228
+ required
1229
+ sortOrder
1230
+ template
1231
+ }
1232
+ }
1233
+ }`;
1234
+
1235
+ const getRelationValueDocument = `query getRelationValue($input: GetRelationValueInput!) {
1236
+ getRelationValue(input: $input) {
1237
+ id
1238
+ template
1239
+ value
1240
+ entity
1241
+ field {
1242
+ id
1243
+ fieldName
1244
+ title
1245
+ description
1246
+ required
1247
+ sortOrder
1248
+ relatedEntityName
1249
+ template
1250
+ }
1251
+ }
1252
+ }`;
1253
+
1254
+ const getRichTextValueDocument = `query getRichTextValue($input: GetRichTextValueInput!) {
1255
+ getRichTextValue(input: $input) {
1256
+ id
1257
+ template
1258
+ value
1259
+ field {
1260
+ id
1261
+ fieldName
1262
+ title
1263
+ description
1264
+ required
1265
+ sortOrder
1266
+ template
1267
+ }
1268
+ }
1269
+ }`;
1270
+
1271
+ const getStringValueDocument = `query getStringValue($input: GetStringValueInput!) {
1272
+ getStringValue(input: $input) {
1273
+ id
1274
+ template
1275
+ value
1276
+ field {
1277
+ id
1278
+ fieldName
1279
+ title
1280
+ description
1281
+ required
1282
+ sortOrder
1283
+ defaultValue
1284
+ maxLength
1285
+ template
1286
+ }
1287
+ }
1288
+ }`;
1289
+
1290
+ const getTemplatesByEntityIdDocument = `query getTemplatesByEntityId($entityId: String!) {
1291
+ getTemplatesByEntityId(entityId: $entityId)
1292
+ }`;
1293
+
1294
+ const getUniqueTemplatesDocument = `query getUniqueTemplates($entityName: String!) {
1295
+ getUniqueTemplates(entityName: $entityName)
1296
+ }`;
1297
+
1298
+ const createCustomerAddressDocument = `mutation createCustomerAddress($input: CreateAddressInput!) {
1299
+ createCustomerAddress(input: $input) {
1300
+ id
1301
+ createdAt
1302
+ updatedAt
1303
+ fullName
1304
+ company
1305
+ streetLine1
1306
+ streetLine2
1307
+ city
1308
+ province
1309
+ postalCode
1310
+ country {
1311
+ id
1312
+ code
1313
+ name
1314
+ }
1315
+ phoneNumber
1316
+ defaultShippingAddress
1317
+ defaultBillingAddress
1318
+ }
1319
+ }`;
1320
+
1321
+ const updateCustomerAddressDocument = `mutation updateCustomerAddress($input: UpdateAddressInput!) {
1322
+ updateCustomerAddress(input: $input) {
1323
+ id
1324
+ createdAt
1325
+ updatedAt
1326
+ fullName
1327
+ company
1328
+ streetLine1
1329
+ streetLine2
1330
+ city
1331
+ province
1332
+ postalCode
1333
+ country {
1334
+ id
1335
+ code
1336
+ name
1337
+ }
1338
+ phoneNumber
1339
+ defaultShippingAddress
1340
+ defaultBillingAddress
1341
+ }
1342
+ }`;
1343
+
1344
+ const deleteCustomerAddressDocument = `mutation deleteCustomerAddress($id: ID!) {
1345
+ deleteCustomerAddress(id: $id) {
1346
+ success
1347
+ }
1348
+ }`;
1349
+
1350
+ const facetDocument = `query facet($id: ID!) {
1351
+ facet(id: $id) {
1352
+ id
1353
+ createdAt
1354
+ updatedAt
1355
+ languageCode
1356
+ name
1357
+ code
1358
+ translations {
1359
+ id
1360
+ languageCode
1361
+ name
1362
+ }
1363
+ values {
1364
+ id
1365
+ createdAt
1366
+ updatedAt
1367
+ languageCode
1368
+ name
1369
+ code
1370
+ facetId
1371
+ translations {
1372
+ id
1373
+ languageCode
1374
+ name
1375
+ }
1376
+ }
1377
+ valueList {
1378
+ items {
1379
+ id
1380
+ createdAt
1381
+ updatedAt
1382
+ languageCode
1383
+ name
1384
+ code
1385
+ facetId
1386
+ translations {
1387
+ id
1388
+ languageCode
1389
+ name
1390
+ }
1391
+ }
1392
+ totalItems
1393
+ }
1394
+ }
1395
+ }`;
1396
+
1397
+ const facetsDocument = `query facets($options: FacetListOptions) {
1398
+ facets(options: $options) {
1399
+ items {
1400
+ id
1401
+ createdAt
1402
+ updatedAt
1403
+ languageCode
1404
+ name
1405
+ code
1406
+ translations {
1407
+ id
1408
+ languageCode
1409
+ name
1410
+ }
1411
+ values {
1412
+ id
1413
+ code
1414
+ name
1415
+ }
1416
+ }
1417
+ totalItems
1418
+ }
1419
+ }`;
1420
+
1421
+ const getOnboardingDocument = `query getOnboarding($customerId: ID!) {
1422
+ getOnboarding(customerId: $customerId) {
1423
+ id
1424
+ countryCode
1425
+ zip
1426
+ city
1427
+ address
1428
+ state
1429
+ resolveUrl
1430
+ }
1431
+ }`;
1432
+
1433
+ const createOnboardingDocument = `mutation createOnboarding($input: OnboardingCreateInput!) {
1434
+ createOnboarding(input: $input) {
1435
+ id
1436
+ countryCode
1437
+ zip
1438
+ city
1439
+ address
1440
+ state
1441
+ resolveUrl
1442
+ }
1443
+ }`;
1444
+
1445
+ const updateOnboardingDocument = `mutation updateOnboarding($input: OnboardingUpdateInput!) {
1446
+ updateOnboarding(input: $input) {
1447
+ id
1448
+ countryCode
1449
+ zip
1450
+ city
1451
+ address
1452
+ state
1453
+ resolveUrl
1454
+ }
1455
+ }`;
1456
+
1457
+ const activeOrderDocument = `query activeOrder {
1458
+ activeOrder {
1459
+ id
1460
+ code
1461
+ state
1462
+ active
1463
+ createdAt
1464
+ updatedAt
1465
+ orderPlacedAt
1466
+ currencyCode
1467
+ totalQuantity
1468
+ subTotal
1469
+ subTotalWithTax
1470
+ shipping
1471
+ shippingWithTax
1472
+ total
1473
+ totalWithTax
1474
+ couponCodes
1475
+ discounts {
1476
+ adjustmentSource
1477
+ type
1478
+ description
1479
+ amount
1480
+ amountWithTax
1481
+ }
1482
+ promotions {
1483
+ id
1484
+ name
1485
+ }
1486
+ lines {
1487
+ id
1488
+ quantity
1489
+ linePrice
1490
+ linePriceWithTax
1491
+ unitPrice
1492
+ unitPriceWithTax
1493
+ productVariant {
1494
+ id
1495
+ name
1496
+ sku
1497
+ price
1498
+ priceWithTax
1499
+ }
1500
+ }
1501
+ shippingLines {
1502
+ id
1503
+ priceWithTax
1504
+ shippingMethod {
1505
+ id
1506
+ code
1507
+ name
1508
+ }
1509
+ }
1510
+ customer {
1511
+ id
1512
+ firstName
1513
+ lastName
1514
+ emailAddress
1515
+ }
1516
+ shippingAddress {
1517
+ fullName
1518
+ streetLine1
1519
+ streetLine2
1520
+ city
1521
+ province
1522
+ postalCode
1523
+ country
1524
+ phoneNumber
1525
+ }
1526
+ billingAddress {
1527
+ fullName
1528
+ streetLine1
1529
+ streetLine2
1530
+ city
1531
+ province
1532
+ postalCode
1533
+ country
1534
+ phoneNumber
1535
+ }
1536
+ payments {
1537
+ id
1538
+ amount
1539
+ method
1540
+ state
1541
+ transactionId
1542
+ }
1543
+ }
1544
+ }`;
1545
+
1546
+ const orderDocument = `query order($id: ID!) {
1547
+ order(id: $id) {
1548
+ id
1549
+ code
1550
+ state
1551
+ active
1552
+ createdAt
1553
+ updatedAt
1554
+ orderPlacedAt
1555
+ currencyCode
1556
+ totalQuantity
1557
+ subTotal
1558
+ subTotalWithTax
1559
+ shipping
1560
+ shippingWithTax
1561
+ total
1562
+ totalWithTax
1563
+ couponCodes
1564
+ taxSummary {
1565
+ description
1566
+ taxRate
1567
+ taxBase
1568
+ taxTotal
1569
+ }
1570
+ discounts {
1571
+ adjustmentSource
1572
+ type
1573
+ description
1574
+ amount
1575
+ amountWithTax
1576
+ }
1577
+ promotions {
1578
+ id
1579
+ name
1580
+ }
1581
+ lines {
1582
+ id
1583
+ quantity
1584
+ linePrice
1585
+ linePriceWithTax
1586
+ unitPrice
1587
+ unitPriceWithTax
1588
+ productVariant {
1589
+ id
1590
+ name
1591
+ sku
1592
+ price
1593
+ priceWithTax
1594
+ }
1595
+ }
1596
+ shippingLines {
1597
+ id
1598
+ priceWithTax
1599
+ shippingMethod {
1600
+ id
1601
+ code
1602
+ name
1603
+ description
1604
+ }
1605
+ }
1606
+ customer {
1607
+ id
1608
+ firstName
1609
+ lastName
1610
+ emailAddress
1611
+ phoneNumber
1612
+ }
1613
+ shippingAddress {
1614
+ fullName
1615
+ streetLine1
1616
+ streetLine2
1617
+ city
1618
+ province
1619
+ postalCode
1620
+ country
1621
+ phoneNumber
1622
+ }
1623
+ billingAddress {
1624
+ fullName
1625
+ streetLine1
1626
+ streetLine2
1627
+ city
1628
+ province
1629
+ postalCode
1630
+ country
1631
+ phoneNumber
1632
+ }
1633
+ payments {
1634
+ id
1635
+ amount
1636
+ method
1637
+ state
1638
+ transactionId
1639
+ metadata
1640
+ }
1641
+ }
1642
+ }`;
1643
+
1644
+ const orderByCodeDocument = `query orderByCode($code: String!) {
1645
+ orderByCode(code: $code) {
1646
+ id
1647
+ code
1648
+ state
1649
+ active
1650
+ type
1651
+ createdAt
1652
+ updatedAt
1653
+ orderPlacedAt
1654
+ currencyCode
1655
+ totalQuantity
1656
+ subTotal
1657
+ subTotalWithTax
1658
+ shipping
1659
+ shippingWithTax
1660
+ total
1661
+ totalWithTax
1662
+ couponCodes
1663
+ taxSummary {
1664
+ description
1665
+ taxRate
1666
+ taxBase
1667
+ taxTotal
1668
+ }
1669
+ discounts {
1670
+ adjustmentSource
1671
+ type
1672
+ description
1673
+ amount
1674
+ amountWithTax
1675
+ }
1676
+ promotions {
1677
+ id
1678
+ name
1679
+ }
1680
+ surcharges {
1681
+ id
1682
+ description
1683
+ sku
1684
+ price
1685
+ priceWithTax
1686
+ }
1687
+ lines {
1688
+ id
1689
+ quantity
1690
+ linePrice
1691
+ linePriceWithTax
1692
+ productVariant {
1693
+ id
1694
+ name
1695
+ sku
1696
+ }
1697
+ }
1698
+ shippingLines {
1699
+ id
1700
+ priceWithTax
1701
+ shippingMethod {
1702
+ id
1703
+ code
1704
+ name
1705
+ }
1706
+ }
1707
+ customer {
1708
+ id
1709
+ firstName
1710
+ lastName
1711
+ emailAddress
1712
+ }
1713
+ shippingAddress {
1714
+ fullName
1715
+ streetLine1
1716
+ city
1717
+ postalCode
1718
+ country
1719
+ }
1720
+ billingAddress {
1721
+ fullName
1722
+ streetLine1
1723
+ city
1724
+ postalCode
1725
+ country
1726
+ }
1727
+ payments {
1728
+ id
1729
+ amount
1730
+ method
1731
+ state
1732
+ }
1733
+ fulfillments {
1734
+ id
1735
+ state
1736
+ method
1737
+ trackingCode
1738
+ }
1739
+ history {
1740
+ items {
1741
+ id
1742
+ type
1743
+ data
1744
+ createdAt
1745
+ }
1746
+ }
1747
+ }
1748
+ }`;
1749
+
1750
+ const nextOrderStatesDocument = `query nextOrderStates {
1751
+ nextOrderStates
1752
+ }`;
1753
+
1754
+ const addItemToOrderDocument = `mutation addItemToOrder($productVariantId: ID!, $quantity: Int!) {
1755
+ addItemToOrder(productVariantId: $productVariantId, quantity: $quantity) {
1756
+ ... on Order {
1757
+ __typename
1758
+ id
1759
+ code
1760
+ state
1761
+ totalQuantity
1762
+ subTotal
1763
+ subTotalWithTax
1764
+ total
1765
+ totalWithTax
1766
+ lines {
1767
+ id
1768
+ quantity
1769
+ linePrice
1770
+ linePriceWithTax
1771
+ productVariant {
1772
+ id
1773
+ name
1774
+ sku
1775
+ price
1776
+ }
1777
+ }
1778
+ }
1779
+ ... on OrderModificationError {
1780
+ __typename
1781
+ errorCode
1782
+ message
1783
+ }
1784
+ ... on OrderLimitError {
1785
+ __typename
1786
+ errorCode
1787
+ message
1788
+ maxItems
1789
+ }
1790
+ ... on NegativeQuantityError {
1791
+ __typename
1792
+ errorCode
1793
+ message
1794
+ }
1795
+ ... on InsufficientStockError {
1796
+ __typename
1797
+ errorCode
1798
+ message
1799
+ quantityAvailable
1800
+ }
1801
+ ... on OrderInterceptorError {
1802
+ __typename
1803
+ errorCode
1804
+ message
1805
+ }
1806
+ }
1807
+ }`;
1808
+
1809
+ const adjustOrderLineDocument = `mutation adjustOrderLine($orderLineId: ID!, $quantity: Int!) {
1810
+ adjustOrderLine(orderLineId: $orderLineId, quantity: $quantity) {
1811
+ ... on Order {
1812
+ __typename
1813
+ id
1814
+ code
1815
+ totalQuantity
1816
+ subTotal
1817
+ subTotalWithTax
1818
+ total
1819
+ totalWithTax
1820
+ lines {
1821
+ id
1822
+ quantity
1823
+ linePrice
1824
+ linePriceWithTax
1825
+ productVariant {
1826
+ id
1827
+ name
1828
+ }
1829
+ }
1830
+ }
1831
+ ... on OrderModificationError {
1832
+ __typename
1833
+ errorCode
1834
+ message
1835
+ }
1836
+ ... on OrderLimitError {
1837
+ __typename
1838
+ errorCode
1839
+ message
1840
+ maxItems
1841
+ }
1842
+ ... on NegativeQuantityError {
1843
+ __typename
1844
+ errorCode
1845
+ message
1846
+ }
1847
+ ... on InsufficientStockError {
1848
+ __typename
1849
+ errorCode
1850
+ message
1851
+ quantityAvailable
1852
+ }
1853
+ ... on OrderInterceptorError {
1854
+ __typename
1855
+ errorCode
1856
+ message
1857
+ }
1858
+ }
1859
+ }`;
1860
+
1861
+ const removeOrderLineDocument = `mutation removeOrderLine($orderLineId: ID!) {
1862
+ removeOrderLine(orderLineId: $orderLineId) {
1863
+ ... on Order {
1864
+ __typename
1865
+ id
1866
+ code
1867
+ totalQuantity
1868
+ subTotal
1869
+ total
1870
+ totalWithTax
1871
+ lines {
1872
+ id
1873
+ quantity
1874
+ }
1875
+ }
1876
+ ... on OrderModificationError {
1877
+ __typename
1878
+ errorCode
1879
+ message
1880
+ }
1881
+ ... on OrderInterceptorError {
1882
+ __typename
1883
+ errorCode
1884
+ message
1885
+ }
1886
+ }
1887
+ }`;
1888
+
1889
+ const removeAllOrderLinesDocument = `mutation removeAllOrderLines {
1890
+ removeAllOrderLines {
1891
+ ... on Order {
1892
+ __typename
1893
+ id
1894
+ code
1895
+ totalQuantity
1896
+ total
1897
+ totalWithTax
1898
+ lines {
1899
+ id
1900
+ }
1901
+ }
1902
+ ... on OrderModificationError {
1903
+ __typename
1904
+ errorCode
1905
+ message
1906
+ }
1907
+ ... on OrderInterceptorError {
1908
+ __typename
1909
+ errorCode
1910
+ message
1911
+ }
1912
+ }
1913
+ }`;
1914
+
1915
+ const applyCouponCodeDocument = `mutation applyCouponCode($couponCode: String!) {
1916
+ applyCouponCode(couponCode: $couponCode) {
1917
+ ... on Order {
1918
+ __typename
1919
+ id
1920
+ code
1921
+ couponCodes
1922
+ subTotal
1923
+ subTotalWithTax
1924
+ total
1925
+ totalWithTax
1926
+ discounts {
1927
+ type
1928
+ description
1929
+ amount
1930
+ amountWithTax
1931
+ }
1932
+ promotions {
1933
+ id
1934
+ name
1935
+ }
1936
+ }
1937
+ ... on CouponCodeExpiredError {
1938
+ __typename
1939
+ errorCode
1940
+ message
1941
+ couponCode
1942
+ }
1943
+ ... on CouponCodeInvalidError {
1944
+ __typename
1945
+ errorCode
1946
+ message
1947
+ couponCode
1948
+ }
1949
+ ... on CouponCodeLimitError {
1950
+ __typename
1951
+ errorCode
1952
+ message
1953
+ couponCode
1954
+ limit
1955
+ }
1956
+ }
1957
+ }`;
1958
+
1959
+ const removeCouponCodeDocument = `mutation removeCouponCode($couponCode: String!) {
1960
+ removeCouponCode(couponCode: $couponCode) {
1961
+ id
1962
+ code
1963
+ couponCodes
1964
+ subTotal
1965
+ total
1966
+ totalWithTax
1967
+ discounts {
1968
+ type
1969
+ description
1970
+ amount
1971
+ }
1972
+ }
1973
+ }`;
1974
+
1975
+ const setOrderShippingAddressDocument = `mutation setOrderShippingAddress($input: CreateAddressInput!) {
1976
+ setOrderShippingAddress(input: $input) {
1977
+ ... on Order {
1978
+ __typename
1979
+ id
1980
+ code
1981
+ shippingAddress {
1982
+ fullName
1983
+ streetLine1
1984
+ streetLine2
1985
+ city
1986
+ province
1987
+ postalCode
1988
+ country
1989
+ phoneNumber
1990
+ }
1991
+ }
1992
+ ... on NoActiveOrderError {
1993
+ __typename
1994
+ errorCode
1995
+ message
1996
+ }
1997
+ }
1998
+ }`;
1999
+
2000
+ const unsetOrderShippingAddressDocument = `mutation unsetOrderShippingAddress {
2001
+ unsetOrderShippingAddress {
2002
+ ... on Order {
2003
+ __typename
2004
+ id
2005
+ code
2006
+ shippingAddress {
2007
+ fullName
2008
+ streetLine1
2009
+ city
2010
+ }
2011
+ }
2012
+ ... on NoActiveOrderError {
2013
+ __typename
2014
+ errorCode
2015
+ message
2016
+ }
2017
+ }
2018
+ }`;
2019
+
2020
+ const setOrderBillingAddressDocument = `mutation setOrderBillingAddress($input: CreateAddressInput!) {
2021
+ setOrderBillingAddress(input: $input) {
2022
+ ... on Order {
2023
+ __typename
2024
+ id
2025
+ code
2026
+ billingAddress {
2027
+ fullName
2028
+ streetLine1
2029
+ streetLine2
2030
+ city
2031
+ province
2032
+ postalCode
2033
+ country
2034
+ phoneNumber
2035
+ }
2036
+ }
2037
+ ... on NoActiveOrderError {
2038
+ __typename
2039
+ errorCode
2040
+ message
2041
+ }
2042
+ }
2043
+ }`;
2044
+
2045
+ const unsetOrderBillingAddressDocument = `mutation unsetOrderBillingAddress {
2046
+ unsetOrderBillingAddress {
2047
+ ... on Order {
2048
+ __typename
2049
+ id
2050
+ code
2051
+ billingAddress {
2052
+ fullName
2053
+ streetLine1
2054
+ city
2055
+ }
2056
+ }
2057
+ ... on NoActiveOrderError {
2058
+ __typename
2059
+ errorCode
2060
+ message
2061
+ }
2062
+ }
2063
+ }`;
2064
+
2065
+ const eligibleShippingMethodsDocument = `query eligibleShippingMethods {
2066
+ eligibleShippingMethods {
2067
+ id
2068
+ name
2069
+ code
2070
+ description
2071
+ price
2072
+ priceWithTax
2073
+ metadata
2074
+ }
2075
+ }`;
2076
+
2077
+ const activeShippingMethodsDocument = `query activeShippingMethods {
2078
+ activeShippingMethods {
2079
+ id
2080
+ code
2081
+ name
2082
+ description
2083
+ translations {
2084
+ id
2085
+ languageCode
2086
+ name
2087
+ description
2088
+ }
2089
+ }
2090
+ }`;
2091
+
2092
+ const setOrderShippingMethodDocument = `mutation setOrderShippingMethod($shippingMethodId: [ID!]!) {
2093
+ setOrderShippingMethod(shippingMethodId: $shippingMethodId) {
2094
+ ... on Order {
2095
+ __typename
2096
+ id
2097
+ code
2098
+ shipping
2099
+ shippingWithTax
2100
+ total
2101
+ totalWithTax
2102
+ shippingLines {
2103
+ id
2104
+ priceWithTax
2105
+ shippingMethod {
2106
+ id
2107
+ code
2108
+ name
2109
+ }
2110
+ }
2111
+ }
2112
+ ... on OrderModificationError {
2113
+ __typename
2114
+ errorCode
2115
+ message
2116
+ }
2117
+ ... on IneligibleShippingMethodError {
2118
+ __typename
2119
+ errorCode
2120
+ message
2121
+ }
2122
+ ... on NoActiveOrderError {
2123
+ __typename
2124
+ errorCode
2125
+ message
2126
+ }
2127
+ }
2128
+ }`;
2129
+
2130
+ const eligiblePaymentMethodsDocument = `query eligiblePaymentMethods {
2131
+ eligiblePaymentMethods {
2132
+ id
2133
+ code
2134
+ name
2135
+ description
2136
+ isEligible
2137
+ eligibilityMessage
2138
+ }
2139
+ }`;
2140
+
2141
+ const activePaymentMethodsDocument = `query activePaymentMethods {
2142
+ activePaymentMethods {
2143
+ id
2144
+ code
2145
+ name
2146
+ description
2147
+ translations {
2148
+ id
2149
+ languageCode
2150
+ name
2151
+ description
2152
+ }
2153
+ }
2154
+ }`;
2155
+
2156
+ const addPaymentToOrderDocument = `mutation addPaymentToOrder($input: PaymentInput!) {
2157
+ addPaymentToOrder(input: $input) {
2158
+ ... on Order {
2159
+ __typename
2160
+ id
2161
+ code
2162
+ state
2163
+ active
2164
+ total
2165
+ totalWithTax
2166
+ payments {
2167
+ id
2168
+ amount
2169
+ method
2170
+ state
2171
+ transactionId
2172
+ metadata
2173
+ }
2174
+ }
2175
+ ... on OrderPaymentStateError {
2176
+ __typename
2177
+ errorCode
2178
+ message
2179
+ }
2180
+ ... on IneligiblePaymentMethodError {
2181
+ __typename
2182
+ errorCode
2183
+ message
2184
+ eligibilityCheckerMessage
2185
+ }
2186
+ ... on PaymentFailedError {
2187
+ __typename
2188
+ errorCode
2189
+ message
2190
+ paymentErrorMessage
2191
+ }
2192
+ ... on PaymentDeclinedError {
2193
+ __typename
2194
+ errorCode
2195
+ message
2196
+ paymentErrorMessage
2197
+ }
2198
+ ... on OrderStateTransitionError {
2199
+ __typename
2200
+ errorCode
2201
+ message
2202
+ transitionError
2203
+ fromState
2204
+ toState
2205
+ }
2206
+ ... on NoActiveOrderError {
2207
+ __typename
2208
+ errorCode
2209
+ message
2210
+ }
2211
+ }
2212
+ }`;
2213
+
2214
+ const transitionOrderToStateDocument = `mutation transitionOrderToState($state: String!) {
2215
+ transitionOrderToState(state: $state) {
2216
+ ... on Order {
2217
+ __typename
2218
+ id
2219
+ code
2220
+ state
2221
+ active
2222
+ }
2223
+ ... on OrderStateTransitionError {
2224
+ __typename
2225
+ errorCode
2226
+ message
2227
+ transitionError
2228
+ fromState
2229
+ toState
2230
+ }
2231
+ }
2232
+ }`;
2233
+
2234
+ const setCustomerForOrderDocument = `mutation setCustomerForOrder($input: CreateCustomerInput!) {
2235
+ setCustomerForOrder(input: $input) {
2236
+ ... on Order {
2237
+ __typename
2238
+ id
2239
+ code
2240
+ customer {
2241
+ id
2242
+ firstName
2243
+ lastName
2244
+ emailAddress
2245
+ phoneNumber
2246
+ }
2247
+ }
2248
+ ... on AlreadyLoggedInError {
2249
+ __typename
2250
+ errorCode
2251
+ message
2252
+ }
2253
+ ... on EmailAddressConflictError {
2254
+ __typename
2255
+ errorCode
2256
+ message
2257
+ }
2258
+ ... on NoActiveOrderError {
2259
+ __typename
2260
+ errorCode
2261
+ message
2262
+ }
2263
+ ... on GuestCheckoutError {
2264
+ __typename
2265
+ errorCode
2266
+ message
2267
+ errorDetail
2268
+ }
2269
+ }
2270
+ }`;
2271
+
2272
+ const setOrderCustomFieldsDocument = `mutation setOrderCustomFields($input: UpdateOrderInput!) {
2273
+ setOrderCustomFields(input: $input) {
2274
+ ... on Order {
2275
+ __typename
2276
+ id
2277
+ code
2278
+ }
2279
+ ... on NoActiveOrderError {
2280
+ __typename
2281
+ errorCode
2282
+ message
2283
+ }
2284
+ }
2285
+ }`;
2286
+
2287
+ const productsDocument = `query products($options: ProductListOptions) {
2288
+ products(options: $options) {
2289
+ items {
2290
+ id
2291
+ name
2292
+ slug
2293
+ description
2294
+ featuredAsset {
2295
+ id
2296
+ preview
2297
+ }
2298
+ variants {
2299
+ id
2300
+ name
2301
+ sku
2302
+ price
2303
+ priceWithTax
2304
+ stockLevel
2305
+ }
2306
+ }
2307
+ totalItems
2308
+ }
2309
+ }`;
2310
+
2311
+ const productDocument = `query product($id: ID, $slug: String) {
2312
+ product(id: $id, slug: $slug) {
2313
+ id
2314
+ name
2315
+ slug
2316
+ description
2317
+ enabled
2318
+ createdAt
2319
+ updatedAt
2320
+ languageCode
2321
+ customFields
2322
+ featuredAsset {
2323
+ id
2324
+ preview
2325
+ source
2326
+ }
2327
+ assets {
2328
+ id
2329
+ preview
2330
+ source
2331
+ }
2332
+ variants {
2333
+ id
2334
+ name
2335
+ sku
2336
+ price
2337
+ priceWithTax
2338
+ stockLevel
2339
+ options {
2340
+ id
2341
+ name
2342
+ code
2343
+ }
2344
+ }
2345
+ optionGroups {
2346
+ id
2347
+ name
2348
+ code
2349
+ options {
2350
+ id
2351
+ name
2352
+ code
2353
+ }
2354
+ }
2355
+ facetValues {
2356
+ id
2357
+ name
2358
+ code
2359
+ }
2360
+ collections {
2361
+ id
2362
+ name
2363
+ slug
2364
+ }
2365
+ translations {
2366
+ id
2367
+ languageCode
2368
+ name
2369
+ slug
2370
+ description
2371
+ }
2372
+ variantList {
2373
+ items {
2374
+ id
2375
+ name
2376
+ sku
2377
+ }
2378
+ totalItems
2379
+ }
2380
+ }
2381
+ }`;
2382
+
2383
+ const searchDocument = `query search($input: SearchInput!) {
2384
+ search(input: $input) {
2385
+ totalItems
2386
+ items {
2387
+ productId
2388
+ productName
2389
+ productVariantId
2390
+ productVariantName
2391
+ sku
2392
+ slug
2393
+ description
2394
+ productAsset {
2395
+ id
2396
+ preview
2397
+ focalPoint {
2398
+ x
2399
+ y
2400
+ }
2401
+ }
2402
+ productVariantAsset {
2403
+ id
2404
+ preview
2405
+ focalPoint {
2406
+ x
2407
+ y
2408
+ }
2409
+ }
2410
+ price {
2411
+ ... on SinglePrice {
2412
+ __typename
2413
+ value
2414
+ }
2415
+ ... on PriceRange {
2416
+ __typename
2417
+ min
2418
+ max
2419
+ }
2420
+ }
2421
+ priceWithTax {
2422
+ ... on SinglePrice {
2423
+ __typename
2424
+ value
2425
+ }
2426
+ ... on PriceRange {
2427
+ __typename
2428
+ min
2429
+ max
2430
+ }
2431
+ }
2432
+ currencyCode
2433
+ facetIds
2434
+ facetValueIds
2435
+ collectionIds
2436
+ score
2437
+ }
2438
+ facetValues {
2439
+ count
2440
+ facetValue {
2441
+ id
2442
+ name
2443
+ code
2444
+ }
2445
+ }
2446
+ collections {
2447
+ count
2448
+ collection {
2449
+ id
2450
+ name
2451
+ slug
2452
+ description
2453
+ parentId
2454
+ position
2455
+ createdAt
2456
+ updatedAt
2457
+ languageCode
2458
+ featuredAsset {
2459
+ id
2460
+ preview
2461
+ }
2462
+ breadcrumbs {
2463
+ id
2464
+ name
2465
+ slug
2466
+ }
2467
+ parent {
2468
+ id
2469
+ name
2470
+ }
2471
+ children {
2472
+ id
2473
+ name
2474
+ }
2475
+ }
2476
+ }
2477
+ }
2478
+ }`;
2479
+
2480
+ /**
2481
+ * Base GraphQL Client
2482
+ * Uses WebSocket as primary layer with HTTP fallback
2483
+ * Handles queries, mutations, and subscriptions over WebSocket when available
2484
+ */
2485
+ class BaseGraphQLClient {
2486
+ private httpClient: GraphQLClient;
2487
+ private wsClient: WSClient | null = null;
2488
+ private wsConnected: boolean = false;
2489
+ private wsInitializing: Promise<void> | null = null;
2490
+ private isDisposing: boolean = false;
2491
+ private authToken: string | null = null;
2492
+ private endpoint: string;
2493
+ private wsEndpoint: string;
2494
+ private config: SDKConfig;
2495
+
2496
+ constructor(config: SDKConfig) {
2497
+ this.endpoint = config.endpoint || 'https://api.forgecart.com/shop-api';
2498
+ this.wsEndpoint = config.wsEndpoint || 'wss://api.forgecart.com/shop-api';
2499
+ this.config = config;
2500
+
2501
+ // Initialize HTTP client (as fallback)
2502
+ this.httpClient = new GraphQLClient(this.endpoint, {
2503
+ headers: config.headers || {},
2504
+ });
2505
+
2506
+ // Initialize WebSocket connection immediately
2507
+ this.initializeWebSocket();
2508
+ }
2509
+
2510
+ /**
2511
+ * Execute a GraphQL query or mutation
2512
+ * Uses WebSocket if available, falls back to HTTP
2513
+ */
2514
+ async request<T = unknown, V extends Variables = Variables>(
2515
+ document: RequestDocument,
2516
+ variables?: V
2517
+ ): Promise<T> {
2518
+
2519
+ // Try WebSocket first if available
2520
+ if (this.wsClient && this.wsConnected) {
2521
+ try {
2522
+ return await this.requestViaWebSocket<T>(document, variables);
2523
+ } catch (wsError) {
2524
+ console.warn('WebSocket request failed, falling back to HTTP:', wsError);
2525
+ // Fall through to HTTP
2526
+ }
2527
+ }
2528
+
2529
+
2530
+ // Use HTTP as fallback or when WebSocket is not available
2531
+ try {
2532
+ return await this.httpClient.request<T>(document, variables);
2533
+ } catch (error) {
2534
+ this.handleError(error);
2535
+ throw error;
2536
+ }
2537
+ }
2538
+
2539
+
2540
+ /**
2541
+ * Execute request via WebSocket
2542
+ * @private
2543
+ */
2544
+ private async requestViaWebSocket<T = unknown>(
2545
+ document: RequestDocument,
2546
+ variables?: Variables
2547
+ ): Promise<T> {
2548
+ if (!this.wsClient) {
2549
+ throw new Error('WebSocket client not initialized');
2550
+ }
2551
+
2552
+ return new Promise<T>((resolve, reject) => {
2553
+ const unsubscribe = this.wsClient!.subscribe(
2554
+ {
2555
+ query: document as string,
2556
+ variables,
2557
+ },
2558
+ {
2559
+ next: (result) => {
2560
+ if (result.errors) {
2561
+ reject(new Error(result.errors.map(e => e.message).join(', ')));
2562
+ } else {
2563
+ resolve(result.data as T);
2564
+ }
2565
+ unsubscribe();
2566
+ },
2567
+ error: (error) => {
2568
+ reject(error);
2569
+ unsubscribe();
2570
+ },
2571
+ complete: () => {
2572
+ unsubscribe();
2573
+ },
2574
+ }
2575
+ );
2576
+ });
2577
+ }
2578
+
2579
+
2580
+
2581
+ /**
2582
+ * Handle GraphQL errors
2583
+ */
2584
+ private handleError(error: any): void {
2585
+ console.error('GraphQL Error:', error);
2586
+ }
2587
+
2588
+
2589
+ /**
2590
+ * Get WebSocket implementation for current environment
2591
+ */
2592
+ private getWebSocketImpl(): any {
2593
+ // Use custom implementation if provided
2594
+ if (this.config.webSocketImpl) {
2595
+ return this.config.webSocketImpl;
2596
+ }
2597
+
2598
+ // Browser environment (native WebSocket)
2599
+ if (typeof WebSocket !== 'undefined') {
2600
+ return WebSocket;
2601
+ }
2602
+
2603
+ // Node.js environment (try to import 'ws' package)
2604
+ try {
2605
+ // Dynamic import for Node.js
2606
+ return require('ws');
2607
+ } catch (e) {
2608
+ console.warn('WebSocket not available. Install "ws" package for Node.js support or provide webSocketImpl in config.');
2609
+ return undefined;
2610
+ }
2611
+ }
2612
+
2613
+ /**
2614
+ * Initialize WebSocket client
2615
+ * Connects immediately and tracks connection state
2616
+ */
2617
+ private initializeWebSocket(): void {
2618
+ // Prevent multiple simultaneous initializations
2619
+ if (this.wsClient || this.wsInitializing) {
2620
+ return;
2621
+ }
2622
+
2623
+ const WebSocketImpl = this.getWebSocketImpl();
2624
+ if (!WebSocketImpl) {
2625
+ console.warn('WebSocket not available. Will use HTTP fallback only.');
2626
+ return;
2627
+ }
2628
+
2629
+ this.wsInitializing = new Promise<void>((resolve, reject) => {
2630
+ let isResolved = false;
2631
+
2632
+ try {
2633
+ const wsOptions: WSClientOptions = {
2634
+ url: this.wsEndpoint,
2635
+ webSocketImpl: WebSocketImpl,
2636
+ lazy: false, // Connect immediately
2637
+ keepAlive: 10_000, // Send keep-alive pings every 10 seconds
2638
+ connectionParams: async () => {
2639
+ try {
2640
+ return this.authToken ? { Authorization: `Bearer ${this.authToken}` } : {};
2641
+ } catch (error) {
2642
+ console.error('Error in connectionParams:', error);
2643
+ return {};
2644
+ }
2645
+ },
2646
+ retryAttempts: Infinity, // Keep retrying
2647
+ shouldRetry: () => true,
2648
+ retryWait: async (retries) => {
2649
+ // Exponential backoff: 1s, 2s, 4s, 8s, max 30s
2650
+ await new Promise(resolve => setTimeout(resolve, Math.min(1000 * Math.pow(2, retries), 30000)));
2651
+ },
2652
+ on: {
2653
+ connected: () => {
2654
+ this.wsConnected = true;
2655
+ console.log('WebSocket connected');
2656
+ if (!isResolved) {
2657
+ isResolved = true;
2658
+ resolve();
2659
+ }
2660
+ },
2661
+ closed: () => {
2662
+ this.wsConnected = false;
2663
+ if (!this.isDisposing) {
2664
+ console.log('WebSocket disconnected');
2665
+ }
2666
+ },
2667
+ error: (error) => {
2668
+ // Suppress errors during disposal - they're expected
2669
+ if (!this.isDisposing && this.wsConnected) {
2670
+ console.error('WebSocket error:', error);
2671
+ }
2672
+ // Don't fail the connection on errors - let retry logic handle it
2673
+ // Only log errors if we're connected (unexpected errors)
2674
+ this.wsConnected = false;
2675
+ },
2676
+ },
2677
+ };
2678
+
2679
+ this.wsClient = createClient(wsOptions);
2680
+ this.wsInitializing = null;
2681
+ } catch (error) {
2682
+ console.error('Failed to create WebSocket client:', error);
2683
+ this.wsInitializing = null;
2684
+ // Resolve anyway to not block - we'll fallback to HTTP
2685
+ if (!isResolved) {
2686
+ isResolved = true;
2687
+ resolve();
2688
+ }
2689
+ }
2690
+ });
2691
+ }
2692
+
2693
+ /**
2694
+ * Subscribe to a GraphQL subscription
2695
+ */
2696
+ subscribe<T = unknown>(
2697
+ document: RequestDocument,
2698
+ variables?: Variables
2699
+ ): AsyncIterableIterator<T> {
2700
+ if (!this.wsClient) {
2701
+ throw new Error('WebSocket client not available. Cannot create subscription.');
2702
+ }
2703
+
2704
+ const subscription = this.wsClient.iterate({
2705
+ query: document as string,
2706
+ variables,
2707
+ });
2708
+
2709
+ const iterator: AsyncIterableIterator<T> = {
2710
+ async next() {
2711
+ const result = await subscription.next();
2712
+ if (result.done) {
2713
+ return { done: true, value: undefined as any };
2714
+ }
2715
+ if (result.value.errors) {
2716
+ throw new Error(result.value.errors.map(e => e.message).join(', '));
2717
+ }
2718
+ return { done: false, value: result.value.data as T };
2719
+ },
2720
+ async return() {
2721
+ subscription.return?.();
2722
+ return { done: true, value: undefined as any };
2723
+ },
2724
+ async throw(error: any) {
2725
+ subscription.throw?.(error);
2726
+ return { done: true, value: undefined as any };
2727
+ },
2728
+ [Symbol.asyncIterator]() {
2729
+ return this;
2730
+ },
2731
+ };
2732
+
2733
+ return iterator;
2734
+ }
2735
+
2736
+
2737
+ /**
2738
+ * Set authentication token
2739
+ * Updates both HTTP and WebSocket connections
2740
+ */
2741
+ setAuthToken(token: string): void {
2742
+ this.authToken = token;
2743
+ this.httpClient.setHeader('Authorization', `Bearer ${token}`);
2744
+
2745
+ // Reconnect WebSocket with new token
2746
+ if (this.wsClient) {
2747
+ this.wsConnected = false;
2748
+ this.wsClient.dispose();
2749
+ this.wsClient = null;
2750
+ this.wsInitializing = null;
2751
+ // Reinitialize with new token
2752
+ this.initializeWebSocket();
2753
+ }
2754
+ }
2755
+
2756
+ /**
2757
+ * Clear authentication token
2758
+ * Updates both HTTP and WebSocket connections
2759
+ */
2760
+ clearAuthToken(): void {
2761
+ this.authToken = null;
2762
+ this.httpClient.setHeader('Authorization', '');
2763
+
2764
+ // Reconnect WebSocket without token
2765
+ if (this.wsClient) {
2766
+ this.wsConnected = false;
2767
+ this.wsClient.dispose();
2768
+ this.wsClient = null;
2769
+ this.wsInitializing = null;
2770
+ // Reinitialize without token
2771
+ this.initializeWebSocket();
2772
+ }
2773
+ }
2774
+
2775
+ /**
2776
+ * Dispose of the client and close all connections
2777
+ */
2778
+ dispose(): void {
2779
+ this.isDisposing = true;
2780
+ if (this.wsClient) {
2781
+ this.wsConnected = false;
2782
+ this.wsClient.dispose();
2783
+ this.wsClient = null;
2784
+ this.wsInitializing = null;
2785
+ }
2786
+ }
2787
+ }
2788
+
2789
+ /**
2790
+ * Asset operations
2791
+ */
2792
+ class AssetOperations {
2793
+ constructor(private client: BaseGraphQLClient) {}
2794
+
2795
+ /**
2796
+ * asset query
2797
+ */
2798
+ async asset(variables: Types.AssetQueryVariables): Promise<Types.AssetQuery> {
2799
+ return await this.client.request<Types.AssetQuery>(assetDocument, variables);
2800
+ }
2801
+
2802
+ /**
2803
+ * assets query
2804
+ */
2805
+ async assets(variables: Types.AssetsQueryVariables): Promise<Types.AssetsQuery> {
2806
+ return await this.client.request<Types.AssetsQuery>(assetsDocument, variables);
2807
+ }
2808
+ }
2809
+
2810
+ /**
2811
+ * Auth operations
2812
+ */
2813
+ class AuthOperations {
2814
+ constructor(private client: BaseGraphQLClient) {}
2815
+
2816
+ /**
2817
+ * me query
2818
+ */
2819
+ async me(): Promise<Types.MeQuery> {
2820
+ return await this.client.request<Types.MeQuery>(meDocument);
2821
+ }
2822
+
2823
+ /**
2824
+ * authenticate mutation
2825
+ */
2826
+ async authenticate(variables: Types.AuthenticateMutationVariables): Promise<Types.AuthenticateMutation> {
2827
+ return await this.client.request<Types.AuthenticateMutation>(authenticateDocument, variables);
2828
+ }
2829
+
2830
+ /**
2831
+ * generateOtp mutation
2832
+ */
2833
+ async generateOtp(variables: Types.GenerateOtpMutationVariables): Promise<Types.GenerateOtpMutation> {
2834
+ return await this.client.request<Types.GenerateOtpMutation>(generateOtpDocument, variables);
2835
+ }
2836
+
2837
+ /**
2838
+ * verifyOtp mutation
2839
+ */
2840
+ async verifyOtp(variables: Types.VerifyOtpMutationVariables): Promise<Types.VerifyOtpMutation> {
2841
+ return await this.client.request<Types.VerifyOtpMutation>(verifyOtpDocument, variables);
2842
+ }
2843
+
2844
+ /**
2845
+ * registerCustomerAccount mutation
2846
+ */
2847
+ async registerCustomerAccount(variables: Types.RegisterCustomerAccountMutationVariables): Promise<Types.RegisterCustomerAccountMutation> {
2848
+ return await this.client.request<Types.RegisterCustomerAccountMutation>(registerCustomerAccountDocument, variables);
2849
+ }
2850
+
2851
+ /**
2852
+ * verifyCustomerAccount mutation
2853
+ */
2854
+ async verifyCustomerAccount(variables: Types.VerifyCustomerAccountMutationVariables): Promise<Types.VerifyCustomerAccountMutation> {
2855
+ return await this.client.request<Types.VerifyCustomerAccountMutation>(verifyCustomerAccountDocument, variables);
2856
+ }
2857
+
2858
+ /**
2859
+ * refreshCustomerVerification mutation
2860
+ */
2861
+ async refreshCustomerVerification(variables: Types.RefreshCustomerVerificationMutationVariables): Promise<Types.RefreshCustomerVerificationMutation> {
2862
+ return await this.client.request<Types.RefreshCustomerVerificationMutation>(refreshCustomerVerificationDocument, variables);
2863
+ }
2864
+
2865
+ /**
2866
+ * updateCustomer mutation
2867
+ */
2868
+ async updateCustomer(variables: Types.UpdateCustomerMutationVariables): Promise<Types.UpdateCustomerMutation> {
2869
+ return await this.client.request<Types.UpdateCustomerMutation>(updateCustomerDocument, variables);
2870
+ }
2871
+
2872
+ /**
2873
+ * updateCustomerPassword mutation
2874
+ */
2875
+ async updateCustomerPassword(variables: Types.UpdateCustomerPasswordMutationVariables): Promise<Types.UpdateCustomerPasswordMutation> {
2876
+ return await this.client.request<Types.UpdateCustomerPasswordMutation>(updateCustomerPasswordDocument, variables);
2877
+ }
2878
+
2879
+ /**
2880
+ * updateCustomerEmailAddress mutation
2881
+ */
2882
+ async updateCustomerEmailAddress(variables: Types.UpdateCustomerEmailAddressMutationVariables): Promise<Types.UpdateCustomerEmailAddressMutation> {
2883
+ return await this.client.request<Types.UpdateCustomerEmailAddressMutation>(updateCustomerEmailAddressDocument, variables);
2884
+ }
2885
+
2886
+ /**
2887
+ * requestUpdateCustomerEmailAddress mutation
2888
+ */
2889
+ async requestUpdateCustomerEmailAddress(variables: Types.RequestUpdateCustomerEmailAddressMutationVariables): Promise<Types.RequestUpdateCustomerEmailAddressMutation> {
2890
+ return await this.client.request<Types.RequestUpdateCustomerEmailAddressMutation>(requestUpdateCustomerEmailAddressDocument, variables);
2891
+ }
2892
+
2893
+ /**
2894
+ * requestPasswordReset mutation
2895
+ */
2896
+ async requestPasswordReset(variables: Types.RequestPasswordResetMutationVariables): Promise<Types.RequestPasswordResetMutation> {
2897
+ return await this.client.request<Types.RequestPasswordResetMutation>(requestPasswordResetDocument, variables);
2898
+ }
2899
+ }
2900
+
2901
+ /**
2902
+ * Blog operations
2903
+ */
2904
+ class BlogOperations {
2905
+ constructor(private client: BaseGraphQLClient) {}
2906
+
2907
+ /**
2908
+ * blogPost query
2909
+ */
2910
+ async blogPost(variables: Types.BlogPostQueryVariables): Promise<Types.BlogPostQuery> {
2911
+ return await this.client.request<Types.BlogPostQuery>(blogPostDocument, variables);
2912
+ }
2913
+
2914
+ /**
2915
+ * blogPosts query
2916
+ */
2917
+ async blogPosts(variables: Types.BlogPostsQueryVariables): Promise<Types.BlogPostsQuery> {
2918
+ return await this.client.request<Types.BlogPostsQuery>(blogPostsDocument, variables);
2919
+ }
2920
+
2921
+ /**
2922
+ * blogPostsByFacets query
2923
+ */
2924
+ async blogPostsByFacets(variables: Types.BlogPostsByFacetsQueryVariables): Promise<Types.BlogPostsByFacetsQuery> {
2925
+ return await this.client.request<Types.BlogPostsByFacetsQuery>(blogPostsByFacetsDocument, variables);
2926
+ }
2927
+ }
2928
+
2929
+ /**
2930
+ * Channel operations
2931
+ */
2932
+ class ChannelOperations {
2933
+ constructor(private client: BaseGraphQLClient) {}
2934
+
2935
+ /**
2936
+ * activeChannel query
2937
+ */
2938
+ async activeChannel(): Promise<Types.ActiveChannelQuery> {
2939
+ return await this.client.request<Types.ActiveChannelQuery>(activeChannelDocument);
2940
+ }
2941
+ }
2942
+
2943
+ /**
2944
+ * Collection operations
2945
+ */
2946
+ class CollectionOperations {
2947
+ constructor(private client: BaseGraphQLClient) {}
2948
+
2949
+ /**
2950
+ * collection query
2951
+ */
2952
+ async collection(variables: Types.CollectionQueryVariables): Promise<Types.CollectionQuery> {
2953
+ return await this.client.request<Types.CollectionQuery>(collectionDocument, variables);
2954
+ }
2955
+
2956
+ /**
2957
+ * collections query
2958
+ */
2959
+ async collections(variables: Types.CollectionsQueryVariables): Promise<Types.CollectionsQuery> {
2960
+ return await this.client.request<Types.CollectionsQuery>(collectionsDocument, variables);
2961
+ }
2962
+ }
2963
+
2964
+ /**
2965
+ * Country operations
2966
+ */
2967
+ class CountryOperations {
2968
+ constructor(private client: BaseGraphQLClient) {}
2969
+
2970
+ /**
2971
+ * availableCountries query
2972
+ */
2973
+ async availableCountries(): Promise<Types.AvailableCountriesQuery> {
2974
+ return await this.client.request<Types.AvailableCountriesQuery>(availableCountriesDocument);
2975
+ }
2976
+ }
2977
+
2978
+ /**
2979
+ * CustomFields operations
2980
+ */
2981
+ class CustomFieldsOperations {
2982
+ constructor(private client: BaseGraphQLClient) {}
2983
+
2984
+ /**
2985
+ * getAllFields query
2986
+ */
2987
+ async getAllFields(variables: Types.GetAllFieldsQueryVariables): Promise<Types.GetAllFieldsQuery> {
2988
+ return await this.client.request<Types.GetAllFieldsQuery>(getAllFieldsDocument, variables);
2989
+ }
2990
+
2991
+ /**
2992
+ * getAllValues query
2993
+ */
2994
+ async getAllValues(variables: Types.GetAllValuesQueryVariables): Promise<Types.GetAllValuesQuery> {
2995
+ return await this.client.request<Types.GetAllValuesQuery>(getAllValuesDocument, variables);
2996
+ }
2997
+
2998
+ /**
2999
+ * getBooleanValue query
3000
+ */
3001
+ async getBooleanValue(variables: Types.GetBooleanValueQueryVariables): Promise<Types.GetBooleanValueQuery> {
3002
+ return await this.client.request<Types.GetBooleanValueQuery>(getBooleanValueDocument, variables);
3003
+ }
3004
+
3005
+ /**
3006
+ * getDateValue query
3007
+ */
3008
+ async getDateValue(variables: Types.GetDateValueQueryVariables): Promise<Types.GetDateValueQuery> {
3009
+ return await this.client.request<Types.GetDateValueQuery>(getDateValueDocument, variables);
3010
+ }
3011
+
3012
+ /**
3013
+ * getFloatValue query
3014
+ */
3015
+ async getFloatValue(variables: Types.GetFloatValueQueryVariables): Promise<Types.GetFloatValueQuery> {
3016
+ return await this.client.request<Types.GetFloatValueQuery>(getFloatValueDocument, variables);
3017
+ }
3018
+
3019
+ /**
3020
+ * getGroupFieldDefinitionById query
3021
+ */
3022
+ async getGroupFieldDefinitionById(variables: Types.GetGroupFieldDefinitionByIdQueryVariables): Promise<Types.GetGroupFieldDefinitionByIdQuery> {
3023
+ return await this.client.request<Types.GetGroupFieldDefinitionByIdQuery>(getGroupFieldDefinitionByIdDocument, variables);
3024
+ }
3025
+
3026
+ /**
3027
+ * getGroupValue query
3028
+ */
3029
+ async getGroupValue(variables: Types.GetGroupValueQueryVariables): Promise<Types.GetGroupValueQuery> {
3030
+ return await this.client.request<Types.GetGroupValueQuery>(getGroupValueDocument, variables);
3031
+ }
3032
+
3033
+ /**
3034
+ * getIntegerValue query
3035
+ */
3036
+ async getIntegerValue(variables: Types.GetIntegerValueQueryVariables): Promise<Types.GetIntegerValueQuery> {
3037
+ return await this.client.request<Types.GetIntegerValueQuery>(getIntegerValueDocument, variables);
3038
+ }
3039
+
3040
+ /**
3041
+ * getRelationValue query
3042
+ */
3043
+ async getRelationValue(variables: Types.GetRelationValueQueryVariables): Promise<Types.GetRelationValueQuery> {
3044
+ return await this.client.request<Types.GetRelationValueQuery>(getRelationValueDocument, variables);
3045
+ }
3046
+
3047
+ /**
3048
+ * getRichTextValue query
3049
+ */
3050
+ async getRichTextValue(variables: Types.GetRichTextValueQueryVariables): Promise<Types.GetRichTextValueQuery> {
3051
+ return await this.client.request<Types.GetRichTextValueQuery>(getRichTextValueDocument, variables);
3052
+ }
3053
+
3054
+ /**
3055
+ * getStringValue query
3056
+ */
3057
+ async getStringValue(variables: Types.GetStringValueQueryVariables): Promise<Types.GetStringValueQuery> {
3058
+ return await this.client.request<Types.GetStringValueQuery>(getStringValueDocument, variables);
3059
+ }
3060
+
3061
+ /**
3062
+ * getTemplatesByEntityId query
3063
+ */
3064
+ async getTemplatesByEntityId(variables: Types.GetTemplatesByEntityIdQueryVariables): Promise<Types.GetTemplatesByEntityIdQuery> {
3065
+ return await this.client.request<Types.GetTemplatesByEntityIdQuery>(getTemplatesByEntityIdDocument, variables);
3066
+ }
3067
+
3068
+ /**
3069
+ * getUniqueTemplates query
3070
+ */
3071
+ async getUniqueTemplates(variables: Types.GetUniqueTemplatesQueryVariables): Promise<Types.GetUniqueTemplatesQuery> {
3072
+ return await this.client.request<Types.GetUniqueTemplatesQuery>(getUniqueTemplatesDocument, variables);
3073
+ }
3074
+ }
3075
+
3076
+ /**
3077
+ * Customer operations
3078
+ */
3079
+ class CustomerOperations {
3080
+ constructor(private client: BaseGraphQLClient) {}
3081
+
3082
+ /**
3083
+ * createCustomerAddress mutation
3084
+ */
3085
+ async createCustomerAddress(variables: Types.CreateCustomerAddressMutationVariables): Promise<Types.CreateCustomerAddressMutation> {
3086
+ return await this.client.request<Types.CreateCustomerAddressMutation>(createCustomerAddressDocument, variables);
3087
+ }
3088
+
3089
+ /**
3090
+ * updateCustomerAddress mutation
3091
+ */
3092
+ async updateCustomerAddress(variables: Types.UpdateCustomerAddressMutationVariables): Promise<Types.UpdateCustomerAddressMutation> {
3093
+ return await this.client.request<Types.UpdateCustomerAddressMutation>(updateCustomerAddressDocument, variables);
3094
+ }
3095
+
3096
+ /**
3097
+ * deleteCustomerAddress mutation
3098
+ */
3099
+ async deleteCustomerAddress(variables: Types.DeleteCustomerAddressMutationVariables): Promise<Types.DeleteCustomerAddressMutation> {
3100
+ return await this.client.request<Types.DeleteCustomerAddressMutation>(deleteCustomerAddressDocument, variables);
3101
+ }
3102
+ }
3103
+
3104
+ /**
3105
+ * Facet operations
3106
+ */
3107
+ class FacetOperations {
3108
+ constructor(private client: BaseGraphQLClient) {}
3109
+
3110
+ /**
3111
+ * facet query
3112
+ */
3113
+ async facet(variables: Types.FacetQueryVariables): Promise<Types.FacetQuery> {
3114
+ return await this.client.request<Types.FacetQuery>(facetDocument, variables);
3115
+ }
3116
+
3117
+ /**
3118
+ * facets query
3119
+ */
3120
+ async facets(variables: Types.FacetsQueryVariables): Promise<Types.FacetsQuery> {
3121
+ return await this.client.request<Types.FacetsQuery>(facetsDocument, variables);
3122
+ }
3123
+ }
3124
+
3125
+ /**
3126
+ * Onboarding operations
3127
+ */
3128
+ class OnboardingOperations {
3129
+ constructor(private client: BaseGraphQLClient) {}
3130
+
3131
+ /**
3132
+ * getOnboarding query
3133
+ */
3134
+ async getOnboarding(variables: Types.GetOnboardingQueryVariables): Promise<Types.GetOnboardingQuery> {
3135
+ return await this.client.request<Types.GetOnboardingQuery>(getOnboardingDocument, variables);
3136
+ }
3137
+
3138
+ /**
3139
+ * createOnboarding mutation
3140
+ */
3141
+ async createOnboarding(variables: Types.CreateOnboardingMutationVariables): Promise<Types.CreateOnboardingMutation> {
3142
+ return await this.client.request<Types.CreateOnboardingMutation>(createOnboardingDocument, variables);
3143
+ }
3144
+
3145
+ /**
3146
+ * updateOnboarding mutation
3147
+ */
3148
+ async updateOnboarding(variables: Types.UpdateOnboardingMutationVariables): Promise<Types.UpdateOnboardingMutation> {
3149
+ return await this.client.request<Types.UpdateOnboardingMutation>(updateOnboardingDocument, variables);
3150
+ }
3151
+ }
3152
+
3153
+ /**
3154
+ * Order operations
3155
+ */
3156
+ class OrderOperations {
3157
+ constructor(private client: BaseGraphQLClient) {}
3158
+
3159
+ /**
3160
+ * activeOrder query
3161
+ */
3162
+ async activeOrder(): Promise<Types.ActiveOrderQuery> {
3163
+ return await this.client.request<Types.ActiveOrderQuery>(activeOrderDocument);
3164
+ }
3165
+
3166
+ /**
3167
+ * order query
3168
+ */
3169
+ async order(variables: Types.OrderQueryVariables): Promise<Types.OrderQuery> {
3170
+ return await this.client.request<Types.OrderQuery>(orderDocument, variables);
3171
+ }
3172
+
3173
+ /**
3174
+ * orderByCode query
3175
+ */
3176
+ async orderByCode(variables: Types.OrderByCodeQueryVariables): Promise<Types.OrderByCodeQuery> {
3177
+ return await this.client.request<Types.OrderByCodeQuery>(orderByCodeDocument, variables);
3178
+ }
3179
+
3180
+ /**
3181
+ * nextOrderStates query
3182
+ */
3183
+ async nextOrderStates(): Promise<Types.NextOrderStatesQuery> {
3184
+ return await this.client.request<Types.NextOrderStatesQuery>(nextOrderStatesDocument);
3185
+ }
3186
+
3187
+ /**
3188
+ * addItemToOrder mutation
3189
+ */
3190
+ async addItemToOrder(variables: Types.AddItemToOrderMutationVariables): Promise<Types.AddItemToOrderMutation> {
3191
+ return await this.client.request<Types.AddItemToOrderMutation>(addItemToOrderDocument, variables);
3192
+ }
3193
+
3194
+ /**
3195
+ * adjustOrderLine mutation
3196
+ */
3197
+ async adjustOrderLine(variables: Types.AdjustOrderLineMutationVariables): Promise<Types.AdjustOrderLineMutation> {
3198
+ return await this.client.request<Types.AdjustOrderLineMutation>(adjustOrderLineDocument, variables);
3199
+ }
3200
+
3201
+ /**
3202
+ * removeOrderLine mutation
3203
+ */
3204
+ async removeOrderLine(variables: Types.RemoveOrderLineMutationVariables): Promise<Types.RemoveOrderLineMutation> {
3205
+ return await this.client.request<Types.RemoveOrderLineMutation>(removeOrderLineDocument, variables);
3206
+ }
3207
+
3208
+ /**
3209
+ * removeAllOrderLines mutation
3210
+ */
3211
+ async removeAllOrderLines(): Promise<Types.RemoveAllOrderLinesMutation> {
3212
+ return await this.client.request<Types.RemoveAllOrderLinesMutation>(removeAllOrderLinesDocument);
3213
+ }
3214
+
3215
+ /**
3216
+ * applyCouponCode mutation
3217
+ */
3218
+ async applyCouponCode(variables: Types.ApplyCouponCodeMutationVariables): Promise<Types.ApplyCouponCodeMutation> {
3219
+ return await this.client.request<Types.ApplyCouponCodeMutation>(applyCouponCodeDocument, variables);
3220
+ }
3221
+
3222
+ /**
3223
+ * removeCouponCode mutation
3224
+ */
3225
+ async removeCouponCode(variables: Types.RemoveCouponCodeMutationVariables): Promise<Types.RemoveCouponCodeMutation> {
3226
+ return await this.client.request<Types.RemoveCouponCodeMutation>(removeCouponCodeDocument, variables);
3227
+ }
3228
+
3229
+ /**
3230
+ * setOrderShippingAddress mutation
3231
+ */
3232
+ async setOrderShippingAddress(variables: Types.SetOrderShippingAddressMutationVariables): Promise<Types.SetOrderShippingAddressMutation> {
3233
+ return await this.client.request<Types.SetOrderShippingAddressMutation>(setOrderShippingAddressDocument, variables);
3234
+ }
3235
+
3236
+ /**
3237
+ * unsetOrderShippingAddress mutation
3238
+ */
3239
+ async unsetOrderShippingAddress(): Promise<Types.UnsetOrderShippingAddressMutation> {
3240
+ return await this.client.request<Types.UnsetOrderShippingAddressMutation>(unsetOrderShippingAddressDocument);
3241
+ }
3242
+
3243
+ /**
3244
+ * setOrderBillingAddress mutation
3245
+ */
3246
+ async setOrderBillingAddress(variables: Types.SetOrderBillingAddressMutationVariables): Promise<Types.SetOrderBillingAddressMutation> {
3247
+ return await this.client.request<Types.SetOrderBillingAddressMutation>(setOrderBillingAddressDocument, variables);
3248
+ }
3249
+
3250
+ /**
3251
+ * unsetOrderBillingAddress mutation
3252
+ */
3253
+ async unsetOrderBillingAddress(): Promise<Types.UnsetOrderBillingAddressMutation> {
3254
+ return await this.client.request<Types.UnsetOrderBillingAddressMutation>(unsetOrderBillingAddressDocument);
3255
+ }
3256
+
3257
+ /**
3258
+ * eligibleShippingMethods query
3259
+ */
3260
+ async eligibleShippingMethods(): Promise<Types.EligibleShippingMethodsQuery> {
3261
+ return await this.client.request<Types.EligibleShippingMethodsQuery>(eligibleShippingMethodsDocument);
3262
+ }
3263
+
3264
+ /**
3265
+ * activeShippingMethods query
3266
+ */
3267
+ async activeShippingMethods(): Promise<Types.ActiveShippingMethodsQuery> {
3268
+ return await this.client.request<Types.ActiveShippingMethodsQuery>(activeShippingMethodsDocument);
3269
+ }
3270
+
3271
+ /**
3272
+ * setOrderShippingMethod mutation
3273
+ */
3274
+ async setOrderShippingMethod(variables: Types.SetOrderShippingMethodMutationVariables): Promise<Types.SetOrderShippingMethodMutation> {
3275
+ return await this.client.request<Types.SetOrderShippingMethodMutation>(setOrderShippingMethodDocument, variables);
3276
+ }
3277
+
3278
+ /**
3279
+ * eligiblePaymentMethods query
3280
+ */
3281
+ async eligiblePaymentMethods(): Promise<Types.EligiblePaymentMethodsQuery> {
3282
+ return await this.client.request<Types.EligiblePaymentMethodsQuery>(eligiblePaymentMethodsDocument);
3283
+ }
3284
+
3285
+ /**
3286
+ * activePaymentMethods query
3287
+ */
3288
+ async activePaymentMethods(): Promise<Types.ActivePaymentMethodsQuery> {
3289
+ return await this.client.request<Types.ActivePaymentMethodsQuery>(activePaymentMethodsDocument);
3290
+ }
3291
+
3292
+ /**
3293
+ * addPaymentToOrder mutation
3294
+ */
3295
+ async addPaymentToOrder(variables: Types.AddPaymentToOrderMutationVariables): Promise<Types.AddPaymentToOrderMutation> {
3296
+ return await this.client.request<Types.AddPaymentToOrderMutation>(addPaymentToOrderDocument, variables);
3297
+ }
3298
+
3299
+ /**
3300
+ * transitionOrderToState mutation
3301
+ */
3302
+ async transitionOrderToState(variables: Types.TransitionOrderToStateMutationVariables): Promise<Types.TransitionOrderToStateMutation> {
3303
+ return await this.client.request<Types.TransitionOrderToStateMutation>(transitionOrderToStateDocument, variables);
3304
+ }
3305
+
3306
+ /**
3307
+ * setCustomerForOrder mutation
3308
+ */
3309
+ async setCustomerForOrder(variables: Types.SetCustomerForOrderMutationVariables): Promise<Types.SetCustomerForOrderMutation> {
3310
+ return await this.client.request<Types.SetCustomerForOrderMutation>(setCustomerForOrderDocument, variables);
3311
+ }
3312
+
3313
+ /**
3314
+ * setOrderCustomFields mutation
3315
+ */
3316
+ async setOrderCustomFields(variables: Types.SetOrderCustomFieldsMutationVariables): Promise<Types.SetOrderCustomFieldsMutation> {
3317
+ return await this.client.request<Types.SetOrderCustomFieldsMutation>(setOrderCustomFieldsDocument, variables);
3318
+ }
3319
+ }
3320
+
3321
+ /**
3322
+ * Products operations
3323
+ */
3324
+ class ProductsOperations {
3325
+ constructor(private client: BaseGraphQLClient) {}
3326
+
3327
+ /**
3328
+ * products query
3329
+ */
3330
+ async products(variables: Types.ProductsQueryVariables): Promise<Types.ProductsQuery> {
3331
+ return await this.client.request<Types.ProductsQuery>(productsDocument, variables);
3332
+ }
3333
+
3334
+ /**
3335
+ * product query
3336
+ */
3337
+ async product(variables: Types.ProductQueryVariables): Promise<Types.ProductQuery> {
3338
+ return await this.client.request<Types.ProductQuery>(productDocument, variables);
3339
+ }
3340
+ }
3341
+
3342
+ /**
3343
+ * Search operations
3344
+ */
3345
+ class SearchOperations {
3346
+ constructor(private client: BaseGraphQLClient) {}
3347
+
3348
+ /**
3349
+ * search query
3350
+ */
3351
+ async search(variables: Types.SearchQueryVariables): Promise<Types.SearchQuery> {
3352
+ return await this.client.request<Types.SearchQuery>(searchDocument, variables);
3353
+ }
3354
+ }
3355
+
3356
+ /**
3357
+ * Shop namespace
3358
+ * Contains categorized operations for shop API
3359
+ */
3360
+ export class ShopNamespace {
3361
+ private client: BaseGraphQLClient;
3362
+
3363
+ readonly asset: AssetOperations;
3364
+ readonly auth: AuthOperations;
3365
+ readonly blog: BlogOperations;
3366
+ readonly channel: ChannelOperations;
3367
+ readonly collection: CollectionOperations;
3368
+ readonly country: CountryOperations;
3369
+ readonly customFields: CustomFieldsOperations;
3370
+ readonly customer: CustomerOperations;
3371
+ readonly facet: FacetOperations;
3372
+ readonly onboarding: OnboardingOperations;
3373
+ readonly order: OrderOperations;
3374
+ readonly products: ProductsOperations;
3375
+ readonly search: SearchOperations;
3376
+
3377
+ constructor(config: SDKConfig) {
3378
+ this.client = new BaseGraphQLClient(config);
3379
+
3380
+ this.asset = new AssetOperations(this.client);
3381
+ this.auth = new AuthOperations(this.client);
3382
+ this.blog = new BlogOperations(this.client);
3383
+ this.channel = new ChannelOperations(this.client);
3384
+ this.collection = new CollectionOperations(this.client);
3385
+ this.country = new CountryOperations(this.client);
3386
+ this.customFields = new CustomFieldsOperations(this.client);
3387
+ this.customer = new CustomerOperations(this.client);
3388
+ this.facet = new FacetOperations(this.client);
3389
+ this.onboarding = new OnboardingOperations(this.client);
3390
+ this.order = new OrderOperations(this.client);
3391
+ this.products = new ProductsOperations(this.client);
3392
+ this.search = new SearchOperations(this.client);
3393
+ }
3394
+
3395
+ /**
3396
+ * Set authentication token
3397
+ * Updates the client with the new token
3398
+ */
3399
+ setAuthToken(token: string): void {
3400
+ this.client.setAuthToken(token);
3401
+ }
3402
+
3403
+ /**
3404
+ * Clear authentication token
3405
+ */
3406
+ clearAuthToken(): void {
3407
+ this.client.clearAuthToken();
3408
+ }
3409
+
3410
+ /**
3411
+ * Dispose of the namespace and close all connections
3412
+ */
3413
+ dispose(): void {
3414
+ this.client.dispose();
3415
+ }
3416
+ }