Socket
Socket
Sign inDemoInstall

pg-sql2

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pg-sql2 - npm Package Compare versions

Comparing version 5.0.0-alpha.2 to 5.0.0-alpha.3

9

CHANGELOG.md
# pg-sql2
## 5.0.0-alpha.3
### Patch Changes
- [#370](https://github.com/benjie/postgraphile-private/pull/370)
[`339fe20d0`](https://github.com/benjie/postgraphile-private/commit/339fe20d0c6e8600d263ce8093cd85a6ea8adbbf)
Thanks [@benjie](https://github.com/benjie)! - Allow multiple instances of
pg-sql2 and tamedevil to help handle package manager shenanigans.
## 5.0.0-alpha.2

@@ -4,0 +13,0 @@

8

dist/index.d.ts

@@ -1,11 +0,5 @@

import "./thereCanBeOnlyOne.js";
import { $$type } from "./thereCanBeOnlyOne.js";
/** Experimental! */
export declare const $$symbolToIdentifier: unique symbol;
/**
* This is the secret to our safety; since this is a symbol it cannot be faked
* in a JSON payload and it cannot be constructed with a new Symbol (even with
* the same argument), so external data cannot make itself trusted.
*/
declare const $$type: unique symbol;
/**
* Represents raw SQL, the text will be output verbatim into the compiled query.

@@ -12,0 +6,0 @@ */

@@ -5,6 +5,6 @@ "use strict";

const tslib_1 = require("tslib");
require("./thereCanBeOnlyOne.js");
const lru_1 = tslib_1.__importDefault(require("@graphile/lru"));
const assert = tslib_1.__importStar(require("assert"));
const util_1 = require("util");
const thereCanBeOnlyOne_js_1 = require("./thereCanBeOnlyOne.js");
function exportAs(thing, exportName) {

@@ -27,8 +27,2 @@ const existingExport = thing.$$export;

const isDev = typeof process !== "undefined" && process.env.GRAPHILE_ENV === "development";
/**
* This is the secret to our safety; since this is a symbol it cannot be faked
* in a JSON payload and it cannot be constructed with a new Symbol (even with
* the same argument), so external data cannot make itself trusted.
*/
const $$type = Symbol("pg-sql2-type");
const FLAG_HAS_PARENS = 1 << 0;

@@ -90,3 +84,3 @@ /**

const newNode = {
[$$type]: "RAW",
[thereCanBeOnlyOne_js_1.$$type]: "RAW",
t: text,

@@ -104,3 +98,3 @@ };

return Object.freeze({
[$$type]: "IDENTIFIER",
[thereCanBeOnlyOne_js_1.$$type]: "IDENTIFIER",
s,

@@ -113,3 +107,3 @@ n,

return Object.freeze({
[$$type]: "VALUE",
[thereCanBeOnlyOne_js_1.$$type]: "VALUE",
v: rawValue,

@@ -119,7 +113,7 @@ });

function makeIndentNode(content) {
const flags = content[$$type] === "QUERY" ? content.f : 0;
const flags = content[thereCanBeOnlyOne_js_1.$$type] === "QUERY" ? content.f : 0;
return Object.freeze({
[$$type]: "INDENT",
[thereCanBeOnlyOne_js_1.$$type]: "INDENT",
f: flags,
c: content[$$type] === "QUERY" ? content : makeQueryNode([content]),
c: content[thereCanBeOnlyOne_js_1.$$type] === "QUERY" ? content : makeQueryNode([content]),
});

@@ -129,3 +123,3 @@ }

return Object.freeze({
[$$type]: "SYMBOL_ALIAS",
[thereCanBeOnlyOne_js_1.$$type]: "SYMBOL_ALIAS",
a: a,

@@ -137,3 +131,3 @@ b: b,

return Object.freeze({
[$$type]: "PLACEHOLDER",
[thereCanBeOnlyOne_js_1.$$type]: "PLACEHOLDER",
s: symbol,

@@ -146,3 +140,3 @@ k: fallback,

for (const node of nodes) {
switch (node[$$type]) {
switch (node[thereCanBeOnlyOne_js_1.$$type]) {
case "RAW": {

@@ -177,3 +171,3 @@ const { t } = node;

default: {
const never = node[$$type];
const never = node[thereCanBeOnlyOne_js_1.$$type];
throw new Error(`Unrecognized node type ${never}`);

@@ -184,3 +178,3 @@ }

return Object.freeze({
[$$type]: "QUERY",
[thereCanBeOnlyOne_js_1.$$type]: "QUERY",
n: nodes,

@@ -194,3 +188,3 @@ f: flags,

node !== null &&
typeof node[$$type] === "string");
typeof node[thereCanBeOnlyOne_js_1.$$type] === "string");
}

@@ -251,6 +245,6 @@ exports.isSQL = isSQL;

const sqlFragments = [];
const trustedInput = untrustedInput[$$type] !== undefined
const trustedInput = untrustedInput[thereCanBeOnlyOne_js_1.$$type] !== undefined
? untrustedInput
: enforceValidNode(untrustedInput, ``);
const items = trustedInput[$$type] === "QUERY"
const items = trustedInput[thereCanBeOnlyOne_js_1.$$type] === "QUERY"
? expandQueryNodes(trustedInput)

@@ -261,6 +255,6 @@ : [trustedInput];

const itemAtIndex = items[itemIndex];
const item = itemAtIndex[$$type] !== undefined
const item = itemAtIndex[thereCanBeOnlyOne_js_1.$$type] !== undefined
? itemAtIndex
: enforceValidNode(itemAtIndex, `item ${itemIndex}`);
switch (item[$$type]) {
switch (item[thereCanBeOnlyOne_js_1.$$type]) {
case "RAW": {

@@ -406,9 +400,9 @@ if (item.t === "") {

const rawVal = values[i];
const valid = rawVal[$$type] !== undefined
const valid = rawVal[thereCanBeOnlyOne_js_1.$$type] !== undefined
? rawVal
: enforceValidNode(rawVal, `template literal placeholder ${i}`);
if (valid[$$type] === "RAW") {
if (valid[thereCanBeOnlyOne_js_1.$$type] === "RAW") {
currentText += valid.t;
}
else if (valid[$$type] === "QUERY") {
else if (valid[thereCanBeOnlyOne_js_1.$$type] === "QUERY") {
// NOTE: this clears the flags

@@ -419,3 +413,3 @@ const nodes = expandQueryNodes(valid);

const node = nodes[nodeIndex];
if (node[$$type] === "RAW") {
if (node[thereCanBeOnlyOne_js_1.$$type] === "RAW") {
currentText += node.t;

@@ -542,3 +536,3 @@ }

// - $myField$
// - YYYY-MM-DD"T"HH24:MI:SS.USTZHTZM
// - YYYY-MM-DD"T"HH24:MI:SS.USTZH:TZM
return makeRawNode(`'${val}'`);

@@ -583,3 +577,3 @@ }

const rawNode = items[0];
const node = rawNode[$$type] !== undefined
const node = rawNode[thereCanBeOnlyOne_js_1.$$type] !== undefined
? rawNode

@@ -595,3 +589,3 @@ : enforceValidNode(rawNode, `join item ${0}`);

const addSeparator = i > 0 && hasSeparator;
const node = rawNode[$$type] !== undefined
const node = rawNode[thereCanBeOnlyOne_js_1.$$type] !== undefined
? rawNode

@@ -602,5 +596,5 @@ : enforceValidNode(rawNode, `join item ${i}`);

}
if (node[$$type] === "QUERY") {
if (node[thereCanBeOnlyOne_js_1.$$type] === "QUERY") {
for (const innerNode of expandQueryNodes(node)) {
if (innerNode[$$type] === "RAW") {
if (innerNode[thereCanBeOnlyOne_js_1.$$type] === "RAW") {
currentText += innerNode.t;

@@ -617,3 +611,3 @@ }

}
else if (node[$$type] === "RAW") {
else if (node[thereCanBeOnlyOne_js_1.$$type] === "RAW") {
currentText += node.t;

@@ -672,3 +666,3 @@ }

const flags = inFlags | FLAG_HAS_PARENS;
if (fragment[$$type] === "QUERY") {
if (fragment[thereCanBeOnlyOne_js_1.$$type] === "QUERY") {
return makeQueryNode(fragment.n, flags);

@@ -705,3 +699,3 @@ }

function parens(frag, force) {
if (frag[$$type] === "QUERY") {
if (frag[thereCanBeOnlyOne_js_1.$$type] === "QUERY") {
if ((frag.f & FLAG_HAS_PARENS) === FLAG_HAS_PARENS) {

@@ -725,4 +719,4 @@ return frag;

const [identifier, rawtext] = nodes;
if (identifier[$$type] !== "IDENTIFIER" ||
rawtext[$$type] !== "RAW" ||
if (identifier[thereCanBeOnlyOne_js_1.$$type] !== "IDENTIFIER" ||
rawtext[thereCanBeOnlyOne_js_1.$$type] !== "RAW" ||
!rawtext.t.startsWith(".")) {

@@ -742,4 +736,4 @@ return parenthesize(frag);

if (i % 2 === 0) {
if (node[$$type] !== "IDENTIFIER" &&
(node[$$type] !== "RAW" || !isIdentifierLike(node.t))) {
if (node[thereCanBeOnlyOne_js_1.$$type] !== "IDENTIFIER" &&
(node[thereCanBeOnlyOne_js_1.$$type] !== "RAW" || !isIdentifierLike(node.t))) {
return parenthesize(frag);

@@ -749,3 +743,3 @@ }

else {
if (node[$$type] !== "RAW" || node.t !== ".") {
if (node[thereCanBeOnlyOne_js_1.$$type] !== "RAW" || node.t !== ".") {
return parenthesize(frag);

@@ -761,5 +755,5 @@ }

}
else if (frag[$$type] === "INDENT") {
else if (frag[thereCanBeOnlyOne_js_1.$$type] === "INDENT") {
const inner = parens(frag.c, force);
if (inner[$$type] === "QUERY" &&
if (inner[thereCanBeOnlyOne_js_1.$$type] === "QUERY" &&
(inner.f & FLAG_HAS_PARENS) === FLAG_HAS_PARENS) {

@@ -779,9 +773,9 @@ // Move the parens to outside

}
else if (frag[$$type] === "VALUE") {
else if (frag[thereCanBeOnlyOne_js_1.$$type] === "VALUE") {
return frag;
}
else if (frag[$$type] === "IDENTIFIER") {
else if (frag[thereCanBeOnlyOne_js_1.$$type] === "IDENTIFIER") {
return frag;
}
else if (frag[$$type] === "RAW") {
else if (frag[thereCanBeOnlyOne_js_1.$$type] === "RAW") {
const expr = frag.t;

@@ -847,4 +841,4 @@ if (expr.match(NUMBER_REGEX_1) || expr.match(NUMBER_REGEX_2)) {

}
else if (sql1[$$type] === "QUERY") {
if (sql2[$$type] !== "QUERY" || sql2.f !== sql1.f || sql2.c !== sql1.c) {
else if (sql1[thereCanBeOnlyOne_js_1.$$type] === "QUERY") {
if (sql2[thereCanBeOnlyOne_js_1.$$type] !== "QUERY" || sql2.f !== sql1.f || sql2.c !== sql1.c) {
return false;

@@ -854,9 +848,9 @@ }

}
else if (sql2[$$type] === "QUERY") {
else if (sql2[thereCanBeOnlyOne_js_1.$$type] === "QUERY") {
return false;
}
else {
switch (sql1[$$type]) {
switch (sql1[thereCanBeOnlyOne_js_1.$$type]) {
case "RAW": {
if (sql2[$$type] !== sql1[$$type]) {
if (sql2[thereCanBeOnlyOne_js_1.$$type] !== sql1[thereCanBeOnlyOne_js_1.$$type]) {
return false;

@@ -867,3 +861,3 @@ }

case "VALUE": {
if (sql2[$$type] !== sql1[$$type]) {
if (sql2[thereCanBeOnlyOne_js_1.$$type] !== sql1[thereCanBeOnlyOne_js_1.$$type]) {
return false;

@@ -874,3 +868,3 @@ }

case "INDENT": {
if (sql2[$$type] !== sql1[$$type]) {
if (sql2[thereCanBeOnlyOne_js_1.$$type] !== sql1[thereCanBeOnlyOne_js_1.$$type]) {
return false;

@@ -881,3 +875,3 @@ }

case "IDENTIFIER": {
if (sql2[$$type] !== sql1[$$type]) {
if (sql2[thereCanBeOnlyOne_js_1.$$type] !== sql1[thereCanBeOnlyOne_js_1.$$type]) {
return false;

@@ -895,3 +889,3 @@ }

case "PLACEHOLDER": {
if (sql2[$$type] !== sql1[$$type]) {
if (sql2[thereCanBeOnlyOne_js_1.$$type] !== sql1[thereCanBeOnlyOne_js_1.$$type]) {
return false;

@@ -918,3 +912,3 @@ }

function replaceSymbolInNode(frag, needle, replacement) {
switch (frag[$$type]) {
switch (frag[thereCanBeOnlyOne_js_1.$$type]) {
case "RAW": {

@@ -960,3 +954,3 @@ return frag;

const never = frag;
throw new Error(`Unhandled SQL type ${never[$$type]}`);
throw new Error(`Unhandled SQL type ${never[thereCanBeOnlyOne_js_1.$$type]}`);
}

@@ -969,3 +963,3 @@ }

function replaceSymbol(frag, needle, replacement) {
if (frag[$$type] === "QUERY") {
if (frag[thereCanBeOnlyOne_js_1.$$type] === "QUERY") {
let changed = false;

@@ -972,0 +966,0 @@ const newNodes = frag.n.map((node) => {

@@ -1,3 +0,9 @@

declare const $$pgSql2: unique symbol;
declare const globalAny: any;
/**
* This is the secret to our safety; since this is a symbol it cannot be faked
* in a JSON payload or other user-provided data, so external data cannot make
* itself trusted.
*
* @internal
*/
export declare const $$type: unique symbol;
//# sourceMappingURL=thereCanBeOnlyOne.d.ts.map
"use strict";
const $$pgSql2 = Symbol.for("pgSql2");
const globalAny = globalThis;
if (globalAny[$$pgSql2] === true) {
// Already warned
}
else if (globalAny[$$pgSql2]) {
globalAny[$$pgSql2] = true;
throw new Error(`WARNING: more than one version of the 'pg-sql2' module has been instantiated - you must ensure there is exactly one pg-sql2 (e.g. using yarn "resolutions" or similar techniques). Try clearing your package lockfile and reinstalling.`, { cause: globalAny[$$pgSql2] });
}
else {
try {
// Capture the stack trace
throw new Error(`The first 'pg-sql2' was installed here`);
}
catch (e) {
globalAny[$$pgSql2] = e;
}
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.$$type = void 0;
/** IMPORTANT: bump this on incompatible changes to this module */
const revision = 1;
/**
* This is the secret to our safety; since this is a symbol it cannot be faked
* in a JSON payload or other user-provided data, so external data cannot make
* itself trusted.
*
* @internal
*/
exports.$$type = Symbol.for(`pg-sql2-type-${revision}`);
//# sourceMappingURL=thereCanBeOnlyOne.js.map
{
"name": "pg-sql2",
"version": "5.0.0-alpha.2",
"version": "5.0.0-alpha.3",
"description": "Generate safe Postgres-compliant SQL with tagged template literals",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc