1 line
8.1 KiB
JSON
1 line
8.1 KiB
JSON
{"ast":null,"code":"\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.errorFromProto = exports.valueResultFromProto = exports.rowResultFromProto = exports.rowsResultFromProto = exports.stmtResultFromProto = void 0;\nconst errors_js_1 = require(\"./errors.js\");\nconst value_js_1 = require(\"./value.js\");\nfunction stmtResultFromProto(result) {\n return {\n affectedRowCount: result.affectedRowCount,\n lastInsertRowid: result.lastInsertRowid,\n columnNames: result.cols.map(col => col.name),\n columnDecltypes: result.cols.map(col => col.decltype)\n };\n}\nexports.stmtResultFromProto = stmtResultFromProto;\nfunction rowsResultFromProto(result, intMode) {\n const stmtResult = stmtResultFromProto(result);\n const rows = result.rows.map(row => rowFromProto(stmtResult.columnNames, row, intMode));\n return {\n ...stmtResult,\n rows\n };\n}\nexports.rowsResultFromProto = rowsResultFromProto;\nfunction rowResultFromProto(result, intMode) {\n const stmtResult = stmtResultFromProto(result);\n let row;\n if (result.rows.length > 0) {\n row = rowFromProto(stmtResult.columnNames, result.rows[0], intMode);\n }\n return {\n ...stmtResult,\n row\n };\n}\nexports.rowResultFromProto = rowResultFromProto;\nfunction valueResultFromProto(result, intMode) {\n const stmtResult = stmtResultFromProto(result);\n let value;\n if (result.rows.length > 0 && stmtResult.columnNames.length > 0) {\n value = (0, value_js_1.valueFromProto)(result.rows[0][0], intMode);\n }\n return {\n ...stmtResult,\n value\n };\n}\nexports.valueResultFromProto = valueResultFromProto;\nfunction rowFromProto(colNames, values, intMode) {\n const row = {};\n // make sure that the \"length\" property is not enumerable\n Object.defineProperty(row, \"length\", {\n value: values.length\n });\n for (let i = 0; i < values.length; ++i) {\n const value = (0, value_js_1.valueFromProto)(values[i], intMode);\n Object.defineProperty(row, i, {\n value\n });\n const colName = colNames[i];\n if (colName !== undefined && !Object.hasOwn(row, colName)) {\n Object.defineProperty(row, colName, {\n value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n }\n }\n return row;\n}\nfunction errorFromProto(error) {\n return new errors_js_1.ResponseError(error.message, error);\n}\nexports.errorFromProto = errorFromProto;","map":{"version":3,"names":["Object","defineProperty","exports","value","errorFromProto","valueResultFromProto","rowResultFromProto","rowsResultFromProto","stmtResultFromProto","errors_js_1","require","value_js_1","result","affectedRowCount","lastInsertRowid","columnNames","cols","map","col","name","columnDecltypes","decltype","intMode","stmtResult","rows","row","rowFromProto","length","valueFromProto","colNames","values","i","colName","undefined","hasOwn","enumerable","configurable","writable","error","ResponseError","message"],"sources":["/Users/shoofle/Projects/the-forest/node_modules/@libsql/hrana-client/lib-cjs/result.js"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.errorFromProto = exports.valueResultFromProto = exports.rowResultFromProto = exports.rowsResultFromProto = exports.stmtResultFromProto = void 0;\nconst errors_js_1 = require(\"./errors.js\");\nconst value_js_1 = require(\"./value.js\");\nfunction stmtResultFromProto(result) {\n return {\n affectedRowCount: result.affectedRowCount,\n lastInsertRowid: result.lastInsertRowid,\n columnNames: result.cols.map(col => col.name),\n columnDecltypes: result.cols.map(col => col.decltype),\n };\n}\nexports.stmtResultFromProto = stmtResultFromProto;\nfunction rowsResultFromProto(result, intMode) {\n const stmtResult = stmtResultFromProto(result);\n const rows = result.rows.map(row => rowFromProto(stmtResult.columnNames, row, intMode));\n return { ...stmtResult, rows };\n}\nexports.rowsResultFromProto = rowsResultFromProto;\nfunction rowResultFromProto(result, intMode) {\n const stmtResult = stmtResultFromProto(result);\n let row;\n if (result.rows.length > 0) {\n row = rowFromProto(stmtResult.columnNames, result.rows[0], intMode);\n }\n return { ...stmtResult, row };\n}\nexports.rowResultFromProto = rowResultFromProto;\nfunction valueResultFromProto(result, intMode) {\n const stmtResult = stmtResultFromProto(result);\n let value;\n if (result.rows.length > 0 && stmtResult.columnNames.length > 0) {\n value = (0, value_js_1.valueFromProto)(result.rows[0][0], intMode);\n }\n return { ...stmtResult, value };\n}\nexports.valueResultFromProto = valueResultFromProto;\nfunction rowFromProto(colNames, values, intMode) {\n const row = {};\n // make sure that the \"length\" property is not enumerable\n Object.defineProperty(row, \"length\", { value: values.length });\n for (let i = 0; i < values.length; ++i) {\n const value = (0, value_js_1.valueFromProto)(values[i], intMode);\n Object.defineProperty(row, i, { value });\n const colName = colNames[i];\n if (colName !== undefined && !Object.hasOwn(row, colName)) {\n Object.defineProperty(row, colName, { value, enumerable: true, configurable: true, writable: true });\n }\n }\n return row;\n}\nfunction errorFromProto(error) {\n return new errors_js_1.ResponseError(error.message, error);\n}\nexports.errorFromProto = errorFromProto;\n"],"mappings":"AAAA,YAAY;;AACZA,MAAM,CAACC,cAAc,CAACC,OAAO,EAAE,YAAY,EAAE;EAAEC,KAAK,EAAE;AAAK,CAAC,CAAC;AAC7DD,OAAO,CAACE,cAAc,GAAGF,OAAO,CAACG,oBAAoB,GAAGH,OAAO,CAACI,kBAAkB,GAAGJ,OAAO,CAACK,mBAAmB,GAAGL,OAAO,CAACM,mBAAmB,GAAG,KAAK,CAAC;AACvJ,MAAMC,WAAW,GAAGC,OAAO,CAAC,aAAa,CAAC;AAC1C,MAAMC,UAAU,GAAGD,OAAO,CAAC,YAAY,CAAC;AACxC,SAASF,mBAAmBA,CAACI,MAAM,EAAE;EACjC,OAAO;IACHC,gBAAgB,EAAED,MAAM,CAACC,gBAAgB;IACzCC,eAAe,EAAEF,MAAM,CAACE,eAAe;IACvCC,WAAW,EAAEH,MAAM,CAACI,IAAI,CAACC,GAAG,CAACC,GAAG,IAAIA,GAAG,CAACC,IAAI,CAAC;IAC7CC,eAAe,EAAER,MAAM,CAACI,IAAI,CAACC,GAAG,CAACC,GAAG,IAAIA,GAAG,CAACG,QAAQ;EACxD,CAAC;AACL;AACAnB,OAAO,CAACM,mBAAmB,GAAGA,mBAAmB;AACjD,SAASD,mBAAmBA,CAACK,MAAM,EAAEU,OAAO,EAAE;EAC1C,MAAMC,UAAU,GAAGf,mBAAmB,CAACI,MAAM,CAAC;EAC9C,MAA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