1 line
8.0 KiB
JSON
1 line
8.0 KiB
JSON
|
{"ast":null,"code":"\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.Batch = exports.Stmt = void 0;\nconst js_base64_1 = require(\"js-base64\");\nconst util_js_1 = require(\"../util.js\");\nfunction Stmt(w, msg) {\n if (msg.sql !== undefined) {\n w.string(\"sql\", msg.sql);\n }\n if (msg.sqlId !== undefined) {\n w.number(\"sql_id\", msg.sqlId);\n }\n w.arrayObjects(\"args\", msg.args, Value);\n w.arrayObjects(\"named_args\", msg.namedArgs, NamedArg);\n w.boolean(\"want_rows\", msg.wantRows);\n}\nexports.Stmt = Stmt;\nfunction NamedArg(w, msg) {\n w.string(\"name\", msg.name);\n w.object(\"value\", msg.value, Value);\n}\nfunction Batch(w, msg) {\n w.arrayObjects(\"steps\", msg.steps, BatchStep);\n}\nexports.Batch = Batch;\nfunction BatchStep(w, msg) {\n if (msg.condition !== undefined) {\n w.object(\"condition\", msg.condition, BatchCond);\n }\n w.object(\"stmt\", msg.stmt, Stmt);\n}\nfunction BatchCond(w, msg) {\n w.stringRaw(\"type\", msg.type);\n if (msg.type === \"ok\" || msg.type === \"error\") {\n w.number(\"step\", msg.step);\n } else if (msg.type === \"not\") {\n w.object(\"cond\", msg.cond, BatchCond);\n } else if (msg.type === \"and\" || msg.type === \"or\") {\n w.arrayObjects(\"conds\", msg.conds, BatchCond);\n } else if (msg.type === \"is_autocommit\") {\n // do nothing\n } else {\n throw (0, util_js_1.impossible)(msg, \"Impossible type of BatchCond\");\n }\n}\nfunction Value(w, msg) {\n if (msg === null) {\n w.stringRaw(\"type\", \"null\");\n } else if (typeof msg === \"bigint\") {\n w.stringRaw(\"type\", \"integer\");\n w.stringRaw(\"value\", \"\" + msg);\n } else if (typeof msg === \"number\") {\n w.stringRaw(\"type\", \"float\");\n w.number(\"value\", msg);\n } else if (typeof msg === \"string\") {\n w.stringRaw(\"type\", \"text\");\n w.string(\"value\", msg);\n } else if (msg instanceof Uint8Array) {\n w.stringRaw(\"type\", \"blob\");\n w.stringRaw(\"base64\", js_base64_1.Base64.fromUint8Array(msg));\n } else if (msg === undefined) {\n // do nothing\n } else {\n throw (0, util_js_1.impossible)(msg, \"Impossible type of Value\");\n }\n}","map":{"version":3,"names":["Object","defineProperty","exports","value","Batch","Stmt","js_base64_1","require","util_js_1","w","msg","sql","undefined","string","sqlId","number","arrayObjects","args","Value","namedArgs","NamedArg","boolean","wantRows","name","object","steps","BatchStep","condition","BatchCond","stmt","stringRaw","type","step","cond","conds","impossible","Uint8Array","Base64","fromUint8Array"],"sources":["/Users/shoofle/Projects/the-forest/node_modules/@libsql/hrana-client/lib-cjs/shared/json_encode.js"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Batch = exports.Stmt = void 0;\nconst js_base64_1 = require(\"js-base64\");\nconst util_js_1 = require(\"../util.js\");\nfunction Stmt(w, msg) {\n if (msg.sql !== undefined) {\n w.string(\"sql\", msg.sql);\n }\n if (msg.sqlId !== undefined) {\n w.number(\"sql_id\", msg.sqlId);\n }\n w.arrayObjects(\"args\", msg.args, Value);\n w.arrayObjects(\"named_args\", msg.namedArgs, NamedArg);\n w.boolean(\"want_rows\", msg.wantRows);\n}\nexports.Stmt = Stmt;\nfunction NamedArg(w, msg) {\n w.string(\"name\", msg.name);\n w.object(\"value\", msg.value, Value);\n}\nfunction Batch(w, msg) {\n w.arrayObjects(\"steps\", msg.steps, BatchStep);\n}\nexports.Batch = Batch;\nfunction BatchStep(w, msg) {\n if (msg.condition !== undefined) {\n w.object(\"condition\", msg.condition, BatchCond);\n }\n w.object(\"stmt\", msg.stmt, Stmt);\n}\nfunction BatchCond(w, msg) {\n w.stringRaw(\"type\", msg.type);\n if (msg.type === \"ok\" || msg.type === \"error\") {\n w.number(\"step\", msg.step);\n }\n else if (msg.type === \"not\") {\n w.object(\"cond\", msg.cond, BatchCond);\n }\n else if (msg.type === \"and\" || msg.type === \"or\") {\n w.arrayObjects
|