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

1 line
42 KiB
JSON

{"ast":null,"code":"\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.HttpStream = void 0;\nconst isomorphic_fetch_1 = require(\"@libsql/isomorphic-fetch\");\nconst errors_js_1 = require(\"../errors.js\");\nconst index_js_1 = require(\"../encoding/index.js\");\nconst id_alloc_js_1 = require(\"../id_alloc.js\");\nconst queue_js_1 = require(\"../queue.js\");\nconst queue_microtask_js_1 = require(\"../queue_microtask.js\");\nconst result_js_1 = require(\"../result.js\");\nconst sql_js_1 = require(\"../sql.js\");\nconst stream_js_1 = require(\"../stream.js\");\nconst util_js_1 = require(\"../util.js\");\nconst cursor_js_1 = require(\"./cursor.js\");\nconst json_encode_js_1 = require(\"./json_encode.js\");\nconst protobuf_encode_js_1 = require(\"./protobuf_encode.js\");\nconst json_encode_js_2 = require(\"./json_encode.js\");\nconst protobuf_encode_js_2 = require(\"./protobuf_encode.js\");\nconst json_decode_js_1 = require(\"./json_decode.js\");\nconst protobuf_decode_js_1 = require(\"./protobuf_decode.js\");\nclass HttpStream extends stream_js_1.Stream {\n #client;\n #baseUrl;\n #jwt;\n #fetch;\n #baton;\n #queue;\n #flushing;\n #cursor;\n #closing;\n #closeQueued;\n #closed;\n #sqlIdAlloc;\n /** @private */\n constructor(client, baseUrl, jwt, customFetch) {\n super(client.intMode);\n this.#client = client;\n this.#baseUrl = baseUrl.toString();\n this.#jwt = jwt;\n this.#fetch = customFetch;\n this.#baton = undefined;\n this.#queue = new queue_js_1.Queue();\n this.#flushing = false;\n this.#closing = false;\n this.#closeQueued = false;\n this.#closed = undefined;\n this.#sqlIdAlloc = new id_alloc_js_1.IdAlloc();\n }\n /** Get the {@link HttpClient} object that this stream belongs to. */\n client() {\n return this.#client;\n }\n /** @private */\n _sqlOwner() {\n return this;\n }\n /** Cache a SQL text on the server. */\n storeSql(sql) {\n const sqlId = this.#sqlIdAlloc.alloc();\n this.#sendStreamRequest({\n type: \"store_sql\",\n sqlId,\n sql\n }).then(() => undefined, error => this._setClosed(error));\n return new sql_js_1.Sql(this, sqlId);\n }\n /** @private */\n _closeSql(sqlId) {\n if (this.#closed !== undefined) {\n return;\n }\n this.#sendStreamRequest({\n type: \"close_sql\",\n sqlId\n }).then(() => this.#sqlIdAlloc.free(sqlId), error => this._setClosed(error));\n }\n /** @private */\n _execute(stmt) {\n return this.#sendStreamRequest({\n type: \"execute\",\n stmt\n }).then(response => {\n return response.result;\n });\n }\n /** @private */\n _batch(batch) {\n return this.#sendStreamRequest({\n type: \"batch\",\n batch\n }).then(response => {\n return response.result;\n });\n }\n /** @private */\n _describe(protoSql) {\n return this.#sendStreamRequest({\n type: \"describe\",\n sql: protoSql.sql,\n sqlId: protoSql.sqlId\n }).then(response => {\n return response.result;\n });\n }\n /** @private */\n _sequence(protoSql) {\n return this.#sendStreamRequest({\n type: \"sequence\",\n sql: protoSql.sql,\n sqlId: protoSql.sqlId\n }).then(_response => {\n return undefined;\n });\n }\n /** Check whether the SQL connection underlying this stream is in autocommit state (i.e., outside of an\n * explicit transaction). This requires protocol version 3 or higher.\n */\n getAutocommit() {\n this.#client._ensureVersion(3, \"getAutocommit()\");\n return this.#sendStreamRequest({\n type: \"get_autocommit\"\n }).then(response => {\n return response.isAutocommit;\n });\n }\n #sendStreamRequest(request) {\n return new Promise((responseCallback, errorCallback) => {\n this.#pushToQueue({\n type: \"pipeline\",\n request,\n responseCallback,\n errorCallback\n });\n });\n }\n /** @private */\n _openCursor(batch) {\n return new Promise((cursorCallback, errorCallback) => {\n this.#pushToQueue({\n type: \"cursor\",\n batch,\n cursorCallback,\n errorCallback\n });\n });\n }\n /** @private */\n _cursorClosed(cursor) {\n if (cursor !== this.#cursor) {\n throw new errors_js_1.InternalError(\"Cursor was closed, but it was not associated with the stream\");\n }\n this.#cursor = undefined;\n (0, queue_microtask_js_1.queueMicrotask)(() => this.#flushQueue());\n }\n /** Immediately close the stream. */\n close() {\n this._setClosed(new errors_js_1.ClientError(\"Stream was manually closed\"));\n }\n /** Gracefully close the stream. */\n closeGracefully() {\n this.#closing = true;\n (0, queue_microtask_js_1.queueMicrotask)(() => this.#flushQueue());\n }\n /** True if the stream is closed. */\n get closed() {\n return this.#closed !== undefined || this.#closing;\n }\n /** @private */\n _setClosed(error) {\n if (this.#closed !== undefined) {\n return;\n }\n this.#closed = error;\n if (this.#cursor !== undefined) {\n this.#cursor._setClosed(error);\n }\n this.#client._streamClosed(this);\n for (;;) {\n const entry = this.#queue.shift();\n if (entry !== undefined) {\n entry.errorCallback(error);\n } else {\n break;\n }\n }\n if ((this.#baton !== undefined || this.#flushing) && !this.#closeQueued) {\n this.#queue.push({\n type: \"pipeline\",\n request: {\n type: \"close\"\n },\n responseCallback: () => undefined,\n errorCallback: () => undefined\n });\n this.#closeQueued = true;\n (0, queue_microtask_js_1.queueMicrotask)(() => this.#flushQueue());\n }\n }\n #pushToQueue(entry) {\n if (this.#closed !== undefined) {\n throw new errors_js_1.ClosedError(\"Stream is closed\", this.#closed);\n } else if (this.#closing) {\n throw new errors_js_1.ClosedError(\"Stream is closing\", undefined);\n } else {\n this.#queue.push(entry);\n (0, queue_microtask_js_1.queueMicrotask)(() => this.#flushQueue());\n }\n }\n #flushQueue() {\n if (this.#flushing || this.#cursor !== undefined) {\n return;\n }\n if (this.#closing && this.#queue.length === 0) {\n this._setClosed(new errors_js_1.ClientError(\"Stream was gracefully closed\"));\n return;\n }\n const endpoint = this.#client._endpoint;\n if (endpoint === undefined) {\n this.#client._endpointPromise.then(() => this.#flushQueue(), error => this._setClosed(error));\n return;\n }\n const firstEntry = this.#queue.shift();\n if (firstEntry === undefined) {\n return;\n } else if (firstEntry.type === \"pipeline\") {\n const pipeline = [firstEntry];\n for (;;) {\n const entry = this.#queue.first();\n if (entry !== undefined && entry.type === \"pipeline\") {\n pipeline.push(entry);\n this.#queue.shift();\n } else if (entry === undefined && this.#closing && !this.#closeQueued) {\n pipeline.push({\n type: \"pipeline\",\n request: {\n type: \"close\"\n },\n responseCallback: () => undefined,\n errorCallback: () => undefined\n });\n this.#closeQueued = true;\n break;\n } else {\n break;\n }\n }\n this.#flushPipeline(endpoint, pipeline);\n } else if (firstEntry.type === \"cursor\") {\n this.#flushCursor(endpoint, firstEntry);\n } else {\n throw (0, util_js_1.impossible)(firstEntry, \"Impossible type of QueueEntry\");\n }\n }\n #flushPipeline(endpoint, pipeline) {\n this.#flush(() => this.#createPipelineRequest(pipeline, endpoint), resp => decodePipelineResponse(resp, endpoint.encoding), respBody => respBody.baton, respBody => respBody.baseUrl, respBody => handlePipelineResponse(pipeline, respBody), error => pipeline.forEach(entry => entry.errorCallback(error)));\n }\n #flushCursor(endpoint, entry) {\n const cursor = new cursor_js_1.HttpCursor(this, endpoint.encoding);\n this.#cursor = cursor;\n this.#flush(() => this.#createCursorRequest(entry, endpoint), resp => cursor.open(resp), respBody => respBody.baton, respBody => respBody.baseUrl, _respBody => entry.cursorCallback(cursor), error => entry.errorCallback(error));\n }\n #flush(createRequest, decodeResponse, getBaton, getBaseUrl, handleResponse, handleError) {\n let promise;\n try {\n const request = createRequest();\n const fetch = this.#fetch;\n promise = fetch(request);\n } catch (error) {\n promise = Promise.reject(error);\n }\n this.#flushing = true;\n promise.then(resp => {\n if (!resp.ok) {\n return errorFromResponse(resp).then(error => {\n throw error;\n });\n }\n return decodeResponse(resp);\n }).then(r => {\n this.#baton = getBaton(r);\n this.#baseUrl = getBaseUrl(r) ?? this.#baseUrl;\n handleResponse(r);\n }).catch(error => {\n this._setClosed(error);\n handleError(error);\n }).finally(() => {\n this.#flushing = false;\n this.#flushQueue();\n });\n }\n #createPipelineRequest(pipeline, endpoint) {\n return this.#createRequest(new URL(endpoint.pipelinePath, this.#baseUrl), {\n baton: this.#baton,\n requests: pipeline.map(entry => entry.request)\n }, endpoint.encoding, json_encode_js_1.PipelineReqBody, protobuf_encode_js_1.PipelineReqBody);\n }\n #createCursorRequest(entry, endpoint) {\n if (endpoint.cursorPath === undefined) {\n throw new errors_js_1.ProtocolVersionError(\"Cursors are supported only on protocol version 3 and higher, \" + `but the HTTP server only supports version ${endpoint.version}.`);\n }\n return this.#createRequest(new URL(endpoint.cursorPath, this.#baseUrl), {\n baton: this.#baton,\n batch: entry.batch\n }, endpoint.encoding, json_encode_js_2.CursorReqBody, protobuf_encode_js_2.CursorReqBody);\n }\n #createRequest(url, reqBody, encoding, jsonFun, protobufFun) {\n let bodyData;\n let contentType;\n if (encoding === \"json\") {\n bodyData = (0, index_js_1.writeJsonObject)(reqBody, jsonFun);\n contentType = \"application/json\";\n } else if (encoding === \"protobuf\") {\n bodyData = (0, index_js_1.writeProtobufMessage)(reqBody, protobufFun);\n contentType = \"application/x-protobuf\";\n } else {\n throw (0, util_js_1.impossible)(encoding, \"Impossible encoding\");\n }\n const headers = new isomorphic_fetch_1.Headers();\n headers.set(\"content-type\", contentType);\n if (this.#jwt !== undefined) {\n headers.set(\"authorization\", `Bearer ${this.#jwt}`);\n }\n return new isomorphic_fetch_1.Request(url.toString(), {\n method: \"POST\",\n headers,\n body: bodyData\n });\n }\n}\nexports.HttpStream = HttpStream;\nfunction handlePipelineResponse(pipeline, respBody) {\n if (respBody.results.length !== pipeline.length) {\n throw new errors_js_1.ProtoError(\"Server returned unexpected number of pipeline results\");\n }\n for (let i = 0; i < pipeline.length; ++i) {\n const result = respBody.results[i];\n const entry = pipeline[i];\n if (result.type === \"ok\") {\n if (result.response.type !== entry.request.type) {\n throw new errors_js_1.ProtoError(\"Received unexpected type of response\");\n }\n entry.responseCallback(result.response);\n } else if (result.type === \"error\") {\n entry.errorCallback((0, result_js_1.errorFromProto)(result.error));\n } else if (result.type === \"none\") {\n throw new errors_js_1.ProtoError(\"Received unrecognized type of StreamResult\");\n } else {\n throw (0, util_js_1.impossible)(result, \"Received impossible type of StreamResult\");\n }\n }\n}\nasync function decodePipelineResponse(resp, encoding) {\n if (encoding === \"json\") {\n const respJson = await resp.json();\n return (0, index_js_1.readJsonObject)(respJson, json_decode_js_1.PipelineRespBody);\n } else if (encoding === \"protobuf\") {\n const respData = await resp.arrayBuffer();\n return (0, index_js_1.readProtobufMessage)(new Uint8Array(respData), protobuf_decode_js_1.PipelineRespBody);\n } else {\n throw (0, util_js_1.impossible)(encoding, \"Impossible encoding\");\n }\n}\nasync function errorFromResponse(resp) {\n const respType = resp.headers.get(\"content-type\") ?? \"text/plain\";\n if (respType === \"application/json\") {\n const respBody = await resp.json();\n if (\"message\" in respBody) {\n return (0, result_js_1.errorFromProto)(respBody);\n }\n }\n let message = `Server returned HTTP status ${resp.status}`;\n if (respType === \"text/plain\") {\n const respBody = (await resp.text()).trim();\n if (respBody !== \"\") {\n message += `: ${respBody}`;\n }\n }\n return new errors_js_1.HttpServerError(message, resp.status);\n}","map":{"version":3,"names":["Object","defineProperty","exports","value","HttpStream","isomorphic_fetch_1","require","errors_js_1","index_js_1","id_alloc_js_1","queue_js_1","queue_microtask_js_1","result_js_1","sql_js_1","stream_js_1","util_js_1","cursor_js_1","json_encode_js_1","protobuf_encode_js_1","json_encode_js_2","protobuf_encode_js_2","json_decode_js_1","protobuf_decode_js_1","Stream","client","baseUrl","jwt","fetch","baton","queue","flushing","cursor","closing","closeQueued","closed","sqlIdAlloc","constructor","customFetch","intMode","toString","undefined","Queue","IdAlloc","_sqlOwner","storeSql","sql","sqlId","alloc","sendStreamRequest","type","then","error","_setClosed","Sql","_closeSql","free","_execute","stmt","response","result","_batch","batch","_describe","protoSql","_sequence","_response","getAutocommit","_ensureVersion","isAutocommit","#sendStreamRequest","request","Promise","responseCallback","errorCallback","pushToQueue","_openCursor","cursorCallback","_cursorClosed","InternalError","queueMicrotask","flushQueue","close","ClientError","closeGracefully","_streamClosed","entry","shift","push","#pushToQueue","ClosedError","#flushQueue","length","endpoint","_endpoint","_endpointPromise","firstEntry","pipeline","first","flushPipeline","flushCursor","impossible","#flushPipeline","flush","createPipelineRequest","resp","decodePipelineResponse","encoding","respBody","handlePipelineResponse","forEach","#flushCursor","HttpCursor","createCursorRequest","open","_respBody","#flush","createRequest","decodeResponse","getBaton","getBaseUrl","handleResponse","handleError","promise","reject","ok","errorFromResponse","r","catch","finally","#createPipelineRequest","URL","pipelinePath","requests","map","PipelineReqBody","#createCursorRequest","cursorPath","ProtocolVersionError","version","CursorReqBody","#createRequest","url","reqBody","jsonFun","protobufFun","bodyData","contentType","writeJsonObject","writeProtobufMessage","headers","Headers","set","Request","method","body","results","ProtoError","i","errorFromProto","respJson","json","readJsonObject","PipelineRespBody","respData","arrayBuffer","readProtobufMessage","Uint8Array","respType","get","message","status","text","trim","HttpServerError"],"sources":["/Users/shoofle/Projects/the-forest/node_modules/@libsql/hrana-client/lib-cjs/http/stream.js"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.HttpStream = void 0;\nconst isomorphic_fetch_1 = require(\"@libsql/isomorphic-fetch\");\nconst errors_js_1 = require(\"../errors.js\");\nconst index_js_1 = require(\"../encoding/index.js\");\nconst id_alloc_js_1 = require(\"../id_alloc.js\");\nconst queue_js_1 = require(\"../queue.js\");\nconst queue_microtask_js_1 = require(\"../queue_microtask.js\");\nconst result_js_1 = require(\"../result.js\");\nconst sql_js_1 = require(\"../sql.js\");\nconst stream_js_1 = require(\"../stream.js\");\nconst util_js_1 = require(\"../util.js\");\nconst cursor_js_1 = require(\"./cursor.js\");\nconst json_encode_js_1 = require(\"./json_encode.js\");\nconst protobuf_encode_js_1 = require(\"./protobuf_encode.js\");\nconst json_encode_js_2 = require(\"./json_encode.js\");\nconst protobuf_encode_js_2 = require(\"./protobuf_encode.js\");\nconst json_decode_js_1 = require(\"./json_decode.js\");\nconst protobuf_decode_js_1 = require(\"./protobuf_decode.js\");\nclass HttpStream extends stream_js_1.Stream {\n #client;\n #baseUrl;\n #jwt;\n #fetch;\n #baton;\n #queue;\n #flushing;\n #cursor;\n #closing;\n #closeQueued;\n #closed;\n #sqlIdAlloc;\n /** @private */\n constructor(client, baseUrl, jwt, customFetch) {\n super(client.intMode);\n this.#client = client;\n this.#baseUrl = baseUrl.toString();\n this.#jwt = jwt;\n this.#fetch = customFetch;\n this.#baton = undefined;\n this.#queue = new queue_js_1.Queue();\n this.#flushing = false;\n this.#closing = false;\n this.#closeQueued = false;\n this.#closed = undefined;\n this.#sqlIdAlloc = new id_alloc_js_1.IdAlloc();\n }\n /** Get the {@link HttpClient} object that this stream belongs to. */\n client() {\n return this.#client;\n }\n /** @private */\n _sqlOwner() {\n return this;\n }\n /** Cache a SQL text on the server. */\n storeSql(sql) {\n const sqlId = this.#sqlIdAlloc.alloc();\n this.#sendStreamRequest({ type: \"store_sql\", sqlId, sql }).then(() => undefined, (error) => this._setClosed(error));\n return new sql_js_1.Sql(this, sqlId);\n }\n /** @private */\n _closeSql(sqlId) {\n if (this.#closed !== undefined) {\n return;\n }\n this.#sendStreamRequest({ type: \"close_sql\", sqlId }).then(() => this.#sqlIdAlloc.free(sqlId), (error) => this._setClosed(error));\n }\n /** @private */\n _execute(stmt) {\n return this.#sendStreamRequest({ type: \"execute\", stmt }).then((response) => {\n return response.result;\n });\n }\n /** @private */\n _batch(batch) {\n return this.#sendStreamRequest({ type: \"batch\", batch }).then((response) => {\n return response.result;\n });\n }\n /** @private */\n _describe(protoSql) {\n return this.#sendStreamRequest({\n type: \"describe\",\n sql: protoSql.sql,\n sqlId: protoSql.sqlId\n }).then((response) => {\n return response.result;\n });\n }\n /** @private */\n _sequence(protoSql) {\n return this.#sendStreamRequest({\n type: \"sequence\",\n sql: protoSql.sql,\n sqlId: protoSql.sqlId,\n }).then((_response) => {\n return undefined;\n });\n }\n /** Check whether the SQL connection underlying this stream is in autocommit state (i.e., outside of an\n * explicit transaction). This requires protocol version 3 or higher.\n */\n getAutocommit() {\n this.#client._ensureVersion(3, \"getAutocommit()\");\n return this.#sendStreamRequest({\n type: \"get_autocommit\",\n }).then((response) => {\n return response.isAutocommit;\n });\n }\n #sendStreamRequest(request) {\n return new Promise((responseCallback, errorCallback) => {\n this.#pushToQueue({ type: \"pipeline\", request, responseCallback, errorCallback });\n });\n }\n /** @private */\n _openCursor(batch) {\n return new Promise((cursorCallback, errorCallback) => {\n this.#pushToQueue({ type: \"cursor\", batch, cursorCallback, errorCallback });\n });\n }\n /** @private */\n _cursorClosed(cursor) {\n if (cursor !== this.#cursor) {\n throw new errors_js_1.InternalError(\"Cursor was closed, but it was not associated with the stream\");\n }\n this.#cursor = undefined;\n (0, queue_microtask_js_1.queueMicrotask)(() => this.#flushQueue());\n }\n /** Immediately close the stream. */\n close() {\n this._setClosed(new errors_js_1.ClientError(\"Stream was manually closed\"));\n }\n /** Gracefully close the stream. */\n closeGracefully() {\n this.#closing = true;\n (0, queue_microtask_js_1.queueMicrotask)(() => this.#flushQueue());\n }\n /** True if the stream is closed. */\n get closed() {\n return this.#closed !== undefined || this.#closing;\n }\n /** @private */\n _setClosed(error) {\n if (this.#closed !== undefined) {\n return;\n }\n this.#closed = error;\n if (this.#cursor !== undefined) {\n this.#cursor._setClosed(error);\n }\n this.#client._streamClosed(this);\n for (;;) {\n const entry = this.#queue.shift();\n if (entry !== undefined) {\n entry.errorCallback(error);\n }\n else {\n break;\n }\n }\n if ((this.#baton !== undefined || this.#flushing) && !this.#closeQueued) {\n this.#queue.push({\n type: \"pipeline\",\n request: { type: \"close\" },\n responseCallback: () => undefined,\n errorCallback: () => undefined,\n });\n this.#closeQueued = true;\n (0, queue_microtask_js_1.queueMicrotask)(() => this.#flushQueue());\n }\n }\n #pushToQueue(entry) {\n if (this.#closed !== undefined) {\n throw new errors_js_1.ClosedError(\"Stream is closed\", this.#closed);\n }\n else if (this.#closing) {\n throw new errors_js_1.ClosedError(\"Stream is closing\", undefined);\n }\n else {\n this.#queue.push(entry);\n (0, queue_microtask_js_1.queueMicrotask)(() => this.#flushQueue());\n }\n }\n #flushQueue() {\n if (this.#flushing || this.#cursor !== undefined) {\n return;\n }\n if (this.#closing && this.#queue.length === 0) {\n this._setClosed(new errors_js_1.ClientError(\"Stream was gracefully closed\"));\n return;\n }\n const endpoint = this.#client._endpoint;\n if (endpoint === undefined) {\n this.#client._endpointPromise.then(() => this.#flushQueue(), (error) => this._setClosed(error));\n return;\n }\n const firstEntry = this.#queue.shift();\n if (firstEntry === undefined) {\n return;\n }\n else if (firstEntry.type === \"pipeline\") {\n const pipeline = [firstEntry];\n for (;;) {\n const entry = this.#queue.first();\n if (entry !== undefined && entry.type === \"pipeline\") {\n pipeline.push(entry);\n this.#queue.shift();\n }\n else if (entry === undefined && this.#closing && !this.#closeQueued) {\n pipeline.push({\n type: \"pipeline\",\n request: { type: \"close\" },\n responseCallback: () => undefined,\n errorCallback: () => undefined,\n });\n this.#closeQueued = true;\n break;\n }\n else {\n break;\n }\n }\n this.#flushPipeline(endpoint, pipeline);\n }\n else if (firstEntry.type === \"cursor\") {\n this.#flushCursor(endpoint, firstEntry);\n }\n else {\n throw (0, util_js_1.impossible)(firstEntry, \"Impossible type of QueueEntry\");\n }\n }\n #flushPipeline(endpoint, pipeline) {\n this.#flush(() => this.#createPipelineRequest(pipeline, endpoint), (resp) => decodePipelineResponse(resp, endpoint.encoding), (respBody) => respBody.baton, (respBody) => respBody.baseUrl, (respBody) => handlePipelineResponse(pipeline, respBody), (error) => pipeline.forEach((entry) => entry.errorCallback(error)));\n }\n #flushCursor(endpoint, entry) {\n const cursor = new cursor_js_1.HttpCursor(this, endpoint.encoding);\n this.#cursor = cursor;\n this.#flush(() => this.#createCursorRequest(entry, endpoint), (resp) => cursor.open(resp), (respBody) => respBody.baton, (respBody) => respBody.baseUrl, (_respBody) => entry.cursorCallback(cursor), (error) => entry.errorCallback(error));\n }\n #flush(createRequest, decodeResponse, getBaton, getBaseUrl, handleResponse, handleError) {\n let promise;\n try {\n const request = createRequest();\n const fetch = this.#fetch;\n promise = fetch(request);\n }\n catch (error) {\n promise = Promise.reject(error);\n }\n this.#flushing = true;\n promise.then((resp) => {\n if (!resp.ok) {\n return errorFromResponse(resp).then((error) => {\n throw error;\n });\n }\n return decodeResponse(resp);\n }).then((r) => {\n this.#baton = getBaton(r);\n this.#baseUrl = getBaseUrl(r) ?? this.#baseUrl;\n handleResponse(r);\n }).catch((error) => {\n this._setClosed(error);\n handleError(error);\n }).finally(() => {\n this.#flushing = false;\n this.#flushQueue();\n });\n }\n #createPipelineRequest(pipeline, endpoint) {\n return this.#createRequest(new URL(endpoint.pipelinePath, this.#baseUrl), {\n baton: this.#baton,\n requests: pipeline.map((entry) => entry.request),\n }, endpoint.encoding, json_encode_js_1.PipelineReqBody, protobuf_encode_js_1.PipelineReqBody);\n }\n #createCursorRequest(entry, endpoint) {\n if (endpoint.cursorPath === undefined) {\n throw new errors_js_1.ProtocolVersionError(\"Cursors are supported only on protocol version 3 and higher, \" +\n `but the HTTP server only supports version ${endpoint.version}.`);\n }\n return this.#createRequest(new URL(endpoint.cursorPath, this.#baseUrl), {\n baton: this.#baton,\n batch: entry.batch,\n }, endpoint.encoding, json_encode_js_2.CursorReqBody, protobuf_encode_js_2.CursorReqBody);\n }\n #createRequest(url, reqBody, encoding, jsonFun, protobufFun) {\n let bodyData;\n let contentType;\n if (encoding === \"json\") {\n bodyData = (0, index_js_1.writeJsonObject)(reqBody, jsonFun);\n contentType = \"application/json\";\n }\n else if (encoding === \"protobuf\") {\n bodyData = (0, index_js_1.writeProtobufMessage)(reqBody, protobufFun);\n contentType = \"application/x-protobuf\";\n }\n else {\n throw (0, util_js_1.impossible)(encoding, \"Impossible encoding\");\n }\n const headers = new isomorphic_fetch_1.Headers();\n headers.set(\"content-type\", contentType);\n if (this.#jwt !== undefined) {\n headers.set(\"authorization\", `Bearer ${this.#jwt}`);\n }\n return new isomorphic_fetch_1.Request(url.toString(), { method: \"POST\", headers, body: bodyData });\n }\n}\nexports.HttpStream = HttpStream;\nfunction handlePipelineResponse(pipeline, respBody) {\n if (respBody.results.length !== pipeline.length) {\n throw new errors_js_1.ProtoError(\"Server returned unexpected number of pipeline results\");\n }\n for (let i = 0; i < pipeline.length; ++i) {\n const result = respBody.results[i];\n const entry = pipeline[i];\n if (result.type === \"ok\") {\n if (result.response.type !== entry.request.type) {\n throw new errors_js_1.ProtoError(\"Received unexpected type of response\");\n }\n entry.responseCallback(result.response);\n }\n else if (result.type === \"error\") {\n entry.errorCallback((0, result_js_1.errorFromProto)(result.error));\n }\n else if (result.type === \"none\") {\n throw new errors_js_1.ProtoError(\"Received unrecognized type of StreamResult\");\n }\n else {\n throw (0, util_js_1.impossible)(result, \"Received impossible type of StreamResult\");\n }\n }\n}\nasync function decodePipelineResponse(resp, encoding) {\n if (encoding === \"json\") {\n const respJson = await resp.json();\n return (0, index_js_1.readJsonObject)(respJson, json_decode_js_1.PipelineRespBody);\n }\n else if (encoding === \"protobuf\") {\n const respData = await resp.arrayBuffer();\n return (0, index_js_1.readProtobufMessage)(new Uint8Array(respData), protobuf_decode_js_1.PipelineRespBody);\n }\n else {\n throw (0, util_js_1.impossible)(encoding, \"Impossible encoding\");\n }\n}\nasync function errorFromResponse(resp) {\n const respType = resp.headers.get(\"content-type\") ?? \"text/plain\";\n if (respType === \"application/json\") {\n const respBody = await resp.json();\n if (\"message\" in respBody) {\n return (0, result_js_1.errorFromProto)(respBody);\n }\n }\n let message = `Server returned HTTP status ${resp.status}`;\n if (respType === \"text/plain\") {\n const respBody = (await resp.text()).trim();\n if (respBody !== \"\") {\n message += `: ${respBody}`;\n }\n }\n return new errors_js_1.HttpServerError(message, resp.status);\n}\n"],"mappings":"AAAA,YAAY;;AACZA,MAAM,CAACC,cAAc,CAACC,OAAO,EAAE,YAAY,EAAE;EAAEC,KAAK,EAAE;AAAK,CAAC,CAAC;AAC7DD,OAAO,CAACE,UAAU,GAAG,KAAK,CAAC;AAC3B,MAAMC,kBAAkB,GAAGC,OAAO,CAAC,0BAA0B,CAAC;AAC9D,MAAMC,WAAW,GAAGD,OAAO,CAAC,cAAc,CAAC;AAC3C,MAAME,UAAU,GAAGF,OAAO,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