@webpieces/core-util 0.4.771 → 0.4.773

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webpieces/core-util",
3
- "version": "0.4.771",
3
+ "version": "0.4.773",
4
4
  "description": "Utility functions for WebPieces - works in browser and Node.js",
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
package/src/index.d.ts CHANGED
@@ -28,8 +28,8 @@ export type { ContractHttpMethod, EndpointResponseType, HttpParameterSource, Htt
28
28
  export type { EndpointKind, EndpointOptions, ExternalEndpointOptions } from './http/decorators';
29
29
  export { WpMcpTool, WpMcpToolHints, WpMcpToolMetadata, getWpMcpTools } from './mcp/McpMetadata';
30
30
  export type { WpMcpMethodDecorator, WpMcpToolOptions } from './mcp/McpMetadata';
31
- export { WpDto, WpDtoField, WpDtoFieldOptions, WpDtoFieldMetadata, WpResponseDto, ApiJsonSchema, DtoValidationFailure, DtoSchemaBuilder, } from './mcp/DtoSchema';
32
- export type { DtoClass, DtoArrayItem, DtoValue } from './mcp/DtoSchema';
31
+ export { WpDto, WpDtoField, WpDtoFieldOptions, WpDtoMapFieldOptions, WpDtoFieldMetadata, WpResponseDto, ApiJsonSchema, DtoValidationFailure, DtoSchemaBuilder, } from './mcp/DtoSchema';
32
+ export type { DtoClass, DtoElementType, DtoValue } from './mcp/DtoSchema';
33
33
  export { AuthMeta } from './http/auth-mode';
34
34
  export type { AuthMode, ApiKeyCredential, ApiKeyCredentials, JwtRoles, JwtRequirement, } from './http/auth-mode';
35
35
  export { Rpc, PubSub, Queue, ENDPOINT_KINDS_BY_API_KIND, getApiKind, assertApiKind, assertPubSubConventions, getQueueName, } from './http/api-kind';
package/src/index.js CHANGED
@@ -9,9 +9,9 @@
9
9
  */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
11
  exports.getIpcEndpoints = exports.getIpcApiId = exports.isInternalApi = exports.WpIpcEndpoint = exports.WpInternal = exports.getHttpParameterDeclarations = exports.QueryParam = exports.PathParam = exports.METADATA_KEYS = exports.validateNoConflictingDecorators = exports.assertEveryWebhookEndpointRetainsRawBody = exports.assertEveryExternalEndpointDeclaresCaller = exports.assertEveryEndpointHasAuthMode = exports.getAuthMode = exports.getAuthMeta = exports.isApiPath = exports.isRawBody = exports.isFormPost = exports.getMaskSpec = exports.getEndpointKinds = exports.getEndpointKind = exports.getEndpointOptions = exports.getEndpoints = exports.getApiPath = exports.MaskLog = exports.WpAuthLocalOnly = exports.WpAuthApiKey = exports.WpAuthWebhook = exports.WpAuthSharedSecret = exports.WpAuthOidc = exports.MISSING_AUTH_DECORATOR_FIX = exports.rolesRequired = exports.WpAuthJwt = exports.WpAuthPublic = exports.Endpoint = exports.ApiPath = exports.GCP_LOG_BUDGET_BYTES = exports.MAX_GCP_LOG_BYTES = exports.LogChunkInfo = exports.LogChunkerImpl = exports.LogChunker = exports.LogManager = exports.ConsoleLoggerFactory = exports.ConsoleLogger = exports.DESIGN_METADATA_KEYS = exports.isDocumentDesign = exports.DocumentDesign = exports.ContextTuple = exports.ContextKey = exports.toError = void 0;
12
- exports.DateUtil = exports.InstantUtil = exports.NetworkRejectClassifier = exports.NO_REG_CODE = exports.WRONG_COMPANY = exports.WRONG_DOMAIN = exports.EMAIL_NOT_CONFIRMED = exports.NOT_APPROVED = exports.WRONG_LOGIN = exports.WRONG_LOGIN_TYPE = exports.ENTITY_NOT_FOUND = exports.SECRETS = exports.Secrets = exports.getEndpointCaller = exports.isExternalSystemKind = exports.ExternalCaller = exports.DEFAULT_CALLER_KIND = exports.EXTERNAL_SYSTEM_KINDS = exports.getQueueName = exports.assertPubSubConventions = exports.assertApiKind = exports.getApiKind = exports.ENDPOINT_KINDS_BY_API_KIND = exports.Queue = exports.PubSub = exports.Rpc = exports.AuthMeta = exports.DtoSchemaBuilder = exports.DtoValidationFailure = exports.ApiJsonSchema = exports.WpResponseDto = exports.WpDtoFieldMetadata = exports.WpDtoFieldOptions = exports.WpDtoField = exports.WpDto = exports.getWpMcpTools = exports.WpMcpToolMetadata = exports.WpMcpToolHints = exports.WpMcpTool = exports.HttpParameterDeclaration = exports.HttpParameterBinding = exports.HttpContractMapper = exports.BoundHttpRequest = exports.RouteMetadataFactory = exports.RouteMetadata = exports.IPC_METADATA_KEYS = exports.assertNotInternalApi = exports.assertInternalApi = exports.getIpcMaskSpec = exports.getIpcEndpointKind = void 0;
13
- exports.ApiUnauthorizedError = exports.ApiBadRequestError = exports.ApiEndUserError = exports.ApiRequestTimeoutError = exports.ApiForbiddenError = exports.ApiRateLimitedError = exports.ApiImplementationError = exports.ApiDependencyTimeoutError = exports.ApiUnavailableError = exports.ApiDependencyError = exports.ApiNotFoundError = exports.ApiError = exports.FilterChain = exports.Filter = exports.SerializedError = exports.SerializedMap = exports.RecordSerializer = exports.getDoNotRecordFields = exports.DoNotRecord = exports.RecordedTestCase = exports.RecordedError = exports.RecordedEndpoint = exports.RecorderKeys = exports.ApiMethodInfo = exports.LOG_API_CALL_LOGGER_NAME = exports.ApiCallLogNameImpl = exports.ApiCallLogName = exports.ApiCallInfo = exports.MaskSpec = exports.LogApiCallImpl = exports.ContextMgr = exports.DestinationTrust = exports.WebpiecesCoreHeaders = exports.templateDeriver = exports.WEBPIECES_DEFAULT_FAILURE_CLASSIFIER = exports.WebpiecesDefaultFailureClassifier = exports.KeyedFailureClassifier = exports.HttpResponseDto = exports.HttpResponseStatus = exports.HttpHeader = exports.RuntimeLocality = exports.ServiceInfo = exports.ApiCallTimeoutError = exports.CallContext = exports.CallDeadline = exports.CallRegistry = exports.ClientRegistry = exports.HeaderRegistry = exports.DateTimeUtil = exports.TimeUtil = void 0;
14
- exports.ApiErrorHttpStatus = exports.ApiErrorPayload = exports.ApiErrorCodec = exports.ApiEndpointNotFoundError = exports.ApiConnectionError = exports.ApiDependencyBackoffError = void 0;
12
+ exports.InstantUtil = exports.NetworkRejectClassifier = exports.NO_REG_CODE = exports.WRONG_COMPANY = exports.WRONG_DOMAIN = exports.EMAIL_NOT_CONFIRMED = exports.NOT_APPROVED = exports.WRONG_LOGIN = exports.WRONG_LOGIN_TYPE = exports.ENTITY_NOT_FOUND = exports.SECRETS = exports.Secrets = exports.getEndpointCaller = exports.isExternalSystemKind = exports.ExternalCaller = exports.DEFAULT_CALLER_KIND = exports.EXTERNAL_SYSTEM_KINDS = exports.getQueueName = exports.assertPubSubConventions = exports.assertApiKind = exports.getApiKind = exports.ENDPOINT_KINDS_BY_API_KIND = exports.Queue = exports.PubSub = exports.Rpc = exports.AuthMeta = exports.DtoSchemaBuilder = exports.DtoValidationFailure = exports.ApiJsonSchema = exports.WpResponseDto = exports.WpDtoFieldMetadata = exports.WpDtoMapFieldOptions = exports.WpDtoFieldOptions = exports.WpDtoField = exports.WpDto = exports.getWpMcpTools = exports.WpMcpToolMetadata = exports.WpMcpToolHints = exports.WpMcpTool = exports.HttpParameterDeclaration = exports.HttpParameterBinding = exports.HttpContractMapper = exports.BoundHttpRequest = exports.RouteMetadataFactory = exports.RouteMetadata = exports.IPC_METADATA_KEYS = exports.assertNotInternalApi = exports.assertInternalApi = exports.getIpcMaskSpec = exports.getIpcEndpointKind = void 0;
13
+ exports.ApiBadRequestError = exports.ApiEndUserError = exports.ApiRequestTimeoutError = exports.ApiForbiddenError = exports.ApiRateLimitedError = exports.ApiImplementationError = exports.ApiDependencyTimeoutError = exports.ApiUnavailableError = exports.ApiDependencyError = exports.ApiNotFoundError = exports.ApiError = exports.FilterChain = exports.Filter = exports.SerializedError = exports.SerializedMap = exports.RecordSerializer = exports.getDoNotRecordFields = exports.DoNotRecord = exports.RecordedTestCase = exports.RecordedError = exports.RecordedEndpoint = exports.RecorderKeys = exports.ApiMethodInfo = exports.LOG_API_CALL_LOGGER_NAME = exports.ApiCallLogNameImpl = exports.ApiCallLogName = exports.ApiCallInfo = exports.MaskSpec = exports.LogApiCallImpl = exports.ContextMgr = exports.DestinationTrust = exports.WebpiecesCoreHeaders = exports.templateDeriver = exports.WEBPIECES_DEFAULT_FAILURE_CLASSIFIER = exports.WebpiecesDefaultFailureClassifier = exports.KeyedFailureClassifier = exports.HttpResponseDto = exports.HttpResponseStatus = exports.HttpHeader = exports.RuntimeLocality = exports.ServiceInfo = exports.ApiCallTimeoutError = exports.CallContext = exports.CallDeadline = exports.CallRegistry = exports.ClientRegistry = exports.HeaderRegistry = exports.DateTimeUtil = exports.TimeUtil = exports.DateUtil = void 0;
14
+ exports.ApiErrorHttpStatus = exports.ApiErrorPayload = exports.ApiErrorCodec = exports.ApiEndpointNotFoundError = exports.ApiConnectionError = exports.ApiDependencyBackoffError = exports.ApiUnauthorizedError = void 0;
15
15
  var errorUtils_1 = require("./lib/errorUtils");
16
16
  Object.defineProperty(exports, "toError", { enumerable: true, get: function () { return errorUtils_1.toError; } });
17
17
  var ContextKey_1 = require("./ContextKey");
@@ -107,6 +107,7 @@ var DtoSchema_1 = require("./mcp/DtoSchema");
107
107
  Object.defineProperty(exports, "WpDto", { enumerable: true, get: function () { return DtoSchema_1.WpDto; } });
108
108
  Object.defineProperty(exports, "WpDtoField", { enumerable: true, get: function () { return DtoSchema_1.WpDtoField; } });
109
109
  Object.defineProperty(exports, "WpDtoFieldOptions", { enumerable: true, get: function () { return DtoSchema_1.WpDtoFieldOptions; } });
110
+ Object.defineProperty(exports, "WpDtoMapFieldOptions", { enumerable: true, get: function () { return DtoSchema_1.WpDtoMapFieldOptions; } });
110
111
  Object.defineProperty(exports, "WpDtoFieldMetadata", { enumerable: true, get: function () { return DtoSchema_1.WpDtoFieldMetadata; } });
111
112
  Object.defineProperty(exports, "WpResponseDto", { enumerable: true, get: function () { return DtoSchema_1.WpResponseDto; } });
112
113
  Object.defineProperty(exports, "ApiJsonSchema", { enumerable: true, get: function () { return DtoSchema_1.ApiJsonSchema; } });
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/core/core-util/src/index.ts"],"names":[],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AAgG;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 WpDtoFieldMetadata,\n WpResponseDto,\n ApiJsonSchema,\n DtoValidationFailure,\n DtoSchemaBuilder,\n} from './mcp/DtoSchema';\nexport type { DtoClass, DtoArrayItem, 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"],"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,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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,6 +1,7 @@
1
1
  import 'reflect-metadata';
2
2
  export type DtoClass = abstract new (...args: any[]) => unknown;
3
- export type DtoArrayItem = 'string' | 'number' | 'integer' | 'boolean' | DtoClass;
3
+ /** The element type of an array or the value type of a map; TypeScript erases both at runtime. */
4
+ export type DtoElementType = 'string' | 'number' | 'integer' | 'boolean' | DtoClass;
4
5
  /** Runtime values accepted at the DTO validation boundary. */
5
6
  export type DtoValue = object | string | number | boolean | null;
6
7
  /** Additive field metadata; the scalar/object type itself comes from `design:type`. */
@@ -9,7 +10,7 @@ export declare class WpDtoFieldOptions {
9
10
  /** Required/optional is explicit because TypeScript erases `?` at runtime. */
10
11
  readonly required: boolean;
11
12
  /** Required for arrays because TypeScript erases their element type. */
12
- readonly arrayItems?: DtoArrayItem | undefined;
13
+ readonly arrayItems?: DtoElementType | undefined;
13
14
  /** A reflected Number is otherwise emitted as JSON Schema `number`. */
14
15
  readonly integer: boolean;
15
16
  readonly minimum?: number | undefined;
@@ -19,14 +20,28 @@ export declare class WpDtoFieldOptions {
19
20
  /** Required/optional is explicit because TypeScript erases `?` at runtime. */
20
21
  required: boolean,
21
22
  /** Required for arrays because TypeScript erases their element type. */
22
- arrayItems?: DtoArrayItem | undefined,
23
+ arrayItems?: DtoElementType | undefined,
23
24
  /** A reflected Number is otherwise emitted as JSON Schema `number`. */
24
25
  integer?: boolean, minimum?: number | undefined, maximum?: number | undefined, enumValues?: readonly [string, ...string[]] | undefined);
25
26
  }
27
+ /**
28
+ * Field metadata for a typed map such as `Record<string, string>` or `Record<string, SomeDto>`.
29
+ * Keys are open strings; every VALUE must match `mapValues`. The value type is explicit for the same
30
+ * reason `arrayItems` is: TypeScript erases it, and a `Record` reflects as plain `Object`.
31
+ */
32
+ export declare class WpDtoMapFieldOptions {
33
+ readonly description: string;
34
+ /** Required/optional is explicit because TypeScript erases `?` at runtime. */
35
+ readonly required: boolean;
36
+ readonly mapValues: DtoElementType;
37
+ constructor(description: string,
38
+ /** Required/optional is explicit because TypeScript erases `?` at runtime. */
39
+ required: boolean, mapValues: DtoElementType);
40
+ }
26
41
  export declare class WpDtoFieldMetadata {
27
42
  readonly propertyKey: string;
28
- readonly options: WpDtoFieldOptions;
29
- constructor(propertyKey: string, options: WpDtoFieldOptions);
43
+ readonly options: WpDtoFieldOptions | WpDtoMapFieldOptions;
44
+ constructor(propertyKey: string, options: WpDtoFieldOptions | WpDtoMapFieldOptions);
30
45
  }
31
46
  /** The JSON Schema subset emitted for Webpieces API DTOs. */
32
47
  export declare class ApiJsonSchema {
@@ -34,7 +49,8 @@ export declare class ApiJsonSchema {
34
49
  description?: string;
35
50
  properties?: Record<string, ApiJsonSchema>;
36
51
  required?: string[];
37
- additionalProperties?: boolean;
52
+ /** `false` closes an object; a schema makes it a typed map whose values all match that schema. */
53
+ additionalProperties?: boolean | ApiJsonSchema;
38
54
  items?: ApiJsonSchema;
39
55
  enum?: string[];
40
56
  minimum?: number;
@@ -49,13 +65,20 @@ export declare class DtoValidationFailure {
49
65
  /** Marks a request/response class as a schema-bearing DTO, including intentionally empty DTOs. */
50
66
  export declare function WpDto(): ClassDecorator;
51
67
  /** Adds documentation and runtime-only shape facts to a DTO property. */
52
- export declare function WpDtoField(options: WpDtoFieldOptions): PropertyDecorator;
68
+ export declare function WpDtoField(options: WpDtoFieldOptions | WpDtoMapFieldOptions): PropertyDecorator;
53
69
  /** Declares an async API method's response DTO because reflection sees Promise, not its generic. */
54
70
  export declare function WpResponseDto(responseDto: () => DtoClass): MethodDecorator;
55
71
  /** Builds and validates the same DTO schema used for MCP input and structured output. */
56
72
  export declare class DtoSchemaBuilder {
57
73
  requestClassOf(apiClass: Function, methodName: string): DtoClass;
58
74
  responseClassOf(apiClass: Function, methodName: string): DtoClass;
75
+ /**
76
+ * The one closure gate for an object schema. Closed means no key can carry an unspecified value:
77
+ * either extra keys are forbidden (`additionalProperties: false`) or every extra key's value is
78
+ * typed (`additionalProperties: <schema>`, a typed map). A missing or `true` value is open.
79
+ * Use this instead of `schema.additionalProperties === false`, which rejects typed maps.
80
+ */
81
+ isClosedSchema(schema: ApiJsonSchema): boolean;
59
82
  build(dtoClass: DtoClass): ApiJsonSchema;
60
83
  validate(dtoClass: DtoClass, value: DtoValue): DtoValidationFailure | undefined;
61
84
  private buildAt;
@@ -65,6 +88,8 @@ export declare class DtoSchemaBuilder {
65
88
  private validateAt;
66
89
  private validateField;
67
90
  private validateArray;
91
+ private validateMap;
92
+ private validateElement;
68
93
  private fields;
69
94
  private requireDto;
70
95
  }
@@ -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.WpDtoFieldOptions = void 0;
3
+ exports.DtoSchemaBuilder = exports.DtoValidationFailure = exports.ApiJsonSchema = exports.WpDtoFieldMetadata = exports.WpDtoMapFieldOptions = exports.WpDtoFieldOptions = void 0;
4
4
  exports.WpDto = WpDto;
5
5
  exports.WpDtoField = WpDtoField;
6
6
  exports.WpResponseDto = WpResponseDto;
@@ -34,6 +34,24 @@ class WpDtoFieldOptions {
34
34
  }
35
35
  }
36
36
  exports.WpDtoFieldOptions = WpDtoFieldOptions;
37
+ /**
38
+ * Field metadata for a typed map such as `Record<string, string>` or `Record<string, SomeDto>`.
39
+ * Keys are open strings; every VALUE must match `mapValues`. The value type is explicit for the same
40
+ * reason `arrayItems` is: TypeScript erases it, and a `Record` reflects as plain `Object`.
41
+ */
42
+ class WpDtoMapFieldOptions {
43
+ description;
44
+ required;
45
+ mapValues;
46
+ constructor(description,
47
+ /** Required/optional is explicit because TypeScript erases `?` at runtime. */
48
+ required, mapValues) {
49
+ this.description = description;
50
+ this.required = required;
51
+ this.mapValues = mapValues;
52
+ }
53
+ }
54
+ exports.WpDtoMapFieldOptions = WpDtoMapFieldOptions;
37
55
  class WpDtoFieldMetadata {
38
56
  propertyKey;
39
57
  options;
@@ -49,6 +67,7 @@ class ApiJsonSchema {
49
67
  description;
50
68
  properties;
51
69
  required;
70
+ /** `false` closes an object; a schema makes it a typed map whose values all match that schema. */
52
71
  additionalProperties;
53
72
  items;
54
73
  enum;
@@ -114,6 +133,16 @@ class DtoSchemaBuilder {
114
133
  }
115
134
  return response();
116
135
  }
136
+ /**
137
+ * The one closure gate for an object schema. Closed means no key can carry an unspecified value:
138
+ * either extra keys are forbidden (`additionalProperties: false`) or every extra key's value is
139
+ * typed (`additionalProperties: <schema>`, a typed map). A missing or `true` value is open.
140
+ * Use this instead of `schema.additionalProperties === false`, which rejects typed maps.
141
+ */
142
+ isClosedSchema(schema) {
143
+ const extra = schema.additionalProperties;
144
+ return extra === false || (typeof extra === 'object' && extra !== null);
145
+ }
117
146
  build(dtoClass) {
118
147
  return this.buildAt(dtoClass, new Set());
119
148
  }
@@ -145,8 +174,14 @@ class DtoSchemaBuilder {
145
174
  const reflected = Reflect.getMetadata('design:type', dtoClass.prototype, field.propertyKey);
146
175
  if (!reflected)
147
176
  throw new Error(`No reflected type for ${dtoClass.name}.${field.propertyKey}.`);
148
- const options = field.options;
149
177
  this.validateOptions(dtoClass, field, reflected);
178
+ const options = field.options;
179
+ if (options instanceof WpDtoMapFieldOptions) {
180
+ const mapSchema = new ApiJsonSchema('object');
181
+ mapSchema.description = options.description;
182
+ mapSchema.additionalProperties = this.itemSchema(options.mapValues, parents);
183
+ return mapSchema;
184
+ }
150
185
  let schema;
151
186
  switch (reflected.name) {
152
187
  case 'String':
@@ -180,6 +215,16 @@ class DtoSchemaBuilder {
180
215
  validateOptions(dtoClass, field, reflected) {
181
216
  const label = `${dtoClass.name}.${field.propertyKey}`;
182
217
  const options = field.options;
218
+ if (options instanceof WpDtoMapFieldOptions) {
219
+ if (reflected !== Object) {
220
+ throw new Error(`${label} declares mapValues but is not a map (Record<string, V>).`);
221
+ }
222
+ return;
223
+ }
224
+ if (reflected === Object) {
225
+ throw new Error(`${label} has type Object: an interface or Record can never be a @WpDto. ` +
226
+ 'For a map, use WpDtoMapFieldOptions.');
227
+ }
183
228
  if (reflected.name !== 'Array' && options.arrayItems) {
184
229
  throw new Error(`${label} declares arrayItems but is not an array.`);
185
230
  }
@@ -227,14 +272,17 @@ class DtoSchemaBuilder {
227
272
  validateField(dtoClass, field, value, path) {
228
273
  // webpieces-disable no-any-unknown -- reflect-metadata returns an erased constructor token
229
274
  const reflected = Reflect.getMetadata('design:type', dtoClass.prototype, field.propertyKey);
275
+ const options = field.options;
276
+ if (options instanceof WpDtoMapFieldOptions)
277
+ return this.validateMap(options, value, path);
230
278
  const expected = reflected?.name;
231
279
  if (expected === 'Array')
232
- return this.validateArray(field.options, value, path);
280
+ return this.validateArray(options, value, path);
233
281
  if (expected === 'String') {
234
282
  if (typeof value !== 'string')
235
283
  return new DtoValidationFailure(`${path} must be a string`);
236
- if (field.options.enumValues && !field.options.enumValues.includes(value)) {
237
- return new DtoValidationFailure(`${path} must be one of: ${field.options.enumValues.join(', ')}`);
284
+ if (options.enumValues && !options.enumValues.includes(value)) {
285
+ return new DtoValidationFailure(`${path} must be one of: ${options.enumValues.join(', ')}`);
238
286
  }
239
287
  return undefined;
240
288
  }
@@ -242,14 +290,14 @@ class DtoSchemaBuilder {
242
290
  if (typeof value !== 'number' || !Number.isFinite(value)) {
243
291
  return new DtoValidationFailure(`${path} must be a number`);
244
292
  }
245
- if (field.options.integer && !Number.isInteger(value)) {
293
+ if (options.integer && !Number.isInteger(value)) {
246
294
  return new DtoValidationFailure(`${path} must be an integer`);
247
295
  }
248
- if (field.options.minimum !== undefined && value < field.options.minimum) {
249
- return new DtoValidationFailure(`${path} must be >= ${field.options.minimum}`);
296
+ if (options.minimum !== undefined && value < options.minimum) {
297
+ return new DtoValidationFailure(`${path} must be >= ${options.minimum}`);
250
298
  }
251
- if (field.options.maximum !== undefined && value > field.options.maximum) {
252
- return new DtoValidationFailure(`${path} must be <= ${field.options.maximum}`);
299
+ if (options.maximum !== undefined && value > options.maximum) {
300
+ return new DtoValidationFailure(`${path} must be <= ${options.maximum}`);
253
301
  }
254
302
  return undefined;
255
303
  }
@@ -266,17 +314,34 @@ class DtoSchemaBuilder {
266
314
  if (!options.arrayItems)
267
315
  return new DtoValidationFailure(`${path} has no item type`);
268
316
  for (let index = 0; index < value.length; index += 1) {
269
- const item = value[index];
270
- if (typeof options.arrayItems !== 'string') {
271
- const nested = this.validateAt(options.arrayItems, item, `${path}[${index}]`);
272
- if (nested)
273
- return nested;
274
- continue;
275
- }
276
- const wanted = options.arrayItems === 'integer' ? 'number' : options.arrayItems;
277
- if (typeof item !== wanted || (options.arrayItems === 'integer' && !Number.isInteger(item))) {
278
- return new DtoValidationFailure(`${path}[${index}] must be ${options.arrayItems}`);
279
- }
317
+ const failure = this.validateElement(options.arrayItems, value[index], `${path}[${index}]`);
318
+ if (failure)
319
+ return failure;
320
+ }
321
+ return undefined;
322
+ }
323
+ validateMap(options, value, path) {
324
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
325
+ return new DtoValidationFailure(`${path} must be an object map`);
326
+ }
327
+ const prototype = Object.getPrototypeOf(value);
328
+ if (prototype !== Object.prototype && prototype !== null) {
329
+ return new DtoValidationFailure(`${path} must be a plain object map`);
330
+ }
331
+ for (const key of Object.keys(value)) {
332
+ const entry = Object.getOwnPropertyDescriptor(value, key)?.value;
333
+ const failure = this.validateElement(options.mapValues, entry, `${path}.${key}`);
334
+ if (failure)
335
+ return failure;
336
+ }
337
+ return undefined;
338
+ }
339
+ validateElement(type, item, path) {
340
+ if (typeof type !== 'string')
341
+ return this.validateAt(type, item, path);
342
+ const wanted = type === 'integer' ? 'number' : type;
343
+ if (typeof item !== wanted || (type === 'integer' && !Number.isInteger(item))) {
344
+ return new DtoValidationFailure(`${path} must be ${type}`);
280
345
  }
281
346
  return undefined;
282
347
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DtoSchema.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/mcp/DtoSchema.ts"],"names":[],"mappings":";;;AA2DA,sBAEC;AAID,gCAYC;AAID,sCAQC;AAzFD,4BAA0B;AAE1B,MAAM,UAAU,GAAG,sBAAsB,CAAC;AAC1C,MAAM,UAAU,GAAG,sBAAsB,CAAC;AAC1C,MAAM,aAAa,GAAG,yBAAyB,CAAC;AAQhD,uFAAuF;AACvF,MAAa,iBAAiB;IAEN;IAEA;IAEA;IAEA;IACA;IACA;IACA;IAVpB,YACoB,WAAmB;IACnC,8EAA8E;IAC9D,QAAiB;IACjC,wEAAwE;IACxD,UAAyB;IACzC,uEAAuE;IACvD,UAAmB,KAAK,EACxB,OAAgB,EAChB,OAAgB,EAChB,UAA2C;QAT3C,gBAAW,GAAX,WAAW,CAAQ;QAEnB,aAAQ,GAAR,QAAQ,CAAS;QAEjB,eAAU,GAAV,UAAU,CAAe;QAEzB,YAAO,GAAP,OAAO,CAAiB;QACxB,YAAO,G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,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;YACvF,CAAC;QACL,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;AArOD,4CAqOC","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;\nexport type DtoArrayItem = '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?: DtoArrayItem,\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\nexport class WpDtoFieldMetadata {\n constructor(\n public readonly propertyKey: string,\n public readonly options: WpDtoFieldOptions,\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 additionalProperties?: boolean;\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): 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 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 const options = field.options;\n this.validateOptions(dtoClass, field, reflected);\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 (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: DtoArrayItem, 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 expected = reflected?.name;\n if (expected === 'Array') return this.validateArray(field.options, value, path);\n if (expected === 'String') {\n if (typeof value !== 'string') return new DtoValidationFailure(`${path} must be a string`);\n if (field.options.enumValues && !field.options.enumValues.includes(value)) {\n return new DtoValidationFailure(`${path} must be one of: ${field.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 (field.options.integer && !Number.isInteger(value)) {\n return new DtoValidationFailure(`${path} must be an integer`);\n }\n if (field.options.minimum !== undefined && value < field.options.minimum) {\n return new DtoValidationFailure(`${path} must be >= ${field.options.minimum}`);\n }\n if (field.options.maximum !== undefined && value > field.options.maximum) {\n return new DtoValidationFailure(`${path} must be <= ${field.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 item = value[index];\n if (typeof options.arrayItems !== 'string') {\n const nested = this.validateAt(options.arrayItems, item, `${path}[${index}]`);\n if (nested) return nested;\n continue;\n }\n const wanted = options.arrayItems === 'integer' ? 'number' : options.arrayItems;\n if (typeof item !== wanted || (options.arrayItems === 'integer' && !Number.isInteger(item))) {\n return new DtoValidationFailure(`${path}[${index}] must be ${options.arrayItems}`);\n }\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":";;;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,C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AC,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"]}
@@ -6,6 +6,13 @@ const DtoSchema_1 = require("./DtoSchema");
6
6
  const invalidEmptyEnum = new DtoSchema_1.WpDtoFieldOptions('invalid enum', true, undefined, false, undefined, undefined,
7
7
  // @ts-expect-error enumValues must contain at least one allowed string
8
8
  []);
9
+ // @ts-expect-error a map's value type must be a scalar name or a DtoClass
10
+ const invalidMapValue = new DtoSchema_1.WpDtoMapFieldOptions('invalid map', true, 'date');
11
+ // @ts-expect-error a map value type is mandatory: it is the whole point of WpDtoMapFieldOptions
12
+ const missingMapValue = new DtoSchema_1.WpDtoMapFieldOptions('invalid map', true);
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
15
+ 'string');
9
16
  class InvalidMcpContract {
10
17
  // @ts-expect-error read-only tools cannot also claim to be destructive
11
18
  invalid() {
@@ -62,4 +69,7 @@ tslib_1.__decorate([
62
69
  void InvalidMcpContract;
63
70
  void InvalidMcpArities;
64
71
  void invalidEmptyEnum;
72
+ void invalidMapValue;
73
+ void missingMapValue;
74
+ void noEighthFieldArgument;
65
75
  //# sourceMappingURL=McpCompileAssertions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"McpCompileAssertions.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/mcp/McpCompileAssertions.ts"],"names":[],"mappings":";;;AAAA,+CAA0C;AAC1C,2CAAgD;AAEhD,MAAM,gBAAgB,GAAG,IAAI,6BAAiB,CAC1C,cAAc,EACd,IAAI,EACJ,SAAS,EACT,KAAK,EACL,SAAS,EACT,SAAS;AACT,uEAAuE;AACvE,EAAE,CACL,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","sourcesContent":["import { WpMcpTool } from './McpMetadata';\nimport { WpDtoFieldOptions } 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\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;\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,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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"]}