@@ -12,6 +12,7 @@ const requireDist = createRequire(join(pkgDir, 'package.json'));
1212const NODE_ONLY = / \b ( c h i l d _ p r o c e s s | c r o s s - s p a w n | n o d e : s t r e a m | n o d e : c h i l d _ p r o c e s s ) \b / ;
1313// Anchored at start-of-line so JSDoc-example `from 'ajv'` strings in vendored chunks don't match.
1414const VALIDATOR_BACKEND_IMPORT = / ^ i m p o r t [ ^ \n ] * ?f r o m \s + [ " ' ] (?: a j v | a j v - f o r m a t s | @ c f w o r k e r \/ j s o n - s c h e m a ) [ " ' ] / m;
15+ const ROOT_VALIDATOR_EXPORTS = [ 'AjvJsonSchemaValidator' , 'CfWorkerJsonSchemaValidator' , 'CfWorkerSchemaDraft' ] ;
1516
1617function chunkImportsOf ( entryPath : string ) : string [ ] {
1718 const visited = new Set < string > ( ) ;
@@ -29,6 +30,12 @@ function chunkImportsOf(entryPath: string): string[] {
2930 return [ ...visited ] ;
3031}
3132
33+ function rootExportBlockOf ( content : string ) : string {
34+ const blocks = content . match ( / (?: ^ | \n ) e x p o r t \{ [ \s \S ] * ?\} ; / g) ;
35+ expect ( blocks ) . toBeTruthy ( ) ;
36+ return blocks ! . at ( - 1 ) ! ;
37+ }
38+
3239describe ( '@modelcontextprotocol/client root entry is browser-safe' , ( ) => {
3340 beforeAll ( ( ) => {
3441 if ( ! existsSync ( join ( distDir , 'index.mjs' ) ) || ! existsSync ( join ( distDir , 'stdio.mjs' ) ) ) {
@@ -80,4 +87,13 @@ describe('@modelcontextprotocol/client root entry is browser-safe', () => {
8087
8188 expect ( new AjvJsonSchemaValidator ( ajv ) ) . toBeInstanceOf ( AjvJsonSchemaValidator ) ;
8289 } ) ;
90+
91+ test ( 'root declarations do not advertise validator provider classes' , ( ) => {
92+ for ( const declaration of [ 'index.d.mts' , 'index.d.cts' ] ) {
93+ const rootExportBlock = rootExportBlockOf ( readFileSync ( join ( distDir , declaration ) , 'utf8' ) ) ;
94+ for ( const symbol of ROOT_VALIDATOR_EXPORTS ) {
95+ expect ( rootExportBlock ) . not . toMatch ( new RegExp ( `\\b(?:type\\s+)?${ symbol } \\b` ) ) ;
96+ }
97+ }
98+ } ) ;
8399} ) ;
0 commit comments