Skip to content

Commit e2af32e

Browse files
committed
Fix linter errors
1 parent 642295e commit e2af32e

File tree

3 files changed

+71
-32
lines changed

3 files changed

+71
-32
lines changed

packages/sdk/src/server/__tests__/server.test.ts

Lines changed: 61 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ describe("BackendClient", () => {
5151
url: "https://api.pipedream.com/v1/test-path",
5252
},
5353
response: {
54-
json: { data: "test-response" },
54+
json: {
55+
data: "test-response",
56+
},
5557
},
5658
})
5759

@@ -73,7 +75,9 @@ describe("BackendClient", () => {
7375
},
7476
},
7577
response: {
76-
json: { success: true },
78+
json: {
79+
success: true,
80+
},
7781
},
7882
})
7983

@@ -117,7 +121,9 @@ describe("BackendClient", () => {
117121
},
118122
},
119123
response: {
120-
json: { success: true },
124+
json: {
125+
success: true,
126+
},
121127
},
122128
})
123129

@@ -145,7 +151,9 @@ describe("BackendClient", () => {
145151
},
146152
},
147153
response: {
148-
json: { success: true },
154+
json: {
155+
success: true,
156+
},
149157
},
150158
})
151159

@@ -312,10 +320,12 @@ describe("BackendClient", () => {
312320
url: `https://api.pipedream.com/v1/connect/${projectId}/accounts?app=app-1`,
313321
},
314322
response: {
315-
json: [{
316-
id: "account-1",
317-
name: "Test Account",
318-
}],
323+
json: [
324+
{
325+
id: "account-1",
326+
name: "Test Account",
327+
},
328+
],
319329
},
320330
});
321331

@@ -340,10 +350,12 @@ describe("BackendClient", () => {
340350
url: `https://api.pipedream.com/v1/connect/${projectId}/accounts?external_user_id=external-id-1`,
341351
},
342352
response: {
343-
json: [{
344-
id: "account-1",
345-
name: "Test Account",
346-
}],
353+
json: [
354+
{
355+
id: "account-1",
356+
name: "Test Account",
357+
},
358+
],
347359
},
348360
});
349361

@@ -465,7 +477,9 @@ describe("BackendClient", () => {
465477
},
466478
},
467479
response: {
468-
json: { result: "workflow-response" },
480+
json: {
481+
result: "workflow-response",
482+
},
469483
},
470484
})
471485

@@ -481,8 +495,10 @@ describe("BackendClient", () => {
481495
});
482496

483497
it("should invoke a workflow with OAuth auth type", async () => {
484-
const token = ""+Math.random()
485-
fetchMock.expectAccessTokenSuccess({ accessToken: token });
498+
const token = "" + Math.random()
499+
fetchMock.expectAccessTokenSuccess({
500+
accessToken: token,
501+
});
486502
fetchMock.expect({
487503
request: {
488504
url: "https://example.com/workflow",
@@ -491,7 +507,9 @@ describe("BackendClient", () => {
491507
},
492508
},
493509
response: {
494-
json: { result: "workflow-response" },
510+
json: {
511+
result: "workflow-response",
512+
},
495513
},
496514
})
497515

@@ -503,7 +521,7 @@ describe("BackendClient", () => {
503521
});
504522

505523
it("should invoke a workflow with static bearer auth type", async () => {
506-
const token = ""+Math.random()
524+
const token = "" + Math.random()
507525
fetchMock.expect({
508526
request: {
509527
url: "https://example.com/workflow",
@@ -512,7 +530,9 @@ describe("BackendClient", () => {
512530
},
513531
},
514532
response: {
515-
json: { result: "workflow-response" },
533+
json: {
534+
result: "workflow-response",
535+
},
516536
},
517537
})
518538

@@ -538,7 +558,9 @@ describe("BackendClient", () => {
538558
url: "https://api.pipedream.com/v1/test-path",
539559
},
540560
response: {
541-
json: { success: true },
561+
json: {
562+
success: true,
563+
},
542564
},
543565
})
544566

@@ -571,7 +593,9 @@ describe("BackendClient", () => {
571593
},
572594
},
573595
response: {
574-
json: { result: "workflow-response" },
596+
json: {
597+
result: "workflow-response",
598+
},
575599
},
576600
})
577601

@@ -697,17 +721,17 @@ describe("BackendClient", () => {
697721
type ExpectRequest = {
698722
method?: string
699723
url?: string | RegExp
700-
json?: Record<string, any>
724+
json?: Record<string, never>
701725
headersContaining?: Record<string, string>
702726
}
703727
type MockResponse =
704728
| Response
705-
| { status?: number; json?: any }
729+
| { status?: number; json?: never }
706730
type IfOpts = {
707731
method: string
708732
url: string
709733
headers: Record<string, string> // NonNullable<RequestInit["headers"]>
710-
json?: any // body json
734+
json?: never // body json
711735
// XXX etc.
712736
}
713737
function setupFetchMock() {
@@ -716,7 +740,7 @@ function setupFetchMock() {
716740
response: () => Response
717741
}[] = []
718742

719-
const jsonResponse = (o: any, opts?: { status?: number }) => {
743+
const jsonResponse = (o: never, opts?: { status?: number }) => {
720744
return new Response(JSON.stringify(o), {
721745
status: opts?.status,
722746
headers: {
@@ -728,13 +752,18 @@ function setupFetchMock() {
728752
beforeEach(() => {
729753
intercepts = [];
730754
// without these generics this fails typecheck and can't figure out why
731-
jest.spyOn<any, any, any>(global, "fetch").mockImplementation(jest.fn<typeof fetch>(async (...args: Parameters<typeof fetch>) => {
732-
const [url, init] = args
733-
let json: any
755+
jest.spyOn<never, never, never>(global, "fetch").mockImplementation(jest.fn<typeof fetch>(async (...args: Parameters<typeof fetch>) => {
756+
const [
757+
url,
758+
init,
759+
] = args
760+
let json: never
734761
if (init?.body && typeof init.body === "string") {
735762
try {
736763
json = JSON.parse(init.body)
737-
} catch {}
764+
} catch {
765+
// pass
766+
}
738767
}
739768
if (url instanceof Request) {
740769
throw new Error("not supported")
@@ -764,7 +793,9 @@ function setupFetchMock() {
764793

765794
// const _expect = (opts: { if: (opts: IfOpts) => boolean, jsonResponse?: any, response?: Response }) => {
766795
const _expect = (opts: { request: ExpectRequest, response: MockResponse }) => {
767-
const { method, url, headersContaining, json } = opts.request
796+
const {
797+
method, url, headersContaining, json,
798+
} = opts.request
768799
intercepts.push({
769800
if: (ifOpts) => {
770801
if (method && ifOpts.method !== method) return false
@@ -806,7 +837,7 @@ function setupFetchMock() {
806837
}
807838

808839
const expectAccessTokenSuccess = (opts?: { accessToken?: string; expiresIn?: number }) => {
809-
const accessToken = opts?.accessToken || ""+Math.random()
840+
const accessToken = opts?.accessToken || "" + Math.random()
810841
_expect({
811842
request: {
812843
url: /\/v1\/oauth\/token$/,

packages/sdk/src/server/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,11 @@ export class BackendClient extends BaseClient {
199199
}
200200

201201
private async ensureValidOauthAccessToken(): Promise<string> {
202-
const { client, clientAuth, as } = this.oauthClient
202+
const {
203+
client,
204+
clientAuth,
205+
as,
206+
} = this.oauthClient
203207

204208
let attempts = 0;
205209
const maxAttempts = 2;
@@ -221,7 +225,9 @@ export class BackendClient extends BaseClient {
221225
token: oauthTokenResponse.access_token,
222226
expiresAt: Date.now() + (oauthTokenResponse.expires_in || 0) * 1000,
223227
};
224-
} catch {}
228+
} catch {
229+
// pass
230+
}
225231

226232
attempts++;
227233
}

pnpm-lock.yaml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)