@webpieces/core-util 0.4.878 → 0.4.880

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.
Files changed (62) hide show
  1. package/package.json +1 -1
  2. package/src/errors/ApiError.d.ts +48 -1
  3. package/src/errors/ApiError.js +56 -2
  4. package/src/errors/ApiError.js.map +1 -1
  5. package/src/errors/ApiErrorCodec.js +9 -2
  6. package/src/errors/ApiErrorCodec.js.map +1 -1
  7. package/src/errors/ClientRole.d.ts +27 -0
  8. package/src/errors/ClientRole.js +32 -0
  9. package/src/errors/ClientRole.js.map +1 -0
  10. package/src/errors/EndUserErrorCode.d.ts +22 -0
  11. package/src/errors/EndUserErrorCode.js +38 -0
  12. package/src/errors/EndUserErrorCode.js.map +1 -0
  13. package/src/errors/EndUserErrorRegistry.d.ts +61 -0
  14. package/src/errors/EndUserErrorRegistry.js +103 -0
  15. package/src/errors/EndUserErrorRegistry.js.map +1 -0
  16. package/src/errors/EndUserErrors.d.ts +28 -0
  17. package/src/errors/EndUserErrors.js +59 -0
  18. package/src/errors/EndUserErrors.js.map +1 -0
  19. package/src/errors/ReceivedApiErrorRule.d.ts +33 -3
  20. package/src/errors/ReceivedApiErrorRule.js +47 -8
  21. package/src/errors/ReceivedApiErrorRule.js.map +1 -1
  22. package/src/errors/index.d.ts +6 -1
  23. package/src/errors/index.js +12 -1
  24. package/src/errors/index.js.map +1 -1
  25. package/src/http/ApiCallTimeoutError.d.ts +22 -1
  26. package/src/http/ApiCallTimeoutError.js +29 -1
  27. package/src/http/ApiCallTimeoutError.js.map +1 -1
  28. package/src/http/CallRegistry.d.ts +7 -2
  29. package/src/http/CallRegistry.js +8 -4
  30. package/src/http/CallRegistry.js.map +1 -1
  31. package/src/http/CallStrategy.d.ts +12 -2
  32. package/src/http/CallStrategy.js +12 -2
  33. package/src/http/CallStrategy.js.map +1 -1
  34. package/src/http/ContextMgr.d.ts +1 -1
  35. package/src/http/ContextMgr.js +1 -1
  36. package/src/http/ContextMgr.js.map +1 -1
  37. package/src/http/ErrorTranslator.d.ts +10 -4
  38. package/src/http/ErrorTranslator.js.map +1 -1
  39. package/src/http/HttpEndpointOptions.d.ts +8 -0
  40. package/src/http/HttpEndpointOptions.js.map +1 -1
  41. package/src/http/StreamErrorControl.d.ts +3 -1
  42. package/src/http/StreamErrorControl.js +4 -3
  43. package/src/http/StreamErrorControl.js.map +1 -1
  44. package/src/http/WebpiecesDefaultErrorTranslator.d.ts +19 -2
  45. package/src/http/WebpiecesDefaultErrorTranslator.js +27 -4
  46. package/src/http/WebpiecesDefaultErrorTranslator.js.map +1 -1
  47. package/src/index.d.ts +2 -2
  48. package/src/index.js +8 -1
  49. package/src/index.js.map +1 -1
  50. package/src/ipc/IpcConnection.js +5 -1
  51. package/src/ipc/IpcConnection.js.map +1 -1
  52. package/src/ipc/IpcErrorTranslator.d.ts +6 -2
  53. package/src/ipc/IpcErrorTranslator.js.map +1 -1
  54. package/src/ipc/IpcRegistry.d.ts +4 -1
  55. package/src/ipc/IpcRegistry.js +5 -3
  56. package/src/ipc/IpcRegistry.js.map +1 -1
  57. package/src/ipc/WebpiecesDefaultIpcErrorTranslator.d.ts +6 -2
  58. package/src/ipc/WebpiecesDefaultIpcErrorTranslator.js +6 -3
  59. package/src/ipc/WebpiecesDefaultIpcErrorTranslator.js.map +1 -1
  60. package/src/ipc/index.d.ts +1 -0
  61. package/src/ipc/index.js +3 -1
  62. package/src/ipc/index.js.map +1 -1
package/src/index.js CHANGED
@@ -12,7 +12,7 @@ exports.MCP = exports.EXTERNAL_CUSTOMER = exports.SVC_TO_SVC = exports.ApiType =
12
12
  exports.InvalidEndpointForMcp = exports.WRITE = exports.WRITE_IDEMPOTENT = exports.READ = exports.EXTERNAL = exports.CRON = exports.CLOUDTASKS = exports.RPC = exports.POST = exports.GET = exports.registerStreamingSchemas = exports.getStreamingEndpoint = exports.WpStream = exports.StreamDirection = exports.StreamWriter = exports.StreamTransportError = exports.StreamEventValidator = exports.StreamingEndpointMetadata = exports.StreamEnvelope = exports.StreamCorrelation = exports.HttpParameterDeclaration = exports.HttpParameterBinding = exports.HttpContractMapper = exports.BoundHttpRequest = exports.StreamDisconnectedError = exports.StreamProtocolError = exports.StreamErrorControl = exports.registerStreamingCatalog = exports.StreamingSchemaCatalog = exports.getAuthorization = exports.WpAuthorization = exports.AuthorizationDeclaration = exports.AuthorizationType = exports.RouteMetadataFactory = exports.RouteMetadata = exports.IPC_METADATA_KEYS = exports.assertNotInternalApi = exports.assertInternalApi = exports.getIpcMaskSpec = exports.getIpcEndpointKind = exports.getIpcEndpoints = exports.getIpcApiId = exports.isInternalApi = exports.WpIpcEndpoint = exports.WpInternal = exports.assertApiTypeMatchesMcpTools = exports.getApiTypeEndpointNames = exports.getApiTypes = exports.DEFAULT_API_TYPES = exports.API_TYPE_METADATA_KEY = void 0;
13
13
  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.apiKey = exports.webhook = exports.sharedSecret = exports.oidc = exports.jwt = exports.AuthDeclaration = exports.AuthMeta = exports.GenerateOutputTarget = exports.GenerateOutputLookup = exports.GenerateLayoutProblem = exports.GeneratedApiDocsLayout = exports.McpToolDefinition = exports.McpToolCatalogError = exports.McpToolCatalogFile = exports.ObjectSchemaBuilder = exports.DtoValidationFailure = exports.ApiJsonSchemaValidator = exports.ApiJsonSchemaDiscriminator = exports.ApiJsonSchema = exports.mcpHintsForOperation = exports.getWpMcpTools = exports.getInvalidEndpointsForMcp = exports.WpMcpToolMetadata = exports.WpMcpToolHints = exports.WpMcpTool = exports.InvalidEndpointForMcpMetadata = void 0;
14
14
  exports.ApiDependencyTimeoutError = exports.ApiUnavailableError = exports.ApiBadGatewayError = 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.ReceivedApiErrorRule = exports.SurfaceEndUserStatus = exports.WEBPIECES_DEFAULT_ERROR_TRANSLATOR = exports.WebpiecesDefaultErrorTranslator = 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 = exports.InstantUtil = void 0;
15
- exports.ApiErrorHttpStatus = exports.ApiErrorBoundary = exports.ApiErrorPayload = exports.ApiErrorCodec = exports.ApiCodedError = exports.ApiNotImplementedError = exports.ApiUnsupportedMediaTypeError = exports.ApiPreconditionFailedError = exports.ApiUnprocessableError = exports.ApiConflictError = exports.ApiEndpointNotFoundError = exports.ApiConnectionError = exports.ApiDependencyBackoffError = exports.ApiUnauthorizedError = exports.ApiBadRequestError = exports.ApiEndUserError = exports.ApiRequestTimeoutError = exports.ApiForbiddenError = exports.ApiRateLimitedError = exports.ApiImplementationError = void 0;
15
+ exports.ApiErrorHttpStatus = exports.ApiErrorBoundary = exports.ApiErrorPayload = exports.ApiErrorCodec = exports.ClientRole = exports.EndUserErrorRegistry = exports.EndUserErrorCode = exports.ApiEndUserBadRequestError = exports.ApiEndUserForbiddenError = exports.ApiEndUserNotFoundError = exports.ApiClientTooOldError = exports.ApiCodedError = exports.ApiNotImplementedError = exports.ApiUnsupportedMediaTypeError = exports.ApiPreconditionFailedError = exports.ApiUnprocessableError = exports.ApiConflictError = exports.ApiEndpointNotFoundError = exports.ApiConnectionError = exports.ApiDependencyBackoffError = exports.ApiUnauthorizedError = exports.ApiBadRequestError = exports.ApiEndUserError = exports.ApiRequestTimeoutError = exports.ApiForbiddenError = exports.ApiRateLimitedError = exports.ApiImplementationError = void 0;
16
16
  var errorUtils_1 = require("./lib/errorUtils");
17
17
  Object.defineProperty(exports, "toError", { enumerable: true, get: function () { return errorUtils_1.toError; } });
18
18
  var ContextKey_1 = require("./ContextKey");
@@ -344,6 +344,13 @@ Object.defineProperty(exports, "ApiPreconditionFailedError", { enumerable: true,
344
344
  Object.defineProperty(exports, "ApiUnsupportedMediaTypeError", { enumerable: true, get: function () { return errors_2.ApiUnsupportedMediaTypeError; } });
345
345
  Object.defineProperty(exports, "ApiNotImplementedError", { enumerable: true, get: function () { return errors_2.ApiNotImplementedError; } });
346
346
  Object.defineProperty(exports, "ApiCodedError", { enumerable: true, get: function () { return errors_2.ApiCodedError; } });
347
+ Object.defineProperty(exports, "ApiClientTooOldError", { enumerable: true, get: function () { return errors_2.ApiClientTooOldError; } });
348
+ Object.defineProperty(exports, "ApiEndUserNotFoundError", { enumerable: true, get: function () { return errors_2.ApiEndUserNotFoundError; } });
349
+ Object.defineProperty(exports, "ApiEndUserForbiddenError", { enumerable: true, get: function () { return errors_2.ApiEndUserForbiddenError; } });
350
+ Object.defineProperty(exports, "ApiEndUserBadRequestError", { enumerable: true, get: function () { return errors_2.ApiEndUserBadRequestError; } });
351
+ Object.defineProperty(exports, "EndUserErrorCode", { enumerable: true, get: function () { return errors_2.EndUserErrorCode; } });
352
+ Object.defineProperty(exports, "EndUserErrorRegistry", { enumerable: true, get: function () { return errors_2.EndUserErrorRegistry; } });
353
+ Object.defineProperty(exports, "ClientRole", { enumerable: true, get: function () { return errors_2.ClientRole; } });
347
354
  Object.defineProperty(exports, "ApiErrorCodec", { enumerable: true, get: function () { return errors_2.ApiErrorCodec; } });
348
355
  Object.defineProperty(exports, "ApiErrorPayload", { enumerable: true, get: function () { return errors_2.ApiErrorPayload; } });
349
356
  Object.defineProperty(exports, "ApiErrorBoundary", { enumerable: true, get: function () { return errors_2.ApiErrorBoundary; } });
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,gDA2B2B;AA1BvB,qGAAA,OAAO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AAA3C,0GAAA,WAAW,OAAA;AAEpB,mCA0BkB;AAzBd,kGAAA,QAAQ,OAAA;AACR,0GAAA,gBAAgB,OAAA;AAChB,4GAAA,kBAAkB,OAAA;AAClB,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,0GAAA,gBAAgB,OAAA;AAChB,+GAAA,qBAAqB,OAAA;AACrB,oHAAA,0BAA0B,OAAA;AAC1B,sHAAA,4BAA4B,OAAA;AAC5B,gHAAA,sBAAsB,OAAA;AACtB,uGAAA,aAAa,OAAA;AACb,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 WpAuth,\n MISSING_AUTH_DECORATOR_FIX,\n WpLocalOnly,\n isLocalOnly,\n MaskLog,\n getApiPath,\n getEndpoints,\n getEndpointHttpMethod,\n getEndpointOptions,\n getEndpointOperation,\n getEndpointKind,\n getEndpointKinds,\n getMaskSpec,\n isFormPost,\n isRawBody,\n isApiPath,\n getAuthMeta,\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 { WpInt, WpMin, WpMax, NUMERIC_METADATA_KEYS } from './http/numeric-field-decorators';\nexport type { Integer } from './http/numeric-field-decorators';\nexport {\n ApiType,\n SVC_TO_SVC,\n EXTERNAL_CUSTOMER,\n MCP,\n API_TYPE_METADATA_KEY,\n DEFAULT_API_TYPES,\n getApiTypes,\n getApiTypeEndpointNames,\n assertApiTypeMatchesMcpTools,\n} from './http/api-type';\nexport type { ApiTypeKind } from './http/api-type';\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 { AuthorizationType, AuthorizationDeclaration, WpAuthorization, getAuthorization } from './http/authorization';\nexport type { AuthorizationRequirement } from './http/authorization';\nexport { StreamingSchemaCatalog, registerStreamingCatalog } from './http/StreamingSchemaCatalog';\nexport {\n StreamErrorControl,\n StreamProtocolError,\n StreamDisconnectedError,\n} from './http/StreamErrorControl';\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 StreamDirection,\n WpStream,\n getStreamingEndpoint,\n registerStreamingSchemas,\n} from './http/StreamingContract';\nexport type { RequestStream, ResponseStream, StreamEnvelopeKind } from './http/StreamingContract';\nexport type {\n EndpointResponseType,\n HttpMethod,\n HttpParameterSource,\n HttpParameterValueType,\n} from './http/HttpContract';\nexport { GET, POST } from './http/HttpContract';\nexport type {\n EndpointKind,\n EndpointOperation,\n EndpointOptions,\n ExternalEndpointOptions,\n} from './http/decorators';\nexport { RPC, CLOUDTASKS, CRON, EXTERNAL, READ, WRITE_IDEMPOTENT, WRITE } from './http/decorators';\nexport {\n InvalidEndpointForMcp,\n InvalidEndpointForMcpMetadata,\n WpMcpTool,\n WpMcpToolHints,\n WpMcpToolMetadata,\n getInvalidEndpointsForMcp,\n getWpMcpTools,\n mcpHintsForOperation,\n} from './mcp/McpMetadata';\nexport type { WpMcpMethodDecorator } from './mcp/McpMetadata';\nexport {\n ApiJsonSchema,\n ApiJsonSchemaDiscriminator,\n ApiJsonSchemaValidator,\n DtoValidationFailure,\n ObjectSchemaBuilder,\n} from './mcp/DtoSchema';\nexport type { ApiJsonSchemaType, DtoValue } from './mcp/DtoSchema';\nexport {\n McpToolCatalogFile,\n McpToolCatalogError,\n McpToolDefinition,\n} from './mcp/McpToolCatalogFile';\nexport {\n GeneratedApiDocsLayout,\n GenerateLayoutProblem,\n GenerateOutputLookup,\n GenerateOutputTarget,\n} from './mcp/GeneratedApiDocsLayout';\nexport type {\n LayoutDependsOn,\n LayoutDependsOnObject,\n LayoutTarget,\n LayoutTargets,\n} from './mcp/GeneratedApiDocsLayout';\n// The TYPE layer of the auth surface — likewise split out of decorators.ts for file size only.\nexport { AuthMeta, AuthDeclaration, jwt, oidc, sharedSecret, webhook, apiKey } from './http/auth-mode';\nexport type {\n AuthMode,\n ApiKeyCredential,\n ApiKeyCredentials,\n AuthMethod,\n AuthMethods,\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\n// @Endpoint(POST, ..., WRITE, 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 sharedSecret(...) 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 @WpLocalOnly 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 ErrorTranslator 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 { ErrorTranslator } from './http/ErrorTranslator';\n// THE webpieces default translator — always installed, and what an app's own translator delegates to\n// in order to decline an error. ONE class, both halves, node and browser alike.\nexport {\n WebpiecesDefaultErrorTranslator,\n WEBPIECES_DEFAULT_ERROR_TRANSLATOR,\n} from './http/WebpiecesDefaultErrorTranslator';\n// WHICH KIND OF CALLER drove this request (gui / llm / public-api), and the per-request end-user\n// status derived from it — the replacement for the deleted per-router EndUserStatus.\nexport { SurfaceEndUserStatus } from './http/Surface';\nexport type { Surface } from './http/Surface';\n// The ONE rule for an error RECEIVED from another process, shared verbatim by HTTP and IPC.\nexport { ReceivedApiErrorRule } from './errors/ReceivedApiErrorRule';\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';\nexport { ContextWriter, ContextStore } from './http/ContextWriter';\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 { ApiCallDirection, 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 ApiBadGatewayError,\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 ApiConflictError,\n ApiUnprocessableError,\n ApiPreconditionFailedError,\n ApiUnsupportedMediaTypeError,\n ApiNotImplementedError,\n ApiCodedError,\n ApiErrorCodec,\n ApiErrorPayload,\n ApiErrorBoundary,\n} from './errors';\nexport type { ApiErrorKind, ApiStatusCode, EdgeHttpStatus } from './errors';\nexport { ApiErrorHttpStatus } from './http/ApiErrorHttpStatus';\nexport type { PublishedKind, PublishedApiError } 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,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,gDA2B2B;AA1BvB,qGAAA,OAAO,OAAA;AACP,sGAAA,QAAQ,OAAA;AACR,mEAAmE;AACnE,0GAAA,YAAY,OAAA;AACZ,oGAAA,MAAM,OAAA;AACN,wHAAA,0BAA0B,OAAA;AAC1B,yGAAA,WAAW,OAAA;AACX,yGAAA,W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AA,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,0GAAA,gBAAgB,OAAA;AAChB,+GAAA,qBAAqB,OAAA;AACrB,oHAAA,0BAA0B,OAAA;AAC1B,sHAAA,4BAA4B,OAAA;AAC5B,gHAAA,sBAAsB,OAAA;AACtB,uGAAA,aAAa,OAAA;AACb,8GAAA,oBAAoB,OAAA;AACpB,iHAAA,uBAAuB,OAAA;AACvB,kHAAA,wBAAwB,OAAA;AACxB,mHAAA,yBAAyB,OAAA;AACzB,0GAAA,gBAAgB,OAAA;AAChB,8GAAA,oBAAoB,OAAA;AACpB,oGAAA,UAAU,OAAA;AACV,uGAAA,aAAa,OAAA;AACb,yGAAA,eAAe,OAAA;AACf,0GAAA,gBAAgB,OAAA;AAQpB,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 WpAuth,\n MISSING_AUTH_DECORATOR_FIX,\n WpLocalOnly,\n isLocalOnly,\n MaskLog,\n getApiPath,\n getEndpoints,\n getEndpointHttpMethod,\n getEndpointOptions,\n getEndpointOperation,\n getEndpointKind,\n getEndpointKinds,\n getMaskSpec,\n isFormPost,\n isRawBody,\n isApiPath,\n getAuthMeta,\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 { WpInt, WpMin, WpMax, NUMERIC_METADATA_KEYS } from './http/numeric-field-decorators';\nexport type { Integer } from './http/numeric-field-decorators';\nexport {\n ApiType,\n SVC_TO_SVC,\n EXTERNAL_CUSTOMER,\n MCP,\n API_TYPE_METADATA_KEY,\n DEFAULT_API_TYPES,\n getApiTypes,\n getApiTypeEndpointNames,\n assertApiTypeMatchesMcpTools,\n} from './http/api-type';\nexport type { ApiTypeKind } from './http/api-type';\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 { AuthorizationType, AuthorizationDeclaration, WpAuthorization, getAuthorization } from './http/authorization';\nexport type { AuthorizationRequirement } from './http/authorization';\nexport { StreamingSchemaCatalog, registerStreamingCatalog } from './http/StreamingSchemaCatalog';\nexport {\n StreamErrorControl,\n StreamProtocolError,\n StreamDisconnectedError,\n} from './http/StreamErrorControl';\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 StreamDirection,\n WpStream,\n getStreamingEndpoint,\n registerStreamingSchemas,\n} from './http/StreamingContract';\nexport type { RequestStream, ResponseStream, StreamEnvelopeKind } from './http/StreamingContract';\nexport type {\n EndpointResponseType,\n HttpMethod,\n HttpParameterSource,\n HttpParameterValueType,\n} from './http/HttpContract';\nexport { GET, POST } from './http/HttpContract';\nexport type {\n EndpointKind,\n EndpointOperation,\n EndpointOptions,\n ExternalEndpointOptions,\n} from './http/decorators';\nexport { RPC, CLOUDTASKS, CRON, EXTERNAL, READ, WRITE_IDEMPOTENT, WRITE } from './http/decorators';\nexport {\n InvalidEndpointForMcp,\n InvalidEndpointForMcpMetadata,\n WpMcpTool,\n WpMcpToolHints,\n WpMcpToolMetadata,\n getInvalidEndpointsForMcp,\n getWpMcpTools,\n mcpHintsForOperation,\n} from './mcp/McpMetadata';\nexport type { WpMcpMethodDecorator } from './mcp/McpMetadata';\nexport {\n ApiJsonSchema,\n ApiJsonSchemaDiscriminator,\n ApiJsonSchemaValidator,\n DtoValidationFailure,\n ObjectSchemaBuilder,\n} from './mcp/DtoSchema';\nexport type { ApiJsonSchemaType, DtoValue } from './mcp/DtoSchema';\nexport {\n McpToolCatalogFile,\n McpToolCatalogError,\n McpToolDefinition,\n} from './mcp/McpToolCatalogFile';\nexport {\n GeneratedApiDocsLayout,\n GenerateLayoutProblem,\n GenerateOutputLookup,\n GenerateOutputTarget,\n} from './mcp/GeneratedApiDocsLayout';\nexport type {\n LayoutDependsOn,\n LayoutDependsOnObject,\n LayoutTarget,\n LayoutTargets,\n} from './mcp/GeneratedApiDocsLayout';\n// The TYPE layer of the auth surface — likewise split out of decorators.ts for file size only.\nexport { AuthMeta, AuthDeclaration, jwt, oidc, sharedSecret, webhook, apiKey } from './http/auth-mode';\nexport type {\n AuthMode,\n ApiKeyCredential,\n ApiKeyCredentials,\n AuthMethod,\n AuthMethods,\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\n// @Endpoint(POST, ..., WRITE, 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 sharedSecret(...) 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 @WpLocalOnly 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 ErrorTranslator 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 { ErrorTranslator } from './http/ErrorTranslator';\n// THE webpieces default translator — always installed, and what an app's own translator delegates to\n// in order to decline an error. ONE class, both halves, node and browser alike.\nexport {\n WebpiecesDefaultErrorTranslator,\n WEBPIECES_DEFAULT_ERROR_TRANSLATOR,\n} from './http/WebpiecesDefaultErrorTranslator';\n// WHICH KIND OF CALLER drove this request (gui / llm / public-api), and the per-request end-user\n// status derived from it — the replacement for the deleted per-router EndUserStatus.\nexport { SurfaceEndUserStatus } from './http/Surface';\nexport type { Surface } from './http/Surface';\n// The ONE rule for an error RECEIVED from another process, shared verbatim by HTTP and IPC.\nexport { ReceivedApiErrorRule } from './errors/ReceivedApiErrorRule';\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';\nexport { ContextWriter, ContextStore } from './http/ContextWriter';\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 { ApiCallDirection, 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 ApiBadGatewayError,\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 ApiConflictError,\n ApiUnprocessableError,\n ApiPreconditionFailedError,\n ApiUnsupportedMediaTypeError,\n ApiNotImplementedError,\n ApiCodedError,\n ApiClientTooOldError,\n ApiEndUserNotFoundError,\n ApiEndUserForbiddenError,\n ApiEndUserBadRequestError,\n EndUserErrorCode,\n EndUserErrorRegistry,\n ClientRole,\n ApiErrorCodec,\n ApiErrorPayload,\n ApiErrorBoundary,\n} from './errors';\nexport type {\n ApiErrorKind,\n ApiStatusCode,\n EdgeHttpStatus,\n EndUserErrorFactory,\n} from './errors';\nexport { ApiErrorHttpStatus } from './http/ApiErrorHttpStatus';\nexport type { PublishedKind, PublishedApiError } from './http/ApiErrorHttpStatus';\n"]}
@@ -4,6 +4,7 @@ exports.IpcErrors = exports.IpcConnection = exports.IpcConnectionOptions = expor
4
4
  const errorUtils_1 = require("../lib/errorUtils");
5
5
  const ApiCallTimeoutError_1 = require("../http/ApiCallTimeoutError");
6
6
  const CallStrategy_1 = require("../http/CallStrategy");
7
+ const HttpEndpointOptions_1 = require("../http/HttpEndpointOptions");
7
8
  const errors_1 = require("../errors");
8
9
  const IpcRegistry_1 = require("./IpcRegistry");
9
10
  const IpcProtocol_1 = require("./IpcProtocol");
@@ -103,7 +104,10 @@ class IpcConnection {
103
104
  const pending = new PendingCall(request.context, resolve, reject);
104
105
  this.pending.set(request.context.callId, pending);
105
106
  pending.cancelTimer = this.options.scheduler.schedule(() => {
106
- this.settle(request.context.callId, new ApiCallTimeoutError_1.ApiCallTimeoutError(this.options.timeoutMs, new CallStrategy_1.CallContext(request.apiId, request.methodId)), 'expired');
107
+ this.settle(request.context.callId, new ApiCallTimeoutError_1.ApiCallTimeoutError(this.options.timeoutMs,
108
+ // IPC contracts declare no @Endpoint operation, so the deadline reports the
109
+ // conservative WRITE: the user is told to check before repeating the call.
110
+ new CallStrategy_1.CallContext(request.apiId, request.methodId, HttpEndpointOptions_1.WRITE)), 'expired');
107
111
  }, this.options.timeoutMs);
108
112
  // This owner observes every async send rejection; a send failure is never a timeout.
109
113
  void this.send(request).catch((error) => {
@@ -1 +1 @@
1
- {"version":3,"file":"IpcConnection.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/ipc/IpcConnection.ts"],"names":[],"mappings":";;;AAAA,kDAA4C;AAC5C,qEAAkE;AAClE,uDAAmD;AACnD,sCAA6E;AAC7E,+CAA4C;AAC5C,+CAOuB;AAEvB,4FAA4F;AAC5F,MAAa,iBAAkB,SAAQ,KAAK;IACxC,YAAY,OAAe,EAAE,KAAa;QACtC,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IACpC,CAAC;CACJ;AALD,8CAKC;AAkBD,MAAa,oBAAoB;IAEhB;IACA;IACA;IACA;IACA;IACA;IACA;IAPb,YACa,SAAiB,EACjB,MAAoB,EACpB,SAAuB,EACvB,MAAqB,EACrB,uBAAuB,SAAS,EAChC,yBAAyB,GAAG,EAC5B,eAAe,aAAa;QAN5B,cAAS,GAAT,SAAS,CAAQ;QACjB,WAAM,GAAN,MAAM,CAAc;QACpB,cAAS,GAAT,SAAS,CAAc;QACvB,WAAM,GAAN,MAAM,CAAe;QACrB,yBAAoB,GAApB,oBAAoB,CAAY;QAChC,2BAAsB,GAAtB,sBAAsB,CAAM;QAC5B,iBAAY,GAAZ,YAAY,CAAgB;QAErC,IACI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;YAC3B,SAAS,IAAI,CAAC;YACd,CAAC,MAAM,CAAC,aAAa,CAAC,oBAAoB,CAAC;YAC3C,oBAAoB,GAAG,CAAC;YACxB,CAAC,MAAM,CAAC,aAAa,CAAC,sBAAsB,CAAC;YAC7C,sBAAsB,GAAG,CAAC,EAC5B,CAAC;YACC,MAAM,IAAI,+BAAsB,CAAC,gDAAgD,CAAC,CAAC;QACvF,CAAC;IACL,CAAC;CACJ;AArB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AAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;YAAE,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;QACzE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;CACJ;AA9LD,sCA8LC;AAED,MAAa,SAAS;IAClB,6QAA6Q;IAC7Q,MAAM,CAAC,SAAS,CAAC,KAAc;QAC3B,OAAO,KAAK,YAAY,KAAK;YACzB,CAAC,CAAC,KAAK;YACP,CAAC,CAAC,IAAI,+BAAsB,CAAC,mCAAmC,CAAC,CAAC;IAC1E,CAAC;CACJ;AAPD,8BAOC","sourcesContent":["import { toError } from '../lib/errorUtils';\nimport { ApiCallTimeoutError } from '../http/ApiCallTimeoutError';\nimport { CallContext } from '../http/CallStrategy';\nimport { ApiEndpointNotFoundError, ApiImplementationError } from '../errors';\nimport { IpcRegistry } from './IpcRegistry';\nimport {\n IpcCallContext,\n IpcFailure,\n IpcMessage,\n IpcReply,\n IpcRequest,\n IpcProtocol,\n} from './IpcProtocol';\n\n/** A local connection failed, distinct from a remote implementation's semantic ApiError. */\nexport class IpcTransportError extends Error {\n constructor(message: string, cause?: Error) {\n super(message, { cause });\n this.name = 'IpcTransportError';\n }\n}\n\n/** Implement this at the host transport boundary; no vendor or platform declarations leak out. */\nexport interface IpcTransport {\n send(message: string): Promise<void> | void;\n subscribe(\n receive: (message: string) => void,\n failed: (error: Error) => void,\n closed: (error: Error) => void,\n ): () => void;\n close(): void;\n}\nexport interface IpcScheduler {\n schedule(callback: () => void, delayMs: number): () => void;\n}\nexport interface IpcErrorOwner {\n report(error: Error): void;\n}\nexport class IpcConnectionOptions {\n constructor(\n readonly timeoutMs: number,\n readonly nextId: () => string,\n readonly scheduler: IpcScheduler,\n readonly errors: IpcErrorOwner,\n readonly maxMessageCharacters = 1_000_000,\n readonly settlementHistoryLimit = 100,\n readonly connectionId = 'unspecified',\n ) {\n if (\n !Number.isFinite(timeoutMs) ||\n timeoutMs <= 0 ||\n !Number.isSafeInteger(maxMessageCharacters) ||\n maxMessageCharacters < 1 ||\n !Number.isSafeInteger(settlementHistoryLimit) ||\n settlementHistoryLimit < 1\n ) {\n throw new ApiImplementationError('IPC timeout and message limit must be positive');\n }\n }\n}\n\ntype SettlementReason = 'resolved' | 'expired' | 'rejected';\nclass SettlementRecord {\n constructor(\n readonly context: IpcCallContext,\n readonly reason: SettlementReason,\n readonly settledAt: number,\n ) {}\n}\n\nclass PendingCall {\n cancelTimer: () => void = () => {};\n constructor(\n readonly context: IpcCallContext,\n readonly resolve: (reply: IpcReply) => void,\n readonly reject: (error: Error) => void,\n ) {}\n}\n\n/** One connection owns both directions, one dispatcher, and all pending-call lifetimes. */\nexport class IpcConnection {\n private readonly pending = new Map<string, PendingCall>();\n private readonly settlements = new Map<string, SettlementRecord>();\n private readonly activeRequests = new Set<string>();\n private readonly usedIds = new Set<string>();\n private handler?: (request: IpcRequest) => Promise<IpcReply>;\n private closed?: Error;\n private readonly unsubscribe: () => void;\n\n constructor(\n private readonly transport: IpcTransport,\n private readonly options: IpcConnectionOptions,\n ) {\n this.unsubscribe = transport.subscribe(\n (message) => this.receive(message),\n (error) => this.fail(new IpcTransportError('IPC transport failed', error)),\n (error) => this.fail(new IpcTransportError('IPC connection closed', error)),\n );\n }\n\n /** Install exactly one factory dispatcher BEFORE exposing this connection to the peer. */\n setHandler(handler: (request: IpcRequest) => Promise<IpcReply>): void {\n if (this.handler)\n throw new ApiImplementationError('An IPC connection already has a dispatcher');\n if (this.closed) throw this.closed;\n this.handler = handler;\n }\n\n newContext(parent?: IpcCallContext): IpcCallContext {\n const id = this.options.nextId();\n if (this.usedIds.has(id))\n throw new ApiImplementationError('IPC identity generator reused a call ID');\n this.usedIds.add(id);\n return new IpcCallContext(parent?.txId ?? id, id, parent?.callId);\n }\n\n request(request: IpcRequest): Promise<IpcReply> {\n if (this.closed) return Promise.reject(this.closed);\n if (this.pending.has(request.context.callId))\n return Promise.reject(new ApiImplementationError('Duplicate pending IPC call'));\n return new Promise<IpcReply>((resolve, reject) => {\n const pending = new PendingCall(request.context, resolve, reject);\n this.pending.set(request.context.callId, pending);\n pending.cancelTimer = this.options.scheduler.schedule(() => {\n this.settle(\n request.context.callId,\n new ApiCallTimeoutError(\n this.options.timeoutMs,\n new CallContext(request.apiId, request.methodId),\n ),\n 'expired',\n );\n }, this.options.timeoutMs);\n // This owner observes every async send rejection; a send failure is never a timeout.\n void this.send(request).catch((error) => {\n this.settle(\n request.context.callId,\n new IpcTransportError('IPC send failed', IpcErrors.normalize(error)),\n 'rejected',\n );\n });\n });\n }\n\n dispose(): void {\n this.fail(new IpcTransportError('IPC connection disposed'));\n this.unsubscribe();\n this.transport.close();\n }\n\n private async send(message: IpcMessage): Promise<void> {\n if (this.closed) throw this.closed;\n const json = JSON.stringify(message);\n if (json.length > this.options.maxMessageCharacters)\n throw new ApiImplementationError('IPC message exceeds configured limit');\n await this.transport.send(json);\n }\n\n private receive(json: string): void {\n if (this.closed) return;\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- transport boundary rejects pending calls or encodes a failure that the client throws\n try {\n if (json.length > this.options.maxMessageCharacters)\n throw new ApiImplementationError('IPC message exceeds configured limit');\n const message = IpcProtocol.parse(json);\n if (message.type === 'request') {\n if (this.activeRequests.has(message.context.callId))\n throw new ApiImplementationError('Duplicate active IPC request');\n this.activeRequests.add(message.context.callId);\n void this.dispatch(message).catch((error) => this.fail(IpcErrors.normalize(error)));\n return;\n }\n const pending = this.pending.get(message.context.callId);\n // Late or unsolicited replies are reported, never resolve a different call or replay work.\n if (!pending) {\n this.options.errors.report(this.lateReplyError(message));\n return;\n }\n if (!IpcProtocol.sameContext(pending.context, message.context))\n throw this.correlationError(message, pending.context);\n this.pending.delete(message.context.callId);\n pending.cancelTimer();\n this.remember(pending.context, 'resolved');\n pending.resolve(message);\n } catch (err: unknown) {\n const error = toError(err);\n this.fail(IpcErrors.normalize(error));\n }\n }\n\n private async dispatch(request: IpcRequest): Promise<void> {\n let reply: IpcReply;\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- transport boundary rejects pending calls or encodes a failure that the client throws\n try {\n if (!this.handler)\n throw new ApiEndpointNotFoundError('IPC dispatcher is not installed');\n reply = await this.handler(request);\n if (!IpcProtocol.sameContext(request.context, reply.context))\n throw new ApiImplementationError('IPC handler reply correlation mismatch');\n } catch (err: unknown) {\n const error = toError(err);\n // The ONE app-reachable seam for an outbound IPC failure. The webpieces default applies the\n // same `ApiErrorBoundary` publication rule this used to call inline — notably that an\n // `ApiConnectionError` publishes as `implementation`, because to the PEER this process is\n // what is broken.\n reply = new IpcFailure(request.context, IpcRegistry.getErrorTranslator().toWire(error));\n } finally {\n this.activeRequests.delete(request.context.callId);\n }\n await this.send(reply);\n }\n\n private settle(id: string, error: Error, reason: SettlementReason): void {\n const pending = this.pending.get(id);\n if (!pending) return;\n this.pending.delete(id);\n pending.cancelTimer();\n this.remember(pending.context, reason);\n pending.reject(error);\n }\n\n private remember(context: IpcCallContext, reason: SettlementReason): void {\n this.settlements.delete(context.callId);\n this.settlements.set(context.callId, new SettlementRecord(context, reason, Date.now()));\n while (this.settlements.size > this.options.settlementHistoryLimit) {\n const oldest = this.settlements.keys().next().value;\n if (typeof oldest !== 'string') return;\n this.settlements.delete(oldest);\n }\n }\n\n private lateReplyError(reply: IpcReply): ApiImplementationError {\n const previous = this.settlements.get(reply.context.callId);\n let classification = 'unknown';\n if (previous) {\n classification = IpcProtocol.sameContext(previous.context, reply.context)\n ? previous.reason === 'expired'\n ? 'expired'\n : 'duplicate-settled'\n : 'correlation-mismatched';\n }\n const settlement = previous\n ? ` terminal=${previous.reason} ageMs=${String(Math.max(0, Date.now() - previous.settledAt))}`\n : '';\n return new ApiImplementationError(\n `Late or unknown IPC reply classification=${classification}${settlement} ${this.correlationFields(reply.context)}`,\n );\n }\n\n private correlationError(reply: IpcReply, expected: IpcCallContext): ApiImplementationError {\n return new ApiImplementationError(\n `IPC reply correlation mismatch classification=correlation-mismatched ` +\n `${this.correlationFields(reply.context)} expectedTxId=${JSON.stringify(expected.txId)}`,\n );\n }\n\n private correlationFields(context: IpcCallContext): string {\n return (\n `callId=${JSON.stringify(context.callId)} txId=${JSON.stringify(context.txId)} ` +\n `parentCallId=${JSON.stringify(context.parentCallId ?? null)} ` +\n `connectionId=${JSON.stringify(this.options.connectionId)}`\n );\n }\n\n private fail(error: Error): void {\n if (this.closed) return;\n this.closed = error;\n for (const id of this.pending.keys()) this.settle(id, error, 'rejected');\n this.options.errors.report(error);\n }\n}\n\nexport class IpcErrors {\n // webpieces-disable no-function-outside-class -- portable stateless IPC primitive; no platform DI container exists on this boundary; webpieces-disable no-any-unknown -- untrusted IPC data is schema-validated; generic dispatch cannot assume a DTO type before validation\n static normalize(value: unknown): Error {\n return value instanceof Error\n ? value\n : new ApiImplementationError('IPC failed with a non-Error value');\n }\n}\n"]}
1
+ {"version":3,"file":"IpcConnection.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/ipc/IpcConnection.ts"],"names":[],"mappings":";;;AAAA,kDAA4C;AAC5C,qEAAkE;AAClE,uDAAmD;AACnD,qEAAoD;AACpD,sCAA6E;AAC7E,+CAA4C;AAC5C,+CAOuB;AAEvB,4FAA4F;AAC5F,MAAa,iBAAkB,SAAQ,KAAK;IACxC,YAAY,OAAe,EAAE,KAAa;QACtC,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IACpC,CAAC;CACJ;AALD,8CAKC;AAkBD,MAAa,oBAAoB;IAEhB;IACA;IACA;IACA;IACA;IACA;IACA;IAPb,YACa,SAAiB,EACjB,MAAoB,EACpB,SAAuB,EACvB,MAAqB,EACrB,uBAAuB,SAAS,EAChC,yBAAyB,GAAG,EAC5B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E,QAAwB;QAC9D,OAAO,IAAI,+BAAsB,CAC7B,uEAAuE;YACnE,GAAG,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,OAAO,CAAC,iBAAiB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAC/F,CAAC;IACN,CAAC;IAEO,iBAAiB,CAAC,OAAuB;QAC7C,OAAO,CACH,UAAU,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG;YAChF,gBAAgB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,YAAY,IAAI,IAAI,CAAC,GAAG;YAC/D,gBAAgB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAC9D,CAAC;IACN,CAAC;IAEO,IAAI,CAAC,KAAY;QACrB,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO;QACxB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;YAAE,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;QACzE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;CACJ;AAhMD,sCAgMC;AAED,MAAa,SAAS;IAClB,6QAA6Q;IAC7Q,MAAM,CAAC,SAAS,CAAC,KAAc;QAC3B,OAAO,KAAK,YAAY,KAAK;YACzB,CAAC,CAAC,KAAK;YACP,CAAC,CAAC,IAAI,+BAAsB,CAAC,mCAAmC,CAAC,CAAC;IAC1E,CAAC;CACJ;AAPD,8BAOC","sourcesContent":["import { toError } from '../lib/errorUtils';\nimport { ApiCallTimeoutError } from '../http/ApiCallTimeoutError';\nimport { CallContext } from '../http/CallStrategy';\nimport { WRITE } from '../http/HttpEndpointOptions';\nimport { ApiEndpointNotFoundError, ApiImplementationError } from '../errors';\nimport { IpcRegistry } from './IpcRegistry';\nimport {\n IpcCallContext,\n IpcFailure,\n IpcMessage,\n IpcReply,\n IpcRequest,\n IpcProtocol,\n} from './IpcProtocol';\n\n/** A local connection failed, distinct from a remote implementation's semantic ApiError. */\nexport class IpcTransportError extends Error {\n constructor(message: string, cause?: Error) {\n super(message, { cause });\n this.name = 'IpcTransportError';\n }\n}\n\n/** Implement this at the host transport boundary; no vendor or platform declarations leak out. */\nexport interface IpcTransport {\n send(message: string): Promise<void> | void;\n subscribe(\n receive: (message: string) => void,\n failed: (error: Error) => void,\n closed: (error: Error) => void,\n ): () => void;\n close(): void;\n}\nexport interface IpcScheduler {\n schedule(callback: () => void, delayMs: number): () => void;\n}\nexport interface IpcErrorOwner {\n report(error: Error): void;\n}\nexport class IpcConnectionOptions {\n constructor(\n readonly timeoutMs: number,\n readonly nextId: () => string,\n readonly scheduler: IpcScheduler,\n readonly errors: IpcErrorOwner,\n readonly maxMessageCharacters = 1_000_000,\n readonly settlementHistoryLimit = 100,\n readonly connectionId = 'unspecified',\n ) {\n if (\n !Number.isFinite(timeoutMs) ||\n timeoutMs <= 0 ||\n !Number.isSafeInteger(maxMessageCharacters) ||\n maxMessageCharacters < 1 ||\n !Number.isSafeInteger(settlementHistoryLimit) ||\n settlementHistoryLimit < 1\n ) {\n throw new ApiImplementationError('IPC timeout and message limit must be positive');\n }\n }\n}\n\ntype SettlementReason = 'resolved' | 'expired' | 'rejected';\nclass SettlementRecord {\n constructor(\n readonly context: IpcCallContext,\n readonly reason: SettlementReason,\n readonly settledAt: number,\n ) {}\n}\n\nclass PendingCall {\n cancelTimer: () => void = () => {};\n constructor(\n readonly context: IpcCallContext,\n readonly resolve: (reply: IpcReply) => void,\n readonly reject: (error: Error) => void,\n ) {}\n}\n\n/** One connection owns both directions, one dispatcher, and all pending-call lifetimes. */\nexport class IpcConnection {\n private readonly pending = new Map<string, PendingCall>();\n private readonly settlements = new Map<string, SettlementRecord>();\n private readonly activeRequests = new Set<string>();\n private readonly usedIds = new Set<string>();\n private handler?: (request: IpcRequest) => Promise<IpcReply>;\n private closed?: Error;\n private readonly unsubscribe: () => void;\n\n constructor(\n private readonly transport: IpcTransport,\n private readonly options: IpcConnectionOptions,\n ) {\n this.unsubscribe = transport.subscribe(\n (message) => this.receive(message),\n (error) => this.fail(new IpcTransportError('IPC transport failed', error)),\n (error) => this.fail(new IpcTransportError('IPC connection closed', error)),\n );\n }\n\n /** Install exactly one factory dispatcher BEFORE exposing this connection to the peer. */\n setHandler(handler: (request: IpcRequest) => Promise<IpcReply>): void {\n if (this.handler)\n throw new ApiImplementationError('An IPC connection already has a dispatcher');\n if (this.closed) throw this.closed;\n this.handler = handler;\n }\n\n newContext(parent?: IpcCallContext): IpcCallContext {\n const id = this.options.nextId();\n if (this.usedIds.has(id))\n throw new ApiImplementationError('IPC identity generator reused a call ID');\n this.usedIds.add(id);\n return new IpcCallContext(parent?.txId ?? id, id, parent?.callId);\n }\n\n request(request: IpcRequest): Promise<IpcReply> {\n if (this.closed) return Promise.reject(this.closed);\n if (this.pending.has(request.context.callId))\n return Promise.reject(new ApiImplementationError('Duplicate pending IPC call'));\n return new Promise<IpcReply>((resolve, reject) => {\n const pending = new PendingCall(request.context, resolve, reject);\n this.pending.set(request.context.callId, pending);\n pending.cancelTimer = this.options.scheduler.schedule(() => {\n this.settle(\n request.context.callId,\n new ApiCallTimeoutError(\n this.options.timeoutMs,\n // IPC contracts declare no @Endpoint operation, so the deadline reports the\n // conservative WRITE: the user is told to check before repeating the call.\n new CallContext(request.apiId, request.methodId, WRITE),\n ),\n 'expired',\n );\n }, this.options.timeoutMs);\n // This owner observes every async send rejection; a send failure is never a timeout.\n void this.send(request).catch((error) => {\n this.settle(\n request.context.callId,\n new IpcTransportError('IPC send failed', IpcErrors.normalize(error)),\n 'rejected',\n );\n });\n });\n }\n\n dispose(): void {\n this.fail(new IpcTransportError('IPC connection disposed'));\n this.unsubscribe();\n this.transport.close();\n }\n\n private async send(message: IpcMessage): Promise<void> {\n if (this.closed) throw this.closed;\n const json = JSON.stringify(message);\n if (json.length > this.options.maxMessageCharacters)\n throw new ApiImplementationError('IPC message exceeds configured limit');\n await this.transport.send(json);\n }\n\n private receive(json: string): void {\n if (this.closed) return;\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- transport boundary rejects pending calls or encodes a failure that the client throws\n try {\n if (json.length > this.options.maxMessageCharacters)\n throw new ApiImplementationError('IPC message exceeds configured limit');\n const message = IpcProtocol.parse(json);\n if (message.type === 'request') {\n if (this.activeRequests.has(message.context.callId))\n throw new ApiImplementationError('Duplicate active IPC request');\n this.activeRequests.add(message.context.callId);\n void this.dispatch(message).catch((error) => this.fail(IpcErrors.normalize(error)));\n return;\n }\n const pending = this.pending.get(message.context.callId);\n // Late or unsolicited replies are reported, never resolve a different call or replay work.\n if (!pending) {\n this.options.errors.report(this.lateReplyError(message));\n return;\n }\n if (!IpcProtocol.sameContext(pending.context, message.context))\n throw this.correlationError(message, pending.context);\n this.pending.delete(message.context.callId);\n pending.cancelTimer();\n this.remember(pending.context, 'resolved');\n pending.resolve(message);\n } catch (err: unknown) {\n const error = toError(err);\n this.fail(IpcErrors.normalize(error));\n }\n }\n\n private async dispatch(request: IpcRequest): Promise<void> {\n let reply: IpcReply;\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- transport boundary rejects pending calls or encodes a failure that the client throws\n try {\n if (!this.handler)\n throw new ApiEndpointNotFoundError('IPC dispatcher is not installed');\n reply = await this.handler(request);\n if (!IpcProtocol.sameContext(request.context, reply.context))\n throw new ApiImplementationError('IPC handler reply correlation mismatch');\n } catch (err: unknown) {\n const error = toError(err);\n // The ONE app-reachable seam for an outbound IPC failure. The webpieces default applies the\n // same `ApiErrorBoundary` publication rule this used to call inline — notably that an\n // `ApiConnectionError` publishes as `implementation`, because to the PEER this process is\n // what is broken.\n reply = new IpcFailure(request.context, IpcRegistry.getErrorTranslator().toWire(error));\n } finally {\n this.activeRequests.delete(request.context.callId);\n }\n await this.send(reply);\n }\n\n private settle(id: string, error: Error, reason: SettlementReason): void {\n const pending = this.pending.get(id);\n if (!pending) return;\n this.pending.delete(id);\n pending.cancelTimer();\n this.remember(pending.context, reason);\n pending.reject(error);\n }\n\n private remember(context: IpcCallContext, reason: SettlementReason): void {\n this.settlements.delete(context.callId);\n this.settlements.set(context.callId, new SettlementRecord(context, reason, Date.now()));\n while (this.settlements.size > this.options.settlementHistoryLimit) {\n const oldest = this.settlements.keys().next().value;\n if (typeof oldest !== 'string') return;\n this.settlements.delete(oldest);\n }\n }\n\n private lateReplyError(reply: IpcReply): ApiImplementationError {\n const previous = this.settlements.get(reply.context.callId);\n let classification = 'unknown';\n if (previous) {\n classification = IpcProtocol.sameContext(previous.context, reply.context)\n ? previous.reason === 'expired'\n ? 'expired'\n : 'duplicate-settled'\n : 'correlation-mismatched';\n }\n const settlement = previous\n ? ` terminal=${previous.reason} ageMs=${String(Math.max(0, Date.now() - previous.settledAt))}`\n : '';\n return new ApiImplementationError(\n `Late or unknown IPC reply classification=${classification}${settlement} ${this.correlationFields(reply.context)}`,\n );\n }\n\n private correlationError(reply: IpcReply, expected: IpcCallContext): ApiImplementationError {\n return new ApiImplementationError(\n `IPC reply correlation mismatch classification=correlation-mismatched ` +\n `${this.correlationFields(reply.context)} expectedTxId=${JSON.stringify(expected.txId)}`,\n );\n }\n\n private correlationFields(context: IpcCallContext): string {\n return (\n `callId=${JSON.stringify(context.callId)} txId=${JSON.stringify(context.txId)} ` +\n `parentCallId=${JSON.stringify(context.parentCallId ?? null)} ` +\n `connectionId=${JSON.stringify(this.options.connectionId)}`\n );\n }\n\n private fail(error: Error): void {\n if (this.closed) return;\n this.closed = error;\n for (const id of this.pending.keys()) this.settle(id, error, 'rejected');\n this.options.errors.report(error);\n }\n}\n\nexport class IpcErrors {\n // webpieces-disable no-function-outside-class -- portable stateless IPC primitive; no platform DI container exists on this boundary; webpieces-disable no-any-unknown -- untrusted IPC data is schema-validated; generic dispatch cannot assume a DTO type before validation\n static normalize(value: unknown): Error {\n return value instanceof Error\n ? value\n : new ApiImplementationError('IPC failed with a non-Error value');\n }\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  import { ApiErrorPayload } from '../errors/ApiErrorCodec';
2
+ import { ClientRole } from '../errors/ClientRole';
2
3
  import { IpcReply } from './IpcProtocol';
3
4
  /**
4
5
  * IpcErrorTranslator - ONE symmetric place an app owns IPC error translation, in BOTH directions.
@@ -33,7 +34,10 @@ export interface IpcErrorTranslator {
33
34
  * HTTP side, so an app can turn a "successful" reply into a throw. Returning normally means "let
34
35
  * this reply through"; the webpieces default returns for an `IpcSuccess` and throws for an
35
36
  * `IpcFailure`. Decline by calling
36
- * `new WebpiecesDefaultIpcErrorTranslator().fromWire(reply)`.
37
+ * `new WebpiecesDefaultIpcErrorTranslator().fromWire(reply, role)`.
38
+ *
39
+ * `role` is WHO is receiving ({@link ClientRole}), declared once at `IpcClientFactory` setup with
40
+ * no default. It decides what a received `unauthorized` means; pass it through when declining.
37
41
  */
38
- fromWire(reply: IpcReply): void;
42
+ fromWire(reply: IpcReply, role: ClientRole): void;
39
43
  }
@@ -1 +1 @@
1
- {"version":3,"file":"IpcErrorTranslator.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/ipc/IpcErrorTranslator.ts"],"names":[],"mappings":"","sourcesContent":["import { ApiErrorPayload } from '../errors/ApiErrorCodec';\nimport { IpcReply } from './IpcProtocol';\n\n/**\n * IpcErrorTranslator - ONE symmetric place an app owns IPC error translation, in BOTH directions.\n *\n * The exact twin of `ErrorTranslator` for HTTP, down to the shape of each half: `toWire` is called in\n * a catch and RETURNS the payload the reply carries, `fromWire` is its mirror and THROWS. It exists\n * for the same reason: IPC already HAD both halves, hand-rolled at three call sites\n * (`IpcServerFactory.handle`, `IpcConnection.dispatch`, `IpcClientFactory`), with no seam an app could\n * reach. An app whose two processes share an error taxonomy had nowhere to put it.\n *\n * Register one with {@link IpcRegistry.setErrorTranslator} — one registry per PROTOCOL, mirroring\n * `ClientRegistry` for HTTP and `McpRegistry` for MCP, because the three speak different wire shapes\n * and an app rarely wants the same answer on all three.\n *\n * There is ALWAYS a translator ({@link IpcRegistry.getErrorTranslator} is non-optional), so every call\n * site is one unconditional line and a registered translator declines by DELEGATING to\n * {@link WebpiecesDefaultIpcErrorTranslator}.\n *\n * This is a business-logic contract (methods, not data), so it is an interface per the webpieces\n * guidelines.\n */\nexport interface IpcErrorTranslator {\n /**\n * SERVER: exception -> the wire payload carried by `IpcFailure`. Always a payload; decline by\n * returning `new WebpiecesDefaultIpcErrorTranslator().toWire(error)`, which applies the shared\n * `ApiErrorBoundary` publication rule (notably: a caller-local `ApiConnectionError` publishes as\n * `implementation`, because to the PEER this process is what is broken).\n */\n toWire(error: Error): ApiErrorPayload;\n\n /**\n * CLIENT: the reply -> a THROW. Called for EVERY reply, success or failure, exactly as on the\n * HTTP side, so an app can turn a \"successful\" reply into a throw. Returning normally means \"let\n * this reply through\"; the webpieces default returns for an `IpcSuccess` and throws for an\n * `IpcFailure`. Decline by calling\n * `new WebpiecesDefaultIpcErrorTranslator().fromWire(reply)`.\n */\n fromWire(reply: IpcReply): void;\n}\n"]}
1
+ {"version":3,"file":"IpcErrorTranslator.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/ipc/IpcErrorTranslator.ts"],"names":[],"mappings":"","sourcesContent":["import { ApiErrorPayload } from '../errors/ApiErrorCodec';\nimport { ClientRole } from '../errors/ClientRole';\nimport { IpcReply } from './IpcProtocol';\n\n/**\n * IpcErrorTranslator - ONE symmetric place an app owns IPC error translation, in BOTH directions.\n *\n * The exact twin of `ErrorTranslator` for HTTP, down to the shape of each half: `toWire` is called in\n * a catch and RETURNS the payload the reply carries, `fromWire` is its mirror and THROWS. It exists\n * for the same reason: IPC already HAD both halves, hand-rolled at three call sites\n * (`IpcServerFactory.handle`, `IpcConnection.dispatch`, `IpcClientFactory`), with no seam an app could\n * reach. An app whose two processes share an error taxonomy had nowhere to put it.\n *\n * Register one with {@link IpcRegistry.setErrorTranslator} — one registry per PROTOCOL, mirroring\n * `ClientRegistry` for HTTP and `McpRegistry` for MCP, because the three speak different wire shapes\n * and an app rarely wants the same answer on all three.\n *\n * There is ALWAYS a translator ({@link IpcRegistry.getErrorTranslator} is non-optional), so every call\n * site is one unconditional line and a registered translator declines by DELEGATING to\n * {@link WebpiecesDefaultIpcErrorTranslator}.\n *\n * This is a business-logic contract (methods, not data), so it is an interface per the webpieces\n * guidelines.\n */\nexport interface IpcErrorTranslator {\n /**\n * SERVER: exception -> the wire payload carried by `IpcFailure`. Always a payload; decline by\n * returning `new WebpiecesDefaultIpcErrorTranslator().toWire(error)`, which applies the shared\n * `ApiErrorBoundary` publication rule (notably: a caller-local `ApiConnectionError` publishes as\n * `implementation`, because to the PEER this process is what is broken).\n */\n toWire(error: Error): ApiErrorPayload;\n\n /**\n * CLIENT: the reply -> a THROW. Called for EVERY reply, success or failure, exactly as on the\n * HTTP side, so an app can turn a \"successful\" reply into a throw. Returning normally means \"let\n * this reply through\"; the webpieces default returns for an `IpcSuccess` and throws for an\n * `IpcFailure`. Decline by calling\n * `new WebpiecesDefaultIpcErrorTranslator().fromWire(reply, role)`.\n *\n * `role` is WHO is receiving ({@link ClientRole}), declared once at `IpcClientFactory` setup with\n * no default. It decides what a received `unauthorized` means; pass it through when declining.\n */\n fromWire(reply: IpcReply, role: ClientRole): void;\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import { ClientRole } from '../errors/ClientRole';
1
2
  import { IpcErrorTranslator } from './IpcErrorTranslator';
2
3
  import { IpcReply, IpcSuccess } from './IpcProtocol';
3
4
  /**
@@ -50,6 +51,8 @@ export declare class IpcClientErrorTranslator {
50
51
  * normally for a failure reply has a bug whose symptom would otherwise be `undefined` arriving
51
52
  * where the contract promised a DTO. For a genuine success the default returns immediately, so
52
53
  * the normal path costs one comparison.
54
+ *
55
+ * @param role - who is receiving, from the `IpcClientFactory` that sent the request.
53
56
  */
54
- static throwIfFailure(reply: IpcReply): asserts reply is IpcSuccess;
57
+ static throwIfFailure(reply: IpcReply, role: ClientRole): asserts reply is IpcSuccess;
55
58
  }
@@ -62,11 +62,13 @@ class IpcClientErrorTranslator {
62
62
  * normally for a failure reply has a bug whose symptom would otherwise be `undefined` arriving
63
63
  * where the contract promised a DTO. For a genuine success the default returns immediately, so
64
64
  * the normal path costs one comparison.
65
+ *
66
+ * @param role - who is receiving, from the `IpcClientFactory` that sent the request.
65
67
  */
66
68
  // webpieces-disable no-function-outside-class -- stateless boundary shared by every IPC client proxy
67
- static throwIfFailure(reply) {
68
- IpcRegistry.getErrorTranslator().fromWire(reply);
69
- WebpiecesDefaultIpcErrorTranslator_1.WEBPIECES_DEFAULT_IPC_ERROR_TRANSLATOR.fromWire(reply);
69
+ static throwIfFailure(reply, role) {
70
+ IpcRegistry.getErrorTranslator().fromWire(reply, role);
71
+ WebpiecesDefaultIpcErrorTranslator_1.WEBPIECES_DEFAULT_IPC_ERROR_TRANSLATOR.fromWire(reply, role);
70
72
  }
71
73
  }
72
74
  exports.IpcClientErrorTranslator = IpcClientErrorTranslator;
@@ -1 +1 @@
1
- {"version":3,"file":"IpcRegistry.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/ipc/IpcRegistry.ts"],"names":[],"mappings":";;;AAEA,6FAA8F;AAE9F;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,WAAW;IACpB;;;;OAIG;IACK,MAAM,CAAC,eAAe,GAAuB,2EAAsC,CAAC;IAE5F;;;OAGG;IACH,4JAA4J;IAC5J,MAAM,CAAC,kBAAkB,CAAC,UAA8B;QACpD,WAAW,CAAC,eAAe,GAAG,UAAU,CAAC;IAC7C,CAAC;IAED,kGAAkG;IAClG,4JAA4J;IAC5J,MAAM,CAAC,kBAAkB;QACrB,OAAO,WAAW,CAAC,eAAe,CAAC;IACvC,CAAC;IAED,6FAA6F;IAC7F,4JAA4J;IAC5J,MAAM,CAAC,aAAa;QAChB,WAAW,CAAC,eAAe,GAAG,2EAAsC,CAAC;IACzE,CAAC;;AA3BL,kCA4BC;AAED;;;;;;;GAOG;AACH,MAAa,wBAAwB;IACjC;;;;;;;OAOG;IACH,qGAAqG;IACrG,MAAM,CAAC,cAAc,CAAC,KAAe;QACjC,WAAW,CAAC,kBAAkB,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACjD,2EAAsC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC3D,CAAC;CACJ;AAdD,4DAcC","sourcesContent":["import { IpcErrorTranslator } from './IpcErrorTranslator';\nimport { IpcReply, IpcSuccess } from './IpcProtocol';\nimport { WEBPIECES_DEFAULT_IPC_ERROR_TRANSLATOR } from './WebpiecesDefaultIpcErrorTranslator';\n\n/**\n * IpcRegistry - the process-global home of the ONE {@link IpcErrorTranslator}, mirroring\n * `ClientRegistry` for HTTP and `McpRegistry` for MCP.\n *\n * ONE REGISTRY PER PROTOCOL, and that is the design: the three speak different wire shapes\n * (`HttpResponseDto`, `CallToolResult`, `ApiErrorPayload`), so one combined registry would either\n * force an app to answer three unrelated questions in one object or hide two of them behind\n * optionality. Three registries, three unconditional call sites.\n *\n * Configured like `HeaderRegistry` / `ClientRegistry` / LogManager — populated once at startup, then\n * globally accessible with NO DI wiring.\n *\n * ```ts\n * // startup, ONCE per process, in BOTH processes that share the connection\n * IpcRegistry.setErrorTranslator(new MyIpcErrorTranslator());\n * ```\n */\nexport class IpcRegistry {\n /**\n * THE translator. NEVER undefined — it starts life holding\n * {@link WEBPIECES_DEFAULT_IPC_ERROR_TRANSLATOR}, and {@link IpcRegistry.setErrorTranslator}\n * REPLACES it. So no IPC call site asks \"did anyone register one\".\n */\n private static errorTranslator: IpcErrorTranslator = WEBPIECES_DEFAULT_IPC_ERROR_TRANSLATOR;\n\n /**\n * Install the app's {@link IpcErrorTranslator}. `set`, not `add`: an app with several layers of\n * error policy composes them INSIDE its own `toWire`, where the precedence is written down.\n */\n // webpieces-disable no-function-outside-class -- static global singleton (like HeaderRegistry/ClientRegistry); populated once at startup, never DI-injected\n static setErrorTranslator(translator: IpcErrorTranslator): void {\n IpcRegistry.errorTranslator = translator;\n }\n\n /** THE {@link IpcErrorTranslator} for this process — never `undefined`, so no caller branches. */\n // webpieces-disable no-function-outside-class -- static global singleton (like HeaderRegistry/ClientRegistry); populated once at startup, never DI-injected\n static getErrorTranslator(): IpcErrorTranslator {\n return IpcRegistry.errorTranslator;\n }\n\n /** Put the process-global back to the webpieces default. For TESTS, so specs cannot leak. */\n // webpieces-disable no-function-outside-class -- static global singleton (like HeaderRegistry/ClientRegistry); populated once at startup, never DI-injected\n static resetForTests(): void {\n IpcRegistry.errorTranslator = WEBPIECES_DEFAULT_IPC_ERROR_TRANSLATOR;\n }\n}\n\n/**\n * The CLIENT half's one call site, and the guarantee behind it — the IPC twin of\n * `ClientErrorTranslator.throwIfFailure`.\n *\n * The `asserts` return type is what lets `IpcClientFactory` read the success body straight afterwards\n * with no `if (reply.type === 'failure')` branch left over: after this call the compiler knows the\n * reply is an {@link IpcSuccess}, because the only way past it is that it is one.\n */\nexport class IpcClientErrorTranslator {\n /**\n * Run `fromWire` over a reply, and make it impossible for an `IpcFailure` to be read as data.\n *\n * The second call is BUG CONTAINMENT, not a fallback branch: an app translator that returns\n * normally for a failure reply has a bug whose symptom would otherwise be `undefined` arriving\n * where the contract promised a DTO. For a genuine success the default returns immediately, so\n * the normal path costs one comparison.\n */\n // webpieces-disable no-function-outside-class -- stateless boundary shared by every IPC client proxy\n static throwIfFailure(reply: IpcReply): asserts reply is IpcSuccess {\n IpcRegistry.getErrorTranslator().fromWire(reply);\n WEBPIECES_DEFAULT_IPC_ERROR_TRANSLATOR.fromWire(reply);\n }\n}\n"]}
1
+ {"version":3,"file":"IpcRegistry.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/ipc/IpcRegistry.ts"],"names":[],"mappings":";;;AAGA,6FAA8F;AAE9F;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,WAAW;IACpB;;;;OAIG;IACK,MAAM,CAAC,eAAe,GAAuB,2EAAsC,CAAC;IAE5F;;;OAGG;IACH,4JAA4J;IAC5J,MAAM,CAAC,kBAAkB,CAAC,UAA8B;QACpD,WAAW,CAAC,eAAe,GAAG,UAAU,CAAC;IAC7C,CAAC;IAED,kGAAkG;IAClG,4JAA4J;IAC5J,MAAM,CAAC,kBAAkB;QACrB,OAAO,WAAW,CAAC,eAAe,CAAC;IACvC,CAAC;IAED,6FAA6F;IAC7F,4JAA4J;IAC5J,MAAM,CAAC,aAAa;QAChB,WAAW,CAAC,eAAe,GAAG,2EAAsC,CAAC;IACzE,CAAC;;AA3BL,kCA4BC;AAED;;;;;;;GAOG;AACH,MAAa,wBAAwB;IACjC;;;;;;;;;OASG;IACH,qGAAqG;IACrG,MAAM,CAAC,cAAc,CAAC,KAAe,EAAE,IAAgB;QACnD,WAAW,CAAC,kBAAkB,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACvD,2EAAsC,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACjE,CAAC;CACJ;AAhBD,4DAgBC","sourcesContent":["import { ClientRole } from '../errors/ClientRole';\nimport { IpcErrorTranslator } from './IpcErrorTranslator';\nimport { IpcReply, IpcSuccess } from './IpcProtocol';\nimport { WEBPIECES_DEFAULT_IPC_ERROR_TRANSLATOR } from './WebpiecesDefaultIpcErrorTranslator';\n\n/**\n * IpcRegistry - the process-global home of the ONE {@link IpcErrorTranslator}, mirroring\n * `ClientRegistry` for HTTP and `McpRegistry` for MCP.\n *\n * ONE REGISTRY PER PROTOCOL, and that is the design: the three speak different wire shapes\n * (`HttpResponseDto`, `CallToolResult`, `ApiErrorPayload`), so one combined registry would either\n * force an app to answer three unrelated questions in one object or hide two of them behind\n * optionality. Three registries, three unconditional call sites.\n *\n * Configured like `HeaderRegistry` / `ClientRegistry` / LogManager — populated once at startup, then\n * globally accessible with NO DI wiring.\n *\n * ```ts\n * // startup, ONCE per process, in BOTH processes that share the connection\n * IpcRegistry.setErrorTranslator(new MyIpcErrorTranslator());\n * ```\n */\nexport class IpcRegistry {\n /**\n * THE translator. NEVER undefined — it starts life holding\n * {@link WEBPIECES_DEFAULT_IPC_ERROR_TRANSLATOR}, and {@link IpcRegistry.setErrorTranslator}\n * REPLACES it. So no IPC call site asks \"did anyone register one\".\n */\n private static errorTranslator: IpcErrorTranslator = WEBPIECES_DEFAULT_IPC_ERROR_TRANSLATOR;\n\n /**\n * Install the app's {@link IpcErrorTranslator}. `set`, not `add`: an app with several layers of\n * error policy composes them INSIDE its own `toWire`, where the precedence is written down.\n */\n // webpieces-disable no-function-outside-class -- static global singleton (like HeaderRegistry/ClientRegistry); populated once at startup, never DI-injected\n static setErrorTranslator(translator: IpcErrorTranslator): void {\n IpcRegistry.errorTranslator = translator;\n }\n\n /** THE {@link IpcErrorTranslator} for this process — never `undefined`, so no caller branches. */\n // webpieces-disable no-function-outside-class -- static global singleton (like HeaderRegistry/ClientRegistry); populated once at startup, never DI-injected\n static getErrorTranslator(): IpcErrorTranslator {\n return IpcRegistry.errorTranslator;\n }\n\n /** Put the process-global back to the webpieces default. For TESTS, so specs cannot leak. */\n // webpieces-disable no-function-outside-class -- static global singleton (like HeaderRegistry/ClientRegistry); populated once at startup, never DI-injected\n static resetForTests(): void {\n IpcRegistry.errorTranslator = WEBPIECES_DEFAULT_IPC_ERROR_TRANSLATOR;\n }\n}\n\n/**\n * The CLIENT half's one call site, and the guarantee behind it — the IPC twin of\n * `ClientErrorTranslator.throwIfFailure`.\n *\n * The `asserts` return type is what lets `IpcClientFactory` read the success body straight afterwards\n * with no `if (reply.type === 'failure')` branch left over: after this call the compiler knows the\n * reply is an {@link IpcSuccess}, because the only way past it is that it is one.\n */\nexport class IpcClientErrorTranslator {\n /**\n * Run `fromWire` over a reply, and make it impossible for an `IpcFailure` to be read as data.\n *\n * The second call is BUG CONTAINMENT, not a fallback branch: an app translator that returns\n * normally for a failure reply has a bug whose symptom would otherwise be `undefined` arriving\n * where the contract promised a DTO. For a genuine success the default returns immediately, so\n * the normal path costs one comparison.\n *\n * @param role - who is receiving, from the `IpcClientFactory` that sent the request.\n */\n // webpieces-disable no-function-outside-class -- stateless boundary shared by every IPC client proxy\n static throwIfFailure(reply: IpcReply, role: ClientRole): asserts reply is IpcSuccess {\n IpcRegistry.getErrorTranslator().fromWire(reply, role);\n WEBPIECES_DEFAULT_IPC_ERROR_TRANSLATOR.fromWire(reply, role);\n }\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  import { ApiErrorPayload } from '../errors/ApiErrorCodec';
2
+ import { ClientRole } from '../errors/ClientRole';
2
3
  import { IpcErrorTranslator } from './IpcErrorTranslator';
3
4
  import { IpcReply } from './IpcProtocol';
4
5
  /**
@@ -14,7 +15,9 @@ import { IpcReply } from './IpcProtocol';
14
15
  * caller-error kind coming back means I sent a bad IPC request (MY bug ->
15
16
  * `ApiImplementationError`), a server-side kind means the peer broke (NOT my bug ->
16
17
  * `ApiDependencyError`), an incoming `ApiDependencyError` is already attributed and rethrows as-is,
17
- * and an `ApiEndUserError` is the actor's own answer and passes through.
18
+ * an `ApiEndUserError` is the actor's own answer and passes through (as its registered subclass), an
19
+ * `ApiClientTooOldError` passes through on every hop, and an `unauthorized` reply depends on the
20
+ * receiving {@link ClientRole}.
18
21
  *
19
22
  * The two protocols share ONE rule object rather than two copies for the obvious reason: an app that
20
23
  * moves a call from IPC to HTTP or back must not thereby change which team gets paged.
@@ -22,7 +25,8 @@ import { IpcReply } from './IpcProtocol';
22
25
  export declare class WebpiecesDefaultIpcErrorTranslator implements IpcErrorTranslator {
23
26
  private readonly boundary;
24
27
  toWire(error: Error): ApiErrorPayload;
25
- fromWire(reply: IpcReply): void;
28
+ /** @param role - who is receiving, declared at `IpcClientFactory` setup. Decides what a 401 means. */
29
+ fromWire(reply: IpcReply, role: ClientRole): void;
26
30
  }
27
31
  /** Process-wide built-in instance — stateless, so one shared instance is enough. */
28
32
  export declare const WEBPIECES_DEFAULT_IPC_ERROR_TRANSLATOR: WebpiecesDefaultIpcErrorTranslator;
@@ -19,7 +19,9 @@ const ApiErrorHttpStatus_1 = require("../http/ApiErrorHttpStatus");
19
19
  * caller-error kind coming back means I sent a bad IPC request (MY bug ->
20
20
  * `ApiImplementationError`), a server-side kind means the peer broke (NOT my bug ->
21
21
  * `ApiDependencyError`), an incoming `ApiDependencyError` is already attributed and rethrows as-is,
22
- * and an `ApiEndUserError` is the actor's own answer and passes through.
22
+ * an `ApiEndUserError` is the actor's own answer and passes through (as its registered subclass), an
23
+ * `ApiClientTooOldError` passes through on every hop, and an `unauthorized` reply depends on the
24
+ * receiving {@link ClientRole}.
23
25
  *
24
26
  * The two protocols share ONE rule object rather than two copies for the obvious reason: an app that
25
27
  * moves a call from IPC to HTTP or back must not thereby change which team gets paged.
@@ -29,7 +31,8 @@ class WebpiecesDefaultIpcErrorTranslator {
29
31
  toWire(error) {
30
32
  return this.boundary.encode(error);
31
33
  }
32
- fromWire(reply) {
34
+ /** @param role - who is receiving, declared at `IpcClientFactory` setup. Decides what a 401 means. */
35
+ fromWire(reply, role) {
33
36
  if (reply.type === 'success') {
34
37
  return;
35
38
  }
@@ -40,7 +43,7 @@ class WebpiecesDefaultIpcErrorTranslator {
40
43
  const equivalent = ApiErrorHttpStatus_1.ApiErrorHttpStatus.hasCode(decoded)
41
44
  ? ApiErrorHttpStatus_1.ApiErrorHttpStatus.codeFor(decoded.kind, statusCode)
42
45
  : 500;
43
- throw ReceivedApiErrorRule_1.ReceivedApiErrorRule.adapt(equivalent, decoded.message, decoded);
46
+ throw ReceivedApiErrorRule_1.ReceivedApiErrorRule.adapt(role, equivalent, decoded.message, decoded);
44
47
  }
45
48
  }
46
49
  exports.WebpiecesDefaultIpcErrorTranslator = WebpiecesDefaultIpcErrorTranslator;
@@ -1 +1 @@
1
- {"version":3,"file":"WebpiecesDefaultIpcErrorTranslator.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/ipc/WebpiecesDefaultIpcErrorTranslator.ts"],"names":[],"mappings":";;;AAAA,iEAA8D;AAC9D,2DAAyE;AACzE,iDAAmD;AACnD,yEAAsE;AACtE,mEAAgE;AAIhE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAa,kCAAkC;IAC1B,QAAQ,GAAG,IAAI,mCAAgB,EAAE,CAAC;IAEnD,MAAM,CAAC,KAAY;QACf,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;IAED,QAAQ,CAAC,KAAe;QACpB,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC3B,OAAO;QACX,CAAC;QACD,MAAM,OAAO,GAAG,6BAAa,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAClD,2FAA2F;QAC3F,8FAA8F;QAC9F,MAAM,UAAU,GAAG,OAAO,YAAY,wBAAa,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;QACrF,MAAM,UAAU,GAAG,uCAAkB,CAAC,OAAO,CAAC,OAAO,CAAC;YAClD,CAAC,CAAC,uCAAkB,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC;YACtD,CAAC,CAAC,GAAG,CAAC;QACV,MAAM,2CAAoB,CAAC,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC3E,CAAC;CACJ;AApBD,gFAoBC;AAED,oFAAoF;AACvE,QAAA,sCAAsC,GAAG,IAAI,kCAAkC,EAAE,CAAC","sourcesContent":["import { ApiErrorBoundary } from '../errors/ApiErrorBoundary';\nimport { ApiErrorCodec, ApiErrorPayload } from '../errors/ApiErrorCodec';\nimport { ApiCodedError } from '../errors/ApiError';\nimport { ReceivedApiErrorRule } from '../errors/ReceivedApiErrorRule';\nimport { ApiErrorHttpStatus } from '../http/ApiErrorHttpStatus';\nimport { IpcErrorTranslator } from './IpcErrorTranslator';\nimport { IpcReply } from './IpcProtocol';\n\n/**\n * THE webpieces default {@link IpcErrorTranslator}, and what {@link IpcRegistry} holds until an app\n * installs its own.\n *\n * `toWire` is exactly what the two IPC receivers did inline before this seam existed — the shared\n * {@link ApiErrorBoundary}, so the `ApiConnectionError` -> `implementation` rule survives untouched.\n *\n * `fromWire` is a BEHAVIOUR CHANGE and a deliberate one. `IpcClientFactory` used to rethrow\n * `ApiErrorCodec.decode(reply.error)` verbatim, which handed the caller the PEER's error type as if\n * this process had produced it. IPC now applies the SAME {@link ReceivedApiErrorRule} as HTTP: a\n * caller-error kind coming back means I sent a bad IPC request (MY bug ->\n * `ApiImplementationError`), a server-side kind means the peer broke (NOT my bug ->\n * `ApiDependencyError`), an incoming `ApiDependencyError` is already attributed and rethrows as-is,\n * and an `ApiEndUserError` is the actor's own answer and passes through.\n *\n * The two protocols share ONE rule object rather than two copies for the obvious reason: an app that\n * moves a call from IPC to HTTP or back must not thereby change which team gets paged.\n */\nexport class WebpiecesDefaultIpcErrorTranslator implements IpcErrorTranslator {\n private readonly boundary = new ApiErrorBoundary();\n\n toWire(error: Error): ApiErrorPayload {\n return this.boundary.encode(error);\n }\n\n fromWire(reply: IpcReply): void {\n if (reply.type === 'success') {\n return;\n }\n const decoded = ApiErrorCodec.decode(reply.error);\n // IPC has no wire status, so the equivalent is derived from the payload's own kind through\n // the ONE status table HTTP uses. Same table, same verdict, no second ladder to keep in step.\n const statusCode = decoded instanceof ApiCodedError ? decoded.statusCode : undefined;\n const equivalent = ApiErrorHttpStatus.hasCode(decoded)\n ? ApiErrorHttpStatus.codeFor(decoded.kind, statusCode)\n : 500;\n throw ReceivedApiErrorRule.adapt(equivalent, decoded.message, decoded);\n }\n}\n\n/** Process-wide built-in instance — stateless, so one shared instance is enough. */\nexport const WEBPIECES_DEFAULT_IPC_ERROR_TRANSLATOR = new WebpiecesDefaultIpcErrorTranslator();\n"]}
1
+ {"version":3,"file":"WebpiecesDefaultIpcErrorTranslator.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/ipc/WebpiecesDefaultIpcErrorTranslator.ts"],"names":[],"mappings":";;;AAAA,iEAA8D;AAC9D,2DAAyE;AACzE,iDAAmD;AAEnD,yEAAsE;AACtE,mEAAgE;AAIhE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAa,kCAAkC;IAC1B,QAAQ,GAAG,IAAI,mCAAgB,EAAE,CAAC;IAEnD,MAAM,CAAC,KAAY;QACf,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;IAED,sGAAsG;IACtG,QAAQ,CAAC,KAAe,EAAE,IAAgB;QACtC,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC3B,OAAO;QACX,CAAC;QACD,MAAM,OAAO,GAAG,6BAAa,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAClD,2FAA2F;QAC3F,8FAA8F;QAC9F,MAAM,UAAU,GAAG,OAAO,YAAY,wBAAa,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;QACrF,MAAM,UAAU,GAAG,uCAAkB,CAAC,OAAO,CAAC,OAAO,CAAC;YAClD,CAAC,CAAC,uCAAkB,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC;YACtD,CAAC,CAAC,GAAG,CAAC;QACV,MAAM,2CAAoB,CAAC,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACjF,CAAC;CACJ;AArBD,gFAqBC;AAED,oFAAoF;AACvE,QAAA,sCAAsC,GAAG,IAAI,kCAAkC,EAAE,CAAC","sourcesContent":["import { ApiErrorBoundary } from '../errors/ApiErrorBoundary';\nimport { ApiErrorCodec, ApiErrorPayload } from '../errors/ApiErrorCodec';\nimport { ApiCodedError } from '../errors/ApiError';\nimport { ClientRole } from '../errors/ClientRole';\nimport { ReceivedApiErrorRule } from '../errors/ReceivedApiErrorRule';\nimport { ApiErrorHttpStatus } from '../http/ApiErrorHttpStatus';\nimport { IpcErrorTranslator } from './IpcErrorTranslator';\nimport { IpcReply } from './IpcProtocol';\n\n/**\n * THE webpieces default {@link IpcErrorTranslator}, and what {@link IpcRegistry} holds until an app\n * installs its own.\n *\n * `toWire` is exactly what the two IPC receivers did inline before this seam existed — the shared\n * {@link ApiErrorBoundary}, so the `ApiConnectionError` -> `implementation` rule survives untouched.\n *\n * `fromWire` is a BEHAVIOUR CHANGE and a deliberate one. `IpcClientFactory` used to rethrow\n * `ApiErrorCodec.decode(reply.error)` verbatim, which handed the caller the PEER's error type as if\n * this process had produced it. IPC now applies the SAME {@link ReceivedApiErrorRule} as HTTP: a\n * caller-error kind coming back means I sent a bad IPC request (MY bug ->\n * `ApiImplementationError`), a server-side kind means the peer broke (NOT my bug ->\n * `ApiDependencyError`), an incoming `ApiDependencyError` is already attributed and rethrows as-is,\n * an `ApiEndUserError` is the actor's own answer and passes through (as its registered subclass), an\n * `ApiClientTooOldError` passes through on every hop, and an `unauthorized` reply depends on the\n * receiving {@link ClientRole}.\n *\n * The two protocols share ONE rule object rather than two copies for the obvious reason: an app that\n * moves a call from IPC to HTTP or back must not thereby change which team gets paged.\n */\nexport class WebpiecesDefaultIpcErrorTranslator implements IpcErrorTranslator {\n private readonly boundary = new ApiErrorBoundary();\n\n toWire(error: Error): ApiErrorPayload {\n return this.boundary.encode(error);\n }\n\n /** @param role - who is receiving, declared at `IpcClientFactory` setup. Decides what a 401 means. */\n fromWire(reply: IpcReply, role: ClientRole): void {\n if (reply.type === 'success') {\n return;\n }\n const decoded = ApiErrorCodec.decode(reply.error);\n // IPC has no wire status, so the equivalent is derived from the payload's own kind through\n // the ONE status table HTTP uses. Same table, same verdict, no second ladder to keep in step.\n const statusCode = decoded instanceof ApiCodedError ? decoded.statusCode : undefined;\n const equivalent = ApiErrorHttpStatus.hasCode(decoded)\n ? ApiErrorHttpStatus.codeFor(decoded.kind, statusCode)\n : 500;\n throw ReceivedApiErrorRule.adapt(role, equivalent, decoded.message, decoded);\n }\n}\n\n/** Process-wide built-in instance — stateless, so one shared instance is enough. */\nexport const WEBPIECES_DEFAULT_IPC_ERROR_TRANSLATOR = new WebpiecesDefaultIpcErrorTranslator();\n"]}
@@ -8,6 +8,7 @@ export { IpcRegistry, IpcClientErrorTranslator } from './IpcRegistry';
8
8
  export type { IpcErrorTranslator } from './IpcErrorTranslator';
9
9
  export { WebpiecesDefaultIpcErrorTranslator, WEBPIECES_DEFAULT_IPC_ERROR_TRANSLATOR, } from './WebpiecesDefaultIpcErrorTranslator';
10
10
  export { ApiErrorPayload } from '../errors/ApiErrorCodec';
11
+ export { ClientRole } from '../errors/ClientRole';
11
12
  export type { IpcTransport, IpcScheduler, IpcErrorOwner } from './IpcConnection';
12
13
  export { IpcCallLogger } from './IpcLogging';
13
14
  export type { IpcLogging } from './IpcLogging';
package/src/ipc/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toError = exports.ApiCallTimeoutError = exports.LogApiCallImpl = exports.ApiMethodInfo = exports.MaskLog = exports.MaskSpec = exports.IpcCallLogger = exports.ApiErrorPayload = exports.WEBPIECES_DEFAULT_IPC_ERROR_TRANSLATOR = exports.WebpiecesDefaultIpcErrorTranslator = exports.IpcClientErrorTranslator = exports.IpcRegistry = exports.IpcErrors = exports.IpcTransportError = exports.IpcConnectionOptions = exports.IpcConnection = exports.IpcProtocol = exports.IpcFailure = exports.IpcSuccess = exports.IpcRequest = exports.IpcCallContext = exports.IPC_METADATA_KEYS = exports.assertNotInternalApi = exports.assertInternalApi = exports.getIpcMaskSpec = exports.getIpcEndpointKind = exports.getIpcEndpoints = exports.getIpcApiId = exports.isInternalApi = exports.WpIpcEndpoint = exports.WpInternal = exports.IpcIdentity = void 0;
3
+ exports.toError = exports.ApiCallTimeoutError = exports.LogApiCallImpl = exports.ApiMethodInfo = exports.MaskLog = exports.MaskSpec = exports.IpcCallLogger = exports.ClientRole = exports.ApiErrorPayload = exports.WEBPIECES_DEFAULT_IPC_ERROR_TRANSLATOR = exports.WebpiecesDefaultIpcErrorTranslator = exports.IpcClientErrorTranslator = exports.IpcRegistry = exports.IpcErrors = exports.IpcTransportError = exports.IpcConnectionOptions = exports.IpcConnection = exports.IpcProtocol = exports.IpcFailure = exports.IpcSuccess = exports.IpcRequest = exports.IpcCallContext = exports.IPC_METADATA_KEYS = exports.assertNotInternalApi = exports.assertInternalApi = exports.getIpcMaskSpec = exports.getIpcEndpointKind = exports.getIpcEndpoints = exports.getIpcApiId = exports.isInternalApi = exports.WpIpcEndpoint = exports.WpInternal = exports.IpcIdentity = void 0;
4
4
  var IpcIdentity_1 = require("./IpcIdentity");
5
5
  Object.defineProperty(exports, "IpcIdentity", { enumerable: true, get: function () { return IpcIdentity_1.IpcIdentity; } });
6
6
  var IpcDecorators_1 = require("./IpcDecorators");
@@ -33,6 +33,8 @@ Object.defineProperty(exports, "WebpiecesDefaultIpcErrorTranslator", { enumerabl
33
33
  Object.defineProperty(exports, "WEBPIECES_DEFAULT_IPC_ERROR_TRANSLATOR", { enumerable: true, get: function () { return WebpiecesDefaultIpcErrorTranslator_1.WEBPIECES_DEFAULT_IPC_ERROR_TRANSLATOR; } });
34
34
  var ApiErrorCodec_1 = require("../errors/ApiErrorCodec");
35
35
  Object.defineProperty(exports, "ApiErrorPayload", { enumerable: true, get: function () { return ApiErrorCodec_1.ApiErrorPayload; } });
36
+ var ClientRole_1 = require("../errors/ClientRole");
37
+ Object.defineProperty(exports, "ClientRole", { enumerable: true, get: function () { return ClientRole_1.ClientRole; } });
36
38
  var IpcLogging_1 = require("./IpcLogging");
37
39
  Object.defineProperty(exports, "IpcCallLogger", { enumerable: true, get: function () { return IpcLogging_1.IpcCallLogger; } });
38
40
  var LogFieldMask_1 = require("../http/LogFieldMask");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/ipc/index.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,iDAWyB;AAVrB,2GAAA,UAAU,OAAA;AACV,8GAAA,aAAa,OAAA;AACb,8GAAA,aAAa,OAAA;AACb,4GAAA,WAAW,OAAA;AACX,gHAAA,eAAe,OAAA;AACf,mHAAA,kBAAkB,OAAA;AAClB,+GAAA,cAAc,OAAA;AACd,kHAAA,iBAAiB,OAAA;AACjB,qHAAA,oBAAoB,OAAA;AACpB,kHAAA,iBAAiB,OAAA;AAGrB,6CAAgG;AAAvF,6GAAA,cAAc,OAAA;AAAE,yGAAA,UAAU,OAAA;AAAE,yGAAA,UAAU,OAAA;AAAE,yGAAA,UAAU,OAAA;AAAE,0GAAA,WAAW,OAAA;AAExE,iDAAoG;AAA3F,8GAAA,aAAa,OAAA;AAAE,qHAAA,oBAAoB,OAAA;AAAE,kHAAA,iBAAiB,OAAA;AAAE,0GAAA,SAAS,OAAA;AAC1E,6CAAsE;AAA7D,0GAAA,WAAW,OAAA;AAAE,uHAAA,wBAAwB,OAAA;AAE9C,2FAG8C;AAF1C,wJAAA,kCAAkC,OAAA;AAClC,4JAAA,sCAAsC,OAAA;AAE1C,yDAA0D;AAAjD,gHAAA,eAAe,OAAA;AAExB,2CAA6C;AAApC,2GAAA,aAAa,OAAA;AAEtB,qDAAgD;AAAvC,wGAAA,QAAQ,OAAA;AACjB,iDAA6C;AAApC,qGAAA,OAAO,OAAA;AAChB,uDAAsD;AAA7C,8GAAA,aAAa,OAAA;AACtB,iDAAoD;AAA3C,4GAAA,cAAc,OAAA;AAEvB,mEAAkE;AAAzD,0HAAA,mBAAmB,OAAA;AAE5B,gDAA4C;AAAnC,qGAAA,OAAO,OAAA","sourcesContent":["export { IpcIdentity } from './IpcIdentity';\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 './IpcDecorators';\nexport type { IpcApiType, IpcEndpointKind, IpcEndpointOptions } from './IpcDecorators';\nexport { IpcCallContext, IpcRequest, IpcSuccess, IpcFailure, IpcProtocol } from './IpcProtocol';\nexport type { IpcReply, IpcMessage } from './IpcProtocol';\nexport { IpcConnection, IpcConnectionOptions, IpcTransportError, IpcErrors } from './IpcConnection';\nexport { IpcRegistry, IpcClientErrorTranslator } from './IpcRegistry';\nexport type { IpcErrorTranslator } from './IpcErrorTranslator';\nexport {\n WebpiecesDefaultIpcErrorTranslator,\n WEBPIECES_DEFAULT_IPC_ERROR_TRANSLATOR,\n} from './WebpiecesDefaultIpcErrorTranslator';\nexport { ApiErrorPayload } from '../errors/ApiErrorCodec';\nexport type { IpcTransport, IpcScheduler, IpcErrorOwner } from './IpcConnection';\nexport { IpcCallLogger } from './IpcLogging';\nexport type { IpcLogging } from './IpcLogging';\nexport { MaskSpec } from '../http/LogFieldMask';\nexport { MaskLog } from '../http/decorators';\nexport { ApiMethodInfo } from '../http/ApiMethodInfo';\nexport { LogApiCallImpl } from '../http/LogApiCall';\nexport type { ApiCallContext } from '../http/ApiCallContext';\nexport { ApiCallTimeoutError } from '../http/ApiCallTimeoutError';\n\nexport { toError } from '../lib/errorUtils';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/ipc/index.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,iDAWyB;AAVrB,2GAAA,UAAU,OAAA;AACV,8GAAA,aAAa,OAAA;AACb,8GAAA,aAAa,OAAA;AACb,4GAAA,WAAW,OAAA;AACX,gHAAA,eAAe,OAAA;AACf,mHAAA,kBAAkB,OAAA;AAClB,+GAAA,cAAc,OAAA;AACd,kHAAA,iBAAiB,OAAA;AACjB,qHAAA,oBAAoB,OAAA;AACpB,kHAAA,iBAAiB,OAAA;AAGrB,6CAAgG;AAAvF,6GAAA,cAAc,OAAA;AAAE,yGAAA,UAAU,OAAA;AAAE,yGAAA,UAAU,OAAA;AAAE,yGAAA,UAAU,OAAA;AAAE,0GAAA,WAAW,OAAA;AAExE,iDAAoG;AAA3F,8GAAA,aAAa,OAAA;AAAE,qHAAA,oBAAoB,OAAA;AAAE,kHAAA,iBAAiB,OAAA;AAAE,0GAAA,SAAS,OAAA;AAC1E,6CAAsE;AAA7D,0GAAA,WAAW,OAAA;AAAE,uHAAA,wBAAwB,OAAA;AAE9C,2FAG8C;AAF1C,wJAAA,kCAAkC,OAAA;AAClC,4JAAA,sCAAsC,OAAA;AAE1C,yDAA0D;AAAjD,gHAAA,eAAe,OAAA;AACxB,mDAAkD;AAAzC,wGAAA,UAAU,OAAA;AAEnB,2CAA6C;AAApC,2GAAA,aAAa,OAAA;AAEtB,qDAAgD;AAAvC,wGAAA,QAAQ,OAAA;AACjB,iDAA6C;AAApC,qGAAA,OAAO,OAAA;AAChB,uDAAsD;AAA7C,8GAAA,aAAa,OAAA;AACtB,iDAAoD;AAA3C,4GAAA,cAAc,OAAA;AAEvB,mEAAkE;AAAzD,0HAAA,mBAAmB,OAAA;AAE5B,gDAA4C;AAAnC,qGAAA,OAAO,OAAA","sourcesContent":["export { IpcIdentity } from './IpcIdentity';\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 './IpcDecorators';\nexport type { IpcApiType, IpcEndpointKind, IpcEndpointOptions } from './IpcDecorators';\nexport { IpcCallContext, IpcRequest, IpcSuccess, IpcFailure, IpcProtocol } from './IpcProtocol';\nexport type { IpcReply, IpcMessage } from './IpcProtocol';\nexport { IpcConnection, IpcConnectionOptions, IpcTransportError, IpcErrors } from './IpcConnection';\nexport { IpcRegistry, IpcClientErrorTranslator } from './IpcRegistry';\nexport type { IpcErrorTranslator } from './IpcErrorTranslator';\nexport {\n WebpiecesDefaultIpcErrorTranslator,\n WEBPIECES_DEFAULT_IPC_ERROR_TRANSLATOR,\n} from './WebpiecesDefaultIpcErrorTranslator';\nexport { ApiErrorPayload } from '../errors/ApiErrorCodec';\nexport { ClientRole } from '../errors/ClientRole';\nexport type { IpcTransport, IpcScheduler, IpcErrorOwner } from './IpcConnection';\nexport { IpcCallLogger } from './IpcLogging';\nexport type { IpcLogging } from './IpcLogging';\nexport { MaskSpec } from '../http/LogFieldMask';\nexport { MaskLog } from '../http/decorators';\nexport { ApiMethodInfo } from '../http/ApiMethodInfo';\nexport { LogApiCallImpl } from '../http/LogApiCall';\nexport type { ApiCallContext } from '../http/ApiCallContext';\nexport { ApiCallTimeoutError } from '../http/ApiCallTimeoutError';\n\nexport { toError } from '../lib/errorUtils';\n"]}