1 line
13 KiB
JSON
1 line
13 KiB
JSON
|
{"ast":null,"code":"\"use strict\";\n\nvar __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = {\n enumerable: true,\n get: function () {\n return m[k];\n }\n };\n }\n Object.defineProperty(o, k2, desc);\n} : function (o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\nvar __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {\n Object.defineProperty(o, \"default\", {\n enumerable: true,\n value: v\n });\n} : function (o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = this && this.__importStar || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.ServerMsg = void 0;\nconst errors_js_1 = require(\"../errors.js\");\nconst d = __importStar(require(\"../encoding/json/decode.js\"));\nconst json_decode_js_1 = require(\"../shared/json_decode.js\");\nfunction ServerMsg(obj) {\n const type = d.string(obj[\"type\"]);\n if (type === \"hello_ok\") {\n return {\n type: \"hello_ok\"\n };\n } else if (type === \"hello_error\") {\n const error = (0, json_decode_js_1.Error)(d.object(obj[\"error\"]));\n return {\n type: \"hello_error\",\n error\n };\n } else if (type === \"response_ok\") {\n const requestId = d.number(obj[\"request_id\"]);\n const response = Response(d.object(obj[\"response\"]));\n return {\n type: \"response_ok\",\n requestId,\n response\n };\n } else if (type === \"response_error\") {\n const requestId = d.number(obj[\"request_id\"]);\n const error = (0, json_decode_js_1.Error)(d.object(obj[\"error\"]));\n return {\n type: \"response_error\",\n requestId,\n error\n };\n } else {\n throw new errors_js_1.ProtoError(\"Unexpected type of ServerMsg\");\n }\n}\nexports.ServerMsg = ServerMsg;\nfunction Response(obj) {\n const type = d.string(obj[\"type\"]);\n if (type === \"open_stream\") {\n return {\n type: \"open_stream\"\n };\n } else if (type === \"close_stream\") {\n return {\n type: \"close_stream\"\n };\n } else if (type === \"execute\") {\n const result = (0, json_decode_js_1.StmtResult)(d.object(obj[\"result\"]));\n return {\n type: \"execute\",\n result\n };\n } else if (type === \"batch\") {\n const result = (0, json_decode_js_1.BatchResult)(d.object(obj[\"result\"]));\n return {\n type: \"batch\",\n result\n };\n } else if (type === \"open_cursor\") {\n return {\n type: \"open_cursor\"\n };\n } else if (type === \"close_cursor\") {\n return {\n type: \"close_cursor\"\n };\n } else if (type === \"fetch_cursor\") {\n const entries = d.arrayObjectsMap(obj[\"entries\"], json_decode_js_1.CursorEntry);\n const done = d.boolean(obj[\"done\"]);\n return {\n type: \"fetch_cursor\",\n entries,\n done\n };\n } else if (type === \"sequence\") {\n return {\n type: \"sequence\"\n };\n } else if (type === \"describe\") {\n const result = (0, json_decode_js_1.DescribeResult)(d.object(obj[\"result\"]));\n return {\n type: \"describe\",\n result\n };\n } else if (type === \"store_sql\") {\n return {\n type: \"store_sql\"\n };\n } else if (type === \"close_sql\") {\n return {\n type: \"close_sql\"\n };\n } else if (type === \"get_autocommit\") {\n const isAutocommit = d.boolean(obj[\"is_autocommit\"]);\n return {\n type: \"get_autocommit\",\n isAutocommit\n };\n } else {\n throw new errors_js_1.ProtoError(\"Unexpected type of
|