@granular-software/sdk 0.4.73 → 0.4.74

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.
package/dist/index.mjs CHANGED
@@ -17555,13 +17555,15 @@ var Environment = class _Environment {
17555
17555
  _apiEndpoint;
17556
17556
  _tokenProvider;
17557
17557
  _beforeMutationSend;
17558
- constructor(granular, envData, apiKey, apiEndpoint, tokenProvider, beforeMutationSend) {
17558
+ _graphqlIdempotencyKey;
17559
+ constructor(granular, envData, apiKey, apiEndpoint, tokenProvider, beforeMutationSend, graphqlIdempotencyKey) {
17559
17560
  this.granular = granular;
17560
17561
  this.envData = envData;
17561
17562
  this._apiKey = apiKey;
17562
17563
  this._apiEndpoint = apiEndpoint;
17563
17564
  this._tokenProvider = tokenProvider;
17564
17565
  this._beforeMutationSend = beforeMutationSend;
17566
+ this._graphqlIdempotencyKey = graphqlIdempotencyKey;
17565
17567
  }
17566
17568
  /** The environment ID */
17567
17569
  get environmentId() {
@@ -18104,11 +18106,13 @@ var Environment = class _Environment {
18104
18106
  if (this._beforeMutationSend && isGraphQLMutationDocument(query)) {
18105
18107
  this._beforeMutationSend?.();
18106
18108
  }
18109
+ const idempotencyKey = this._graphqlIdempotencyKey?.(query, variables);
18107
18110
  const response = await fetch(this._apiEndpoint, {
18108
18111
  method: "POST",
18109
18112
  headers: {
18110
18113
  "Content-Type": "application/json",
18111
- Authorization: `Bearer ${authToken}`
18114
+ Authorization: `Bearer ${authToken}`,
18115
+ ...idempotencyKey ? { "Idempotency-Key": idempotencyKey } : {}
18112
18116
  },
18113
18117
  body: JSON.stringify({
18114
18118
  environmentId: this.environmentId,
@@ -19682,6 +19686,7 @@ var Granular = class _Granular {
19682
19686
  onUnexpectedClose;
19683
19687
  onReconnectError;
19684
19688
  effectHostUrl;
19689
+ graphqlIdempotencyKey;
19685
19690
  debugHttp = process.env.GRANULAR_DEBUG_HTTP === "1";
19686
19691
  /** Sandbox-level effect registry: sandboxId → (effectKey@selector → ToolWithHandler) */
19687
19692
  sandboxEffects = /* @__PURE__ */ new Map();
@@ -19711,6 +19716,7 @@ var Granular = class _Granular {
19711
19716
  this.onUnexpectedClose = options.onUnexpectedClose;
19712
19717
  this.onReconnectError = options.onReconnectError;
19713
19718
  this.effectHostUrl = options.effectHostUrl;
19719
+ this.graphqlIdempotencyKey = options.graphqlIdempotencyKey;
19714
19720
  this.httpUrl = this.apiUrl.replace(/^wss:\/\//, "https://").replace(/^ws:\/\//, "http://").replace(/\/ws$/, "");
19715
19721
  }
19716
19722
  /**
@@ -20726,7 +20732,9 @@ var Granular = class _Granular {
20726
20732
  envData,
20727
20733
  this.apiKey,
20728
20734
  graphqlEndpoint,
20729
- this.tokenProvider
20735
+ this.tokenProvider,
20736
+ void 0,
20737
+ this.graphqlIdempotencyKey
20730
20738
  );
20731
20739
  }
20732
20740
  async bindWebSocketEnvironmentSession(environment, clientId, session, transportOptions = {}) {