@webpieces/core-util 0.4.805 → 0.4.807

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webpieces/core-util",
3
- "version": "0.4.805",
3
+ "version": "0.4.807",
4
4
  "description": "Utility functions for WebPieces - works in browser and Node.js",
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
@@ -1,7 +1,7 @@
1
1
  import 'reflect-metadata';
2
2
  import { ApiConnectionError } from '../errors/ApiError';
3
3
  import { ApiErrorPayload } from '../errors/ApiErrorCodec';
4
- import { ApiJsonSchema, DtoClass, DtoValue } from '../mcp/DtoSchema';
4
+ import { ApiJsonSchema, DtoValue } from '../mcp/DtoSchema';
5
5
  /** Stable application-level key for relating stream events and failures. */
6
6
  export declare class StreamCorrelation {
7
7
  readonly key: string | number;
@@ -68,25 +68,35 @@ export declare class StreamTransportError extends ApiConnectionError {
68
68
  readonly requestId?: string | undefined;
69
69
  constructor(message: string, correlation?: StreamCorrelation | undefined, requestId?: string | undefined, cause?: Error);
70
70
  }
71
- /** Runtime schema and wire-policy metadata for one streaming method. */
71
+ /**
72
+ * Runtime schema and wire-policy metadata for one streaming method.
73
+ *
74
+ * It holds the two event SCHEMAS rather than two DTO classes. Until #984 it held classes and built
75
+ * their schemas from `@WpDtoField` at decoration time; that decorator is deleted, because the
76
+ * compiler already knows every fact it restated (#983). A schema is the thing a boundary validates
77
+ * against, so it is the thing the metadata carries.
78
+ */
72
79
  export declare class StreamingEndpointMetadata {
73
- readonly requestEventClass: DtoClass;
74
- readonly responseEventClass: DtoClass;
75
- /** Generic NDJSON/SSE supports non-terminal failures in both directions. */
76
- readonly supportsNonTerminalFailures: boolean;
77
80
  readonly requestSchema: ApiJsonSchema;
78
81
  readonly responseSchema: ApiJsonSchema;
79
- constructor(requestEventClass: DtoClass, responseEventClass: DtoClass,
82
+ /** Generic NDJSON/SSE supports non-terminal failures in both directions. */
83
+ readonly supportsNonTerminalFailures: boolean;
84
+ constructor(requestSchema: ApiJsonSchema, responseSchema: ApiJsonSchema,
80
85
  /** Generic NDJSON/SSE supports non-terminal failures in both directions. */
81
86
  supportsNonTerminalFailures?: boolean);
82
87
  }
83
- /** Marks `(ResponseStream<ResponseEvent>) => Promise<RequestStream<RequestEvent>>`. */
84
- export declare function WpStream(requestEvent: () => DtoClass, responseEvent: () => DtoClass): MethodDecorator;
88
+ /**
89
+ * Marks `(ResponseStream<ResponseEvent>) => Promise<RequestStream<RequestEvent>>`, with the two
90
+ * event schemas the wire adapters validate against.
91
+ *
92
+ * Build them with {@link ObjectSchemaBuilder}, or read them out of the build's generated model.
93
+ */
94
+ export declare function WpStream(requestEventSchema: ApiJsonSchema, responseEventSchema: ApiJsonSchema): MethodDecorator;
85
95
  export declare function getStreamingEndpoint(apiClass: Function, methodName: string): StreamingEndpointMetadata | undefined;
86
96
  /** Validate a typed event at every adapter boundary, with one consistent diagnostic. */
87
97
  export declare class StreamEventValidator {
88
98
  private readonly schemas;
89
- validate(dtoClass: DtoClass, value: unknown, direction: 'request' | 'response'): void;
99
+ validate(schema: ApiJsonSchema, value: unknown, direction: 'request' | 'response'): void;
90
100
  }
91
101
  /** Awaiting the sink acknowledges the write, so adapters cannot outrun their consumer. */
92
102
  export declare class StreamWriter<T> implements RequestStream<T>, ResponseStream<T> {
@@ -46,32 +46,39 @@ class StreamTransportError extends ApiError_1.ApiConnectionError {
46
46
  }
47
47
  }
48
48
  exports.StreamTransportError = StreamTransportError;
49
- /** Runtime schema and wire-policy metadata for one streaming method. */
49
+ /**
50
+ * Runtime schema and wire-policy metadata for one streaming method.
51
+ *
52
+ * It holds the two event SCHEMAS rather than two DTO classes. Until #984 it held classes and built
53
+ * their schemas from `@WpDtoField` at decoration time; that decorator is deleted, because the
54
+ * compiler already knows every fact it restated (#983). A schema is the thing a boundary validates
55
+ * against, so it is the thing the metadata carries.
56
+ */
50
57
  class StreamingEndpointMetadata {
51
- requestEventClass;
52
- responseEventClass;
53
- supportsNonTerminalFailures;
54
58
  requestSchema;
55
59
  responseSchema;
56
- constructor(requestEventClass, responseEventClass,
60
+ supportsNonTerminalFailures;
61
+ constructor(requestSchema, responseSchema,
57
62
  /** Generic NDJSON/SSE supports non-terminal failures in both directions. */
58
63
  supportsNonTerminalFailures = true) {
59
- this.requestEventClass = requestEventClass;
60
- this.responseEventClass = responseEventClass;
64
+ this.requestSchema = requestSchema;
65
+ this.responseSchema = responseSchema;
61
66
  this.supportsNonTerminalFailures = supportsNonTerminalFailures;
62
- const schemas = new DtoSchema_1.DtoSchemaBuilder();
63
- this.requestSchema = schemas.build(requestEventClass);
64
- this.responseSchema = schemas.build(responseEventClass);
65
67
  }
66
68
  }
67
69
  exports.StreamingEndpointMetadata = StreamingEndpointMetadata;
68
- /** Marks `(ResponseStream<ResponseEvent>) => Promise<RequestStream<RequestEvent>>`. */
70
+ /**
71
+ * Marks `(ResponseStream<ResponseEvent>) => Promise<RequestStream<RequestEvent>>`, with the two
72
+ * event schemas the wire adapters validate against.
73
+ *
74
+ * Build them with {@link ObjectSchemaBuilder}, or read them out of the build's generated model.
75
+ */
69
76
  // webpieces-disable no-function-outside-class -- decorator factory
70
- function WpStream(requestEvent, responseEvent) {
77
+ function WpStream(requestEventSchema, responseEventSchema) {
71
78
  return (target, propertyKey) => {
72
79
  const apiClass = target.constructor;
73
80
  const methods = Reflect.getMetadata(decorators_1.METADATA_KEYS.STREAM_ENDPOINTS, apiClass) ?? {};
74
- methods[String(propertyKey)] = new StreamingEndpointMetadata(requestEvent(), responseEvent());
81
+ methods[String(propertyKey)] = new StreamingEndpointMetadata(requestEventSchema, responseEventSchema);
75
82
  Reflect.defineMetadata(decorators_1.METADATA_KEYS.STREAM_ENDPOINTS, methods, apiClass);
76
83
  };
77
84
  }
@@ -82,10 +89,10 @@ function getStreamingEndpoint(apiClass, methodName) {
82
89
  }
83
90
  /** Validate a typed event at every adapter boundary, with one consistent diagnostic. */
84
91
  class StreamEventValidator {
85
- schemas = new DtoSchema_1.DtoSchemaBuilder();
92
+ schemas = new DtoSchema_1.ApiJsonSchemaValidator();
86
93
  // webpieces-disable no-any-unknown -- DTO validation is the runtime narrowing boundary
87
- validate(dtoClass, value, direction) {
88
- const failure = this.schemas.validate(dtoClass, value);
94
+ validate(schema, value, direction) {
95
+ const failure = this.schemas.validate(schema, value);
89
96
  if (failure)
90
97
  throw new StreamTransportError(`Invalid ${direction} stream event: ${failure.message}`);
91
98
  }
@@ -1 +1 @@
1
- {"version":3,"file":"StreamingContract.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/http/StreamingContract.ts"],"names":[],"mappings":";;;AAoHA,4BAcC;AAGD,oDAOC;AA5ID,4BAA0B;AAC1B,iDAAwD;AACxD,2DAAyE;AACzE,gDAAuF;AACvF,kDAA4C;AAC5C,6CAA6C;AAE7C,4EAA4E;AAC5E,MAAa,iBAAiB;IAEN;IACA;IAFpB,YACoB,GAAoB,EACpB,SAAkB;QADlB,QAAG,GAAH,GAAG,CAAiB;QACpB,cAAS,GAAT,SAAS,CAAS;IACnC,CAAC;CACP;AALD,8CAKC;AA6DD,gEAAgE;AAChE,MAAa,cAAc;IAEH;IACA;IACA;IACA;IACA;IALpB,YACoB,IAAwB,EACxB,KAAS,EACT,KAAuB,EACvB,WAA+B,EAC/B,QAAkB;QAJlB,SAAI,GAAJ,IAAI,CAAoB;QACxB,UAAK,GAAL,KAAK,CAAI;QACT,UAAK,GAAL,KAAK,CAAkB;QACvB,gBAAW,GAAX,WAAW,CAAoB;QAC/B,aAAQ,GAAR,QAAQ,CAAU;IACnC,CAAC;CACP;AARD,wCAQC;AAED,8EAA8E;AAC9E,MAAa,oBAAqB,SAAQ,6BAAkB;IAGpC;IACA;IAHpB,YACI,OAAe,EACC,WAA+B,EAC/B,SAAkB,EAClC,KAAa;QAEb,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAJN,gBAAW,GAAX,WAAW,CA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AAG,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC/C,4FAA4F;QAC5F,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;YACnC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YACrB,MAAM,KAAK,GAAG,IAAA,oBAAO,EAAC,GAAG,CAAC,CAAC;YAC3B,IAAI,KAAK,YAAY,oBAAoB;gBAAE,MAAM,KAAK,CAAC;YACvD,MAAM,IAAI,oBAAoB,CAC1B,iDAAiD,EACjD,QAAQ,CAAC,WAAW,EACpB,QAAQ,CAAC,WAAW,EAAE,SAAS,EAC/B,KAAK,CACR,CAAC;QACN,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AA9ED,oCA8EC","sourcesContent":["import 'reflect-metadata';\nimport { ApiConnectionError } from '../errors/ApiError';\nimport { ApiErrorCodec, ApiErrorPayload } from '../errors/ApiErrorCodec';\nimport { ApiJsonSchema, DtoClass, DtoSchemaBuilder, DtoValue } from '../mcp/DtoSchema';\nimport { toError } from '../lib/errorUtils';\nimport { METADATA_KEYS } from './decorators';\n\n/** Stable application-level key for relating stream events and failures. */\nexport class StreamCorrelation {\n constructor(\n public readonly key: string | number,\n public readonly requestId?: string,\n ) {}\n}\n\nexport interface StreamFailureOptions {\n /** Defaults to true. Wire adapters may promote false to true when continuation is unsafe. */\n terminal?: boolean;\n}\n\n/** Server-to-client half of a typed stream. Every write is an explicit backpressure boundary. */\nexport interface ResponseStream<T> {\n event(value: T, correlation?: StreamCorrelation): Promise<void>;\n /**\n * Publish a failure on this stream. Takes `Error`, the parent of everything: `ApiError` is a\n * CONVENIENCE taxonomy webpieces ships so the common cases are easy, never something the\n * framework may demand from an application. An app's own `MyLibError extends Error` is\n * published as kind `implementation` with generic text, exactly as on every other boundary.\n *\n * This is the FAITHFUL {@link ApiErrorCodec} encode, NOT `ApiErrorBoundary.encode`, and that is\n * deliberate: a stream failure is delivered IN BAND to a peer that is reading the stream, so a\n * {@link StreamTransportError} (an `ApiConnectionError`) must arrive as kind `connection` for\n * the peer to reconstruct it as the transport failure it is. Republishing it as\n * `implementation` — right at an HTTP/MCP edge, where the caller is asking us to do work — would\n * tell the peer the wrong thing about a stream it is holding one end of.\n */\n fail(\n error: Error,\n correlation?: StreamCorrelation,\n options?: StreamFailureOptions,\n ): Promise<void>;\n complete(): Promise<void>;\n // webpieces-disable no-any-unknown -- cancellation reasons are deliberately transport-neutral\n onCancel(handler: (reason?: unknown) => void | Promise<void>): void;\n}\n\n/** Client-to-server half. Cancellation exists immediately and is independent of writer readiness. */\nexport interface RequestStream<T> {\n event(value: T, correlation?: StreamCorrelation): Promise<void>;\n /**\n * Publish a failure on this stream. Takes `Error`, the parent of everything: `ApiError` is a\n * CONVENIENCE taxonomy webpieces ships so the common cases are easy, never something the\n * framework may demand from an application. An app's own `MyLibError extends Error` is\n * published as kind `implementation` with generic text, exactly as on every other boundary.\n *\n * This is the FAITHFUL {@link ApiErrorCodec} encode, NOT `ApiErrorBoundary.encode`, and that is\n * deliberate: a stream failure is delivered IN BAND to a peer that is reading the stream, so a\n * {@link StreamTransportError} (an `ApiConnectionError`) must arrive as kind `connection` for\n * the peer to reconstruct it as the transport failure it is. Republishing it as\n * `implementation` — right at an HTTP/MCP edge, where the caller is asking us to do work — would\n * tell the peer the wrong thing about a stream it is holding one end of.\n */\n fail(\n error: Error,\n correlation?: StreamCorrelation,\n options?: StreamFailureOptions,\n ): Promise<void>;\n complete(): Promise<void>;\n // webpieces-disable no-any-unknown -- cancellation reasons are deliberately transport-neutral\n cancel(reason?: unknown): Promise<void>;\n}\n\nexport type StreamEnvelopeKind = 'event' | 'failure' | 'complete';\n\n/** Transport-neutral record used by NDJSON and SSE adapters. */\nexport class StreamEnvelope<T = DtoValue> {\n constructor(\n public readonly kind: StreamEnvelopeKind,\n public readonly value?: T,\n public readonly error?: ApiErrorPayload,\n public readonly correlation?: StreamCorrelation,\n public readonly terminal?: boolean,\n ) {}\n}\n\n/** Local failure where no legal in-band envelope could be sent or decoded. */\nexport class StreamTransportError extends ApiConnectionError {\n constructor(\n message: string,\n public readonly correlation?: StreamCorrelation,\n public readonly requestId?: string,\n cause?: Error,\n ) {\n super(message, cause);\n }\n}\n\n/** Runtime schema and wire-policy metadata for one streaming method. */\nexport class StreamingEndpointMetadata {\n readonly requestSchema: ApiJsonSchema;\n readonly responseSchema: ApiJsonSchema;\n\n constructor(\n public readonly requestEventClass: DtoClass,\n public readonly responseEventClass: DtoClass,\n /** Generic NDJSON/SSE supports non-terminal failures in both directions. */\n public readonly supportsNonTerminalFailures = true,\n ) {\n const schemas = new DtoSchemaBuilder();\n this.requestSchema = schemas.build(requestEventClass);\n this.responseSchema = schemas.build(responseEventClass);\n }\n}\n\n/** Marks `(ResponseStream<ResponseEvent>) => Promise<RequestStream<RequestEvent>>`. */\n// webpieces-disable no-function-outside-class -- decorator factory\nexport function WpStream(\n requestEvent: () => DtoClass,\n responseEvent: () => DtoClass,\n): MethodDecorator {\n return (target: object, propertyKey: string | symbol): void => {\n const apiClass = target.constructor;\n const methods: Record<string, StreamingEndpointMetadata> =\n Reflect.getMetadata(METADATA_KEYS.STREAM_ENDPOINTS, apiClass) ?? {};\n methods[String(propertyKey)] = new StreamingEndpointMetadata(\n requestEvent(),\n responseEvent(),\n );\n Reflect.defineMetadata(METADATA_KEYS.STREAM_ENDPOINTS, methods, apiClass);\n };\n}\n\n// webpieces-disable no-function-outside-class -- metadata reader paired with WpStream\nexport function getStreamingEndpoint(\n apiClass: Function,\n methodName: string,\n): StreamingEndpointMetadata | undefined {\n const methods: Record<string, StreamingEndpointMetadata> =\n Reflect.getMetadata(METADATA_KEYS.STREAM_ENDPOINTS, apiClass) ?? {};\n return methods[methodName];\n}\n\n/** Validate a typed event at every adapter boundary, with one consistent diagnostic. */\nexport class StreamEventValidator {\n private readonly schemas = new DtoSchemaBuilder();\n\n // webpieces-disable no-any-unknown -- DTO validation is the runtime narrowing boundary\n validate(dtoClass: DtoClass, value: unknown, direction: 'request' | 'response'): void {\n const failure = this.schemas.validate(dtoClass, value as DtoValue);\n if (failure)\n throw new StreamTransportError(`Invalid ${direction} stream event: ${failure.message}`);\n }\n}\n\n/** Awaiting the sink acknowledges the write, so adapters cannot outrun their consumer. */\nexport class StreamWriter<T> implements RequestStream<T>, ResponseStream<T> {\n private terminal = false;\n private cancelled = false;\n private pending: Promise<void> = Promise.resolve();\n // webpieces-disable no-any-unknown -- cancellation reasons are deliberately transport-neutral\n private readonly cancelHandlers: Array<(reason?: unknown) => void | Promise<void>> = [];\n\n constructor(\n private readonly sink: (envelope: StreamEnvelope<T>) => Promise<void>,\n private readonly validateEvent?: (value: T) => void,\n private readonly allowNonTerminalFailures = true,\n ) {}\n\n async event(value: T, correlation?: StreamCorrelation): Promise<void> {\n this.requireWritable();\n this.validateEvent?.(value);\n await this.enqueue(new StreamEnvelope('event', value, undefined, correlation));\n }\n\n async fail(\n error: Error,\n correlation?: StreamCorrelation,\n options?: StreamFailureOptions,\n ): Promise<void> {\n this.requireWritable();\n const terminal = (options?.terminal ?? true) || !this.allowNonTerminalFailures;\n if (terminal) this.terminal = true;\n await this.enqueue(\n new StreamEnvelope<T>(\n 'failure',\n undefined,\n ApiErrorCodec.encode(error),\n correlation,\n terminal,\n ),\n );\n }\n\n async complete(): Promise<void> {\n this.requireWritable();\n this.terminal = true;\n await this.enqueue(new StreamEnvelope<T>('complete'));\n }\n\n // webpieces-disable no-any-unknown -- cancellation reasons are deliberately transport-neutral\n onCancel(handler: (reason?: unknown) => void | Promise<void>): void {\n this.cancelHandlers.push(handler);\n }\n\n // webpieces-disable no-any-unknown -- cancellation reasons are deliberately transport-neutral\n async cancel(reason?: unknown): Promise<void> {\n if (this.cancelled || this.terminal) return;\n this.cancelled = true;\n this.terminal = true;\n for (const handler of this.cancelHandlers) await handler(reason);\n }\n\n private requireWritable(): void {\n if (this.terminal || this.cancelled)\n throw new StreamTransportError('Cannot write after stream termination.');\n }\n\n private enqueue(envelope: StreamEnvelope<T>): Promise<void> {\n const delivery = this.pending.then(async () => this.sink(envelope));\n this.pending = delivery.catch(() => undefined);\n // webpieces-disable no-any-unknown -- transport boundary normalizes arbitrary sink failures\n return delivery.catch((err: unknown) => {\n this.terminal = true;\n const error = toError(err);\n if (error instanceof StreamTransportError) throw error;\n throw new StreamTransportError(\n 'Stream transport could not acknowledge a write.',\n envelope.correlation,\n envelope.correlation?.requestId,\n error,\n );\n });\n }\n}\n"]}
1
+ {"version":3,"file":"StreamingContract.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/http/StreamingContract.ts"],"names":[],"mappings":";;;AAyHA,4BAcC;AAGD,oDAOC;AAjJD,4BAA0B;AAC1B,iDAAwD;AACxD,2DAAyE;AACzE,gDAAmF;AACnF,kDAA4C;AAC5C,6CAA6C;AAE7C,4EAA4E;AAC5E,MAAa,iBAAiB;IAEN;IACA;IAFpB,YACoB,GAAoB,EACpB,SAAkB;QADlB,QAAG,GAAH,GAAG,CAAiB;QACpB,cAAS,GAAT,SAAS,CAAS;IACnC,CAAC;CACP;AALD,8CAKC;AA6DD,gEAAgE;AAChE,MAAa,cAAc;IAEH;IACA;IACA;IACA;IACA;IALpB,YACoB,IAAwB,EACxB,KAAS,EACT,KAAuB,EACvB,WAA+B,EAC/B,QAAkB;QAJlB,SAAI,GAAJ,IAAI,CAAoB;QACxB,UAAK,GAAL,KAAK,CAAI;QACT,UAAK,GAAL,KAAK,CAAkB;QACvB,gBAAW,GAAX,WAAW,CAAoB;QAC/B,aAAQ,GAAR,QAAQ,CAAU;IACnC,CAAC;CACP;AARD,wCAQC;AAED,8EAA8E;AAC9E,MAAa,oBAAqB,SAAQ,6BAAkB;IAGpC;IACA;IAHpB,YACI,OAAe,EACC,WAA+B,EAC/B,SAAkB,EAClC,KAAa;QAEb,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAJN,gBAAW,GAAX,WAAW,CAAoB;QAC/B,cAAS,GAAT,SAAS,CAA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MAAM,KAAK,CAAC;YACvD,MAAM,IAAI,oBAAoB,CAC1B,iDAAiD,EACjD,QAAQ,CAAC,WAAW,EACpB,QAAQ,CAAC,WAAW,EAAE,SAAS,EAC/B,KAAK,CACR,CAAC;QACN,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AA9ED,oCA8EC","sourcesContent":["import 'reflect-metadata';\nimport { ApiConnectionError } from '../errors/ApiError';\nimport { ApiErrorCodec, ApiErrorPayload } from '../errors/ApiErrorCodec';\nimport { ApiJsonSchema, ApiJsonSchemaValidator, DtoValue } from '../mcp/DtoSchema';\nimport { toError } from '../lib/errorUtils';\nimport { METADATA_KEYS } from './decorators';\n\n/** Stable application-level key for relating stream events and failures. */\nexport class StreamCorrelation {\n constructor(\n public readonly key: string | number,\n public readonly requestId?: string,\n ) {}\n}\n\nexport interface StreamFailureOptions {\n /** Defaults to true. Wire adapters may promote false to true when continuation is unsafe. */\n terminal?: boolean;\n}\n\n/** Server-to-client half of a typed stream. Every write is an explicit backpressure boundary. */\nexport interface ResponseStream<T> {\n event(value: T, correlation?: StreamCorrelation): Promise<void>;\n /**\n * Publish a failure on this stream. Takes `Error`, the parent of everything: `ApiError` is a\n * CONVENIENCE taxonomy webpieces ships so the common cases are easy, never something the\n * framework may demand from an application. An app's own `MyLibError extends Error` is\n * published as kind `implementation` with generic text, exactly as on every other boundary.\n *\n * This is the FAITHFUL {@link ApiErrorCodec} encode, NOT `ApiErrorBoundary.encode`, and that is\n * deliberate: a stream failure is delivered IN BAND to a peer that is reading the stream, so a\n * {@link StreamTransportError} (an `ApiConnectionError`) must arrive as kind `connection` for\n * the peer to reconstruct it as the transport failure it is. Republishing it as\n * `implementation` — right at an HTTP/MCP edge, where the caller is asking us to do work — would\n * tell the peer the wrong thing about a stream it is holding one end of.\n */\n fail(\n error: Error,\n correlation?: StreamCorrelation,\n options?: StreamFailureOptions,\n ): Promise<void>;\n complete(): Promise<void>;\n // webpieces-disable no-any-unknown -- cancellation reasons are deliberately transport-neutral\n onCancel(handler: (reason?: unknown) => void | Promise<void>): void;\n}\n\n/** Client-to-server half. Cancellation exists immediately and is independent of writer readiness. */\nexport interface RequestStream<T> {\n event(value: T, correlation?: StreamCorrelation): Promise<void>;\n /**\n * Publish a failure on this stream. Takes `Error`, the parent of everything: `ApiError` is a\n * CONVENIENCE taxonomy webpieces ships so the common cases are easy, never something the\n * framework may demand from an application. An app's own `MyLibError extends Error` is\n * published as kind `implementation` with generic text, exactly as on every other boundary.\n *\n * This is the FAITHFUL {@link ApiErrorCodec} encode, NOT `ApiErrorBoundary.encode`, and that is\n * deliberate: a stream failure is delivered IN BAND to a peer that is reading the stream, so a\n * {@link StreamTransportError} (an `ApiConnectionError`) must arrive as kind `connection` for\n * the peer to reconstruct it as the transport failure it is. Republishing it as\n * `implementation` — right at an HTTP/MCP edge, where the caller is asking us to do work — would\n * tell the peer the wrong thing about a stream it is holding one end of.\n */\n fail(\n error: Error,\n correlation?: StreamCorrelation,\n options?: StreamFailureOptions,\n ): Promise<void>;\n complete(): Promise<void>;\n // webpieces-disable no-any-unknown -- cancellation reasons are deliberately transport-neutral\n cancel(reason?: unknown): Promise<void>;\n}\n\nexport type StreamEnvelopeKind = 'event' | 'failure' | 'complete';\n\n/** Transport-neutral record used by NDJSON and SSE adapters. */\nexport class StreamEnvelope<T = DtoValue> {\n constructor(\n public readonly kind: StreamEnvelopeKind,\n public readonly value?: T,\n public readonly error?: ApiErrorPayload,\n public readonly correlation?: StreamCorrelation,\n public readonly terminal?: boolean,\n ) {}\n}\n\n/** Local failure where no legal in-band envelope could be sent or decoded. */\nexport class StreamTransportError extends ApiConnectionError {\n constructor(\n message: string,\n public readonly correlation?: StreamCorrelation,\n public readonly requestId?: string,\n cause?: Error,\n ) {\n super(message, cause);\n }\n}\n\n/**\n * Runtime schema and wire-policy metadata for one streaming method.\n *\n * It holds the two event SCHEMAS rather than two DTO classes. Until #984 it held classes and built\n * their schemas from `@WpDtoField` at decoration time; that decorator is deleted, because the\n * compiler already knows every fact it restated (#983). A schema is the thing a boundary validates\n * against, so it is the thing the metadata carries.\n */\nexport class StreamingEndpointMetadata {\n constructor(\n public readonly requestSchema: ApiJsonSchema,\n public readonly responseSchema: ApiJsonSchema,\n /** Generic NDJSON/SSE supports non-terminal failures in both directions. */\n public readonly supportsNonTerminalFailures = true,\n ) {}\n}\n\n/**\n * Marks `(ResponseStream<ResponseEvent>) => Promise<RequestStream<RequestEvent>>`, with the two\n * event schemas the wire adapters validate against.\n *\n * Build them with {@link ObjectSchemaBuilder}, or read them out of the build's generated model.\n */\n// webpieces-disable no-function-outside-class -- decorator factory\nexport function WpStream(\n requestEventSchema: ApiJsonSchema,\n responseEventSchema: ApiJsonSchema,\n): MethodDecorator {\n return (target: object, propertyKey: string | symbol): void => {\n const apiClass = target.constructor;\n const methods: Record<string, StreamingEndpointMetadata> =\n Reflect.getMetadata(METADATA_KEYS.STREAM_ENDPOINTS, apiClass) ?? {};\n methods[String(propertyKey)] = new StreamingEndpointMetadata(\n requestEventSchema,\n responseEventSchema,\n );\n Reflect.defineMetadata(METADATA_KEYS.STREAM_ENDPOINTS, methods, apiClass);\n };\n}\n\n// webpieces-disable no-function-outside-class -- metadata reader paired with WpStream\nexport function getStreamingEndpoint(\n apiClass: Function,\n methodName: string,\n): StreamingEndpointMetadata | undefined {\n const methods: Record<string, StreamingEndpointMetadata> =\n Reflect.getMetadata(METADATA_KEYS.STREAM_ENDPOINTS, apiClass) ?? {};\n return methods[methodName];\n}\n\n/** Validate a typed event at every adapter boundary, with one consistent diagnostic. */\nexport class StreamEventValidator {\n private readonly schemas = new ApiJsonSchemaValidator();\n\n // webpieces-disable no-any-unknown -- DTO validation is the runtime narrowing boundary\n validate(schema: ApiJsonSchema, value: unknown, direction: 'request' | 'response'): void {\n const failure = this.schemas.validate(schema, value as DtoValue);\n if (failure)\n throw new StreamTransportError(`Invalid ${direction} stream event: ${failure.message}`);\n }\n}\n\n/** Awaiting the sink acknowledges the write, so adapters cannot outrun their consumer. */\nexport class StreamWriter<T> implements RequestStream<T>, ResponseStream<T> {\n private terminal = false;\n private cancelled = false;\n private pending: Promise<void> = Promise.resolve();\n // webpieces-disable no-any-unknown -- cancellation reasons are deliberately transport-neutral\n private readonly cancelHandlers: Array<(reason?: unknown) => void | Promise<void>> = [];\n\n constructor(\n private readonly sink: (envelope: StreamEnvelope<T>) => Promise<void>,\n private readonly validateEvent?: (value: T) => void,\n private readonly allowNonTerminalFailures = true,\n ) {}\n\n async event(value: T, correlation?: StreamCorrelation): Promise<void> {\n this.requireWritable();\n this.validateEvent?.(value);\n await this.enqueue(new StreamEnvelope('event', value, undefined, correlation));\n }\n\n async fail(\n error: Error,\n correlation?: StreamCorrelation,\n options?: StreamFailureOptions,\n ): Promise<void> {\n this.requireWritable();\n const terminal = (options?.terminal ?? true) || !this.allowNonTerminalFailures;\n if (terminal) this.terminal = true;\n await this.enqueue(\n new StreamEnvelope<T>(\n 'failure',\n undefined,\n ApiErrorCodec.encode(error),\n correlation,\n terminal,\n ),\n );\n }\n\n async complete(): Promise<void> {\n this.requireWritable();\n this.terminal = true;\n await this.enqueue(new StreamEnvelope<T>('complete'));\n }\n\n // webpieces-disable no-any-unknown -- cancellation reasons are deliberately transport-neutral\n onCancel(handler: (reason?: unknown) => void | Promise<void>): void {\n this.cancelHandlers.push(handler);\n }\n\n // webpieces-disable no-any-unknown -- cancellation reasons are deliberately transport-neutral\n async cancel(reason?: unknown): Promise<void> {\n if (this.cancelled || this.terminal) return;\n this.cancelled = true;\n this.terminal = true;\n for (const handler of this.cancelHandlers) await handler(reason);\n }\n\n private requireWritable(): void {\n if (this.terminal || this.cancelled)\n throw new StreamTransportError('Cannot write after stream termination.');\n }\n\n private enqueue(envelope: StreamEnvelope<T>): Promise<void> {\n const delivery = this.pending.then(async () => this.sink(envelope));\n this.pending = delivery.catch(() => undefined);\n // webpieces-disable no-any-unknown -- transport boundary normalizes arbitrary sink failures\n return delivery.catch((err: unknown) => {\n this.terminal = true;\n const error = toError(err);\n if (error instanceof StreamTransportError) throw error;\n throw new StreamTransportError(\n 'Stream transport could not acknowledge a write.',\n envelope.correlation,\n envelope.correlation?.requestId,\n error,\n );\n });\n }\n}\n"]}
@@ -89,8 +89,8 @@ function assertApiTypeMatchesMcpTools(apiClass) {
89
89
  const tools = (0, McpMetadata_1.getWpMcpTools)(apiClass);
90
90
  if (declaresMcp && tools.length === 0) {
91
91
  throw new Error(`${apiClass.name} declares @ApiType(..., MCP) but no method carries @WpMcpTool. ` +
92
- 'Add @WpMcpTool({name, description, openWorldHint}) to the methods agents may ' +
93
- 'call, or drop MCP from the @ApiType list.');
92
+ "Add @WpMcpTool('<stable_tool_name>') to the methods agents may call, or drop MCP " +
93
+ 'from the @ApiType list.');
94
94
  }
95
95
  if (!declaresMcp && tools.length > 0) {
96
96
  const named = tools.map((tool) => tool.methodName).join(', ');
@@ -1 +1 @@
1
- {"version":3,"file":"api-type.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/http/api-type.ts"],"names":[],"mappings":";;;AAkEA,0BAKC;AAID,kCAMC;AAUD,oEAkBC;AAID,0DAIC;AArHD,4BAA0B;AAC1B,6CAA6C;AAC7C,oDAAsE;AAEtE,8EAA8E;AAC9E,IAAK,YAIJ;AAJD,WAAK,YAAY;IACb,yCAAyB,CAAA;IACzB,uDAAuC,CAAA;IACvC,2BAAW,CAAA;AACf,CAAC,EAJI,YAAY,KAAZ,YAAY,QAIhB;AAED,wDAAwD;AAC3C,QAAA,UAAU,GAAG,YAAY,CAAC,UAAU,CAAC;AACrC,QAAA,iBAAiB,GAAG,YAAY,CAAC,iBAAiB,CAAC;AACnD,QAAA,GAAG,GAAG,YAAY,CAAC,GAAG,CAAC;AAKpC,0FAA0F;AAC7E,QAAA,qBAAqB,GAAG,oBAAoB,CAAC;AAE1D,8FAA8F;AACjF,QAAA,iBAAiB,GAA2B,CAAC,kBAAU,CAAC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA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ED,uGAAuG;AACvG,yFAAyF;AACzF,SAAgB,uBAAuB,CAAC,QAAkB;IACtD,MAAM,SAAS,GACX,OAAO,CAAC,WAAW,CAAC,0BAAa,CAAC,SAAS,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;IACjE,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC","sourcesContent":["import 'reflect-metadata';\nimport { METADATA_KEYS } from './decorators';\nimport { getWpMcpTools, WpMcpToolMetadata } from '../mcp/McpMetadata';\n\n/** Nominal backing keeps raw string literals out of contract declarations. */\nenum ApiTypeValue {\n SVC_TO_SVC = 'svc-to-svc',\n EXTERNAL_CUSTOMER = 'external-customer',\n MCP = 'mcp',\n}\n\n/** Short, statically importable decorator arguments. */\nexport const SVC_TO_SVC = ApiTypeValue.SVC_TO_SVC;\nexport const EXTERNAL_CUSTOMER = ApiTypeValue.EXTERNAL_CUSTOMER;\nexport const MCP = ApiTypeValue.MCP;\n\n/** WHICH generated documents a contract feeds. One value per document. */\nexport type ApiTypeKind = typeof SVC_TO_SVC | typeof EXTERNAL_CUSTOMER | typeof MCP;\n\n/** Metadata key for the contract-level declaration, parallel to {@link METADATA_KEYS}. */\nexport const API_TYPE_METADATA_KEY = 'webpieces:api-type';\n\n/** The fail-closed default: a contract that says nothing feeds only the internal document. */\nexport const DEFAULT_API_TYPES: readonly ApiTypeKind[] = [SVC_TO_SVC];\n\n/**\n * WHICH generated documents this CONTRACT feeds.\n *\n * ```typescript\n * @ApiPath('/stores')\n * @ApiType(SVC_TO_SVC, EXTERNAL_CUSTOMER) // private + customer documents\n * export abstract class StoreApi { ... }\n * ```\n *\n * | value | document |\n * |---|---|\n * | `SVC_TO_SVC` | `full-private-openapi.json` |\n * | `EXTERNAL_CUSTOMER` | `public-openapi.json` |\n * | `MCP` | `mcp-openapi.json` |\n *\n * A document is WRITTEN when at least one contract declares its type, and it contains the contracts\n * that declared it and no others. No contract declaring `MCP` therefore means no `mcp-openapi.json`\n * at all — there is no separate emptiness rule to keep in step with this one.\n *\n * ## Absent means `SVC_TO_SVC` only, and the level is why that is affordable\n *\n * `.claude/rules/no-backwards-compat.md` shim shape #5 rejects \"a widening that is an ABSENCE rather\n * than a token\": a default that publishes to customers would mean you reach them having typed\n * nothing, so the safe state requires an edit and the widest grant is free. Naming the type inverts\n * that — `grep -rn EXTERNAL_CUSTOMER` is the entire customer-facing surface on one screen.\n *\n * It is a CLASS-level declaration because that costs one token per contract rather than one per\n * method. A per-method audience list was the earlier design and was rejected on exactly that\n * ergonomic ground; the per-METHOD case that remains — a new endpoint on an already-published API —\n * is served by `{ hidden: true }` in `EndpointOptions`, which subtracts one method from the customer\n * document and leaves it in the other two. The two are orthogonal: this one selects FILES, that one\n * subtracts a METHOD from one file.\n *\n * ## `MCP` and `@WpMcpTool` are ONE decision\n *\n * `MCP` on a contract with no `@WpMcpTool` method is an error, and a `@WpMcpTool` method on a\n * contract that does not declare `MCP` is an error. Both directions are asserted by\n * {@link assertApiTypeMatchesMcpTools}; without that, membership is declared in two places and they\n * can disagree, which is the defect this whole documentation epic exists to remove.\n */\n// webpieces-disable no-function-outside-class -- decorator factory; decorators are inherently module-scope\nexport function ApiType(first: ApiTypeKind, ...rest: readonly ApiTypeKind[]): ClassDecorator {\n const types = [first, ...rest];\n return (target: Function) => {\n Reflect.defineMetadata(API_TYPE_METADATA_KEY, types, target);\n };\n}\n\n/** The documents this contract feeds — its declaration, else {@link DEFAULT_API_TYPES}. */\n// webpieces-disable no-function-outside-class -- metadata reader paired with the decorator\nexport function getApiTypes(apiClass: Function): readonly ApiTypeKind[] {\n const declared: ApiTypeKind[] | undefined = Reflect.getMetadata(\n API_TYPE_METADATA_KEY,\n apiClass,\n );\n return declared ?? DEFAULT_API_TYPES;\n}\n\n/**\n * MCP membership and `@WpMcpTool` must AGREE, in both directions.\n *\n * A wiring-time assert rather than a type, because the two declarations sit on different decorators\n * at different levels and TypeScript cannot relate them. It is the sibling of\n * `assertEveryEndpointHasAuthMode`, and exists for the same reason.\n */\n// webpieces-disable no-function-outside-class -- wiring-time assert, sibling of assertEveryEndpointHasAuthMode\nexport function assertApiTypeMatchesMcpTools(apiClass: Function): void {\n const declaresMcp = getApiTypes(apiClass).includes(MCP);\n const tools = getWpMcpTools(apiClass);\n if (declaresMcp && tools.length === 0) {\n throw new Error(\n `${apiClass.name} declares @ApiType(..., MCP) but no method carries @WpMcpTool. ` +\n 'Add @WpMcpTool({name, description, openWorldHint}) to the methods agents may ' +\n 'call, or drop MCP from the @ApiType list.',\n );\n }\n if (!declaresMcp && tools.length > 0) {\n const named = tools.map((tool: WpMcpToolMetadata) => tool.methodName).join(', ');\n throw new Error(\n `${apiClass.name} has @WpMcpTool on ${named} but does not declare @ApiType(..., MCP). ` +\n 'Add MCP to the @ApiType list — membership has ONE spelling, so a tool on a ' +\n 'contract nobody published to agents is a contradiction, not a hint.',\n );\n }\n}\n\n/** Reads the endpoints map so a caller can see which methods exist without importing decorators.ts. */\n// webpieces-disable no-function-outside-class -- metadata reader, sibling of getApiTypes\nexport function getApiTypeEndpointNames(apiClass: Function): readonly string[] {\n const endpoints: Record<string, string> =\n Reflect.getMetadata(METADATA_KEYS.ENDPOINTS, apiClass) ?? {};\n return Object.keys(endpoints);\n}\n"]}
1
+ {"version":3,"file":"api-type.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/http/api-type.ts"],"names":[],"mappings":";;;AAkEA,0BAKC;AAID,kCAMC;AAUD,oEAkBC;AAID,0DAIC;AArHD,4BAA0B;AAC1B,6CAA6C;AAC7C,oDAAsE;AAEtE,8EAA8E;AAC9E,IAAK,YAIJ;AAJD,WAAK,YAAY;IACb,yCAAyB,CAAA;IACzB,uDAAuC,CAAA;IACvC,2BAAW,CAAA;AACf,CAAC,EAJI,YAAY,KAAZ,YAAY,QAIhB;AAED,wDAAwD;AAC3C,QAAA,UAAU,GAAG,YAAY,CAAC,UAAU,CAAC;AACrC,QAAA,iBAAiB,GAAG,YAAY,CAAC,iB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AAC,CAAC,IAAuB,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjF,MAAM,IAAI,KAAK,CACX,GAAG,QAAQ,CAAC,IAAI,sBAAsB,KAAK,4CAA4C;YACnF,6EAA6E;YAC7E,qEAAqE,CAC5E,CAAC;IACN,CAAC;AACL,CAAC;AAED,uGAAuG;AACvG,yFAAyF;AACzF,SAAgB,uBAAuB,CAAC,QAAkB;IACtD,MAAM,SAAS,GACX,OAAO,CAAC,WAAW,CAAC,0BAAa,CAAC,SAAS,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;IACjE,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC","sourcesContent":["import 'reflect-metadata';\nimport { METADATA_KEYS } from './decorators';\nimport { getWpMcpTools, WpMcpToolMetadata } from '../mcp/McpMetadata';\n\n/** Nominal backing keeps raw string literals out of contract declarations. */\nenum ApiTypeValue {\n SVC_TO_SVC = 'svc-to-svc',\n EXTERNAL_CUSTOMER = 'external-customer',\n MCP = 'mcp',\n}\n\n/** Short, statically importable decorator arguments. */\nexport const SVC_TO_SVC = ApiTypeValue.SVC_TO_SVC;\nexport const EXTERNAL_CUSTOMER = ApiTypeValue.EXTERNAL_CUSTOMER;\nexport const MCP = ApiTypeValue.MCP;\n\n/** WHICH generated documents a contract feeds. One value per document. */\nexport type ApiTypeKind = typeof SVC_TO_SVC | typeof EXTERNAL_CUSTOMER | typeof MCP;\n\n/** Metadata key for the contract-level declaration, parallel to {@link METADATA_KEYS}. */\nexport const API_TYPE_METADATA_KEY = 'webpieces:api-type';\n\n/** The fail-closed default: a contract that says nothing feeds only the internal document. */\nexport const DEFAULT_API_TYPES: readonly ApiTypeKind[] = [SVC_TO_SVC];\n\n/**\n * WHICH generated documents this CONTRACT feeds.\n *\n * ```typescript\n * @ApiPath('/stores')\n * @ApiType(SVC_TO_SVC, EXTERNAL_CUSTOMER) // private + customer documents\n * export abstract class StoreApi { ... }\n * ```\n *\n * | value | document |\n * |---|---|\n * | `SVC_TO_SVC` | `full-private-openapi.json` |\n * | `EXTERNAL_CUSTOMER` | `public-openapi.json` |\n * | `MCP` | `mcp-openapi.json` |\n *\n * A document is WRITTEN when at least one contract declares its type, and it contains the contracts\n * that declared it and no others. No contract declaring `MCP` therefore means no `mcp-openapi.json`\n * at all — there is no separate emptiness rule to keep in step with this one.\n *\n * ## Absent means `SVC_TO_SVC` only, and the level is why that is affordable\n *\n * `.claude/rules/no-backwards-compat.md` shim shape #5 rejects \"a widening that is an ABSENCE rather\n * than a token\": a default that publishes to customers would mean you reach them having typed\n * nothing, so the safe state requires an edit and the widest grant is free. Naming the type inverts\n * that — `grep -rn EXTERNAL_CUSTOMER` is the entire customer-facing surface on one screen.\n *\n * It is a CLASS-level declaration because that costs one token per contract rather than one per\n * method. A per-method audience list was the earlier design and was rejected on exactly that\n * ergonomic ground; the per-METHOD case that remains — a new endpoint on an already-published API —\n * is served by `{ hidden: true }` in `EndpointOptions`, which subtracts one method from the customer\n * document and leaves it in the other two. The two are orthogonal: this one selects FILES, that one\n * subtracts a METHOD from one file.\n *\n * ## `MCP` and `@WpMcpTool` are ONE decision\n *\n * `MCP` on a contract with no `@WpMcpTool` method is an error, and a `@WpMcpTool` method on a\n * contract that does not declare `MCP` is an error. Both directions are asserted by\n * {@link assertApiTypeMatchesMcpTools}; without that, membership is declared in two places and they\n * can disagree, which is the defect this whole documentation epic exists to remove.\n */\n// webpieces-disable no-function-outside-class -- decorator factory; decorators are inherently module-scope\nexport function ApiType(first: ApiTypeKind, ...rest: readonly ApiTypeKind[]): ClassDecorator {\n const types = [first, ...rest];\n return (target: Function) => {\n Reflect.defineMetadata(API_TYPE_METADATA_KEY, types, target);\n };\n}\n\n/** The documents this contract feeds — its declaration, else {@link DEFAULT_API_TYPES}. */\n// webpieces-disable no-function-outside-class -- metadata reader paired with the decorator\nexport function getApiTypes(apiClass: Function): readonly ApiTypeKind[] {\n const declared: ApiTypeKind[] | undefined = Reflect.getMetadata(\n API_TYPE_METADATA_KEY,\n apiClass,\n );\n return declared ?? DEFAULT_API_TYPES;\n}\n\n/**\n * MCP membership and `@WpMcpTool` must AGREE, in both directions.\n *\n * A wiring-time assert rather than a type, because the two declarations sit on different decorators\n * at different levels and TypeScript cannot relate them. It is the sibling of\n * `assertEveryEndpointHasAuthMode`, and exists for the same reason.\n */\n// webpieces-disable no-function-outside-class -- wiring-time assert, sibling of assertEveryEndpointHasAuthMode\nexport function assertApiTypeMatchesMcpTools(apiClass: Function): void {\n const declaresMcp = getApiTypes(apiClass).includes(MCP);\n const tools = getWpMcpTools(apiClass);\n if (declaresMcp && tools.length === 0) {\n throw new Error(\n `${apiClass.name} declares @ApiType(..., MCP) but no method carries @WpMcpTool. ` +\n \"Add @WpMcpTool('<stable_tool_name>') to the methods agents may call, or drop MCP \" +\n 'from the @ApiType list.',\n );\n }\n if (!declaresMcp && tools.length > 0) {\n const named = tools.map((tool: WpMcpToolMetadata) => tool.methodName).join(', ');\n throw new Error(\n `${apiClass.name} has @WpMcpTool on ${named} but does not declare @ApiType(..., MCP). ` +\n 'Add MCP to the @ApiType list — membership has ONE spelling, so a tool on a ' +\n 'contract nobody published to agents is a contradiction, not a hint.',\n );\n }\n}\n\n/** Reads the endpoints map so a caller can see which methods exist without importing decorators.ts. */\n// webpieces-disable no-function-outside-class -- metadata reader, sibling of getApiTypes\nexport function getApiTypeEndpointNames(apiClass: Function): readonly string[] {\n const endpoints: Record<string, string> =\n Reflect.getMetadata(METADATA_KEYS.ENDPOINTS, apiClass) ?? {};\n return Object.keys(endpoints);\n}\n"]}
package/src/index.d.ts CHANGED
@@ -33,12 +33,13 @@ export type { RequestStream, ResponseStream, StreamEnvelopeKind, StreamFailureOp
33
33
  export type { EndpointResponseType, HttpMethod, HttpParameterSource, HttpParameterValueType, } from './http/HttpContract';
34
34
  export { GET, POST } from './http/HttpContract';
35
35
  export type { EndpointKind, EndpointOperation, EndpointOptions, ExternalEndpointOptions, } from './http/decorators';
36
- export { RPC, CLOUDTASKS, CRON, EXTERNAL, READ, WRITE_IDEMPOTENT, WRITE, } from './http/decorators';
36
+ export { RPC, CLOUDTASKS, CRON, EXTERNAL, READ, WRITE_IDEMPOTENT, WRITE } from './http/decorators';
37
37
  export { WpMcpTool, WpMcpToolHints, WpMcpToolMetadata, getWpMcpTools, mcpHintsForOperation, } from './mcp/McpMetadata';
38
- export type { WpMcpMethodDecorator, WpMcpToolOptions } from './mcp/McpMetadata';
38
+ export type { WpMcpMethodDecorator } from './mcp/McpMetadata';
39
39
  export { WpMcpAuthJwt, WpMcpJwtAuthMetadata, getWpMcpAuthJwt } from './mcp/McpAuthMetadata';
40
- export { WpDto, WpDtoField, WpDtoFieldOptions, WpMcpHeader, WpDtoMapFieldOptions, WpDtoFieldMetadata, WpResponseDto, ApiJsonSchema, DtoValidationFailure, DtoSchemaBuilder, } from './mcp/DtoSchema';
41
- export type { DtoClass, DtoElementType, DtoValue } from './mcp/DtoSchema';
40
+ export { ApiJsonSchema, ApiJsonSchemaValidator, DtoValidationFailure, ObjectSchemaBuilder, } from './mcp/DtoSchema';
41
+ export type { ApiJsonSchemaType, DtoValue } from './mcp/DtoSchema';
42
+ export { McpToolCatalog, McpToolCatalogError, McpToolDefinition } from './mcp/McpToolCatalog';
42
43
  export { AuthMeta } from './http/auth-mode';
43
44
  export type { AuthMode, ApiKeyCredential, ApiKeyCredentials, JwtRoles, JwtRequirement, } from './http/auth-mode';
44
45
  export { Rpc, PubSub, Queue, ENDPOINT_KINDS_BY_API_KIND, getApiKind, assertApiKind, assertPubSubConventions, getQueueName, } from './http/api-kind';
package/src/index.js CHANGED
@@ -10,9 +10,9 @@
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
11
  exports.WpMax = exports.WpMin = exports.WpInt = exports.getHttpParameterDeclarations = exports.QueryParam = exports.PathParam = exports.METADATA_KEYS = exports.validateNoConflictingDecorators = exports.assertEveryWebhookEndpointRetainsRawBody = exports.assertEveryExternalEndpointDeclaresCaller = exports.assertEveryEndpointHasAuthMode = exports.getAuthMode = exports.getAuthMeta = exports.isApiPath = exports.isRawBody = exports.isFormPost = exports.getMaskSpec = exports.getEndpointKinds = exports.getEndpointKind = exports.getEndpointOperation = exports.getEndpointOptions = exports.getEndpointHttpMethod = exports.getEndpoints = exports.getApiPath = exports.MaskLog = exports.WpAuthLocalOnly = exports.WpAuthApiKey = exports.WpAuthWebhook = exports.WpAuthSharedSecret = exports.WpAuthOidc = exports.MISSING_AUTH_DECORATOR_FIX = exports.rolesRequired = exports.WpAuthJwt = exports.WpAuthPublic = exports.Endpoint = exports.ApiPath = exports.GCP_LOG_BUDGET_BYTES = exports.MAX_GCP_LOG_BYTES = exports.LogChunkInfo = exports.LogChunkerImpl = exports.LogChunker = exports.LogManager = exports.ConsoleLoggerFactory = exports.ConsoleLogger = exports.DESIGN_METADATA_KEYS = exports.isDocumentDesign = exports.DocumentDesign = exports.ContextTuple = exports.ContextKey = exports.toError = void 0;
12
12
  exports.WpMcpJwtAuthMetadata = exports.WpMcpAuthJwt = exports.mcpHintsForOperation = exports.getWpMcpTools = exports.WpMcpToolMetadata = exports.WpMcpToolHints = exports.WpMcpTool = exports.WRITE = exports.WRITE_IDEMPOTENT = exports.READ = exports.EXTERNAL = exports.CRON = exports.CLOUDTASKS = exports.RPC = exports.POST = exports.GET = exports.getStreamingEndpoint = exports.WpStream = exports.StreamWriter = exports.StreamTransportError = exports.StreamEventValidator = exports.StreamingEndpointMetadata = exports.StreamEnvelope = exports.StreamCorrelation = exports.HttpParameterDeclaration = exports.HttpParameterBinding = exports.HttpContractMapper = exports.BoundHttpRequest = 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 = exports.MCP = exports.EXTERNAL_CUSTOMER = exports.SVC_TO_SVC = exports.ApiType = exports.NUMERIC_METADATA_KEYS = void 0;
13
- 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 = exports.NetworkRejectClassifier = exports.NO_REG_CODE = exports.WRONG_COMPANY = exports.WRONG_DOMAIN = exports.EMAIL_NOT_CONFIRMED = exports.NOT_APPROVED = exports.WRONG_LOGIN = exports.WRONG_LOGIN_TYPE = exports.ENTITY_NOT_FOUND = exports.SECRETS = exports.Secrets = exports.getEndpointCaller = exports.isExternalSystemKind = exports.ExternalCaller = exports.DEFAULT_CALLER_KIND = exports.EXTERNAL_SYSTEM_KINDS = exports.getQueueName = exports.assertPubSubConventions = exports.assertApiKind = exports.getApiKind = exports.ENDPOINT_KINDS_BY_API_KIND = exports.Queue = exports.PubSub = exports.Rpc = exports.AuthMeta = exports.DtoSchemaBuilder = exports.DtoValidationFailure = exports.ApiJsonSchema = exports.WpResponseDto = exports.WpDtoFieldMetadata = exports.WpDtoMapFieldOptions = exports.WpMcpHeader = exports.WpDtoFieldOptions = exports.WpDtoField = exports.WpDto = exports.getWpMcpAuthJwt = void 0;
14
- 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 = 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 = void 0;
15
- exports.ApiErrorHttpStatus = exports.ApiErrorBoundary = exports.ApiErrorPayload = exports.ApiErrorCodec = exports.ApiCodedError = exports.ApiNotImplementedError = void 0;
13
+ 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 = exports.NetworkRejectClassifier = exports.NO_REG_CODE = exports.WRONG_COMPANY = exports.WRONG_DOMAIN = exports.EMAIL_NOT_CONFIRMED = exports.NOT_APPROVED = exports.WRONG_LOGIN = exports.WRONG_LOGIN_TYPE = exports.ENTITY_NOT_FOUND = exports.SECRETS = exports.Secrets = exports.getEndpointCaller = exports.isExternalSystemKind = exports.ExternalCaller = exports.DEFAULT_CALLER_KIND = exports.EXTERNAL_SYSTEM_KINDS = exports.getQueueName = exports.assertPubSubConventions = exports.assertApiKind = exports.getApiKind = exports.ENDPOINT_KINDS_BY_API_KIND = exports.Queue = exports.PubSub = exports.Rpc = exports.AuthMeta = exports.McpToolDefinition = exports.McpToolCatalogError = exports.McpToolCatalog = exports.ObjectSchemaBuilder = exports.DtoValidationFailure = exports.ApiJsonSchemaValidator = exports.ApiJsonSchema = exports.getWpMcpAuthJwt = void 0;
14
+ 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 = 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 = void 0;
15
+ exports.ApiErrorHttpStatus = exports.ApiErrorBoundary = exports.ApiErrorPayload = 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");
@@ -147,16 +147,14 @@ Object.defineProperty(exports, "WpMcpAuthJwt", { enumerable: true, get: function
147
147
  Object.defineProperty(exports, "WpMcpJwtAuthMetadata", { enumerable: true, get: function () { return McpAuthMetadata_1.WpMcpJwtAuthMetadata; } });
148
148
  Object.defineProperty(exports, "getWpMcpAuthJwt", { enumerable: true, get: function () { return McpAuthMetadata_1.getWpMcpAuthJwt; } });
149
149
  var DtoSchema_1 = require("./mcp/DtoSchema");
150
- Object.defineProperty(exports, "WpDto", { enumerable: true, get: function () { return DtoSchema_1.WpDto; } });
151
- Object.defineProperty(exports, "WpDtoField", { enumerable: true, get: function () { return DtoSchema_1.WpDtoField; } });
152
- Object.defineProperty(exports, "WpDtoFieldOptions", { enumerable: true, get: function () { return DtoSchema_1.WpDtoFieldOptions; } });
153
- Object.defineProperty(exports, "WpMcpHeader", { enumerable: true, get: function () { return DtoSchema_1.WpMcpHeader; } });
154
- Object.defineProperty(exports, "WpDtoMapFieldOptions", { enumerable: true, get: function () { return DtoSchema_1.WpDtoMapFieldOptions; } });
155
- Object.defineProperty(exports, "WpDtoFieldMetadata", { enumerable: true, get: function () { return DtoSchema_1.WpDtoFieldMetadata; } });
156
- Object.defineProperty(exports, "WpResponseDto", { enumerable: true, get: function () { return DtoSchema_1.WpResponseDto; } });
157
150
  Object.defineProperty(exports, "ApiJsonSchema", { enumerable: true, get: function () { return DtoSchema_1.ApiJsonSchema; } });
151
+ Object.defineProperty(exports, "ApiJsonSchemaValidator", { enumerable: true, get: function () { return DtoSchema_1.ApiJsonSchemaValidator; } });
158
152
  Object.defineProperty(exports, "DtoValidationFailure", { enumerable: true, get: function () { return DtoSchema_1.DtoValidationFailure; } });
159
- Object.defineProperty(exports, "DtoSchemaBuilder", { enumerable: true, get: function () { return DtoSchema_1.DtoSchemaBuilder; } });
153
+ Object.defineProperty(exports, "ObjectSchemaBuilder", { enumerable: true, get: function () { return DtoSchema_1.ObjectSchemaBuilder; } });
154
+ var McpToolCatalog_1 = require("./mcp/McpToolCatalog");
155
+ Object.defineProperty(exports, "McpToolCatalog", { enumerable: true, get: function () { return McpToolCatalog_1.McpToolCatalog; } });
156
+ Object.defineProperty(exports, "McpToolCatalogError", { enumerable: true, get: function () { return McpToolCatalog_1.McpToolCatalogError; } });
157
+ Object.defineProperty(exports, "McpToolDefinition", { enumerable: true, get: function () { return McpToolCatalog_1.McpToolDefinition; } });
160
158
  // The TYPE layer of the auth surface — likewise split out of decorators.ts for file size only.
161
159
  var auth_mode_1 = require("./http/auth-mode");
162
160
  Object.defineProperty(exports, "AuthMeta", { enumerable: true, get: function () { return auth_mode_1.AuthMeta; } });
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,gDAgC2B;AA/BvB,qGAAA,OAAO,O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wB,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 WpAuthJwt,\n rolesRequired,\n MISSING_AUTH_DECORATOR_FIX,\n WpAuthOidc,\n WpAuthSharedSecret,\n WpAuthWebhook,\n WpAuthApiKey,\n WpAuthLocalOnly,\n MaskLog,\n getApiPath,\n getEndpoints,\n getEndpointHttpMethod,\n getEndpointOptions,\n getEndpointOperation,\n getEndpointKind,\n getEndpointKinds,\n getMaskSpec,\n isFormPost,\n isRawBody,\n isApiPath,\n getAuthMeta,\n getAuthMode,\n assertEveryEndpointHasAuthMode,\n assertEveryExternalEndpointDeclaresCaller,\n assertEveryWebhookEndpointRetainsRawBody,\n validateNoConflictingDecorators,\n METADATA_KEYS,\n} from './http/decorators';\nexport {\n PathParam,\n QueryParam,\n getHttpParameterDeclarations,\n} from './http/http-parameter-decorators';\nexport { 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 {\n BoundHttpRequest,\n HttpContractMapper,\n HttpParameterBinding,\n HttpParameterDeclaration,\n} from './http/HttpContract';\nexport {\n StreamCorrelation,\n StreamEnvelope,\n StreamingEndpointMetadata,\n StreamEventValidator,\n StreamTransportError,\n StreamWriter,\n WpStream,\n getStreamingEndpoint,\n} from './http/StreamingContract';\nexport type {\n RequestStream,\n ResponseStream,\n StreamEnvelopeKind,\n StreamFailureOptions,\n} from './http/StreamingContract';\nexport type {\n 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 {\n RPC,\n CLOUDTASKS,\n CRON,\n EXTERNAL,\n READ,\n WRITE_IDEMPOTENT,\n WRITE,\n} from './http/decorators';\nexport {\n WpMcpTool,\n WpMcpToolHints,\n WpMcpToolMetadata,\n getWpMcpTools,\n mcpHintsForOperation,\n} from './mcp/McpMetadata';\nexport type { WpMcpMethodDecorator, WpMcpToolOptions } from './mcp/McpMetadata';\nexport { WpMcpAuthJwt, WpMcpJwtAuthMetadata, getWpMcpAuthJwt } from './mcp/McpAuthMetadata';\nexport {\n WpDto,\n WpDtoField,\n WpDtoFieldOptions,\n WpMcpHeader,\n WpDtoMapFieldOptions,\n WpDtoFieldMetadata,\n WpResponseDto,\n ApiJsonSchema,\n DtoValidationFailure,\n DtoSchemaBuilder,\n} from './mcp/DtoSchema';\nexport type { DtoClass, DtoElementType, DtoValue } from './mcp/DtoSchema';\n// The TYPE layer of the auth surface — likewise split out of decorators.ts for file size only.\nexport { AuthMeta } from './http/auth-mode';\nexport type {\n AuthMode,\n ApiKeyCredential,\n ApiKeyCredentials,\n JwtRoles,\n JwtRequirement,\n} from './http/auth-mode';\n// API kind (RPC vs PubSub/Cloud Tasks) + queue naming. Split out of decorators.ts for file size only;\n// one-way dependency api-kind -> decorators, and the barrel keeps the surface identical.\nexport {\n Rpc,\n PubSub,\n Queue,\n ENDPOINT_KINDS_BY_API_KIND,\n getApiKind,\n assertApiKind,\n assertPubSubConventions,\n getQueueName,\n} from './http/api-kind';\nexport type { ApiKind } from './http/api-kind';\n// WHO calls an `external` endpoint — the caller declaration\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 @WpAuthSharedSecret key).\nexport { Secrets, SECRETS } from './http/Secrets';\n\n// Type validators\nexport { ValidateImplementation } from './http/validators';\n\n// Authentication subtype constants.\nexport {\n ENTITY_NOT_FOUND,\n WRONG_LOGIN_TYPE,\n WRONG_LOGIN,\n NOT_APPROVED,\n EMAIL_NOT_CONFIRMED,\n WRONG_DOMAIN,\n WRONG_COMPANY,\n NO_REG_CODE,\n} from './errors';\n\nexport { NetworkRejectClassifier } from './http/networkReject';\n\n// Date/Time DTOs and Utilities (inspired by Java Time / JSR-310)\nexport {\n InstantDto,\n DateDto,\n TimeDto,\n DateTimeDto,\n InstantUtil,\n DateUtil,\n TimeUtil,\n DateTimeUtil,\n} from './http/datetime';\n\n// Context keys + registry (the global magic-context header system)\nexport { HeaderRegistry } from './http/HeaderRegistry';\nexport { ClientRegistry } from './http/ClientRegistry';\nexport { CallRegistry } from './http/CallRegistry';\nexport { CallDeadline } from './http/CallDeadline';\nexport { CallContext } from './http/CallStrategy';\nexport type { Attempt, CallStrategy } from './http/CallStrategy';\nexport { ApiCallTimeoutError } from './http/ApiCallTimeoutError';\nexport type { ServiceUrlDeriver } from './http/ClientRegistry';\n\n// \"What service am I\" — set once at startup, read by the logging backends and by\n// RequestContextHeaders (to stamp requestIdSource on ids this service mints).\nexport { ServiceInfo } from './http/ServiceInfo';\n// \"Where am I running\" — declared once at startup (setupRuntime, from RuntimeSetupOptions.locality).\n// The ONE input to @WpAuthLocalOnly enforcement. Undeclared reads as DEPLOYED (fail safe).\nexport { RuntimeLocality } from './http/RuntimeLocality';\nexport type { Locality } from './http/RuntimeLocality';\n// The ENTIRE HTTP response as pure data — the ONE form both transports (express, fetch) are\n// normalised into, so an 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;A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AAmB,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 WpAuthJwt,\n rolesRequired,\n MISSING_AUTH_DECORATOR_FIX,\n WpAuthOidc,\n WpAuthSharedSecret,\n WpAuthWebhook,\n WpAuthApiKey,\n WpAuthLocalOnly,\n MaskLog,\n getApiPath,\n getEndpoints,\n getEndpointHttpMethod,\n getEndpointOptions,\n getEndpointOperation,\n getEndpointKind,\n getEndpointKinds,\n getMaskSpec,\n isFormPost,\n isRawBody,\n isApiPath,\n getAuthMeta,\n getAuthMode,\n assertEveryEndpointHasAuthMode,\n assertEveryExternalEndpointDeclaresCaller,\n assertEveryWebhookEndpointRetainsRawBody,\n validateNoConflictingDecorators,\n METADATA_KEYS,\n} from './http/decorators';\nexport {\n PathParam,\n QueryParam,\n getHttpParameterDeclarations,\n} from './http/http-parameter-decorators';\nexport { 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 {\n BoundHttpRequest,\n HttpContractMapper,\n HttpParameterBinding,\n HttpParameterDeclaration,\n} from './http/HttpContract';\nexport {\n StreamCorrelation,\n StreamEnvelope,\n StreamingEndpointMetadata,\n StreamEventValidator,\n StreamTransportError,\n StreamWriter,\n WpStream,\n getStreamingEndpoint,\n} from './http/StreamingContract';\nexport type {\n RequestStream,\n ResponseStream,\n StreamEnvelopeKind,\n StreamFailureOptions,\n} from './http/StreamingContract';\nexport type {\n 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 WpMcpTool,\n WpMcpToolHints,\n WpMcpToolMetadata,\n getWpMcpTools,\n mcpHintsForOperation,\n} from './mcp/McpMetadata';\nexport type { WpMcpMethodDecorator } from './mcp/McpMetadata';\nexport { WpMcpAuthJwt, WpMcpJwtAuthMetadata, getWpMcpAuthJwt } from './mcp/McpAuthMetadata';\nexport {\n ApiJsonSchema,\n ApiJsonSchemaValidator,\n DtoValidationFailure,\n ObjectSchemaBuilder,\n} from './mcp/DtoSchema';\nexport type { ApiJsonSchemaType, DtoValue } from './mcp/DtoSchema';\nexport { McpToolCatalog, McpToolCatalogError, McpToolDefinition } from './mcp/McpToolCatalog';\n// The TYPE layer of the auth surface — likewise split out of decorators.ts for file size only.\nexport { AuthMeta } from './http/auth-mode';\nexport type {\n AuthMode,\n ApiKeyCredential,\n ApiKeyCredentials,\n JwtRoles,\n JwtRequirement,\n} from './http/auth-mode';\n// API kind (RPC vs PubSub/Cloud Tasks) + queue naming. Split out of decorators.ts for file size only;\n// one-way dependency api-kind -> decorators, and the barrel keeps the surface identical.\nexport {\n Rpc,\n PubSub,\n Queue,\n ENDPOINT_KINDS_BY_API_KIND,\n getApiKind,\n assertApiKind,\n assertPubSubConventions,\n getQueueName,\n} from './http/api-kind';\nexport type { ApiKind } from './http/api-kind';\n// WHO calls an `external` endpoint — the caller declaration\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 @WpAuthSharedSecret key).\nexport { Secrets, SECRETS } from './http/Secrets';\n\n// Type validators\nexport { ValidateImplementation } from './http/validators';\n\n// Authentication subtype constants.\nexport {\n ENTITY_NOT_FOUND,\n WRONG_LOGIN_TYPE,\n WRONG_LOGIN,\n NOT_APPROVED,\n EMAIL_NOT_CONFIRMED,\n WRONG_DOMAIN,\n WRONG_COMPANY,\n NO_REG_CODE,\n} from './errors';\n\nexport { NetworkRejectClassifier } from './http/networkReject';\n\n// Date/Time DTOs and Utilities (inspired by Java Time / JSR-310)\nexport {\n InstantDto,\n DateDto,\n TimeDto,\n DateTimeDto,\n InstantUtil,\n DateUtil,\n TimeUtil,\n DateTimeUtil,\n} from './http/datetime';\n\n// Context keys + registry (the global magic-context header system)\nexport { HeaderRegistry } from './http/HeaderRegistry';\nexport { ClientRegistry } from './http/ClientRegistry';\nexport { CallRegistry } from './http/CallRegistry';\nexport { CallDeadline } from './http/CallDeadline';\nexport { CallContext } from './http/CallStrategy';\nexport type { Attempt, CallStrategy } from './http/CallStrategy';\nexport { ApiCallTimeoutError } from './http/ApiCallTimeoutError';\nexport type { ServiceUrlDeriver } from './http/ClientRegistry';\n\n// \"What service am I\" — set once at startup, read by the logging backends and by\n// RequestContextHeaders (to stamp requestIdSource on ids this service mints).\nexport { ServiceInfo } from './http/ServiceInfo';\n// \"Where am I running\" — declared once at startup (setupRuntime, from RuntimeSetupOptions.locality).\n// The ONE input to @WpAuthLocalOnly enforcement. Undeclared reads as DEPLOYED (fail safe).\nexport { RuntimeLocality } from './http/RuntimeLocality';\nexport type { Locality } from './http/RuntimeLocality';\n// The ENTIRE HTTP response as pure data — the ONE form both transports (express, fetch) are\n// normalised into, so an 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"]}