@sdkgen/node-runtime 2.1.0 → 2.3.1

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.
@@ -2,7 +2,7 @@ export interface User {
2
2
  name: string;
3
3
  age: number;
4
4
  }
5
- export declare type ErrorType = "Fatal" | "Connection";
5
+ export type ErrorType = "Fatal" | "Connection";
6
6
  export declare class ApiClient {
7
7
  private baseUrl;
8
8
  private useStaging;
@@ -17,6 +17,7 @@ const fs_1 = require("fs");
17
17
  const parser_1 = require("@sdkgen/parser");
18
18
  const typescript_generator_1 = require("@sdkgen/typescript-generator");
19
19
  const axios_1 = __importDefault(require("axios"));
20
+ const decimal_js_1 = __importDefault(require("decimal.js"));
20
21
  const src_1 = require("../../src");
21
22
  const ast = new parser_1.Parser(`${__dirname}/api.sdkgen`).parse();
22
23
  (0, fs_1.writeFileSync)(`${__dirname}/api.ts`, (0, typescript_generator_1.generateNodeServerSource)(ast).replace(/@sdkgen\/node-runtime/gu, "../../src"));
@@ -37,6 +38,9 @@ api.fn.identity = async (ctx, { types }) => {
37
38
  api.fn.throwsError = async () => {
38
39
  throw new SomeError("Some message");
39
40
  };
41
+ api.fn.decimalAdd = async (_ctx, { a, b }) => {
42
+ return a.add(b);
43
+ };
40
44
  // ExecSync(`../../cubos/sdkgen/sdkgen ${__dirname + "/api.sdkgen"} -o ${__dirname + "/legacyNodeClient.ts"} -t typescript_nodeclient`);
41
45
  const { ApiClient: NodeLegacyApiClient } = require(`${__dirname}/legacyNodeClient.ts`);
42
46
  const nodeLegacyClient = new NodeLegacyApiClient("http://localhost:34367");
@@ -102,4 +106,8 @@ describe("Simple API", () => {
102
106
  type: "SomeError",
103
107
  });
104
108
  });
109
+ test("Can handle decimals", async () => {
110
+ const result = await nodeClient.decimalAdd(null, { a: new decimal_js_1.default("0.1"), b: new decimal_js_1.default("0.2") });
111
+ expect(result.eq(new decimal_js_1.default("0.3"))).toEqual(true);
112
+ });
105
113
  });
@@ -1,14 +1,12 @@
1
1
  import type { AstJson, AstRoot } from "@sdkgen/parser";
2
2
  import type { Context, ContextReply } from "./context";
3
3
  import type { DeepReadonly } from "./utils";
4
- declare type Middleware<ExtraContextT> = (ctx: Context & ExtraContextT, next: () => Promise<ContextReply>) => Promise<ContextReply>;
5
- export declare abstract class BaseApiConfig<ExtraContextT = unknown> {
4
+ type Middleware<ExtraContextT> = (ctx: Context & ExtraContextT, next: () => Promise<ContextReply>) => Promise<ContextReply>;
5
+ export declare class BaseApiConfig<ExtraContextT = unknown> {
6
6
  private _ast;
7
7
  get ast(): AstRoot;
8
8
  astJson: DeepReadonly<AstJson>;
9
- fn: {
10
- [name: string]: ((ctx: Context & ExtraContextT, args: any) => Promise<any>) | undefined;
11
- };
9
+ fn: Record<string, ((ctx: Context & ExtraContextT, args: any) => Promise<any>) | undefined>;
12
10
  readonly middlewares: Array<Middleware<ExtraContextT>>;
13
11
  use(middleware: Middleware<ExtraContextT>): void;
14
12
  }
@@ -4,6 +4,7 @@ exports.BaseApiConfig = void 0;
4
4
  const parser_1 = require("@sdkgen/parser");
5
5
  class BaseApiConfig {
6
6
  constructor() {
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
8
  this.fn = {};
8
9
  this.middlewares = [];
9
10
  }
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import type { IncomingHttpHeaders, OutgoingHttpHeader } from "http";
3
4
  import type { Readable } from "stream";
4
5
  export interface ContextRequest {
@@ -1,31 +1,32 @@
1
1
  /// <reference types="node" />
2
2
  import type { AstJson, TypeDescription } from "@sdkgen/parser";
3
+ import { Decimal } from "decimal.js";
3
4
  import type { DeepReadonly } from "./utils";
4
- declare type TypeTable = AstJson["typeTable"];
5
- declare type ExpandRecursively<T> = T extends object ? (T extends infer O ? {
5
+ type TypeTable = AstJson["typeTable"];
6
+ type ExpandRecursively<T> = T extends object ? (T extends infer O ? {
6
7
  [K in keyof O]: ExpandRecursively<O[K]>;
7
8
  } : never) : T;
8
- declare type JsonType = number | string | boolean | null | JsonType[] | {
9
+ type JsonType = number | string | boolean | null | JsonType[] | {
9
10
  [Key in string]: JsonType;
10
11
  };
11
- declare type AnyDecodedType = number | string | boolean | null | bigint | Buffer | Date | AnyDecodedType[] | {
12
+ type AnyDecodedType = number | string | boolean | null | bigint | Decimal | Buffer | Date | AnyDecodedType[] | {
12
13
  [Key in string]: AnyDecodedType;
13
14
  };
14
- declare type DecodedType<Type, Table extends object> = TypeDescription extends Type ? AnyDecodedType : Type extends "string" | "email" | "html" | "xml" | "url" | "hex" | "uuid" | "base64" | "cpf" | "cnpj" ? string : Type extends "json" ? JsonType : Type extends "bool" ? boolean : Type extends "void" ? null : Type extends "int" | "uint" | "float" | "money" ? number : Type extends "bigint" ? bigint : Type extends "bytes" ? Buffer : Type extends "date" | "datetime" ? Date : Type extends `${infer X}?` ? DecodedType<X, Table> | null : Type extends `${infer X}[]` ? Array<DecodedType<X, Table>> : Type extends Array<string | [string, string]> ? DecodedEnumType<Type, Table> : Type extends ReadonlyArray<string | readonly [string, string]> ? DecodedEnumType<Type, Table> : Type extends object ? {
15
+ export type DecodedType<Type, Table extends object = {}> = TypeDescription extends Type ? AnyDecodedType : Type extends "string" | "email" | "html" | "xml" | "url" | "hex" | "uuid" | "base64" | "cpf" | "cnpj" ? string : Type extends "json" ? JsonType : Type extends "bool" ? boolean : Type extends "void" ? null : Type extends "int" | "uint" | "float" | "money" ? number : Type extends "bigint" ? bigint : Type extends "bytes" ? Buffer : Type extends "decimal" ? Decimal : Type extends "date" | "datetime" ? Date : Type extends `${infer X}?` ? DecodedType<X, Table> | null : Type extends `${infer X}[]` ? Array<DecodedType<X, Table>> : Type extends Array<string | [string, string]> ? DecodedEnumType<Type, Table> : Type extends ReadonlyArray<string | readonly [string, string]> ? DecodedEnumType<Type, Table> : Type extends object ? {
15
16
  -readonly [Key in keyof Type]: DecodedType<Type[Key], Table>;
16
17
  } : object extends Table ? never : Type extends keyof Table ? DecodedType<Table[Type], Table> : never;
17
- declare type DecodedEnumType<Type extends Array<string | [string, string]> | ReadonlyArray<string | readonly [string, string]>, Table extends object> = Type[number] extends string ? Type[number] : DecodeTaggedEnumValueType<Type[number], Table>;
18
- declare type DecodeTaggedEnumValueType<ValueType extends string | [string, string] | readonly [string, string], Table extends object> = ValueType extends string ? {
18
+ type DecodedEnumType<Type extends Array<string | [string, string]> | ReadonlyArray<string | readonly [string, string]>, Table extends object> = Type[number] extends string ? Type[number] : DecodeTaggedEnumValueType<Type[number], Table>;
19
+ type DecodeTaggedEnumValueType<ValueType extends string | [string, string] | readonly [string, string], Table extends object> = ValueType extends string ? {
19
20
  tag: ValueType;
20
21
  } : ValueType extends [infer Tag, infer Struct] ? ExpandRecursively<{
21
22
  tag: Tag;
22
23
  } & DecodedType<Struct, Table>> : ValueType extends readonly [infer Tag, infer Struct] ? ExpandRecursively<{
23
24
  tag: Tag;
24
25
  } & DecodedType<Struct, Table>> : never;
25
- declare type EncodedType<Type, Table extends object> = TypeDescription extends Type ? JsonType : Type extends "string" | "email" | "html" | "xml" | "url" | "hex" | "uuid" | "base64" | "cpf" | "cnpj" ? string : Type extends "json" ? JsonType : Type extends "bool" ? boolean : Type extends "void" ? null : Type extends "int" | "uint" | "float" | "money" ? number : Type extends "bigint" | "bytes" | "date" | "datetime" ? string : Type extends `${infer X}?` ? EncodedType<X, Table> | null : Type extends `${infer X}[]` ? Array<EncodedType<X, Table>> : Type extends Array<string | [string, string]> ? EnumEncodedValueType<Type[number], Table> : Type extends ReadonlyArray<string | readonly [string, string]> ? EnumEncodedValueType<Type[number], Table> : Type extends object ? {
26
+ export type EncodedType<Type, Table extends object = {}> = TypeDescription extends Type ? JsonType : Type extends "string" | "email" | "html" | "xml" | "url" | "hex" | "uuid" | "base64" | "cpf" | "cnpj" ? string : Type extends "json" ? JsonType : Type extends "bool" ? boolean : Type extends "void" ? null : Type extends "int" | "uint" | "float" | "money" ? number : Type extends "bigint" | "bytes" | "date" | "datetime" | "decimal" ? string : Type extends `${infer X}?` ? EncodedType<X, Table> | null : Type extends `${infer X}[]` ? Array<EncodedType<X, Table>> : Type extends Array<string | [string, string]> ? EnumEncodedValueType<Type[number], Table> : Type extends ReadonlyArray<string | readonly [string, string]> ? EnumEncodedValueType<Type[number], Table> : Type extends object ? {
26
27
  -readonly [Key in keyof Type]: EncodedType<Type[Key], Table>;
27
28
  } : object extends Table ? never : Type extends keyof Table ? EncodedType<Table[Type], Table> : never;
28
- declare type EnumEncodedValueType<ValueType extends string | [string, string] | readonly [string, string], Table extends object> = ValueType extends string ? ValueType : ValueType extends [infer Tag, infer Struct] ? [Tag, EncodedType<Struct, Table>] : ValueType extends readonly [infer Tag, infer Struct] ? [Tag, EncodedType<Struct, Table>] : never;
29
+ type EnumEncodedValueType<ValueType extends string | [string, string] | readonly [string, string], Table extends object> = ValueType extends string ? ValueType : ValueType extends [infer Tag, infer Struct] ? [Tag, EncodedType<Struct, Table>] : ValueType extends readonly [infer Tag, infer Struct] ? [Tag, EncodedType<Struct, Table>] : never;
29
30
  export declare function encode<Table extends DeepReadonly<TypeTable>, Type extends DeepReadonly<TypeDescription>>(typeTable: Table, path: string, type: Type, value: unknown): EncodedType<Type, Table>;
30
31
  export declare function decode<Table extends DeepReadonly<TypeTable>, Type extends DeepReadonly<TypeDescription>>(typeTable: Table, path: string, type: Type, value: unknown): DecodedType<Type, Table>;
31
32
  export {};
@@ -37,6 +37,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
37
37
  exports.decode = exports.encode = void 0;
38
38
  const CNPJ = __importStar(require("@fnando/cnpj"));
39
39
  const CPF = __importStar(require("@fnando/cpf"));
40
+ const decimal_js_1 = require("decimal.js");
40
41
  const simpleStringTypes = ["string", "email", "html", "xml"];
41
42
  const simpleTypes = ["json", "bool", "url", "int", "uint", "float", "money", "hex", "uuid", "base64", "void", ...simpleStringTypes];
42
43
  class ParseError extends Error {
@@ -48,7 +49,7 @@ class ParseError extends Error {
48
49
  catch (err) {
49
50
  str = String(value);
50
51
  }
51
- super(`Invalid type at '${path}', expected ${type}, got ${str}`);
52
+ super(`Invalid type at '${path}', expected ${String(type)}, got ${str}`);
52
53
  }
53
54
  }
54
55
  function simpleEncodeDecode(path, type, value) {
@@ -220,7 +221,11 @@ function encode(typeTable, path, type, value) {
220
221
  if (!(value instanceof Date && !isNaN(value.getTime())) && !(typeof value === "string" && /^[0-9]{4}-[01][0-9]-[0123][0-9]$/u.test(value))) {
221
222
  throw new ParseError(path, type, value);
222
223
  }
223
- return (typeof value === "string" ? new Date(value).toISOString().split("T")[0] : value.toISOString().split("T")[0]);
224
+ const dateValue = value instanceof Date ? value : new Date(value);
225
+ return `${dateValue.getFullYear().toString().padStart(4, "0")}-${(dateValue.getMonth() + 1).toString().padStart(2, "0")}-${dateValue
226
+ .getDate()
227
+ .toString()
228
+ .padStart(2, "0")}`;
224
229
  }
225
230
  else if (type === "datetime") {
226
231
  if (!(value instanceof Date && !isNaN(value.getTime())) &&
@@ -230,13 +235,19 @@ function encode(typeTable, path, type, value) {
230
235
  }
231
236
  return (typeof value === "string" ? new Date(value) : value).toISOString().replace("Z", "");
232
237
  }
238
+ else if (type === "decimal") {
239
+ if (typeof value !== "number" && (typeof value !== "string" || !/^-?[0-9]+(?:\.[0-9]+)?$/u.test(value)) && !decimal_js_1.Decimal.isDecimal(value)) {
240
+ throw new ParseError(path, type, value);
241
+ }
242
+ return new decimal_js_1.Decimal(value).toString();
243
+ }
233
244
  else {
234
245
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
235
246
  const resolved = typeTable[type];
236
247
  if (resolved) {
237
248
  return encode(typeTable, path, resolved, value);
238
249
  }
239
- throw new Error(`Unknown type '${type}' at '${path}'`);
250
+ throw new Error(`Unknown type '${String(type)}' at '${path}'`);
240
251
  }
241
252
  }
242
253
  exports.encode = encode;
@@ -301,11 +312,11 @@ function decode(typeTable, path, type, value) {
301
312
  }
302
313
  else if (type === "bytes") {
303
314
  if (typeof value !== "string") {
304
- throw new ParseError(path, `${type} (base 64)`, value);
315
+ throw new ParseError(path, `${String(type)} (base 64)`, value);
305
316
  }
306
317
  const buffer = Buffer.from(value, "base64");
307
318
  if (buffer.toString("base64") !== value) {
308
- throw new ParseError(path, `${type} (base 64)`, value);
319
+ throw new ParseError(path, `${String(type)} (base 64)`, value);
309
320
  }
310
321
  return buffer;
311
322
  }
@@ -346,6 +357,12 @@ function decode(typeTable, path, type, value) {
346
357
  }
347
358
  return new Date(`${value.endsWith("Z") ? value : value.concat("Z")}`);
348
359
  }
360
+ else if (type === "decimal") {
361
+ if (typeof value !== "number" && (typeof value !== "string" || !/^-?[0-9]+(?:\.[0-9]+)?$/u.test(value))) {
362
+ throw new ParseError(path, type, value);
363
+ }
364
+ return new decimal_js_1.Decimal(value);
365
+ }
349
366
  else {
350
367
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
351
368
  const resolved = typeTable[type];
@@ -353,7 +370,7 @@ function decode(typeTable, path, type, value) {
353
370
  // eslint-disable-next-line @typescript-eslint/no-unsafe-return
354
371
  return decode(typeTable, path, resolved, value);
355
372
  }
356
- throw new Error(`Unknown type '${type}' at '${path}'`);
373
+ throw new Error(`Unknown type '${String(type)}' at '${path}'`);
357
374
  }
358
375
  }
359
376
  exports.decode = decode;
@@ -3,9 +3,7 @@ import type { PartialDeep } from "type-fest";
3
3
  import type { Context } from "./context";
4
4
  import type { SdkgenError, SdkgenErrorWithData } from "./error";
5
5
  import type { DeepReadonly } from "./utils";
6
- interface ErrClasses {
7
- [className: string]: (new (message: string, data: any) => SdkgenErrorWithData<any>) | (new (message: string) => SdkgenError) | undefined;
8
- }
6
+ type ErrClasses = Record<string, (new (message: string, data: any) => SdkgenErrorWithData<any>) | (new (message: string) => SdkgenError) | undefined>;
9
7
  export declare class SdkgenHttpClient {
10
8
  private astJson;
11
9
  private errClasses;
@@ -76,27 +76,29 @@ class SdkgenHttpClient {
76
76
  });
77
77
  req.write(requestBody);
78
78
  req.end();
79
- }).catch(error => {
79
+ }).catch((error) => {
80
+ var _a;
80
81
  if ((0, utils_1.has)(error, "type") && (0, utils_1.has)(error, "message") && typeof error.type === "string" && typeof error.message === "string") {
81
- const errClass = this.errClasses[error.type];
82
- if (errClass) {
83
- const errorJson = this.astJson.errors.find(err => (Array.isArray(err) ? err[0] === error.type : err === error.type));
84
- if (errorJson) {
85
- if (Array.isArray(errorJson) && (0, utils_1.has)(error, "data")) {
86
- throw new errClass(error.message, (0, encode_decode_1.decode)(this.astJson.typeTable, `${errClass.name}.data`, errorJson[1], error.data));
87
- }
88
- else {
89
- throw new errClass(error.message, undefined);
90
- }
91
- }
82
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
83
+ const errClass = (_a = this.errClasses[error.type]) !== null && _a !== void 0 ? _a : this.errClasses.Fatal;
84
+ const errType = errClass.name;
85
+ const errorJson = this.astJson.errors.find(err => (Array.isArray(err) ? err[0] === errType : err === errType));
86
+ let newError;
87
+ if (errorJson && Array.isArray(errorJson) && (0, utils_1.has)(error, "data")) {
88
+ newError = new errClass(error.message, (0, encode_decode_1.decode)(this.astJson.typeTable, `${errClass.name}.data`, errorJson[1], error.data));
89
+ }
90
+ else {
91
+ newError = new errClass(error.message, undefined);
92
+ }
93
+ if (!newError.type) {
94
+ newError.type = errType;
92
95
  }
93
- throw new this.errClasses.Fatal(`${error.type}: ${error.message}`);
96
+ throw newError;
94
97
  }
95
98
  else {
96
99
  throw error;
97
100
  }
98
101
  });
99
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
100
102
  return (0, encode_decode_1.decode)(this.astJson.typeTable, `${functionName}.ret`, func.ret, encodedRet);
101
103
  }
102
104
  }
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import type { IncomingMessage, Server, ServerResponse } from "http";
3
4
  import type { BaseApiConfig } from "./api-config";
4
5
  export declare class SdkgenHttpServer<ExtraContextT = unknown> {
@@ -67,11 +67,21 @@ class SdkgenHttpServer {
67
67
  res.end();
68
68
  return;
69
69
  }
70
- const body = [];
71
- req.on("data", chunk => body.push(chunk));
72
- req.on("end", () => {
73
- this.handleRequestWithBody(req, res, Buffer.concat(body), hrStart).catch((e) => this.writeReply(res, null, { error: e }, hrStart));
74
- });
70
+ const handleBody = (body) => {
71
+ this.handleRequestWithBody(req, res, body, hrStart).catch((e) => this.writeReply(res, null, { error: e }, hrStart));
72
+ };
73
+ // Google Cloud Functions add a rawBody property to the request object
74
+ if ((0, utils_1.has)(req, "rawBody") && req.rawBody instanceof Buffer) {
75
+ handleBody(req.rawBody);
76
+ }
77
+ else {
78
+ const body = [];
79
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
80
+ req.on("data", chunk => body.push(chunk));
81
+ req.on("end", () => {
82
+ handleBody(Buffer.concat(body));
83
+ });
84
+ }
75
85
  };
76
86
  this.extraContext = ((_a = maybeExtraContext[0]) !== null && _a !== void 0 ? _a : {});
77
87
  this.httpServer = (0, http_1.createServer)(this.handleRequest.bind(this));
@@ -150,28 +160,29 @@ class SdkgenHttpServer {
150
160
  return new Promise(resolve => {
151
161
  this.httpServer.listen(port, () => {
152
162
  const addr = this.httpServer.address();
153
- let addrString;
154
- if (addr === null) {
155
- addrString = undefined;
163
+ let urlHost;
164
+ if (addr.address === "::") {
165
+ urlHost = `localhost:${addr.port}`;
156
166
  }
157
- else if (typeof addr === "string") {
158
- addrString = addr;
167
+ else if (addr.family === "ipv6") {
168
+ urlHost = `[${addr.address}]:${addr.port}`;
159
169
  }
160
170
  else {
161
- addrString = `${addr.address}:${addr.port}`;
171
+ urlHost = `${addr.address}:${addr.port}`;
162
172
  }
163
- if (!addrString) {
164
- console.log(`Listening.`);
165
- resolve();
166
- return;
173
+ if (addr.address === "::" || addr.address === "0.0.0.0") {
174
+ console.log(`\nListening on port ${addr.port}`);
175
+ }
176
+ else {
177
+ console.log(`\nListening on port ${addr.port} (${addr.address})`);
167
178
  }
168
- console.log(`Listening on ${addrString}`);
169
179
  if (this.introspection) {
170
- console.log(`Access the sdkgen Playground at http://${addrString}/playground`);
180
+ console.log(`Playground: http://${urlHost}/playground`);
171
181
  }
172
182
  if (this.hasSwagger) {
173
- console.log(`Access the REST API Swagger at http://${addrString}/swagger`);
183
+ console.log(`Swagger UI: http://${urlHost}/swagger`);
174
184
  }
185
+ console.log("");
175
186
  resolve();
176
187
  });
177
188
  });
@@ -370,6 +381,7 @@ class SdkgenHttpServer {
370
381
  type instanceof parser_1.DatePrimitiveType ||
371
382
  type instanceof parser_1.DateTimePrimitiveType ||
372
383
  type instanceof parser_1.MoneyPrimitiveType ||
384
+ type instanceof parser_1.DecimalPrimitiveType ||
373
385
  type instanceof parser_1.BigIntPrimitiveType ||
374
386
  type instanceof parser_1.CpfPrimitiveType ||
375
387
  type instanceof parser_1.CnpjPrimitiveType ||
@@ -463,7 +475,9 @@ class SdkgenHttpServer {
463
475
  if (reply.error) {
464
476
  const error = this.makeResponseError(reply.error);
465
477
  if (!(ctx === null || ctx === void 0 ? void 0 : ctx.response.statusCode)) {
466
- res.statusCode = error.type === "Fatal" ? 500 : 400;
478
+ const errorNode = this.apiConfig.ast.errors.find(node => node.name === error.type);
479
+ const statusAnnotation = errorNode === null || errorNode === void 0 ? void 0 : errorNode.annotations.find(x => x instanceof parser_1.StatusCodeAnnotation);
480
+ res.statusCode = statusAnnotation ? statusAnnotation.statusCode : error.type === "Fatal" ? 500 : 400;
467
481
  }
468
482
  res.setHeader("content-type", "application/json");
469
483
  res.write(JSON.stringify(error));
@@ -495,6 +509,7 @@ class SdkgenHttpServer {
495
509
  type instanceof parser_1.DatePrimitiveType ||
496
510
  type instanceof parser_1.DateTimePrimitiveType ||
497
511
  type instanceof parser_1.MoneyPrimitiveType ||
512
+ type instanceof parser_1.DecimalPrimitiveType ||
498
513
  type instanceof parser_1.BigIntPrimitiveType ||
499
514
  type instanceof parser_1.CpfPrimitiveType ||
500
515
  type instanceof parser_1.CnpjPrimitiveType ||
@@ -924,16 +939,3 @@ class SdkgenHttpServer {
924
939
  }
925
940
  }
926
941
  exports.SdkgenHttpServer = SdkgenHttpServer;
927
- // type SdkgenHttpServerConstructor<ExtraContextT = unknown> = {} extends ExtraContextT
928
- // ? ExtraContextT extends {}
929
- // ? new (apiConfig: BaseApiConfig<ExtraContextT>) => SdkgenHttpServer
930
- // : new (apiConfig: BaseApiConfig<ExtraContextT>, extraContext: ExtraContextT) => SdkgenHttpServer
931
- // : new (apiConfig: BaseApiConfig<ExtraContextT>, extraContext: ExtraContextT) => SdkgenHttpServer;
932
- // function wrap(constructor: typeof SdkgenHttpServerBase) {
933
- // return constructor as unknown as SdkgenHttpServerConstructor;
934
- // }
935
- // // eslint-disable-next-line @typescript-eslint/naming-convention
936
- // export const SdkgenHttpServer = wrap(class SdkgenHttpServer<ExtraContextT = unknown> extends SdkgenHttpServerBase<ExtraContextT> {});
937
- // export type SdkgenHttpServer<ExtraContextT = unknown> = {
938
- // [Prop in keyof SdkgenHttpServerBase<ExtraContextT>]: SdkgenHttpServerBase<ExtraContextT>[Prop];
939
- // };
@@ -1,6 +1,6 @@
1
1
  export { BaseApiConfig } from "./api-config";
2
2
  export { Context, ContextReply, ContextRequest } from "./context";
3
- export { decode, encode } from "./encode-decode";
3
+ export { decode, encode, DecodedType, EncodedType } from "./encode-decode";
4
4
  export { Fatal, SdkgenError, SdkgenErrorWithData } from "./error";
5
5
  export { SdkgenHttpClient } from "./http-client";
6
6
  export { SdkgenHttpServer } from "./http-server";