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

1 line
6.6 KiB
JSON

{"ast":null,"code":"import { ResponseError } from \"./errors.js\";\nimport { valueFromProto } from \"./value.js\";\nexport function 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}\nexport function 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}\nexport function 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}\nexport function valueResultFromProto(result, intMode) {\n const stmtResult = stmtResultFromProto(result);\n let value;\n if (result.rows.length > 0 && stmtResult.columnNames.length > 0) {\n value = valueFromProto(result.rows[0][0], intMode);\n }\n return {\n ...stmtResult,\n value\n };\n}\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 = 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}\nexport function errorFromProto(error) {\n return new ResponseError(error.message, error);\n}","map":{"version":3,"names":["ResponseError","valueFromProto","stmtResultFromProto","result","affectedRowCount","lastInsertRowid","columnNames","cols","map","col","name","columnDecltypes","decltype","rowsResultFromProto","intMode","stmtResult","rows","row","rowFromProto","rowResultFromProto","length","valueResultFromProto","value","colNames","values","Object","defineProperty","i","colName","undefined","hasOwn","enumerable","configurable","writable","errorFromProto","error","message"],"sources":["/Users/shoofle/Projects/the-forest/node_modules/@libsql/hrana-client/lib-esm/result.js"],"sourcesContent":["import { ResponseError } from \"./errors.js\";\nimport { valueFromProto } from \"./value.js\";\nexport function 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}\nexport function 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}\nexport function 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}\nexport function valueResultFromProto(result, intMode) {\n const stmtResult = stmtResultFromProto(result);\n let value;\n if (result.rows.length > 0 && stmtResult.columnNames.length > 0) {\n value = valueFromProto(result.rows[0][0], intMode);\n }\n return { ...stmtResult, value };\n}\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 = 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}\nexport function errorFromProto(error) {\n return new ResponseError(error.message, error);\n}\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,aAAa;AAC3C,SAASC,cAAc,QAAQ,YAAY;AAC3C,OAAO,SAASC,mBAAmBA,CAACC,MAAM,EAAE;EACxC,OAAO;IACHC,gBAAgB,EAAED,MAAM,CAACC,gBAAgB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