Skip to content

Commit 1344010

Browse files
chore(formatter): run prettier and eslint separately
1 parent 8b9992f commit 1344010

86 files changed

Lines changed: 4257 additions & 5515 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ CHANGELOG.md
22
/ecosystem-tests/*/**
33
/node_modules
44
/deno
5+
/packages/mcp-server/cloudflare-worker/worker-configuration.d.ts
56

67
# don't format tsc output, will break source maps
78
dist

eslint.config.mjs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// @ts-check
22
import tseslint from 'typescript-eslint';
33
import unusedImports from 'eslint-plugin-unused-imports';
4-
import prettier from 'eslint-plugin-prettier';
54

65
export default tseslint.config(
76
{
@@ -14,11 +13,9 @@ export default tseslint.config(
1413
plugins: {
1514
'@typescript-eslint': tseslint.plugin,
1615
'unused-imports': unusedImports,
17-
prettier,
1816
},
1917
rules: {
2018
'no-unused-vars': 'off',
21-
'prettier/prettier': 'error',
2219
'unused-imports/no-unused-imports': 'error',
2320
'no-restricted-imports': [
2421
'error',

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
"@typescript-eslint/eslint-plugin": "8.31.1",
3939
"@typescript-eslint/parser": "8.31.1",
4040
"eslint": "^9.39.1",
41-
"eslint-plugin-prettier": "^5.4.1",
4241
"eslint-plugin-unused-imports": "^4.1.4",
4342
"iconv-lite": "^0.6.3",
4443
"jest": "^29.4.0",

packages/mcp-server/cloudflare-worker/worker-configuration.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable */
1+
22
// Generated by Wrangler by running `wrangler types` (hash: fc286f4a60f8eb63b1e0d82ea1f34233)
33
// Runtime types generated with workerd@1.20260124.0 2025-03-10 nodejs_compat
44
declare namespace Cloudflare {
@@ -29,7 +29,7 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
2929
See the Apache Version 2.0 License for specific language governing permissions
3030
and limitations under the License.
3131
***************************************************************************** */
32-
/* eslint-disable */
32+
3333
// noinspection JSUnusedGlobalSymbols
3434
declare var onmessage: never;
3535
/**

packages/mcp-server/jest.config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ const config: JestConfigWithTsJest = {
1010
'^@imagekit/api-mcp$': '<rootDir>/src/index.ts',
1111
'^@imagekit/api-mcp/(.*)$': '<rootDir>/src/$1',
1212
},
13-
modulePathIgnorePatterns: ['<rootDir>/dist/'],
13+
modulePathIgnorePatterns: [
14+
'<rootDir>/dist/',
15+
],
1416
testPathIgnorePatterns: ['scripts'],
1517
};
1618

packages/mcp-server/src/auth.ts

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,36 @@
11
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
import { IncomingMessage } from 'node:http';
4-
import { ClientOptions } from '@imagekit/nodejs';
3+
import { IncomingMessage } from 'node:http'
4+
import { ClientOptions } from '@imagekit/nodejs'
55
import { McpOptions } from './options';
66

7-
export const parseClientAuthHeaders = (req: IncomingMessage, required?: boolean): Partial<ClientOptions> => {
8-
if (req.headers.authorization) {
9-
const scheme = req.headers.authorization.split(' ')[0]!;
10-
const value = req.headers.authorization.slice(scheme.length + 1);
11-
switch (scheme) {
12-
case 'Basic':
13-
const rawValue = Buffer.from(value, 'base64').toString();
14-
return {
15-
privateKey: rawValue.slice(0, rawValue.search(':')),
16-
password: rawValue.slice(rawValue.search(':') + 1),
17-
};
18-
default:
19-
throw new Error(
20-
'Unsupported authorization scheme. Expected the "Authorization" header to be a supported scheme (Basic).',
21-
);
22-
}
23-
} else if (required) {
24-
throw new Error('Missing required Authorization header; see WWW-Authenticate header for details.');
7+
export const parseClientAuthHeaders = (req: IncomingMessage, required?: boolean): Partial<ClientOptions> => { if (req.headers.authorization) {
8+
const scheme = req.headers.authorization.split(" ")[0]!;
9+
const value = req.headers.authorization.slice(scheme.length + 1);
10+
switch (scheme) {
11+
case 'Basic':
12+
const rawValue = Buffer.from(value, 'base64').toString();
13+
return { privateKey: rawValue.slice(0, rawValue.search(':')), password: rawValue.slice(rawValue.search(':') + 1) }
14+
default:
15+
throw new Error('Unsupported authorization scheme. Expected the "Authorization" header to be a supported scheme (Basic).');
2516
}
17+
} else if (required) {
18+
throw new Error('Missing required Authorization header; see WWW-Authenticate header for details.');
19+
}
2620

27-
const privateKey =
28-
Array.isArray(req.headers['x-imagekit-private-key']) ?
29-
req.headers['x-imagekit-private-key'][0]
30-
: req.headers['x-imagekit-private-key'];
31-
const password =
32-
Array.isArray(req.headers['x-optional-imagekit-ignores-this']) ?
33-
req.headers['x-optional-imagekit-ignores-this'][0]
34-
: req.headers['x-optional-imagekit-ignores-this'];
35-
return { privateKey, password };
36-
};
21+
const privateKey = Array.isArray(req.headers['x-imagekit-private-key']) ? req.headers['x-imagekit-private-key'][0] : req.headers['x-imagekit-private-key']
22+
const password = Array.isArray(req.headers['x-optional-imagekit-ignores-this']) ? req.headers['x-optional-imagekit-ignores-this'][0] : req.headers['x-optional-imagekit-ignores-this']
23+
return {privateKey, password}; }
3724

3825
export const getStainlessApiKey = (req: IncomingMessage, mcpOptions: McpOptions): string | undefined => {
3926
// Try to get the key from the x-stainless-api-key header
40-
const headerKey =
41-
Array.isArray(req.headers['x-stainless-api-key']) ?
42-
req.headers['x-stainless-api-key'][0]
43-
: req.headers['x-stainless-api-key'];
27+
const headerKey = Array.isArray(req.headers['x-stainless-api-key']) ?
28+
req.headers['x-stainless-api-key'][0]
29+
: req.headers['x-stainless-api-key'];
4430
if (headerKey && typeof headerKey === 'string') {
4531
return headerKey;
4632
}
4733

4834
// Fall back to value set in the mcpOptions (e.g. from environment variable), if provided
4935
return mcpOptions.stainlessApiKey;
50-
};
36+
}

packages/mcp-server/src/code-tool-types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
import { ClientOptions } from '@imagekit/nodejs';
3+
import { ClientOptions } from '@imagekit/nodejs'
44

55
export type WorkerInput = {
66
project_name: string;

packages/mcp-server/src/code-tool-worker.ts

Lines changed: 55 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ function getTSDiagnostics(code: string): string[] {
5959
const codeWithImport = [
6060
'import { ImageKit } from "@imagekit/nodejs";',
6161
functionSource.type === 'declaration' ?
62-
`async function run(${functionSource.client}: ImageKit)`
63-
: `const run: (${functionSource.client}: ImageKit) => Promise<unknown> =`,
62+
`async function run(${functionSource.client}: ImageKit)` :
63+
`const run: (${functionSource.client}: ImageKit) => Promise<unknown> =`,
6464
functionSource.code,
6565
].join('\n');
6666
const sourcePath = path.resolve('code.ts');
@@ -108,55 +108,55 @@ function getTSDiagnostics(code: string): string[] {
108108

109109
const fuse = new Fuse(
110110
[
111-
'client.customMetadataFields.create',
112-
'client.customMetadataFields.delete',
113-
'client.customMetadataFields.list',
114-
'client.customMetadataFields.update',
115-
'client.files.copy',
116-
'client.files.delete',
117-
'client.files.get',
118-
'client.files.move',
119-
'client.files.rename',
120-
'client.files.update',
121-
'client.files.upload',
122-
'client.files.bulk.addTags',
123-
'client.files.bulk.delete',
124-
'client.files.bulk.removeAITags',
125-
'client.files.bulk.removeTags',
126-
'client.files.versions.delete',
127-
'client.files.versions.get',
128-
'client.files.versions.list',
129-
'client.files.versions.restore',
130-
'client.files.metadata.get',
131-
'client.files.metadata.getFromURL',
132-
'client.savedExtensions.create',
133-
'client.savedExtensions.delete',
134-
'client.savedExtensions.get',
135-
'client.savedExtensions.list',
136-
'client.savedExtensions.update',
137-
'client.assets.list',
138-
'client.cache.invalidation.create',
139-
'client.cache.invalidation.get',
140-
'client.folders.copy',
141-
'client.folders.create',
142-
'client.folders.delete',
143-
'client.folders.move',
144-
'client.folders.rename',
145-
'client.folders.job.get',
146-
'client.accounts.usage.get',
147-
'client.accounts.origins.create',
148-
'client.accounts.origins.delete',
149-
'client.accounts.origins.get',
150-
'client.accounts.origins.list',
151-
'client.accounts.origins.update',
152-
'client.accounts.urlEndpoints.create',
153-
'client.accounts.urlEndpoints.delete',
154-
'client.accounts.urlEndpoints.get',
155-
'client.accounts.urlEndpoints.list',
156-
'client.accounts.urlEndpoints.update',
157-
'client.beta.v2.files.upload',
158-
'client.webhooks.unsafeUnwrap',
159-
'client.webhooks.unwrap',
111+
"client.customMetadataFields.create",
112+
"client.customMetadataFields.delete",
113+
"client.customMetadataFields.list",
114+
"client.customMetadataFields.update",
115+
"client.files.copy",
116+
"client.files.delete",
117+
"client.files.get",
118+
"client.files.move",
119+
"client.files.rename",
120+
"client.files.update",
121+
"client.files.upload",
122+
"client.files.bulk.addTags",
123+
"client.files.bulk.delete",
124+
"client.files.bulk.removeAITags",
125+
"client.files.bulk.removeTags",
126+
"client.files.versions.delete",
127+
"client.files.versions.get",
128+
"client.files.versions.list",
129+
"client.files.versions.restore",
130+
"client.files.metadata.get",
131+
"client.files.metadata.getFromURL",
132+
"client.savedExtensions.create",
133+
"client.savedExtensions.delete",
134+
"client.savedExtensions.get",
135+
"client.savedExtensions.list",
136+
"client.savedExtensions.update",
137+
"client.assets.list",
138+
"client.cache.invalidation.create",
139+
"client.cache.invalidation.get",
140+
"client.folders.copy",
141+
"client.folders.create",
142+
"client.folders.delete",
143+
"client.folders.move",
144+
"client.folders.rename",
145+
"client.folders.job.get",
146+
"client.accounts.usage.get",
147+
"client.accounts.origins.create",
148+
"client.accounts.origins.delete",
149+
"client.accounts.origins.get",
150+
"client.accounts.origins.list",
151+
"client.accounts.origins.update",
152+
"client.accounts.urlEndpoints.create",
153+
"client.accounts.urlEndpoints.delete",
154+
"client.accounts.urlEndpoints.get",
155+
"client.accounts.urlEndpoints.list",
156+
"client.accounts.urlEndpoints.update",
157+
"client.beta.v2.files.upload",
158+
"client.webhooks.unsafeUnwrap",
159+
"client.webhooks.unwrap"
160160
],
161161
{ threshold: 1, shouldSort: true },
162162
);
@@ -239,12 +239,7 @@ function parseError(code: string, error: unknown): string | undefined {
239239
// Deno uses V8; the first "<anonymous>:LINE:COLUMN" is the top of stack.
240240
const lineNumber = error.stack?.match(/<anonymous>:([0-9]+):[0-9]+/)?.[1];
241241
// -1 for the zero-based indexing
242-
const line =
243-
lineNumber &&
244-
code
245-
.split('\n')
246-
.at(parseInt(lineNumber, 10) - 1)
247-
?.trim();
242+
const line = lineNumber && code.split('\n').at(parseInt(lineNumber, 10) - 1)?.trim();
248243
return line ? `${message}\n at line ${lineNumber}\n ${line}` : message;
249244
} catch {
250245
return message;
@@ -256,9 +251,8 @@ const fetch = async (req: Request): Promise<Response> => {
256251

257252
const runFunctionSource = code ? getRunFunctionSource(code) : null;
258253
if (!runFunctionSource) {
259-
const message =
260-
code ?
261-
'The code is missing a top-level `run` function.'
254+
const message = code
255+
? 'The code is missing a top-level `run` function.'
262256
: 'The code argument is missing. Provide one containing a top-level `run` function.';
263257
return Response.json(
264258
{
@@ -303,7 +297,7 @@ const fetch = async (req: Request): Promise<Response> => {
303297
try {
304298
let run_ = async (client: any) => {};
305299
run_ = (await tseval(`${code}\nexport default run;`)).default;
306-
const result = await run_(makeSdkProxy(client, { path: ['client'] }));
300+
const result = await run_(makeSdkProxy(client, { path: ["client"] }));
307301
return Response.json({
308302
is_error: false,
309303
result,

0 commit comments

Comments
 (0)