@forgecart/sdk 1.2.2 → 1.2.3

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.
@@ -4,7 +4,7 @@
4
4
  * This file was automatically generated and should not be manually edited.
5
5
  * To regenerate, run: npm run codegen:ts
6
6
  *
7
- * Generated at: 2025-12-15T07:13:55.745Z
7
+ * Generated at: 2025-12-15T13:49:08.285Z
8
8
  * Generator version: 1.0.0
9
9
  *
10
10
  * 🤖 Generated with ForgeCart SDK Generator
@@ -25,6 +25,8 @@ export interface SDKConfig {
25
25
  webSocketImpl?: unknown;
26
26
  /** Use HTTP only, skip WebSocket initialization (default: false) */
27
27
  httpOnly?: boolean;
28
+ /** Enable debug logging with request timing (default: false) */
29
+ debug?: boolean;
28
30
  }
29
31
  export type ActiveAdministratorQueryVariables = Types.ActiveAdministratorQueryVariables;
30
32
  export type ActiveAdministratorQuery = Types.ActiveAdministratorQuery;
@@ -990,6 +992,10 @@ declare class BaseGraphQLClient {
990
992
  private wsEndpoint;
991
993
  private config;
992
994
  constructor(config: SDKConfig);
995
+ /**
996
+ * Extract operation name from GraphQL document
997
+ */
998
+ private getOperationName;
993
999
  /**
994
1000
  * Execute a GraphQL query or mutation
995
1001
  * Uses WebSocket if available, falls back to HTTP
@@ -5,7 +5,7 @@
5
5
  * This file was automatically generated and should not be manually edited.
6
6
  * To regenerate, run: npm run codegen:ts
7
7
  *
8
- * Generated at: 2025-12-15T07:13:55.745Z
8
+ * Generated at: 2025-12-15T13:49:08.285Z
9
9
  * Generator version: 1.0.0
10
10
  *
11
11
  * 🤖 Generated with ForgeCart SDK Generator
@@ -6914,26 +6914,50 @@ class BaseGraphQLClient {
6914
6914
  // Initialize WebSocket connection immediately
6915
6915
  this.initializeWebSocket();
6916
6916
  }
6917
+ /**
6918
+ * Extract operation name from GraphQL document
6919
+ */
6920
+ getOperationName(document) {
6921
+ const docString = typeof document === 'string' ? document : String(document);
6922
+ const match = docString.match(/(?:query|mutation|subscription)\s+(\w+)/);
6923
+ return match ? match[1] : 'UnknownOperation';
6924
+ }
6917
6925
  /**
6918
6926
  * Execute a GraphQL query or mutation
6919
6927
  * Uses WebSocket if available, falls back to HTTP
6920
6928
  */
6921
6929
  async request(document, variables) {
6930
+ const startTime = this.config.debug ? performance.now() : 0;
6931
+ const operationName = this.config.debug ? this.getOperationName(document) : '';
6932
+ let transport = 'HTTP';
6922
6933
  // Try WebSocket first if available
6923
6934
  if (this.wsClient && this.wsConnected) {
6924
6935
  try {
6925
- return await this.requestViaWebSocket(document, variables);
6936
+ transport = 'WebSocket';
6937
+ const result = await this.requestViaWebSocket(document, variables);
6938
+ if (this.config.debug) {
6939
+ console.log(`[ForgeCart SDK] ${operationName} (${transport}) - ${(performance.now() - startTime).toFixed(0)}ms`);
6940
+ }
6941
+ return result;
6926
6942
  }
6927
6943
  catch (wsError) {
6944
+ transport = 'WebSocket -> HTTP';
6928
6945
  console.warn('WebSocket request failed, falling back to HTTP:', wsError);
6929
6946
  // Fall through to HTTP
6930
6947
  }
6931
6948
  }
6932
6949
  // Use HTTP as fallback or when WebSocket is not available
6933
6950
  try {
6934
- return await this.httpClient.request(document, variables);
6951
+ const result = await this.httpClient.request(document, variables);
6952
+ if (this.config.debug) {
6953
+ console.log(`[ForgeCart SDK] ${operationName} (${transport}) - ${(performance.now() - startTime).toFixed(0)}ms`);
6954
+ }
6955
+ return result;
6935
6956
  }
6936
6957
  catch (error) {
6958
+ if (this.config.debug) {
6959
+ console.log(`[ForgeCart SDK] ${operationName} (${transport}) - FAILED after ${(performance.now() - startTime).toFixed(0)}ms`);
6960
+ }
6937
6961
  this.handleError(error);
6938
6962
  throw error;
6939
6963
  }
package/dist/index.d.ts CHANGED
@@ -18,6 +18,8 @@ export interface ForgeCartSDKConfig {
18
18
  token: string;
19
19
  /** Use HTTP only, skip WebSocket initialization (default: false) */
20
20
  httpOnly?: boolean;
21
+ /** Enable debug logging with request timing (default: false) */
22
+ debug?: boolean;
21
23
  /** Custom HTTP headers */
22
24
  headers?: Record<string, string>;
23
25
  /** Custom WebSocket implementation (optional, auto-detected if not provided) */
package/dist/index.js CHANGED
@@ -52,6 +52,7 @@ class ForgeCartSDK {
52
52
  headers,
53
53
  webSocketImpl: config.webSocketImpl,
54
54
  httpOnly: config.httpOnly,
55
+ debug: config.debug,
55
56
  };
56
57
  this.admin = new admin_js_1.AdminNamespace(adminConfig);
57
58
  const shopConfig = {
@@ -60,6 +61,7 @@ class ForgeCartSDK {
60
61
  headers,
61
62
  webSocketImpl: config.webSocketImpl,
62
63
  httpOnly: config.httpOnly,
64
+ debug: config.debug,
63
65
  };
64
66
  this.shop = new shop_js_1.ShopNamespace(shopConfig);
65
67
  }
@@ -4,7 +4,7 @@
4
4
  * This file was automatically generated and should not be manually edited.
5
5
  * To regenerate, run: npm run codegen:ts
6
6
  *
7
- * Generated at: 2025-12-15T07:13:55.632Z
7
+ * Generated at: 2025-12-15T13:49:08.152Z
8
8
  * Generator version: 1.0.0
9
9
  *
10
10
  * 🤖 Generated with ForgeCart SDK Generator
@@ -25,6 +25,8 @@ export interface SDKConfig {
25
25
  webSocketImpl?: unknown;
26
26
  /** Use HTTP only, skip WebSocket initialization (default: false) */
27
27
  httpOnly?: boolean;
28
+ /** Enable debug logging with request timing (default: false) */
29
+ debug?: boolean;
28
30
  }
29
31
  export type AssetQueryVariables = Types.AssetQueryVariables;
30
32
  export type AssetQuery = Types.AssetQuery;
@@ -246,6 +248,10 @@ declare class BaseGraphQLClient {
246
248
  private wsEndpoint;
247
249
  private config;
248
250
  constructor(config: SDKConfig);
251
+ /**
252
+ * Extract operation name from GraphQL document
253
+ */
254
+ private getOperationName;
249
255
  /**
250
256
  * Execute a GraphQL query or mutation
251
257
  * Uses WebSocket if available, falls back to HTTP
@@ -5,7 +5,7 @@
5
5
  * This file was automatically generated and should not be manually edited.
6
6
  * To regenerate, run: npm run codegen:ts
7
7
  *
8
- * Generated at: 2025-12-15T07:13:55.632Z
8
+ * Generated at: 2025-12-15T13:49:08.152Z
9
9
  * Generator version: 1.0.0
10
10
  *
11
11
  * 🤖 Generated with ForgeCart SDK Generator
@@ -2230,26 +2230,50 @@ class BaseGraphQLClient {
2230
2230
  // Initialize WebSocket connection immediately
2231
2231
  this.initializeWebSocket();
2232
2232
  }
2233
+ /**
2234
+ * Extract operation name from GraphQL document
2235
+ */
2236
+ getOperationName(document) {
2237
+ const docString = typeof document === 'string' ? document : String(document);
2238
+ const match = docString.match(/(?:query|mutation|subscription)\s+(\w+)/);
2239
+ return match ? match[1] : 'UnknownOperation';
2240
+ }
2233
2241
  /**
2234
2242
  * Execute a GraphQL query or mutation
2235
2243
  * Uses WebSocket if available, falls back to HTTP
2236
2244
  */
2237
2245
  async request(document, variables) {
2246
+ const startTime = this.config.debug ? performance.now() : 0;
2247
+ const operationName = this.config.debug ? this.getOperationName(document) : '';
2248
+ let transport = 'HTTP';
2238
2249
  // Try WebSocket first if available
2239
2250
  if (this.wsClient && this.wsConnected) {
2240
2251
  try {
2241
- return await this.requestViaWebSocket(document, variables);
2252
+ transport = 'WebSocket';
2253
+ const result = await this.requestViaWebSocket(document, variables);
2254
+ if (this.config.debug) {
2255
+ console.log(`[ForgeCart SDK] ${operationName} (${transport}) - ${(performance.now() - startTime).toFixed(0)}ms`);
2256
+ }
2257
+ return result;
2242
2258
  }
2243
2259
  catch (wsError) {
2260
+ transport = 'WebSocket -> HTTP';
2244
2261
  console.warn('WebSocket request failed, falling back to HTTP:', wsError);
2245
2262
  // Fall through to HTTP
2246
2263
  }
2247
2264
  }
2248
2265
  // Use HTTP as fallback or when WebSocket is not available
2249
2266
  try {
2250
- return await this.httpClient.request(document, variables);
2267
+ const result = await this.httpClient.request(document, variables);
2268
+ if (this.config.debug) {
2269
+ console.log(`[ForgeCart SDK] ${operationName} (${transport}) - ${(performance.now() - startTime).toFixed(0)}ms`);
2270
+ }
2271
+ return result;
2251
2272
  }
2252
2273
  catch (error) {
2274
+ if (this.config.debug) {
2275
+ console.log(`[ForgeCart SDK] ${operationName} (${transport}) - FAILED after ${(performance.now() - startTime).toFixed(0)}ms`);
2276
+ }
2253
2277
  this.handleError(error);
2254
2278
  throw error;
2255
2279
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forgecart/sdk",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "TypeScript SDK for ForgeCart API - Auto-generated GraphQL client",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -4,7 +4,7 @@
4
4
  * This file was automatically generated and should not be manually edited.
5
5
  * To regenerate, run: npm run codegen:ts
6
6
  *
7
- * Generated at: 2025-12-15T07:13:55.745Z
7
+ * Generated at: 2025-12-15T13:49:08.285Z
8
8
  * Generator version: 1.0.0
9
9
  *
10
10
  * 🤖 Generated with ForgeCart SDK Generator
@@ -30,6 +30,8 @@ export interface SDKConfig {
30
30
  webSocketImpl?: unknown;
31
31
  /** Use HTTP only, skip WebSocket initialization (default: false) */
32
32
  httpOnly?: boolean;
33
+ /** Enable debug logging with request timing (default: false) */
34
+ debug?: boolean;
33
35
  }
34
36
 
35
37
  export type ActiveAdministratorQueryVariables = Types.ActiveAdministratorQueryVariables;
@@ -8208,6 +8210,15 @@ class BaseGraphQLClient {
8208
8210
  this.initializeWebSocket();
8209
8211
  }
8210
8212
 
8213
+ /**
8214
+ * Extract operation name from GraphQL document
8215
+ */
8216
+ private getOperationName(document: RequestDocument): string {
8217
+ const docString = typeof document === 'string' ? document : String(document);
8218
+ const match = docString.match(/(?:query|mutation|subscription)\s+(\w+)/);
8219
+ return match ? match[1] : 'UnknownOperation';
8220
+ }
8221
+
8211
8222
  /**
8212
8223
  * Execute a GraphQL query or mutation
8213
8224
  * Uses WebSocket if available, falls back to HTTP
@@ -8216,12 +8227,22 @@ class BaseGraphQLClient {
8216
8227
  document: RequestDocument,
8217
8228
  variables?: V
8218
8229
  ): Promise<T> {
8230
+ const startTime = this.config.debug ? performance.now() : 0;
8231
+ const operationName = this.config.debug ? this.getOperationName(document) : '';
8232
+ let transport = 'HTTP';
8233
+
8219
8234
 
8220
8235
  // Try WebSocket first if available
8221
8236
  if (this.wsClient && this.wsConnected) {
8222
8237
  try {
8223
- return await this.requestViaWebSocket<T>(document, variables);
8238
+ transport = 'WebSocket';
8239
+ const result = await this.requestViaWebSocket<T>(document, variables);
8240
+ if (this.config.debug) {
8241
+ console.log(`[ForgeCart SDK] ${operationName} (${transport}) - ${(performance.now() - startTime).toFixed(0)}ms`);
8242
+ }
8243
+ return result;
8224
8244
  } catch (wsError) {
8245
+ transport = 'WebSocket -> HTTP';
8225
8246
  console.warn('WebSocket request failed, falling back to HTTP:', wsError);
8226
8247
  // Fall through to HTTP
8227
8248
  }
@@ -8230,8 +8251,15 @@ class BaseGraphQLClient {
8230
8251
 
8231
8252
  // Use HTTP as fallback or when WebSocket is not available
8232
8253
  try {
8233
- return await this.httpClient.request<T>(document, variables);
8254
+ const result = await this.httpClient.request<T>(document, variables);
8255
+ if (this.config.debug) {
8256
+ console.log(`[ForgeCart SDK] ${operationName} (${transport}) - ${(performance.now() - startTime).toFixed(0)}ms`);
8257
+ }
8258
+ return result;
8234
8259
  } catch (error) {
8260
+ if (this.config.debug) {
8261
+ console.log(`[ForgeCart SDK] ${operationName} (${transport}) - FAILED after ${(performance.now() - startTime).toFixed(0)}ms`);
8262
+ }
8235
8263
  this.handleError(error);
8236
8264
  throw error;
8237
8265
  }
package/src/index.ts CHANGED
@@ -20,6 +20,8 @@ export interface ForgeCartSDKConfig {
20
20
  token: string
21
21
  /** Use HTTP only, skip WebSocket initialization (default: false) */
22
22
  httpOnly?: boolean
23
+ /** Enable debug logging with request timing (default: false) */
24
+ debug?: boolean
23
25
  /** Custom HTTP headers */
24
26
  headers?: Record<string, string>
25
27
  /** Custom WebSocket implementation (optional, auto-detected if not provided) */
@@ -75,6 +77,7 @@ export class ForgeCartSDK {
75
77
  headers,
76
78
  webSocketImpl: config.webSocketImpl,
77
79
  httpOnly: config.httpOnly,
80
+ debug: config.debug,
78
81
  }
79
82
  this.admin = new AdminNamespace(adminConfig)
80
83
 
@@ -84,6 +87,7 @@ export class ForgeCartSDK {
84
87
  headers,
85
88
  webSocketImpl: config.webSocketImpl,
86
89
  httpOnly: config.httpOnly,
90
+ debug: config.debug,
87
91
  }
88
92
  this.shop = new ShopNamespace(shopConfig)
89
93
  }
@@ -4,7 +4,7 @@
4
4
  * This file was automatically generated and should not be manually edited.
5
5
  * To regenerate, run: npm run codegen:ts
6
6
  *
7
- * Generated at: 2025-12-15T07:13:55.632Z
7
+ * Generated at: 2025-12-15T13:49:08.152Z
8
8
  * Generator version: 1.0.0
9
9
  *
10
10
  * 🤖 Generated with ForgeCart SDK Generator
@@ -30,6 +30,8 @@ export interface SDKConfig {
30
30
  webSocketImpl?: unknown;
31
31
  /** Use HTTP only, skip WebSocket initialization (default: false) */
32
32
  httpOnly?: boolean;
33
+ /** Enable debug logging with request timing (default: false) */
34
+ debug?: boolean;
33
35
  }
34
36
 
35
37
  export type AssetQueryVariables = Types.AssetQueryVariables;
@@ -2532,6 +2534,15 @@ class BaseGraphQLClient {
2532
2534
  this.initializeWebSocket();
2533
2535
  }
2534
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
+
2535
2546
  /**
2536
2547
  * Execute a GraphQL query or mutation
2537
2548
  * Uses WebSocket if available, falls back to HTTP
@@ -2540,12 +2551,22 @@ class BaseGraphQLClient {
2540
2551
  document: RequestDocument,
2541
2552
  variables?: V
2542
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
+
2543
2558
 
2544
2559
  // Try WebSocket first if available
2545
2560
  if (this.wsClient && this.wsConnected) {
2546
2561
  try {
2547
- return await this.requestViaWebSocket<T>(document, variables);
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;
2548
2568
  } catch (wsError) {
2569
+ transport = 'WebSocket -> HTTP';
2549
2570
  console.warn('WebSocket request failed, falling back to HTTP:', wsError);
2550
2571
  // Fall through to HTTP
2551
2572
  }
@@ -2554,8 +2575,15 @@ class BaseGraphQLClient {
2554
2575
 
2555
2576
  // Use HTTP as fallback or when WebSocket is not available
2556
2577
  try {
2557
- return await this.httpClient.request<T>(document, variables);
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;
2558
2583
  } catch (error) {
2584
+ if (this.config.debug) {
2585
+ console.log(`[ForgeCart SDK] ${operationName} (${transport}) - FAILED after ${(performance.now() - startTime).toFixed(0)}ms`);
2586
+ }
2559
2587
  this.handleError(error);
2560
2588
  throw error;
2561
2589
  }