{"ast":null,"code":"import { ProtoError, MisuseError } from \"./errors.js\";\nimport { stmtResultFromProto, rowsResultFromProto, rowResultFromProto, valueResultFromProto, errorFromProto } from \"./result.js\";\nimport { stmtToProto } from \"./stmt.js\";\nimport { impossible } from \"./util.js\";\n/** A builder for creating a batch and executing it on the server. */\nexport class Batch {\n /** @private */\n _stream;\n #useCursor;\n /** @private */\n _steps;\n #executed;\n /** @private */\n constructor(stream, useCursor) {\n this._stream = stream;\n this.#useCursor = useCursor;\n this._steps = [];\n this.#executed = false;\n }\n /** Return a builder for adding a step to the batch. */\n step() {\n return new BatchStep(this);\n }\n /** Execute the batch. */\n execute() {\n if (this.#executed) {\n throw new MisuseError(\"This batch has already been executed\");\n }\n this.#executed = true;\n const batch = {\n steps: this._steps.map(step => step.proto)\n };\n if (this.#useCursor) {\n return executeCursor(this._stream, this._steps, batch);\n } else {\n return executeRegular(this._stream, this._steps, batch);\n }\n }\n}\nfunction executeRegular(stream, steps, batch) {\n return stream._batch(batch).then(result => {\n for (let step = 0; step < steps.length; ++step) {\n const stepResult = result.stepResults.get(step);\n const stepError = result.stepErrors.get(step);\n steps[step].callback(stepResult, stepError);\n }\n });\n}\nasync function executeCursor(stream, steps, batch) {\n const cursor = await stream._openCursor(batch);\n try {\n let nextStep = 0;\n let beginEntry = undefined;\n let rows = [];\n for (;;) {\n const entry = await cursor.next();\n if (entry === undefined) {\n break;\n }\n if (entry.type === \"step_begin\") {\n if (entry.step < nextStep || entry.step >= steps.length) {\n throw new ProtoError(\"Server produced StepBeginEntry for unexpected step\");\n } else if (beginEntry !== undefined) {\n throw new ProtoError(\"Server produced StepBeginEntry before terminating previous step\");\n }\n for (let step = nextStep; step < entry.step; ++step) {\n steps[step].callback(undefined, undefined);\n }\n nextStep = entry.step + 1;\n beginEntry = entry;\n rows = [];\n } else if (entry.type === \"step_end\") {\n if (beginEntry === undefined) {\n throw new ProtoError(\"Server produced StepEndEntry but no step is active\");\n }\n const stmtResult = {\n cols: beginEntry.cols,\n rows,\n affectedRowCount: entry.affectedRowCount,\n lastInsertRowid: entry.lastInsertRowid\n };\n steps[beginEntry.step].callback(stmtResult, undefined);\n beginEntry = undefined;\n rows = [];\n } else if (entry.type === \"step_error\") {\n if (beginEntry === undefined) {\n if (entry.step >= steps.length) {\n throw new ProtoError(\"Server produced StepErrorEntry for unexpected step\");\n }\n for (let step = nextStep; step < entry.step; ++step) {\n steps[step].callback(undefined, undefined);\n }\n } else {\n if (entry.step !== beginEntry.step) {\n throw new ProtoError(\"Server produced StepErrorEntry for unexpected step\");\n }\n beginEntry = undefined;\n rows = [];\n }\n steps[entry.step].callback(undefined, entry.error);\n nextStep = entry.step + 1;\n } else if (entry.type === \"row\") {\n if (beginEntry === undefined) {\n throw new ProtoError(\"Server produced RowEntry but no step is active\");\n }\n rows.push(entry.row);\n } else if (entry.type === \"error\") {\n throw errorFromProto(entry.error);\n } else if (entry.type === \"none\") {\n throw new ProtoError(\"Server produced unrecognized CursorEntry\");\n } else {\n throw impossible(entry, \"Impossible CursorEntry\");\n }\n }\n if (beginEntry !== undefined) {\n throw new ProtoError(\"Server closed Cursor before terminating active step\");\n }\n for (let step = nextStep; step < steps.length; ++step) {\n steps[step].callback(undefined, undefined);\n }\n } finally {\n cursor.close();\n }\n}\n/** A builder for adding a step to the batch. */\nexport class BatchStep {\n /** @private */\n _batch;\n #conds;\n /** @private */\n _index;\n /** @private */\n constructor(batch) {\n this._batch = batch;\n this.#conds = [];\n this._index = undefined;\n }\n /** Add the condition that needs to be satisfied to execute the statement. If you use this method multiple\n * times, we join the conditions with a logical AND. */\n condition(cond) {\n this.#conds.push(cond._proto);\n return this;\n }\n /** Add a statement that returns rows. */\n query(stmt) {\n return this.#add(stmt, true, rowsResultFromProto);\n }\n /** Add a statement that returns at most a single row. */\n queryRow(stmt) {\n return this.#add(stmt, true, rowResultFromProto);\n }\n /** Add a statement that returns at most a single value. */\n queryValue(stmt) {\n return this.#add(stmt, true, valueResultFromProto);\n }\n /** Add a statement without returning rows. */\n run(stmt) {\n return this.#add(stmt, false, stmtResultFromProto);\n }\n #add(inStmt, wantRows, fromProto) {\n if (this._index !== undefined) {\n throw new MisuseError(\"This BatchStep has already been added to the batch\");\n }\n const stmt = stmtToProto(this._batch._stream._sqlOwner(), inStmt, wantRows);\n let condition;\n if (this.#conds.length === 0) {\n condition = undefined;\n } else if (this.#conds.length === 1) {\n condition = this.#conds[0];\n } else {\n condition = {\n type: \"and\",\n conds: this.#conds.slice()\n };\n }\n const proto = {\n stmt,\n condition\n };\n return new Promise((outputCallback, errorCallback) => {\n const callback = (stepResult, stepError) => {\n if (stepResult !== undefined && stepError !== undefined) {\n errorCallback(new ProtoError(\"Server returned both result and error\"));\n } else if (stepError !== undefined) {\n errorCallback(errorFromProto(stepError));\n } else if (stepResult !== undefined) {\n outputCallback(fromProto(stepResult, this._batch._stream.intMode));\n } else {\n outputCallback(undefined);\n }\n };\n this._index = this._batch._steps.length;\n this._batch._steps.push({\n proto,\n callback\n });\n });\n }\n}\nexport class BatchCond {\n /** @private */\n _batch;\n /** @private */\n _proto;\n /** @private */\n constructor(batch, proto) {\n this._batch = batch;\n this._proto = proto;\n }\n /** Create a condition that evaluates to true when the given step executes successfully.\n *\n * If the given step fails error or is skipped because its condition evaluated to false, this\n * condition evaluates to false.\n */\n static ok(step) {\n return new BatchCond(step._batch, {\n type: \"ok\",\n step: stepIndex(step)\n });\n }\n /** Create a condition that evaluates to true when the given step fails.\n *\n * If the given step succeeds or is skipped because its condition evaluated to false, this condition\n * evaluates to false.\n */\n static error(step) {\n return new BatchCond(step._batch, {\n type: \"error\",\n step: stepIndex(step)\n });\n }\n /** Create a condition that is a logical negation of another condition.\n */\n static not(cond) {\n return new BatchCond(cond._batch, {\n type: \"not\",\n cond: cond._proto\n });\n }\n /** Create a condition that is a logical AND of other conditions.\n */\n static and(batch, conds) {\n for (const cond of conds) {\n checkCondBatch(batch, cond);\n }\n return new BatchCond(batch, {\n type: \"and\",\n conds: conds.map(e => e._proto)\n });\n }\n /** Create a condition that is a logical OR of other conditions.\n */\n static or(batch, conds) {\n for (const cond of conds) {\n checkCondBatch(batch, cond);\n }\n return new BatchCond(batch, {\n type: \"or\",\n conds: conds.map(e => e._proto)\n });\n }\n /** Create a condition that evaluates to true when the SQL connection is in autocommit mode (not inside an\n * explicit transaction). This requires protocol version 3 or higher.\n */\n static isAutocommit(batch) {\n batch._stream.client()._ensureVersion(3, \"BatchCond.isAutocommit()\");\n return new BatchCond(batch, {\n type: \"is_autocommit\"\n });\n }\n}\nfunction stepIndex(step) {\n if (step._index === undefined) {\n throw new MisuseError(\"Cannot add a condition referencing a step that has not been added to the batch\");\n }\n return step._index;\n}\nfunction checkCondBatch(expectedBatch, cond) {\n if (cond._batch !== expectedBatch) {\n throw new MisuseError(\"Cannot mix BatchCond objects for different Batch objects\");\n }\n}","map":{"version":3,"names":["ProtoError","MisuseError","stmtResultFromProto","rowsResultFromProto","rowResultFromProto","valueResultFromProto","errorFromProto","stmtToProto","impossible","Batch","_stream","useCursor","_steps","executed","constructor","stream","step","BatchStep","execute","batch","steps","map","proto","executeCursor","executeRegular","_batch","then","result","length","stepResult","stepResults","get","stepError","stepErrors","callback","cursor","_openCursor","nextStep","beginEntry","undefined","rows","entry","next","type","stmtResult","cols","affectedRowCount","lastInsertRowid","error","push","row","close","conds","_index","condition","cond","_proto","query","stmt","add","queryRow","queryValue","run","#add","inStmt","wantRows","fromProto","_sqlOwner","slice","Promise","outputCallback","errorCallback","intMode","BatchCond","ok","stepIndex","not","and","checkCondBatch","e","or","isAutocommit","client","_ensureVersion","expectedBatch"],"sources":["/Users/shoofle/Projects/the-forest/node_modules/@libsql/hrana-client/lib-esm/batch.js"],"sourcesContent":["import { ProtoError, MisuseError } from \"./errors.js\";\nimport { stmtResultFromProto, rowsResultFromProto, rowResultFromProto, valueResultFromProto, errorFromProto, } from \"./result.js\";\nimport { stmtToProto } from \"./stmt.js\";\nimport { impossible } from \"./util.js\";\n/** A builder for creating a batch and executing it on the server. */\nexport class Batch {\n /** @private */\n _stream;\n #useCursor;\n /** @private */\n _steps;\n #executed;\n /** @private */\n constructor(stream, useCursor) {\n this._stream = stream;\n this.#useCursor = useCursor;\n this._steps = [];\n this.#executed = false;\n }\n /** Return a builder for adding a step to the batch. */\n step() {\n return new BatchStep(this);\n }\n /** Execute the batch. */\n execute() {\n if (this.#executed) {\n throw new MisuseError(\"This batch has already been executed\");\n }\n this.#executed = true;\n const batch = {\n steps: this._steps.map((step) => step.proto),\n };\n if (this.#useCursor) {\n return executeCursor(this._stream, this._steps, batch);\n }\n else {\n return executeRegular(this._stream, this._steps, batch);\n }\n }\n}\nfunction executeRegular(stream, steps, batch) {\n return stream._batch(batch).then((result) => {\n for (let step = 0; step < steps.length; ++step) {\n const stepResult = result.stepResults.get(step);\n const stepError = result.stepErrors.get(step);\n steps[step].callback(stepResult, stepError);\n }\n });\n}\nasync function executeCursor(stream, steps, batch) {\n const cursor = await stream._openCursor(batch);\n try {\n let nextStep = 0;\n let beginEntry = undefined;\n let rows = [];\n for (;;) {\n const entry = await cursor.next();\n if (entry === undefined) {\n break;\n }\n if (entry.type === \"step_begin\") {\n if (entry.step < nextStep || entry.step >= steps.length) {\n throw new ProtoError(\"Server produced StepBeginEntry for unexpected step\");\n }\n else if (beginEntry !== undefined) {\n throw new ProtoError(\"Server produced StepBeginEntry before terminating previous step\");\n }\n for (let step = nextStep; step < entry.step; ++step) {\n steps[step].callback(undefined, undefined);\n }\n nextStep = entry.step + 1;\n beginEntry = entry;\n rows = [];\n }\n else if (entry.type === \"step_end\") {\n if (beginEntry === undefined) {\n throw new ProtoError(\"Server produced StepEndEntry but no step is active\");\n }\n const stmtResult = {\n cols: beginEntry.cols,\n rows,\n affectedRowCount: entry.affectedRowCount,\n lastInsertRowid: entry.lastInsertRowid,\n };\n steps[beginEntry.step].callback(stmtResult, undefined);\n beginEntry = undefined;\n rows = [];\n }\n else if (entry.type === \"step_error\") {\n if (beginEntry === undefined) {\n if (entry.step >= steps.length) {\n throw new ProtoError(\"Server produced StepErrorEntry for unexpected step\");\n }\n for (let step = nextStep; step < entry.step; ++step) {\n steps[step].callback(undefined, undefined);\n }\n }\n else {\n if (entry.step !== beginEntry.step) {\n throw new ProtoError(\"Server produced StepErrorEntry for unexpected step\");\n }\n beginEntry = undefined;\n rows = [];\n }\n steps[entry.step].callback(undefined, entry.error);\n nextStep = entry.step + 1;\n }\n else if (entry.type === \"row\") {\n if (beginEntry === undefined) {\n throw new ProtoError(\"Server produced RowEntry but no step is active\");\n }\n rows.push(entry.row);\n }\n else if (entry.type === \"error\") {\n throw errorFromProto(entry.error);\n }\n else if (entry.type === \"none\") {\n throw new ProtoError(\"Server produced unrecognized CursorEntry\");\n }\n else {\n throw impossible(entry, \"Impossible CursorEntry\");\n }\n }\n if (beginEntry !== undefined) {\n throw new ProtoError(\"Server closed Cursor before terminating active step\");\n }\n for (let step = nextStep; step < steps.length; ++step) {\n steps[step].callback(undefined, undefined);\n }\n }\n finally {\n cursor.close();\n }\n}\n/** A builder for adding a step to the batch. */\nexport class BatchStep {\n /** @private */\n _batch;\n #conds;\n /** @private */\n _index;\n /** @private */\n constructor(batch) {\n this._batch = batch;\n this.#conds = [];\n this._index = undefined;\n }\n /** Add the condition that needs to be satisfied to execute the statement. If you use this method multiple\n * times, we join the conditions with a logical AND. */\n condition(cond) {\n this.#conds.push(cond._proto);\n return this;\n }\n /** Add a statement that returns rows. */\n query(stmt) {\n return this.#add(stmt, true, rowsResultFromProto);\n }\n /** Add a statement that returns at most a single row. */\n queryRow(stmt) {\n return this.#add(stmt, true, rowResultFromProto);\n }\n /** Add a statement that returns at most a single value. */\n queryValue(stmt) {\n return this.#add(stmt, true, valueResultFromProto);\n }\n /** Add a statement without returning rows. */\n run(stmt) {\n return this.#add(stmt, false, stmtResultFromProto);\n }\n #add(inStmt, wantRows, fromProto) {\n if (this._index !== undefined) {\n throw new MisuseError(\"This BatchStep has already been added to the batch\");\n }\n const stmt = stmtToProto(this._batch._stream._sqlOwner(), inStmt, wantRows);\n let condition;\n if (this.#conds.length === 0) {\n condition = undefined;\n }\n else if (this.#conds.length === 1) {\n condition = this.#conds[0];\n }\n else {\n condition = { type: \"and\", conds: this.#conds.slice() };\n }\n const proto = { stmt, condition };\n return new Promise((outputCallback, errorCallback) => {\n const callback = (stepResult, stepError) => {\n if (stepResult !== undefined && stepError !== undefined) {\n errorCallback(new ProtoError(\"Server returned both result and error\"));\n }\n else if (stepError !== undefined) {\n errorCallback(errorFromProto(stepError));\n }\n else if (stepResult !== undefined) {\n outputCallback(fromProto(stepResult, this._batch._stream.intMode));\n }\n else {\n outputCallback(undefined);\n }\n };\n this._index = this._batch._steps.length;\n this._batch._steps.push({ proto, callback });\n });\n }\n}\nexport class BatchCond {\n /** @private */\n _batch;\n /** @private */\n _proto;\n /** @private */\n constructor(batch, proto) {\n this._batch = batch;\n this._proto = proto;\n }\n /** Create a condition that evaluates to true when the given step executes successfully.\n *\n * If the given step fails error or is skipped because its condition evaluated to false, this\n * condition evaluates to false.\n */\n static ok(step) {\n return new BatchCond(step._batch, { type: \"ok\", step: stepIndex(step) });\n }\n /** Create a condition that evaluates to true when the given step fails.\n *\n * If the given step succeeds or is skipped because its condition evaluated to false, this condition\n * evaluates to false.\n */\n static error(step) {\n return new BatchCond(step._batch, { type: \"error\", step: stepIndex(step) });\n }\n /** Create a condition that is a logical negation of another condition.\n */\n static not(cond) {\n return new BatchCond(cond._batch, { type: \"not\", cond: cond._proto });\n }\n /** Create a condition that is a logical AND of other conditions.\n */\n static and(batch, conds) {\n for (const cond of conds) {\n checkCondBatch(batch, cond);\n }\n return new BatchCond(batch, { type: \"and\", conds: conds.map(e => e._proto) });\n }\n /** Create a condition that is a logical OR of other conditions.\n */\n static or(batch, conds) {\n for (const cond of conds) {\n checkCondBatch(batch, cond);\n }\n return new BatchCond(batch, { type: \"or\", conds: conds.map(e => e._proto) });\n }\n /** Create a condition that evaluates to true when the SQL connection is in autocommit mode (not inside an\n * explicit transaction). This requires protocol version 3 or higher.\n */\n static isAutocommit(batch) {\n batch._stream.client()._ensureVersion(3, \"BatchCond.isAutocommit()\");\n return new BatchCond(batch, { type: \"is_autocommit\" });\n }\n}\nfunction stepIndex(step) {\n if (step._index === undefined) {\n throw new MisuseError(\"Cannot add a condition referencing a step that has not been added to the batch\");\n }\n return step._index;\n}\nfunction checkCondBatch(expectedBatch, cond) {\n if (cond._batch !== expectedBatch) {\n throw new MisuseError(\"Cannot mix BatchCond objects for different Batch objects\");\n }\n}\n"],"mappings":"AAAA,SAASA,UAAU,EAAEC,WAAW,QAAQ,aAAa;AACrD,SAASC,mBAAmB,EAAEC,mBAAmB,EAAEC,kBAAkB,EAAEC,oBAAoB,EAAEC,cAAc,QAAS,aAAa;AACjI,SAASC,WAAW,QAAQ,WAAW;AACvC,SAASC,UAAU,QAAQ,WAAW;AACtC;AACA,OAAO,MAAMC,KAAK,CAAC;EACf;EACAC,OAAO;EACP,CAACC,SAAS;EACV;EACAC,MAAM;EACN,CAACC,QAAQ;EACT;EACAC,WAAWA,CAACC,MAAM,EAAEJ,SAAS,EAAE;IAC3B,IAAI,CAACD,OAAO,GAAGK,MAAM;IACrB,IAAI,CAAC,CAACJ,SAAS,GAAGA,SAAS;IAC3B,IAAI,CAACC,MAAM,GAAG,EAAE;IAChB,IAAI,CAAC,CAACC,QAAQ,GAAG,KAAK;EAC1B;EACA;EACAG,IAAIA,CAAA,EAAG;IACH,OAAO,IAAIC,SAAS,CAAC,IAAI,CAAC;EAC9B;EACA;EACAC,OAAOA,CAAA,EAAG;IACN,IAAI,IAAI,CAAC,CAACL,QAAQ,EAAE;MAChB,MAAM,IAAIZ,WAAW,CAAC,sCAAsC,CAAC;IACjE;IACA,IAAI,CAAC,CAACY,QAAQ,GAAG,IAAI;IACrB,MAAMM,KAAK,GAAG;MACVC,KAAK,EAAE,IAAI,CAACR,MAAM,CAACS,GAAG,CAAEL,IAAI,IAAKA,IAAI,CAACM,KAAK;IAC/C,CAAC;IACD,IAAI,IAAI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