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