Problem
The SchemaManager constructor (line 64-78 in src/utils/SchemaManager.ts) currently creates its DynamicTableFactory internally with only 2 parameters:
this.tableFactory = new DynamicTableFactory(clientFactory, schema);
This means consumers cannot pass a pre-configured DynamicTableFactory with custom policies (e.g., WriteConversionPolicyInterface, UnknownFieldPolicyInterface).
In the service_portfolio_mcp project, we need a DynamicTableFactory with a LocaleWriteConversionPolicy for proper date/number formatting. Currently this requires an unsafe property override workaround:
(schemaManager as unknown as { tableFactory: DynamicTableFactory }).tableFactory = tableFactory;
This violates the Open/Closed Principle (OCP).
Proposed Solution
Add an optional 3rd parameter to the SchemaManager constructor:
constructor(
clientFactory: AppSheetClientFactoryInterface,
schema: SchemaConfig,
tableFactory?: DynamicTableFactoryInterface // NEW: optional
) {
// ...validate schema...
this.tableFactory = tableFactory ?? new DynamicTableFactory(clientFactory, schema);
}
- If
tableFactory is provided: use it directly
- If NOT provided: create internally as before (backward compatible)
Acceptance Criteria
Context
- Related MCP Server ticket: SOSO-448
- Current library version: v3.4.0
DynamicTableFactory constructor already accepts writeConversionPolicy as 4th parameter
Problem
The
SchemaManagerconstructor (line 64-78 insrc/utils/SchemaManager.ts) currently creates itsDynamicTableFactoryinternally with only 2 parameters:This means consumers cannot pass a pre-configured
DynamicTableFactorywith custom policies (e.g.,WriteConversionPolicyInterface,UnknownFieldPolicyInterface).In the
service_portfolio_mcpproject, we need aDynamicTableFactorywith aLocaleWriteConversionPolicyfor proper date/number formatting. Currently this requires an unsafe property override workaround:This violates the Open/Closed Principle (OCP).
Proposed Solution
Add an optional 3rd parameter to the
SchemaManagerconstructor:tableFactoryis provided: use it directlyAcceptance Criteria
tableFactory?: DynamicTableFactoryInterfaceadded to constructorContext
DynamicTableFactoryconstructor already acceptswriteConversionPolicyas 4th parameter