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

1 line
7.2 KiB
JSON

{"ast":null,"code":"import { Base64 } from \"js-base64\";\nimport { impossible } from \"../util.js\";\nexport function 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}\nfunction NamedArg(w, msg) {\n w.string(\"name\", msg.name);\n w.object(\"value\", msg.value, Value);\n}\nexport function Batch(w, msg) {\n w.arrayObjects(\"steps\", msg.steps, BatchStep);\n}\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 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\", Base64.fromUint8Array(msg));\n } else if (msg === undefined) {\n // do nothing\n } else {\n throw impossible(msg, \"Impossible type of Value\");\n }\n}","map":{"version":3,"names":["Base64","impossible","Stmt","w","msg","sql","undefined","string","sqlId","number","arrayObjects","args","Value","namedArgs","NamedArg","boolean","wantRows","name","object","value","Batch","steps","BatchStep","condition","BatchCond","stmt","stringRaw","type","step","cond","conds","Uint8Array","fromUint8Array"],"sources":["/Users/shoofle/Projects/the-forest/node_modules/@libsql/hrana-client/lib-esm/shared/json_encode.js"],"sourcesContent":["import { Base64 } from \"js-base64\";\nimport { impossible } from \"../util.js\";\nexport function 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}\nfunction NamedArg(w, msg) {\n w.string(\"name\", msg.name);\n w.object(\"value\", msg.value, Value);\n}\nexport function Batch(w, msg) {\n w.arrayObjects(\"steps\", msg.steps, BatchStep);\n}\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 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\", Base64.fromUint8Array(msg));\n }\n else if (msg === undefined) {\n // do nothing\n }\n else {\n throw impossible(msg, \"Impossible type of Value\");\n }\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,WAAW;AAClC,SAASC,UAAU,QAAQ,YAAY;AACvC,OAAO,SAASC,IAAIA,CAACC,CAAC,EAAEC,GAAG,EAAE;EACzB,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,CAAC;EACvCT,CAAC,CAACO,YAAY,CAAC,YAAY,EAAEN,GAAG,CAACS,SAAS,EAAEC,QAAQ,CAAC;EACrDX,CAAC,CAACY,OAAO,CAAC,WAAW,EAAEX,GAAG,CAACY,QAAQ,CAAC;AACxC;AACA,SAASF,QAAQA,CAACX,CAAC,EAAEC,GAAG,EAAE;EACtBD,CAAC,CAACI,MAAM,CAAC,MAAM,EAAEH,GAAG,CAACa,IAAI,CAAC;EAC1Bd,CAAC,CAACe,MAAM,CAAC,OAAO,EAAEd,GAAG,CAACe,KAAK,EAAEP,KAAK,CAAC;AACvC;AACA,OAAO,SAASQ,KAAKA,CAACjB,CAAC,EAAEC,GAAG,EAAE;EAC1BD,CAAC,CAACO,YAA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