Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"type": "module",
"imports": {
"~docsCatalog": "./src/docs.json",
"#collectionsHost": "./dist/server.collectionsHost.js",
"#toolsHost": "./dist/server.toolsHost.js"
},
"exports": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

exports[`options defaults should return specific properties: defaults 1`] = `
{
"collectionModules": [],
"contextManagement": false,
"contextPath": "/",
"contextUrl": "file:///",
Expand Down
33 changes: 33 additions & 0 deletions src/__tests__/__snapshots__/server.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ exports[`runServer should allow server to be stopped, http stop server: diagnost
[
"Server stats enabled.",
],
[
"No external collections loaded.",
],
[
"No external resources loaded.",
],
Expand Down Expand Up @@ -71,6 +74,9 @@ exports[`runServer should allow server to be stopped, stdio stop server: diagnos
[
"Server stats enabled.",
],
[
"No external collections loaded.",
],
[
"No external resources loaded.",
],
Expand Down Expand Up @@ -133,6 +139,9 @@ exports[`runServer should attempt to run server, create transport, connect, and
[
"Server stats enabled.",
],
[
"No external collections loaded.",
],
[
"No external resources loaded.",
],
Expand Down Expand Up @@ -206,6 +215,9 @@ exports[`runServer should attempt to run server, disable SIGINT handler: diagnos
[
"Server stats enabled.",
],
[
"No external collections loaded.",
],
[
"No external resources loaded.",
],
Expand Down Expand Up @@ -274,6 +286,9 @@ exports[`runServer should attempt to run server, enable SIGINT handler explicitl
[
"Server stats enabled.",
],
[
"No external collections loaded.",
],
[
"No external resources loaded.",
],
Expand Down Expand Up @@ -347,6 +362,9 @@ exports[`runServer should attempt to run server, log warnings for experimental o
[
"Server stats enabled.",
],
[
"No external collections loaded.",
],
[
"No external resources loaded.",
],
Expand Down Expand Up @@ -435,6 +453,9 @@ exports[`runServer should attempt to run server, register a tool: diagnostics 1`
[
"Server stats enabled.",
],
[
"No external collections loaded.",
],
[
"No external resources loaded.",
],
Expand Down Expand Up @@ -516,6 +537,9 @@ exports[`runServer should attempt to run server, register multiple tools: diagno
[
"Server stats enabled.",
],
[
"No external collections loaded.",
],
[
"No external resources loaded.",
],
Expand Down Expand Up @@ -604,6 +628,9 @@ exports[`runServer should attempt to run server, use custom options: diagnostics
[
"Server stats enabled.",
],
[
"No external collections loaded.",
],
[
"No external resources loaded.",
],
Expand Down Expand Up @@ -677,6 +704,9 @@ exports[`runServer should attempt to run server, use default tools, http: diagno
[
"Server stats enabled.",
],
[
"No external collections loaded.",
],
[
"No external resources loaded.",
],
Expand Down Expand Up @@ -759,6 +789,9 @@ exports[`runServer should attempt to run server, use default tools, stdio: diagn
[
"Server stats enabled.",
],
[
"No external collections loaded.",
],
[
"No external resources loaded.",
],
Expand Down
5 changes: 3 additions & 2 deletions src/__tests__/server.collections.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { composeCollections } from '../server.collections';
import { getOptions, getSessionOptions } from '../options.context';

jest.mock('../options.context', () => ({
getOptions: jest.fn(),
getSessionOptions: jest.fn()
getOptions: jest.fn(() => ({})),
getSessionOptions: jest.fn(() => ({ sessionId: 'test' })),
getLoggerOptions: jest.fn(() => ({}))
}));

describe('composeCollections', () => {
Expand Down
17 changes: 17 additions & 0 deletions src/options.collections.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { type ToolOptions, setToolOptions } from './options.tools';

/**
* Options for records. A limited subset of options.
*
* @alias ToolOptions
*/
type CollectionOptions = ToolOptions;

/**
* Return a refined set of options from global options for records.
*
* @alias setToolOptions
*/
const setCollectionOptions = setToolOptions;

export { setCollectionOptions, type CollectionOptions };
5 changes: 5 additions & 0 deletions src/options.defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { basename, resolve } from 'node:path';
import { pathToFileURL } from 'node:url';
import packageJson from '../package.json';
import { type ToolModule } from './server.toolsUser';
import { type CollectionModule } from './server.collectionsUser';
import { getNodeMajorVersion } from './options.helpers';

/**
Expand Down Expand Up @@ -47,6 +48,8 @@ import { getNodeMajorVersion } from './options.helpers';
* @property {typeof TOOL_MEMO_OPTIONS} toolMemoOptions - Tool-specific memoization options.
* @property {ToolModule|ToolModule[]} toolModules - Array of external tool modules (ESM specs or paths) to be loaded and
* registered with the server.
* @property {CollectionModule|CollectionModule[]} collectionModules - Array of external collection modules
* (ESM specs or paths) to be loaded and registered with the server.
* @property urlRegex - Regular expression pattern for URL matching.
* @property version - Version of the package.
* @property whitelist - Central outbound-URL policy options.
Expand Down Expand Up @@ -83,6 +86,7 @@ interface DefaultOptions<TLogOptions = LoggingOptions> {
stats: StatsOptions;
toolMemoOptions: Partial<typeof TOOL_MEMO_OPTIONS>;
toolModules: ToolModule | ToolModule[];
collectionModules: CollectionModule | CollectionModule[];
urlRegex: RegExp;
version: string;
whitelist: WhitelistOptions;
Expand Down Expand Up @@ -560,6 +564,7 @@ const DEFAULT_OPTIONS: DefaultOptions = {
resourceModules: [],
toolMemoOptions: TOOL_MEMO_OPTIONS,
toolModules: [],
collectionModules: [],
separator: DEFAULT_SEPARATOR,
urlRegex: URL_REGEX,
version: (process.env.NODE_ENV === 'local' && '0.0.0') || packageJson.version,
Expand Down
Loading
Loading