@prisma/client-engine-runtime
Advanced tools
+1
-0
@@ -322,2 +322,3 @@ /** | ||
| private getActiveTransaction; | ||
| cancelAllTransactions(): Promise<void>; | ||
| private startTransactionTimeout; | ||
@@ -324,0 +325,0 @@ private closeTransaction; |
+1
-0
@@ -322,2 +322,3 @@ /** | ||
| private getActiveTransaction; | ||
| cancelAllTransactions(): Promise<void>; | ||
| private startTransactionTimeout; | ||
@@ -324,0 +325,0 @@ private closeTransaction; |
+92
-28
@@ -37,41 +37,90 @@ var __defProp = Object.defineProperty; | ||
| }) { | ||
| const flattened = []; | ||
| if (!query.includes(BEGIN_REPEAT)) { | ||
| return { query, params }; | ||
| } | ||
| const flattenedParams = []; | ||
| let lastParamId = 1; | ||
| let result = ""; | ||
| let templatePos = 0; | ||
| let state = 0 /* Normal */; | ||
| let stateBeforeQuote = 0 /* Normal */; | ||
| while (templatePos < query.length) { | ||
| const nextChar = query[templatePos]; | ||
| if (state === 1 /* Quoted */ && nextChar !== '"') { | ||
| result += nextChar; | ||
| templatePos++; | ||
| continue; | ||
| } | ||
| if (nextChar === '"') { | ||
| if (state === 1 /* Quoted */) { | ||
| state = stateBeforeQuote; | ||
| } else { | ||
| stateBeforeQuote = state; | ||
| state = 1 /* Quoted */; | ||
| } | ||
| result += nextChar; | ||
| templatePos++; | ||
| continue; | ||
| } | ||
| if (query.slice(templatePos, templatePos + BEGIN_REPEAT.length) === BEGIN_REPEAT) { | ||
| if (state === 2 /* Repeating */) { | ||
| throw new Error("Nested repetition is not allowed"); | ||
| } | ||
| state = 2 /* Repeating */; | ||
| templatePos += BEGIN_REPEAT.length; | ||
| result += "("; | ||
| const paramNum = parseInt(query.slice(templatePos).match(/^\$(\d+)/)?.[1] ?? "0"); | ||
| const arrParam = params[paramNum - 1]; | ||
| const expanded = arrParam.map((_, idx) => "$" + (lastParamId + idx)).join(", "); | ||
| result += expanded; | ||
| flattened.push(...arrParam); | ||
| lastParamId += arrParam.length; | ||
| templatePos += query.slice(templatePos).indexOf(END_REPEAT) + END_REPEAT.length; | ||
| continue; | ||
| } | ||
| if (query.slice(templatePos, templatePos + END_REPEAT.length) === END_REPEAT) { | ||
| if (state === 0 /* Normal */) { | ||
| throw new Error("Unmatched repetition end"); | ||
| } | ||
| state = 0 /* Normal */; | ||
| templatePos += END_REPEAT.length; | ||
| result += ")"; | ||
| } else if (query[templatePos] === "$") { | ||
| continue; | ||
| } | ||
| if (nextChar === "$") { | ||
| const paramMatch = query.slice(templatePos + 1).match(/^\d+/); | ||
| if (paramMatch) { | ||
| const paramNum = parseInt(paramMatch[0]); | ||
| const paramValue = params[paramNum - 1]; | ||
| if (!Array.isArray(paramValue)) { | ||
| result += "$" + lastParamId; | ||
| flattened.push(paramValue); | ||
| lastParamId++; | ||
| templatePos += paramMatch[0].length + 1; | ||
| } | ||
| } else { | ||
| result += query[templatePos]; | ||
| if (!paramMatch) { | ||
| result += "$"; | ||
| templatePos++; | ||
| continue; | ||
| } | ||
| } else { | ||
| result += query[templatePos]; | ||
| templatePos++; | ||
| templatePos += paramMatch[0].length + 1; | ||
| const originalParamIdx = parseInt(paramMatch[0]); | ||
| const paramValue = params[originalParamIdx - 1]; | ||
| switch (state) { | ||
| case 0 /* Normal */: { | ||
| flattenedParams.push(paramValue); | ||
| result += `$${lastParamId++}`; | ||
| break; | ||
| } | ||
| case 2 /* Repeating */: { | ||
| const paramArray = Array.isArray(paramValue) ? paramValue : [paramValue]; | ||
| if (paramArray.length === 0) { | ||
| result += "NULL"; | ||
| break; | ||
| } | ||
| paramArray.forEach((value, idx) => { | ||
| flattenedParams.push(value); | ||
| result += `$${lastParamId++}`; | ||
| if (idx !== paramArray.length - 1) { | ||
| result += ", "; | ||
| } | ||
| }); | ||
| break; | ||
| } | ||
| default: { | ||
| throw new Error(`Unexpected state: ${state}`); | ||
| } | ||
| } | ||
| continue; | ||
| } | ||
| result += nextChar; | ||
| templatePos++; | ||
| } | ||
| return { | ||
| query: result, | ||
| params: flattened | ||
| params: flattenedParams | ||
| }; | ||
@@ -146,3 +195,15 @@ } | ||
| (row) => row.reduce((acc, value, index) => { | ||
| acc[resultSet.columnNames[index]] = value; | ||
| const splitByDot = resultSet.columnNames[index].split("."); | ||
| let nested = acc; | ||
| for (let i = 0; i < splitByDot.length; i++) { | ||
| const key = splitByDot[i]; | ||
| if (i === splitByDot.length - 1) { | ||
| nested[key] = value; | ||
| } else { | ||
| if (nested[key] === void 0) { | ||
| nested[key] = {}; | ||
| } | ||
| nested = nested[key]; | ||
| } | ||
| } | ||
| return acc; | ||
@@ -234,6 +295,6 @@ }, {}) | ||
| } | ||
| if (value.length !== 1) { | ||
| throw new Error(`Expected exactly one element, got ${value.length}`); | ||
| if (value.length > 1) { | ||
| throw new Error(`Expected zero or one element, got ${value.length}`); | ||
| } | ||
| return value[0]; | ||
| return value[0] ?? null; | ||
| } | ||
@@ -773,2 +834,5 @@ case "required": { | ||
| } | ||
| async cancelAllTransactions() { | ||
| await Promise.allSettled([...this.transactions.values()].map((tx) => this.closeTransaction(tx, "rolled_back"))); | ||
| } | ||
| startTransactionTimeout(transactionId, timeout) { | ||
@@ -775,0 +839,0 @@ const timeoutStartedAt = Date.now(); |
+1
-1
| { | ||
| "name": "@prisma/client-engine-runtime", | ||
| "version": "6.4.0-integration-fix-accelerate-engine-crash-policy.1", | ||
| "version": "6.4.0-integration-renovate-configure.1", | ||
| "description": "This package is intended for Prisma's internal use", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
62619
2.89%1199
5.73%