@grest-ts/http 0.0.5

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 (118) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +613 -0
  3. package/dist/src/client/GGHttpSchema.createClient.d.ts +14 -0
  4. package/dist/src/client/GGHttpSchema.createClient.d.ts.map +1 -0
  5. package/dist/src/client/GGHttpSchema.createClient.js +80 -0
  6. package/dist/src/client/GGHttpSchema.createClient.js.map +1 -0
  7. package/dist/src/index-browser.d.ts +8 -0
  8. package/dist/src/index-browser.d.ts.map +1 -0
  9. package/dist/src/index-browser.js +11 -0
  10. package/dist/src/index-browser.js.map +1 -0
  11. package/dist/src/index-node.d.ts +18 -0
  12. package/dist/src/index-node.d.ts.map +1 -0
  13. package/dist/src/index-node.js +32 -0
  14. package/dist/src/index-node.js.map +1 -0
  15. package/dist/src/rpc/GGHttpRouteRPC.d.ts +19 -0
  16. package/dist/src/rpc/GGHttpRouteRPC.d.ts.map +1 -0
  17. package/dist/src/rpc/GGHttpRouteRPC.js +32 -0
  18. package/dist/src/rpc/GGHttpRouteRPC.js.map +1 -0
  19. package/dist/src/rpc/RpcRequest/GGRpcRequestBuilder.d.ts +18 -0
  20. package/dist/src/rpc/RpcRequest/GGRpcRequestBuilder.d.ts.map +1 -0
  21. package/dist/src/rpc/RpcRequest/GGRpcRequestBuilder.js +80 -0
  22. package/dist/src/rpc/RpcRequest/GGRpcRequestBuilder.js.map +1 -0
  23. package/dist/src/rpc/RpcRequest/GGRpcRequestParser.d.ts +18 -0
  24. package/dist/src/rpc/RpcRequest/GGRpcRequestParser.d.ts.map +1 -0
  25. package/dist/src/rpc/RpcRequest/GGRpcRequestParser.js +90 -0
  26. package/dist/src/rpc/RpcRequest/GGRpcRequestParser.js.map +1 -0
  27. package/dist/src/rpc/RpcResponse/GGRpcResponseBuilder.d.ts +12 -0
  28. package/dist/src/rpc/RpcResponse/GGRpcResponseBuilder.d.ts.map +1 -0
  29. package/dist/src/rpc/RpcResponse/GGRpcResponseBuilder.js +77 -0
  30. package/dist/src/rpc/RpcResponse/GGRpcResponseBuilder.js.map +1 -0
  31. package/dist/src/rpc/RpcResponse/GGRpcResponseParser.d.ts +7 -0
  32. package/dist/src/rpc/RpcResponse/GGRpcResponseParser.d.ts.map +1 -0
  33. package/dist/src/rpc/RpcResponse/GGRpcResponseParser.js +21 -0
  34. package/dist/src/rpc/RpcResponse/GGRpcResponseParser.js.map +1 -0
  35. package/dist/src/schema/GGHttpSchema.d.ts +68 -0
  36. package/dist/src/schema/GGHttpSchema.d.ts.map +1 -0
  37. package/dist/src/schema/GGHttpSchema.js +18 -0
  38. package/dist/src/schema/GGHttpSchema.js.map +1 -0
  39. package/dist/src/schema/httpSchema.d.ts +43 -0
  40. package/dist/src/schema/httpSchema.d.ts.map +1 -0
  41. package/dist/src/schema/httpSchema.js +85 -0
  42. package/dist/src/schema/httpSchema.js.map +1 -0
  43. package/dist/src/server/GGHttp.d.ts +12 -0
  44. package/dist/src/server/GGHttp.d.ts.map +1 -0
  45. package/dist/src/server/GGHttp.js +16 -0
  46. package/dist/src/server/GGHttp.js.map +1 -0
  47. package/dist/src/server/GGHttpMetrics.d.ts +22 -0
  48. package/dist/src/server/GGHttpMetrics.d.ts.map +1 -0
  49. package/dist/src/server/GGHttpMetrics.js +15 -0
  50. package/dist/src/server/GGHttpMetrics.js.map +1 -0
  51. package/dist/src/server/GGHttpSchema.startServer.d.ts +30 -0
  52. package/dist/src/server/GGHttpSchema.startServer.d.ts.map +1 -0
  53. package/dist/src/server/GGHttpSchema.startServer.js +114 -0
  54. package/dist/src/server/GGHttpSchema.startServer.js.map +1 -0
  55. package/dist/src/server/GGHttpServer.d.ts +32 -0
  56. package/dist/src/server/GGHttpServer.d.ts.map +1 -0
  57. package/dist/src/server/GGHttpServer.js +116 -0
  58. package/dist/src/server/GGHttpServer.js.map +1 -0
  59. package/dist/src/server/GG_HTTP_REQUEST.d.ts +16 -0
  60. package/dist/src/server/GG_HTTP_REQUEST.d.ts.map +1 -0
  61. package/dist/src/server/GG_HTTP_REQUEST.js +10 -0
  62. package/dist/src/server/GG_HTTP_REQUEST.js.map +1 -0
  63. package/dist/src/server/GG_HTTP_SERVER.d.ts +4 -0
  64. package/dist/src/server/GG_HTTP_SERVER.d.ts.map +1 -0
  65. package/dist/src/server/GG_HTTP_SERVER.js +3 -0
  66. package/dist/src/server/GG_HTTP_SERVER.js.map +1 -0
  67. package/dist/src/tsconfig.json +17 -0
  68. package/dist/testkit/clientHttp/GGHttpCall.d.ts +35 -0
  69. package/dist/testkit/clientHttp/GGHttpCall.d.ts.map +1 -0
  70. package/dist/testkit/clientHttp/GGHttpCall.js +37 -0
  71. package/dist/testkit/clientHttp/GGHttpCall.js.map +1 -0
  72. package/dist/testkit/clientHttp/GGHttpSchema.callOn.d.ts +37 -0
  73. package/dist/testkit/clientHttp/GGHttpSchema.callOn.d.ts.map +1 -0
  74. package/dist/testkit/clientHttp/GGHttpSchema.callOn.js +29 -0
  75. package/dist/testkit/clientHttp/GGHttpSchema.callOn.js.map +1 -0
  76. package/dist/testkit/index-testkit.d.ts +8 -0
  77. package/dist/testkit/index-testkit.d.ts.map +1 -0
  78. package/dist/testkit/index-testkit.js +8 -0
  79. package/dist/testkit/index-testkit.js.map +1 -0
  80. package/dist/testkit/mock/GGHttpInterceptorsServer.d.ts +13 -0
  81. package/dist/testkit/mock/GGHttpInterceptorsServer.d.ts.map +1 -0
  82. package/dist/testkit/mock/GGHttpInterceptorsServer.js +100 -0
  83. package/dist/testkit/mock/GGHttpInterceptorsServer.js.map +1 -0
  84. package/dist/testkit/mock/GGHttpSchema.mock.d.ts +36 -0
  85. package/dist/testkit/mock/GGHttpSchema.mock.d.ts.map +1 -0
  86. package/dist/testkit/mock/GGHttpSchema.mock.js +78 -0
  87. package/dist/testkit/mock/GGHttpSchema.mock.js.map +1 -0
  88. package/dist/testkit/routing/GGApiRoutingSelector.d.ts +8 -0
  89. package/dist/testkit/routing/GGApiRoutingSelector.d.ts.map +1 -0
  90. package/dist/testkit/routing/GGApiRoutingSelector.js +4 -0
  91. package/dist/testkit/routing/GGApiRoutingSelector.js.map +1 -0
  92. package/dist/testkit/routing/GGHttpSchema.routing.d.ts +14 -0
  93. package/dist/testkit/routing/GGHttpSchema.routing.d.ts.map +1 -0
  94. package/dist/testkit/routing/GGHttpSchema.routing.js +21 -0
  95. package/dist/testkit/routing/GGHttpSchema.routing.js.map +1 -0
  96. package/dist/testkit/utils/validateContractResponse.d.ts +8 -0
  97. package/dist/testkit/utils/validateContractResponse.d.ts.map +1 -0
  98. package/dist/testkit/utils/validateContractResponse.js +68 -0
  99. package/dist/testkit/utils/validateContractResponse.js.map +1 -0
  100. package/dist/tsconfig.publish.tsbuildinfo +1 -0
  101. package/package.json +74 -0
  102. package/src/client/GGHttpSchema.createClient.ts +107 -0
  103. package/src/index-browser.ts +12 -0
  104. package/src/index-node.ts +38 -0
  105. package/src/rpc/GGHttpRouteRPC.ts +42 -0
  106. package/src/rpc/RpcRequest/GGRpcRequestBuilder.ts +91 -0
  107. package/src/rpc/RpcRequest/GGRpcRequestParser.ts +100 -0
  108. package/src/rpc/RpcResponse/GGRpcResponseBuilder.ts +84 -0
  109. package/src/rpc/RpcResponse/GGRpcResponseParser.ts +23 -0
  110. package/src/schema/GGHttpSchema.ts +115 -0
  111. package/src/schema/httpSchema.ts +99 -0
  112. package/src/server/GGHttp.ts +27 -0
  113. package/src/server/GGHttpMetrics.ts +31 -0
  114. package/src/server/GGHttpSchema.startServer.ts +161 -0
  115. package/src/server/GGHttpServer.ts +133 -0
  116. package/src/server/GG_HTTP_REQUEST.ts +12 -0
  117. package/src/server/GG_HTTP_SERVER.ts +4 -0
  118. package/src/tsconfig.json +17 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GGHttpServer.js","sourceRoot":"","sources":["../../../src/server/GGHttpServer.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACx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AI,EAAE;YACtC,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;YAChE,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;YACxB,MAAM,WAAW,GAAG,IAAI,CAAC;YACzB,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,WAAW,CAAC;YACjD,OAAO,IAAI,CAAC,cAAc,GAAG,CAAC,IAAI,WAAW,CAAC,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC;gBAC7D,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;YAC1D,CAAC;YACD,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAC;QAC5C,CAAC,CAAC,EAAE,CAAC;IACT,CAAC;IAEM,OAAO,CAAC,QAAoC;QAC/C,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,UAAU,CAAC,QAAoC;QAClD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAChC,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ"}
@@ -0,0 +1,16 @@
1
+ import { GGContextKey } from "@grest-ts/context";
2
+ declare const IsHttpRequestContext: import("@grest-ts/schema").ObjectSchema<{
3
+ port: number;
4
+ method: string;
5
+ path: string;
6
+ pathTemplate?: string;
7
+ }>;
8
+ export type HttpRequestContext = typeof IsHttpRequestContext.infer;
9
+ export declare const GG_HTTP_REQUEST: GGContextKey<{
10
+ port: number;
11
+ method: string;
12
+ path: string;
13
+ pathTemplate?: string;
14
+ }>;
15
+ export {};
16
+ //# sourceMappingURL=GG_HTTP_REQUEST.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GG_HTTP_REQUEST.d.ts","sourceRoot":"","sources":["../../../src/server/GG_HTTP_REQUEST.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAG/C,QAAA,MAAM,oBAAoB;;;;;EAKxB,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,oBAAoB,CAAC,KAAK,CAAC;AAEnE,eAAO,MAAM,eAAe;;;;;EAA6E,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { GGContextKey } from "@grest-ts/context";
2
+ import { IsNumber, IsObject, IsString } from "@grest-ts/schema";
3
+ const IsHttpRequestContext = IsObject({
4
+ port: IsNumber,
5
+ method: IsString,
6
+ path: IsString,
7
+ pathTemplate: IsString.orUndefined
8
+ });
9
+ export const GG_HTTP_REQUEST = new GGContextKey('http-request', IsHttpRequestContext);
10
+ //# sourceMappingURL=GG_HTTP_REQUEST.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GG_HTTP_REQUEST.js","sourceRoot":"","sources":["../../../src/server/GG_HTTP_REQUEST.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAE9D,MAAM,oBAAoB,GAAG,QAAQ,CAAC;IAClC,IAAI,EAAE,QAAQ;IACd,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,QAAQ;IACd,YAAY,EAAE,QAAQ,CAAC,WAAW;CACrC,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,YAAY,CAAqB,cAAc,EAAE,oBAAoB,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { GGLocatorKey } from "@grest-ts/locator";
2
+ import { GGHttpServer } from "./GGHttpServer";
3
+ export declare const GG_HTTP_SERVER: GGLocatorKey<GGHttpServer>;
4
+ //# sourceMappingURL=GG_HTTP_SERVER.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GG_HTTP_SERVER.d.ts","sourceRoot":"","sources":["../../../src/server/GG_HTTP_SERVER.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,eAAO,MAAM,cAAc,4BAAiD,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { GGLocatorKey } from "@grest-ts/locator";
2
+ export const GG_HTTP_SERVER = new GGLocatorKey("GGHttpServer");
3
+ //# sourceMappingURL=GG_HTTP_SERVER.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GG_HTTP_SERVER.js","sourceRoot":"","sources":["../../../src/server/GG_HTTP_SERVER.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAG/C,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,YAAY,CAAe,cAAc,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ {
2
+ "//": "THIS FILE IS GENERATED - DO NOT EDIT",
3
+ "extends": "../../../../tsconfig.base.json",
4
+ "compilerOptions": {
5
+ "rootDir": ".",
6
+ "lib": [
7
+ "ES2022",
8
+ "DOM"
9
+ ],
10
+ "types": [
11
+ "node"
12
+ ]
13
+ },
14
+ "include": [
15
+ "**/*"
16
+ ]
17
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Test action for HTTP API calls.
3
+ *
4
+ * Handles HTTP requests with proper test action lifecycle
5
+ * (interceptors, expectations, logging).
6
+ */
7
+ import { ERROR, GGPromise, VALIDATION_ERROR, ValidationIssueJson } from "@grest-ts/schema";
8
+ import { GGTestAction, tActionRawData } from "@grest-ts/testkit";
9
+ import { ConstructorOf } from "@grest-ts/common";
10
+ import { GGContext } from "@grest-ts/context";
11
+ export declare class GGHttpCall<InputData, SuccessData, ErrorsUnion extends ERROR<any, any>> extends GGTestAction<SuccessData> {
12
+ private readonly data;
13
+ private readonly _execute;
14
+ private _validatingError;
15
+ constructor(ctx: GGContext, methodName: string, data: any, execute: (data: any) => GGPromise<any, any>);
16
+ toBeError<Type extends ConstructorOf<ErrorsUnion>>(type: Type): GGHttpCall<InputData, ExtractBadRequestData<Type, ErrorsUnion, InputData>, never>;
17
+ protected executeAction(): Promise<tActionRawData>;
18
+ protected processRawResponse(result: tActionRawData): Promise<SuccessData>;
19
+ }
20
+ export type ExtractBadRequestData<Type extends {
21
+ new (...args: any[]): any;
22
+ }, Union, InputData = unknown> = Union extends InstanceType<Type> ? Union extends typeof VALIDATION_ERROR.infer ? ValidationErrorsObject<InputData> : Union extends ERROR<any, infer Data> ? Data : never : never;
23
+ export type ValidationFieldError = string[] & {
24
+ __issue?: ValidationIssueJson;
25
+ };
26
+ export type ValidationErrorsObject<T> = T extends object ? {
27
+ [K in keyof T]?: ValidationFieldError | {
28
+ __issue?: ValidationIssueJson;
29
+ };
30
+ } : {
31
+ [key: string]: ValidationFieldError | {
32
+ __issue?: ValidationIssueJson;
33
+ };
34
+ };
35
+ //# sourceMappingURL=GGHttpCall.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GGHttpCall.d.ts","sourceRoot":"","sources":["../../../testkit/clientHttp/GGHttpCall.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,mBAAmB,EAAC,MAAM,kBAAkB,CAAC;AACzF,OAAO,EAAC,YAAY,EAAsB,cAAc,EAAC,MAAM,mBAAmB,CAAC;AACnF,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAE5C,qBAAa,UAAU,CAAC,SAAS,EAAE,WAAW,EAAE,WAAW,SAAS,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAAE,SAAQ,Y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AAC,EAAE,mBAAmB,CAAA;KAAE;CAAE,GAC7E;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,oBAAoB,GAAG;QAAE,OAAO,CAAC,EAAE,mBAAmB,CAAA;KAAE,CAAA;CAAE,CAAA"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Test action for HTTP API calls.
3
+ *
4
+ * Handles HTTP requests with proper test action lifecycle
5
+ * (interceptors, expectations, logging).
6
+ */
7
+ import { GGTestAction } from "@grest-ts/testkit";
8
+ import { parseContractResponse } from "../utils/validateContractResponse.js";
9
+ export class GGHttpCall extends GGTestAction {
10
+ data;
11
+ _execute;
12
+ _validatingError;
13
+ constructor(ctx, methodName, data, execute) {
14
+ const config = {
15
+ noResponse: false,
16
+ logData: {
17
+ message: "[HTTP " + methodName + "]",
18
+ request: data
19
+ }
20
+ };
21
+ super(ctx, config);
22
+ this.data = data;
23
+ this._execute = execute;
24
+ }
25
+ toBeError(type) {
26
+ this._validatingError = type;
27
+ this.responseExpectations.flush();
28
+ return this;
29
+ }
30
+ async executeAction() {
31
+ return this._execute(this.data).asResult();
32
+ }
33
+ processRawResponse(result) {
34
+ return parseContractResponse(result, this._validatingError);
35
+ }
36
+ }
37
+ //# sourceMappingURL=GGHttpCall.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GGHttpCall.js","sourceRoot":"","sources":["../../../testkit/clientHttp/GGHttpCall.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAC,YAAY,EAAqC,MAAM,mBAAmB,CAAC;AAEnF,OAAO,EAAC,qBAAqB,EAAC,MAAM,mCAAmC,CAAC;AAGxE,MAAM,OAAO,UAAwE,SAAQ,YAAyB;IAEjG,IAAI,CAAM;IACV,QAAQ,CAAqC;IAEtD,gBAAgB,CAAiC;IAEzD,YAAY,GAAc,EAAE,UAAkB,EAAE,IAAS,EAAE,OAA2C;QAClG,MAAM,MAAM,GAAuB;YAC/B,UAAU,EAAE,KAAK;YACjB,OAAO,EAAE;gBACL,OAAO,EAAE,QAAQ,GAAG,UAAU,GAAG,GAAG;gBACpC,OAAO,EAAE,IAAI;aAChB;SACJ,CAAC;QACF,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC5B,CAAC;IAEM,SAAS,CAA0C,IAAU;QAChE,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAC7B,IAAI,CAAC,oBAAoB,CAAC,KAAK,EAAE,CAAC;QAClC,OAAO,IAAW,CAAC;IACvB,CAAC;IAES,KAAK,CAAC,aAAa;QACzB,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC/C,CAAC;IAES,kBAAkB,CAAC,MAAsB;QAC/C,OAAO,qBAAqB,CAAC,MAAM,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAChE,CAAC;CACJ"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * CALL_ON_FACTORY implementation for GGHttpSchema.
3
+ *
4
+ * Enables callOn(HttpApi) to work by providing HTTP transport.
5
+ * Returns properly typed GGHttpCall for each contract method.
6
+ */
7
+ import { GGContractMethod, GGContractMethodErrors, GGSchema, Raw, SERVER_ERROR, VALIDATION_ERROR } from "@grest-ts/schema";
8
+ import { GGHttpCall } from "./GGHttpCall";
9
+ import { GGContext } from "@grest-ts/context";
10
+ import { CALL_ON_FACTORY, GGCallOnFactory } from "@grest-ts/testkit";
11
+ /**
12
+ * Maps contract methods with input to GGHttpCall.
13
+ */
14
+ type HttpCallWithInput<TContract extends Record<string, GGContractMethod>> = {
15
+ [K in keyof TContract as TContract[K] extends {
16
+ input: GGSchema<any>;
17
+ } ? K : never]: (data: Raw<TContract[K]['input']['infer']>) => GGHttpCall<TContract[K]['input']['infer'], TContract[K]['success']['infer'], GGContractMethodErrors<TContract[K]> | typeof SERVER_ERROR.infer | typeof VALIDATION_ERROR.infer>;
18
+ };
19
+ /**
20
+ * Maps contract methods without input to GGHttpCall.
21
+ */
22
+ type HttpCallWithoutInput<TContract extends Record<string, GGContractMethod>> = {
23
+ [K in keyof TContract as TContract[K] extends {
24
+ input: GGSchema<any>;
25
+ } ? never : K]: () => GGHttpCall<void, TContract[K]['success']['infer'], GGContractMethodErrors<TContract[K]> | typeof SERVER_ERROR.infer>;
26
+ };
27
+ /**
28
+ * Full HTTP call map for a contract - all methods return GGHttpCall.
29
+ */
30
+ export type GGHttpCallMap<TContract extends Record<string, GGContractMethod>> = HttpCallWithInput<TContract> & HttpCallWithoutInput<TContract>;
31
+ declare module "../../src/schema/GGHttpSchema" {
32
+ interface GGHttpSchema<TContract, TContext = {}> extends GGCallOnFactory {
33
+ [CALL_ON_FACTORY](ctx: GGContext): GGHttpCallMap<TContract>;
34
+ }
35
+ }
36
+ export {};
37
+ //# sourceMappingURL=GGHttpSchema.callOn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GGHttpSchema.callOn.d.ts","sourceRoot":"","sources":["../../../testkit/clientHttp/GGHttpSchema.callOn.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAA0B,gBAAgB,EAAE,sBAAsB,EAAE,QAAQ,EAAE,GAAG,EAAE,YAAY,EAAE,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAClJ,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AACxC,OAAO,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAC,eAAe,EAAE,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAGnE;;GAEG;AACH,KAAK,iBAAiB,CAAC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,IAAI;KACxE,CAAC,IAAI,MAAM,SAAS,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS;QAAE,KAAK,EAAE,QAAQ,CAAC,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"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * CALL_ON_FACTORY implementation for GGHttpSchema.
3
+ *
4
+ * Enables callOn(HttpApi) to work by providing HTTP transport.
5
+ * Returns properly typed GGHttpCall for each contract method.
6
+ */
7
+ import { GGHttpCall } from "./GGHttpCall.js";
8
+ import { GGHttpSchema } from "../../src/schema/GGHttpSchema.js";
9
+ import { CALL_ON_FACTORY } from "@grest-ts/testkit";
10
+ import { createClient } from "../../src/client/GGHttpSchema.createClient.js";
11
+ const classCache = new WeakMap();
12
+ GGHttpSchema.prototype[CALL_ON_FACTORY] = function (ctx) {
13
+ if (!classCache.has(this)) {
14
+ classCache.set(this, createClient(this, { noValidation: true }));
15
+ }
16
+ const contractClient = classCache.get(this);
17
+ return new Proxy({}, {
18
+ get(_, methodName) {
19
+ const contractMethod = contractClient[methodName];
20
+ if (typeof contractMethod === 'function') {
21
+ return (data) => new GGHttpCall(ctx, methodName, data, contractMethod);
22
+ }
23
+ else {
24
+ return undefined;
25
+ }
26
+ }
27
+ });
28
+ };
29
+ //# sourceMappingURL=GGHttpSchema.callOn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GGHttpSchema.callOn.js","sourceRoot":"","sources":["../../../testkit/clientHttp/GGHttpSchema.callOn.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAExC,OAAO,EAAC,YAAY,EAAC,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAC,eAAe,EAAkB,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAC,YAAY,EAAC,MAAM,4CAA4C,CAAC;AA8BxE,MAAM,UAAU,GAAsB,IAAI,OAAO,EAAE,CAAC;AAEpD,YAAY,CAAC,SAAS,CAAC,eAAe,CAAC,GAAG,UAAyF,GAAc;IAC7I,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,YAAY,CAAC,IAAI,EAAE,EAAC,YAAY,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC;IACnE,CAAC;IACD,MAAM,cAAc,GAAG,UAAU,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC;IAC7C,OAAO,IAAI,KAAK,CAAC,EAA8B,EAAE;QAC7C,GAAG,CAAC,CAAC,EAAE,UAAkB;YACrB,MAAM,cAAc,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;YAClD,IAAI,OAAO,cAAc,KAAK,UAAU,EAAE,CAAC;gBACvC,OAAO,CAAC,IAAU,EAAE,EAAE,CAAC,IAAI,UAAU,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;YACjF,CAAC;iBAAM,CAAC;gBACJ,OAAO,SAAS,CAAC;YACrB,CAAC;QACL,CAAC;KACJ,CAAC,CAAC;AACP,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ export * from './clientHttp/GGHttpCall';
2
+ export * from './mock/GGHttpInterceptorsServer';
3
+ export * from './utils/validateContractResponse';
4
+ export * from './routing/GGApiRoutingSelector';
5
+ import './clientHttp/GGHttpSchema.callOn';
6
+ import './routing/GGHttpSchema.routing';
7
+ import './mock/GGHttpSchema.mock';
8
+ //# sourceMappingURL=index-testkit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-testkit.d.ts","sourceRoot":"","sources":["../../testkit/index-testkit.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,OAAO,kCAAkC,CAAC;AAC1C,OAAO,gCAAgC,CAAC;AACxC,OAAO,0BAA0B,CAAC"}
@@ -0,0 +1,8 @@
1
+ export * from './clientHttp/GGHttpCall.js';
2
+ export * from './mock/GGHttpInterceptorsServer.js';
3
+ export * from './utils/validateContractResponse.js';
4
+ export * from './routing/GGApiRoutingSelector.js';
5
+ import './clientHttp/GGHttpSchema.callOn.js';
6
+ import './routing/GGHttpSchema.routing.js';
7
+ import './mock/GGHttpSchema.mock.js';
8
+ //# sourceMappingURL=index-testkit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-testkit.js","sourceRoot":"","sources":["../../testkit/index-testkit.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,OAAO,kCAAkC,CAAC;AAC1C,OAAO,gCAAgC,CAAC;AACxC,OAAO,0BAA0B,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { GGTestComponent, GGTestRunner } from "@grest-ts/testkit";
2
+ import { GGHttpInterceptor } from "./GGHttpSchema.mock";
3
+ export declare class GGHttpInterceptorsServer implements GGTestComponent {
4
+ private readonly server;
5
+ private readonly discoveryServer;
6
+ private readonly interceptors;
7
+ private readonly mockRoutedApis;
8
+ constructor(runner: GGTestRunner);
9
+ teardown(): Promise<void>;
10
+ addInterceptor(interceptor: GGHttpInterceptor): void;
11
+ deleteInterceptor(interceptor: GGHttpInterceptor): void;
12
+ }
13
+ //# sourceMappingURL=GGHttpInterceptorsServer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GGHttpInterceptorsServer.d.ts","sourceRoot":"","sources":["../../../testkit/mock/GGHttpInterceptorsServer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,eAAe,EAAE,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAEhE,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAEtD,qBAAa,wBAAyB,YAAW,eAAe;IAE5D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAW;IAClC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAyB;IACzD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA6C;IAE1E,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA0B;gBAE7C,MAAM,EAAE,YAAY;IAQnB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAK/B,cAAc,CAAC,WAAW,EAAE,iBAAiB;IA0E7C,iBAAiB,CAAC,WAAW,EAAE,iBAAiB;CAkB1D"}
@@ -0,0 +1,100 @@
1
+ import { GGLog } from "@grest-ts/logger";
2
+ import { ERROR } from "@grest-ts/schema";
3
+ import { GGTestRunner } from "@grest-ts/testkit";
4
+ import { GGLocalDiscoveryServer, ROUTING_STRATEGIES } from "@grest-ts/discovery-local";
5
+ export class GGHttpInterceptorsServer {
6
+ server;
7
+ discoveryServer;
8
+ interceptors = new Map();
9
+ // Track APIs where we've added mock routes (to use "last" routing strategy)
10
+ mockRoutedApis = new Set();
11
+ constructor(runner) {
12
+ if (!(runner.discoveryServer instanceof GGLocalDiscoveryServer)) {
13
+ throw new Error("GGHttpInterceptorsServer requires GGLocalDiscoveryServer as discovery server. This should be default for tests...");
14
+ }
15
+ this.server = runner.ipcServer;
16
+ this.discoveryServer = runner.discoveryServer;
17
+ }
18
+ async teardown() {
19
+ this.interceptors.clear();
20
+ this.mockRoutedApis.clear();
21
+ }
22
+ addInterceptor(interceptor) {
23
+ const key = interceptor.getKey();
24
+ const path = interceptor.pathPrefix + interceptor.pathSuffix;
25
+ const mode = interceptor.passThrough ? "spy" : "mock";
26
+ GGLog.debug(this, `Add http ${mode} interceptor [${key}]`);
27
+ if (!interceptor.passThrough) {
28
+ // Mock mode - always add route to discovery server for mocking
29
+ // Use "last" strategy so our mock route (added after service routes) wins
30
+ this.discoveryServer.addRoute({
31
+ api: interceptor.apiName,
32
+ baseUrl: this.server.getUrl(),
33
+ pathPrefix: interceptor.pathPrefix
34
+ });
35
+ this.discoveryServer.setRoutingStrategy(interceptor.apiName, ROUTING_STRATEGIES.last);
36
+ this.mockRoutedApis.add(interceptor.apiName);
37
+ this.server.interceptHttp(interceptor.method, path, async (body) => {
38
+ GGLog.debug(this, `[MOCKED_REQUEST] [${key}]`, body);
39
+ const reply = await interceptor.onRequest(body);
40
+ GGLog.debug(this, `[MOCKED_REPLY] [${key}]`, reply);
41
+ if (reply instanceof ERROR) {
42
+ return reply.toJSON();
43
+ }
44
+ return {
45
+ success: true,
46
+ statusCode: 200,
47
+ type: "OK",
48
+ data: reply
49
+ };
50
+ });
51
+ }
52
+ else {
53
+ // Spy mode - proxy to real service
54
+ const serviceRoute = this.discoveryServer.getRoute(interceptor.apiName);
55
+ if (!serviceRoute) {
56
+ throw new Error(`Cannot add spy for '${interceptor.apiName}' - service is not running!\n` +
57
+ `Spies require the actual service to be running so requests can be proxied.\n` +
58
+ `Did you forget to add 'withRuntime(${interceptor.apiName.replace('Api', 'Runtime')})' to your test?`);
59
+ }
60
+ const targetBaseUrl = serviceRoute.baseUrl;
61
+ this.server.interceptHttp(interceptor.method, path, async (body, _pathParams, headers) => {
62
+ GGLog.debug(this, `[SPIED_REQUEST] [${key}]`, body);
63
+ await interceptor.onRequest(body);
64
+ GGLog.debug(this, `Forwarding ${interceptor.method} ${path} -> ${targetBaseUrl}`);
65
+ // Forward original headers (including auth headers), add/override Content-Type
66
+ const forwardHeaders = {
67
+ ...(headers || {}),
68
+ 'content-type': 'application/json'
69
+ };
70
+ const response = await fetch(targetBaseUrl + path, {
71
+ method: interceptor.method,
72
+ headers: forwardHeaders,
73
+ body: body ? JSON.stringify(body) : undefined
74
+ });
75
+ const responseBody = await response.json();
76
+ await interceptor.onResponse(responseBody);
77
+ GGLog.debug(this, `[SPIED_RESPONSE] [${key}]`, responseBody);
78
+ return responseBody;
79
+ });
80
+ }
81
+ this.interceptors.set(key, interceptor);
82
+ }
83
+ deleteInterceptor(interceptor) {
84
+ const key = interceptor.getKey();
85
+ const path = interceptor.pathPrefix + interceptor.pathSuffix;
86
+ const mode = interceptor.passThrough ? "spy" : "mock";
87
+ this.interceptors.delete(key);
88
+ GGLog.debug(this, `Remove http ${mode} interceptor [${key}]`);
89
+ this.server.removeInterceptHttp(interceptor.method, path);
90
+ // For mock mode, remove only our mock route entry (by baseUrl), not the real service routes
91
+ if (!interceptor.passThrough) {
92
+ this.discoveryServer.removeRoute(interceptor.apiName, this.server.getUrl());
93
+ this.mockRoutedApis.delete(interceptor.apiName);
94
+ // Restore default routing strategy if no more mock routes for this API
95
+ this.discoveryServer.setRoutingStrategy(interceptor.apiName, ROUTING_STRATEGIES.roundRobin);
96
+ }
97
+ }
98
+ }
99
+ GGTestRunner.registerExtension(GGHttpInterceptorsServer);
100
+ //# sourceMappingURL=GGHttpInterceptorsServer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GGHttpInterceptorsServer.js","sourceRoot":"","sources":["../../../testkit/mock/GGHttpInterceptorsServer.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,EAAC,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAC,KAAK,EAAC,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAkB,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAC,sBAAsB,EAAE,kBAAkB,EAAC,MAAM,2BAA2B,CAAC;AAGrF,MAAM,OAAO,wBAAwB;IAEhB,MAAM,CAAW;IACjB,eAAe,CAAyB;IACxC,YAAY,GAAmC,IAAI,GAAG,EAAE,CAAC;IAC1E,4EAA4E;IAC3D,cAAc,GAAgB,IAAI,GAAG,EAAE,CAAC;IAEzD,YAAY,MAAoB;QAC5B,IAAI,CAAC,CAAC,MAAM,CAAC,eAAe,YAAY,sBAAsB,CAAC,EAAE,CAAC;YAC9D,MAAM,IAAI,KAAK,CAAC,mHAAmH,CAAC,CAAC;QACzI,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC;QAC/B,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,eAAe,CAAC;IAClD,CAAC;IAEM,KAAK,CAAC,QAAQ;QACjB,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAC1B,IAAI,CAAC,cAAc,C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,uEAAuE;YACvE,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,WAAW,CAAC,OAAO,EAAE,kBAAkB,CAAC,UAAU,CAAC,CAAC;QAChG,CAAC;IACL,CAAC;CACJ;AAED,YAAY,CAAC,iBAAiB,CAAC,wBAAwB,CAAC,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { GGCallInterceptor, GGCallInterceptorConfig, GGMockWith, GGSpyWith, GGTestRunner } from "@grest-ts/testkit";
2
+ import { HttpMethod } from "@grest-ts/common";
3
+ import { GGContractApiDefinition } from "@grest-ts/schema";
4
+ declare module "../../src/schema/GGHttpSchema" {
5
+ interface GGHttpSchema<TContract extends GGContractApiDefinition, TContext = {}> {
6
+ readonly mock: ApiMockMethods<TContract>;
7
+ readonly spy: ApiSpyMethods<TContract>;
8
+ }
9
+ }
10
+ type ApiMockMethods<TContract> = {
11
+ readonly [K in keyof TContract]: GGMockWith;
12
+ };
13
+ type ApiSpyMethods<TContract> = {
14
+ readonly [K in keyof TContract]: GGSpyWith;
15
+ };
16
+ export interface HttpInterceptorConfig extends GGCallInterceptorConfig {
17
+ method: HttpMethod;
18
+ apiName: string;
19
+ pathPrefix: string;
20
+ pathSuffix: string;
21
+ expectError?: any;
22
+ }
23
+ export declare class GGHttpInterceptor extends GGCallInterceptor {
24
+ readonly method: HttpMethod;
25
+ readonly apiName: string;
26
+ readonly pathPrefix: string;
27
+ readonly pathSuffix: string;
28
+ protected readonly expectError?: any;
29
+ constructor(test: GGTestRunner, config: HttpInterceptorConfig);
30
+ getKey(): string;
31
+ protected doRegister(): void;
32
+ protected doUnregister(): void;
33
+ protected parseResponseData(result: any): any;
34
+ }
35
+ export {};
36
+ //# sourceMappingURL=GGHttpSchema.mock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GGHttpSchema.mock.d.ts","sourceRoot":"","sources":["../../../testkit/mock/GGHttpSchema.mock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAE,uBAAu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B,SAAS,CAAC,iBAAiB,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG;CAGhD"}
@@ -0,0 +1,78 @@
1
+ import { GGCallInterceptor, GGMockWith, GGSpyWith } from "@grest-ts/testkit";
2
+ import { GGHttpInterceptorsServer } from "./GGHttpInterceptorsServer.js";
3
+ import { parseContractResponse } from "../utils/validateContractResponse.js";
4
+ import { GGHttpSchema } from "../../src/schema/GGHttpSchema.js";
5
+ Object.defineProperty(GGHttpSchema.prototype, 'mock', {
6
+ get() {
7
+ const name = this.name;
8
+ const methods = this.codec;
9
+ const fullPathPrefix = "/" + this.pathPrefix + "/";
10
+ return new Proxy({}, {
11
+ get(_target, prop) {
12
+ const methodDef = methods[prop];
13
+ if (!methodDef) {
14
+ return undefined;
15
+ }
16
+ return new GGMockWith(GGHttpInterceptor, {
17
+ apiName: name,
18
+ method: methodDef.method,
19
+ pathPrefix: fullPathPrefix,
20
+ pathSuffix: methodDef.path
21
+ });
22
+ }
23
+ });
24
+ },
25
+ enumerable: false,
26
+ configurable: true
27
+ });
28
+ Object.defineProperty(GGHttpSchema.prototype, 'spy', {
29
+ get() {
30
+ const fullPathPrefix = "/" + this.pathPrefix + "/";
31
+ const name = this.name;
32
+ const methods = this.codec;
33
+ return new Proxy({}, {
34
+ get(_target, prop) {
35
+ const methodDef = methods[prop];
36
+ if (!methodDef) {
37
+ return undefined;
38
+ }
39
+ return new GGSpyWith(GGHttpInterceptor, {
40
+ apiName: name,
41
+ method: methodDef.method,
42
+ pathPrefix: fullPathPrefix,
43
+ pathSuffix: methodDef.path
44
+ });
45
+ }
46
+ });
47
+ },
48
+ enumerable: false,
49
+ configurable: true
50
+ });
51
+ export class GGHttpInterceptor extends GGCallInterceptor {
52
+ method;
53
+ apiName;
54
+ pathPrefix;
55
+ pathSuffix;
56
+ expectError;
57
+ constructor(test, config) {
58
+ super(test, config);
59
+ this.method = config.method;
60
+ this.apiName = config.apiName;
61
+ this.pathPrefix = config.pathPrefix;
62
+ this.pathSuffix = config.pathSuffix;
63
+ this.expectError = config.expectError;
64
+ }
65
+ getKey() {
66
+ return `${this.method} ${this.pathPrefix}${this.pathSuffix}`;
67
+ }
68
+ doRegister() {
69
+ this.test.getExtensionInstance(GGHttpInterceptorsServer).addInterceptor(this);
70
+ }
71
+ doUnregister() {
72
+ this.test.getExtensionInstance(GGHttpInterceptorsServer).deleteInterceptor(this);
73
+ }
74
+ parseResponseData(result) {
75
+ return parseContractResponse(result, this.expectError);
76
+ }
77
+ }
78
+ //# sourceMappingURL=GGHttpSchema.mock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GGHttpSchema.mock.js","sourceRoot":"","sources":["../../../testkit/mock/GGHttpSchema.mock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAA2B,UAAU,EAAE,SAAS,EAAe,MAAM,mBAAmB,CAAA;AACjH,OAAO,EAAC,wBAAwB,EAAC,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAC,qBAAqB,EAAC,MAAM,mCAAmC,CAAC;AAExE,OAAO,EAAc,YAAY,EAAC,MAAM,+BAA+B,CAAC;AAkBxE,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE;IAClD,GAAG;QACC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACvB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC;QAC3B,MAAM,cAAc,GAAG,GAAG,GAAG,IAAI,CAAC,UAAU,GAAG,GAAG,CAAA;QAClD,OAAO,IAAI,KAAK,CAAC,EAAE,EAAE;YACjB,GAAG,CAAC,OAAO,EAAE,IAAY;gBACrB,MAAM,SAAS,GAAgB,OAAO,CAAC,IAAI,CAAC,CAAA;gBAC5C,IAAI,CAAC,SAAS,EAAE,CAAC;oBACb,OAAO,SAAS,CAAA;gBACpB,CAAC;gBACD,OAAO,IAAI,UAAU,CAAC,iBAAiB,EAAE;oBACrC,OAAO,EAAE,IAAI;oBACb,MAAM,E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QAC5B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAC9B,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACpC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACpC,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;IAC1C,CAAC;IAEM,MAAM;QACT,OAAO,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;IACjE,CAAC;IAES,UAAU;QAChB,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,wBAAwB,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IAClF,CAAC;IAES,YAAY;QAClB,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,wBAAwB,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACrF,CAAC;IAES,iBAAiB,CAAC,MAAW;QACnC,OAAO,qBAAqB,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAC3D,CAAC;CACJ"}
@@ -0,0 +1,8 @@
1
+ export interface GGApiRoutingSelector {
2
+ first(): void;
3
+ last(): void;
4
+ random(): void;
5
+ roundRobin(): void;
6
+ set(strategy: any): void;
7
+ }
8
+ //# sourceMappingURL=GGApiRoutingSelector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GGApiRoutingSelector.d.ts","sourceRoot":"","sources":["../../../testkit/routing/GGApiRoutingSelector.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,oBAAoB;IACjC,KAAK,IAAI,IAAI,CAAA;IACb,IAAI,IAAI,IAAI,CAAA;IACZ,MAAM,IAAI,IAAI,CAAA;IACd,UAAU,IAAI,IAAI,CAAA;IAClB,GAAG,CAAC,QAAQ,EAAE,GAAG,GAAG,IAAI,CAAA;CAC3B"}
@@ -0,0 +1,4 @@
1
+ // Interface for API routing selector (test-only feature)
2
+ // Actual implementation is GGLocalRoutingStrategySelector from @grest-ts/discovery/testkit
3
+ export {};
4
+ //# sourceMappingURL=GGApiRoutingSelector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GGApiRoutingSelector.js","sourceRoot":"","sources":["../../../testkit/routing/GGApiRoutingSelector.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,2FAA2F"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Test extension for HttpApiSchema - adds routing property
3
+ */
4
+ import type { GGApiRoutingSelector } from "./GGApiRoutingSelector";
5
+ import { GGContractApiDefinition } from "@grest-ts/schema";
6
+ declare module "../../src/schema/GGHttpSchema" {
7
+ interface GGHttpSchema<TContract extends GGContractApiDefinition, TContext = {}> {
8
+ /**
9
+ * Routing selector for this API (for testing)
10
+ */
11
+ readonly routing: GGApiRoutingSelector;
12
+ }
13
+ }
14
+ //# sourceMappingURL=GGHttpSchema.routing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GGHttpSchema.routing.d.ts","sourceRoot":"","sources":["../../../testkit/routing/GGHttpSchema.routing.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAA;AAEhE,OAAO,EAAC,uBAAuB,EAAC,MAAM,kBAAkB,CAAC;AAMzD,OAAO,QAAQ,+BAA+B,CAAC;IAC3C,UAAU,YAAY,CAAC,SAAS,SAAS,uBAAuB,EAAE,QAAQ,GAAG,EAAE;QAC3E;;WAEG;QACH,QAAQ,CAAC,OAAO,EAAE,oBAAoB,CAAA;KACzC;CACJ"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Test extension for HttpApiSchema - adds routing property
3
+ */
4
+ import { GGLocalRoutingStrategySelector } from "@grest-ts/discovery-local/testkit";
5
+ import { GGHttpSchema } from "../../src/schema/GGHttpSchema.js";
6
+ // WeakMap to store per-instance routing selectors
7
+ const routingSelectors = new WeakMap();
8
+ // Add routing to HttpApiSchema prototype
9
+ Object.defineProperty(GGHttpSchema.prototype, 'routing', {
10
+ get() {
11
+ let selector = routingSelectors.get(this);
12
+ if (!selector) {
13
+ selector = new GGLocalRoutingStrategySelector(this.name);
14
+ routingSelectors.set(this, selector);
15
+ }
16
+ return selector;
17
+ },
18
+ enumerable: false,
19
+ configurable: true
20
+ });
21
+ //# sourceMappingURL=GGHttpSchema.routing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GGHttpSchema.routing.js","sourceRoot":"","sources":["../../../testkit/routing/GGHttpSchema.routing.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAC,8BAA8B,EAAC,MAAM,mCAAmC,CAAA;AAEhF,OAAO,EAAC,YAAY,EAAC,MAAM,+BAA+B,CAAC;AAG3D,kDAAkD;AAClD,MAAM,gBAAgB,GAAG,IAAI,OAAO,EAA0D,CAAA;AAY9F,yCAAyC;AACzC,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,SAAS,EAAE,SAAS,EAAE;IACrD,GAAG;QACC,IAAI,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACzC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACZ,QAAQ,GAAG,IAAI,8BAA8B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACxD,gBAAgB,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;QACxC,CAAC;QACD,OAAO,QAAQ,CAAA;IACnB,CAAC;IACD,UAAU,EAAE,KAAK;IACjB,YAAY,EAAE,IAAI;CACrB,CAAC,CAAA"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Parse contract response - unwrap OK/error structure and return inner data.
3
+ * Used by HttpInterceptor, SocketInterceptor, and GGHttpCall.
4
+ *
5
+ * @returns The data to validate, or undefined if no data validation needed
6
+ */
7
+ export declare function parseContractResponse(result: any, expectError: any): any;
8
+ //# sourceMappingURL=validateContractResponse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateContractResponse.d.ts","sourceRoot":"","sources":["../../../testkit/utils/validateContractResponse.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,GAAG,GAAG,CA2BxE"}