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(\"conds\", msg.conds, BatchCond);\n }\n else if (msg.type === \"is_autocommit\") {\n // do nothing\n }\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 }\n else if (typeof msg === \"bigint\") {\n w.stringRaw(\"type\", \"integer\");\n w.stringRaw(\"value\", \"\" + msg);\n }\n else if (typeof msg === \"number\") {\n w.stringRaw(\"type\", \"float\");\n w.number(\"value\", msg);\n }\n else if (typeof msg === \"string\") {\n w.stringRaw(\"type\", \"text\");\n w.string(\"value\", msg);\n }\n else if (msg instanceof Uint8Array) {\n w.stringRaw(\"type\", \"blob\");\n w.stringRaw(\"base64\", js_base64_1.Base64.fromUint8Array(msg));\n }\n else if (msg === undefined) {\n // do nothing\n }\n else {\n throw (0, util_js_1.impossible)(msg, \"Impossible type of Value\");\n }\n}\n"],"mappings":"AAAA,YAAY;;AACZA,MAAM,CAACC,cAAc,CAACC,OAAO,EAAE,YAAY,EAAE;EAAEC,KAAK,EAAE;AAAK,CAAC,CAAC;AAC7DD,OAAO,CAACE,KAAK,GAAGF,OAAO,CAACG,IAAI,GAAG,KAAK,CAAC;AACrC,MAAMC,WAAW,GAAGC,OAAO,CAAC,WAAW,CAAC;AACxC,MAAMC,SAAS,GAAGD,OAAO,CAAC,YAAY,CAAC;AACvC,SAASF,IAAIA,CAACI,CAAC,EAAEC,GAAG,EAAE;EAClB,IAAIA,GAAG,CAACC,GAAG,KAAKC,SAAS,EAAE;IACvBH,CAAC,CAACI,MAAM,CAAC,KAAK,EAAEH,GAAG,CAACC,GAAG,CAAC;EAC5B;EACA,IAAID,GAAG,CAACI,KAAK,KAAKF,SAAS,EAAE;IACzBH,CAAC,CAACM,MAAM,CAAC,QAAQ,EAAEL,GAAG,CAACI,KAAK,CAAC;EACjC;EACAL,CAAC,CAACO,YAAY,CAAC,MAAM,EAAEN,GAAG,CAACO,IAAI,EAAEC,KAAK,CAA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