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