@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.
- package/dist/spec/simple/legacyNodeClient.d.ts +1 -1
- package/dist/spec/simple/simple.spec.js +8 -0
- package/dist/src/api-config.d.ts +3 -5
- package/dist/src/api-config.js +1 -0
- package/dist/src/context.d.ts +1 -0
- package/dist/src/encode-decode.d.ts +10 -9
- package/dist/src/encode-decode.js +23 -6
- package/dist/src/http-client.d.ts +1 -3
- package/dist/src/http-client.js +16 -14
- package/dist/src/http-server.d.ts +1 -0
- package/dist/src/http-server.js +34 -32
- package/dist/src/index.d.ts +1 -1
- package/dist/src/swagger.js +208 -155
- package/dist/src/test-wrapper.d.ts +1 -2
- package/dist/src/test-wrapper.js +23 -21
- package/dist/src/utils.d.ts +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +22 -18
|
@@ -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
|
});
|
package/dist/src/api-config.d.ts
CHANGED
|
@@ -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
|
-
|
|
5
|
-
export declare
|
|
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
|
}
|
package/dist/src/api-config.js
CHANGED
package/dist/src/context.d.ts
CHANGED
|
@@ -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
|
-
|
|
5
|
-
|
|
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
|
-
|
|
9
|
+
type JsonType = number | string | boolean | null | JsonType[] | {
|
|
9
10
|
[Key in string]: JsonType;
|
|
10
11
|
};
|
|
11
|
-
|
|
12
|
+
type AnyDecodedType = number | string | boolean | null | bigint | Decimal | Buffer | Date | AnyDecodedType[] | {
|
|
12
13
|
[Key in string]: AnyDecodedType;
|
|
13
14
|
};
|
|
14
|
-
|
|
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
|
-
|
|
18
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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;
|
package/dist/src/http-client.js
CHANGED
|
@@ -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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
|
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
|
}
|
package/dist/src/http-server.js
CHANGED
|
@@ -67,11 +67,21 @@ class SdkgenHttpServer {
|
|
|
67
67
|
res.end();
|
|
68
68
|
return;
|
|
69
69
|
}
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
|
154
|
-
if (addr ===
|
|
155
|
-
|
|
163
|
+
let urlHost;
|
|
164
|
+
if (addr.address === "::") {
|
|
165
|
+
urlHost = `localhost:${addr.port}`;
|
|
156
166
|
}
|
|
157
|
-
else if (
|
|
158
|
-
|
|
167
|
+
else if (addr.family === "ipv6") {
|
|
168
|
+
urlHost = `[${addr.address}]:${addr.port}`;
|
|
159
169
|
}
|
|
160
170
|
else {
|
|
161
|
-
|
|
171
|
+
urlHost = `${addr.address}:${addr.port}`;
|
|
162
172
|
}
|
|
163
|
-
if (
|
|
164
|
-
console.log(`
|
|
165
|
-
|
|
166
|
-
|
|
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(`
|
|
180
|
+
console.log(`Playground: http://${urlHost}/playground`);
|
|
171
181
|
}
|
|
172
182
|
if (this.hasSwagger) {
|
|
173
|
-
console.log(`
|
|
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
|
-
|
|
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
|
-
// };
|
package/dist/src/index.d.ts
CHANGED
|
@@ -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";
|