1 line
7.2 KiB
JSON
1 line
7.2 KiB
JSON
|
{"ast":null,"code":"import { ProtoError } from \"../errors.js\";\nimport * as d from \"../encoding/json/decode.js\";\nimport { Error, StmtResult, BatchResult, DescribeResult } from \"../shared/json_decode.js\";\nexport function PipelineRespBody(obj) {\n const baton = d.stringOpt(obj[\"baton\"]);\n const baseUrl = d.stringOpt(obj[\"base_url\"]);\n const results = d.arrayObjectsMap(obj[\"results\"], StreamResult);\n return {\n baton,\n baseUrl,\n results\n };\n}\nfunction StreamResult(obj) {\n const type = d.string(obj[\"type\"]);\n if (type === \"ok\") {\n const response = StreamResponse(d.object(obj[\"response\"]));\n return {\n type: \"ok\",\n response\n };\n } else if (type === \"error\") {\n const error = Error(d.object(obj[\"error\"]));\n return {\n type: \"error\",\n error\n };\n } else {\n throw new ProtoError(\"Unexpected type of StreamResult\");\n }\n}\nfunction StreamResponse(obj) {\n const type = d.string(obj[\"type\"]);\n if (type === \"close\") {\n return {\n type: \"close\"\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 === \"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 StreamResponse\");\n }\n}\nexport function CursorRespBody(obj) {\n const baton = d.stringOpt(obj[\"baton\"]);\n const baseUrl = d.stringOpt(obj[\"base_url\"]);\n return {\n baton,\n baseUrl\n };\n}","map":{"version":3,"names":["ProtoError","d","Error","StmtResult","BatchResult","DescribeResult","PipelineRespBody","obj","baton","stringOpt","baseUrl","results","arrayObjectsMap","StreamResult","type","string","response","StreamResponse","object","error","result","isAutocommit","boolean","CursorRespBody"],"sources":["/Users/shoofle/Projects/the-forest/node_modules/@libsql/hrana-client/lib-esm/http/json_decode.js"],"sourcesContent":["import { ProtoError } from \"../errors.js\";\nimport * as d from \"../encoding/json/decode.js\";\nimport { Error, StmtResult, BatchResult, DescribeResult } from \"../shared/json_decode.js\";\nexport function PipelineRespBody(obj) {\n const baton = d.stringOpt(obj[\"baton\"]);\n const baseUrl = d.stringOpt(obj[\"base_url\"]);\n const results = d.arrayObjectsMap(obj[\"results\"], StreamResult);\n return { baton, baseUrl, results };\n}\nfunction StreamResult(obj) {\n const type = d.string(obj[\"type\"]);\n if (type === \"ok\") {\n const response = StreamResponse(d.object(obj[\"response\"]));\n return { type: \"ok\", response };\n }\n else if (type === \"error\") {\n const error = Error(d.object(obj[\"error\"]));\n return { type: \"error\", error };\n }\n else {\n throw new ProtoError(\"Unexpected type of StreamResult\");\n }\n}\nfunction StreamResponse(obj) {\n const type = d.string(obj[\"type\"]);\n if (type === \"close\") {\n return { type: \"close\" };\n }\n else if (type === \"execute\") {\n const result = StmtResult(d.object(obj[\"result\"]));\n return { type: \"execute\", result };\n }\n else if (type === \"batch\") {\n const result = BatchResult(d.object(obj[\"result\"]));\n return { type: \"batch\", result };\n }\n else if (type =
|