@jskit-ai/connectors-catalog 0.2.42 → 0.2.44

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/connectors-catalog",
3
- "version": "0.2.42",
3
+ "version": "0.2.44",
4
4
  "description": "Provider definitions and focused API operations for JSKIT connectors.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -125,7 +125,7 @@
125
125
  "@aws-sdk/client-redshift-data": "3.1128.0",
126
126
  "@aws-sdk/client-s3": "3.1128.0",
127
127
  "@aws-sdk/s3-request-presigner": "3.1128.0",
128
- "@jskit-ai/connectors-core": "0.2.41",
128
+ "@jskit-ai/connectors-core": "0.2.42",
129
129
  "@modelcontextprotocol/sdk": "1.32.1",
130
130
  "@smithy/fetch-http-handler": "5.8.0",
131
131
  "jose": "^6.1.3",
@@ -22,7 +22,8 @@ async function fixture(t) {
22
22
  t.after(() => rm(directory, { recursive: true, force: true }));
23
23
  const protection = createCredentialProtection({ keys: { current: new Uint8Array(32).fill(8) }, activeKeyId: "current" });
24
24
  const requests = [];
25
- const state = { key: "fixture-v4-key", status: 200, response: page, wait: false, resolutions: 0 };
25
+ // With `wait`, a request stays open until its signal aborts; `sent`, when a test sets one, resolves once it is out.
26
+ const state = { key: "fixture-v4-key", status: 200, response: page, wait: false, sent: null, resolutions: 0 };
26
27
  const options = {
27
28
  configuration: { schemaVersion: 1, registrations: {}, integrations: { seo: {
28
29
  provider: "semrush", displayName: "Marketing projects", accountMode: "shared", scopes: [],
@@ -34,6 +35,7 @@ async function fixture(t) {
34
35
  fetchImpl: async (address, init) => {
35
36
  requests.push({ url: new URL(String(address)), init, headers: new Headers(init.headers) });
36
37
  if (state.wait) {
38
+ state.sent?.resolve();
37
39
  return new Promise((_, reject) => {
38
40
  if (init.signal.aborted) reject(init.signal.reason);
39
41
  else init.signal.addEventListener("abort", () => reject(init.signal.reason), { once: true });
@@ -187,14 +189,24 @@ test("Semrush transport failures do not retry or verify the connection, and auth
187
189
  test("Semrush interruption and timeout leave the stored connection usable without replaying reads", async (t) => {
188
190
  const { service, options, state, requests } = await fixture(t);
189
191
  await service.connectApiKey(input); state.wait = true;
192
+ // Each read is stopped once its request is out, never by a timer racing it: on a loaded machine a 15 ms cancel or a
193
+ // 20 ms timeout went off before the request was sent, and the count below found 2 requests.
190
194
  const controller = new AbortController();
195
+ state.sent = Promise.withResolvers();
191
196
  const pending = service.invoke({ ...input, operation: "projects.list", signal: controller.signal });
192
- setTimeout(() => controller.abort(), 15);
197
+ await Promise.race([state.sent.promise, pending]);
198
+ controller.abort();
193
199
  await assert.rejects(pending, { code: "connector_cancelled" });
200
+ // The provider's 20 ms timeout signal aborts when the test says, with the TimeoutError AbortSignal.timeout gives.
201
+ const timeouts = [], timer = new AbortController(), timeout = AbortSignal.timeout;
202
+ t.mock.method(AbortSignal, "timeout", (duration) => { timeouts.push(duration); return duration === 20 ? timer.signal : timeout(duration); });
194
203
  const timeoutService = createConnectionService({ appEnv: "test", ...options, providers: [{ ...semrushProvider, requestTimeoutMs: 20 }] });
195
- const keepAlive = setTimeout(() => {}, 1000);
196
- try { await assert.rejects(timeoutService.invoke({ ...input, operation: "projects.list" }), { code: "connector_provider_timeout" }); }
197
- finally { clearTimeout(keepAlive); }
204
+ state.sent = Promise.withResolvers();
205
+ const timing = timeoutService.invoke({ ...input, operation: "projects.list" });
206
+ await Promise.race([state.sent.promise, timing]);
207
+ timer.abort(new DOMException("The operation timed out.", "TimeoutError"));
208
+ await assert.rejects(timing, { code: "connector_provider_timeout" });
209
+ assert.ok(timeouts.includes(20), `timeouts created: ${timeouts}`);
198
210
  assert.equal(requests.length, 3);
199
211
  assert.equal((await service.status(input)).status, "connected");
200
212
  state.wait = false;