|
1 | 1 | import { describe, expect, it } from 'vitest'; |
2 | 2 | import * as core from '../index.js'; |
| 3 | +import * as alliance from '../../alliance/index.js'; |
| 4 | + |
| 5 | +/** |
| 6 | + * Guards the public runtime export surface of both barrels (#203). Types are |
| 7 | + * erased at runtime, so only value exports appear here; this catches an internal |
| 8 | + * symbol accidentally leaking into a barrel and growing the blast radius. When a |
| 9 | + * genuinely public symbol is added, add it to the allow-list in the same change. |
| 10 | + */ |
| 11 | +const CORE_PUBLIC_EXPORTS = [ |
| 12 | + 'PineconeClient', |
| 13 | + 'ServerContext', |
| 14 | + 'SourceRegistry', |
| 15 | + 'buildSourceRegistry', |
| 16 | + 'countResponseSchema', |
| 17 | + 'createIsolatedContext', |
| 18 | + 'createServer', |
| 19 | + 'generateUrlForNamespace', |
| 20 | + 'generateUrlsResponseSchema', |
| 21 | + 'getDefaultServerContext', |
| 22 | + 'guidedQueryResponseSchema', |
| 23 | + 'hasUrlGenerator', |
| 24 | + 'keywordSearchResponseSchema', |
| 25 | + 'keywordSearchSuccessResponseSchema', |
| 26 | + 'listNamespacesResponseSchema', |
| 27 | + 'namespaceRouterResponseSchema', |
| 28 | + 'queryDocumentsResponseSchema', |
| 29 | + 'queryResponseSchema', |
| 30 | + 'queryResultRowSchema', |
| 31 | + 'querySuccessResponseSchema', |
| 32 | + 'registerUrlGenerator', |
| 33 | + 'resolveConfig', |
| 34 | + 'setPineconeClient', |
| 35 | + 'setupCoreServer', |
| 36 | + 'suggestQueryParams', |
| 37 | + 'suggestQueryParamsResponseSchema', |
| 38 | + 'teardownServer', |
| 39 | + 'toolErrorSchema', |
| 40 | + 'unregisterUrlGenerator', |
| 41 | + 'validateMetadataFilter', |
| 42 | + 'validateMetadataFilterDetailed', |
| 43 | +]; |
| 44 | + |
| 45 | +const ALLIANCE_PUBLIC_EXPORTS = [ |
| 46 | + ...CORE_PUBLIC_EXPORTS, |
| 47 | + 'ALLIANCE_DEFAULT_INDEX_NAME', |
| 48 | + 'ALLIANCE_DEFAULT_RERANK_MODEL', |
| 49 | + 'DEFAULT_ALLIANCE_RERANK_MODEL', |
| 50 | + 'registerBuiltinUrlGenerators', |
| 51 | + 'resolveAllianceConfig', |
| 52 | + 'setupAllianceServer', |
| 53 | +].sort(); |
3 | 54 |
|
4 | 55 | describe('public export surface', () => { |
5 | 56 | it('does not export internal experimental block builders', () => { |
6 | 57 | expect('buildQueryExperimental' in core).toBe(false); |
7 | 58 | expect('buildGuidedQueryExperimental' in core).toBe(false); |
8 | 59 | }); |
| 60 | + |
| 61 | + it('does not export the internal-only symbols trimmed in #203', () => { |
| 62 | + for (const name of ['trimOptional', 'createUnconfiguredAllianceContext']) { |
| 63 | + expect(name in core).toBe(false); |
| 64 | + } |
| 65 | + for (const name of ['generatorMailing', 'generatorSlackCpplang']) { |
| 66 | + expect(name in alliance).toBe(false); |
| 67 | + } |
| 68 | + }); |
| 69 | + |
| 70 | + it('core barrel value exports match the allow-list', () => { |
| 71 | + expect(Object.keys(core).sort()).toEqual([...CORE_PUBLIC_EXPORTS].sort()); |
| 72 | + }); |
| 73 | + |
| 74 | + it('alliance barrel value exports match the allow-list', () => { |
| 75 | + expect(Object.keys(alliance).sort()).toEqual(ALLIANCE_PUBLIC_EXPORTS); |
| 76 | + }); |
9 | 77 | }); |
0 commit comments