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

1 line
32 KiB
JSON

{"ast":null,"code":"import * as hrana from \"@libsql/hrana-client\";\nimport { LibsqlError } from \"@libsql/core/api\";\nimport { transactionModeToBegin, ResultSetImpl } from \"@libsql/core/util\";\nexport class HranaTransaction {\n #mode;\n #version;\n // Promise that is resolved when the BEGIN statement completes, or `undefined` if we haven't executed the\n // BEGIN statement yet.\n #started;\n /** @private */\n constructor(mode, version) {\n this.#mode = mode;\n this.#version = version;\n this.#started = undefined;\n }\n execute(stmt) {\n return this.batch([stmt]).then(results => results[0]);\n }\n async batch(stmts) {\n const stream = this._getStream();\n if (stream.closed) {\n throw new LibsqlError(\"Cannot execute statements because the transaction is closed\", \"TRANSACTION_CLOSED\");\n }\n try {\n const hranaStmts = stmts.map(stmtToHrana);\n let rowsPromises;\n if (this.#started === undefined) {\n // The transaction hasn't started yet, so we need to send the BEGIN statement in a batch with\n // `hranaStmts`.\n this._getSqlCache().apply(hranaStmts);\n const batch = stream.batch(this.#version >= 3);\n const beginStep = batch.step();\n const beginPromise = beginStep.run(transactionModeToBegin(this.#mode));\n // Execute the `hranaStmts` only if the BEGIN succeeded, to make sure that we don't execute it\n // outside of a transaction.\n let lastStep = beginStep;\n rowsPromises = hranaStmts.map(hranaStmt => {\n const stmtStep = batch.step().condition(hrana.BatchCond.ok(lastStep));\n if (this.#version >= 3) {\n // If the Hrana version supports it, make sure that we are still in a transaction\n stmtStep.condition(hrana.BatchCond.not(hrana.BatchCond.isAutocommit(batch)));\n }\n const rowsPromise = stmtStep.query(hranaStmt);\n rowsPromise.catch(() => undefined); // silence Node warning\n lastStep = stmtStep;\n return rowsPromise;\n });\n // `this.#started` is resolved successfully only if the batch and the BEGIN statement inside\n // of the batch are both successful.\n this.#started = batch.execute().then(() => beginPromise).then(() => undefined);\n try {\n await this.#started;\n } catch (e) {\n // If the BEGIN failed, the transaction is unusable and we must close it. However, if the\n // BEGIN suceeds and `hranaStmts` fail, the transaction is _not_ closed.\n this.close();\n throw e;\n }\n } else {\n if (this.#version < 3) {\n // The transaction has started, so we must wait until the BEGIN statement completed to make\n // sure that we don't execute `hranaStmts` outside of a transaction.\n await this.#started;\n } else {\n // The transaction has started, but we will use `hrana.BatchCond.isAutocommit()` to make\n // sure that we don't execute `hranaStmts` outside of a transaction, so we don't have to\n // wait for `this.#started`\n }\n this._getSqlCache().apply(hranaStmts);\n const batch = stream.batch(this.#version >= 3);\n let lastStep = undefined;\n rowsPromises = hranaStmts.map(hranaStmt => {\n const stmtStep = batch.step();\n if (lastStep !== undefined) {\n stmtStep.condition(hrana.BatchCond.ok(lastStep));\n }\n if (this.#version >= 3) {\n stmtStep.condition(hrana.BatchCond.not(hrana.BatchCond.isAutocommit(batch)));\n }\n const rowsPromise = stmtStep.query(hranaStmt);\n rowsPromise.catch(() => undefined); // silence Node warning\n lastStep = stmtStep;\n return rowsPromise;\n });\n await batch.execute();\n }\n const resultSets = [];\n for (const rowsPromise of rowsPromises) {\n const rows = await rowsPromise;\n if (rows === undefined) {\n throw new LibsqlError(\"Statement in a transaction was not executed, \" + \"probably because the transaction has been rolled back\", \"TRANSACTION_CLOSED\");\n }\n resultSets.push(resultSetFromHrana(rows));\n }\n return resultSets;\n } catch (e) {\n throw mapHranaError(e);\n }\n }\n async executeMultiple(sql) {\n const stream = this._getStream();\n if (stream.closed) {\n throw new LibsqlError(\"Cannot execute statements because the transaction is closed\", \"TRANSACTION_CLOSED\");\n }\n try {\n if (this.#started === undefined) {\n // If the transaction hasn't started yet, start it now\n this.#started = stream.run(transactionModeToBegin(this.#mode)).then(() => undefined);\n try {\n await this.#started;\n } catch (e) {\n this.close();\n throw e;\n }\n } else {\n // Wait until the transaction has started\n await this.#started;\n }\n await stream.sequence(sql);\n } catch (e) {\n throw mapHranaError(e);\n }\n }\n async rollback() {\n try {\n const stream = this._getStream();\n if (stream.closed) {\n return;\n }\n if (this.#started !== undefined) {\n // We don't have to wait for the BEGIN statement to complete. If the BEGIN fails, we will\n // execute a ROLLBACK outside of an active transaction, which should be harmless.\n } else {\n // We did nothing in the transaction, so there is nothing to rollback.\n return;\n }\n // Pipeline the ROLLBACK statement and the stream close.\n const promise = stream.run(\"ROLLBACK\").catch(e => {\n throw mapHranaError(e);\n });\n stream.closeGracefully();\n await promise;\n } catch (e) {\n throw mapHranaError(e);\n } finally {\n // `this.close()` may close the `hrana.Client`, which aborts all pending stream requests, so we\n // must call it _after_ we receive the ROLLBACK response.\n // Also note that the current stream should already be closed, but we need to call `this.close()`\n // anyway, because it may need to do more cleanup.\n this.close();\n }\n }\n async commit() {\n // (this method is analogous to `rollback()`)\n try {\n const stream = this._getStream();\n if (stream.closed) {\n throw new LibsqlError(\"Cannot commit the transaction because it is already closed\", \"TRANSACTION_CLOSED\");\n }\n if (this.#started !== undefined) {\n // Make sure to execute the COMMIT only if the BEGIN was successful.\n await this.#started;\n } else {\n return;\n }\n const promise = stream.run(\"COMMIT\").catch(e => {\n throw mapHranaError(e);\n });\n stream.closeGracefully();\n await promise;\n } catch (e) {\n throw mapHranaError(e);\n } finally {\n this.close();\n }\n }\n}\nexport async function executeHranaBatch(mode, version, batch, hranaStmts, disableForeignKeys = false) {\n if (disableForeignKeys) {\n batch.step().run(\"PRAGMA foreign_keys=off\");\n }\n const beginStep = batch.step();\n const beginPromise = beginStep.run(transactionModeToBegin(mode));\n let lastStep = beginStep;\n const stmtPromises = hranaStmts.map(hranaStmt => {\n const stmtStep = batch.step().condition(hrana.BatchCond.ok(lastStep));\n if (version >= 3) {\n stmtStep.condition(hrana.BatchCond.not(hrana.BatchCond.isAutocommit(batch)));\n }\n const stmtPromise = stmtStep.query(hranaStmt);\n lastStep = stmtStep;\n return stmtPromise;\n });\n const commitStep = batch.step().condition(hrana.BatchCond.ok(lastStep));\n if (version >= 3) {\n commitStep.condition(hrana.BatchCond.not(hrana.BatchCond.isAutocommit(batch)));\n }\n const commitPromise = commitStep.run(\"COMMIT\");\n const rollbackStep = batch.step().condition(hrana.BatchCond.not(hrana.BatchCond.ok(commitStep)));\n rollbackStep.run(\"ROLLBACK\").catch(_ => undefined);\n if (disableForeignKeys) {\n batch.step().run(\"PRAGMA foreign_keys=on\");\n }\n await batch.execute();\n const resultSets = [];\n await beginPromise;\n for (const stmtPromise of stmtPromises) {\n const hranaRows = await stmtPromise;\n if (hranaRows === undefined) {\n throw new LibsqlError(\"Statement in a batch was not executed, probably because the transaction has been rolled back\", \"TRANSACTION_CLOSED\");\n }\n resultSets.push(resultSetFromHrana(hranaRows));\n }\n await commitPromise;\n return resultSets;\n}\nexport function stmtToHrana(stmt) {\n if (typeof stmt === \"string\") {\n return new hrana.Stmt(stmt);\n }\n const hranaStmt = new hrana.Stmt(stmt.sql);\n if (Array.isArray(stmt.args)) {\n hranaStmt.bindIndexes(stmt.args);\n } else {\n for (const [key, value] of Object.entries(stmt.args)) {\n hranaStmt.bindName(key, value);\n }\n }\n return hranaStmt;\n}\nexport function resultSetFromHrana(hranaRows) {\n const columns = hranaRows.columnNames.map(c => c ?? \"\");\n const columnTypes = hranaRows.columnDecltypes.map(c => c ?? \"\");\n const rows = hranaRows.rows;\n const rowsAffected = hranaRows.affectedRowCount;\n const lastInsertRowid = hranaRows.lastInsertRowid !== undefined ? hranaRows.lastInsertRowid : undefined;\n return new ResultSetImpl(columns, columnTypes, rows, rowsAffected, lastInsertRowid);\n}\nexport function mapHranaError(e) {\n if (e instanceof hrana.ClientError) {\n const code = mapHranaErrorCode(e);\n return new LibsqlError(e.message, code, undefined, e);\n }\n return e;\n}\nfunction mapHranaErrorCode(e) {\n if (e instanceof hrana.ResponseError && e.code !== undefined) {\n return e.code;\n } else if (e instanceof hrana.ProtoError) {\n return \"HRANA_PROTO_ERROR\";\n } else if (e instanceof hrana.ClosedError) {\n return e.cause instanceof hrana.ClientError ? mapHranaErrorCode(e.cause) : \"HRANA_CLOSED_ERROR\";\n } else if (e instanceof hrana.WebSocketError) {\n return \"HRANA_WEBSOCKET_ERROR\";\n } else if (e instanceof hrana.HttpServerError) {\n return \"SERVER_ERROR\";\n } else if (e instanceof hrana.ProtocolVersionError) {\n return \"PROTOCOL_VERSION_ERROR\";\n } else if (e instanceof hrana.InternalError) {\n return \"INTERNAL_ERROR\";\n } else {\n return \"UNKNOWN\";\n }\n}","map":{"version":3,"names":["hrana","LibsqlError","transactionModeToBegin","ResultSetImpl","HranaTransaction","mode","version","started","constructor","undefined","execute","stmt","batch","then","results","stmts","stream","_getStream","closed","hranaStmts","map","stmtToHrana","rowsPromises","_getSqlCache","apply","beginStep","step","beginPromise","run","lastStep","hranaStmt","stmtStep","condition","BatchCond","ok","not","isAutocommit","rowsPromise","query","catch","e","close","resultSets","rows","push","resultSetFromHrana","mapHranaError","executeMultiple","sql","sequence","rollback","promise","closeGracefully","commit","executeHranaBatch","disableForeignKeys","stmtPromises","stmtPromise","commitStep","commitPromise","rollbackStep","_","hranaRows","Stmt","Array","isArray","args","bindIndexes","key","value","Object","entries","bindName","columns","columnNames","c","columnTypes","columnDecltypes","rowsAffected","affectedRowCount","lastInsertRowid","ClientError","code","mapHranaErrorCode","message","ResponseError","ProtoError","ClosedError","cause","WebSocketError","HttpServerError","ProtocolVersionError","InternalError"],"sources":["/Users/shoofle/Projects/the-forest/node_modules/@libsql/client/lib-esm/hrana.js"],"sourcesContent":["import * as hrana from \"@libsql/hrana-client\";\nimport { LibsqlError } from \"@libsql/core/api\";\nimport { transactionModeToBegin, ResultSetImpl } from \"@libsql/core/util\";\nexport class HranaTransaction {\n #mode;\n #version;\n // Promise that is resolved when the BEGIN statement completes, or `undefined` if we haven't executed the\n // BEGIN statement yet.\n #started;\n /** @private */\n constructor(mode, version) {\n this.#mode = mode;\n this.#version = version;\n this.#started = undefined;\n }\n execute(stmt) {\n return this.batch([stmt]).then((results) => results[0]);\n }\n async batch(stmts) {\n const stream = this._getStream();\n if (stream.closed) {\n throw new LibsqlError(\"Cannot execute statements because the transaction is closed\", \"TRANSACTION_CLOSED\");\n }\n try {\n const hranaStmts = stmts.map(stmtToHrana);\n let rowsPromises;\n if (this.#started === undefined) {\n // The transaction hasn't started yet, so we need to send the BEGIN statement in a batch with\n // `hranaStmts`.\n this._getSqlCache().apply(hranaStmts);\n const batch = stream.batch(this.#version >= 3);\n const beginStep = batch.step();\n const beginPromise = beginStep.run(transactionModeToBegin(this.#mode));\n // Execute the `hranaStmts` only if the BEGIN succeeded, to make sure that we don't execute it\n // outside of a transaction.\n let lastStep = beginStep;\n rowsPromises = hranaStmts.map((hranaStmt) => {\n const stmtStep = batch\n .step()\n .condition(hrana.BatchCond.ok(lastStep));\n if (this.#version >= 3) {\n // If the Hrana version supports it, make sure that we are still in a transaction\n stmtStep.condition(hrana.BatchCond.not(hrana.BatchCond.isAutocommit(batch)));\n }\n const rowsPromise = stmtStep.query(hranaStmt);\n rowsPromise.catch(() => undefined); // silence Node warning\n lastStep = stmtStep;\n return rowsPromise;\n });\n // `this.#started` is resolved successfully only if the batch and the BEGIN statement inside\n // of the batch are both successful.\n this.#started = batch\n .execute()\n .then(() => beginPromise)\n .then(() => undefined);\n try {\n await this.#started;\n }\n catch (e) {\n // If the BEGIN failed, the transaction is unusable and we must close it. However, if the\n // BEGIN suceeds and `hranaStmts` fail, the transaction is _not_ closed.\n this.close();\n throw e;\n }\n }\n else {\n if (this.#version < 3) {\n // The transaction has started, so we must wait until the BEGIN statement completed to make\n // sure that we don't execute `hranaStmts` outside of a transaction.\n await this.#started;\n }\n else {\n // The transaction has started, but we will use `hrana.BatchCond.isAutocommit()` to make\n // sure that we don't execute `hranaStmts` outside of a transaction, so we don't have to\n // wait for `this.#started`\n }\n this._getSqlCache().apply(hranaStmts);\n const batch = stream.batch(this.#version >= 3);\n let lastStep = undefined;\n rowsPromises = hranaStmts.map((hranaStmt) => {\n const stmtStep = batch.step();\n if (lastStep !== undefined) {\n stmtStep.condition(hrana.BatchCond.ok(lastStep));\n }\n if (this.#version >= 3) {\n stmtStep.condition(hrana.BatchCond.not(hrana.BatchCond.isAutocommit(batch)));\n }\n const rowsPromise = stmtStep.query(hranaStmt);\n rowsPromise.catch(() => undefined); // silence Node warning\n lastStep = stmtStep;\n return rowsPromise;\n });\n await batch.execute();\n }\n const resultSets = [];\n for (const rowsPromise of rowsPromises) {\n const rows = await rowsPromise;\n if (rows === undefined) {\n throw new LibsqlError(\"Statement in a transaction was not executed, \" +\n \"probably because the transaction has been rolled back\", \"TRANSACTION_CLOSED\");\n }\n resultSets.push(resultSetFromHrana(rows));\n }\n return resultSets;\n }\n catch (e) {\n throw mapHranaError(e);\n }\n }\n async executeMultiple(sql) {\n const stream = this._getStream();\n if (stream.closed) {\n throw new LibsqlError(\"Cannot execute statements because the transaction is closed\", \"TRANSACTION_CLOSED\");\n }\n try {\n if (this.#started === undefined) {\n // If the transaction hasn't started yet, start it now\n this.#started = stream\n .run(transactionModeToBegin(this.#mode))\n .then(() => undefined);\n try {\n await this.#started;\n }\n catch (e) {\n this.close();\n throw e;\n }\n }\n else {\n // Wait until the transaction has started\n await this.#started;\n }\n await stream.sequence(sql);\n }\n catch (e) {\n throw mapHranaError(e);\n }\n }\n async rollback() {\n try {\n const stream = this._getStream();\n if (stream.closed) {\n return;\n }\n if (this.#started !== undefined) {\n // We don't have to wait for the BEGIN statement to complete. If the BEGIN fails, we will\n // execute a ROLLBACK outside of an active transaction, which should be harmless.\n }\n else {\n // We did nothing in the transaction, so there is nothing to rollback.\n return;\n }\n // Pipeline the ROLLBACK statement and the stream close.\n const promise = stream.run(\"ROLLBACK\").catch((e) => {\n throw mapHranaError(e);\n });\n stream.closeGracefully();\n await promise;\n }\n catch (e) {\n throw mapHranaError(e);\n }\n finally {\n // `this.close()` may close the `hrana.Client`, which aborts all pending stream requests, so we\n // must call it _after_ we receive the ROLLBACK response.\n // Also note that the current stream should already be closed, but we need to call `this.close()`\n // anyway, because it may need to do more cleanup.\n this.close();\n }\n }\n async commit() {\n // (this method is analogous to `rollback()`)\n try {\n const stream = this._getStream();\n if (stream.closed) {\n throw new LibsqlError(\"Cannot commit the transaction because it is already closed\", \"TRANSACTION_CLOSED\");\n }\n if (this.#started !== undefined) {\n // Make sure to execute the COMMIT only if the BEGIN was successful.\n await this.#started;\n }\n else {\n return;\n }\n const promise = stream.run(\"COMMIT\").catch((e) => {\n throw mapHranaError(e);\n });\n stream.closeGracefully();\n await promise;\n }\n catch (e) {\n throw mapHranaError(e);\n }\n finally {\n this.close();\n }\n }\n}\nexport async function executeHranaBatch(mode, version, batch, hranaStmts, disableForeignKeys = false) {\n if (disableForeignKeys) {\n batch.step().run(\"PRAGMA foreign_keys=off\");\n }\n const beginStep = batch.step();\n const beginPromise = beginStep.run(transactionModeToBegin(mode));\n let lastStep = beginStep;\n const stmtPromises = hranaStmts.map((hranaStmt) => {\n const stmtStep = batch.step().condition(hrana.BatchCond.ok(lastStep));\n if (version >= 3) {\n stmtStep.condition(hrana.BatchCond.not(hrana.BatchCond.isAutocommit(batch)));\n }\n const stmtPromise = stmtStep.query(hranaStmt);\n lastStep = stmtStep;\n return stmtPromise;\n });\n const commitStep = batch.step().condition(hrana.BatchCond.ok(lastStep));\n if (version >= 3) {\n commitStep.condition(hrana.BatchCond.not(hrana.BatchCond.isAutocommit(batch)));\n }\n const commitPromise = commitStep.run(\"COMMIT\");\n const rollbackStep = batch\n .step()\n .condition(hrana.BatchCond.not(hrana.BatchCond.ok(commitStep)));\n rollbackStep.run(\"ROLLBACK\").catch((_) => undefined);\n if (disableForeignKeys) {\n batch.step().run(\"PRAGMA foreign_keys=on\");\n }\n await batch.execute();\n const resultSets = [];\n await beginPromise;\n for (const stmtPromise of stmtPromises) {\n const hranaRows = await stmtPromise;\n if (hranaRows === undefined) {\n throw new LibsqlError(\"Statement in a batch was not executed, probably because the transaction has been rolled back\", \"TRANSACTION_CLOSED\");\n }\n resultSets.push(resultSetFromHrana(hranaRows));\n }\n await commitPromise;\n return resultSets;\n}\nexport function stmtToHrana(stmt) {\n if (typeof stmt === \"string\") {\n return new hrana.Stmt(stmt);\n }\n const hranaStmt = new hrana.Stmt(stmt.sql);\n if (Array.isArray(stmt.args)) {\n hranaStmt.bindIndexes(stmt.args);\n }\n else {\n for (const [key, value] of Object.entries(stmt.args)) {\n hranaStmt.bindName(key, value);\n }\n }\n return hranaStmt;\n}\nexport function resultSetFromHrana(hranaRows) {\n const columns = hranaRows.columnNames.map((c) => c ?? \"\");\n const columnTypes = hranaRows.columnDecltypes.map((c) => c ?? \"\");\n const rows = hranaRows.rows;\n const rowsAffected = hranaRows.affectedRowCount;\n const lastInsertRowid = hranaRows.lastInsertRowid !== undefined\n ? hranaRows.lastInsertRowid\n : undefined;\n return new ResultSetImpl(columns, columnTypes, rows, rowsAffected, lastInsertRowid);\n}\nexport function mapHranaError(e) {\n if (e instanceof hrana.ClientError) {\n const code = mapHranaErrorCode(e);\n return new LibsqlError(e.message, code, undefined, e);\n }\n return e;\n}\nfunction mapHranaErrorCode(e) {\n if (e instanceof hrana.ResponseError && e.code !== undefined) {\n return e.code;\n }\n else if (e instanceof hrana.ProtoError) {\n return \"HRANA_PROTO_ERROR\";\n }\n else if (e instanceof hrana.ClosedError) {\n return e.cause instanceof hrana.ClientError\n ? mapHranaErrorCode(e.cause)\n : \"HRANA_CLOSED_ERROR\";\n }\n else if (e instanceof hrana.WebSocketError) {\n return \"HRANA_WEBSOCKET_ERROR\";\n }\n else if (e instanceof hrana.HttpServerError) {\n return \"SERVER_ERROR\";\n }\n else if (e instanceof hrana.ProtocolVersionError) {\n return \"PROTOCOL_VERSION_ERROR\";\n }\n else if (e instanceof hrana.InternalError) {\n return \"INTERNAL_ERROR\";\n }\n else {\n return \"UNKNOWN\";\n }\n}\n"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,sBAAsB;AAC7C,SAASC,WAAW,QAAQ,kBAAkB;AAC9C,SAASC,sBAAsB,EAAEC,aAAa,QAAQ,mBAAmB;AACzE,OAAO,MAAMC,gBAAgB,CAAC;EAC1B,CAACC,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