@cerbos/orm-prisma
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -28,2 +28,8 @@ "use strict"; | ||
} | ||
function getOperandName(operands) { | ||
return (operands.find(o => o.hasOwnProperty("name"))).name; | ||
} | ||
function getOperandValue(operands) { | ||
return (operands.find(o => o.hasOwnProperty("value"))).value; | ||
} | ||
function mapOperand(operand, getFieldName, output = {}) { | ||
@@ -40,34 +46,34 @@ if (isExpression(operand)) { | ||
case "eq": | ||
output[getFieldName(operands[0].name)] = { | ||
equals: operands[1].value, | ||
output[getFieldName(getOperandName(operands))] = { | ||
equals: getOperandValue(operands), | ||
}; | ||
break; | ||
case "ne": | ||
output[getFieldName(operands[0].name)] = { | ||
not: operands[1].value, | ||
output[getFieldName(getOperandName(operands))] = { | ||
not: getOperandValue(operands), | ||
}; | ||
break; | ||
case "lt": | ||
output[getFieldName(operands[0].name)] = { | ||
lt: operands[1].value, | ||
output[getFieldName(getOperandName(operands))] = { | ||
lt: getOperandValue(operands), | ||
}; | ||
break; | ||
case "gt": | ||
output[getFieldName(operands[0].name)] = { | ||
gt: operands[1].value, | ||
output[getFieldName(getOperandName(operands))] = { | ||
gt: getOperandValue(operands), | ||
}; | ||
break; | ||
case "lte": | ||
output[getFieldName(operands[0].name)] = { | ||
lte: operands[1].value, | ||
output[getFieldName(getOperandName(operands))] = { | ||
lte: getOperandValue(operands), | ||
}; | ||
break; | ||
case "gte": | ||
output[getFieldName(operands[0].name)] = { | ||
gte: operands[1].value, | ||
output[getFieldName(getOperandName(operands))] = { | ||
gte: getOperandValue(operands), | ||
}; | ||
break; | ||
case "in": | ||
output[getFieldName(operands[0].name)] = { | ||
in: operands[1].value, | ||
output[getFieldName(getOperandName(operands))] = { | ||
in: getOperandValue(operands), | ||
}; | ||
@@ -74,0 +80,0 @@ break; |
@@ -25,2 +25,8 @@ import { PlanKind } from "@cerbos/core"; | ||
} | ||
function getOperandName(operands) { | ||
return (operands.find(o => o.hasOwnProperty("name"))).name; | ||
} | ||
function getOperandValue(operands) { | ||
return (operands.find(o => o.hasOwnProperty("value"))).value; | ||
} | ||
function mapOperand(operand, getFieldName, output = {}) { | ||
@@ -37,34 +43,34 @@ if (isExpression(operand)) { | ||
case "eq": | ||
output[getFieldName(operands[0].name)] = { | ||
equals: operands[1].value, | ||
output[getFieldName(getOperandName(operands))] = { | ||
equals: getOperandValue(operands), | ||
}; | ||
break; | ||
case "ne": | ||
output[getFieldName(operands[0].name)] = { | ||
not: operands[1].value, | ||
output[getFieldName(getOperandName(operands))] = { | ||
not: getOperandValue(operands), | ||
}; | ||
break; | ||
case "lt": | ||
output[getFieldName(operands[0].name)] = { | ||
lt: operands[1].value, | ||
output[getFieldName(getOperandName(operands))] = { | ||
lt: getOperandValue(operands), | ||
}; | ||
break; | ||
case "gt": | ||
output[getFieldName(operands[0].name)] = { | ||
gt: operands[1].value, | ||
output[getFieldName(getOperandName(operands))] = { | ||
gt: getOperandValue(operands), | ||
}; | ||
break; | ||
case "lte": | ||
output[getFieldName(operands[0].name)] = { | ||
lte: operands[1].value, | ||
output[getFieldName(getOperandName(operands))] = { | ||
lte: getOperandValue(operands), | ||
}; | ||
break; | ||
case "gte": | ||
output[getFieldName(operands[0].name)] = { | ||
gte: operands[1].value, | ||
output[getFieldName(getOperandName(operands))] = { | ||
gte: getOperandValue(operands), | ||
}; | ||
break; | ||
case "in": | ||
output[getFieldName(operands[0].name)] = { | ||
in: operands[1].value, | ||
output[getFieldName(getOperandName(operands))] = { | ||
in: getOperandValue(operands), | ||
}; | ||
@@ -71,0 +77,0 @@ break; |
{ | ||
"name": "@cerbos/orm-prisma", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"homepage": "https://cerbos.dev", | ||
@@ -17,3 +17,4 @@ "description": "", | ||
"version": "git add -A src", | ||
"postversion": "git push && git push --tags" | ||
"postversion": "git push && git push --tags", | ||
"test": "jest src/**.test.ts" | ||
}, | ||
@@ -23,2 +24,4 @@ "author": "Cerbos", | ||
"devDependencies": { | ||
"@types/jest": "^29.0.0", | ||
"ts-jest": "^28.0.8", | ||
"ts-node": "^10.4.0", | ||
@@ -28,4 +31,4 @@ "typescript": "^4.5.4" | ||
"dependencies": { | ||
"@cerbos/core": "^0.5.0" | ||
"@cerbos/core": "^0.5.1" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27529
11
798
4
1
Updated@cerbos/core@^0.5.1