{"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\"]));\n return { type: \"response_error\", requestId, 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 { type: \"open_stream\" };\n }\n else if (type === \"close_stream\") {\n return { type: \"close_stream\" };\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 === \"open_cursor\") {\n return { type: \"open_cursor\" };\n }\n else if (type === \"close_cursor\") {\n return { 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 { type: \"fetch_cursor\", entries, done };\n }\n else if (type === \"sequence\") {\n return { type: \"sequence\" };\n }\n else if (type === \"describe\") {\n const result = DescribeResult(d.object(obj[\"result\"]));\n return { type: \"describe\", result };\n }\n else if (type === \"store_sql\") {\n return { type: \"store_sql\" };\n }\n else if (type === \"close_sql\") {\n return { type: \"close_sql\" };\n }\n else if (type === \"get_autocommit\") {\n const isAutocommit = d.boolean(obj[\"is_autocommit\"]);\n return { type: \"get_autocommit\", isAutocommit };\n }\n else {\n throw new ProtoError(\"Unexpected type of Response\");\n }\n}\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,cAAc;AACzC,OAAO,KAAKC,CAAC,MAAM,4BAA4B;AAC/C,SAASC,KAAK,EAAEC,UAAU,EAAEC,WAAW,EAAEC,WAAW,EAAEC,cAAc,QAAQ,0BAA0B;AACtG,OAAO,SAASC,SAASA,CAACC,GAAG,EAAE;EAC3B,MAAMC,IAAI,GAAGR,CAAC,CAACS,MAAM,CAACF,GAAG,CAAC,MAAM,CAAC,CAAC;EAClC,IAAIC,IAAI,KAAK,UAAU,EAAE;IACrB,OAAO;MAAEA,IAAI,EAAE;IAAW,CAAC;EAC/B,CAAC,MACI,IAAIA,IAAI,KAAK,aAAa,EAAE;IAC7B,MAAME,KAAK,GAAGT,KAAK,CAACD,CAAC,CAACW,MAAM,CAACJ,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3C,OAAO;MAAEC,IAAI,EAAE,aAAa;MAAEE;IAAM,CAAC;EACzC,CAAC,MACI,IAAIF,IAAI,KAAK,aAAa,EAAE;IAC7B,MAAMI,SAAS,GAAGZ,CAAC,CAACa,MAAM,CAACN,GAAG,CAAC,YAAY,CAAC,CAAC;IAC7C,MAAMO,QAAQ,GAAGC,QAAQ,CAACf,CAAC,CAACW,MAAM,CAACJ,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;IACpD,OAAO;MAAEC,I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