@grest-ts/http 0.0.23 → 0.0.24

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 (47) hide show
  1. package/README.md +45 -0
  2. package/dist/src/client/GGHttpSchema.createClient.js +2 -2
  3. package/dist/src/client/GGHttpSchema.createClient.js.map +1 -1
  4. package/dist/src/index-node.d.ts +2 -0
  5. package/dist/src/index-node.d.ts.map +1 -1
  6. package/dist/src/index-node.js +2 -0
  7. package/dist/src/index-node.js.map +1 -1
  8. package/dist/src/rpc/GGHttpRouteRPC.d.ts +19 -6
  9. package/dist/src/rpc/GGHttpRouteRPC.d.ts.map +1 -1
  10. package/dist/src/rpc/GGHttpRouteRPC.js +27 -5
  11. package/dist/src/rpc/GGHttpRouteRPC.js.map +1 -1
  12. package/dist/src/rpc/openApiHelpers.d.ts +21 -0
  13. package/dist/src/rpc/openApiHelpers.d.ts.map +1 -0
  14. package/dist/src/rpc/openApiHelpers.js +70 -0
  15. package/dist/src/rpc/openApiHelpers.js.map +1 -0
  16. package/dist/src/rpc/openApiSuccessResponse.d.ts +15 -0
  17. package/dist/src/rpc/openApiSuccessResponse.d.ts.map +1 -0
  18. package/dist/src/rpc/openApiSuccessResponse.js +32 -0
  19. package/dist/src/rpc/openApiSuccessResponse.js.map +1 -0
  20. package/dist/src/schema/GGHttpSchema.d.ts +66 -1
  21. package/dist/src/schema/GGHttpSchema.d.ts.map +1 -1
  22. package/dist/src/schema/GGHttpSchema.js.map +1 -1
  23. package/dist/src/schema/httpSchema.d.ts.map +1 -1
  24. package/dist/src/schema/httpSchema.js +14 -3
  25. package/dist/src/schema/httpSchema.js.map +1 -1
  26. package/dist/src/server/GGHttp.d.ts +6 -1
  27. package/dist/src/server/GGHttp.d.ts.map +1 -1
  28. package/dist/src/server/GGHttp.js +5 -0
  29. package/dist/src/server/GGHttp.js.map +1 -1
  30. package/dist/src/server/GGHttpSchema.startServer.js +15 -0
  31. package/dist/src/server/GGHttpSchema.startServer.js.map +1 -1
  32. package/dist/src/server/GGHttpServer.d.ts +43 -0
  33. package/dist/src/server/GGHttpServer.d.ts.map +1 -1
  34. package/dist/src/server/GGHttpServer.js +70 -2
  35. package/dist/src/server/GGHttpServer.js.map +1 -1
  36. package/dist/tsconfig.publish.tsbuildinfo +1 -1
  37. package/package.json +10 -10
  38. package/src/client/GGHttpSchema.createClient.ts +2 -2
  39. package/src/index-node.ts +2 -0
  40. package/src/rpc/GGHttpRouteRPC.ts +34 -6
  41. package/src/rpc/openApiHelpers.ts +87 -0
  42. package/src/rpc/openApiSuccessResponse.ts +38 -0
  43. package/src/schema/GGHttpSchema.ts +73 -1
  44. package/src/schema/httpSchema.ts +16 -4
  45. package/src/server/GGHttp.ts +6 -1
  46. package/src/server/GGHttpSchema.startServer.ts +14 -0
  47. package/src/server/GGHttpServer.ts +84 -2
package/README.md CHANGED
@@ -235,6 +235,8 @@ export const GG_CLIENT_INFO = new GGContextKey<ClientInfo>('clientInfo', IsObjec
235
235
  }))
236
236
 
237
237
  export const ClientInfoMiddleware: GGHttpTransportMiddleware = {
238
+ headers: ['x-client-version', 'x-client-platform'],
239
+ responseHeaders: [],
238
240
  updateRequest(req: GGHttpRequest): void {
239
241
  const info = GG_CLIENT_INFO.get()
240
242
  if (info) {
@@ -409,6 +411,49 @@ protected compose(): void {
409
411
  }
410
412
  ```
411
413
 
414
+ ### CORS Headers
415
+
416
+ CORS `Access-Control-Allow-Headers` are auto-discovered from middleware and codecs.
417
+ Only `Content-Type` is included by default (it's set by the framework's RPC layer).
418
+ All other headers — including `Authorization` — are registered automatically when
419
+ middleware declares them via `headers` or when `useHeader()` extracts them from codecs.
420
+
421
+ When using `useHeader()`, header names are extracted from the codec's input schema automatically:
422
+
423
+ ```typescript
424
+ const HeaderType = IsObject({
425
+ "x-org-token": IsString.orUndefined // Auto-discovered as CORS header
426
+ })
427
+ GG_ORG_TOKEN.addCodec("http", HeaderType.codecTo(...))
428
+
429
+ httpSchema(Contract)
430
+ .useHeader(GG_ORG_TOKEN) // "x-org-token" added to CORS Allow-Headers
431
+ .routes({ ... })
432
+ ```
433
+
434
+ Both `headers` (request) and `responseHeaders` (response) are required on middleware and codecs —
435
+ TypeScript enforces this at compile time. Use `[]` when not applicable:
436
+
437
+ ```typescript
438
+ export const MyMiddleware: GGHttpTransportMiddleware = {
439
+ headers: ['x-custom-header'],
440
+ responseHeaders: [],
441
+ updateRequest(req) { ... },
442
+ parseRequest(req) { ... }
443
+ }
444
+ ```
445
+
446
+ Codecs also declare `responseHeaders`. For example, `GGFileDownload` declares
447
+ `['Content-Disposition']` which is automatically added to `Access-Control-Expose-Headers`.
448
+
449
+ You can also register headers manually on the server:
450
+
451
+ ```typescript
452
+ const httpServer = new GGHttpServer()
453
+ httpServer.registerCorsHeaders(['x-custom-header'])
454
+ httpServer.registerCorsExposeHeaders(['x-custom-response-header'])
455
+ ```
456
+
412
457
  ## HTTP Client
413
458
 
414
459
  ### Creating Clients
@@ -73,8 +73,8 @@ export function createClient(httpSchema, config) {
73
73
  return new GGPromise(implementation(data));
74
74
  };
75
75
  }
76
- // @TODO Next line is just so test would register it correctly.
77
- httpSchema.contract.implement(transportImplementation);
76
+ // Per-client stub doesn't belong in the callOn registry (server's impl does).
77
+ httpSchema.contract.implement(transportImplementation, { skipLocatorRegistration: true });
78
78
  return transportImplementation;
79
79
  }
80
80
  //# sourceMappingURL=GGHttpSchema.createClient.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GGHttpSchema.createClient.js","sourceRoot":"","sources":["../../../src/client/GGHttpSchema.createClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,EAA6C,kBAAkB,EAA4B,SAAS,EAAM,YAAY,EAAC,MAAM,kBAAkB,CAAA;AACvK,OAAO,EAAwD,YAAY,EAAC,MAAM,wBAAwB,CAAC;AAC3G,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAe3C,YAAY,CAAC,SAAS,CAAC,YAAY,GAAG,UA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,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,kBAAkB,CAAC,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;gBAC1G,CAAC;qBAAM,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;oBACpC,OAAO,CAAC,IAAI,GAAG,SAAS,CAAA;gBAC5B,CAAC;gBACD,IAAI,OAAO,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;oBAC3B,OAAO,OAAsB,CAAC;gBAClC,CAAC;qBAAM,CAAC;oBACJ,OAAO,kBAAkB,CAAC,cAAc,CAAC,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;gBAC/E,CAAC;gBACD,gDAAgD;YACpD,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,OAAO,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;YACpC,CAAC;QACL,CAAC,CAAC;QAEF,uBAAuB,CAAC,UAAU,CAAC,GAAG,CAAC,IAAc,EAAE,EAAE;YACrD,OAAO,IAAI,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAA;QAC9C,CAAC,CAAA;IAEL,CAAC;IACD,gFAAgF;IAChF,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,uBAA8D,EAAE,EAAC,uBAAuB,EAAE,IAAI,EAAC,CAAC,CAAA;IAC9H,OAAO,uBAAuB,CAAC;AACnC,CAAC"}
@@ -3,6 +3,8 @@ export * from "./server/GG_HTTP_REQUEST";
3
3
  export * from "./schema/GGHttpSchema";
4
4
  export * from "./schema/httpSchema";
5
5
  export * from "./rpc/GGHttpRouteRPC";
6
+ export * from "./rpc/openApiSuccessResponse";
7
+ export * from "./rpc/openApiHelpers";
6
8
  export * from "./rpc/RpcRequest/GGRpcRequestBuilder";
7
9
  export * from "./rpc/RpcRequest/GGRpcRequestParser";
8
10
  export * from "./rpc/RpcResponse/GGRpcResponseBuilder";
@@ -1 +1 @@
1
- {"version":3,"file":"index-node.d.ts","sourceRoot":"","sources":["../../src/index-node.ts"],"names":[],"mappings":"AAUA,cAAc,wBAAwB,CAAC;AAGvC,cAAc,0BAA0B,CAAC;AAGzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sCAAsC,CAAC;AACrD,cAAc,qCAAqC,CAAC;AACpD,cAAc,wCAAwC,CAAC;AACvD,cAAc,uCAAuC,CAAC;AAGtD,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AAGxC,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAIlD,OAAO,oCAAoC,CAAC;AAC5C,OAAO,mCAAmC,CAAC"}
1
+ {"version":3,"file":"index-node.d.ts","sourceRoot":"","sources":["../../src/index-node.ts"],"names":[],"mappings":"AAUA,cAAc,wBAAwB,CAAC;AAGvC,cAAc,0BAA0B,CAAC;AAGzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sCAAsC,CAAC;AACrD,cAAc,qCAAqC,CAAC;AACpD,cAAc,wCAAwC,CAAC;AACvD,cAAc,uCAAuC,CAAC;AAGtD,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AAGxC,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAIlD,OAAO,oCAAoC,CAAC;AAC5C,OAAO,mCAAmC,CAAC"}
@@ -14,6 +14,8 @@ export * from "./server/GG_HTTP_REQUEST.js";
14
14
  export * from "./schema/GGHttpSchema.js";
15
15
  export * from "./schema/httpSchema.js";
16
16
  export * from "./rpc/GGHttpRouteRPC.js";
17
+ export * from "./rpc/openApiSuccessResponse.js";
18
+ export * from "./rpc/openApiHelpers.js";
17
19
  export * from "./rpc/RpcRequest/GGRpcRequestBuilder.js";
18
20
  export * from "./rpc/RpcRequest/GGRpcRequestParser.js";
19
21
  export * from "./rpc/RpcResponse/GGRpcResponseBuilder.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index-node.js","sourceRoot":"","sources":["../../src/index-node.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,OAAO,EAAC,8BAA8B,EAAC,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAC,oBAAoB,EAAC,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAC,kBAAkB,EAAC,MAAM,qCAAqC,CAAC;AACvE,8BAA8B,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;IACtD,YAAY,EAAE,IAAI,kBAAkB,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,YAAY;IACvE,YAAY,EAAE,IAAI,oBAAoB,CAAC,MAAM,CAAC,CAAC,YAAY;CAC9D,CAAC,CAAC,CAAC;AAEJ,UAAU;AACV,cAAc,wBAAwB,CAAC;AAEvC,UAAU;AACV,cAAc,0BAA0B,CAAC;AAEzC,aAAa;AACb,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sCAAsC,CAAC;AACrD,cAAc,qCAAqC,CAAC;AACpD,cAAc,wCAAwC,CAAC;AACvD,cAAc,uCAAuC,CAAC;AAEtD,+BAA+B;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AAExC,SAAS;AACT,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAGlD,aAAa;AACb,OAAO,oCAAoC,CAAC;AAC5C,OAAO,mCAAmC,CAAC"}
1
+ {"version":3,"file":"index-node.js","sourceRoot":"","sources":["../../src/index-node.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,OAAO,EAAC,8BAA8B,EAAC,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAC,oBAAoB,EAAC,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAC,kBAAkB,EAAC,MAAM,qCAAqC,CAAC;AACvE,8BAA8B,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;IACtD,YAAY,EAAE,IAAI,kBAAkB,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,YAAY;IACvE,YAAY,EAAE,IAAI,oBAAoB,CAAC,MAAM,CAAC,CAAC,YAAY;CAC9D,CAAC,CAAC,CAAC;AAEJ,UAAU;AACV,cAAc,wBAAwB,CAAC;AAEvC,UAAU;AACV,cAAc,0BAA0B,CAAC;AAEzC,aAAa;AACb,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sCAAsC,CAAC;AACrD,cAAc,qCAAqC,CAAC;AACpD,cAAc,wCAAwC,CAAC;AACvD,cAAc,uCAAuC,CAAC;AAEtD,+BAA+B;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AAExC,SAAS;AACT,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAGlD,aAAa;AACb,OAAO,oCAAoC,CAAC;AAC5C,OAAO,mCAAmC,CAAC"}
@@ -1,19 +1,32 @@
1
1
  import { HttpMethod } from "@grest-ts/common";
2
- import { ClientHttpRouteToRpcTransformClientCodec, ClientHttpRouteToRpcTransformClientConfig, ClientHttpRouteToRpcTransformServerCodec, ClientHttpRouteToRpcTransformServerConfig, GGHttpCodec } from "../schema/GGHttpSchema";
2
+ import { ClientHttpRouteToRpcTransformClientCodec, ClientHttpRouteToRpcTransformClientConfig, ClientHttpRouteToRpcTransformServerCodec, ClientHttpRouteToRpcTransformServerConfig, GGHttpCodec, GGHttpCodecOpenApiConfig } from "../schema/GGHttpSchema";
3
+ import type { OpenAPIV3_1 } from "openapi-types";
4
+ import { GGSchema } from "@grest-ts/schema";
3
5
  export type GGRpcServerCodecFactory = (method: HttpMethod, path: string, config: ClientHttpRouteToRpcTransformServerConfig) => ClientHttpRouteToRpcTransformServerCodec;
4
6
  export declare function _registerRpcServerCodecFactory(factory: GGRpcServerCodecFactory): void;
5
7
  export declare const GGRpc: {
6
- GET: (path: string) => GGHttpRpcCodec;
7
- DELETE: (path: string) => GGHttpRpcCodec;
8
- POST: (path: string) => GGHttpRpcCodec;
9
- PUT: (path: string) => GGHttpRpcCodec;
8
+ GET: (path: string, opts?: {
9
+ deprecated?: boolean;
10
+ }) => GGHttpRpcCodec;
11
+ DELETE: (path: string, opts?: {
12
+ deprecated?: boolean;
13
+ }) => GGHttpRpcCodec;
14
+ POST: (path: string, opts?: {
15
+ deprecated?: boolean;
16
+ }) => GGHttpRpcCodec;
17
+ PUT: (path: string, opts?: {
18
+ deprecated?: boolean;
19
+ }) => GGHttpRpcCodec;
10
20
  };
11
21
  declare class GGHttpRpcCodec implements GGHttpCodec {
12
22
  readonly method: HttpMethod;
13
23
  readonly path: string;
14
- constructor(method: HttpMethod, path: string);
24
+ readonly deprecated: boolean | undefined;
25
+ readonly responseHeaders: Record<string, GGSchema<string | undefined>>;
26
+ constructor(method: HttpMethod, path: string, deprecated?: boolean);
15
27
  createForClient(config: ClientHttpRouteToRpcTransformClientConfig): ClientHttpRouteToRpcTransformClientCodec;
16
28
  createForServer(config: ClientHttpRouteToRpcTransformServerConfig): ClientHttpRouteToRpcTransformServerCodec;
29
+ toOpenApiOperation(config: GGHttpCodecOpenApiConfig): Partial<OpenAPIV3_1.OperationObject>;
17
30
  }
18
31
  export {};
19
32
  //# sourceMappingURL=GGHttpRouteRPC.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GGHttpRouteRPC.d.ts","sourceRoot":"","sources":["../../../src/rpc/GGHttpRouteRPC.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAC,wCAAwC,EAAE,yCAAyC,EAAE,wCAAwC,EAAE,yCAAyC,EAAE,WAAW,EAAC,MAAM,wBAAwB,CAAA;AAI5N,MAAM,MAAM,uBAAuB,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,yCAAyC,KAAK,wCAAwC,CAAC;AAIxK,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,uBAAuB,GAAG,IAAI,CAErF;AAED,eAAO,MAAM,KAAK;gBACF,MAAM;mBACH,MAAM;iBACR,MAAM;gBACP,MAAM;CACrB,CAAA;AAED,cAAM,cAAe,YAAW,WAAW;IAEvC,SAAgB,MAAM,EAAE,UAAU,CAAA;IAClC,SAAgB,IAAI,EAAE,MAAM,CAAA;gBAEhB,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM;IAKrC,eAAe,CAAC,MAAM,EAAE,yCAAyC,GAAG,wCAAwC;IAO5G,eAAe,CAAC,MAAM,EAAE,yCAAyC,GAAG,wCAAwC;CAItH"}
1
+ {"version":3,"file":"GGHttpRouteRPC.d.ts","sourceRoot":"","sources":["../../../src/rpc/GGHttpRouteRPC.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAC,wCAAwC,EAAE,yCAAyC,EAAE,wCAAwC,EAAE,yCAAyC,EAAE,WAAW,EAAE,wBAAwB,EAAC,MAAM,wBAAwB,CAAA;AAGtP,OAAO,KAAK,EAAC,WAAW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SuccessResponses } from "./openApiSuccessResponse.js";
4
+ import { buildOpenApiParameters } from "./openApiHelpers.js";
3
5
  let _serverCodecFactory;
4
6
  export function _registerRpcServerCodecFactory(factory) {
5
7
  _serverCodecFactory = factory;
6
8
  }
7
9
  export const GGRpc = {
8
- GET: (path) => new GGHttpRpcCodec("GET", path),
9
- DELETE: (path) => new GGHttpRpcCodec("DELETE", path),
10
- POST: (path) => new GGHttpRpcCodec("POST", path),
11
- PUT: (path) => new GGHttpRpcCodec("PUT", path),
10
+ GET: (path, opts) => new GGHttpRpcCodec("GET", path, opts?.deprecated),
11
+ DELETE: (path, opts) => new GGHttpRpcCodec("DELETE", path, opts?.deprecated),
12
+ POST: (path, opts) => new GGHttpRpcCodec("POST", path, opts?.deprecated),
13
+ PUT: (path, opts) => new GGHttpRpcCodec("PUT", path, opts?.deprecated),
12
14
  };
13
15
  class GGHttpRpcCodec {
14
16
  method;
15
17
  path;
16
- constructor(method, path) {
18
+ deprecated;
19
+ responseHeaders = {};
20
+ constructor(method, path, deprecated) {
17
21
  this.method = method;
18
22
  this.path = path;
23
+ this.deprecated = deprecated;
19
24
  }
20
25
  createForClient(config) {
21
26
  return {
@@ -28,5 +33,22 @@ class GGHttpRpcCodec {
28
33
  throw new Error("Server RPC codec not available. Ensure @grest-ts/http server entry is imported.");
29
34
  return _serverCodecFactory(this.method, this.path, config);
30
35
  }
36
+ toOpenApiOperation(config) {
37
+ const hasBody = this.method === "POST" || this.method === "PUT" || this.method === "PATCH";
38
+ const operationId = config.methodName;
39
+ const parameters = buildOpenApiParameters(this.path, hasBody, config.contract.input ?? undefined, config.schemaResolver);
40
+ const operation = {
41
+ operationId,
42
+ parameters,
43
+ responses: buildRpcSuccessResponses(config.contract, config.schemaResolver)
44
+ };
45
+ if (hasBody && config.contract.input) {
46
+ operation.requestBody = {
47
+ required: true,
48
+ content: { 'application/json': { schema: config.schemaResolver(config.contract.input.toSchemaDescription()) } }
49
+ };
50
+ }
51
+ return operation;
52
+ }
31
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CAAC;YACnC,SAAS,CAAC,WAAW,GAAG;gBACpB,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,EAAC,kBAAkB,EAAE,EAAC,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,mBAAmB,EAAE,CAAC,EAAC,EAAC;aAC9G,CAAC;QACN,CAAC;QAED,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ"}
@@ -0,0 +1,21 @@
1
+ import type { GGSchema } from "@grest-ts/schema";
2
+ import type { GGOpenApiSchemaResolver } from "../schema/GGHttpSchema";
3
+ import type { OpenAPIV3_1 } from "openapi-types";
4
+ /**
5
+ * Build OpenAPI parameter objects for a route from the contract's input schema.
6
+ *
7
+ * Path parameters are extracted from the path template (:id → {id}).
8
+ * For GET/DELETE (no body), remaining input fields become query parameters.
9
+ *
10
+ * Uses toSchemaDescription() to walk the input object's fields as
11
+ * GGSchemaDescription instances, then passes each to schemaResolver so named
12
+ * schemas are emitted as $ref where applicable.
13
+ *
14
+ * Type-cast note: openapi-types@12 defines OpenAPIV3_1.ParameterObject as a
15
+ * direct alias of OpenAPIV3.ParameterObject, whose `schema` field resolves to
16
+ * V3 schema types (missing `type:"null"` as a valid NonArraySchemaObjectType).
17
+ * The casts to ParameterObject["schema"] are the precise boundary of that
18
+ * typedef limitation — runtime objects are fully valid OpenAPI 3.1 parameters.
19
+ */
20
+ export declare function buildOpenApiParameters(pathTemplate: string, hasBody: boolean, inputSchema: GGSchema<unknown> | undefined, schemaResolver: GGOpenApiSchemaResolver): OpenAPIV3_1.ParameterObject[];
21
+ //# sourceMappingURL=openApiHelpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openApiHelpers.d.ts","sourceRoot":"","sources":["../../../src/rpc/openApiHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAsB,MAAM,kBAAkB,CAAC;AACpE,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,wBAAwB,CAAC;AACpE,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAE/C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CAClC,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,SAAS,EAC1C,cAAc,EAAE,uBAAuB,GACxC,WAAW,CAAC,eAAe,EAAE,CAuC/B"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Build OpenAPI parameter objects for a route from the contract's input schema.
3
+ *
4
+ * Path parameters are extracted from the path template (:id → {id}).
5
+ * For GET/DELETE (no body), remaining input fields become query parameters.
6
+ *
7
+ * Uses toSchemaDescription() to walk the input object's fields as
8
+ * GGSchemaDescription instances, then passes each to schemaResolver so named
9
+ * schemas are emitted as $ref where applicable.
10
+ *
11
+ * Type-cast note: openapi-types@12 defines OpenAPIV3_1.ParameterObject as a
12
+ * direct alias of OpenAPIV3.ParameterObject, whose `schema` field resolves to
13
+ * V3 schema types (missing `type:"null"` as a valid NonArraySchemaObjectType).
14
+ * The casts to ParameterObject["schema"] are the precise boundary of that
15
+ * typedef limitation — runtime objects are fully valid OpenAPI 3.1 parameters.
16
+ */
17
+ export function buildOpenApiParameters(pathTemplate, hasBody, inputSchema, schemaResolver) {
18
+ const pathParams = (pathTemplate.match(/:(\w+)/g) || []).map(m => m.slice(1));
19
+ if (!inputSchema)
20
+ return pathParams.map(name => buildPathParam(name, undefined, schemaResolver));
21
+ // Use toSchemaDescription() to get GGSchemaDescription instances per field.
22
+ // This gives us the format-agnostic tree without coupling to internal def structure.
23
+ const desc = inputSchema.toSchemaDescription();
24
+ if (desc.node.kind !== 'object') {
25
+ // Input schemas must be object schemas so their fields can be mapped to
26
+ // path/query parameters. Any other kind is a contract definition error.
27
+ throw new Error(`buildOpenApiParameters: input schema must be an object schema (kind='object'), ` +
28
+ `got kind='${desc.node.kind}'. Contract input schemas must use IsObject({...}).`);
29
+ }
30
+ const properties = desc.node.properties;
31
+ const params = pathParams.map(name => buildPathParam(name, properties[name], schemaResolver));
32
+ if (!hasBody) {
33
+ for (const [name, fieldDesc] of Object.entries(properties)) {
34
+ if (pathParams.includes(name))
35
+ continue;
36
+ const resolved = schemaResolver(fieldDesc);
37
+ const { description, ...schemaWithoutDescription } = resolved;
38
+ const isRequired = !fieldDesc.optional && resolved.default === undefined;
39
+ const param = {
40
+ name,
41
+ in: 'query',
42
+ required: isRequired,
43
+ schema: schemaWithoutDescription
44
+ };
45
+ if (description)
46
+ param.description = description;
47
+ params.push(param);
48
+ }
49
+ }
50
+ return params;
51
+ }
52
+ function buildPathParam(name, fieldDesc, schemaResolver) {
53
+ if (!fieldDesc) {
54
+ // Path params are always non-empty — an empty segment cannot be routed.
55
+ return { name, in: 'path', required: true,
56
+ schema: { type: 'string', minLength: 1 } };
57
+ }
58
+ const resolved = schemaResolver(fieldDesc);
59
+ const { description, ...schemaWithoutDescription } = resolved;
60
+ const param = {
61
+ name,
62
+ in: 'path',
63
+ required: true,
64
+ schema: schemaWithoutDescription
65
+ };
66
+ if (description)
67
+ param.description = description;
68
+ return param;
69
+ }
70
+ //# sourceMappingURL=openApiHelpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openApiHelpers.js","sourceRoot":"","sources":["../../../src/rpc/openApiHelpers.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,sBAAsB,CAClC,YAAoB,EACpB,OAAgB,EAChB,WAA0C,EAC1C,cAAuC;IAEvC,MAAM,UAAU,GAAG,CAAC,YAAY,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9E,IAAI,CAAC,WAAW;QAAE,OAAO,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CA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vB,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC;AAED,SAAS,cAAc,CACnB,IAAY,EACZ,SAA0C,EAC1C,cAAuC;IAEvC,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,wEAAwE;QACxE,OAAO,EAAC,IAAI,EAAE,EAAE,EAAE,MAAe,EAAE,QAAQ,EAAE,IAAa;YACtD,MAAM,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAA0C,EAAC,CAAC;IACzF,CAAC;IACD,MAAM,QAAQ,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;IAC3C,MAAM,EAAC,WAAW,EAAE,GAAG,wBAAwB,EAAC,GAAG,QAAe,CAAC;IACnE,MAAM,KAAK,GAAgC;QACvC,IAAI;QACJ,EAAE,EAAE,MAAe;QACnB,QAAQ,EAAE,IAAa;QACvB,MAAM,EAAE,wBAAiE;KAC5E,CAAC;IACF,IAAI,WAAW;QAAE,KAAK,CAAC,WAAW,GAAG,WAAW,CAAC;IACjD,OAAO,KAAK,CAAC;AACjB,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { GGContractMethod } from "@grest-ts/schema";
2
+ import type { OpenAPIV3_1 } from "openapi-types";
3
+ import type { GGOpenApiSchemaResolver } from "../schema/GGHttpSchema";
4
+ /**
5
+ * Builds the standard GGRpc JSON-envelope success response for OpenAPI.
6
+ *
7
+ * On-wire the response is always:
8
+ * { success: true, type: "OK", data: <success schema> } (200)
9
+ * or no body (204 when no success schema)
10
+ *
11
+ * The resolver is used to emit $ref for named success schemas rather than
12
+ * inlining them. Pass config.schemaResolver from toOpenApiOperation().
13
+ */
14
+ export declare function buildRpcSuccessResponses(contract: GGContractMethod, resolver: GGOpenApiSchemaResolver): OpenAPIV3_1.ResponsesObject;
15
+ //# sourceMappingURL=openApiSuccessResponse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openApiSuccessResponse.d.ts","sourceRoot":"","sources":["../../../src/rpc/openApiSuccessResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,wBAAwB,CAAC;AAEpE;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACpC,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,uBAAuB,GAClC,WAAW,CAAC,eAAe,CAoB7B"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Builds the standard GGRpc JSON-envelope success response for OpenAPI.
3
+ *
4
+ * On-wire the response is always:
5
+ * { success: true, type: "OK", data: <success schema> } (200)
6
+ * or no body (204 when no success schema)
7
+ *
8
+ * The resolver is used to emit $ref for named success schemas rather than
9
+ * inlining them. Pass config.schemaResolver from toOpenApiOperation().
10
+ */
11
+ export function buildRpcSuccessResponses(contract, resolver) {
12
+ if (contract.success) {
13
+ const dataSchema = resolver(contract.success.toSchemaDescription());
14
+ const successSchema = {
15
+ type: "object",
16
+ properties: {
17
+ success: { type: "boolean", enum: [true] },
18
+ type: { type: "string", enum: ["OK"] },
19
+ data: dataSchema
20
+ },
21
+ required: ["success", "type", "data"]
22
+ };
23
+ return {
24
+ "200": {
25
+ description: "Success",
26
+ content: { "application/json": { schema: successSchema } }
27
+ }
28
+ };
29
+ }
30
+ return { "204": { description: "No content" } };
31
+ }
32
+ //# sourceMappingURL=openApiSuccessResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openApiSuccessResponse.js","sourceRoot":"","sources":["../../../src/rpc/openApiSuccessResponse.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,MAAM,UAAU,wBAAwB,CACpC,QAA0B,EAC1B,QAAiC;IAEjC,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;QACnB,MAAM,UAAU,GAAG,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAAC;QACpE,MAAM,aAAa,GAAqC;YACpD,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACR,OAAO,EAAE,EAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,EAAC;gBACxC,IAAI,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,EAAC;gBACpC,IAAI,EAAE,UAAU;aACnB;YACD,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC;SACxC,CAAC;QACF,OAAO;YACH,KAAK,EAAE;gBACH,WAAW,EAAE,SAAS;gBACtB,OAAO,EAAE,EAAC,kBAAkB,EAAE,EAAC,MAAM,EAAE,aAAa,EAAC,EAAC;aACzD;SACJ,CAAC;IACN,CAAC;IACD,OAAO,EAAC,KAAK,EAAE,EAAC,WAAW,EAAE,YAAY,EAAC,EAAC,CAAC;AAChD,CAAC"}
@@ -1,7 +1,8 @@
1
- import { ERROR, ERROR_JSON, GGContractApiDefinition, GGContractClass, GGContractMethod, OK } from "@grest-ts/schema";
1
+ import { ERROR, ERROR_JSON, GGContractApiDefinition, GGContractClass, GGContractMethod, GGSchema, GGSchemaDescription, OK } from "@grest-ts/schema";
2
2
  import type { HttpMethod } from "@grest-ts/common";
3
3
  import type http from "http";
4
4
  import type { GGHttpServerMiddleware } from "../server/GGHttpSchema.startServer";
5
+ import type { OpenAPIV3_1 } from "openapi-types";
5
6
  export declare class GGHttpSchema<TContract extends GGContractApiDefinition, TContext> {
6
7
  readonly name: string;
7
8
  readonly pathPrefix: string;
@@ -34,13 +35,77 @@ export interface ClientHttpRouteToRpcTransformServerCodec {
34
35
  parseRequest: (req: http.IncomingMessage) => Promise<unknown>;
35
36
  sendResponse: (res: http.ServerResponse, rpcResult: ERROR<string, unknown> | OK<unknown>) => Promise<void>;
36
37
  }
38
+ /**
39
+ * Config passed to toOpenApiOperation? — gives the codec access to the contract and route context
40
+ * so it can produce accurate OpenAPI operation metadata.
41
+ */
42
+ /**
43
+ * Resolves a GGSchemaDescription to an OpenAPI SchemaObject or ReferenceObject.
44
+ * When provided via GGHttpCodecOpenApiConfig, codecs should use this for all schema
45
+ * conversions — it enables $ref extraction for named schemas.
46
+ * For standalone use (tests, custom tools), use inlineSchemaResolver from @grest-ts/openapi.
47
+ */
48
+ export type GGOpenApiSchemaResolver = (desc: GGSchemaDescription) => OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject;
49
+ export interface GGHttpCodecOpenApiConfig {
50
+ readonly pathPrefix: string;
51
+ readonly methodName: string;
52
+ readonly contract: GGContractMethod;
53
+ /**
54
+ * Resolves a GGSchema to an OpenAPI SchemaObject or ReferenceObject.
55
+ * Provided by the document builder (toOpenApi) as registry.schemaOrRef.
56
+ * For standalone codec use or tests, pass inlineSchemaResolver from @grest-ts/openapi.
57
+ */
58
+ readonly schemaResolver: GGOpenApiSchemaResolver;
59
+ }
37
60
  export interface GGHttpCodec {
38
61
  readonly method: HttpMethod;
39
62
  readonly path: string;
63
+ /**
64
+ * Mark this operation as deprecated in the OpenAPI spec.
65
+ * Swagger UI renders deprecated operations with a strikethrough.
66
+ * @default false
67
+ */
68
+ readonly deprecated?: boolean;
69
+ /**
70
+ * Response headers this codec sets, mapped to their value schemas.
71
+ * Keys are header names; values describe the header value format.
72
+ * Used for CORS Access-Control-Expose-Headers and OpenAPI response header docs.
73
+ * Use {} if the codec sets no custom response headers.
74
+ */
75
+ readonly responseHeaders: Record<string, GGSchema<string | undefined>>;
40
76
  createForClient(config: ClientHttpRouteToRpcTransformClientConfig): ClientHttpRouteToRpcTransformClientCodec;
41
77
  createForServer(config: ClientHttpRouteToRpcTransformServerConfig): ClientHttpRouteToRpcTransformServerCodec;
78
+ /**
79
+ * Optional hook for custom codecs to describe their OpenAPI operation semantics.
80
+ * The returned partial is merged on top of the auto-generated operation object,
81
+ * allowing overrides for requestBody content type, security schemes, etc.
82
+ *
83
+ * Built-in GGRpc.* codecs implement this automatically.
84
+ * Custom codec authors (e.g. GGFileUpload) may implement it for accurate docs.
85
+ */
86
+ toOpenApiOperation?(config: GGHttpCodecOpenApiConfig): Partial<OpenAPIV3_1.OperationObject>;
42
87
  }
43
88
  export interface GGHttpTransportMiddleware {
89
+ /**
90
+ * Request headers this middleware reads or writes, mapped to their value schemas.
91
+ * Keys are header names; values describe the header value format for validation and docs.
92
+ * Used for CORS Access-Control-Allow-Headers and OpenAPI parameter docs.
93
+ * Use {} if the middleware touches no custom request headers.
94
+ *
95
+ * @example
96
+ * headers: {
97
+ * "authorization": IsString.nonEmpty.docs({title: "Bearer token", example: "Bearer ..."}),
98
+ * "accept-language": IsLocale.orUndefined
99
+ * }
100
+ */
101
+ readonly headers: Record<string, GGSchema<string | undefined>>;
102
+ /**
103
+ * Response headers this middleware sets, mapped to their value schemas.
104
+ * Keys are header names; values describe the header value format for validation and docs.
105
+ * Used for CORS Access-Control-Expose-Headers and OpenAPI response header docs.
106
+ * Use {} if the middleware sets no custom response headers.
107
+ */
108
+ readonly responseHeaders: Record<string, GGSchema<string | undefined>>;
44
109
  /**
45
110
  * Client-side: modify outgoing request (add headers, etc.)
46
111
  */
@@ -1 +1 @@
1
- {"version":3,"file":"GGHttpSchema.d.ts","sourceRoot":"","sources":["../../../src/schema/GGHttpSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,UAAU,EAAE,uBAAuB,EAAE,eAAe,EAAE,gBAAgB,EAAE,EAAE,EAAC,MAAM,kBAAkB,CAAC;AACnH,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,oCAAoC,CAAC;AAE/E,qBAAa,YAAY,CAAC,SAAS,SAAS,uBAAuB,EAAE,QAAQ;IAEzE,SAAgB,IAAI,EAAE,MAAM,CAAA;IA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,EAAE,CAAC,CAAC;CAC9C"}
@@ -1 +1 @@
1
- {"version":3,"file":"GGHttpSchema.js","sourceRoot":"","sources":["../../../src/schema/GGHttpSchema.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,YAAY;IAEL,IAAI,CAAQ;IACZ,UAAU,CAAQ;IAClB,cAAc,CAAsC;IACpD,KAAK,CAAsC;IAC3C,QAAQ,GAAsC,IAAI,CAAA;IAElE,YACI,UAAkB,EAClB,QAAoC,EACpC,SAA+C,EAC/C,cAAoD,EAAE;QAEtD,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAA;QACzB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,cAAc,GAAG,WAAW,CAAA;QACjC,IAAI,CAAC,KAAK,GAAG,SAAS,CAAA;QACtB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;QAClC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACzB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACvB,CAAC;CACJ"}
1
+ {"version":3,"file":"GGHttpSchema.js","sourceRoot":"","sources":["../../../src/schema/GGHttpSchema.ts"],"names":[],"mappings":"AAMA,MAAM,OAAO,YAAY;IAEL,IAAI,CAAQ;IACZ,UAAU,CAAQ;IAClB,cAAc,CAAsC;IACpD,KAAK,CAAsC;IAC3C,QAAQ,GAAsC,IAAI,CAAA;IAElE,YACI,UAAkB,EAClB,QAAoC,EACpC,SAA+C,EAC/C,cAAoD,EAAE;QAEtD,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAA;QACzB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,cAAc,GAAG,WAAW,CAAA;QACjC,IAAI,CAAC,KAAK,GAAG,SAAS,CAAA;QACtB,IAAI,CAAC,QA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,EAAE,QAAQ,CAAC;CAG9F"}
@@ -46,9 +46,22 @@ class GGHttpSchemaBuilder {
46
46
  if (!codec) {
47
47
  throw new Error(`Context key '${contextKey.name}' does not have an 'http-header' codec registered.`);
48
48
  }
49
+ // Build the typed header map from codec.inputSchema — the IsObject({headerName: schema})
50
+ // that describes which headers this codec reads and what format each value has.
51
+ const inputSchema = codec.inputSchema;
52
+ const headers = {};
53
+ if (inputSchema) {
54
+ const desc = inputSchema.toSchemaDescription();
55
+ if (desc.node.kind === 'object') {
56
+ for (const [k, fieldDesc] of Object.entries(desc.node.properties)) {
57
+ headers[k] = fieldDesc.schema;
58
+ }
59
+ }
60
+ }
49
61
  const middleware = {
62
+ headers,
63
+ responseHeaders: {},
50
64
  updateRequest(req) {
51
- // Client-side: context -> headers
52
65
  const contextValue = contextKey.get();
53
66
  if (contextValue !== undefined) {
54
67
  const result = codec.decode(contextValue);
@@ -57,7 +70,6 @@ class GGHttpSchemaBuilder {
57
70
  }
58
71
  }
59
72
  else {
60
- // Clear any default headers by decoding an empty context
61
73
  const emptyResult = codec.decode({});
62
74
  if (emptyResult.success) {
63
75
  for (const key of Object.keys(emptyResult.value)) {
@@ -67,7 +79,6 @@ class GGHttpSchemaBuilder {
67
79
  }
68
80
  },
69
81
  parseRequest(req) {
70
- // Server-side: headers -> context
71
82
  const headers = req.headers;
72
83
  const result = codec.encode(headers);
73
84
  if (result.success) {
@@ -1 +1 @@
1
- {"version":3,"file":"httpSchema.js","sourceRoot":"","sources":["../../../src/schema/httpSchema.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAKzD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,UAAU,CACtB,QAAoC;IAEpC,OAAO,IAAI,mBAAmB,CAAC,QAAQ,CAAC,CAAA;AAC5C,CAAC;AAED,MAAM,mBAAmB;IAEJ,SAAS,CAA4B;IAC9C,WAAW,GAAW,EAAE,CAAA;IACxB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AW,CAAC,CAAC;oBAC9C,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC;wBACtB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,KAAe,CAAC,EAAE,CAAC;4BACzD,OAAO,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;wBAC5B,CAAC;oBACL,CAAC;gBACL,CAAC;YACL,CAAC;YACD,YAAY,CAAC,GAAyB;gBAClC,MAAM,OAAO,GAAG,GAAG,CAAC,OAAiC,CAAC;gBACtD,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;gBACrC,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;oBACjB,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACjC,CAAC;YACL,CAAC;SACJ,CAAC;QAEF,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACnC,OAAO,IAAmE,CAAC;IAC/E,CAAC;IAED,MAAM,CAAC,OAAgD;QACnD,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,CAAA;IACzF,CAAC;CACJ"}
@@ -3,7 +3,12 @@ import { GGContractApiDefinition, GGContractImplementation } from "@grest-ts/sch
3
3
  import { GGHttpServerMiddleware } from "./GGHttpSchema.startServer";
4
4
  import { GGHttpServer } from "./GGHttpServer";
5
5
  export declare class GGHttp<TContext = undefined> {
6
- private readonly httpServer;
6
+ /**
7
+ * Protected (not private) so that plugin modules can access the underlying server
8
+ * via module augmentation (e.g. @grest-ts/openapi adds .openApi() to the builder).
9
+ * Do not tighten back to private.
10
+ */
11
+ protected readonly httpServer: GGHttpServer;
7
12
  private readonly middlewares;
8
13
  constructor(httpServer: GGHttpServer);
9
14
  use<M extends GGHttpServerMiddleware>(middleware: M): GGHttp<TContext | M>;
@@ -1 +1 @@
1
- {"version":3,"file":"GGHttp.d.ts","sourceRoot":"","sources":["../../../src/server/GGHttp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAC,uBAAuB,EAAE,wBAAwB,EAAC,MAAM,kBAAkB,CAAC;AACnF,OAAO,EAAC,sBAAsB,EAAC,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,qBAAa,MAAM,CAAC,QAAQ,GAAG,SAAS;IAEpC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAc;IACzC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAgC;gBAEhD,UAAU,EAAE,YAAY;IAI7B,GAAG,CAAC,CAAC,SAAS,sBAAsB,EAAE,UAAU,EAAE,CAAC,GAAG,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC;IAK1E,IAAI,CAAC,SAAS,SAAS,uBAAuB,EAAE,cAAc,EACjE,MAAM,EAAE,YAAY,CAAC,SAAS,EAAE,cAAc,CAAC,EAC/C,cAAc,EAAE,wBAAwB,CAAC,SAAS,CAAC,GACpD,IAAI;CAIV"}
1
+ {"version":3,"file":"GGHttp.d.ts","sourceRoot":"","sources":["../../../src/server/GGHttp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAC,uBAAuB,EAAE,wBAAwB,EAAC,MAAM,kBAAkB,CAAC;AACnF,OAAO,EAAC,sBAAsB,EAAC,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,qBAAa,MAAM,CAAC,QAAQ,GAAG,SAAS;IAEpC;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,YAAY,CAAA;IAC3C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAgC;gBAEhD,UAAU,EAAE,YAAY;IAI7B,GAAG,CAAC,CAAC,SAAS,sBAAsB,EAAE,UAAU,EAAE,CAAC,GAAG,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC;IAK1E,IAAI,CAAC,SAAS,SAAS,uBAAuB,EAAE,cAAc,EACjE,MAAM,EAAE,YAAY,CAAC,SAAS,EAAE,cAAc,CAAC,EAC/C,cAAc,EAAE,wBAAwB,CAAC,SAAS,CAAC,GACpD,IAAI;CAIV"}
@@ -1,4 +1,9 @@
1
1
  export class GGHttp {
2
+ /**
3
+ * Protected (not private) so that plugin modules can access the underlying server
4
+ * via module augmentation (e.g. @grest-ts/openapi adds .openApi() to the builder).
5
+ * Do not tighten back to private.
6
+ */
2
7
  httpServer;
3
8
  middlewares = [];
4
9
  constructor(httpServer) {
@@ -1 +1 @@
1
- {"version":3,"file":"GGHttp.js","sourceRoot":"","sources":["../../../src/server/GGHttp.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,MAAM;IAEE,UAAU,CAAc;IACxB,WAAW,GAA6B,EAAE,CAAC;IAE5D,YAAY,UAAwB;QAChC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,CAAC;IAEM,GAAG,CAAmC,UAAa;QACtD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAClC,OAAO,IAAW,CAAC;IACvB,CAAC;IAEM,IAAI,CACP,MAA+C,EAC/C,cAAmD;QAEnD,MAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,EAAC,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAC,CAAC,CAAC;QACxF,OAAO,IAAW,CAAC;IACvB,CAAC;CACJ"}
1
+ {"version":3,"file":"GGHttp.js","sourceRoot":"","sources":["../../../src/server/GGHttp.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,MAAM;IAEf;;;;OAIG;IACgB,UAAU,CAAc;IAC1B,WAAW,GAA6B,EAAE,CAAC;IAE5D,YAAY,UAAwB;QAChC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,CAAC;IAEM,GAAG,CAAmC,UAAa;QACtD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAClC,OAAO,IAAW,CAAC;IACvB,CAAC;IAEM,IAAI,CACP,MAA+C,EAC/C,cAAmD;QAEnD,MAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,EAAC,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAC,CAAC,CAAC;QACxF,OAAO,IAAW,CAAC;IACvB,CAAC;CACJ"}