@webpieces/core-util 0.4.773 → 0.4.774

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/core/core-util/src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;;;;AAEH,+CAA2C;AAAlC,qGAAA,OAAO,OAAA;AAChB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AAOnB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AAErB,+EAA+E;AAC/E,kFAAkF;AAClF,yCAAyC;AACzC,mDAA0F;AAAjF,gHAAA,cAAc,OAAA;AAAE,kHAAA,gBAAgB,OAAA;AAAE,sHAAA,oBAAoB,OAAA;AAO/D,yDAAwD;AAA/C,8GAAA,aAAa,OAAA;AACtB,uEAAsE;AAA7D,4HAAA,oBAAoB,OAAA;AAC7B,mDAAkD;AAAzC,wGAAA,UAAU,OAAA;AACnB,mDAM8B;AAL1B,wGAAA,UAAU,OAAA;AACV,4GAAA,cAAc,OAAA;AACd,0GAAA,YAAY,OAAA;AACZ,+GAAA,iBAAiB,OAAA;AACjB,kHAAA,oBAAoB,OAAA;AAGxB,8DAA8D;AAC9D,sEAAsE;AACtE,qEAAqE;AACrE,uEAAuE;AACvE,kEAAkE;AAElE,4BAA4B;AAC5B,gDA8B2B;AA7BvB,qGAAA,OAAO,OAAA;AACP,sGAAA,QAAQ,OAAA;AACR,mEAAmE;AACnE,0GAAA,YAAY,OAAA;AACZ,uGAAA,SAAS,OAAA;AACT,2GAAA,aAAa,OAAA;AACb,wHAAA,0BAA0B,OAAA;AAC1B,wGAAA,UAAU,OAAA;AACV,gHAAA,kBAAkB,OAAA;AAClB,2GAAA,aAAa,OAAA;AACb,0GAAA,YAAY,OAAA;AACZ,6GAAA,eAAe,OAAA;AACf,qGAAA,OAAO,OAAA;AACP,wGAAA,UAAU,OAAA;AAC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,gBAAgB,OAAA;AAChB,iHAAA,aAAa,OAAA;AACb,oHAAA,gBAAgB,OAAA;AAEpB,2DAAgF;AAAvE,0GAAA,WAAW,OAAA;AAAE,mHAAA,oBAAoB,OAAA;AAC1C,qEAAoG;AAA3F,oHAAA,gBAAgB,OAAA;AAAE,iHAAA,aAAa,OAAA;AAAE,mHAAA,eAAe,OAAA;AAEzD,gGAAgG;AAChG,2EAA2E;AAC3E,+FAA+F;AAC/F,kGAAkG;AAClG,wFAAwF;AACxF,2CAA0C;AAAjC,gGAAA,MAAM,OAAA;AAEf,qDAAoD;AAA3C,0GAAA,WAAW,OAAA;AAEpB,mCAkBkB;AAjBd,kGAAA,QAAQ,OAAA;AACR,0GAAA,gBAAgB,OAAA;AAChB,4GAAA,kBAAkB,OAAA;AAClB,6GAAA,mBAAmB,OAAA;AACnB,mHAAA,yBAAyB,OAAA;AACzB,gHAAA,sBAAsB,OAAA;AACtB,6GAAA,mBAAmB,OAAA;AACnB,2GAAA,iBAAiB,OAAA;AACjB,gHAAA,sBAAsB,OAAA;AACtB,yGAAA,eAAe,OAAA;AACf,4GAAA,kBAAkB,OAAA;AAClB,8GAAA,oBAAoB,OAAA;AACpB,mHAAA,yBAAyB,OAAA;AACzB,4GAAA,kBAAkB,OAAA;AAClB,kHAAA,wBAAwB,OAAA;AACxB,uGAAA,aAAa,OAAA;AACb,yGAAA,eAAe,OAAA;AAGnB,gEAA+D;AAAtD,wHAAA,kBAAkB,OAAA","sourcesContent":["/**\n * @webpieces/core-util\n *\n * Utility functions for WebPieces applications.\n * This package works in both browser and Node.js environments.\n *\n * @packageDocumentation\n */\n\nexport { toError } from './lib/errorUtils';\nexport { ContextKey } from './ContextKey';\nexport type {\n AnyContextKey,\n AnyTrustedContextKey,\n AnyUntrustedContextKey,\n Trust,\n} from './ContextKey';\nexport { ContextTuple } from './ContextTuple';\n\n// @DocumentDesign — DI-design-root marker. Applies to ANY project kind (server\n// controllers AND library impl classes), so it lives here (browser + Node) rather\n// than in a server-only routing package.\nexport { DocumentDesign, isDocumentDesign, DESIGN_METADATA_KEYS } from './DocumentDesign';\n\n// Logging (merged from former @webpieces/wp-logging).\n// Pluggable logging interface + a browser-safe console default; apps plug in\n// bunyan/winston/pino/etc. via LogManager.setFactory(...). Browser + Node.\nexport type { Logger, LogLevel } from './logging/Logger';\nexport type { LoggerFactory } from './logging/LoggerFactory';\nexport { ConsoleLogger } from './logging/ConsoleLogger';\nexport { ConsoleLoggerFactory } from './logging/ConsoleLoggerFactory';\nexport { LogManager } from './logging/LogManager';\nexport {\n LogChunker,\n LogChunkerImpl,\n LogChunkInfo,\n MAX_GCP_LOG_BYTES,\n GCP_LOG_BUDGET_BYTES,\n} from './logging/LogChunker';\n\n// HTTP API contract (merged from former @webpieces/http-api).\n// Shared HTTP API definition consumed by both client and server: REST\n// decorators, the API error taxonomy, datetime DTOs, platform-header\n// registry/readers, ValidateImplementation, and the test-case recorder\n// contract. Pure definitions — express-free, browser + Node safe.\n\n// API definition decorators\nexport {\n ApiPath,\n Endpoint,\n // Auth mode decorators (clean service-to-service + user JWT model)\n WpAuthPublic,\n WpAuthJwt,\n rolesRequired,\n MISSING_AUTH_DECORATOR_FIX,\n WpAuthOidc,\n WpAuthSharedSecret,\n WpAuthWebhook,\n WpAuthApiKey,\n WpAuthLocalOnly,\n MaskLog,\n getApiPath,\n getEndpoints,\n getEndpointOptions,\n getEndpointKind,\n getEndpointKinds,\n getMaskSpec,\n isFormPost,\n isRawBody,\n isApiPath,\n getAuthMeta,\n getAuthMode,\n assertEveryEndpointHasAuthMode,\n assertEveryExternalEndpointDeclaresCaller,\n assertEveryWebhookEndpointRetainsRawBody,\n validateNoConflictingDecorators,\n METADATA_KEYS,\n} from './http/decorators';\nexport {\n PathParam,\n QueryParam,\n getHttpParameterDeclarations,\n} from './http/http-parameter-decorators';\nexport {\n WpInternal,\n WpIpcEndpoint,\n isInternalApi,\n getIpcApiId,\n getIpcEndpoints,\n getIpcEndpointKind,\n getIpcMaskSpec,\n assertInternalApi,\n assertNotInternalApi,\n IPC_METADATA_KEYS,\n} from './ipc/IpcDecorators';\nexport type { IpcApiType, IpcEndpointKind, IpcEndpointOptions } from './ipc/IpcDecorators';\n// The runtime representation of ONE route (split out of decorators.ts for file size only).\nexport { RouteMetadata } from './http/RouteMetadata';\nexport { RouteMetadataFactory } from './http/RouteMetadataFactory';\nexport {\n BoundHttpRequest,\n HttpContractMapper,\n HttpParameterBinding,\n HttpParameterDeclaration,\n} from './http/HttpContract';\nexport type {\n ContractHttpMethod,\n EndpointResponseType,\n HttpParameterSource,\n HttpParameterValueType,\n} from './http/HttpContract';\nexport type { EndpointKind, EndpointOptions, ExternalEndpointOptions } from './http/decorators';\nexport { WpMcpTool, WpMcpToolHints, WpMcpToolMetadata, getWpMcpTools } from './mcp/McpMetadata';\nexport type { WpMcpMethodDecorator, WpMcpToolOptions } from './mcp/McpMetadata';\nexport {\n WpDto,\n WpDtoField,\n WpDtoFieldOptions,\n WpDtoMapFieldOptions,\n WpDtoFieldMetadata,\n WpResponseDto,\n ApiJsonSchema,\n DtoValidationFailure,\n DtoSchemaBuilder,\n} from './mcp/DtoSchema';\nexport type { DtoClass, DtoElementType, DtoValue } from './mcp/DtoSchema';\n// The TYPE layer of the auth surface — likewise split out of decorators.ts for file size only.\nexport { AuthMeta } from './http/auth-mode';\nexport type {\n AuthMode,\n ApiKeyCredential,\n ApiKeyCredentials,\n JwtRoles,\n JwtRequirement,\n} from './http/auth-mode';\n// API kind (RPC vs PubSub/Cloud Tasks) + queue naming. Split out of decorators.ts for file size only;\n// one-way dependency api-kind -> decorators, and the barrel keeps the surface identical.\nexport {\n Rpc,\n PubSub,\n Queue,\n ENDPOINT_KINDS_BY_API_KIND,\n getApiKind,\n assertApiKind,\n assertPubSubConventions,\n getQueueName,\n} from './http/api-kind';\nexport type { ApiKind } from './http/api-kind';\n// WHO calls an `external` endpoint — the caller declaration @Endpoint(..., 'external', {calledBy})\n// requires, and the reader for it.\nexport {\n EXTERNAL_SYSTEM_KINDS,\n DEFAULT_CALLER_KIND,\n ExternalCaller,\n isExternalSystemKind,\n getEndpointCaller,\n} from './http/external-caller';\nexport type { ExternalSystemKind } from './http/external-caller';\n// Client-side shared-secret store (the value THIS service sends per @WpAuthSharedSecret key).\nexport { Secrets, SECRETS } from './http/Secrets';\n\n// Type validators\nexport { ValidateImplementation } from './http/validators';\n\n// Authentication subtype constants.\nexport {\n ENTITY_NOT_FOUND,\n WRONG_LOGIN_TYPE,\n WRONG_LOGIN,\n NOT_APPROVED,\n EMAIL_NOT_CONFIRMED,\n WRONG_DOMAIN,\n WRONG_COMPANY,\n NO_REG_CODE,\n} from './errors';\n\nexport { NetworkRejectClassifier } from './http/networkReject';\n\n// Date/Time DTOs and Utilities (inspired by Java Time / JSR-310)\nexport {\n InstantDto,\n DateDto,\n TimeDto,\n DateTimeDto,\n InstantUtil,\n DateUtil,\n TimeUtil,\n DateTimeUtil,\n} from './http/datetime';\n\n// Context keys + registry (the global magic-context header system)\nexport { HeaderRegistry } from './http/HeaderRegistry';\nexport { ClientRegistry } from './http/ClientRegistry';\nexport { CallRegistry } from './http/CallRegistry';\nexport { CallDeadline } from './http/CallDeadline';\nexport { CallContext } from './http/CallStrategy';\nexport type { Attempt, CallStrategy } from './http/CallStrategy';\nexport { ApiCallTimeoutError } from './http/ApiCallTimeoutError';\nexport type { ServiceUrlDeriver } from './http/ClientRegistry';\n\n// \"What service am I\" — set once at startup, read by the logging backends and by\n// RequestContextHeaders (to stamp requestIdSource on ids this service mints).\nexport { ServiceInfo } from './http/ServiceInfo';\n// \"Where am I running\" — declared once at startup (setupRuntime, from RuntimeSetupOptions.locality).\n// The ONE input to @WpAuthLocalOnly enforcement. Undeclared reads as DEPLOYED (fail safe).\nexport { RuntimeLocality } from './http/RuntimeLocality';\nexport type { Locality } from './http/RuntimeLocality';\n// The ENTIRE HTTP response as pure data — the ONE form both transports (express, fetch) are\n// normalised into, so an ErrorTranslators implementation is written once and serves both.\nexport { HttpHeader, HttpResponseStatus, HttpResponseDto } from './http/HttpResponseDto';\n// Pluggable, bidirectional error translation (app exception <-> the WHOLE response). Set on\n// ClientRegistry at startup; consulted before the built-in webpieces mapping on BOTH sides.\nexport type { ErrorTranslators } from './http/ErrorTranslators';\n// Pluggable per-client failure classification (is a thrown API-call error a real failure or an\n// expected non-failure?). Registered on ClientRegistry at startup; consulted by LogApiCall.\nexport type { FailureClassifier } from './http/FailureClassifier';\nexport { KeyedFailureClassifier } from './http/FailureClassifier';\nexport {\n WebpiecesDefaultFailureClassifier,\n WEBPIECES_DEFAULT_FAILURE_CLASSIFIER,\n} from './http/WebpiecesDefaultFailureClassifier';\nexport { templateDeriver } from './http/templateDeriver';\nexport { WebpiecesCoreHeaders } from './http/WebpiecesCoreHeaders';\nexport { ContextReader } from './http/ContextReader';\n\n// The OUTBOUND half of the trust model: whether a TRUSTED context key may ride to the endpoint being\n// called. Built ONLY from the destination endpoint's AuthMode — see the class doc.\nexport { DestinationTrust } from './http/DestinationTrust';\n\n// BROWSER-ONLY outbound-header propagation (app-held store + registry -> outbound HTTP headers).\n// Only @webpieces/http-client-browser may name it; the server reads RequestContext directly via\n// RequestContextHeaders in the Node-only @webpieces/core-context.\nexport { ContextMgr } from './http/ContextMgr';\n\n// API-call logging helper (uses LogManager above). NOT a singleton: construct one per environment\n// with that environment's ApiCallContext — `new LogApiCallImpl(new RequestContextApiCallContext())`\n// on node, `new LogApiCallImpl(new BrowserApiCallContext())` in a browser.\nexport { LogApiCallImpl } from './http/LogApiCall';\n\n// Opt-in field masking for the LogApiCall log path — declare per-api sensitive fields so secrets\n// (OAuth refresh tokens, id-token JWTs) are masked in the logs while the real value stays on the wire.\nexport { MaskSpec } from './http/LogFieldMask';\nexport type { MaskMode } from './http/LogFieldMask';\n\n// The structured `api` tag + the context-writer seam LogApiCall stamps through. The Node\n// RequestContext-backed impl lives in @webpieces/core-context, the browser one in\n// @webpieces/http-client-browser; each is CONSTRUCTED by its package, never installed globally.\nexport { ApiCallInfo } from './http/ApiCallInfo';\nexport type { ApiType, ApiResult } from './http/ApiCallInfo';\n// Console-render bridge: turns LogApiCall's [LogApiCall] bracket into [API.{side}.{phase}] locally.\nexport {\n ApiCallLogName,\n ApiCallLogNameImpl,\n LOG_API_CALL_LOGGER_NAME,\n} from './http/ApiCallLogName';\nexport { ApiMethodInfo } from './http/ApiMethodInfo';\nexport type { ApiSide } from './http/ApiMethodInfo';\nexport type { ApiCallContext } from './http/ApiCallContext';\n\n// Test-case recording contract (impl lives in http-server; hooks in http-client)\nexport { TestCaseRecorder, RecorderKeys } from './http/recorder/TestCaseRecorder';\nexport {\n RecordedEndpoint,\n RecordedError,\n RecordedTestCase,\n} from './http/recorder/RecordedEndpoint';\nexport { DoNotRecord, getDoNotRecordFields } from './http/recorder/DoNotRecord';\nexport { RecordSerializer, SerializedMap, SerializedError } from './http/recorder/RecordSerializer';\n\n// ---------------------------------------------------------------------------------------------\n// Filter-chain primitives, shared by BOTH chains: the inbound server chain\n// (`Filter<MethodMeta, WpResponse<unknown>>`, @webpieces/http-routing) and the outbound client\n// chain (`Filter<ClientRequest, Response>`, @webpieces/http-client-core). Declared once, here, in\n// the package both depend on — see the class doc for why a second pair would be a shim.\nexport { Filter } from './filters/Filter';\nexport type { Service } from './filters/Filter';\nexport { FilterChain } from './filters/FilterChain';\n\nexport {\n ApiError,\n ApiNotFoundError,\n ApiDependencyError,\n ApiUnavailableError,\n ApiDependencyTimeoutError,\n ApiImplementationError,\n ApiRateLimitedError,\n ApiForbiddenError,\n ApiRequestTimeoutError,\n ApiEndUserError,\n ApiBadRequestError,\n ApiUnauthorizedError,\n ApiDependencyBackoffError,\n ApiConnectionError,\n ApiEndpointNotFoundError,\n ApiErrorCodec,\n ApiErrorPayload,\n} from './errors';\nexport type { ApiErrorKind } from './errors';\nexport { ApiErrorHttpStatus } from './http/ApiErrorHttpStatus';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/core/core-util/src/index.ts"],"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wBAAwB,OAAA;AAE5B,sDAAqD;AAA5C,8GAAA,aAAa,OAAA;AAItB,iFAAiF;AACjF,qEAAkF;AAAvD,gHAAA,YAAY,OAAA;AACvC,qEAI0C;AAHtC,oHAAA,gBAAgB,OAAA;AAChB,iHAAA,aAAa,OAAA;AACb,oHAAA,gBAAgB,OAAA;AAEpB,2DAAgF;AAAvE,0GAAA,WAAW,OAAA;AAAE,mHAAA,oBAAoB,OAAA;AAC1C,qEAAoG;AAA3F,oHAAA,gBAAgB,OAAA;AAAE,iHAAA,aAAa,OAAA;AAAE,mHAAA,eAAe,OAAA;AAEzD,gGAAgG;AAChG,2EAA2E;AAC3E,+FAA+F;AAC/F,kGAAkG;AAClG,wFAAwF;AACxF,2CAA0C;AAAjC,gGAAA,MAAM,OAAA;AAEf,qDAAoD;AAA3C,0GAAA,WAAW,OAAA;AAEpB,mCAmBkB;AAlBd,kGAAA,QAAQ,OAAA;AACR,0GAAA,gBAAgB,OAAA;AAChB,4GAAA,kBAAkB,OAAA;AAClB,6GAAA,mBAAmB,OAAA;AACnB,mHAAA,yBAAyB,OAAA;AACzB,gHAAA,sBAAsB,OAAA;AACtB,6GAAA,mBAAmB,OAAA;AACnB,2GAAA,iBAAiB,OAAA;AACjB,gHAAA,sBAAsB,OAAA;AACtB,yGAAA,eAAe,OAAA;AACf,4GAAA,kBAAkB,OAAA;AAClB,8GAAA,oBAAoB,OAAA;AACpB,mHAAA,yBAAyB,OAAA;AACzB,4GAAA,kBAAkB,OAAA;AAClB,kHAAA,wBAAwB,OAAA;AACxB,uGAAA,aAAa,OAAA;AACb,yGAAA,eAAe,OAAA;AACf,0GAAA,gBAAgB,OAAA;AAGpB,gEAA+D;AAAtD,wHAAA,kBAAkB,OAAA","sourcesContent":["/**\n * @webpieces/core-util\n *\n * Utility functions for WebPieces applications.\n * This package works in both browser and Node.js environments.\n *\n * @packageDocumentation\n */\n\nexport { toError } from './lib/errorUtils';\nexport { ContextKey } from './ContextKey';\nexport type {\n AnyContextKey,\n AnyTrustedContextKey,\n AnyUntrustedContextKey,\n Trust,\n} from './ContextKey';\nexport { ContextTuple } from './ContextTuple';\n\n// @DocumentDesign — DI-design-root marker. Applies to ANY project kind (server\n// controllers AND library impl classes), so it lives here (browser + Node) rather\n// than in a server-only routing package.\nexport { DocumentDesign, isDocumentDesign, DESIGN_METADATA_KEYS } from './DocumentDesign';\n\n// Logging (merged from former @webpieces/wp-logging).\n// Pluggable logging interface + a browser-safe console default; apps plug in\n// bunyan/winston/pino/etc. via LogManager.setFactory(...). Browser + Node.\nexport type { Logger, LogLevel } from './logging/Logger';\nexport type { LoggerFactory } from './logging/LoggerFactory';\nexport { ConsoleLogger } from './logging/ConsoleLogger';\nexport { ConsoleLoggerFactory } from './logging/ConsoleLoggerFactory';\nexport { LogManager } from './logging/LogManager';\nexport {\n LogChunker,\n LogChunkerImpl,\n LogChunkInfo,\n MAX_GCP_LOG_BYTES,\n GCP_LOG_BUDGET_BYTES,\n} from './logging/LogChunker';\n\n// HTTP API contract (merged from former @webpieces/http-api).\n// Shared HTTP API definition consumed by both client and server: REST\n// decorators, the API error taxonomy, datetime DTOs, platform-header\n// registry/readers, ValidateImplementation, and the test-case recorder\n// contract. Pure definitions — express-free, browser + Node safe.\n\n// API definition decorators\nexport {\n ApiPath,\n Endpoint,\n // Auth mode decorators (clean service-to-service + user JWT model)\n WpAuthPublic,\n WpAuthJwt,\n rolesRequired,\n MISSING_AUTH_DECORATOR_FIX,\n WpAuthOidc,\n WpAuthSharedSecret,\n WpAuthWebhook,\n WpAuthApiKey,\n WpAuthLocalOnly,\n MaskLog,\n getApiPath,\n getEndpoints,\n getEndpointOptions,\n getEndpointKind,\n getEndpointKinds,\n getMaskSpec,\n isFormPost,\n isRawBody,\n isApiPath,\n getAuthMeta,\n getAuthMode,\n assertEveryEndpointHasAuthMode,\n assertEveryExternalEndpointDeclaresCaller,\n assertEveryWebhookEndpointRetainsRawBody,\n validateNoConflictingDecorators,\n METADATA_KEYS,\n} from './http/decorators';\nexport {\n PathParam,\n QueryParam,\n getHttpParameterDeclarations,\n} from './http/http-parameter-decorators';\nexport {\n WpInternal,\n WpIpcEndpoint,\n isInternalApi,\n getIpcApiId,\n getIpcEndpoints,\n getIpcEndpointKind,\n getIpcMaskSpec,\n assertInternalApi,\n assertNotInternalApi,\n IPC_METADATA_KEYS,\n} from './ipc/IpcDecorators';\nexport type { IpcApiType, IpcEndpointKind, IpcEndpointOptions } from './ipc/IpcDecorators';\n// The runtime representation of ONE route (split out of decorators.ts for file size only).\nexport { RouteMetadata } from './http/RouteMetadata';\nexport { RouteMetadataFactory } from './http/RouteMetadataFactory';\nexport {\n BoundHttpRequest,\n HttpContractMapper,\n HttpParameterBinding,\n HttpParameterDeclaration,\n} from './http/HttpContract';\nexport {\n StreamCorrelation,\n StreamEnvelope,\n StreamingEndpointMetadata,\n StreamEventValidator,\n StreamTransportError,\n StreamWriter,\n WpStream,\n getStreamingEndpoint,\n} from './http/StreamingContract';\nexport type {\n RequestStream,\n ResponseStream,\n StreamEnvelopeKind,\n StreamFailureOptions,\n} from './http/StreamingContract';\nexport type {\n ContractHttpMethod,\n EndpointResponseType,\n HttpParameterSource,\n HttpParameterValueType,\n} from './http/HttpContract';\nexport type { EndpointKind, EndpointOptions, ExternalEndpointOptions } from './http/decorators';\nexport { WpMcpTool, WpMcpToolHints, WpMcpToolMetadata, getWpMcpTools } from './mcp/McpMetadata';\nexport type { WpMcpMethodDecorator, WpMcpToolOptions } from './mcp/McpMetadata';\nexport { WpMcpAuthJwt, WpMcpJwtAuthMetadata, getWpMcpAuthJwt } from './mcp/McpAuthMetadata';\nexport {\n WpDto,\n WpDtoField,\n WpDtoFieldOptions,\n WpMcpHeader,\n WpDtoMapFieldOptions,\n WpDtoFieldMetadata,\n WpResponseDto,\n ApiJsonSchema,\n DtoValidationFailure,\n DtoSchemaBuilder,\n} from './mcp/DtoSchema';\nexport type { DtoClass, DtoElementType, DtoValue } from './mcp/DtoSchema';\n// The TYPE layer of the auth surface — likewise split out of decorators.ts for file size only.\nexport { AuthMeta } from './http/auth-mode';\nexport type {\n AuthMode,\n ApiKeyCredential,\n ApiKeyCredentials,\n JwtRoles,\n JwtRequirement,\n} from './http/auth-mode';\n// API kind (RPC vs PubSub/Cloud Tasks) + queue naming. Split out of decorators.ts for file size only;\n// one-way dependency api-kind -> decorators, and the barrel keeps the surface identical.\nexport {\n Rpc,\n PubSub,\n Queue,\n ENDPOINT_KINDS_BY_API_KIND,\n getApiKind,\n assertApiKind,\n assertPubSubConventions,\n getQueueName,\n} from './http/api-kind';\nexport type { ApiKind } from './http/api-kind';\n// WHO calls an `external` endpoint — the caller declaration @Endpoint(..., 'external', {calledBy})\n// requires, and the reader for it.\nexport {\n EXTERNAL_SYSTEM_KINDS,\n DEFAULT_CALLER_KIND,\n ExternalCaller,\n isExternalSystemKind,\n getEndpointCaller,\n} from './http/external-caller';\nexport type { ExternalSystemKind } from './http/external-caller';\n// Client-side shared-secret store (the value THIS service sends per @WpAuthSharedSecret key).\nexport { Secrets, SECRETS } from './http/Secrets';\n\n// Type validators\nexport { ValidateImplementation } from './http/validators';\n\n// Authentication subtype constants.\nexport {\n ENTITY_NOT_FOUND,\n WRONG_LOGIN_TYPE,\n WRONG_LOGIN,\n NOT_APPROVED,\n EMAIL_NOT_CONFIRMED,\n WRONG_DOMAIN,\n WRONG_COMPANY,\n NO_REG_CODE,\n} from './errors';\n\nexport { NetworkRejectClassifier } from './http/networkReject';\n\n// Date/Time DTOs and Utilities (inspired by Java Time / JSR-310)\nexport {\n InstantDto,\n DateDto,\n TimeDto,\n DateTimeDto,\n InstantUtil,\n DateUtil,\n TimeUtil,\n DateTimeUtil,\n} from './http/datetime';\n\n// Context keys + registry (the global magic-context header system)\nexport { HeaderRegistry } from './http/HeaderRegistry';\nexport { ClientRegistry } from './http/ClientRegistry';\nexport { CallRegistry } from './http/CallRegistry';\nexport { CallDeadline } from './http/CallDeadline';\nexport { CallContext } from './http/CallStrategy';\nexport type { Attempt, CallStrategy } from './http/CallStrategy';\nexport { ApiCallTimeoutError } from './http/ApiCallTimeoutError';\nexport type { ServiceUrlDeriver } from './http/ClientRegistry';\n\n// \"What service am I\" — set once at startup, read by the logging backends and by\n// RequestContextHeaders (to stamp requestIdSource on ids this service mints).\nexport { ServiceInfo } from './http/ServiceInfo';\n// \"Where am I running\" — declared once at startup (setupRuntime, from RuntimeSetupOptions.locality).\n// The ONE input to @WpAuthLocalOnly enforcement. Undeclared reads as DEPLOYED (fail safe).\nexport { RuntimeLocality } from './http/RuntimeLocality';\nexport type { Locality } from './http/RuntimeLocality';\n// The ENTIRE HTTP response as pure data — the ONE form both transports (express, fetch) are\n// normalised into, so an ErrorTranslators implementation is written once and serves both.\nexport { HttpHeader, HttpResponseStatus, HttpResponseDto } from './http/HttpResponseDto';\n// Pluggable, bidirectional error translation (app exception <-> the WHOLE response). Set on\n// ClientRegistry at startup; consulted before the built-in webpieces mapping on BOTH sides.\nexport type { ErrorTranslators } from './http/ErrorTranslators';\n// Pluggable per-client failure classification (is a thrown API-call error a real failure or an\n// expected non-failure?). Registered on ClientRegistry at startup; consulted by LogApiCall.\nexport type { FailureClassifier } from './http/FailureClassifier';\nexport { KeyedFailureClassifier } from './http/FailureClassifier';\nexport {\n WebpiecesDefaultFailureClassifier,\n WEBPIECES_DEFAULT_FAILURE_CLASSIFIER,\n} from './http/WebpiecesDefaultFailureClassifier';\nexport { templateDeriver } from './http/templateDeriver';\nexport { WebpiecesCoreHeaders } from './http/WebpiecesCoreHeaders';\nexport { ContextReader } from './http/ContextReader';\n\n// The OUTBOUND half of the trust model: whether a TRUSTED context key may ride to the endpoint being\n// called. Built ONLY from the destination endpoint's AuthMode — see the class doc.\nexport { DestinationTrust } from './http/DestinationTrust';\n\n// BROWSER-ONLY outbound-header propagation (app-held store + registry -> outbound HTTP headers).\n// Only @webpieces/http-client-browser may name it; the server reads RequestContext directly via\n// RequestContextHeaders in the Node-only @webpieces/core-context.\nexport { ContextMgr } from './http/ContextMgr';\n\n// API-call logging helper (uses LogManager above). NOT a singleton: construct one per environment\n// with that environment's ApiCallContext — `new LogApiCallImpl(new RequestContextApiCallContext())`\n// on node, `new LogApiCallImpl(new BrowserApiCallContext())` in a browser.\nexport { LogApiCallImpl } from './http/LogApiCall';\n\n// Opt-in field masking for the LogApiCall log path — declare per-api sensitive fields so secrets\n// (OAuth refresh tokens, id-token JWTs) are masked in the logs while the real value stays on the wire.\nexport { MaskSpec } from './http/LogFieldMask';\nexport type { MaskMode } from './http/LogFieldMask';\n\n// The structured `api` tag + the context-writer seam LogApiCall stamps through. The Node\n// RequestContext-backed impl lives in @webpieces/core-context, the browser one in\n// @webpieces/http-client-browser; each is CONSTRUCTED by its package, never installed globally.\nexport { ApiCallInfo } from './http/ApiCallInfo';\nexport type { ApiType, ApiResult } from './http/ApiCallInfo';\n// Console-render bridge: turns LogApiCall's [LogApiCall] bracket into [API.{side}.{phase}] locally.\nexport {\n ApiCallLogName,\n ApiCallLogNameImpl,\n LOG_API_CALL_LOGGER_NAME,\n} from './http/ApiCallLogName';\nexport { ApiMethodInfo } from './http/ApiMethodInfo';\nexport type { ApiSide } from './http/ApiMethodInfo';\nexport type { ApiCallContext } from './http/ApiCallContext';\n\n// Test-case recording contract (impl lives in http-server; hooks in http-client)\nexport { TestCaseRecorder, RecorderKeys } from './http/recorder/TestCaseRecorder';\nexport {\n RecordedEndpoint,\n RecordedError,\n RecordedTestCase,\n} from './http/recorder/RecordedEndpoint';\nexport { DoNotRecord, getDoNotRecordFields } from './http/recorder/DoNotRecord';\nexport { RecordSerializer, SerializedMap, SerializedError } from './http/recorder/RecordSerializer';\n\n// ---------------------------------------------------------------------------------------------\n// Filter-chain primitives, shared by BOTH chains: the inbound server chain\n// (`Filter<MethodMeta, WpResponse<unknown>>`, @webpieces/http-routing) and the outbound client\n// chain (`Filter<ClientRequest, Response>`, @webpieces/http-client-core). Declared once, here, in\n// the package both depend on — see the class doc for why a second pair would be a shim.\nexport { Filter } from './filters/Filter';\nexport type { Service } from './filters/Filter';\nexport { FilterChain } from './filters/FilterChain';\n\nexport {\n ApiError,\n ApiNotFoundError,\n ApiDependencyError,\n ApiUnavailableError,\n ApiDependencyTimeoutError,\n ApiImplementationError,\n ApiRateLimitedError,\n ApiForbiddenError,\n ApiRequestTimeoutError,\n ApiEndUserError,\n ApiBadRequestError,\n ApiUnauthorizedError,\n ApiDependencyBackoffError,\n ApiConnectionError,\n ApiEndpointNotFoundError,\n ApiErrorCodec,\n ApiErrorPayload,\n ApiErrorBoundary,\n} from './errors';\nexport type { ApiErrorKind } from './errors';\nexport { ApiErrorHttpStatus } from './http/ApiErrorHttpStatus';\n"]}
@@ -16,13 +16,26 @@ export declare class WpDtoFieldOptions {
16
16
  readonly minimum?: number | undefined;
17
17
  readonly maximum?: number | undefined;
18
18
  readonly enumValues?: readonly [string, ...string[]] | undefined;
19
+ /** MCP 2026 SEP-2243 header mirrored as `Mcp-Param-{name}`. */
20
+ readonly mcpHeader?: WpMcpHeader | undefined;
19
21
  constructor(description: string,
20
22
  /** Required/optional is explicit because TypeScript erases `?` at runtime. */
21
23
  required: boolean,
22
24
  /** Required for arrays because TypeScript erases their element type. */
23
25
  arrayItems?: DtoElementType | undefined,
24
26
  /** A reflected Number is otherwise emitted as JSON Schema `number`. */
25
- integer?: boolean, minimum?: number | undefined, maximum?: number | undefined, enumValues?: readonly [string, ...string[]] | undefined);
27
+ integer?: boolean, minimum?: number | undefined, maximum?: number | undefined, enumValues?: readonly [string, ...string[]] | undefined,
28
+ /** MCP 2026 SEP-2243 header mirrored as `Mcp-Param-{name}`. */
29
+ mcpHeader?: WpMcpHeader | undefined);
30
+ }
31
+ /**
32
+ * Names the `x-mcp-header` a primitive tool parameter is mirrored into (`Mcp-Param-{name}`). A class,
33
+ * not a bare string, so the 8th `WpDtoFieldOptions` argument can never be mistaken for a map value
34
+ * type (maps use `WpDtoMapFieldOptions`).
35
+ */
36
+ export declare class WpMcpHeader {
37
+ readonly name: string;
38
+ constructor(name: string);
26
39
  }
27
40
  /**
28
41
  * Field metadata for a typed map such as `Record<string, string>` or `Record<string, SomeDto>`.
@@ -55,12 +68,18 @@ export declare class ApiJsonSchema {
55
68
  enum?: string[];
56
69
  minimum?: number;
57
70
  maximum?: number;
71
+ /** MCP 2026 SEP-2243 schema extension consumed by the official SDK. */
72
+ 'x-mcp-header'?: string;
58
73
  constructor(type?: 'object' | 'string' | 'number' | 'integer' | 'boolean' | 'array');
59
74
  }
60
75
  /** A validation result safe to show to an API caller/model. */
61
76
  export declare class DtoValidationFailure {
77
+ /** JSON path of the offending value, e.g. `$.address.city`. */
78
+ readonly field: string;
62
79
  readonly message: string;
63
- constructor(message: string);
80
+ constructor(
81
+ /** JSON path of the offending value, e.g. `$.address.city`. */
82
+ field: string, message: string);
64
83
  }
65
84
  /** Marks a request/response class as a schema-bearing DTO, including intentionally empty DTOs. */
66
85
  export declare function WpDto(): ClassDecorator;
@@ -85,6 +104,7 @@ export declare class DtoSchemaBuilder {
85
104
  private fieldSchema;
86
105
  private validateOptions;
87
106
  private itemSchema;
107
+ private validateMcpHeaders;
88
108
  private validateAt;
89
109
  private validateField;
90
110
  private validateArray;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DtoSchemaBuilder = exports.DtoValidationFailure = exports.ApiJsonSchema = exports.WpDtoFieldMetadata = exports.WpDtoMapFieldOptions = exports.WpDtoFieldOptions = void 0;
3
+ exports.DtoSchemaBuilder = exports.DtoValidationFailure = exports.ApiJsonSchema = exports.WpDtoFieldMetadata = exports.WpDtoMapFieldOptions = exports.WpMcpHeader = exports.WpDtoFieldOptions = void 0;
4
4
  exports.WpDto = WpDto;
5
5
  exports.WpDtoField = WpDtoField;
6
6
  exports.WpResponseDto = WpResponseDto;
@@ -17,13 +17,16 @@ class WpDtoFieldOptions {
17
17
  minimum;
18
18
  maximum;
19
19
  enumValues;
20
+ mcpHeader;
20
21
  constructor(description,
21
22
  /** Required/optional is explicit because TypeScript erases `?` at runtime. */
22
23
  required,
23
24
  /** Required for arrays because TypeScript erases their element type. */
24
25
  arrayItems,
25
26
  /** A reflected Number is otherwise emitted as JSON Schema `number`. */
26
- integer = false, minimum, maximum, enumValues) {
27
+ integer = false, minimum, maximum, enumValues,
28
+ /** MCP 2026 SEP-2243 header mirrored as `Mcp-Param-{name}`. */
29
+ mcpHeader) {
27
30
  this.description = description;
28
31
  this.required = required;
29
32
  this.arrayItems = arrayItems;
@@ -31,9 +34,22 @@ class WpDtoFieldOptions {
31
34
  this.minimum = minimum;
32
35
  this.maximum = maximum;
33
36
  this.enumValues = enumValues;
37
+ this.mcpHeader = mcpHeader;
34
38
  }
35
39
  }
36
40
  exports.WpDtoFieldOptions = WpDtoFieldOptions;
41
+ /**
42
+ * Names the `x-mcp-header` a primitive tool parameter is mirrored into (`Mcp-Param-{name}`). A class,
43
+ * not a bare string, so the 8th `WpDtoFieldOptions` argument can never be mistaken for a map value
44
+ * type (maps use `WpDtoMapFieldOptions`).
45
+ */
46
+ class WpMcpHeader {
47
+ name;
48
+ constructor(name) {
49
+ this.name = name;
50
+ }
51
+ }
52
+ exports.WpMcpHeader = WpMcpHeader;
37
53
  /**
38
54
  * Field metadata for a typed map such as `Record<string, string>` or `Record<string, SomeDto>`.
39
55
  * Keys are open strings; every VALUE must match `mapValues`. The value type is explicit for the same
@@ -80,8 +96,12 @@ class ApiJsonSchema {
80
96
  exports.ApiJsonSchema = ApiJsonSchema;
81
97
  /** A validation result safe to show to an API caller/model. */
82
98
  class DtoValidationFailure {
99
+ field;
83
100
  message;
84
- constructor(message) {
101
+ constructor(
102
+ /** JSON path of the offending value, e.g. `$.address.city`. */
103
+ field, message) {
104
+ this.field = field;
85
105
  this.message = message;
86
106
  }
87
107
  }
@@ -144,7 +164,9 @@ class DtoSchemaBuilder {
144
164
  return extra === false || (typeof extra === 'object' && extra !== null);
145
165
  }
146
166
  build(dtoClass) {
147
- return this.buildAt(dtoClass, new Set());
167
+ const schema = this.buildAt(dtoClass, new Set());
168
+ this.validateMcpHeaders(schema, new Map());
169
+ return schema;
148
170
  }
149
171
  validate(dtoClass, value) {
150
172
  return this.validateAt(dtoClass, value, '$');
@@ -210,6 +232,8 @@ class DtoSchemaBuilder {
210
232
  schema.maximum = options.maximum;
211
233
  if (options.enumValues)
212
234
  schema.enum = [...options.enumValues];
235
+ if (options.mcpHeader)
236
+ schema['x-mcp-header'] = options.mcpHeader.name;
213
237
  return schema;
214
238
  }
215
239
  validateOptions(dtoClass, field, reflected) {
@@ -232,34 +256,61 @@ class DtoSchemaBuilder {
232
256
  (options.integer || options.minimum !== undefined || options.maximum !== undefined)) {
233
257
  throw new Error(`${label} declares numeric constraints but is not a number.`);
234
258
  }
235
- if (options.minimum !== undefined && options.maximum !== undefined && options.minimum > options.maximum) {
259
+ if (options.minimum !== undefined &&
260
+ options.maximum !== undefined &&
261
+ options.minimum > options.maximum) {
236
262
  throw new Error(`${label} minimum cannot exceed maximum.`);
237
263
  }
238
264
  if (options.enumValues && reflected.name !== 'String') {
239
265
  throw new Error(`${label} enumValues require a string field.`);
240
266
  }
267
+ if (options.mcpHeader !== undefined) {
268
+ if (!/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/.test(options.mcpHeader.name)) {
269
+ throw new Error(`${label} mcpHeader must be an RFC 9110 token.`);
270
+ }
271
+ if (!['String', 'Number', 'Boolean'].includes(reflected.name)) {
272
+ throw new Error(`${label} mcpHeader requires a primitive field.`);
273
+ }
274
+ if (reflected.name === 'Number' && !options.integer) {
275
+ throw new Error(`${label} mcpHeader cannot mirror a non-integer number (MCP 2026-07-28).`);
276
+ }
277
+ }
241
278
  }
242
279
  itemSchema(item, parents) {
243
280
  if (typeof item !== 'string')
244
281
  return this.buildAt(item, parents);
245
282
  return new ApiJsonSchema(item === 'integer' ? 'integer' : item);
246
283
  }
284
+ validateMcpHeaders(schema, seen) {
285
+ const header = schema['x-mcp-header'];
286
+ if (header) {
287
+ const key = header.toLowerCase();
288
+ const prior = seen.get(key);
289
+ if (prior) {
290
+ throw new Error(`mcpHeader '${header}' duplicates '${prior}' case-insensitively.`);
291
+ }
292
+ seen.set(key, header);
293
+ }
294
+ for (const child of Object.values(schema.properties ?? {})) {
295
+ this.validateMcpHeaders(child, seen);
296
+ }
297
+ }
247
298
  validateAt(dtoClass, value, path) {
248
299
  this.requireDto(dtoClass);
249
300
  if (typeof value !== 'object' || value === null || Array.isArray(value)) {
250
- return new DtoValidationFailure(`${path} must be an object`);
301
+ return new DtoValidationFailure(path, `${path} must be an object`);
251
302
  }
252
303
  const fields = this.fields(dtoClass);
253
304
  const known = new Set(fields.map((field) => field.propertyKey));
254
305
  for (const key of Object.keys(value)) {
255
306
  if (!known.has(key))
256
- return new DtoValidationFailure(`${path}.${key} is not allowed`);
307
+ return new DtoValidationFailure(`${path}.${key}`, `${path}.${key} is not allowed`);
257
308
  }
258
309
  for (const field of fields) {
259
310
  const fieldValue = Object.getOwnPropertyDescriptor(value, field.propertyKey)?.value;
260
311
  if (fieldValue === undefined) {
261
312
  if (field.options.required) {
262
- return new DtoValidationFailure(`${path}.${field.propertyKey} is required`);
313
+ return new DtoValidationFailure(`${path}.${field.propertyKey}`, `${path}.${field.propertyKey} is required`);
263
314
  }
264
315
  continue;
265
316
  }
@@ -280,39 +331,39 @@ class DtoSchemaBuilder {
280
331
  return this.validateArray(options, value, path);
281
332
  if (expected === 'String') {
282
333
  if (typeof value !== 'string')
283
- return new DtoValidationFailure(`${path} must be a string`);
334
+ return new DtoValidationFailure(path, `${path} must be a string`);
284
335
  if (options.enumValues && !options.enumValues.includes(value)) {
285
- return new DtoValidationFailure(`${path} must be one of: ${options.enumValues.join(', ')}`);
336
+ return new DtoValidationFailure(path, `${path} must be one of: ${options.enumValues.join(', ')}`);
286
337
  }
287
338
  return undefined;
288
339
  }
289
340
  if (expected === 'Number') {
290
341
  if (typeof value !== 'number' || !Number.isFinite(value)) {
291
- return new DtoValidationFailure(`${path} must be a number`);
342
+ return new DtoValidationFailure(path, `${path} must be a number`);
292
343
  }
293
344
  if (options.integer && !Number.isInteger(value)) {
294
- return new DtoValidationFailure(`${path} must be an integer`);
345
+ return new DtoValidationFailure(path, `${path} must be an integer`);
295
346
  }
296
347
  if (options.minimum !== undefined && value < options.minimum) {
297
- return new DtoValidationFailure(`${path} must be >= ${options.minimum}`);
348
+ return new DtoValidationFailure(path, `${path} must be >= ${options.minimum}`);
298
349
  }
299
350
  if (options.maximum !== undefined && value > options.maximum) {
300
- return new DtoValidationFailure(`${path} must be <= ${options.maximum}`);
351
+ return new DtoValidationFailure(path, `${path} must be <= ${options.maximum}`);
301
352
  }
302
353
  return undefined;
303
354
  }
304
355
  if (expected === 'Boolean') {
305
356
  return typeof value === 'boolean'
306
357
  ? undefined
307
- : new DtoValidationFailure(`${path} must be a boolean`);
358
+ : new DtoValidationFailure(path, `${path} must be a boolean`);
308
359
  }
309
360
  return this.validateAt(reflected, value, path);
310
361
  }
311
362
  validateArray(options, value, path) {
312
363
  if (!Array.isArray(value))
313
- return new DtoValidationFailure(`${path} must be an array`);
364
+ return new DtoValidationFailure(path, `${path} must be an array`);
314
365
  if (!options.arrayItems)
315
- return new DtoValidationFailure(`${path} has no item type`);
366
+ return new DtoValidationFailure(path, `${path} has no item type`);
316
367
  for (let index = 0; index < value.length; index += 1) {
317
368
  const failure = this.validateElement(options.arrayItems, value[index], `${path}[${index}]`);
318
369
  if (failure)
@@ -322,11 +373,11 @@ class DtoSchemaBuilder {
322
373
  }
323
374
  validateMap(options, value, path) {
324
375
  if (typeof value !== 'object' || value === null || Array.isArray(value)) {
325
- return new DtoValidationFailure(`${path} must be an object map`);
376
+ return new DtoValidationFailure(path, `${path} must be an object map`);
326
377
  }
327
378
  const prototype = Object.getPrototypeOf(value);
328
379
  if (prototype !== Object.prototype && prototype !== null) {
329
- return new DtoValidationFailure(`${path} must be a plain object map`);
380
+ return new DtoValidationFailure(path, `${path} must be a plain object map`);
330
381
  }
331
382
  for (const key of Object.keys(value)) {
332
383
  const entry = Object.getOwnPropertyDescriptor(value, key)?.value;
@@ -341,7 +392,7 @@ class DtoSchemaBuilder {
341
392
  return this.validateAt(type, item, path);
342
393
  const wanted = type === 'integer' ? 'number' : type;
343
394
  if (typeof item !== wanted || (type === 'integer' && !Number.isInteger(item))) {
344
- return new DtoValidationFailure(`${path} must be ${type}`);
395
+ return new DtoValidationFailure(path, `${path} must be ${type}`);
345
396
  }
346
397
  return undefined;
347
398
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DtoSchema.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/mcp/DtoSchema.ts"],"names":[],"mappings":";;;AA2EA,sBAEC;AAID,gCAYC;AAID,sCAQC;AAzGD,4BAA0B;AAE1B,MAAM,UAAU,GAAG,sBAAsB,CAAC;AAC1C,MAAM,UAAU,GAAG,sBAAsB,CAAC;AAC1C,MAAM,aAAa,GAAG,yBAAyB,CAAC;AAShD,uFAAuF;AACvF,MAAa,iBAAiB;IAEN;IAEA;IAEA;IAEA;IACA;IACA;IACA;IAVpB,YACoB,WAAmB;IACnC,8EAA8E;IAC9D,QAAiB;IACjC,wEAAwE;IACxD,UAA2B;IAC3C,uEAAuE;IACvD,UAAmB,KAAK,EACxB,OAAgB,EAChB,OAAgB,EAChB,UAA2C;QAT3C,gBAAW,GAAX,WAAW,CAAQ;QAEnB,aAAQ,GAAR,QAAQ,CAAS;QAEjB,eAAU,GAAV,UAAU,CAAiB;QAE3B,YAAO,GAAP,OAAO,CAAiB;QACxB,YAAO,GAAP,OAAO,CAAS;QAChB,YAAO,GAAP,OAAO,CAAS;QAChB,eAAU,GAAV,UAAU,CAAiC;IAC5D,CAAC;CACP;AAbD,8CAaC;AAED;;;;GAIG;AACH,MAAa,oBAAoB;IAET;IAEA;IACA;IAJpB,YACoB,WAAmB;IACnC,8EAA8E;IAC9D,QAAiB,EACjB,SAAyB;QAHzB,gBAAW,GAAX,WAAW,CAAQ;QAEnB,aAAQ,GAAR,QAAQ,CAAS;QACj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QACD,OAAO,SAAS,CAAC;IACrB,CAAC;IAEO,eAAe,CACnB,IAAoB,EACpB,IAAc,EACd,IAAY;QAEZ,IAAI,OAAO,IAAI,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACvE,MAAM,MAAM,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC;QACpD,IAAI,OAAO,IAAI,KAAK,MAAM,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;YAC5E,OAAO,IAAI,oBAAoB,CAAC,GAAG,IAAI,YAAY,IAAI,EAAE,CAAC,CAAC;QAC/D,CAAC;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;IAEO,MAAM,CAAC,QAAkB;QAC7B,MAAM,MAAM,GACR,OAAO,CAAC,WAAW,CAAC,UAAU,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;QACpD,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAEO,UAAU,CAAC,QAAkB;QACjC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAE,CAAC;YAC7C,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,CAAC,IAAI,yDAAyD,CAAC,CAAC;QAC/F,CAAC;IACL,CAAC;CACJ;AA7RD,4CA6RC","sourcesContent":["import 'reflect-metadata';\n\nconst DTO_MARKER = 'webpieces:dto-schema';\nconst DTO_FIELDS = 'webpieces:dto-fields';\nconst RESPONSE_DTOS = 'webpieces:response-dtos';\n\n// webpieces-disable no-any-unknown -- abstract class tokens necessarily erase constructor parameters\nexport type DtoClass = abstract new (...args: any[]) => unknown;\n/** The element type of an array or the value type of a map; TypeScript erases both at runtime. */\nexport type DtoElementType = 'string' | 'number' | 'integer' | 'boolean' | DtoClass;\n/** Runtime values accepted at the DTO validation boundary. */\nexport type DtoValue = object | string | number | boolean | null;\n\n/** Additive field metadata; the scalar/object type itself comes from `design:type`. */\nexport class WpDtoFieldOptions {\n constructor(\n public readonly description: string,\n /** Required/optional is explicit because TypeScript erases `?` at runtime. */\n public readonly required: boolean,\n /** Required for arrays because TypeScript erases their element type. */\n public readonly arrayItems?: DtoElementType,\n /** A reflected Number is otherwise emitted as JSON Schema `number`. */\n public readonly integer: boolean = false,\n public readonly minimum?: number,\n public readonly maximum?: number,\n public readonly enumValues?: readonly [string, ...string[]],\n ) {}\n}\n\n/**\n * Field metadata for a typed map such as `Record<string, string>` or `Record<string, SomeDto>`.\n * Keys are open strings; every VALUE must match `mapValues`. The value type is explicit for the same\n * reason `arrayItems` is: TypeScript erases it, and a `Record` reflects as plain `Object`.\n */\nexport class WpDtoMapFieldOptions {\n constructor(\n public readonly description: string,\n /** Required/optional is explicit because TypeScript erases `?` at runtime. */\n public readonly required: boolean,\n public readonly mapValues: DtoElementType,\n ) {}\n}\n\nexport class WpDtoFieldMetadata {\n constructor(\n public readonly propertyKey: string,\n public readonly options: WpDtoFieldOptions | WpDtoMapFieldOptions,\n ) {}\n}\n\n/** The JSON Schema subset emitted for Webpieces API DTOs. */\nexport class ApiJsonSchema {\n type?: 'object' | 'string' | 'number' | 'integer' | 'boolean' | 'array';\n description?: string;\n properties?: Record<string, ApiJsonSchema>;\n required?: string[];\n /** `false` closes an object; a schema makes it a typed map whose values all match that schema. */\n additionalProperties?: boolean | ApiJsonSchema;\n items?: ApiJsonSchema;\n enum?: string[];\n minimum?: number;\n maximum?: number;\n\n constructor(type?: 'object' | 'string' | 'number' | 'integer' | 'boolean' | 'array') {\n this.type = type;\n }\n}\n\n/** A validation result safe to show to an API caller/model. */\nexport class DtoValidationFailure {\n constructor(public readonly message: string) {}\n}\n\n/** Marks a request/response class as a schema-bearing DTO, including intentionally empty DTOs. */\n// webpieces-disable no-function-outside-class -- decorator factories are inherently module-scope\nexport function WpDto(): ClassDecorator {\n return (target: Function): void => Reflect.defineMetadata(DTO_MARKER, true, target);\n}\n\n/** Adds documentation and runtime-only shape facts to a DTO property. */\n// webpieces-disable no-function-outside-class -- decorator factories are inherently module-scope\nexport function WpDtoField(options: WpDtoFieldOptions | WpDtoMapFieldOptions): PropertyDecorator {\n if (options.description.trim() === '') {\n throw new Error('@WpDtoField requires non-empty field documentation.');\n }\n return (target: object, propertyKey: string | symbol): void => {\n const dtoClass = target.constructor;\n const fields: Record<string, WpDtoFieldMetadata> =\n Reflect.getMetadata(DTO_FIELDS, dtoClass) ?? {};\n const name = String(propertyKey);\n fields[name] = new WpDtoFieldMetadata(name, options);\n Reflect.defineMetadata(DTO_FIELDS, fields, dtoClass);\n };\n}\n\n/** Declares an async API method's response DTO because reflection sees Promise, not its generic. */\n// webpieces-disable no-function-outside-class -- decorator factories are inherently module-scope\nexport function WpResponseDto(responseDto: () => DtoClass): MethodDecorator {\n return (target: object, propertyKey: string | symbol): void => {\n const apiClass = target.constructor;\n const responses: Record<string, () => DtoClass> =\n Reflect.getMetadata(RESPONSE_DTOS, apiClass) ?? {};\n responses[String(propertyKey)] = responseDto;\n Reflect.defineMetadata(RESPONSE_DTOS, responses, apiClass);\n };\n}\n\n/** Builds and validates the same DTO schema used for MCP input and structured output. */\nexport class DtoSchemaBuilder {\n requestClassOf(apiClass: Function, methodName: string): DtoClass {\n // webpieces-disable no-any-unknown -- reflect-metadata returns erased runtime constructor tokens\n const params = Reflect.getMetadata('design:paramtypes', apiClass.prototype, methodName) as\n | DtoClass[]\n | undefined;\n if (!params || params.length !== 1) {\n throw new Error(\n `${apiClass.name}.${methodName} must take exactly one @WpDto request class to be an MCP tool.`,\n );\n }\n return params[0];\n }\n\n responseClassOf(apiClass: Function, methodName: string): DtoClass {\n const responses: Record<string, () => DtoClass> =\n Reflect.getMetadata(RESPONSE_DTOS, apiClass) ?? {};\n const response = responses[methodName];\n if (!response) {\n throw new Error(\n `${apiClass.name}.${methodName} must declare @WpResponseDto(() => ResponseClass) before MCP exposure.`,\n );\n }\n return response();\n }\n\n /**\n * The one closure gate for an object schema. Closed means no key can carry an unspecified value:\n * either extra keys are forbidden (`additionalProperties: false`) or every extra key's value is\n * typed (`additionalProperties: <schema>`, a typed map). A missing or `true` value is open.\n * Use this instead of `schema.additionalProperties === false`, which rejects typed maps.\n */\n isClosedSchema(schema: ApiJsonSchema): boolean {\n const extra = schema.additionalProperties;\n return extra === false || (typeof extra === 'object' && extra !== null);\n }\n\n build(dtoClass: DtoClass): ApiJsonSchema {\n return this.buildAt(dtoClass, new Set<DtoClass>());\n }\n\n validate(dtoClass: DtoClass, value: DtoValue): DtoValidationFailure | undefined {\n return this.validateAt(dtoClass, value, '$');\n }\n\n private buildAt(dtoClass: DtoClass, parents: Set<DtoClass>): ApiJsonSchema {\n this.requireDto(dtoClass);\n if (parents.has(dtoClass)) {\n throw new Error(`Recursive DTO ${dtoClass.name} cannot use an inline MCP schema.`);\n }\n const nextParents = new Set(parents);\n nextParents.add(dtoClass);\n const schema = new ApiJsonSchema('object');\n schema.properties = {};\n schema.additionalProperties = false;\n const required: string[] = [];\n for (const field of this.fields(dtoClass)) {\n schema.properties[field.propertyKey] = this.fieldSchema(dtoClass, field, nextParents);\n if (field.options.required) required.push(field.propertyKey);\n }\n if (required.length > 0) schema.required = required;\n return schema;\n }\n\n private fieldSchema(\n dtoClass: DtoClass,\n field: WpDtoFieldMetadata,\n parents: Set<DtoClass>,\n ): ApiJsonSchema {\n // webpieces-disable no-any-unknown -- reflect-metadata returns an erased constructor token\n const reflected = Reflect.getMetadata(\n 'design:type',\n dtoClass.prototype,\n field.propertyKey,\n ) as DtoClass | undefined;\n if (!reflected) throw new Error(`No reflected type for ${dtoClass.name}.${field.propertyKey}.`);\n this.validateOptions(dtoClass, field, reflected);\n const options = field.options;\n if (options instanceof WpDtoMapFieldOptions) {\n const mapSchema = new ApiJsonSchema('object');\n mapSchema.description = options.description;\n mapSchema.additionalProperties = this.itemSchema(options.mapValues, parents);\n return mapSchema;\n }\n let schema: ApiJsonSchema;\n switch (reflected.name) {\n case 'String':\n schema = new ApiJsonSchema('string');\n break;\n case 'Number':\n schema = new ApiJsonSchema(options.integer ? 'integer' : 'number');\n break;\n case 'Boolean':\n schema = new ApiJsonSchema('boolean');\n break;\n case 'Array':\n if (!options.arrayItems) {\n throw new Error(`${dtoClass.name}.${field.propertyKey} must declare arrayItems.`);\n }\n schema = new ApiJsonSchema('array');\n schema.items = this.itemSchema(options.arrayItems, parents);\n break;\n default:\n schema = this.buildAt(reflected, parents);\n }\n schema.description = options.description;\n if (options.minimum !== undefined) schema.minimum = options.minimum;\n if (options.maximum !== undefined) schema.maximum = options.maximum;\n if (options.enumValues) schema.enum = [...options.enumValues];\n return schema;\n }\n\n private validateOptions(\n dtoClass: DtoClass,\n field: WpDtoFieldMetadata,\n reflected: DtoClass,\n ): void {\n const label = `${dtoClass.name}.${field.propertyKey}`;\n const options = field.options;\n if (options instanceof WpDtoMapFieldOptions) {\n if (reflected !== Object) {\n throw new Error(`${label} declares mapValues but is not a map (Record<string, V>).`);\n }\n return;\n }\n if (reflected === Object) {\n throw new Error(\n `${label} has type Object: an interface or Record can never be a @WpDto. ` +\n 'For a map, use WpDtoMapFieldOptions.',\n );\n }\n if (reflected.name !== 'Array' && options.arrayItems) {\n throw new Error(`${label} declares arrayItems but is not an array.`);\n }\n if (\n reflected.name !== 'Number' &&\n (options.integer || options.minimum !== undefined || options.maximum !== undefined)\n ) {\n throw new Error(`${label} declares numeric constraints but is not a number.`);\n }\n if (options.minimum !== undefined && options.maximum !== undefined && options.minimum > options.maximum) {\n throw new Error(`${label} minimum cannot exceed maximum.`);\n }\n if (options.enumValues && reflected.name !== 'String') {\n throw new Error(`${label} enumValues require a string field.`);\n }\n }\n\n private itemSchema(item: DtoElementType, parents: Set<DtoClass>): ApiJsonSchema {\n if (typeof item !== 'string') return this.buildAt(item, parents);\n return new ApiJsonSchema(item === 'integer' ? 'integer' : item);\n }\n\n private validateAt(\n dtoClass: DtoClass,\n value: DtoValue,\n path: string,\n ): DtoValidationFailure | undefined {\n this.requireDto(dtoClass);\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n return new DtoValidationFailure(`${path} must be an object`);\n }\n const fields = this.fields(dtoClass);\n const known = new Set(fields.map((field: WpDtoFieldMetadata) => field.propertyKey));\n for (const key of Object.keys(value)) {\n if (!known.has(key)) return new DtoValidationFailure(`${path}.${key} is not allowed`);\n }\n for (const field of fields) {\n const fieldValue = Object.getOwnPropertyDescriptor(value, field.propertyKey)?.value;\n if (fieldValue === undefined) {\n if (field.options.required) {\n return new DtoValidationFailure(`${path}.${field.propertyKey} is required`);\n }\n continue;\n }\n const failure = this.validateField(dtoClass, field, fieldValue, `${path}.${field.propertyKey}`);\n if (failure) return failure;\n }\n return undefined;\n }\n\n private validateField(\n dtoClass: DtoClass,\n field: WpDtoFieldMetadata,\n value: DtoValue,\n path: string,\n ): DtoValidationFailure | undefined {\n // webpieces-disable no-any-unknown -- reflect-metadata returns an erased constructor token\n const reflected = Reflect.getMetadata(\n 'design:type',\n dtoClass.prototype,\n field.propertyKey,\n ) as DtoClass;\n const options = field.options;\n if (options instanceof WpDtoMapFieldOptions) return this.validateMap(options, value, path);\n const expected = reflected?.name;\n if (expected === 'Array') return this.validateArray(options, value, path);\n if (expected === 'String') {\n if (typeof value !== 'string') return new DtoValidationFailure(`${path} must be a string`);\n if (options.enumValues && !options.enumValues.includes(value)) {\n return new DtoValidationFailure(`${path} must be one of: ${options.enumValues.join(', ')}`);\n }\n return undefined;\n }\n if (expected === 'Number') {\n if (typeof value !== 'number' || !Number.isFinite(value)) {\n return new DtoValidationFailure(`${path} must be a number`);\n }\n if (options.integer && !Number.isInteger(value)) {\n return new DtoValidationFailure(`${path} must be an integer`);\n }\n if (options.minimum !== undefined && value < options.minimum) {\n return new DtoValidationFailure(`${path} must be >= ${options.minimum}`);\n }\n if (options.maximum !== undefined && value > options.maximum) {\n return new DtoValidationFailure(`${path} must be <= ${options.maximum}`);\n }\n return undefined;\n }\n if (expected === 'Boolean') {\n return typeof value === 'boolean'\n ? undefined\n : new DtoValidationFailure(`${path} must be a boolean`);\n }\n return this.validateAt(reflected, value, path);\n }\n\n private validateArray(\n options: WpDtoFieldOptions,\n value: DtoValue,\n path: string,\n ): DtoValidationFailure | undefined {\n if (!Array.isArray(value)) return new DtoValidationFailure(`${path} must be an array`);\n if (!options.arrayItems) return new DtoValidationFailure(`${path} has no item type`);\n for (let index = 0; index < value.length; index += 1) {\n const failure = this.validateElement(options.arrayItems, value[index], `${path}[${index}]`);\n if (failure) return failure;\n }\n return undefined;\n }\n\n private validateMap(\n options: WpDtoMapFieldOptions,\n value: DtoValue,\n path: string,\n ): DtoValidationFailure | undefined {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n return new DtoValidationFailure(`${path} must be an object map`);\n }\n const prototype: object | null = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n return new DtoValidationFailure(`${path} must be a plain object map`);\n }\n for (const key of Object.keys(value)) {\n const entry: DtoValue = Object.getOwnPropertyDescriptor(value, key)?.value;\n const failure = this.validateElement(options.mapValues, entry, `${path}.${key}`);\n if (failure) return failure;\n }\n return undefined;\n }\n\n private validateElement(\n type: DtoElementType,\n item: DtoValue,\n path: string,\n ): DtoValidationFailure | undefined {\n if (typeof type !== 'string') return this.validateAt(type, item, path);\n const wanted = type === 'integer' ? 'number' : type;\n if (typeof item !== wanted || (type === 'integer' && !Number.isInteger(item))) {\n return new DtoValidationFailure(`${path} must be ${type}`);\n }\n return undefined;\n }\n\n private fields(dtoClass: DtoClass): WpDtoFieldMetadata[] {\n const fields: Record<string, WpDtoFieldMetadata> =\n Reflect.getMetadata(DTO_FIELDS, dtoClass) ?? {};\n return Object.values(fields);\n }\n\n private requireDto(dtoClass: DtoClass): void {\n if (!Reflect.getMetadata(DTO_MARKER, dtoClass)) {\n throw new Error(`${dtoClass.name} must be decorated with @WpDto() for schema generation.`);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"DtoSchema.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/mcp/DtoSchema.ts"],"names":[],"mappings":";;;AA4FA,sBAEC;AAID,gCAYC;AAID,sCAQC;AA1HD,4BAA0B;AAE1B,MAAM,UAAU,GAAG,sBAAsB,CAAC;AAC1C,MAAM,UAAU,GAAG,sBAAsB,CAAC;AAC1C,MAAM,aAAa,GAAG,yBAAyB,CAAC;AAShD,uFAAuF;AACvF,MAAa,iBAAiB;IAEN;IAEA;IAEA;IAEA;IACA;IACA;IACA;IAEA;IAZpB,YACoB,WAAmB;IACnC,8EAA8E;IAC9D,QAAiB;IACjC,wEAAwE;IACxD,UAA2B;IAC3C,uEAAuE;IACvD,UAAmB,KAAK,EACxB,OAAgB,EAChB,OAAgB,EAChB,UAA2C;IAC3D,+DAA+D;IAC/C,SAAuB;QAXvB,gBAAW,GAAX,WAAW,CAAQ;QAEnB,aAAQ,GAAR,QAAQ,CAAS;QAEjB,eAAU,GAAV,UAAU,CAAiB;QAE3B,YAAO,GAAP,OAAO,CAAiB;QACxB,YAAO,GAAP,OAAO,CAAS;QAChB,YAAO,GAAP,OAAO,CAAS;QAChB,eAAU,GAAV,UAAU,CAAiC;QAE3C,cAAS,GAAT,SAAS,CAAc;IACxC,CAAC;CACP;AAfD,8CAeC;AAED;;;;GAIG;AACH,MAAa,WAAW;IACQ;IAA5B,YAA4B,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;CAC/C;AAFD,kCAEC;AAED;;;;GAIG;AACH,MAAa,oBAAoB;IAET;IAEA;IACA;IAJpB,YACoB,WAAmB;IACnC,8EAA8E;IAC9D,QAAiB,EACjB,SAAyB;QAHzB,gBAAW,GAAX,WAAW,CAAQ;QAEnB,aAAQ,GAAR,QAAQ,CAAS;QACjB,cAAS,GAAT,SAAS,CAAgB;IAC1C,CAAC;CACP;AAPD,oDAOC;AAED,MAAa,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CAAC,EAAE,CAAC;YAC7C,MAAM,IAAI,KAAK,CACX,GAAG,QAAQ,CAAC,IAAI,yDAAyD,CAC5E,CAAC;QACN,CAAC;IACL,CAAC;CACJ;AAzVD,4CAyVC","sourcesContent":["import 'reflect-metadata';\n\nconst DTO_MARKER = 'webpieces:dto-schema';\nconst DTO_FIELDS = 'webpieces:dto-fields';\nconst RESPONSE_DTOS = 'webpieces:response-dtos';\n\n// webpieces-disable no-any-unknown -- abstract class tokens necessarily erase constructor parameters\nexport type DtoClass = abstract new (...args: any[]) => unknown;\n/** The element type of an array or the value type of a map; TypeScript erases both at runtime. */\nexport type DtoElementType = 'string' | 'number' | 'integer' | 'boolean' | DtoClass;\n/** Runtime values accepted at the DTO validation boundary. */\nexport type DtoValue = object | string | number | boolean | null;\n\n/** Additive field metadata; the scalar/object type itself comes from `design:type`. */\nexport class WpDtoFieldOptions {\n constructor(\n public readonly description: string,\n /** Required/optional is explicit because TypeScript erases `?` at runtime. */\n public readonly required: boolean,\n /** Required for arrays because TypeScript erases their element type. */\n public readonly arrayItems?: DtoElementType,\n /** A reflected Number is otherwise emitted as JSON Schema `number`. */\n public readonly integer: boolean = false,\n public readonly minimum?: number,\n public readonly maximum?: number,\n public readonly enumValues?: readonly [string, ...string[]],\n /** MCP 2026 SEP-2243 header mirrored as `Mcp-Param-{name}`. */\n public readonly mcpHeader?: WpMcpHeader,\n ) {}\n}\n\n/**\n * Names the `x-mcp-header` a primitive tool parameter is mirrored into (`Mcp-Param-{name}`). A class,\n * not a bare string, so the 8th `WpDtoFieldOptions` argument can never be mistaken for a map value\n * type (maps use `WpDtoMapFieldOptions`).\n */\nexport class WpMcpHeader {\n constructor(public readonly name: string) {}\n}\n\n/**\n * Field metadata for a typed map such as `Record<string, string>` or `Record<string, SomeDto>`.\n * Keys are open strings; every VALUE must match `mapValues`. The value type is explicit for the same\n * reason `arrayItems` is: TypeScript erases it, and a `Record` reflects as plain `Object`.\n */\nexport class WpDtoMapFieldOptions {\n constructor(\n public readonly description: string,\n /** Required/optional is explicit because TypeScript erases `?` at runtime. */\n public readonly required: boolean,\n public readonly mapValues: DtoElementType,\n ) {}\n}\n\nexport class WpDtoFieldMetadata {\n constructor(\n public readonly propertyKey: string,\n public readonly options: WpDtoFieldOptions | WpDtoMapFieldOptions,\n ) {}\n}\n\n/** The JSON Schema subset emitted for Webpieces API DTOs. */\nexport class ApiJsonSchema {\n type?: 'object' | 'string' | 'number' | 'integer' | 'boolean' | 'array';\n description?: string;\n properties?: Record<string, ApiJsonSchema>;\n required?: string[];\n /** `false` closes an object; a schema makes it a typed map whose values all match that schema. */\n additionalProperties?: boolean | ApiJsonSchema;\n items?: ApiJsonSchema;\n enum?: string[];\n minimum?: number;\n maximum?: number;\n /** MCP 2026 SEP-2243 schema extension consumed by the official SDK. */\n declare 'x-mcp-header'?: string;\n\n constructor(type?: 'object' | 'string' | 'number' | 'integer' | 'boolean' | 'array') {\n this.type = type;\n }\n}\n\n/** A validation result safe to show to an API caller/model. */\nexport class DtoValidationFailure {\n constructor(\n /** JSON path of the offending value, e.g. `$.address.city`. */\n public readonly field: string,\n public readonly message: string,\n ) {}\n}\n\n/** Marks a request/response class as a schema-bearing DTO, including intentionally empty DTOs. */\n// webpieces-disable no-function-outside-class -- decorator factories are inherently module-scope\nexport function WpDto(): ClassDecorator {\n return (target: Function): void => Reflect.defineMetadata(DTO_MARKER, true, target);\n}\n\n/** Adds documentation and runtime-only shape facts to a DTO property. */\n// webpieces-disable no-function-outside-class -- decorator factories are inherently module-scope\nexport function WpDtoField(options: WpDtoFieldOptions | WpDtoMapFieldOptions): PropertyDecorator {\n if (options.description.trim() === '') {\n throw new Error('@WpDtoField requires non-empty field documentation.');\n }\n return (target: object, propertyKey: string | symbol): void => {\n const dtoClass = target.constructor;\n const fields: Record<string, WpDtoFieldMetadata> =\n Reflect.getMetadata(DTO_FIELDS, dtoClass) ?? {};\n const name = String(propertyKey);\n fields[name] = new WpDtoFieldMetadata(name, options);\n Reflect.defineMetadata(DTO_FIELDS, fields, dtoClass);\n };\n}\n\n/** Declares an async API method's response DTO because reflection sees Promise, not its generic. */\n// webpieces-disable no-function-outside-class -- decorator factories are inherently module-scope\nexport function WpResponseDto(responseDto: () => DtoClass): MethodDecorator {\n return (target: object, propertyKey: string | symbol): void => {\n const apiClass = target.constructor;\n const responses: Record<string, () => DtoClass> =\n Reflect.getMetadata(RESPONSE_DTOS, apiClass) ?? {};\n responses[String(propertyKey)] = responseDto;\n Reflect.defineMetadata(RESPONSE_DTOS, responses, apiClass);\n };\n}\n\n/** Builds and validates the same DTO schema used for MCP input and structured output. */\nexport class DtoSchemaBuilder {\n requestClassOf(apiClass: Function, methodName: string): DtoClass {\n // webpieces-disable no-any-unknown -- reflect-metadata returns erased runtime constructor tokens\n const params = Reflect.getMetadata('design:paramtypes', apiClass.prototype, methodName) as\n | DtoClass[]\n | undefined;\n if (!params || params.length !== 1) {\n throw new Error(\n `${apiClass.name}.${methodName} must take exactly one @WpDto request class to be an MCP tool.`,\n );\n }\n return params[0];\n }\n\n responseClassOf(apiClass: Function, methodName: string): DtoClass {\n const responses: Record<string, () => DtoClass> =\n Reflect.getMetadata(RESPONSE_DTOS, apiClass) ?? {};\n const response = responses[methodName];\n if (!response) {\n throw new Error(\n `${apiClass.name}.${methodName} must declare @WpResponseDto(() => ResponseClass) before MCP exposure.`,\n );\n }\n return response();\n }\n\n /**\n * The one closure gate for an object schema. Closed means no key can carry an unspecified value:\n * either extra keys are forbidden (`additionalProperties: false`) or every extra key's value is\n * typed (`additionalProperties: <schema>`, a typed map). A missing or `true` value is open.\n * Use this instead of `schema.additionalProperties === false`, which rejects typed maps.\n */\n isClosedSchema(schema: ApiJsonSchema): boolean {\n const extra = schema.additionalProperties;\n return extra === false || (typeof extra === 'object' && extra !== null);\n }\n\n build(dtoClass: DtoClass): ApiJsonSchema {\n const schema = this.buildAt(dtoClass, new Set<DtoClass>());\n this.validateMcpHeaders(schema, new Map<string, string>());\n return schema;\n }\n\n validate(dtoClass: DtoClass, value: DtoValue): DtoValidationFailure | undefined {\n return this.validateAt(dtoClass, value, '$');\n }\n\n private buildAt(dtoClass: DtoClass, parents: Set<DtoClass>): ApiJsonSchema {\n this.requireDto(dtoClass);\n if (parents.has(dtoClass)) {\n throw new Error(`Recursive DTO ${dtoClass.name} cannot use an inline MCP schema.`);\n }\n const nextParents = new Set(parents);\n nextParents.add(dtoClass);\n const schema = new ApiJsonSchema('object');\n schema.properties = {};\n schema.additionalProperties = false;\n const required: string[] = [];\n for (const field of this.fields(dtoClass)) {\n schema.properties[field.propertyKey] = this.fieldSchema(dtoClass, field, nextParents);\n if (field.options.required) required.push(field.propertyKey);\n }\n if (required.length > 0) schema.required = required;\n return schema;\n }\n\n private fieldSchema(\n dtoClass: DtoClass,\n field: WpDtoFieldMetadata,\n parents: Set<DtoClass>,\n ): ApiJsonSchema {\n // webpieces-disable no-any-unknown -- reflect-metadata returns an erased constructor token\n const reflected = Reflect.getMetadata(\n 'design:type',\n dtoClass.prototype,\n field.propertyKey,\n ) as DtoClass | undefined;\n if (!reflected)\n throw new Error(`No reflected type for ${dtoClass.name}.${field.propertyKey}.`);\n this.validateOptions(dtoClass, field, reflected);\n const options = field.options;\n if (options instanceof WpDtoMapFieldOptions) {\n const mapSchema = new ApiJsonSchema('object');\n mapSchema.description = options.description;\n mapSchema.additionalProperties = this.itemSchema(options.mapValues, parents);\n return mapSchema;\n }\n let schema: ApiJsonSchema;\n switch (reflected.name) {\n case 'String':\n schema = new ApiJsonSchema('string');\n break;\n case 'Number':\n schema = new ApiJsonSchema(options.integer ? 'integer' : 'number');\n break;\n case 'Boolean':\n schema = new ApiJsonSchema('boolean');\n break;\n case 'Array':\n if (!options.arrayItems) {\n throw new Error(\n `${dtoClass.name}.${field.propertyKey} must declare arrayItems.`,\n );\n }\n schema = new ApiJsonSchema('array');\n schema.items = this.itemSchema(options.arrayItems, parents);\n break;\n default:\n schema = this.buildAt(reflected, parents);\n }\n schema.description = options.description;\n if (options.minimum !== undefined) schema.minimum = options.minimum;\n if (options.maximum !== undefined) schema.maximum = options.maximum;\n if (options.enumValues) schema.enum = [...options.enumValues];\n if (options.mcpHeader) schema['x-mcp-header'] = options.mcpHeader.name;\n return schema;\n }\n\n private validateOptions(\n dtoClass: DtoClass,\n field: WpDtoFieldMetadata,\n reflected: DtoClass,\n ): void {\n const label = `${dtoClass.name}.${field.propertyKey}`;\n const options = field.options;\n if (options instanceof WpDtoMapFieldOptions) {\n if (reflected !== Object) {\n throw new Error(\n `${label} declares mapValues but is not a map (Record<string, V>).`,\n );\n }\n return;\n }\n if (reflected === Object) {\n throw new Error(\n `${label} has type Object: an interface or Record can never be a @WpDto. ` +\n 'For a map, use WpDtoMapFieldOptions.',\n );\n }\n if (reflected.name !== 'Array' && options.arrayItems) {\n throw new Error(`${label} declares arrayItems but is not an array.`);\n }\n if (\n reflected.name !== 'Number' &&\n (options.integer || options.minimum !== undefined || options.maximum !== undefined)\n ) {\n throw new Error(`${label} declares numeric constraints but is not a number.`);\n }\n if (\n options.minimum !== undefined &&\n options.maximum !== undefined &&\n options.minimum > options.maximum\n ) {\n throw new Error(`${label} minimum cannot exceed maximum.`);\n }\n if (options.enumValues && reflected.name !== 'String') {\n throw new Error(`${label} enumValues require a string field.`);\n }\n if (options.mcpHeader !== undefined) {\n if (!/^[!#$%&'*+\\-.^_`|~0-9A-Za-z]+$/.test(options.mcpHeader.name)) {\n throw new Error(`${label} mcpHeader must be an RFC 9110 token.`);\n }\n if (!['String', 'Number', 'Boolean'].includes(reflected.name)) {\n throw new Error(`${label} mcpHeader requires a primitive field.`);\n }\n if (reflected.name === 'Number' && !options.integer) {\n throw new Error(\n `${label} mcpHeader cannot mirror a non-integer number (MCP 2026-07-28).`,\n );\n }\n }\n }\n\n private itemSchema(item: DtoElementType, parents: Set<DtoClass>): ApiJsonSchema {\n if (typeof item !== 'string') return this.buildAt(item, parents);\n return new ApiJsonSchema(item === 'integer' ? 'integer' : item);\n }\n\n private validateMcpHeaders(schema: ApiJsonSchema, seen: Map<string, string>): void {\n const header = schema['x-mcp-header'];\n if (header) {\n const key = header.toLowerCase();\n const prior = seen.get(key);\n if (prior) {\n throw new Error(`mcpHeader '${header}' duplicates '${prior}' case-insensitively.`);\n }\n seen.set(key, header);\n }\n for (const child of Object.values(schema.properties ?? {})) {\n this.validateMcpHeaders(child, seen);\n }\n }\n\n private validateAt(\n dtoClass: DtoClass,\n value: DtoValue,\n path: string,\n ): DtoValidationFailure | undefined {\n this.requireDto(dtoClass);\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n return new DtoValidationFailure(path, `${path} must be an object`);\n }\n const fields = this.fields(dtoClass);\n const known = new Set(fields.map((field: WpDtoFieldMetadata) => field.propertyKey));\n for (const key of Object.keys(value)) {\n if (!known.has(key))\n return new DtoValidationFailure(`${path}.${key}`, `${path}.${key} is not allowed`);\n }\n for (const field of fields) {\n const fieldValue = Object.getOwnPropertyDescriptor(value, field.propertyKey)?.value;\n if (fieldValue === undefined) {\n if (field.options.required) {\n return new DtoValidationFailure(\n `${path}.${field.propertyKey}`,\n `${path}.${field.propertyKey} is required`,\n );\n }\n continue;\n }\n const failure = this.validateField(\n dtoClass,\n field,\n fieldValue,\n `${path}.${field.propertyKey}`,\n );\n if (failure) return failure;\n }\n return undefined;\n }\n\n private validateField(\n dtoClass: DtoClass,\n field: WpDtoFieldMetadata,\n value: DtoValue,\n path: string,\n ): DtoValidationFailure | undefined {\n // webpieces-disable no-any-unknown -- reflect-metadata returns an erased constructor token\n const reflected = Reflect.getMetadata(\n 'design:type',\n dtoClass.prototype,\n field.propertyKey,\n ) as DtoClass;\n const options = field.options;\n if (options instanceof WpDtoMapFieldOptions) return this.validateMap(options, value, path);\n const expected = reflected?.name;\n if (expected === 'Array') return this.validateArray(options, value, path);\n if (expected === 'String') {\n if (typeof value !== 'string')\n return new DtoValidationFailure(path, `${path} must be a string`);\n if (options.enumValues && !options.enumValues.includes(value)) {\n return new DtoValidationFailure(\n path,\n `${path} must be one of: ${options.enumValues.join(', ')}`,\n );\n }\n return undefined;\n }\n if (expected === 'Number') {\n if (typeof value !== 'number' || !Number.isFinite(value)) {\n return new DtoValidationFailure(path, `${path} must be a number`);\n }\n if (options.integer && !Number.isInteger(value)) {\n return new DtoValidationFailure(path, `${path} must be an integer`);\n }\n if (options.minimum !== undefined && value < options.minimum) {\n return new DtoValidationFailure(path, `${path} must be >= ${options.minimum}`);\n }\n if (options.maximum !== undefined && value > options.maximum) {\n return new DtoValidationFailure(path, `${path} must be <= ${options.maximum}`);\n }\n return undefined;\n }\n if (expected === 'Boolean') {\n return typeof value === 'boolean'\n ? undefined\n : new DtoValidationFailure(path, `${path} must be a boolean`);\n }\n return this.validateAt(reflected, value, path);\n }\n\n private validateArray(\n options: WpDtoFieldOptions,\n value: DtoValue,\n path: string,\n ): DtoValidationFailure | undefined {\n if (!Array.isArray(value))\n return new DtoValidationFailure(path, `${path} must be an array`);\n if (!options.arrayItems) return new DtoValidationFailure(path, `${path} has no item type`);\n for (let index = 0; index < value.length; index += 1) {\n const failure = this.validateElement(\n options.arrayItems,\n value[index],\n `${path}[${index}]`,\n );\n if (failure) return failure;\n }\n return undefined;\n }\n\n private validateMap(\n options: WpDtoMapFieldOptions,\n value: DtoValue,\n path: string,\n ): DtoValidationFailure | undefined {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n return new DtoValidationFailure(path, `${path} must be an object map`);\n }\n const prototype: object | null = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n return new DtoValidationFailure(path, `${path} must be a plain object map`);\n }\n for (const key of Object.keys(value)) {\n const entry: DtoValue = Object.getOwnPropertyDescriptor(value, key)?.value;\n const failure = this.validateElement(options.mapValues, entry, `${path}.${key}`);\n if (failure) return failure;\n }\n return undefined;\n }\n\n private validateElement(\n type: DtoElementType,\n item: DtoValue,\n path: string,\n ): DtoValidationFailure | undefined {\n if (typeof type !== 'string') return this.validateAt(type, item, path);\n const wanted = type === 'integer' ? 'number' : type;\n if (typeof item !== wanted || (type === 'integer' && !Number.isInteger(item))) {\n return new DtoValidationFailure(path, `${path} must be ${type}`);\n }\n return undefined;\n }\n\n private fields(dtoClass: DtoClass): WpDtoFieldMetadata[] {\n const fields: Record<string, WpDtoFieldMetadata> =\n Reflect.getMetadata(DTO_FIELDS, dtoClass) ?? {};\n return Object.values(fields);\n }\n\n private requireDto(dtoClass: DtoClass): void {\n if (!Reflect.getMetadata(DTO_MARKER, dtoClass)) {\n throw new Error(\n `${dtoClass.name} must be decorated with @WpDto() for schema generation.`,\n );\n }\n }\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import 'reflect-metadata';
2
+ import { JwtRequirement } from '../http/auth-mode';
3
+ /** Authorization policy for the verified MCP user principal, independent of HTTP hop auth. */
4
+ export declare class WpMcpJwtAuthMetadata {
5
+ readonly requirement: JwtRequirement;
6
+ constructor(requirement: JwtRequirement);
7
+ }
8
+ export declare function WpMcpAuthJwt(requirement: JwtRequirement): MethodDecorator;
9
+ export declare function getWpMcpAuthJwt(apiClass: Function, methodName: string): WpMcpJwtAuthMetadata | undefined;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WpMcpJwtAuthMetadata = void 0;
4
+ exports.WpMcpAuthJwt = WpMcpAuthJwt;
5
+ exports.getWpMcpAuthJwt = getWpMcpAuthJwt;
6
+ require("reflect-metadata");
7
+ const decorators_1 = require("../http/decorators");
8
+ /** Authorization policy for the verified MCP user principal, independent of HTTP hop auth. */
9
+ class WpMcpJwtAuthMetadata {
10
+ requirement;
11
+ constructor(requirement) {
12
+ this.requirement = requirement;
13
+ }
14
+ }
15
+ exports.WpMcpJwtAuthMetadata = WpMcpJwtAuthMetadata;
16
+ // webpieces-disable no-function-outside-class -- authorization decorator factory
17
+ function WpMcpAuthJwt(requirement) {
18
+ return (target, propertyKey) => {
19
+ const apiClass = target.constructor;
20
+ const methodName = String(propertyKey);
21
+ if (Reflect.hasMetadata(decorators_1.METADATA_KEYS.MCP_AUTH_JWT, apiClass, methodName)) {
22
+ throw new Error(`Only one @WpMcpAuthJwt may decorate ${apiClass.name}.${methodName}.`);
23
+ }
24
+ Reflect.defineMetadata(decorators_1.METADATA_KEYS.MCP_AUTH_JWT, new WpMcpJwtAuthMetadata(requirement), apiClass, methodName);
25
+ };
26
+ }
27
+ // webpieces-disable no-function-outside-class -- metadata reader paired with WpMcpAuthJwt
28
+ function getWpMcpAuthJwt(apiClass, methodName) {
29
+ return Reflect.getMetadata(decorators_1.METADATA_KEYS.MCP_AUTH_JWT, apiClass, methodName);
30
+ }
31
+ //# sourceMappingURL=McpAuthMetadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"McpAuthMetadata.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/mcp/McpAuthMetadata.ts"],"names":[],"mappings":";;;AAUA,oCAcC;AAGD,0CAOC;AAlCD,4BAA0B;AAE1B,mDAAmD;AAEnD,8FAA8F;AAC9F,MAAa,oBAAoB;IACD;IAA5B,YAA4B,WAA2B;QAA3B,gBAAW,GAAX,WAAW,CAAgB;IAAG,CAAC;CAC9D;AAFD,oDAEC;AAED,iFAAiF;AACjF,SAAgB,YAAY,CAAC,WAA2B;IACpD,OAAO,CAAC,MAAc,EAAE,WAA4B,EAAQ,EAAE;QAC1D,MAAM,QAAQ,GAAG,MAAM,CAAC,WAAW,CAAC;QACpC,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;QACvC,IAAI,OAAO,CAAC,WAAW,CAAC,0BAAa,CAAC,YAAY,EAAE,QAAQ,EAAE,UAAU,CAAC,EAAE,CAAC;YACxE,MAAM,IAAI,KAAK,CAAC,uCAAuC,QAAQ,CAAC,IAAI,IAAI,UAAU,GAAG,CAAC,CAAC;QAC3F,CAAC;QACD,OAAO,CAAC,cAAc,CAClB,0BAAa,CAAC,YAAY,EAC1B,IAAI,oBAAoB,CAAC,WAAW,CAAC,EACrC,QAAQ,EACR,UAAU,CACb,CAAC;IACN,CAAC,CAAC;AACN,CAAC;AAED,0FAA0F;AAC1F,SAAgB,eAAe,CAC3B,QAAkB,EAClB,UAAkB;IAElB,OAAO,OAAO,CAAC,WAAW,CAAC,0BAAa,CAAC,YAAY,EAAE,QAAQ,EAAE,UAAU,CAE5D,CAAC;AACpB,CAAC","sourcesContent":["import 'reflect-metadata';\nimport { JwtRequirement } from '../http/auth-mode';\nimport { METADATA_KEYS } from '../http/decorators';\n\n/** Authorization policy for the verified MCP user principal, independent of HTTP hop auth. */\nexport class WpMcpJwtAuthMetadata {\n constructor(public readonly requirement: JwtRequirement) {}\n}\n\n// webpieces-disable no-function-outside-class -- authorization decorator factory\nexport function WpMcpAuthJwt(requirement: JwtRequirement): MethodDecorator {\n return (target: object, propertyKey: string | symbol): void => {\n const apiClass = target.constructor;\n const methodName = String(propertyKey);\n if (Reflect.hasMetadata(METADATA_KEYS.MCP_AUTH_JWT, apiClass, methodName)) {\n throw new Error(`Only one @WpMcpAuthJwt may decorate ${apiClass.name}.${methodName}.`);\n }\n Reflect.defineMetadata(\n METADATA_KEYS.MCP_AUTH_JWT,\n new WpMcpJwtAuthMetadata(requirement),\n apiClass,\n methodName,\n );\n };\n}\n\n// webpieces-disable no-function-outside-class -- metadata reader paired with WpMcpAuthJwt\nexport function getWpMcpAuthJwt(\n apiClass: Function,\n methodName: string,\n): WpMcpJwtAuthMetadata | undefined {\n return Reflect.getMetadata(METADATA_KEYS.MCP_AUTH_JWT, apiClass, methodName) as\n | WpMcpJwtAuthMetadata\n | undefined;\n}\n"]}
@@ -11,7 +11,7 @@ const invalidMapValue = new DtoSchema_1.WpDtoMapFieldOptions('invalid map', true
11
11
  // @ts-expect-error a map value type is mandatory: it is the whole point of WpDtoMapFieldOptions
12
12
  const missingMapValue = new DtoSchema_1.WpDtoMapFieldOptions('invalid map', true);
13
13
  const noEighthFieldArgument = new DtoSchema_1.WpDtoFieldOptions('maps are not a WpDtoFieldOptions argument', false, undefined, false, undefined, undefined, undefined,
14
- // @ts-expect-error maps use WpDtoMapFieldOptions, never an 8th positional argument
14
+ // @ts-expect-error maps use WpDtoMapFieldOptions; the 8th argument is only a WpMcpHeader
15
15
  'string');
16
16
  class InvalidMcpContract {
17
17
  // @ts-expect-error read-only tools cannot also claim to be destructive
@@ -1 +1 @@
1
- {"version":3,"file":"McpCompileAssertions.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/mcp/McpCompileAssertions.ts"],"names":[],"mappings":";;;AAAA,+CAA0C;AAC1C,2CAAsE;AAEtE,MAAM,gBAAgB,GAAG,IAAI,6BAAiB,CAC1C,cAAc,EACd,IAAI,EACJ,SAAS,EACT,KAAK,EACL,SAAS,EACT,SAAS;AACT,uEAAuE;AACvE,EAAE,CACL,CAAC;AAEF,0EAA0E;AAC1E,MAAM,eAAe,GAAG,IAAI,gCAAoB,CAAC,aAAa,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAE9E,gGAAgG;AAChG,MAAM,eAAe,GAAG,IAAI,gCAAoB,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;AAEtE,MAAM,qBAAqB,GAAG,IAAI,6BAAiB,CAC/C,2CAA2C,EAC3C,KAAK,EACL,SAAS,EACT,KAAK,EACL,SAAS,EACT,SAAS,EACT,SAAS;AACT,mFAAmF;AACnF,QAAQ,CACX,CAAC;AAEF,MAAe,kBAAkB;IAC7B,uEAAuE;IASvE,OAAO;QACH,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;IACrC,CAAC;CACJ;AAHG;IARC,IAAA,uBAAS,EAAC;QACP,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,sCAAsC;QACnD,YAAY,EAAE,IAAI;QAClB,eAAe,EAAE,IAAI;QACrB,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,KAAK;KACvB,CAAC;;;;iDAGD;AAGL,MAAe,iBAAiB;IAC5B,6DAA6D;IAQ7D,IAAI;QACA,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;IACrC,CAAC;IAED,6DAA6D;IAQ7D,KAAK,CAAC,MAAc,EAAE,OAAe;QACjC,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;IACrC,CAAC;CACJ;AAfG;IAPC,IAAA,uBAAS,EAAC;QACP,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE,sCAAsC;QACnD,YAAY,EAAE,IAAI;QAClB,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,KAAK;KACvB,CAAC;;;;6CAGD;AAUD;IAPC,IAAA,uBAAS,EAAC;QACP,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE,sCAAsC;QACnD,YAAY,EAAE,IAAI;QAClB,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,KAAK;KACvB,CAAC;;;;8CAGD;AAGL,KAAK,kBAAkB,CAAC;AACxB,KAAK,iBAAiB,CAAC;AACvB,KAAK,gBAAgB,CAAC;AACtB,KAAK,eAAe,CAAC;AACrB,KAAK,eAAe,CAAC;AACrB,KAAK,qBAAqB,CAAC","sourcesContent":["import { WpMcpTool } from './McpMetadata';\nimport { WpDtoFieldOptions, WpDtoMapFieldOptions } from './DtoSchema';\n\nconst invalidEmptyEnum = new WpDtoFieldOptions(\n 'invalid enum',\n true,\n undefined,\n false,\n undefined,\n undefined,\n // @ts-expect-error enumValues must contain at least one allowed string\n [],\n);\n\n// @ts-expect-error a map's value type must be a scalar name or a DtoClass\nconst invalidMapValue = new WpDtoMapFieldOptions('invalid map', true, 'date');\n\n// @ts-expect-error a map value type is mandatory: it is the whole point of WpDtoMapFieldOptions\nconst missingMapValue = new WpDtoMapFieldOptions('invalid map', true);\n\nconst noEighthFieldArgument = new WpDtoFieldOptions(\n 'maps are not a WpDtoFieldOptions argument',\n false,\n undefined,\n false,\n undefined,\n undefined,\n undefined,\n // @ts-expect-error maps use WpDtoMapFieldOptions, never an 8th positional argument\n 'string',\n);\n\nabstract class InvalidMcpContract {\n // @ts-expect-error read-only tools cannot also claim to be destructive\n @WpMcpTool({\n name: 'invalid',\n description: 'This declaration must never compile.',\n readOnlyHint: true,\n destructiveHint: true,\n idempotentHint: true,\n openWorldHint: false,\n })\n invalid(): Promise<void> {\n throw new Error('contract only');\n }\n}\n\nabstract class InvalidMcpArities {\n // @ts-expect-error MCP tools require exactly one request DTO\n @WpMcpTool({\n name: 'zero-arity',\n description: 'This declaration must never compile.',\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n })\n zero(): Promise<object> {\n throw new Error('contract only');\n }\n\n // @ts-expect-error MCP tools require exactly one request DTO\n @WpMcpTool({\n name: 'multi-arity',\n description: 'This declaration must never compile.',\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n })\n multi(_first: object, _second: object): Promise<object> {\n throw new Error('contract only');\n }\n}\n\nvoid InvalidMcpContract;\nvoid InvalidMcpArities;\nvoid invalidEmptyEnum;\nvoid invalidMapValue;\nvoid missingMapValue;\nvoid noEighthFieldArgument;\n"]}
1
+ {"version":3,"file":"McpCompileAssertions.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/mcp/McpCompileAssertions.ts"],"names":[],"mappings":";;;AAAA,+CAA0C;AAC1C,2CAAsE;AAEtE,MAAM,gBAAgB,GAAG,IAAI,6BAAiB,CAC1C,cAAc,EACd,IAAI,EACJ,SAAS,EACT,KAAK,EACL,SAAS,EACT,SAAS;AACT,uEAAuE;AACvE,EAAE,CACL,CAAC;AAEF,0EAA0E;AAC1E,MAAM,eAAe,GAAG,IAAI,gCAAoB,CAAC,aAAa,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAE9E,gGAAgG;AAChG,MAAM,eAAe,GAAG,IAAI,gCAAoB,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;AAEtE,MAAM,qBAAqB,GAAG,IAAI,6BAAiB,CAC/C,2CAA2C,EAC3C,KAAK,EACL,SAAS,EACT,KAAK,EACL,SAAS,EACT,SAAS,EACT,SAAS;AACT,yFAAyF;AACzF,QAAQ,CACX,CAAC;AAEF,MAAe,kBAAkB;IAC7B,uEAAuE;IASvE,OAAO;QACH,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;IACrC,CAAC;CACJ;AAHG;IARC,IAAA,uBAAS,EAAC;QACP,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,sCAAsC;QACnD,YAAY,EAAE,IAAI;QAClB,eAAe,EAAE,IAAI;QACrB,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,KAAK;KACvB,CAAC;;;;iDAGD;AAGL,MAAe,iBAAiB;IAC5B,6DAA6D;IAQ7D,IAAI;QACA,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;IACrC,CAAC;IAED,6DAA6D;IAQ7D,KAAK,CAAC,MAAc,EAAE,OAAe;QACjC,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;IACrC,CAAC;CACJ;AAfG;IAPC,IAAA,uBAAS,EAAC;QACP,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE,sCAAsC;QACnD,YAAY,EAAE,IAAI;QAClB,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,KAAK;KACvB,CAAC;;;;6CAGD;AAUD;IAPC,IAAA,uBAAS,EAAC;QACP,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE,sCAAsC;QACnD,YAAY,EAAE,IAAI;QAClB,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,KAAK;KACvB,CAAC;;;;8CAGD;AAGL,KAAK,kBAAkB,CAAC;AACxB,KAAK,iBAAiB,CAAC;AACvB,KAAK,gBAAgB,CAAC;AACtB,KAAK,eAAe,CAAC;AACrB,KAAK,eAAe,CAAC;AACrB,KAAK,qBAAqB,CAAC","sourcesContent":["import { WpMcpTool } from './McpMetadata';\nimport { WpDtoFieldOptions, WpDtoMapFieldOptions } from './DtoSchema';\n\nconst invalidEmptyEnum = new WpDtoFieldOptions(\n 'invalid enum',\n true,\n undefined,\n false,\n undefined,\n undefined,\n // @ts-expect-error enumValues must contain at least one allowed string\n [],\n);\n\n// @ts-expect-error a map's value type must be a scalar name or a DtoClass\nconst invalidMapValue = new WpDtoMapFieldOptions('invalid map', true, 'date');\n\n// @ts-expect-error a map value type is mandatory: it is the whole point of WpDtoMapFieldOptions\nconst missingMapValue = new WpDtoMapFieldOptions('invalid map', true);\n\nconst noEighthFieldArgument = new WpDtoFieldOptions(\n 'maps are not a WpDtoFieldOptions argument',\n false,\n undefined,\n false,\n undefined,\n undefined,\n undefined,\n // @ts-expect-error maps use WpDtoMapFieldOptions; the 8th argument is only a WpMcpHeader\n 'string',\n);\n\nabstract class InvalidMcpContract {\n // @ts-expect-error read-only tools cannot also claim to be destructive\n @WpMcpTool({\n name: 'invalid',\n description: 'This declaration must never compile.',\n readOnlyHint: true,\n destructiveHint: true,\n idempotentHint: true,\n openWorldHint: false,\n })\n invalid(): Promise<void> {\n throw new Error('contract only');\n }\n}\n\nabstract class InvalidMcpArities {\n // @ts-expect-error MCP tools require exactly one request DTO\n @WpMcpTool({\n name: 'zero-arity',\n description: 'This declaration must never compile.',\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n })\n zero(): Promise<object> {\n throw new Error('contract only');\n }\n\n // @ts-expect-error MCP tools require exactly one request DTO\n @WpMcpTool({\n name: 'multi-arity',\n description: 'This declaration must never compile.',\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n })\n multi(_first: object, _second: object): Promise<object> {\n throw new Error('contract only');\n }\n}\n\nvoid InvalidMcpContract;\nvoid InvalidMcpArities;\nvoid invalidEmptyEnum;\nvoid invalidMapValue;\nvoid missingMapValue;\nvoid noEighthFieldArgument;\n"]}