the-forest/client/node_modules/.cache/babel-loader/cac9505fc4e3966819140aabe4a3f2fc18bbaf9707fda843757dd7b2737bb805.json
2024-09-17 20:35:18 -04:00

1 line
13 KiB
JSON

{"ast":null,"code":"import { Base64 } from \"js-base64\";\nimport { ProtoError } from \"../errors.js\";\nimport * as d from \"../encoding/json/decode.js\";\nexport function Error(obj) {\n const message = d.string(obj[\"message\"]);\n const code = d.stringOpt(obj[\"code\"]);\n return {\n message,\n code\n };\n}\nexport function StmtResult(obj) {\n const cols = d.arrayObjectsMap(obj[\"cols\"], Col);\n const rows = d.array(obj[\"rows\"]).map(rowObj => d.arrayObjectsMap(rowObj, Value));\n const affectedRowCount = d.number(obj[\"affected_row_count\"]);\n const lastInsertRowidStr = d.stringOpt(obj[\"last_insert_rowid\"]);\n const lastInsertRowid = lastInsertRowidStr !== undefined ? BigInt(lastInsertRowidStr) : undefined;\n return {\n cols,\n rows,\n affectedRowCount,\n lastInsertRowid\n };\n}\nfunction Col(obj) {\n const name = d.stringOpt(obj[\"name\"]);\n const decltype = d.stringOpt(obj[\"decltype\"]);\n return {\n name,\n decltype\n };\n}\nexport function BatchResult(obj) {\n const stepResults = new Map();\n d.array(obj[\"step_results\"]).forEach((value, i) => {\n if (value !== null) {\n stepResults.set(i, StmtResult(d.object(value)));\n }\n });\n const stepErrors = new Map();\n d.array(obj[\"step_errors\"]).forEach((value, i) => {\n if (value !== null) {\n stepErrors.set(i, Error(d.object(value)));\n }\n });\n return {\n stepResults,\n stepErrors\n };\n}\nexport function CursorEntry(obj) {\n const type = d.string(obj[\"type\"]);\n if (type === \"step_begin\") {\n const step = d.number(obj[\"step\"]);\n const cols = d.arrayObjectsMap(obj[\"cols\"], Col);\n return {\n type: \"step_begin\",\n step,\n cols\n };\n } else if (type === \"step_end\") {\n const affectedRowCount = d.number(obj[\"affected_row_count\"]);\n const lastInsertRowidStr = d.stringOpt(obj[\"last_insert_rowid\"]);\n const lastInsertRowid = lastInsertRowidStr !== undefined ? BigInt(lastInsertRowidStr) : undefined;\n return {\n type: \"step_end\",\n affectedRowCount,\n lastInsertRowid\n };\n } else if (type === \"step_error\") {\n const step = d.number(obj[\"step\"]);\n const error = Error(d.object(obj[\"error\"]));\n return {\n type: \"step_error\",\n step,\n error\n };\n } else if (type === \"row\") {\n const row = d.arrayObjectsMap(obj[\"row\"], Value);\n return {\n type: \"row\",\n row\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 CursorEntry\");\n }\n}\nexport function DescribeResult(obj) {\n const params = d.arrayObjectsMap(obj[\"params\"], DescribeParam);\n const cols = d.arrayObjectsMap(obj[\"cols\"], DescribeCol);\n const isExplain = d.boolean(obj[\"is_explain\"]);\n const isReadonly = d.boolean(obj[\"is_readonly\"]);\n return {\n params,\n cols,\n isExplain,\n isReadonly\n };\n}\nfunction DescribeParam(obj) {\n const name = d.stringOpt(obj[\"name\"]);\n return {\n name\n };\n}\nfunction DescribeCol(obj) {\n const name = d.string(obj[\"name\"]);\n const decltype = d.stringOpt(obj[\"decltype\"]);\n return {\n name,\n decltype\n };\n}\nexport function Value(obj) {\n const type = d.string(obj[\"type\"]);\n if (type === \"null\") {\n return null;\n } else if (type === \"integer\") {\n const value = d.string(obj[\"value\"]);\n return BigInt(value);\n } else if (type === \"float\") {\n return d.number(obj[\"value\"]);\n } else if (type === \"text\") {\n return d.string(obj[\"value\"]);\n } else if (type === \"blob\") {\n return Base64.toUint8Array(d.string(obj[\"base64\"]));\n } else {\n throw new ProtoError(\"Unexpected type of Value\");\n }\n}","map":{"version":3,"names":["Base64","ProtoError","d","Error","obj","message","string","code","stringOpt","StmtResult","cols","arrayObjectsMap","Col","rows","array","map","rowObj","Value","affectedRowCount","number","lastInsertRowidStr","lastInsertRowid","undefined","BigInt","name","decltype","BatchResult","stepResults","Map","forEach","value","i","set","object","stepErrors","CursorEntry","type","step","error","row","DescribeResult","params","DescribeParam","DescribeCol","isExplain","boolean","isReadonly","toUint8Array"],"sources":["/Users/shoofle/Projects/the-forest/node_modules/@libsql/hrana-client/lib-esm/shared/json_decode.js"],"sourcesContent":["import { Base64 } from \"js-base64\";\nimport { ProtoError } from \"../errors.js\";\nimport * as d from \"../encoding/json/decode.js\";\nexport function Error(obj) {\n const message = d.string(obj[\"message\"]);\n const code = d.stringOpt(obj[\"code\"]);\n return { message, code };\n}\nexport function StmtResult(obj) {\n const cols = d.arrayObjectsMap(obj[\"cols\"], Col);\n const rows = d.array(obj[\"rows\"]).map((rowObj) => d.arrayObjectsMap(rowObj, Value));\n const affectedRowCount = d.number(obj[\"affected_row_count\"]);\n const lastInsertRowidStr = d.stringOpt(obj[\"last_insert_rowid\"]);\n const lastInsertRowid = lastInsertRowidStr !== undefined\n ? BigInt(lastInsertRowidStr) : undefined;\n return { cols, rows, affectedRowCount, lastInsertRowid };\n}\nfunction Col(obj) {\n const name = d.stringOpt(obj[\"name\"]);\n const decltype = d.stringOpt(obj[\"decltype\"]);\n return { name, decltype };\n}\nexport function BatchResult(obj) {\n const stepResults = new Map();\n d.array(obj[\"step_results\"]).forEach((value, i) => {\n if (value !== null) {\n stepResults.set(i, StmtResult(d.object(value)));\n }\n });\n const stepErrors = new Map();\n d.array(obj[\"step_errors\"]).forEach((value, i) => {\n if (value !== null) {\n stepErrors.set(i, Error(d.object(value)));\n }\n });\n return { stepResults, stepErrors };\n}\nexport function CursorEntry(obj) {\n const type = d.string(obj[\"type\"]);\n if (type === \"step_begin\") {\n const step = d.number(obj[\"step\"]);\n const cols = d.arrayObjectsMap(obj[\"cols\"], Col);\n return { type: \"step_begin\", step, cols };\n }\n else if (type === \"step_end\") {\n const affectedRowCount = d.number(obj[\"affected_row_count\"]);\n const lastInsertRowidStr = d.stringOpt(obj[\"last_insert_rowid\"]);\n const lastInsertRowid = lastInsertRowidStr !== undefined\n ? BigInt(lastInsertRowidStr) : undefined;\n return { type: \"step_end\", affectedRowCount, lastInsertRowid };\n }\n else if (type === \"step_error\") {\n const step = d.number(obj[\"step\"]);\n const error = Error(d.object(obj[\"error\"]));\n return { type: \"step_error\", step, error };\n }\n else if (type === \"row\") {\n const row = d.arrayObjectsMap(obj[\"row\"], Value);\n return { type: \"row\", row };\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 CursorEntry\");\n }\n}\nexport function DescribeResult(obj) {\n const params = d.arrayObjectsMap(obj[\"params\"], DescribeParam);\n const cols = d.arrayObjectsMap(obj[\"cols\"], DescribeCol);\n const isExplain = d.boolean(obj[\"is_explain\"]);\n const isReadonly = d.boolean(obj[\"is_readonly\"]);\n return { params, cols, isExplain, isReadonly };\n}\nfunction DescribeParam(obj) {\n const name = d.stringOpt(obj[\"name\"]);\n return { name };\n}\nfunction DescribeCol(obj) {\n const name = d.string(obj[\"name\"]);\n const decltype = d.stringOpt(obj[\"decltype\"]);\n return { name, decltype };\n}\nexport function Value(obj) {\n const type = d.string(obj[\"type\"]);\n if (type === \"null\") {\n return null;\n }\n else if (type === \"integer\") {\n const value = d.string(obj[\"value\"]);\n return BigInt(value);\n }\n else if (type === \"float\") {\n return d.number(obj[\"value\"]);\n }\n else if (type === \"text\") {\n return d.string(obj[\"value\"]);\n }\n else if (type === \"blob\") {\n return Base64.toUint8Array(d.string(obj[\"base64\"]));\n }\n else {\n throw new ProtoError(\"Unexpected type of Value\");\n }\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,WAAW;AAClC,SAASC,UAAU,QAAQ,cAAc;AACzC,OAAO,KAAKC,CAAC,MAAM,4BAA4B;AAC/C,OAAO,SAASC,KAAKA,CAACC,GAAG,EAAE;EACvB,MAAMC,OAAO,GAAGH,CAAC,CAACI,MAAM,CAACF,GAAG,CAAC,SAAS,CAAC,CAAC;EACxC,MAAMG,IAAI,GAAGL,CAAC,CAACM,SAAS,CAACJ,GAAG,CAAC,MAAM,CAAC,CAAC;EACrC,OAAO;IAA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