Comparing version 0.20.8 to 0.20.9
@@ -30,2 +30,2 @@ /*! | ||
export declare const _plugJSBI: typeof plugJSBI; | ||
export declare const _edgedbJsVersion = "0.20.8"; | ||
export declare const _edgedbJsVersion = "0.20.9"; |
@@ -58,2 +58,2 @@ "use strict"; | ||
exports._plugJSBI = bigint_1.plugJSBI; | ||
exports._edgedbJsVersion = "0.20.8"; | ||
exports._edgedbJsVersion = "0.20.9"; |
@@ -7,3 +7,4 @@ "use strict"; | ||
const reservedKeywords_1 = require("../reflection/reservedKeywords"); | ||
function shapeToEdgeQL(shape, ctx, pointerKeys = null, keysOnly = false) { | ||
function shapeToEdgeQL(shape, ctx, pointers = null, keysOnly = false) { | ||
var _a; | ||
if (shape === null) { | ||
@@ -50,3 +51,3 @@ return ``; | ||
if (keysOnly) { | ||
addLine(q(key) + | ||
addLine(q(key, false) + | ||
((0, reflection_1.isObjectType)(val.__element__) | ||
@@ -58,5 +59,3 @@ ? `: ${shapeToEdgeQL(val.__element__.__shape__, ctx, null, true)}` | ||
const renderedExpr = renderEdgeQL(val, ctx); | ||
const expectedCardinality = pointerKeys && | ||
!pointerKeys.includes(key) && | ||
val.hasOwnProperty("__cardinality__") | ||
const expectedCardinality = pointers && !pointers[key] && val.hasOwnProperty("__cardinality__") | ||
? val.__cardinality__ === reflection_1.Cardinality.Many || | ||
@@ -67,3 +66,4 @@ val.__cardinality__ === reflection_1.Cardinality.AtLeastOne | ||
: ""; | ||
addLine(`${expectedCardinality}${q(key)} ${operator} ${renderedExpr.includes("\n") | ||
const wrapAssertExists = ((_a = pointers === null || pointers === void 0 ? void 0 : pointers[key]) === null || _a === void 0 ? void 0 : _a.cardinality) === reflection_1.Cardinality.AtLeastOne; | ||
addLine(`${expectedCardinality}${q(key, false)} ${operator} ${wrapAssertExists ? "assert_exists(" : ""}${renderedExpr.includes("\n") | ||
? `(\n${indent(renderedExpr[0] === "(" && | ||
@@ -73,3 +73,3 @@ renderedExpr[renderedExpr.length - 1] === ")" | ||
: renderedExpr, 4)}\n )` | ||
: renderedExpr}`); | ||
: renderedExpr}${wrapAssertExists ? ")" : ""}`); | ||
} | ||
@@ -391,3 +391,3 @@ else { | ||
expr.__expr__.__element__.__shape__) { | ||
lines.push(shapeToEdgeQL((expr.__element__.__shape__ || {}), ctx, Object.keys(expr.__element__.__pointers__))); | ||
lines.push(shapeToEdgeQL((expr.__element__.__shape__ || {}), ctx, expr.__element__.__pointers__)); | ||
} | ||
@@ -849,16 +849,17 @@ } | ||
} | ||
function q(ident, allowReserved = false) { | ||
function q(ident, allowBacklinks = true) { | ||
if (!ident || | ||
ident.startsWith("@") || | ||
ident.includes("::") || | ||
ident.startsWith("<")) { | ||
(allowBacklinks && (ident.startsWith("<") || ident.includes("::")))) { | ||
return ident; | ||
} | ||
const isAlphaNum = /^([^\W\d]\w*|([1-9]\d*|0))$/.test(ident); | ||
const lident = ident.toLowerCase(); | ||
const isReserved = lident !== "__type__" && | ||
lident !== "__std__" && | ||
reservedKeywords_1.reservedKeywords.includes(lident); | ||
if (isAlphaNum && (allowReserved || !isReserved)) { | ||
return ident; | ||
if (isAlphaNum) { | ||
const lident = ident.toLowerCase(); | ||
const isReserved = lident !== "__type__" && | ||
lident !== "__std__" && | ||
reservedKeywords_1.reservedKeywords.includes(lident); | ||
if (!isReserved) { | ||
return ident; | ||
} | ||
} | ||
@@ -865,0 +866,0 @@ return "`" + ident.replace(/`/g, "``") + "`"; |
@@ -21,2 +21,3 @@ import { | ||
isTupleType, | ||
ObjectTypePointers, | ||
ObjectTypeSet, | ||
@@ -87,3 +88,3 @@ OperatorKind, | ||
ctx: RenderCtx, | ||
pointerKeys: string[] | null = null, | ||
pointers: ObjectTypePointers | null = null, | ||
keysOnly: boolean = false | ||
@@ -137,3 +138,3 @@ ) { | ||
addLine( | ||
q(key) + | ||
q(key, false) + | ||
(isObjectType(val.__element__) | ||
@@ -158,5 +159,3 @@ ? `: ${shapeToEdgeQL( | ||
const expectedCardinality = | ||
pointerKeys && | ||
!pointerKeys.includes(key) && | ||
val.hasOwnProperty("__cardinality__") | ||
pointers && !pointers[key] && val.hasOwnProperty("__cardinality__") | ||
? val.__cardinality__ === Cardinality.Many || | ||
@@ -168,4 +167,10 @@ val.__cardinality__ === Cardinality.AtLeastOne | ||
// If selecting a required multi link, wrap expr in 'assert_exists' | ||
const wrapAssertExists = | ||
pointers?.[key]?.cardinality === Cardinality.AtLeastOne; | ||
addLine( | ||
`${expectedCardinality}${q(key)} ${operator} ${ | ||
`${expectedCardinality}${q(key, false)} ${operator} ${ | ||
wrapAssertExists ? "assert_exists(" : "" | ||
}${ | ||
renderedExpr.includes("\n") | ||
@@ -180,3 +185,3 @@ ? `(\n${indent( | ||
: renderedExpr | ||
}` | ||
}${wrapAssertExists ? ")" : ""}` | ||
); | ||
@@ -674,3 +679,3 @@ } else { | ||
ctx, | ||
Object.keys(expr.__element__.__pointers__) | ||
expr.__element__.__pointers__ | ||
) | ||
@@ -1233,8 +1238,7 @@ ); | ||
// https://github.com/edgedb/edgedb/blob/master/edb/edgeql/quote.py | ||
function q(ident: string, allowReserved: boolean = false): string { | ||
function q(ident: string, allowBacklinks: boolean = true): string { | ||
if ( | ||
!ident || | ||
ident.startsWith("@") || | ||
ident.includes("::") || | ||
ident.startsWith("<") // backlink | ||
(allowBacklinks && (ident.startsWith("<") || ident.includes("::"))) | ||
) { | ||
@@ -1245,12 +1249,12 @@ return ident; | ||
const isAlphaNum = /^([^\W\d]\w*|([1-9]\d*|0))$/.test(ident); | ||
if (isAlphaNum) { | ||
const lident = ident.toLowerCase(); | ||
const isReserved = | ||
lident !== "__type__" && | ||
lident !== "__std__" && | ||
reservedKeywords.includes(lident); | ||
const lident = ident.toLowerCase(); | ||
const isReserved = | ||
lident !== "__type__" && | ||
lident !== "__std__" && | ||
reservedKeywords.includes(lident); | ||
if (isAlphaNum && (allowReserved || !isReserved)) { | ||
return ident; | ||
if (!isReserved) { | ||
return ident; | ||
} | ||
} | ||
@@ -1257,0 +1261,0 @@ |
{ | ||
"name": "edgedb", | ||
"version": "0.20.8", | ||
"version": "0.20.9", | ||
"description": "The official Node.js client library for EdgeDB", | ||
@@ -5,0 +5,0 @@ "homepage": "https://edgedb.com/docs", |
Sorry, the diff of this file is not supported yet
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
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
1001193
25545