the-forest/client/node_modules/.cache/babel-loader/6466045a20e95c9bcb4dcabda2e2cb6a07e26ccdd88810302c91afb4fd2bb44d.json

1 line
8.5 KiB
JSON
Raw Normal View History

2024-09-17 20:35:18 -04:00
{"ast":null,"code":"import { ProtoError } from \"../errors.js\";\nimport * as d from \"../encoding/json/decode.js\";\nimport { Error, StmtResult, BatchResult, CursorEntry, DescribeResult } from \"../shared/json_decode.js\";\nexport function 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 = 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 = Error(d.object(obj[\"error\"]));\n return {\n type: \"response_error\",\n requestId,\n error\n };\n } else {\n throw new ProtoError(\"Unexpected type of ServerMsg\");\n }\n}\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 = StmtResult(d.object(obj[\"result\"]));\n return {\n type: \"execute\",\n result\n };\n } else if (type === \"batch\") {\n const result = 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\"], 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 = 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 ProtoError(\"Unexpected type of Response\");\n }\n}","map":{"version":3,"names":["ProtoError","d","Error","StmtResult","BatchResult","CursorEntry","DescribeResult","ServerMsg","obj","type","string","error","object","requestId","number","response","Response","result","entries","arrayObjectsMap","done","boolean","isAutocommit"],"sources":["/Users/shoofle/Projects/the-forest/node_modules/@libsql/hrana-client/lib-esm/ws/json_decode.js"],"sourcesContent":["import { ProtoError } from \"../errors.js\";\nimport * as d from \"../encoding/json/decode.js\";\nimport { Error, StmtResult, BatchResult, CursorEntry, DescribeResult } from \"../shared/json_decode.js\";\nexport function ServerMsg(obj) {\n const type = d.string(obj[\"type\"]);\n if (type === \"hello_ok\") {\n return { type: \"hello_ok\" };\n }\n else if (type === \"hello_error\") {\n const error = Error(d.object(obj[\"error\"]));\n return { type: \"hello_error\", 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 { type: \"response_ok\", requestId, response };\n }\n else if (type === \"response_error\") {\n const requestId = d.number(obj[\"request_id\"]);\n const error = Error(d.object(obj[\"error\"]));