@forgecart/sdk 1.2.5 → 1.2.6

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