@prisma/client-engine-runtime
Advanced tools
+73
-24
@@ -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 | ||
| }; | ||
@@ -78,0 +127,0 @@ } |
+1
-1
| { | ||
| "name": "@prisma/client-engine-runtime", | ||
| "version": "6.4.0-dev.35", | ||
| "version": "6.4.0-dev.36", | ||
| "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
62236
1.92%1187
4.31%