1 line
28 KiB
JSON
1 line
28 KiB
JSON
|
{"ast":null,"code":"\"use strict\";\n\nvar __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = {\n enumerable: true,\n get: function () {\n return m[k];\n }\n };\n }\n Object.defineProperty(o, k2, desc);\n} : function (o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\nvar __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {\n Object.defineProperty(o, \"default\", {\n enumerable: true,\n value: v\n });\n} : function (o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = this && this.__importStar || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __exportStar = this && this.__exportStar || function (m, exports) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n};\nvar __importDefault = this && this.__importDefault || function (mod) {\n return mod && mod.__esModule ? mod : {\n \"default\": mod\n };\n};\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.HttpTransaction = exports.HttpClient = exports._createClient = exports.createClient = void 0;\nconst hrana = __importStar(require(\"@libsql/hrana-client\"));\nconst api_1 = require(\"@libsql/core/api\");\nconst config_1 = require(\"@libsql/core/config\");\nconst hrana_js_1 = require(\"./hrana.js\");\nconst sql_cache_js_1 = require(\"./sql_cache.js\");\nconst uri_1 = require(\"@libsql/core/uri\");\nconst util_1 = require(\"@libsql/core/util\");\nconst promise_limit_1 = __importDefault(require(\"promise-limit\"));\n__exportStar(require(\"@libsql/core/api\"), exports);\nfunction createClient(config) {\n return _createClient((0, config_1.expandConfig)(config, true));\n}\nexports.createClient = createClient;\n/** @private */\nfunction _createClient(config) {\n if (config.scheme !== \"https\" && config.scheme !== \"http\") {\n throw new api_1.LibsqlError('The HTTP client supports only \"libsql:\", \"https:\" and \"http:\" URLs, ' + `got ${JSON.stringify(config.scheme + \":\")}. For more information, please read ${util_1.supportedUrlLink}`, \"URL_SCHEME_NOT_SUPPORTED\");\n }\n if (config.encryptionKey !== undefined) {\n throw new api_1.LibsqlError(\"Encryption key is not supported by the remote client.\", \"ENCRYPTION_KEY_NOT_SUPPORTED\");\n }\n if (config.scheme === \"http\" && config.tls) {\n throw new api_1.LibsqlError(`A \"http:\" URL cannot opt into TLS by using ?tls=1`, \"URL_INVALID\");\n } else if (config.scheme === \"https\" && !config.tls) {\n throw new api_1.LibsqlError(`A \"https:\" URL cannot opt out of TLS by using ?tls=0`, \"URL_INVALID\");\n }\n const url = (0, uri_1.encodeBaseUrl)(config.scheme, config.authority, config.path);\n return new HttpClient(url, config.authToken, config.intMode, config.fetch, config.concurrency);\n}\nexports._createClient = _createClient;\nconst sqlCacheCapacity = 30;\nclass HttpClient {\n #client;\n protocol;\n #authToken;\n #promiseLimitFunction;\n /** @private */\n constructor(url, authToken, intMode, customFetch, concurrency) {\n this.#client = hrana.openHttp(url, authToken, customFetch);\n this.#client.intMode = intMode;\n this.protocol = \"http\";\n this.#authToken = authToken;\n this.#promiseLimitFunction = (0, promise_limit_1.default)(concurrency);\n }\n async limit(fn) {\n return this.#promiseLimitFunction(fn);\n }\n async execute(stmtOrSql, args) {\n let stmt;\n if (typeof stmtOrSql === \"string\") {\n stmt = {\n sql: stmtOrSql,\n args: args || []\n };\n } else {\n stmt = stmtOrSq
|