{"ast":null,"code":"\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.Stream = void 0;\nconst batch_js_1 = require(\"./batch.js\");\nconst describe_js_1 = require(\"./describe.js\");\nconst result_js_1 = require(\"./result.js\");\nconst sql_js_1 = require(\"./sql.js\");\nconst stmt_js_1 = require(\"./stmt.js\");\n/** A stream for executing SQL statements (a \"database connection\"). */\nclass Stream {\n /** @private */\n constructor(intMode) {\n this.intMode = intMode;\n }\n /** Execute a statement and return rows. */\n query(stmt) {\n return this.#execute(stmt, true, result_js_1.rowsResultFromProto);\n }\n /** Execute a statement and return at most a single row. */\n queryRow(stmt) {\n return this.#execute(stmt, true, result_js_1.rowResultFromProto);\n }\n /** Execute a statement and return at most a single value. */\n queryValue(stmt) {\n return this.#execute(stmt, true, result_js_1.valueResultFromProto);\n }\n /** Execute a statement without returning rows. */\n run(stmt) {\n return this.#execute(stmt, false, result_js_1.stmtResultFromProto);\n }\n #execute(inStmt, wantRows, fromProto) {\n const stmt = (0, stmt_js_1.stmtToProto)(this._sqlOwner(), inStmt, wantRows);\n return this._execute(stmt).then(r => fromProto(r, this.intMode));\n }\n /** Return a builder for creating and executing a batch.\n *\n * If `useCursor` is true, the batch will be executed using a Hrana cursor, which will stream results from\n * the server to the client, which consumes less memory on the server. This requires protocol version 3 or\n * higher.\n */\n batch(useCursor = false) {\n return new batch_js_1.Batch(this, useCursor);\n }\n /** Parse and analyze a statement. This requires protocol version 2 or higher. */\n describe(inSql) {\n const protoSql = (0, sql_js_1.sqlToProto)(this._sqlOwner(), inSql);\n return this._describe(protoSql).then(describe_js_1.describeResultFromProto);\n }\n /** Execute a sequence of statements separated by semicolons. This requires protocol version 2 or higher.\n * */\n sequence(inSql) {\n const protoSql = (0, sql_js_1.sqlToProto)(this._sqlOwner(), inSql);\n return this._sequence(protoSql);\n }\n /** Representation of integers returned from the database. See {@link IntMode}.\n *\n * This value affects the results of all operations on this stream.\n */\n intMode;\n}\nexports.Stream = Stream;","map":{"version":3,"names":["Object","defineProperty","exports","value","Stream","batch_js_1","require","describe_js_1","result_js_1","sql_js_1","stmt_js_1","constructor","intMode","query","stmt","execute","rowsResultFromProto","queryRow","rowResultFromProto","queryValue","valueResultFromProto","run","stmtResultFromProto","#execute","inStmt","wantRows","fromProto","stmtToProto","_sqlOwner","_execute","then","r","batch","useCursor","Batch","describe","inSql","protoSql","sqlToProto","_describe","describeResultFromProto","sequence","_sequence"],"sources":["/Users/shoofle/Projects/the-forest/node_modules/@libsql/hrana-client/lib-cjs/stream.js"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Stream = void 0;\nconst batch_js_1 = require(\"./batch.js\");\nconst describe_js_1 = require(\"./describe.js\");\nconst result_js_1 = require(\"./result.js\");\nconst sql_js_1 = require(\"./sql.js\");\nconst stmt_js_1 = require(\"./stmt.js\");\n/** A stream for executing SQL statements (a \"database connection\"). */\nclass Stream {\n /** @private */\n constructor(intMode) {\n this.intMode = intMode;\n }\n /** Execute a statement and return rows. */\n query(stmt) {\n return this.#execute(stmt, true, result_js_1.rowsResultFromProto);\n }\n /** Execute a statement and return at most a single row. */\n queryRow(stmt) {\n return this.#execute(stmt, true, result_js_1.rowResultFromProto);\n }\n /** Execute a statement and return at most a single value. */\n queryValue(stmt) {\n return this.#execute(stmt, true, result_js_1.valueResultFromProto);\n }\n /** Execute a statement without returning rows. */\n run(stmt) {\n return this.#execute(stmt, false, result_js_1.stmtResultFromProto);\n }\n #execute(inStmt, wantRows, fromProto) {\n const stmt = (0, stmt_js_1.stmtToProto)(this._sqlOwner(), inStmt, wantRows);\n return this._execute(stmt).then((r) => fromProto(r, this.intMode));\n }\n /** Return a builder for creating and executing a batch.\n *\n * If `useCursor` is true, the batch will be executed using a Hrana cursor, which will stream results from\n * the server to the client, which consumes less memory on the server. This requires protocol version 3 or\n * higher.\n */\n batch(useCursor = false) {\n return new batch_js_1.Batch(this, useCursor);\n }\n /** Parse and analyze a statement. This requires protocol version 2 or higher. */\n describe(inSql) {\n const protoSql = (0, sql_js_1.sqlToProto)(this._sqlOwner(), inSql);\n return this._describe(protoSql).then(describe_js_1.describeResultFromProto);\n }\n /** Execute a sequence of statements separated by semicolons. This requires protocol version 2 or higher.\n * */\n sequence(inSql) {\n const protoSql = (0, sql_js_1.sqlToProto)(this._sqlOwner(), inSql);\n return this._sequence(protoSql);\n }\n /** Representation of integers returned from the database. See {@link IntMode}.\n *\n * This value affects the results of all operations on this stream.\n */\n intMode;\n}\nexports.Stream = Stream;\n"],"mappings":"AAAA,YAAY;;AACZA,MAAM,CAACC,cAAc,CAACC,OAAO,EAAE,YAAY,EAAE;EAAEC,KAAK,EAAE;AAAK,CAAC,CAAC;AAC7DD,OAAO,CAACE,MAAM,GAAG,KAAK,CAAC;AACvB,MAAMC,UAAU,GAAGC,OAAO,CAAC,YAAY,CAAC;AACxC,MAAMC,aAAa,GAAGD,OAAO,CAAC,eAAe,CAAC;AAC9C,MAAME,WAAW,GAAGF,OAAO,CAAC,aAAa,CAAC;AAC1C,MAAMG,QAAQ,GAAGH,OAAO,CAAC,UAAU,CAAC;AACpC,MAAMI,SAAS,GAAGJ,OAAO,CAAC,WAAW,CAAC;AACtC;AACA,MAAMF,MAAM,CAAC;EACT;EACAO,WAAWA,CAACC,OAAO,EAAE;IACjB,IAAI,CAACA,OAAO,GAAGA,OAAO;EAC1B;EACA;EACAC,KAAKA,CAACC,IAAI,EAAE;IACR,OAAO,IAAI,CAAC,CAACC,OAAO,CAACD,IAAI,EAAE,IAAI,EAAEN,WAAW,CAACQ,mBAAmB,CAAC;EACrE;EACA;EACAC,QAAQA,CAACH,IAAI,EAAE;IACX,OAAO,IAAI,CAAC,CAACC,OAAO,CAACD,IAAI,EAAE,IAAI,EAAEN,WAAW,CAACU,kBAAkB,CAAC;EACpE;EACA;EACAC,UAAUA,CAACL,IAAI,EAAE;IACb,OAAO,IAAI,CAAC,CAACC,OAAO,CAACD,IAAI,EAAE,IAAI,EAAEN,W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