@secondlayer/sdk 8.0.1 → 9.0.1

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.
@@ -145,12 +145,23 @@ function resolveBaseUrl(explicit) {
145
145
  }
146
146
  return LOCAL_API_URL;
147
147
  }
148
+ var CREDENTIAL_ENV_VARS = ["INSTANCE_TOKEN", "SL_API_KEY"];
149
+ var warnedConflicts = new Set;
148
150
  function resolveApiKey(apiKey) {
149
151
  if (apiKey !== undefined)
150
152
  return apiKey;
151
153
  if (typeof process === "undefined")
152
154
  return;
153
- return process.env?.SL_API_KEY || undefined;
155
+ const instanceToken = process.env?.INSTANCE_TOKEN || undefined;
156
+ const legacyKey = process.env?.SL_API_KEY || undefined;
157
+ if (instanceToken && legacyKey && instanceToken !== legacyKey) {
158
+ const pair = `${instanceToken}\x00${legacyKey}`;
159
+ if (!warnedConflicts.has(pair)) {
160
+ warnedConflicts.add(pair);
161
+ console.warn("[secondlayer] INSTANCE_TOKEN and SL_API_KEY are set to different values — using INSTANCE_TOKEN (SL_API_KEY is a legacy alias for it).");
162
+ }
163
+ }
164
+ return instanceToken ?? legacyKey;
154
165
  }
155
166
  function buildQuery(params) {
156
167
  const search = new URLSearchParams;
@@ -340,7 +351,7 @@ class Subgraphs extends BaseClient {
340
351
  async list() {
341
352
  return this.request("GET", "/api/subgraphs");
342
353
  }
343
- async get(name) {
354
+ async status(name) {
344
355
  return this.request("GET", `/api/subgraphs/${name}`);
345
356
  }
346
357
  async openapi(name, options) {
@@ -1465,7 +1476,7 @@ function subscribeStreamsEvents(opts) {
1465
1476
  })}`;
1466
1477
  const res = await opts.fetchImpl(url, {
1467
1478
  headers: {
1468
- Authorization: `Bearer ${opts.apiKey}`,
1479
+ ...opts.apiKey ? { Authorization: `Bearer ${opts.apiKey}` } : {},
1469
1480
  Accept: "text/event-stream"
1470
1481
  },
1471
1482
  signal: controller.signal
@@ -1676,7 +1687,7 @@ function createStreamsClient(options) {
1676
1687
  });
1677
1688
  async function request(path) {
1678
1689
  const response = await fetchImpl(`${baseUrl}${path}`, {
1679
- headers: { Authorization: `Bearer ${options.apiKey}` }
1690
+ headers: options.apiKey ? { Authorization: `Bearer ${options.apiKey}` } : {}
1680
1691
  });
1681
1692
  if (!response.ok)
1682
1693
  await mapStreamsError(response);
@@ -1887,7 +1898,7 @@ class Subscriptions extends BaseClient {
1887
1898
  async test(id) {
1888
1899
  return this.request("POST", `/api/subscriptions/${id}/test`);
1889
1900
  }
1890
- async recentDeliveries(id) {
1901
+ async deliveries(id) {
1891
1902
  return this.request("GET", `/api/subscriptions/${id}/deliveries`);
1892
1903
  }
1893
1904
  async replay(id, range) {
@@ -1896,7 +1907,7 @@ class Subscriptions extends BaseClient {
1896
1907
  async dead(id) {
1897
1908
  return this.request("GET", `/api/subscriptions/${id}/dead`);
1898
1909
  }
1899
- async requeueDead(id, outboxId) {
1910
+ async requeue(id, outboxId) {
1900
1911
  return this.request("POST", `/api/subscriptions/${id}/dead/${outboxId}/requeue`);
1901
1912
  }
1902
1913
  }
@@ -1911,7 +1922,7 @@ class SecondLayer extends BaseClient {
1911
1922
  constructor(options = {}) {
1912
1923
  super(options);
1913
1924
  this.streams = createStreamsClient({
1914
- apiKey: resolveApiKey(options.apiKey) ?? "",
1925
+ apiKey: resolveApiKey(options.apiKey),
1915
1926
  baseUrl: options.baseUrl,
1916
1927
  fetchImpl: options.fetchImpl,
1917
1928
  dumpsBaseUrl: options.dumpsBaseUrl
@@ -1983,5 +1994,5 @@ export {
1983
1994
  Subgraphs
1984
1995
  };
1985
1996
 
1986
- //# debugId=D755EDD13178F73464756E2164756E21
1997
+ //# debugId=9E199310A6B6CFB264756E2164756E21
1987
1998
  //# sourceMappingURL=index.js.map