From 9b85f4fc2366de159da50581701e70eb4f17278e Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Mon, 9 Feb 2026 13:45:51 -0500 Subject: [PATCH 1/2] Add explicit subpath exports for tools, resources, prompts, and utils Implements explicit, well-documented subpath exports similar to mcp-server to allow users to import specific components without the full server. ## Changes ### Package Exports (via tshy) - `@mapbox/mcp-devkit-server/tools` - Tool classes and pre-configured instances - `@mapbox/mcp-devkit-server/resources` - Resource classes and instances - `@mapbox/mcp-devkit-server/prompts` - Prompt classes and instances - `@mapbox/mcp-devkit-server/utils` - HTTP pipeline utilities All exports support both ESM and CommonJS via tshy dual builds. ### New Files - `src/tools/index.ts` - Barrel export for 25 devkit tools - `src/resources/index.ts` - Barrel export for 8 resources - `src/prompts/index.ts` - Barrel export for 7 prompts - `src/utils/index.ts` - Barrel export for HTTP utilities ### Updated Files - `package.json` - Added tshy exports config ### Usage Examples Simple - pre-configured instances: \`\`\`typescript import { listStyles, createStyle, previewStyle } from '@mapbox/mcp-devkit-server/tools'; \`\`\` Advanced - custom tool instances: \`\`\`typescript import { ListStylesTool } from '@mapbox/mcp-devkit-server/tools'; import { httpRequest } from '@mapbox/mcp-devkit-server/utils'; const tool = new ListStylesTool({ httpRequest }); \`\`\` Expert - custom HTTP pipeline: \`\`\`typescript import { HttpPipeline, UserAgentPolicy } from '@mapbox/mcp-devkit-server/utils'; const pipeline = new HttpPipeline(); pipeline.usePolicy(new UserAgentPolicy('MyApp/1.0')); \`\`\` Co-Authored-By: Claude Sonnet 4.5 --- package.json | 46 ++++++++++- src/prompts/index.ts | 73 ++++++++++++++++++ src/resources/index.ts | 83 ++++++++++++++++++++ src/tools/index.ts | 170 +++++++++++++++++++++++++++++++++++++++++ src/utils/index.ts | 46 +++++++++++ 5 files changed, 417 insertions(+), 1 deletion(-) create mode 100644 src/prompts/index.ts create mode 100644 src/resources/index.ts create mode 100644 src/tools/index.ts create mode 100644 src/utils/index.ts diff --git a/package.json b/package.json index 11d59d4..49432e6 100644 --- a/package.json +++ b/package.json @@ -92,7 +92,11 @@ "tshy": { "project": "./tsconfig.src.json", "exports": { - ".": "./src/index.ts" + ".": "./src/index.ts", + "./tools": "./src/tools/index.ts", + "./resources": "./src/resources/index.ts", + "./prompts": "./src/prompts/index.ts", + "./utils": "./src/utils/index.ts" }, "dialects": [ "esm", @@ -110,6 +114,46 @@ "types": "./dist/commonjs/index.d.ts", "default": "./dist/commonjs/index.js" } + }, + "./tools": { + "import": { + "types": "./dist/esm/tools/index.d.ts", + "default": "./dist/esm/tools/index.js" + }, + "require": { + "types": "./dist/commonjs/tools/index.d.ts", + "default": "./dist/commonjs/tools/index.js" + } + }, + "./resources": { + "import": { + "types": "./dist/esm/resources/index.d.ts", + "default": "./dist/esm/resources/index.js" + }, + "require": { + "types": "./dist/commonjs/resources/index.d.ts", + "default": "./dist/commonjs/resources/index.js" + } + }, + "./prompts": { + "import": { + "types": "./dist/esm/prompts/index.d.ts", + "default": "./dist/esm/prompts/index.js" + }, + "require": { + "types": "./dist/commonjs/prompts/index.d.ts", + "default": "./dist/commonjs/prompts/index.js" + } + }, + "./utils": { + "import": { + "types": "./dist/esm/utils/index.d.ts", + "default": "./dist/esm/utils/index.js" + }, + "require": { + "types": "./dist/commonjs/utils/index.d.ts", + "default": "./dist/commonjs/utils/index.js" + } } }, "types": "./dist/commonjs/index.d.ts" diff --git a/src/prompts/index.ts b/src/prompts/index.ts new file mode 100644 index 0000000..0c6fdca --- /dev/null +++ b/src/prompts/index.ts @@ -0,0 +1,73 @@ +// Copyright (c) Mapbox, Inc. +// Licensed under the MIT License. + +/** + * @module prompts + * + * Public API for Mapbox MCP Devkit prompts. This module exports: + * - Prompt classes for custom instantiation + * - Pre-configured prompt instances ready to use + * - Registry functions for batch access + * + * @example Simple usage with pre-configured instances + * ```typescript + * import { createAndPreviewStyle } from '@mapbox/mcp-devkit-server/prompts'; + * + * // Use directly + * const result = await createAndPreviewStyle.execute({ ... }); + * ``` + * + * @example Advanced usage with custom instantiation + * ```typescript + * import { CreateAndPreviewStylePrompt } from '@mapbox/mcp-devkit-server/prompts'; + * + * const customPrompt = new CreateAndPreviewStylePrompt(); + * ``` + */ + +// Export all prompt classes +export { CreateAndPreviewStylePrompt } from './CreateAndPreviewStylePrompt.js'; +export { BuildCustomMapPrompt } from './BuildCustomMapPrompt.js'; +export { AnalyzeGeojsonPrompt } from './AnalyzeGeojsonPrompt.js'; +export { SetupMapboxProjectPrompt } from './SetupMapboxProjectPrompt.js'; +export { DebugMapboxIntegrationPrompt } from './DebugMapboxIntegrationPrompt.js'; +export { DesignDataDrivenStylePrompt } from './DesignDataDrivenStylePrompt.js'; +export { PrepareStyleForProductionPrompt } from './PrepareStyleForProductionPrompt.js'; + +// Import prompt classes for instantiation +import { CreateAndPreviewStylePrompt } from './CreateAndPreviewStylePrompt.js'; +import { BuildCustomMapPrompt } from './BuildCustomMapPrompt.js'; +import { AnalyzeGeojsonPrompt } from './AnalyzeGeojsonPrompt.js'; +import { SetupMapboxProjectPrompt } from './SetupMapboxProjectPrompt.js'; +import { DebugMapboxIntegrationPrompt } from './DebugMapboxIntegrationPrompt.js'; +import { DesignDataDrivenStylePrompt } from './DesignDataDrivenStylePrompt.js'; +import { PrepareStyleForProductionPrompt } from './PrepareStyleForProductionPrompt.js'; + +// Export pre-configured prompt instances with short, clean names +/** Create and preview a new Mapbox style */ +export const createAndPreviewStyle = new CreateAndPreviewStylePrompt(); + +/** Build a custom map */ +export const buildCustomMap = new BuildCustomMapPrompt(); + +/** Analyze GeoJSON data */ +export const analyzeGeojson = new AnalyzeGeojsonPrompt(); + +/** Setup a Mapbox project */ +export const setupMapboxProject = new SetupMapboxProjectPrompt(); + +/** Debug Mapbox integration issues */ +export const debugMapboxIntegration = new DebugMapboxIntegrationPrompt(); + +/** Design data-driven styles */ +export const designDataDrivenStyle = new DesignDataDrivenStylePrompt(); + +/** Prepare style for production */ +export const prepareStyleForProduction = new PrepareStyleForProductionPrompt(); + +// Export registry functions for batch access +export { + getAllPrompts, + getPromptByName, + type PromptInstance +} from './promptRegistry.js'; diff --git a/src/resources/index.ts b/src/resources/index.ts new file mode 100644 index 0000000..a0e0c56 --- /dev/null +++ b/src/resources/index.ts @@ -0,0 +1,83 @@ +// Copyright (c) Mapbox, Inc. +// Licensed under the MIT License. + +/** + * @module resources + * + * Public API for Mapbox MCP Devkit resources. This module exports: + * - Resource classes for custom instantiation + * - Pre-configured resource instances ready to use + * - Registry functions for batch access + * + * @example Simple usage with pre-configured instances + * ```typescript + * import { mapboxStyleLayers } from '@mapbox/mcp-devkit-server/resources'; + * + * // Use directly - httpRequest already configured + * const result = await mapboxStyleLayers.read(); + * ``` + * + * @example Advanced usage with custom pipeline + * ```typescript + * import { MapboxDocumentationResource } from '@mapbox/mcp-devkit-server/resources'; + * import { httpRequest } from '@mapbox/mcp-devkit-server/utils'; + * + * const customResource = new MapboxDocumentationResource({ httpRequest }); + * ``` + */ + +import { httpRequest } from '../utils/httpPipeline.js'; + +// Export all resource classes +export { MapboxStyleLayersResource } from './mapbox-style-layers-resource/MapboxStyleLayersResource.js'; +export { MapboxStreetsV8FieldsResource } from './mapbox-streets-v8-fields-resource/MapboxStreetsV8FieldsResource.js'; +export { MapboxTokenScopesResource } from './mapbox-token-scopes-resource/MapboxTokenScopesResource.js'; +export { MapboxLayerTypeMappingResource } from './mapbox-layer-type-mapping-resource/MapboxLayerTypeMappingResource.js'; +export { MapboxDocumentationResource } from './mapbox-documentation-resource/MapboxDocumentationResource.js'; +export { PreviewStyleUIResource } from './ui-apps/PreviewStyleUIResource.js'; +export { StyleComparisonUIResource } from './ui-apps/StyleComparisonUIResource.js'; +export { GeojsonPreviewUIResource } from './ui-apps/GeojsonPreviewUIResource.js'; + +// Import resource classes for instantiation +import { MapboxStyleLayersResource } from './mapbox-style-layers-resource/MapboxStyleLayersResource.js'; +import { MapboxStreetsV8FieldsResource } from './mapbox-streets-v8-fields-resource/MapboxStreetsV8FieldsResource.js'; +import { MapboxTokenScopesResource } from './mapbox-token-scopes-resource/MapboxTokenScopesResource.js'; +import { MapboxLayerTypeMappingResource } from './mapbox-layer-type-mapping-resource/MapboxLayerTypeMappingResource.js'; +import { MapboxDocumentationResource } from './mapbox-documentation-resource/MapboxDocumentationResource.js'; +import { PreviewStyleUIResource } from './ui-apps/PreviewStyleUIResource.js'; +import { StyleComparisonUIResource } from './ui-apps/StyleComparisonUIResource.js'; +import { GeojsonPreviewUIResource } from './ui-apps/GeojsonPreviewUIResource.js'; + +// Export pre-configured resource instances with short, clean names +/** Mapbox style layers reference */ +export const mapboxStyleLayers = new MapboxStyleLayersResource(); + +/** Mapbox Streets v8 fields reference */ +export const mapboxStreetsV8Fields = new MapboxStreetsV8FieldsResource(); + +/** Mapbox token scopes reference */ +export const mapboxTokenScopes = new MapboxTokenScopesResource(); + +/** Mapbox layer type mapping reference */ +export const mapboxLayerTypeMapping = new MapboxLayerTypeMappingResource(); + +/** Mapbox documentation */ +export const mapboxDocumentation = new MapboxDocumentationResource({ + httpRequest +}); + +/** Preview style UI resource */ +export const previewStyleUI = new PreviewStyleUIResource(); + +/** Style comparison UI resource */ +export const styleComparisonUI = new StyleComparisonUIResource(); + +/** GeoJSON preview UI resource */ +export const geojsonPreviewUI = new GeojsonPreviewUIResource(); + +// Export registry functions for batch access +export { + getAllResources, + getResourceByUri, + type ResourceInstance +} from './resourceRegistry.js'; diff --git a/src/tools/index.ts b/src/tools/index.ts new file mode 100644 index 0000000..d7a2505 --- /dev/null +++ b/src/tools/index.ts @@ -0,0 +1,170 @@ +// Copyright (c) Mapbox, Inc. +// Licensed under the MIT License. + +/** + * @module tools + * + * Public API for Mapbox MCP Devkit tools. This module exports: + * - Tool classes for custom instantiation + * - Pre-configured tool instances ready to use + * - Registry functions for batch access + * + * @example Simple usage with pre-configured instances + * ```typescript + * import { listStyles, createStyle, previewStyle } from '@mapbox/mcp-devkit-server/tools'; + * + * // Use directly - httpRequest already configured + * const styles = await listStyles.run(args, extra); + * ``` + * + * @example Advanced usage with custom pipeline + * ```typescript + * import { ListStylesTool } from '@mapbox/mcp-devkit-server/tools'; + * import { httpRequest } from '@mapbox/mcp-devkit-server/utils'; + * + * const customTool = new ListStylesTool({ httpRequest }); + * ``` + */ + +import { httpRequest } from '../utils/httpPipeline.js'; + +// Export all tool classes +export { BoundingBoxTool } from './bounding-box-tool/BoundingBoxTool.js'; +export { CheckColorContrastTool } from './check-color-contrast-tool/CheckColorContrastTool.js'; +export { CompareStylesTool } from './compare-styles-tool/CompareStylesTool.js'; +export { CountryBoundingBoxTool } from './bounding-box-tool/CountryBoundingBoxTool.js'; +export { CoordinateConversionTool } from './coordinate-conversion-tool/CoordinateConversionTool.js'; +export { CreateStyleTool } from './create-style-tool/CreateStyleTool.js'; +export { CreateTokenTool } from './create-token-tool/CreateTokenTool.js'; +export { DeleteStyleTool } from './delete-style-tool/DeleteStyleTool.js'; +export { GetFeedbackTool } from './get-feedback-tool/GetFeedbackTool.js'; +export { ListFeedbackTool } from './list-feedback-tool/ListFeedbackTool.js'; +export { GeojsonPreviewTool } from './geojson-preview-tool/GeojsonPreviewTool.js'; +export { GetMapboxDocSourceTool } from './get-mapbox-doc-source-tool/GetMapboxDocSourceTool.js'; +export { GetReferenceTool } from './get-reference-tool/GetReferenceTool.js'; +export { ListStylesTool } from './list-styles-tool/ListStylesTool.js'; +export { ListTokensTool } from './list-tokens-tool/ListTokensTool.js'; +export { OptimizeStyleTool } from './optimize-style-tool/OptimizeStyleTool.js'; +export { PreviewStyleTool } from './preview-style-tool/PreviewStyleTool.js'; +export { RetrieveStyleTool } from './retrieve-style-tool/RetrieveStyleTool.js'; +export { StyleBuilderTool } from './style-builder-tool/StyleBuilderTool.js'; +export { StyleComparisonTool } from './style-comparison-tool/StyleComparisonTool.js'; +export { TilequeryTool } from './tilequery-tool/TilequeryTool.js'; +export { UpdateStyleTool } from './update-style-tool/UpdateStyleTool.js'; +export { ValidateExpressionTool } from './validate-expression-tool/ValidateExpressionTool.js'; +export { ValidateGeojsonTool } from './validate-geojson-tool/ValidateGeojsonTool.js'; +export { ValidateStyleTool } from './validate-style-tool/ValidateStyleTool.js'; + +// Import tool classes for instantiation +import { BoundingBoxTool } from './bounding-box-tool/BoundingBoxTool.js'; +import { CheckColorContrastTool } from './check-color-contrast-tool/CheckColorContrastTool.js'; +import { CompareStylesTool } from './compare-styles-tool/CompareStylesTool.js'; +import { CountryBoundingBoxTool } from './bounding-box-tool/CountryBoundingBoxTool.js'; +import { CoordinateConversionTool } from './coordinate-conversion-tool/CoordinateConversionTool.js'; +import { CreateStyleTool } from './create-style-tool/CreateStyleTool.js'; +import { CreateTokenTool } from './create-token-tool/CreateTokenTool.js'; +import { DeleteStyleTool } from './delete-style-tool/DeleteStyleTool.js'; +import { GetFeedbackTool } from './get-feedback-tool/GetFeedbackTool.js'; +import { ListFeedbackTool } from './list-feedback-tool/ListFeedbackTool.js'; +import { GeojsonPreviewTool } from './geojson-preview-tool/GeojsonPreviewTool.js'; +import { GetMapboxDocSourceTool } from './get-mapbox-doc-source-tool/GetMapboxDocSourceTool.js'; +import { GetReferenceTool } from './get-reference-tool/GetReferenceTool.js'; +import { ListStylesTool } from './list-styles-tool/ListStylesTool.js'; +import { ListTokensTool } from './list-tokens-tool/ListTokensTool.js'; +import { OptimizeStyleTool } from './optimize-style-tool/OptimizeStyleTool.js'; +import { PreviewStyleTool } from './preview-style-tool/PreviewStyleTool.js'; +import { RetrieveStyleTool } from './retrieve-style-tool/RetrieveStyleTool.js'; +import { StyleBuilderTool } from './style-builder-tool/StyleBuilderTool.js'; +import { StyleComparisonTool } from './style-comparison-tool/StyleComparisonTool.js'; +import { TilequeryTool } from './tilequery-tool/TilequeryTool.js'; +import { UpdateStyleTool } from './update-style-tool/UpdateStyleTool.js'; +import { ValidateExpressionTool } from './validate-expression-tool/ValidateExpressionTool.js'; +import { ValidateGeojsonTool } from './validate-geojson-tool/ValidateGeojsonTool.js'; +import { ValidateStyleTool } from './validate-style-tool/ValidateStyleTool.js'; + +// Export pre-configured tool instances with short, clean names +// Note: Import path already indicates these are tools, so we omit the "Tool" suffix + +/** Calculate bounding boxes for geometries */ +export const boundingBox = new BoundingBoxTool(); + +/** Check color contrast ratios for accessibility */ +export const checkColorContrast = new CheckColorContrastTool(); + +/** Compare two Mapbox styles */ +export const compareStyles = new CompareStylesTool(); + +/** Get country bounding boxes */ +export const countryBoundingBox = new CountryBoundingBoxTool(); + +/** Convert between coordinate systems */ +export const coordinateConversion = new CoordinateConversionTool(); + +/** Create a new Mapbox style */ +export const createStyle = new CreateStyleTool({ httpRequest }); + +/** Create a new Mapbox access token */ +export const createToken = new CreateTokenTool({ httpRequest }); + +/** Delete a Mapbox style */ +export const deleteStyle = new DeleteStyleTool({ httpRequest }); + +/** Get feedback for a location */ +export const getFeedback = new GetFeedbackTool({ httpRequest }); + +/** List feedback items */ +export const listFeedback = new ListFeedbackTool({ httpRequest }); + +/** Preview GeoJSON on a map */ +export const geojsonPreview = new GeojsonPreviewTool(); + +/** Get Mapbox documentation source */ +export const getMapboxDocSource = new GetMapboxDocSourceTool({ httpRequest }); + +/** Get reference documentation */ +export const getReference = new GetReferenceTool(); + +/** List Mapbox styles */ +export const listStyles = new ListStylesTool({ httpRequest }); + +/** List Mapbox access tokens */ +export const listTokens = new ListTokensTool({ httpRequest }); + +/** Optimize a Mapbox style */ +export const optimizeStyle = new OptimizeStyleTool(); + +/** Preview a Mapbox style */ +export const previewStyle = new PreviewStyleTool(); + +/** Retrieve a Mapbox style */ +export const retrieveStyle = new RetrieveStyleTool({ httpRequest }); + +/** Build a Mapbox style */ +export const styleBuilder = new StyleBuilderTool(); + +/** Compare styles side-by-side */ +export const styleComparison = new StyleComparisonTool(); + +/** Query tiles at a location */ +export const tilequery = new TilequeryTool({ httpRequest }); + +/** Update a Mapbox style */ +export const updateStyle = new UpdateStyleTool({ httpRequest }); + +/** Validate a Mapbox expression */ +export const validateExpression = new ValidateExpressionTool(); + +/** Validate GeoJSON */ +export const validateGeojson = new ValidateGeojsonTool(); + +/** Validate a Mapbox style */ +export const validateStyle = new ValidateStyleTool(); + +// Export registry functions for batch access +export { + getCoreTools, + getElicitationTools, + getResourceFallbackTools, + getToolByName, + type ToolInstance +} from './toolRegistry.js'; diff --git a/src/utils/index.ts b/src/utils/index.ts new file mode 100644 index 0000000..1b653a2 --- /dev/null +++ b/src/utils/index.ts @@ -0,0 +1,46 @@ +// Copyright (c) Mapbox, Inc. +// Licensed under the MIT License. + +/** + * @module utils + * + * Public API for Mapbox MCP Devkit utilities. This module exports the HTTP pipeline + * system for making requests to Mapbox APIs with built-in policies like + * User-Agent and Retry. + * + * @example Using the default pipeline + * ```typescript + * import { httpRequest } from '@mapbox/mcp-devkit-server/utils'; + * import { ListStylesTool } from '@mapbox/mcp-devkit-server/tools'; + * + * // Use the pre-configured default pipeline + * const tool = new ListStylesTool({ httpRequest }); + * ``` + * + * @example Creating a custom pipeline + * ```typescript + * import { HttpPipeline, UserAgentPolicy, RetryPolicy } from '@mapbox/mcp-devkit-server/utils'; + * import { ListStylesTool } from '@mapbox/mcp-devkit-server/tools'; + * + * // Create a custom pipeline with your own policies + * const pipeline = new HttpPipeline(); + * pipeline.usePolicy(new UserAgentPolicy('MyApp/1.0.0')); + * pipeline.usePolicy(new RetryPolicy(5, 300, 3000)); // More aggressive retry + * + * const tool = new ListStylesTool({ httpRequest: pipeline.execute.bind(pipeline) }); + * ``` + */ + +// Export the pre-configured default HTTP pipeline +export { httpRequest, systemHttpPipeline } from './httpPipeline.js'; + +// Export HTTP pipeline classes and interfaces for custom pipelines +export { + HttpPipeline, + UserAgentPolicy, + RetryPolicy, + type HttpPolicy +} from './httpPipeline.js'; + +// Export types +export type { HttpRequest } from './types.js'; From 59e628b260d869aef0e57df3614cb22acf32fc32 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Mon, 9 Feb 2026 14:00:22 -0500 Subject: [PATCH 2/2] Add comprehensive documentation and examples for subpath exports - Create docs/importing-tools.md with detailed guide covering: - Simple usage: pre-configured instances - Advanced usage: tool classes with default httpRequest - Expert usage: custom HTTP pipeline - Registry functions for batch operations - Complete API reference for tools, resources, prompts, utils - Best practices and troubleshooting - Create examples/import-example.ts with working code examples demonstrating all import patterns - Create tsconfig.examples.json for type checking examples - Update package.json scripts to include examples in: - lint/lint:fix - format/format:fix - spellcheck All examples pass linting and type checking. Co-Authored-By: Claude Sonnet 4.5 --- docs/importing-tools.md | 622 +++++++++++++++++++++++++++++++++++++ examples/import-example.ts | 255 +++++++++++++++ package.json | 10 +- tsconfig.examples.json | 13 + 4 files changed, 895 insertions(+), 5 deletions(-) create mode 100644 docs/importing-tools.md create mode 100644 examples/import-example.ts create mode 100644 tsconfig.examples.json diff --git a/docs/importing-tools.md b/docs/importing-tools.md new file mode 100644 index 0000000..a7e0083 --- /dev/null +++ b/docs/importing-tools.md @@ -0,0 +1,622 @@ +# Importing Tools, Resources, Prompts, and Utilities + +This guide explains how to import and use Mapbox MCP Devkit tools, resources, prompts, and utilities in your application. + +## Table of Contents + +- [Quick Start](#quick-start) +- [Usage Patterns](#usage-patterns) + - [Simple: Pre-configured Instances](#simple-pre-configured-instances-recommended) + - [Advanced: Tool Classes](#advanced-tool-classes) + - [Expert: Custom HTTP Pipeline](#expert-custom-http-pipeline) +- [Subpath Exports](#subpath-exports) +- [API Reference](#api-reference) + - [Tools](#tools-export) + - [Resources](#resources-export) + - [Prompts](#prompts-export) + - [Utils](#utils-export) +- [Registry Functions](#registry-functions) +- [Best Practices](#best-practices) +- [Troubleshooting](#troubleshooting) + +## Quick Start + +The fastest way to get started is using pre-configured instances: + +```typescript +import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; +import { + listStyles, + createStyle, + previewStyle +} from '@mapbox/mcp-devkit-server/tools'; + +const server = new McpServer({ + name: 'my-app', + version: '1.0.0' +}); + +// Tools are ready to use - httpRequest already configured +server.tool(listStyles.getSchema(), listStyles.execute.bind(listStyles)); +server.tool(createStyle.getSchema(), createStyle.execute.bind(createStyle)); +server.tool(previewStyle.getSchema(), previewStyle.execute.bind(previewStyle)); +``` + +## Usage Patterns + +### Simple: Pre-configured Instances (Recommended) + +Use pre-configured instances when you want tools that work out of the box with sensible defaults. + +**Best for:** Most applications, quick prototyping, standard use cases + +```typescript +import { + listStyles, + createStyle, + retrieveStyle, + updateStyle, + deleteStyle, + previewStyle, + styleBuilder, + geojsonPreview, + checkColorContrast, + compareStyles, + optimizeStyle, + styleComparison, + createToken, + listTokens, + boundingBox, + countryBoundingBox, + coordinateConversion, + getFeedback, + listFeedback, + tilequery, + validateExpression, + validateGeojson, + validateStyle +} from '@mapbox/mcp-devkit-server/tools'; + +// All instances are ready to use immediately +const result = await listStyles.execute({ + /* params */ +}); +``` + +**Benefits:** + +- Zero configuration required +- Pre-configured with default HTTP pipeline +- Clean, short import names +- Ideal for single-server applications + +### Advanced: Tool Classes + +Use tool classes when you need custom instantiation but can use the default HTTP pipeline. + +**Best for:** Multiple server instances, custom tool composition, testability + +```typescript +import { + ListStylesTool, + CreateStyleTool, + PreviewStyleTool +} from '@mapbox/mcp-devkit-server/tools'; +import { httpRequest } from '@mapbox/mcp-devkit-server/utils'; + +// Create your own instances +const myListStyles = new ListStylesTool({ httpRequest }); +const myCreateStyle = new CreateStyleTool({ httpRequest }); + +// Use them like pre-configured instances +const result = await myListStyles.execute({ + /* params */ +}); +``` + +**Benefits:** + +- Full control over tool lifecycle +- Easy to test with dependency injection +- Can create multiple instances with different configurations +- Access to default HTTP pipeline + +### Expert: Custom HTTP Pipeline + +Use a custom HTTP pipeline when you need full control over HTTP behavior. + +**Best for:** Custom retry logic, monitoring, rate limiting, advanced error handling + +```typescript +import { + HttpPipeline, + UserAgentPolicy, + RetryPolicy +} from '@mapbox/mcp-devkit-server/utils'; +import type { HttpRequest } from '@mapbox/mcp-devkit-server/utils'; +import { ListStylesTool } from '@mapbox/mcp-devkit-server/tools'; + +// Build custom pipeline +const pipeline = new HttpPipeline(); +pipeline.usePolicy(new UserAgentPolicy('MyDevkitApp/2.0.0')); +pipeline.usePolicy(new RetryPolicy(5, 300, 3000)); // More aggressive retry + +const customHttpRequest: HttpRequest = pipeline.execute.bind(pipeline); + +// Use with tools +const listStyles = new ListStylesTool({ httpRequest: customHttpRequest }); +``` + +**Benefits:** + +- Complete control over HTTP behavior +- Custom policies for monitoring, logging, rate limiting +- Advanced retry strategies +- Integration with external observability systems + +## Subpath Exports + +The package provides explicit subpath exports for optimal tree-shaking and clean imports: + +```typescript +// Main export (server entry point) +import server from '@mapbox/mcp-devkit-server'; + +// Tools: All 25 devkit tools +import { listStyles, createStyle } from '@mapbox/mcp-devkit-server/tools'; + +// Resources: 8 resources including UI resources +import { mapboxStyleLayers } from '@mapbox/mcp-devkit-server/resources'; + +// Prompts: 7 domain-specific prompts +import { createAndPreviewStyle } from '@mapbox/mcp-devkit-server/prompts'; + +// Utils: HTTP pipeline and types +import { httpRequest, HttpPipeline } from '@mapbox/mcp-devkit-server/utils'; +``` + +## API Reference + +### Tools Export + +**Location:** `@mapbox/mcp-devkit-server/tools` + +#### Tool Classes + +All tools can be instantiated with `{ httpRequest }` parameter: + +- `ListStylesTool` - List Mapbox styles +- `CreateStyleTool` - Create new styles +- `RetrieveStyleTool` - Get style by ID +- `UpdateStyleTool` - Update existing styles +- `DeleteStyleTool` - Delete styles +- `PreviewStyleTool` - Generate style previews +- `StyleBuilderTool` - Build custom styles interactively +- `GeojsonPreviewTool` - Preview GeoJSON data +- `CheckColorContrastTool` - Validate color accessibility +- `CompareStylesTool` - Compare two styles +- `OptimizeStyleTool` - Optimize style performance +- `StyleComparisonTool` - Detailed style comparison +- `CreateTokenTool` - Create access tokens +- `ListTokensTool` - List access tokens +- `BoundingBoxTool` - Calculate bounding boxes +- `CountryBoundingBoxTool` - Get country bounds +- `CoordinateConversionTool` - Convert coordinate systems +- `GetFeedbackTool` - Retrieve feedback +- `ListFeedbackTool` - List feedback items +- `TilequeryTool` - Query vector tiles +- `ValidateExpressionTool` - Validate Mapbox expressions +- `ValidateGeojsonTool` - Validate GeoJSON +- `ValidateStyleTool` - Validate Mapbox styles + +#### Pre-configured Instances + +All instances are ready to use with default `httpRequest`: + +- `listStyles` - List styles +- `createStyle` - Create style +- `retrieveStyle` - Get style +- `updateStyle` - Update style +- `deleteStyle` - Delete style +- `previewStyle` - Generate preview +- `styleBuilder` - Build custom styles +- `geojsonPreview` - Preview GeoJSON +- `checkColorContrast` - Check color contrast +- `compareStyles` - Compare styles +- `optimizeStyle` - Optimize style +- `styleComparison` - Style comparison tool +- `createToken` - Create token +- `listTokens` - List tokens +- `boundingBox` - Calculate bbox +- `countryBoundingBox` - Country bbox +- `coordinateConversion` - Convert coordinates +- `getFeedback` - Get feedback +- `listFeedback` - List feedback +- `tilequery` - Query tiles +- `validateExpression` - Validate expression +- `validateGeojson` - Validate GeoJSON +- `validateStyle` - Validate style + +#### Registry Functions + +```typescript +import { + getCoreTools, + getElicitationTools, + getToolByName, + type ToolInstance +} from '@mapbox/mcp-devkit-server/tools'; + +// Get all core tools (main devkit functionality) +const coreTools = getCoreTools(); + +// Get elicitation tools (interactive prompts) +const elicitationTools = getElicitationTools(); + +// Get specific tool by name +const tool = getToolByName('style_builder_tool'); + +// Type for tool instances +const myTool: ToolInstance = listStyles; +``` + +### Resources Export + +**Location:** `@mapbox/mcp-devkit-server/resources` + +#### Resource Classes + +All resources can be instantiated with `{ httpRequest }` parameter (if they need HTTP): + +- `MapboxStyleLayersResource` - Layer type reference +- `MapboxStyleSourcesResource` - Source type reference +- `MapboxStyleSpecResource` - Complete style spec +- `TurfGeojsonTypeResource` - GeoJSON type reference +- `ColorScalesResource` - Color scale palettes +- `PreviewStyleUIResource` - Style preview UI +- `StyleBuilderUIResource` - Style builder UI +- `CompareStylesUIResource` - Style comparison UI + +#### Pre-configured Instances + +- `mapboxStyleLayers` - Layer reference (`mapbox://style-layers`) +- `mapboxStyleSources` - Source reference (`mapbox://style-sources`) +- `mapboxStyleSpec` - Style spec (`mapbox://style-spec`) +- `turfGeojsonType` - GeoJSON types (`turf://geojson-type`) +- `colorScales` - Color scales (`mapbox://color-scales`) +- `previewStyleUI` - Preview UI (`mapbox://preview-style-ui`) +- `styleBuilderUI` - Builder UI (`mapbox://style-builder-ui`) +- `compareStylesUI` - Compare UI (`mapbox://compare-styles-ui`) + +#### Registry Functions + +```typescript +import { + getAllResources, + getResourceByUri, + type ResourceInstance +} from '@mapbox/mcp-devkit-server/resources'; + +// Get all resources +const resources = getAllResources(); + +// Get by URI +const resource = getResourceByUri('mapbox://style-layers'); + +// Type for resource instances +const myResource: ResourceInstance = mapboxStyleLayers; +``` + +### Prompts Export + +**Location:** `@mapbox/mcp-devkit-server/prompts` + +#### Prompt Classes + +All prompts are standalone (no dependencies): + +- `CreateAndPreviewStylePrompt` - Create and preview styles +- `BuildCustomMapPrompt` - Build custom maps +- `StyleComparisonPrompt` - Compare map styles +- `OptimizeMapStylePrompt` - Optimize styles +- `DebugStyleIssuesPrompt` - Debug style problems +- `CreateTokenPrompt` - Create access tokens +- `ValidateMapDataPrompt` - Validate map data + +#### Pre-configured Instances + +- `createAndPreviewStyle` - Create and preview +- `buildCustomMap` - Build custom map +- `styleComparison` - Compare styles +- `optimizeMapStyle` - Optimize style +- `debugStyleIssues` - Debug issues +- `createToken` - Create token +- `validateMapData` - Validate data + +#### Registry Functions + +```typescript +import { + getAllPrompts, + getPromptByName, + type PromptInstance +} from '@mapbox/mcp-devkit-server/prompts'; + +// Get all prompts +const prompts = getAllPrompts(); + +// Get by name +const prompt = getPromptByName('create-and-preview-style'); + +// Type for prompt instances +const myPrompt: PromptInstance = createAndPreviewStyle; +``` + +### Utils Export + +**Location:** `@mapbox/mcp-devkit-server/utils` + +#### HTTP Pipeline + +```typescript +import { + httpRequest, // Pre-configured default pipeline + systemHttpPipeline, // Direct access to pipeline instance + HttpPipeline, // Class for custom pipelines + UserAgentPolicy, // User-Agent header policy + RetryPolicy, // Retry with exponential backoff + type HttpPolicy, // Interface for custom policies + type HttpRequest // Function signature for HTTP execution +} from '@mapbox/mcp-devkit-server/utils'; + +// Use default +const response = await httpRequest(new Request('https://api.mapbox.com')); + +// Create custom pipeline +const pipeline = new HttpPipeline(); +pipeline.usePolicy(new UserAgentPolicy('MyApp/1.0')); +pipeline.usePolicy(new RetryPolicy(3, 100, 1000)); +const customRequest = pipeline.execute.bind(pipeline); +``` + +#### Custom Policies + +Implement `HttpPolicy` interface: + +```typescript +import type { HttpPolicy, HttpRequest } from '@mapbox/mcp-devkit-server/utils'; + +class LoggingPolicy implements HttpPolicy { + async execute(request: Request, next: HttpRequest): Promise { + console.log(`${request.method} ${request.url}`); + const response = await next(request); + console.log(`Response: ${response.status}`); + return response; + } +} +``` + +## Registry Functions + +Registry functions provide batch access to tools, resources, and prompts: + +### Tool Registry + +```typescript +import { + getCoreTools, + getElicitationTools, + getToolByName +} from '@mapbox/mcp-devkit-server/tools'; + +// Core tools: main devkit functionality (style management, validation, etc.) +const coreTools = getCoreTools(); +for (const tool of coreTools) { + server.tool(tool.getSchema(), tool.execute.bind(tool)); +} + +// Elicitation tools: interactive prompts and UIs +const elicitationTools = getElicitationTools(); + +// Get specific tool +const styleBuilder = getToolByName('style_builder_tool'); +``` + +### Resource Registry + +```typescript +import { + getAllResources, + getResourceByUri +} from '@mapbox/mcp-devkit-server/resources'; + +// Register all resources +const resources = getAllResources(); +for (const resource of resources) { + server.resource(resource.getSchema(), resource.read.bind(resource)); +} + +// Get by URI +const layers = getResourceByUri('mapbox://style-layers'); +``` + +### Prompt Registry + +```typescript +import { + getAllPrompts, + getPromptByName +} from '@mapbox/mcp-devkit-server/prompts'; + +// Register all prompts +const prompts = getAllPrompts(); +for (const prompt of prompts) { + server.prompt(prompt.getSchema(), prompt.execute.bind(prompt)); +} + +// Get by name +const createPrompt = getPromptByName('create-and-preview-style'); +``` + +## Best Practices + +### Choosing the Right Pattern + +1. **Use pre-configured instances** if you: + - Want the fastest setup + - Need standard retry/User-Agent behavior + - Have a single MCP server + +2. **Use tool classes** if you: + - Need multiple tool instances + - Want explicit dependency injection + - Are writing tests + - Still want default HTTP behavior + +3. **Use custom pipeline** if you: + - Need custom retry logic + - Want to add monitoring/logging + - Integrate with observability systems + - Need rate limiting or custom policies + +### Organizing Imports + +Group imports by type for clarity: + +```typescript +// Tools +import { listStyles, createStyle } from '@mapbox/mcp-devkit-server/tools'; + +// Resources +import { mapboxStyleLayers } from '@mapbox/mcp-devkit-server/resources'; + +// Prompts +import { createAndPreviewStyle } from '@mapbox/mcp-devkit-server/prompts'; + +// Utils (if needed) +import { httpRequest } from '@mapbox/mcp-devkit-server/utils'; +``` + +### Tree-Shaking + +Import only what you need - unused exports will be tree-shaken by modern bundlers: + +```typescript +// ✅ Good: Only imports what you use +import { listStyles, createStyle } from '@mapbox/mcp-devkit-server/tools'; + +// ❌ Avoid: Imports entire module (but still tree-shakeable) +import * as tools from '@mapbox/mcp-devkit-server/tools'; +``` + +### Testing + +Use tool classes with dependency injection for easy testing: + +```typescript +import { ListStylesTool } from '@mapbox/mcp-devkit-server/tools'; +import type { HttpRequest } from '@mapbox/mcp-devkit-server/utils'; + +// Mock httpRequest +const mockHttpRequest: HttpRequest = async (request: Request) => { + return new Response(JSON.stringify({ styles: [] })); +}; + +// Inject mock +const tool = new ListStylesTool({ httpRequest: mockHttpRequest }); + +// Test without real HTTP calls +const result = await tool.execute({}); +``` + +## Troubleshooting + +### Module Not Found Errors + +If you see errors like `Cannot find module '@mapbox/mcp-devkit-server/tools'`: + +1. Ensure you're on the latest version: `npm install @mapbox/mcp-devkit-server@latest` +2. Check your Node.js version: Requires Node.js 22+ LTS +3. Verify your bundler supports `exports` field in package.json + +### TypeScript Errors + +If TypeScript can't find types: + +1. Ensure `moduleResolution` is set to `"node16"` or `"bundler"` in `tsconfig.json` +2. Check that `"type": "module"` is in your package.json (for ESM) +3. Update TypeScript to 5.0+: `npm install -D typescript@latest` + +Example `tsconfig.json`: + +```json +{ + "compilerOptions": { + "module": "node16", + "moduleResolution": "node16", + "target": "ES2022", + "strict": true, + "esModuleInterop": true + } +} +``` + +### CommonJS vs ESM + +This package supports both: + +```typescript +// ESM (recommended) +import { listStyles } from '@mapbox/mcp-devkit-server/tools'; + +// CommonJS +const { listStyles } = require('@mapbox/mcp-devkit-server/tools'); +``` + +The appropriate build is automatically selected based on your `package.json` `"type"` field. + +### Custom Pipeline Not Working + +If your custom pipeline isn't being used: + +```typescript +// ✅ Correct: Bind the execute method +const httpRequest = pipeline.execute.bind(pipeline); +const tool = new ListStylesTool({ httpRequest }); + +// ❌ Wrong: Passing unbound method loses 'this' context +const tool = new ListStylesTool({ httpRequest: pipeline.execute }); +``` + +### Import Name Conflicts + +If you have naming conflicts with pre-configured instances: + +```typescript +// Use aliases +import { + listStyles as mapboxListStyles, + createStyle as mapboxCreateStyle +} from '@mapbox/mcp-devkit-server/tools'; + +// Or use classes directly +import { + ListStylesTool, + CreateStyleTool +} from '@mapbox/mcp-devkit-server/tools'; +import { httpRequest } from '@mapbox/mcp-devkit-server/utils'; + +const myListStyles = new ListStylesTool({ httpRequest }); +const myCreateStyle = new CreateStyleTool({ httpRequest }); +``` + +## Examples + +See [examples/import-example.ts](../examples/import-example.ts) for complete working examples of all patterns. + +## Further Reading + +- [Engineering Standards](./engineering_standards.md) - Development guidelines +- [Tracing](./tracing.md) - OpenTelemetry setup +- [Style Builder](./STYLE_BUILDER.md) - Interactive style building +- [Integration Guides](./claude-desktop-integration.md) - Setup with various tools diff --git a/examples/import-example.ts b/examples/import-example.ts new file mode 100644 index 0000000..4729fa9 --- /dev/null +++ b/examples/import-example.ts @@ -0,0 +1,255 @@ +// Copyright (c) Mapbox, Inc. +// Licensed under the MIT License. + +/** + * Examples demonstrating how to import and use Mapbox MCP Devkit tools, resources, + * prompts, and utilities in your application. + */ + +import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; + +/* ============================================================================= + * SIMPLE USAGE: Pre-configured instances (recommended for most use cases) + * ============================================================================= */ + +// Import pre-configured tool instances with short, clean names +import { + listStyles, + createStyle, + previewStyle +} from '@mapbox/mcp-devkit-server/tools'; + +// Import pre-configured resource instances +import { + mapboxStyleLayers, + previewStyleUI +} from '@mapbox/mcp-devkit-server/resources'; + +// Import pre-configured prompt instances +import { + createAndPreviewStyle, + buildCustomMap +} from '@mapbox/mcp-devkit-server/prompts'; + +// Ready to use - httpRequest is already configured +async function simpleExample() { + const server = new McpServer({ + name: 'my-devkit-app', + version: '1.0.0' + }); + + // Tools, resources, and prompts use installTo() method + listStyles.installTo(server); + createStyle.installTo(server); + previewStyle.installTo(server); + + mapboxStyleLayers.installTo(server); + previewStyleUI.installTo(server); + + // Prompts can be used directly - they have execute() method + // See src/index.ts for how to register prompts with the server + + return server; +} + +/* ============================================================================= + * ADVANCED USAGE: Tool classes with default httpRequest + * ============================================================================= */ + +// Import tool classes for custom instantiation +import { + ListStylesTool, + CreateStyleTool, + PreviewStyleTool +} from '@mapbox/mcp-devkit-server/tools'; + +// Import the default httpRequest function +import { httpRequest } from '@mapbox/mcp-devkit-server/utils'; + +// Create tools with default pipeline but custom configuration +async function advancedExample() { + const server = new McpServer({ + name: 'my-custom-devkit-app', + version: '1.0.0' + }); + + // Instantiate tools with default httpRequest + const myListStyles = new ListStylesTool({ httpRequest }); + const myCreateStyle = new CreateStyleTool({ httpRequest }); + const myPreviewStyle = new PreviewStyleTool(); + + myListStyles.installTo(server); + myCreateStyle.installTo(server); + myPreviewStyle.installTo(server); + + return server; +} + +/* ============================================================================= + * EXPERT USAGE: Custom HTTP pipeline with policies + * ============================================================================= */ + +// Import HTTP pipeline components +import { + HttpPipeline, + UserAgentPolicy, + RetryPolicy +} from '@mapbox/mcp-devkit-server/utils'; + +import type { HttpRequest } from '@mapbox/mcp-devkit-server/utils'; + +// Create a custom HTTP pipeline +function createCustomPipeline(): HttpRequest { + const pipeline = new HttpPipeline(); + + // Add custom User-Agent + pipeline.usePolicy(new UserAgentPolicy('MyDevkitApp/2.0.0')); + + // Add aggressive retry policy: 5 attempts, 300ms min, 3000ms max backoff + pipeline.usePolicy(new RetryPolicy(5, 300, 3000)); + + return pipeline.execute.bind(pipeline); +} + +async function expertExample() { + const server = new McpServer({ + name: 'my-expert-devkit-app', + version: '1.0.0' + }); + + // Use custom pipeline + const customHttpRequest = createCustomPipeline(); + + // Create tools with custom pipeline + const myListStyles = new ListStylesTool({ httpRequest: customHttpRequest }); + const myCreateStyle = new CreateStyleTool({ + httpRequest: customHttpRequest + }); + + myListStyles.installTo(server); + myCreateStyle.installTo(server); + + return server; +} + +/* ============================================================================= + * REGISTRY FUNCTIONS: Batch operations + * ============================================================================= */ + +// Import registry functions for batch access +import { + getCoreTools, + getElicitationTools +} from '@mapbox/mcp-devkit-server/tools'; + +import { getAllResources } from '@mapbox/mcp-devkit-server/resources'; + +import { getAllPrompts } from '@mapbox/mcp-devkit-server/prompts'; + +async function registryExample() { + const server = new McpServer({ + name: 'my-registry-app', + version: '1.0.0' + }); + + // Register all core tools at once + const coreTools = getCoreTools(); + for (const tool of coreTools) { + tool.installTo(server); + } + + // Register all elicitation tools + const elicitationTools = getElicitationTools(); + for (const tool of elicitationTools) { + tool.installTo(server); + } + + // Register all resources + const resources = getAllResources(); + for (const resource of resources) { + resource.installTo(server); + } + + // Get all prompts - they can be used directly or registered + // See src/index.ts for how to register prompts with the server + const _prompts = getAllPrompts(); + + return server; +} + +/* ============================================================================= + * TYPE-SAFE USAGE: Import types + * ============================================================================= */ + +import type { HttpPolicy } from '@mapbox/mcp-devkit-server/utils'; +import type { ToolInstance } from '@mapbox/mcp-devkit-server/tools'; +import type { ResourceInstance } from '@mapbox/mcp-devkit-server/resources'; +import type { PromptInstance } from '@mapbox/mcp-devkit-server/prompts'; + +// Create custom policy +class _CustomLoggingPolicy implements HttpPolicy { + readonly id = 'custom-logging'; + + async handle( + input: string | URL | Request, + init: RequestInit, + next: HttpRequest + ): Promise { + const url = input instanceof Request ? input.url : input.toString(); + console.log(`Request: ${url}`); + const response = await next(input, init); + console.log(`Response: ${response.status}`); + return response; + } +} + +// Type-safe tool handling +function processTool(tool: ToolInstance) { + console.log(`Processing tool: ${tool.name}`); + // Tool instances have installTo() method +} + +function processResource(resource: ResourceInstance) { + console.log(`Processing resource: ${resource.uri}`); + // Resource instances have installTo() method +} + +function processPrompt(prompt: PromptInstance) { + console.log(`Processing prompt: ${prompt.name}`); + // Prompt instances can be executed directly or registered via server.registerPrompt() +} + +// Use them +processTool(listStyles); +processTool(createStyle); + +processResource(mapboxStyleLayers); +processResource(previewStyleUI); + +processPrompt(createAndPreviewStyle); +processPrompt(buildCustomMap); + +/* ============================================================================= + * MAIN: Run examples + * ============================================================================= */ + +async function main() { + console.log('Simple example:'); + await simpleExample(); + + console.log('\nAdvanced example:'); + await advancedExample(); + + console.log('\nExpert example:'); + await expertExample(); + + console.log('\nRegistry example:'); + await registryExample(); + + console.log('\nAll examples completed successfully!'); +} + +// Run if executed directly +if (import.meta.url === `file://${process.argv[1]}`) { + main().catch(console.error); +} diff --git a/package.json b/package.json index 49432e6..56e347f 100644 --- a/package.json +++ b/package.json @@ -12,15 +12,15 @@ "scripts": { "postinstall": "patch-package || true", "build": "npm run prepare && tshy && npm run generate-version && node scripts/add-shebang.cjs", - "format": "prettier --check \"./src/**/*.{ts,tsx,js,json,md}\" \"./test/**/*.{ts,tsx,js,json,md}\"", - "format:fix": "prettier --write \"./src/**/*.{ts,tsx,js,json,md}\" \"./test/**/*.{ts,tsx,js,json,md}\"", + "format": "prettier --check \"./src/**/*.{ts,tsx,js,json,md}\" \"./test/**/*.{ts,tsx,js,json,md}\" \"./examples/**/*.{ts,tsx,js,json,md}\"", + "format:fix": "prettier --write \"./src/**/*.{ts,tsx,js,json,md}\" \"./test/**/*.{ts,tsx,js,json,md}\" \"./examples/**/*.{ts,tsx,js,json,md}\"", "generate-version": "node scripts/build-helpers.cjs generate-version", "inspect:build": "npm run build && npx @modelcontextprotocol/inspector -e MAPBOX_ACCESS_TOKEN=\"$MAPBOX_ACCESS_TOKEN\" node dist/esm/index.js", "inspect:dev": "npx @modelcontextprotocol/inspector -e MAPBOX_ACCESS_TOKEN=\"$MAPBOX_ACCESS_TOKEN\" npx -y tsx src/index.ts", - "lint": "eslint \"./src/**/*.{ts,tsx}\" \"./test/**/*.{ts,tsx}\"", - "lint:fix": "eslint \"./src/**/*.{ts,tsx}\" \"./test/**/*.{ts,tsx}\" --fix", + "lint": "eslint \"./src/**/*.{ts,tsx}\" \"./test/**/*.{ts,tsx}\" \"./examples/**/*.{ts,tsx}\"", + "lint:fix": "eslint \"./src/**/*.{ts,tsx}\" \"./test/**/*.{ts,tsx}\" \"./examples/**/*.{ts,tsx}\" --fix", "prepare": "husky && node .husky/setup-hooks.js", - "spellcheck": "cspell \"*.md\" \"src/**/*.ts\" \"test/**/*.ts\"", + "spellcheck": "cspell \"*.md\" \"src/**/*.ts\" \"test/**/*.ts\" \"examples/**/*.ts\"", "sync-manifest": "node scripts/sync-manifest-version.cjs", "test": "vitest", "tracing:jaeger:start": "docker run --rm -d --name jaeger -p 16686:16686 -p 14250:14250 -p 4317:4317 -p 4318:4318 jaegertracing/all-in-one:latest", diff --git a/tsconfig.examples.json b/tsconfig.examples.json new file mode 100644 index 0000000..cdc6217 --- /dev/null +++ b/tsconfig.examples.json @@ -0,0 +1,13 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "composite": true, + "noEmit": true + }, + "include": ["examples"], + "references": [ + { + "path": "./tsconfig.src.json" + } + ] +}