@sdkgen/node-runtime 2.3.2 → 2.4.0

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 (54) hide show
  1. package/dist/api-config.js +19 -0
  2. package/dist/{src/context.d.ts → context.d.ts} +1 -0
  3. package/dist/context.js +3 -0
  4. package/dist/encode-decode.js +344 -0
  5. package/dist/error.js +33 -0
  6. package/dist/execute.js +57 -0
  7. package/dist/http-client.js +107 -0
  8. package/dist/{src/http-server.d.ts → http-server.d.ts} +1 -0
  9. package/dist/http-server.js +941 -0
  10. package/dist/{src/index.js → index.js} +1 -0
  11. package/dist/swagger.js +453 -0
  12. package/dist/test-wrapper.js +58 -0
  13. package/dist/utils.js +8 -0
  14. package/package.json +50 -34
  15. package/.eslintignore +0 -1
  16. package/.eslintrc.json +0 -3
  17. package/.prettierrc +0 -12
  18. package/.vscode/settings.json +0 -14
  19. package/dist/spec/error.spec.d.ts +0 -1
  20. package/dist/spec/error.spec.js +0 -15
  21. package/dist/spec/rest/rest.spec.d.ts +0 -1
  22. package/dist/spec/rest/rest.spec.js +0 -353
  23. package/dist/spec/runtime/errors.spec.d.ts +0 -1
  24. package/dist/spec/runtime/errors.spec.js +0 -43
  25. package/dist/spec/runtime/middleware.spec.d.ts +0 -1
  26. package/dist/spec/runtime/middleware.spec.js +0 -100
  27. package/dist/spec/simple/legacyNodeClient.d.ts +0 -17
  28. package/dist/spec/simple/legacyNodeClient.js +0 -128
  29. package/dist/spec/simple/simple.spec.d.ts +0 -1
  30. package/dist/spec/simple/simple.spec.js +0 -113
  31. package/dist/spec/types.d.ts +0 -1
  32. package/dist/spec/types.js +0 -60
  33. package/dist/spec/types.spec.d.ts +0 -1
  34. package/dist/spec/types.spec.js +0 -128
  35. package/dist/src/api-config.js +0 -19
  36. package/dist/src/context.js +0 -2
  37. package/dist/src/encode-decode.js +0 -376
  38. package/dist/src/error.js +0 -32
  39. package/dist/src/execute.js +0 -56
  40. package/dist/src/http-client.js +0 -105
  41. package/dist/src/http-server.js +0 -941
  42. package/dist/src/swagger.js +0 -439
  43. package/dist/src/test-wrapper.js +0 -52
  44. package/dist/src/utils.js +0 -7
  45. package/dist/tsconfig.tsbuildinfo +0 -1
  46. /package/dist/{src/api-config.d.ts → api-config.d.ts} +0 -0
  47. /package/dist/{src/encode-decode.d.ts → encode-decode.d.ts} +0 -0
  48. /package/dist/{src/error.d.ts → error.d.ts} +0 -0
  49. /package/dist/{src/execute.d.ts → execute.d.ts} +0 -0
  50. /package/dist/{src/http-client.d.ts → http-client.d.ts} +0 -0
  51. /package/dist/{src/index.d.ts → index.d.ts} +0 -0
  52. /package/dist/{src/swagger.d.ts → swagger.d.ts} +0 -0
  53. /package/dist/{src/test-wrapper.d.ts → test-wrapper.d.ts} +0 -0
  54. /package/dist/{src/utils.d.ts → utils.d.ts} +0 -0
@@ -1,128 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.ApiClient = void 0;
27
- /* eslint-disable */
28
- const http = __importStar(require("http"));
29
- const https = __importStar(require("https"));
30
- const url_1 = require("url");
31
- class ApiClient {
32
- constructor(baseUrl = "https://", useStaging = false) {
33
- this.baseUrl = baseUrl;
34
- this.useStaging = useStaging;
35
- this.deviceId = null;
36
- }
37
- async getUser(id) {
38
- const args = {
39
- id: id,
40
- };
41
- const ret = await this.makeRequest({ name: "getUser", args });
42
- return {
43
- name: ret.name,
44
- age: ret.age | 0,
45
- };
46
- }
47
- async ping() {
48
- const ret = await this.makeRequest({ name: "ping", args: {} });
49
- return ret;
50
- }
51
- async setPushToken(token) {
52
- const args = {
53
- token: token,
54
- };
55
- await this.makeRequest({ name: "setPushToken", args });
56
- }
57
- device() {
58
- const device = {
59
- type: "node",
60
- };
61
- if (this.deviceId)
62
- device.id = this.deviceId;
63
- return device;
64
- }
65
- randomBytesHex(len) {
66
- let hex = "";
67
- for (let i = 0; i < 2 * len; ++i)
68
- hex += "0123456789abcdef"[Math.floor(Math.random() * 16)];
69
- return hex;
70
- }
71
- async makeRequest({ name, args }) {
72
- const deviceData = this.device();
73
- const body = {
74
- id: this.randomBytesHex(8),
75
- device: deviceData,
76
- name: name,
77
- args: args,
78
- };
79
- const url = new url_1.URL(this.baseUrl + (this.useStaging ? "-staging" : "") + "/" + name);
80
- const options = {
81
- hostname: url.hostname,
82
- path: url.pathname,
83
- port: url.port,
84
- method: "POST",
85
- };
86
- return new Promise((resolve, reject) => {
87
- const req = (url.protocol === "http:" ? http : https).request(options, resp => {
88
- let data = "";
89
- resp.on("data", chunk => {
90
- data += chunk;
91
- });
92
- resp.on("end", () => {
93
- try {
94
- const response = JSON.parse(data);
95
- try {
96
- this.deviceId = response.deviceId;
97
- if (response.ok) {
98
- resolve(response.result);
99
- }
100
- else {
101
- reject(response.error);
102
- }
103
- }
104
- catch (e) {
105
- console.error(e);
106
- reject({ type: "Fatal", message: `${e}` });
107
- }
108
- }
109
- catch (e) {
110
- console.error(e);
111
- reject({
112
- type: "BadFormattedResponse",
113
- message: `Response couldn't be parsed as JSON (${data}):\n${e}`,
114
- });
115
- }
116
- });
117
- });
118
- req.on("error", e => {
119
- console.error(`problem with request: ${e.message}`);
120
- reject({ type: "Fatal", message: e.toString() });
121
- });
122
- // write data to request body
123
- req.write(JSON.stringify(body));
124
- req.end();
125
- });
126
- }
127
- }
128
- exports.ApiClient = ApiClient;
@@ -1 +0,0 @@
1
- export {};
@@ -1,113 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- /* eslint-disable @typescript-eslint/no-explicit-any */
7
- /* eslint-disable @typescript-eslint/require-await */
8
- /* eslint-disable @typescript-eslint/no-unsafe-return */
9
- /* eslint-disable @typescript-eslint/naming-convention */
10
- /* eslint-disable @typescript-eslint/no-require-imports */
11
- /* eslint-disable @typescript-eslint/no-var-requires */
12
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
13
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
14
- /* eslint-disable @typescript-eslint/no-unsafe-call */
15
- const crypto_1 = require("crypto");
16
- const fs_1 = require("fs");
17
- const parser_1 = require("@sdkgen/parser");
18
- const typescript_generator_1 = require("@sdkgen/typescript-generator");
19
- const axios_1 = __importDefault(require("axios"));
20
- const decimal_js_1 = __importDefault(require("decimal.js"));
21
- const src_1 = require("../../src");
22
- const ast = new parser_1.Parser(`${__dirname}/api.sdkgen`).parse();
23
- (0, fs_1.writeFileSync)(`${__dirname}/api.ts`, (0, typescript_generator_1.generateNodeServerSource)(ast).replace(/@sdkgen\/node-runtime/gu, "../../src"));
24
- const { api, SomeError } = require(`${__dirname}/api.ts`);
25
- (0, fs_1.unlinkSync)(`${__dirname}/api.ts`);
26
- let lastCallCtx = null;
27
- api.fn.getUser = async (ctx, { id }) => {
28
- lastCallCtx = ctx;
29
- return {
30
- age: 1,
31
- name: id,
32
- };
33
- };
34
- api.fn.identity = async (ctx, { types }) => {
35
- lastCallCtx = ctx;
36
- return types;
37
- };
38
- api.fn.throwsError = async () => {
39
- throw new SomeError("Some message");
40
- };
41
- api.fn.decimalAdd = async (_ctx, { a, b }) => {
42
- return a.add(b);
43
- };
44
- // ExecSync(`../../cubos/sdkgen/sdkgen ${__dirname + "/api.sdkgen"} -o ${__dirname + "/legacyNodeClient.ts"} -t typescript_nodeclient`);
45
- const { ApiClient: NodeLegacyApiClient } = require(`${__dirname}/legacyNodeClient.ts`);
46
- const nodeLegacyClient = new NodeLegacyApiClient("http://localhost:34367");
47
- (0, fs_1.writeFileSync)(`${__dirname}/nodeClient.ts`, (0, typescript_generator_1.generateNodeClientSource)(ast).replace(/@sdkgen\/node-runtime/gu, "../../src"));
48
- const { ApiClient: NodeApiClient } = require(`${__dirname}/nodeClient.ts`);
49
- (0, fs_1.unlinkSync)(`${__dirname}/nodeClient.ts`);
50
- const nodeClient = new NodeApiClient("http://localhost:34367");
51
- const server = new src_1.SdkgenHttpServer(api, { aaa: true });
52
- describe("Simple API", () => {
53
- beforeAll(async () => {
54
- await server.listen(34367);
55
- });
56
- afterAll(async () => {
57
- await server.close();
58
- });
59
- test("Healthcheck on 'GET /' only", async () => {
60
- expect(await axios_1.default.get("http://localhost:34367/")).toMatchObject({ data: { ok: true } });
61
- await expect(axios_1.default.get("http://localhost:34367/egesg")).rejects.toThrowError();
62
- });
63
- test("Can get ast.json at runtime", async () => {
64
- expect(await axios_1.default.get("http://localhost:34367/ast.json")).toMatchObject({ data: (0, parser_1.astToJson)(ast) });
65
- server.introspection = false;
66
- await expect(axios_1.default.get("http://localhost:34367/ast.json")).rejects.toThrowError();
67
- });
68
- test("Can make a call from legacy node client", async () => {
69
- expect(await nodeLegacyClient.getUser("abc")).toEqual({ age: 1, name: "abc" });
70
- expect(await nodeLegacyClient.getUser("5hdr")).toEqual({ age: 1, name: "5hdr" });
71
- expect(lastCallCtx.request).toMatchObject({ deviceInfo: { type: "node" }, name: "getUser" });
72
- expect(lastCallCtx.aaa).toBe(true);
73
- });
74
- test("Can make a call from newer node client", async () => {
75
- expect(await nodeClient.getUser(null, { id: "abc" })).toEqual({ age: 1, name: "abc" });
76
- expect(await nodeClient.getUser(null, { id: "5hdr" })).toEqual({ age: 1, name: "5hdr" });
77
- expect(lastCallCtx.request).toMatchObject({ deviceInfo: { type: "node" }, name: "getUser" });
78
- });
79
- test("Can process all types as identity", async () => {
80
- const types = {
81
- array: [1, 2, 3],
82
- arrayOfOptionals: [1, null, 3],
83
- base64: "SGVsbG8K",
84
- bool: true,
85
- bytes: (0, crypto_1.randomBytes)(23),
86
- date: new Date(2019, 12, 3),
87
- datetime: new Date(),
88
- enum: "aa",
89
- float: 22235.6,
90
- hex: "f84c4d20",
91
- int: -25,
92
- json: [{ a: 23, b: "odcbu" }],
93
- money: 356,
94
- optional1: null,
95
- optional2: 2525,
96
- string: "efvregare",
97
- struct: { aa: 42 },
98
- uint: 243,
99
- uuid: "f84c4d20-eed8-4004-b236-74aaa71fbeca",
100
- };
101
- expect(await nodeClient.identity(null, { types })).toEqual(types);
102
- });
103
- test("Errors are passed correctly", async () => {
104
- await expect(nodeClient.throwsError(null, {})).rejects.toMatchObject({
105
- message: "Some message",
106
- type: "SomeError",
107
- });
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
- });
113
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,60 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const spec_ts_1 = require("spec.ts");
4
- const src_1 = require("../src");
5
- {
6
- const typeTable = {};
7
- const encoded = (0, src_1.encode)(typeTable, "", "string", "");
8
- const decoded = (0, src_1.decode)(typeTable, "", "string", "");
9
- (0, spec_ts_1.assert)(encoded, spec_ts_1._);
10
- (0, spec_ts_1.assert)(decoded, spec_ts_1._);
11
- }
12
- {
13
- const typeTable = {};
14
- const encoded = (0, src_1.encode)(typeTable, "", "bigint", "");
15
- const decoded = (0, src_1.decode)(typeTable, "", "bigint", "");
16
- (0, spec_ts_1.assert)(encoded, spec_ts_1._);
17
- (0, spec_ts_1.assert)(decoded, spec_ts_1._);
18
- }
19
- {
20
- const typeTable = {
21
- Foo: "string?",
22
- };
23
- const encoded = (0, src_1.encode)(typeTable, "", "Foo", "");
24
- const decoded = (0, src_1.decode)(typeTable, "", "Foo", "");
25
- (0, spec_ts_1.assert)(encoded, spec_ts_1._);
26
- (0, spec_ts_1.assert)(decoded, spec_ts_1._);
27
- }
28
- {
29
- const typeTable = {
30
- Foo: "string?",
31
- Bar: {
32
- a: "string",
33
- b: "Foo[]",
34
- },
35
- };
36
- const encoded = (0, src_1.encode)(typeTable, "", "Bar", "");
37
- const decoded = (0, src_1.decode)(typeTable, "", "Bar", "");
38
- (0, spec_ts_1.assert)(encoded, spec_ts_1._);
39
- (0, spec_ts_1.assert)(decoded, spec_ts_1._);
40
- }
41
- {
42
- const typeTable = {
43
- Foo: "string?",
44
- Bar: ["a", "b"],
45
- };
46
- const encoded = (0, src_1.encode)(typeTable, "", "Bar", "");
47
- const decoded = (0, src_1.decode)(typeTable, "", "Bar", "");
48
- (0, spec_ts_1.assert)(encoded, spec_ts_1._);
49
- (0, spec_ts_1.assert)(decoded, spec_ts_1._);
50
- }
51
- {
52
- const typeTable = {
53
- Foo: { x: "string?" },
54
- Bar: ["a", ["b", "Foo"]],
55
- };
56
- const encoded = (0, src_1.encode)(typeTable, "", "Bar", "");
57
- const decoded = (0, src_1.decode)(typeTable, "", "Bar", "");
58
- (0, spec_ts_1.assert)(encoded, spec_ts_1._);
59
- (0, spec_ts_1.assert)(decoded, spec_ts_1._);
60
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,128 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
4
- /* eslint-disable @typescript-eslint/no-unsafe-call */
5
- const src_1 = require("../src");
6
- describe("Encode/Decode", () => {
7
- test("Process CPF", () => {
8
- expect((0, src_1.encode)({}, "", "cpf", "067.183.145-36")).toBe("06718314536");
9
- expect((0, src_1.decode)({}, "", "cpf", "06718314536")).toBe("067.183.145-36");
10
- expect(() => {
11
- (0, src_1.encode)({}, "", "cpf", "067.183.145-35");
12
- }).toThrow();
13
- expect(() => {
14
- (0, src_1.decode)({}, "", "cpf", "06718314535");
15
- }).toThrow();
16
- });
17
- test("Process CNPJ", () => {
18
- expect((0, src_1.encode)({}, "", "cnpj", "18.571.767/0001-36")).toBe("18571767000136");
19
- expect((0, src_1.decode)({}, "", "cnpj", "18571767000136")).toBe("18.571.767/0001-36");
20
- expect(() => {
21
- (0, src_1.encode)({}, "", "cnpj", "18.571.767/0001-35");
22
- }).toThrow();
23
- expect(() => {
24
- (0, src_1.decode)({}, "", "cnpj", "18571767000135");
25
- }).toThrow();
26
- });
27
- test("Process URL", () => {
28
- expect((0, src_1.encode)({}, "", "url", "https://cubos.io/")).toBe("https://cubos.io/");
29
- expect((0, src_1.decode)({}, "", "url", "https://cubos.io/")).toBe("https://cubos.io/");
30
- expect((0, src_1.encode)({}, "", "url", " https:cubos.io/ ")).toBe("https://cubos.io/");
31
- expect((0, src_1.encode)({}, "", "url", " https:cubos.io ")).toBe("https://cubos.io/");
32
- expect(() => {
33
- (0, src_1.encode)({}, "", "url", "dfbdfb");
34
- }).toThrow();
35
- expect(() => {
36
- (0, src_1.decode)({}, "", "url", "hhh.com");
37
- }).toThrow();
38
- });
39
- test("Process Base64", () => {
40
- expect((0, src_1.encode)({}, "", "base64", "c3VyZS4=")).toBe("c3VyZS4=");
41
- expect((0, src_1.encode)({}, "", "base64", "")).toBe("");
42
- expect(() => {
43
- (0, src_1.encode)({}, "", "base64", "c3VyZS4");
44
- }).toThrow();
45
- expect(() => {
46
- (0, src_1.encode)({}, "", "base64", " c3VyZS4=");
47
- }).toThrow();
48
- expect((0, src_1.decode)({}, "", "base64", "c3VyZS4=")).toBe("c3VyZS4=");
49
- expect((0, src_1.decode)({}, "", "base64", "")).toBe("");
50
- expect(() => {
51
- (0, src_1.decode)({}, "", "base64", "c3VyZS4");
52
- }).toThrow();
53
- expect(() => {
54
- (0, src_1.decode)({}, "", "base64", " c3VyZS4=");
55
- }).toThrow();
56
- });
57
- test("Process Date", () => {
58
- expect((0, src_1.encode)({}, "", "date", new Date("2020-11-10T00:00:00Z"))).toBe("2020-11-10");
59
- expect((0, src_1.encode)({}, "", "date", new Date("2020-11-10T15:34:50Z"))).toBe("2020-11-10");
60
- expect((0, src_1.encode)({}, "", "date", "2020-11-10")).toBe("2020-11-10");
61
- expect(() => {
62
- (0, src_1.encode)({}, "", "date", "2020-11-10T15:34:50Z");
63
- }).toThrow();
64
- expect(() => {
65
- (0, src_1.encode)({}, "", "date", "hello world");
66
- }).toThrow();
67
- expect(() => {
68
- (0, src_1.decode)({}, "", "date", "2020-02-30");
69
- }).toThrow();
70
- expect(() => {
71
- (0, src_1.encode)({}, "", "date", new Date(""));
72
- }).toThrow();
73
- });
74
- test("Process Datetime", () => {
75
- expect((0, src_1.encode)({}, "", "datetime", new Date("2020-11-10T15:34:50Z"))).toBe("2020-11-10T15:34:50.000");
76
- expect((0, src_1.encode)({}, "", "datetime", "2020-11-10T15:34:50Z")).toBe("2020-11-10T15:34:50.000");
77
- expect((0, src_1.encode)({}, "", "datetime", "2020-11-10T15:34:50.999")).toBe("2020-11-10T15:34:50.999");
78
- expect((0, src_1.encode)({}, "", "datetime", "2020-11-10T15:34:50+01:00")).toBe("2020-11-10T14:34:50.000");
79
- expect((0, src_1.encode)({}, "", "datetime", "2020-11-10T15:34:50.999+01:00")).toBe("2020-11-10T14:34:50.999");
80
- expect(() => {
81
- (0, src_1.encode)({}, "", "datetime", "2020-11-10");
82
- }).toThrow();
83
- expect(() => {
84
- (0, src_1.encode)({}, "", "datetime", "hello world");
85
- }).toThrow();
86
- expect(() => {
87
- (0, src_1.encode)({}, "", "datetime", "2020-11-10T15:34:50.999$01:00");
88
- }).toThrow();
89
- expect(() => {
90
- (0, src_1.decode)({}, "", "datetime", "2020-11-10T15:34:50.999$01:00");
91
- }).toThrow();
92
- expect((0, src_1.decode)({}, "", "datetime", "2020-11-10T15:34:50Z").getTime()).toBe(new Date("2020-11-10T15:34:50Z").getTime());
93
- expect((0, src_1.decode)({}, "", "datetime", "2020-11-10T15:34:50.000").getTime()).toBe(new Date("2020-11-10T15:34:50Z").getTime());
94
- expect(() => {
95
- (0, src_1.encode)({}, "", "datetime", new Date(""));
96
- }).toThrow();
97
- });
98
- test("Process BigInt", () => {
99
- expect((0, src_1.encode)({}, "", "bigint", BigInt(10))).toBe("10");
100
- expect(() => {
101
- (0, src_1.encode)({}, "", "bigint", 10);
102
- }).toThrow();
103
- expect(() => {
104
- (0, src_1.encode)({}, "", "bigint", "10");
105
- }).toThrow();
106
- expect((0, src_1.decode)({}, "", "bigint", 10)).toBe(BigInt(10));
107
- expect((0, src_1.decode)({}, "", "bigint", "10")).toBe(BigInt(10));
108
- expect(() => {
109
- (0, src_1.decode)({}, "", "bigint", "hello world");
110
- }).toThrow();
111
- });
112
- test("Process Enum", () => {
113
- for (const func of [src_1.encode, src_1.decode]) {
114
- expect(func({}, "", ["a", "b"], "a")).toBe("a");
115
- expect(func({}, "", ["a", "b"], "b")).toBe("b");
116
- expect(() => {
117
- func({}, "", ["a", "b"], "c");
118
- }).toThrow();
119
- expect(() => {
120
- func({ X: { v: "int" } }, "", ["a", ["b", "X"]], "b");
121
- }).toThrow();
122
- }
123
- expect((0, src_1.encode)({ X: { v: "int" } }, "", ["a", ["b", "X"]], { tag: "a" })).toBe("a");
124
- expect((0, src_1.encode)({ X: { v: "int" } }, "", ["a", ["b", "X"]], { tag: "b", v: 4 })).toEqual(["b", { v: 4 }]);
125
- expect((0, src_1.decode)({ X: { v: "int" } }, "", ["a", ["b", "X"]], "a")).toEqual({ tag: "a" });
126
- expect((0, src_1.decode)({ X: { v: "int" } }, "", ["a", ["b", "X"]], ["b", { v: 4 }])).toEqual({ tag: "b", v: 4 });
127
- });
128
- });
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseApiConfig = void 0;
4
- const parser_1 = require("@sdkgen/parser");
5
- class BaseApiConfig {
6
- constructor() {
7
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
- this.fn = {};
9
- this.middlewares = [];
10
- }
11
- get ast() {
12
- var _a;
13
- return ((_a = this._ast) !== null && _a !== void 0 ? _a : (this._ast = (0, parser_1.jsonToAst)(this.astJson)));
14
- }
15
- use(middleware) {
16
- this.middlewares.push(middleware);
17
- }
18
- }
19
- exports.BaseApiConfig = BaseApiConfig;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });