1 line
18 KiB
JSON
1 line
18 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.Value = exports.DescribeResult = exports.CursorEntry = exports.BatchResult = exports.StmtResult = exports.Error = void 0;\nconst js_base64_1 = require(\"js-base64\");\nconst errors_js_1 = require(\"../errors.js\");\nconst d = __importStar(require(\"../encoding/json/decode.js\"));\nfunction Error(obj) {\n const message = d.string(obj[\"message\"]);\n const code = d.stringOpt(obj[\"code\"]);\n return {\n message,\n code\n };\n}\nexports.Error = Error;\nfunction 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}\nexports.StmtResult = StmtResult;\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}\nfunction 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}\nexports.BatchResult = BatchResult;\nfunction 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 errors_js_1.ProtoError(\"Unexpected type of CursorEntry\");\n }\
|