Skip to content

Commit 1f7d29c

Browse files
committed
Optimize schema
1 parent 0562ba2 commit 1f7d29c

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

src/tools/create-token-tool/CreateTokenTool.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class CreateTokenTool extends MapboxApiBasedTool<
2828
);
2929

3030
// Check if any secret scopes are being used
31-
const hasSecretScopes = input.scopes.some((scope) =>
31+
const hasSecretScopes = input.scopes?.some((scope) =>
3232
SECRET_SCOPES.includes(scope as (typeof SECRET_SCOPES)[number])
3333
);
3434

@@ -53,7 +53,7 @@ export class CreateTokenTool extends MapboxApiBasedTool<
5353
expires?: string;
5454
} = {
5555
note: input.note as string,
56-
scopes: input.scopes
56+
scopes: input.scopes || []
5757
};
5858

5959
if (input.allowedUrls) {

src/tools/style-comparison-tool/StyleComparisonTool.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,25 @@ export class StyleComparisonTool extends BaseTool<
1919
/**
2020
* Processes style input to extract username/styleId format
2121
*/
22-
private processStyleId(style: string, accessToken: string): string {
22+
private processStyleId(
23+
style: string | undefined,
24+
accessToken?: string
25+
): string {
2326
// If it's a full URL, extract the username/styleId part
24-
if (style.startsWith('mapbox://styles/')) {
27+
if (style?.startsWith('mapbox://styles/')) {
2528
return style.replace('mapbox://styles/', '');
2629
}
2730

2831
// If it contains a slash, assume it's already username/styleId format
29-
if (style.includes('/')) {
32+
if (style?.includes('/')) {
3033
return style;
3134
}
3235

3336
// If it's just a style ID, try to get username from the token
37+
if (!style) {
38+
throw new Error('Style is required');
39+
}
40+
3441
try {
3542
const username = MapboxApiBasedTool.getUserNameFromToken(accessToken);
3643
return `${username}/${style}`;

0 commit comments

Comments
 (0)