Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cirql

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cirql - npm Package Compare versions

Comparing version 0.2.3 to 0.2.4

662

dist/cirql.js

@@ -1,14 +0,14 @@

var nt = Object.defineProperty;
var st = (r, e, t) => e in r ? nt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
var $ = (r, e, t) => (st(r, typeof e != "symbol" ? e + "" : e, t), t), Fe = (r, e, t) => {
var st = Object.defineProperty;
var it = (r, e, t) => e in r ? st(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
var $ = (r, e, t) => (it(r, typeof e != "symbol" ? e + "" : e, t), t), Me = (r, e, t) => {
if (!e.has(r))
throw TypeError("Cannot " + t);
};
var u = (r, e, t) => (Fe(r, e, "read from private field"), t ? t.call(r) : e.get(r)), c = (r, e, t) => {
var u = (r, e, t) => (Me(r, e, "read from private field"), t ? t.call(r) : e.get(r)), c = (r, e, t) => {
if (e.has(r))
throw TypeError("Cannot add the same private member more than once");
e instanceof WeakSet ? e.add(r) : e.set(r, t);
}, m = (r, e, t, n) => (Fe(r, e, "write to private field"), n ? n.call(r, t) : e.set(r, t), t), He = (r, e, t, n) => ({
}, w = (r, e, t, n) => (Me(r, e, "write to private field"), n ? n.call(r, t) : e.set(r, t), t), Ve = (r, e, t, n) => ({
set _(i) {
m(r, e, i, t);
w(r, e, i, t);
},

@@ -18,6 +18,6 @@ get _() {

}
}), s = (r, e, t) => (Fe(r, e, "access private method"), t);
import it from "isomorphic-ws";
}), s = (r, e, t) => (Me(r, e, "access private method"), t);
import ut from "isomorphic-ws";
import { z as Y } from "zod";
class ut extends Event {
class ot extends Event {
constructor(t, n) {

@@ -30,3 +30,3 @@ super("close");

}
class ot extends Event {
class at extends Event {
constructor(t) {

@@ -38,7 +38,7 @@ super("error");

}
const G = Symbol("Query Raw"), Ve = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
function at(r) {
const G = Symbol("Query Raw"), Ke = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
function lt(r) {
let e = "";
for (let t = 0; t < 7; t++)
e += Ve.charAt(Math.floor(Math.random() * Ve.length));
e += Ke.charAt(Math.floor(Math.random() * Ke.length));
return r ? `${e}_${r}` : e;

@@ -55,9 +55,12 @@ }

}
function lt(r) {
const e = new URL("rpc", r.connection.endpoint.replace("http", "ws")), t = setInterval(() => o("ping"), 3e4), n = new it(e), i = /* @__PURE__ */ new Map();
function ye(...r) {
return r.some((e) => e.includes(","));
}
function ct(r) {
const e = new URL("rpc", r.connection.endpoint.replace("http", "ws")), t = setInterval(() => o("ping"), 3e4), n = new ut(e), i = /* @__PURE__ */ new Map();
let l = !1;
const o = (a, h = []) => {
const g = at();
return new Promise((E, b) => {
i.set(g, [E, b]), n.send(JSON.stringify({
const g = lt();
return new Promise((E, S) => {
i.set(g, [E, S]), n.send(JSON.stringify({
id: g,

@@ -67,3 +70,3 @@ method: a,

})), setTimeout(() => {
i.delete(g) && b(new Error("Request timed out"));
i.delete(g) && S(new Error("Request timed out"));
}, 5e3);

@@ -76,3 +79,3 @@ });

l = !0, n.close(), d(-1, "connection terminated");
}, w = async (a, h) => o("query", h ? [a, h] : [a]);
}, m = async (a, h) => o("query", h ? [a, h] : [a]);
return n.addEventListener("open", async () => {

@@ -91,3 +94,3 @@ var g;

}), n.addEventListener("message", (a) => {
const { id: h, result: g, method: E, error: b } = JSON.parse(a.data);
const { id: h, result: g, method: E, error: S } = JSON.parse(a.data);
if (E !== "notify")

@@ -98,3 +101,3 @@ if (!i.has(h))

const [F, ae] = i.get(h);
i.delete(h), b ? ae(b) : F(g);
i.delete(h), S ? ae(S) : F(g);
}

@@ -106,6 +109,6 @@ }), n.addEventListener("error", (a) => {

close: f,
query: w
query: m
};
}
const ct = (r) => r.errors.map((t) => `- @${t.path.join(".")}: ${t.message}`).join(`
const ht = (r) => r.errors.map((t) => `- @${t.path.join(".")}: ${t.message}`).join(`
`);

@@ -119,6 +122,6 @@ class q extends Error {

}
class Ke extends q {
class Ze extends q {
constructor(t, n) {
super(t + `
` + ct(n), "parse_failure");
` + ht(n), "parse_failure");
$(this, "reason");

@@ -128,3 +131,3 @@ this.reason = n;

}
class O extends q {
class N extends q {
constructor(t, n) {

@@ -136,3 +139,3 @@ super(t, "invalid_query");

}
function Ue(r) {
function ke(r) {
const e = [];

@@ -151,3 +154,3 @@ function t(n, i) {

}
function ye(r) {
function pe(r) {
const e = Object.keys(r), t = [];

@@ -160,3 +163,3 @@ for (const n of e)

for (const o of i)
l.push(`(${ye(o)})`);
l.push(`(${pe(o)})`);
t.push(`(${l.join(` ${n} `)})`);

@@ -169,10 +172,10 @@ } else {

}
const pe = Symbol("Fuzzy Query"), Re = Symbol("Dynamic Query");
var H, Nt, N, T;
const ke = class {
const we = Symbol("Fuzzy Query"), Fe = Symbol("Dynamic Query");
var H, bt, b, T;
const Pe = class {
constructor(e) {
c(this, N);
c(this, b);
c(this, H, void 0);
$(this, Nt, !0);
m(this, H, e);
$(this, bt, !0);
w(this, H, e);
}

@@ -190,4 +193,11 @@ get _quantity() {

from(...e) {
const t = e.map((n) => typeof n == "string" ? n : `(${n.toQuery()})`);
return s(this, N, T).call(this, {
const t = e.map((n) => {
if (typeof n == "string") {
if (ye(n))
throw new N("Multiple targets must be specified seperately");
return n;
} else
return `(${n.toQuery()})`;
});
return s(this, b, T).call(this, {
targets: t.join(", ")

@@ -206,3 +216,3 @@ });

fromRecord(e, t) {
return s(this, N, T).call(this, {
return s(this, b, T).call(this, {
quantity: "maybe",

@@ -221,3 +231,3 @@ targets: `type::thing(${JSON.stringify(e)}, ${JSON.stringify(t)})`

where(e) {
return typeof e == "object" && (e = ye(e)), s(this, N, T).call(this, { where: e });
return typeof e == "object" && (e = pe(e)), s(this, b, T).call(this, { where: e });
}

@@ -231,3 +241,3 @@ /**

split(...e) {
return s(this, N, T).call(this, { split: e });
return s(this, b, T).call(this, { split: e });
}

@@ -242,3 +252,3 @@ /**

groupBy(...e) {
return s(this, N, T).call(this, { group: e });
return s(this, b, T).call(this, { group: e });
}

@@ -251,7 +261,7 @@ /**

groupAll() {
return s(this, N, T).call(this, { group: "all" });
return s(this, b, T).call(this, { group: "all" });
}
orderBy(e, t) {
const n = typeof e == "string" ? { [e]: t || "asc" } : e;
return s(this, N, T).call(this, {
return s(this, b, T).call(this, {
order: n

@@ -267,3 +277,3 @@ });

limit(e) {
return s(this, N, T).call(this, {
return s(this, b, T).call(this, {
quantity: "many",

@@ -283,3 +293,3 @@ limit: e

one() {
return s(this, N, T).call(this, {
return s(this, b, T).call(this, {
quantity: "maybe",

@@ -296,3 +306,3 @@ limit: 1

start(e) {
return s(this, N, T).call(this, { start: e });
return s(this, b, T).call(this, { start: e });
}

@@ -306,3 +316,3 @@ /**

fetch(...e) {
return s(this, N, T).call(this, { fetch: e });
return s(this, b, T).call(this, { fetch: e });
}

@@ -316,3 +326,3 @@ /**

timeout(e) {
return s(this, N, T).call(this, { timeout: e });
return s(this, b, T).call(this, { timeout: e });
}

@@ -325,3 +335,3 @@ /**

parallel() {
return s(this, N, T).call(this, { parallel: !0 });
return s(this, b, T).call(this, { parallel: !0 });
}

@@ -338,3 +348,3 @@ toQuery() {

start: f,
fetch: w,
fetch: m,
timeout: a,

@@ -351,11 +361,11 @@ parallel: h

if (n && (E += ` WHERE ${n}`), i.length > 0 && (E += ` SPLIT ${i.join(", ")}`), l === "all" ? E += " GROUP BY ALL" : l.length > 0 && (E += ` GROUP BY ${l.join(", ")}`), g.length > 0) {
const b = g.map(([F, ae]) => `${F} ${ae.toUpperCase()}`);
E += ` ORDER BY ${b.join(", ")}`;
const S = g.map(([F, ae]) => `${F} ${ae.toUpperCase()}`);
E += ` ORDER BY ${S.join(", ")}`;
}
return d && (E += ` LIMIT BY ${d}`), f && (E += ` START AT ${f}`), w.length > 0 && (E += ` FETCH ${w.join(", ")}`), a && (E += ` TIMEOUT ${a}s`), h && (E += " PARALLEL"), E;
return d && (E += ` LIMIT BY ${d}`), f && (E += ` START AT ${f}`), m.length > 0 && (E += ` FETCH ${m.join(", ")}`), a && (E += ` TIMEOUT ${a}s`), h && (E += " PARALLEL"), E;
}
};
let qe = ke;
Nt = pe, H = new WeakMap(), N = new WeakSet(), T = function(e) {
return new ke({
let Ne = Pe;
bt = we, H = new WeakMap(), b = new WeakSet(), T = function(e) {
return new Pe({
...u(this, H),

@@ -365,4 +375,6 @@ ...e

};
function ht(...r) {
return new qe({
function ft(...r) {
if (ye(...r))
throw new N("Multiple projections must be specified seperately");
return new Ne({
quantity: "many",

@@ -382,6 +394,6 @@ projections: r.join(", ") || "*",

}
var C, Tt, I, _, ce, Me, Z, we;
const Pe = class {
var C, Tt, j, _, ce, Le, Z, ge;
const Je = class {
constructor(e) {
c(this, I);
c(this, j);
c(this, ce);

@@ -391,3 +403,3 @@ c(this, Z);

$(this, Tt, !0);
m(this, C, e);
w(this, C, e);
}

@@ -405,5 +417,5 @@ get _quantity() {

set(e, t) {
if (s(this, Z, we).call(this))
throw new O("Cannot set field when content is set");
return s(this, I, _).call(this, {
if (s(this, Z, ge).call(this))
throw new N("Cannot set field when content is set");
return s(this, j, _).call(this, {
setFields: {

@@ -424,5 +436,5 @@ ...u(this, C).setFields,

setAll(e) {
if (s(this, Z, we).call(this))
throw new O("Cannot set fields when content is set");
return s(this, I, _).call(this, {
if (s(this, Z, ge).call(this))
throw new N("Cannot set fields when content is set");
return s(this, j, _).call(this, {
setFields: {

@@ -444,5 +456,5 @@ ...u(this, C).setFields,

content(e) {
if (s(this, ce, Me).call(this))
throw new O("Cannot set content when fields are set");
return s(this, I, _).call(this, { content: e });
if (s(this, ce, Le).call(this))
throw new N("Cannot set content when fields are set");
return s(this, j, _).call(this, { content: e });
}

@@ -456,3 +468,3 @@ /**

return(e) {
return s(this, I, _).call(this, { returnMode: e });
return s(this, j, _).call(this, { returnMode: e });
}

@@ -466,3 +478,3 @@ /**

returnFields(...e) {
return s(this, I, _).call(this, {
return s(this, j, _).call(this, {
returnMode: "fields",

@@ -479,3 +491,3 @@ returnFields: e

timeout(e) {
return s(this, I, _).call(this, { timeout: e });
return s(this, j, _).call(this, { timeout: e });
}

@@ -488,3 +500,3 @@ /**

parallel() {
return s(this, I, _).call(this, { parallel: !0 });
return s(this, j, _).call(this, { parallel: !0 });
}

@@ -504,23 +516,25 @@ toQuery() {

let f = `CREATE ${e}`;
if (s(this, ce, Me).call(this)) {
const w = Ue(n);
w && (f += ` SET ${w}`);
if (s(this, ce, Le).call(this)) {
const m = ke(n);
m && (f += ` SET ${m}`);
} else
s(this, Z, we).call(this) && (f += ` CONTENT ${JSON.stringify(t)}`);
s(this, Z, ge).call(this) && (f += ` CONTENT ${JSON.stringify(t)}`);
return i === "fields" ? f += ` RETURN ${l.join(", ")}` : i && (f += ` RETURN ${i.toUpperCase()}`), o && (f += ` TIMEOUT ${o}s`), d && (f += " PARALLEL"), f;
}
};
let Ne = Pe;
Tt = pe, C = new WeakMap(), I = new WeakSet(), _ = function(e) {
return new Pe({ ...u(this, C), ...e });
}, ce = new WeakSet(), Me = function() {
let be = Je;
Tt = we, C = new WeakMap(), j = new WeakSet(), _ = function(e) {
return new Je({ ...u(this, C), ...e });
}, ce = new WeakSet(), Le = function() {
return Object.keys(u(this, C).setFields).length > 0;
}, Z = new WeakSet(), we = function() {
}, Z = new WeakSet(), ge = function() {
return Object.keys(u(this, C).content).length > 0;
};
function ft(...r) {
function dt(...r) {
if (r.length === 0)
throw new O("At least one target must be specified");
return new Ne({
quantity: "many",
throw new N("At least one target must be specified");
if (ye(...r))
throw new N("Multiple targets must be specified seperately");
return new be({
quantity: r.length === 1 ? "one" : "many",
targets: r.join(", "),

@@ -535,4 +549,4 @@ setFields: {},

}
function dt(r, e) {
return new Ne({
function yt(r, e) {
return new be({
quantity: "one",

@@ -548,4 +562,4 @@ targets: `type::thing(${JSON.stringify(r)}, ${JSON.stringify(e)})`,

}
var R, bt, v, j, X, ge, W, $e;
const Je = class {
var R, St, v, L, X, $e, W, Ee;
const De = class {
constructor(e) {

@@ -556,4 +570,4 @@ c(this, v);

c(this, R, void 0);
$(this, bt, !0);
m(this, R, e);
$(this, St, !0);
w(this, R, e);
}

@@ -571,5 +585,5 @@ get _quantity() {

set(e, t) {
if (s(this, W, $e).call(this))
throw new O("Cannot set field when content is set");
return s(this, v, j).call(this, {
if (s(this, W, Ee).call(this))
throw new N("Cannot set field when content is set");
return s(this, v, L).call(this, {
setFields: {

@@ -590,5 +604,5 @@ ...u(this, R).setFields,

setAll(e) {
if (s(this, W, $e).call(this))
throw new O("Cannot set fields when content is set");
return s(this, v, j).call(this, {
if (s(this, W, Ee).call(this))
throw new N("Cannot set fields when content is set");
return s(this, v, L).call(this, {
setFields: {

@@ -610,5 +624,5 @@ ...u(this, R).setFields,

content(e) {
if (s(this, X, ge).call(this))
throw new O("Cannot set content when fields are set");
return s(this, v, j).call(this, {
if (s(this, X, $e).call(this))
throw new N("Cannot set content when fields are set");
return s(this, v, L).call(this, {
content: e,

@@ -628,5 +642,5 @@ contentMode: "replace"

merge(e) {
if (s(this, X, ge).call(this))
throw new O("Cannot set content when fields are set");
return s(this, v, j).call(this, {
if (s(this, X, $e).call(this))
throw new N("Cannot set content when fields are set");
return s(this, v, L).call(this, {
content: e,

@@ -645,3 +659,3 @@ contentMode: "merge"

where(e) {
return typeof e == "object" && (e = ye(e)), s(this, v, j).call(this, { where: e });
return typeof e == "object" && (e = pe(e)), s(this, v, L).call(this, { where: e });
}

@@ -655,3 +669,3 @@ /**

return(e) {
return s(this, v, j).call(this, { returnMode: e });
return s(this, v, L).call(this, { returnMode: e });
}

@@ -665,3 +679,3 @@ /**

returnFields(...e) {
return s(this, v, j).call(this, {
return s(this, v, L).call(this, {
returnMode: "fields",

@@ -678,3 +692,3 @@ returnFields: e

timeout(e) {
return s(this, v, j).call(this, { timeout: e });
return s(this, v, L).call(this, { timeout: e });
}

@@ -687,3 +701,3 @@ /**

parallel() {
return s(this, v, j).call(this, { parallel: !0 });
return s(this, v, L).call(this, { parallel: !0 });
}

@@ -700,3 +714,3 @@ toQuery() {

timeout: f,
parallel: w
parallel: m
} = u(this, R);

@@ -706,24 +720,26 @@ if (!e)

let a = `UPDATE ${e}`;
if (s(this, X, ge).call(this)) {
const h = Ue(i);
if (s(this, X, $e).call(this)) {
const h = ke(i);
h && (a += ` SET ${h}`);
} else
s(this, W, $e).call(this) && (a += ` ${n === "merge" ? "MERGE" : "CONTENT"} ${JSON.stringify(t)}`);
return l && (a += ` WHERE ${l}`), o === "fields" ? a += ` RETURN ${d.join(", ")}` : o && (a += ` RETURN ${o.toUpperCase()}`), f && (a += ` TIMEOUT ${f}s`), w && (a += " PARALLEL"), a;
s(this, W, Ee).call(this) && (a += ` ${n === "merge" ? "MERGE" : "CONTENT"} ${JSON.stringify(t)}`);
return l && (a += ` WHERE ${l}`), o === "fields" ? a += ` RETURN ${d.join(", ")}` : o && (a += ` RETURN ${o.toUpperCase()}`), f && (a += ` TIMEOUT ${f}s`), m && (a += " PARALLEL"), a;
}
};
let Te = Je;
bt = pe, R = new WeakMap(), v = new WeakSet(), j = function(e) {
return new Je({
let Te = De;
St = we, R = new WeakMap(), v = new WeakSet(), L = function(e) {
return new De({
...u(this, R),
...e
});
}, X = new WeakSet(), ge = function() {
}, X = new WeakSet(), $e = function() {
return Object.keys(u(this, R).setFields).length > 0;
}, W = new WeakSet(), $e = function() {
}, W = new WeakSet(), Ee = function() {
return Object.keys(u(this, R).content).length > 0;
};
function yt(...r) {
function pt(...r) {
if (r.length === 0)
throw new O("At least one target must be specified");
throw new N("At least one target must be specified");
if (ye(...r))
throw new N("Multiple targets must be specified seperately");
return new Te({

@@ -742,3 +758,3 @@ quantity: "many",

}
function pt(r, e) {
function wt(r, e) {
return new Te({

@@ -757,9 +773,9 @@ quantity: "maybe",

}
var V, St, k, K;
const De = class {
var V, Ot, k, K;
const Be = class {
constructor(e) {
c(this, k);
c(this, V, void 0);
$(this, St, !0);
m(this, V, e);
$(this, Ot, !0);
w(this, V, e);
}

@@ -778,3 +794,3 @@ get _quantity() {

where(e) {
return typeof e == "object" && (e = ye(e)), s(this, k, K).call(this, { where: e });
return typeof e == "object" && (e = pe(e)), s(this, k, K).call(this, { where: e });
}

@@ -834,5 +850,5 @@ /**

};
let be = De;
St = pe, V = new WeakMap(), k = new WeakSet(), K = function(e) {
return new De({
let Se = Be;
Ot = we, V = new WeakMap(), k = new WeakSet(), K = function(e) {
return new Be({
...u(this, V),

@@ -844,4 +860,6 @@ ...e

if (r.length === 0)
throw new O("At least one target must be specified");
return new be({
throw new N("At least one target must be specified");
if (ye(...r))
throw new N("Multiple targets must be specified seperately");
return new Se({
quantity: "many",

@@ -856,4 +874,4 @@ targets: r.join(", "),

}
function wt(r, e) {
return new be({
function gt(r, e) {
return new Se({
quantity: "maybe",

@@ -868,4 +886,4 @@ targets: `type::thing(${JSON.stringify(r)}, ${JSON.stringify(e)})`,

}
var L, Ot, x, U, he, Ie, ee, Ee;
const Be = class {
var I, vt, x, U, he, Ie, ee, qe;
const ze = class {
constructor(e) {

@@ -875,7 +893,7 @@ c(this, x);

c(this, ee);
c(this, L, void 0);
$(this, Ot, !0);
c(this, I, void 0);
$(this, vt, !0);
$(this, "_schema", Y.undefined());
$(this, "_quantity", "zero");
m(this, L, e);
w(this, I, e);
}

@@ -890,7 +908,7 @@ /**

set(e, t) {
if (s(this, ee, Ee).call(this))
throw new O("Cannot set field when content is set");
if (s(this, ee, qe).call(this))
throw new N("Cannot set field when content is set");
return s(this, x, U).call(this, {
setFields: {
...u(this, L).setFields,
...u(this, I).setFields,
[e]: t

@@ -909,7 +927,7 @@ }

setAll(e) {
if (s(this, ee, Ee).call(this))
throw new O("Cannot set fields when content is set");
if (s(this, ee, qe).call(this))
throw new N("Cannot set fields when content is set");
return s(this, x, U).call(this, {
setFields: {
...u(this, L).setFields,
...u(this, I).setFields,
...e

@@ -930,3 +948,3 @@ }

if (s(this, he, Ie).call(this))
throw new O("Cannot set content when fields are set");
throw new N("Cannot set content when fields are set");
return s(this, x, U).call(this, { content: e });

@@ -982,4 +1000,4 @@ }

timeout: f,
parallel: w
} = u(this, L);
parallel: m
} = u(this, I);
if (!e || !t || !n)

@@ -989,21 +1007,21 @@ throw new Error("From, edge, and to must be defined");

if (s(this, he, Ie).call(this)) {
const h = Ue(l);
const h = ke(l);
h && (a += ` SET ${h}`);
} else
s(this, ee, Ee).call(this) && (a += ` CONTENT ${JSON.stringify(i)}`);
return o === "fields" ? a += ` RETURN ${d.join(", ")}` : o && (a += ` RETURN ${o.toUpperCase()}`), f && (a += ` TIMEOUT ${f}s`), w && (a += " PARALLEL"), a;
s(this, ee, qe).call(this) && (a += ` CONTENT ${JSON.stringify(i)}`);
return o === "fields" ? a += ` RETURN ${d.join(", ")}` : o && (a += ` RETURN ${o.toUpperCase()}`), f && (a += ` TIMEOUT ${f}s`), m && (a += " PARALLEL"), a;
}
};
let je = Be;
Ot = Re, L = new WeakMap(), x = new WeakSet(), U = function(e) {
return new Be({
...u(this, L),
let je = ze;
vt = Fe, I = new WeakMap(), x = new WeakSet(), U = function(e) {
return new ze({
...u(this, I),
...e
});
}, he = new WeakSet(), Ie = function() {
return Object.keys(u(this, L).setFields).length > 0;
}, ee = new WeakSet(), Ee = function() {
return Object.keys(u(this, L).content).length > 0;
return Object.keys(u(this, I).setFields).length > 0;
}, ee = new WeakSet(), qe = function() {
return Object.keys(u(this, I).content).length > 0;
};
function gt(r, e, t) {
function $t(r, e, t) {
return new je({

@@ -1021,11 +1039,11 @@ from: r,

}
function $t(r, e, t, n, i) {
function Et(r, e, t, n, i) {
const l = `type::thing(${JSON.stringify(r)}, ${JSON.stringify(e)})`, o = `type::thing(${JSON.stringify(n)}, ${JSON.stringify(i)})`;
return gt(l, t, o);
return $t(l, t, o);
}
var P, J, Q, te, re, S, A, Se, Ze;
const ze = class {
var P, J, Q, te, re, O, A, Oe, Xe;
const Ge = class {
constructor(e, t, n) {
c(this, S);
c(this, Se);
c(this, O);
c(this, Oe);
c(this, P, void 0);

@@ -1036,3 +1054,3 @@ c(this, J, void 0);

c(this, re, void 0);
m(this, P, e), m(this, Q, t), m(this, J, n || {});
w(this, P, e), w(this, Q, t), w(this, J, n || {});
}

@@ -1049,3 +1067,3 @@ /**

query(e) {
return s(this, S, A).call(this, {
return s(this, O, A).call(this, {
query: e.query,

@@ -1064,3 +1082,3 @@ schema: e.schema

selectMany(e) {
return s(this, S, A).call(this, {
return s(this, O, A).call(this, {
query: e.query,

@@ -1081,3 +1099,3 @@ schema: e.schema.array()

let t = e.query;
return t instanceof qe && (t = t.limit(1)), s(this, S, A).call(this, {
return t instanceof Ne && (t = t.limit(1)), s(this, O, A).call(this, {
query: e.query,

@@ -1101,4 +1119,4 @@ schema: e.schema.nullable(),

create(e) {
const t = e.id ? dt(e.table, e.id) : ft(e.table);
return s(this, S, A).call(this, {
const t = e.id ? yt(e.table, e.id) : dt(e.table);
return s(this, O, A).call(this, {
query: t.setAll(e.data),

@@ -1122,4 +1140,4 @@ schema: e.schema,

update(e) {
const t = e.id ? pt(e.table, e.id) : yt(e.table);
return s(this, S, A).call(this, {
const t = e.id ? wt(e.table, e.id) : pt(e.table);
return s(this, O, A).call(this, {
query: t.setAll(e.data),

@@ -1140,4 +1158,4 @@ schema: e.schema,

delete(e) {
let t = e.id ? wt(e.table, e.id) : mt(e.table);
return e.where && (t = t.where(e.where)), s(this, S, A).call(this, {
let t = e.id ? gt(e.table, e.id) : mt(e.table);
return e.where && (t = t.where(e.where)), s(this, O, A).call(this, {
query: t,

@@ -1156,4 +1174,4 @@ schema: Y.undefined(),

count(e) {
let t = ht("count()").from(e.table).groupAll();
return e.where && (t = t.where(e.where)), s(this, S, A).call(this, {
let t = ft("count()").from(e.table).groupAll();
return e.where && (t = t.where(e.where)), s(this, O, A).call(this, {
query: t,

@@ -1175,4 +1193,4 @@ schema: Y.number(),

relate(e) {
let t = $t(e.fromTable, e.fromId, e.edge, e.toTable, e.toId);
return e.data && (t = t.setAll(e.data)), s(this, S, A).call(this, {
let t = Et(e.fromTable, e.fromId, e.edge, e.toTable, e.toId);
return e.data && (t = t.setAll(e.data)), s(this, O, A).call(this, {
query: t,

@@ -1192,3 +1210,3 @@ schema: Y.undefined(),

let t;
return typeof e.value == "object" && "toQuery" in e.value ? t = `(${e.value.toQuery()})` : t = y(e.value), s(this, S, A).call(this, {
return typeof e.value == "object" && "toQuery" in e.value ? t = `(${e.value.toQuery()})` : t = y(e.value), s(this, O, A).call(this, {
query: `LET $${e.name} = ${t}`,

@@ -1213,3 +1231,3 @@ schema: Y.undefined(),

const i = le(e.if) ? e.if[G] : me(e.if), l = le(e.then) ? e.then[G] : me(e.then), o = le(e.else) ? e.else[G] : me(e.else);
return s(this, S, A).call(this, {
return s(this, O, A).call(this, {
query: `IF ${i} THEN (${l}) ELSE (${o}) END`,

@@ -1230,3 +1248,3 @@ schema: t.or(n)

return [];
const e = s(this, Se, Ze).call(this), t = [];
const e = s(this, Oe, Xe).call(this), t = [];
u(this, P).onLog(e, u(this, J));

@@ -1237,3 +1255,3 @@ const n = await u(this, P).onQuery(e, u(this, J));

for (let i = 0; i < n.length; i++) {
const { schema: l, transform: o, skip: d } = u(this, Q)[i], { status: f, result: w } = n[i];
const { schema: l, transform: o, skip: d } = u(this, Q)[i], { status: f, result: m } = n[i];
if (f !== "OK")

@@ -1244,5 +1262,5 @@ throw new q(`Query ${i + 1} returned a non-successful status code: ${f}`, "invalid_response");

else {
const a = o ? o(w) : w, h = l.safeParse(a);
const a = o ? o(m) : m, h = l.safeParse(a);
if (!h.success)
throw new Ke(`Query ${i + 1} failed to parse`, h.error);
throw new Ze(`Query ${i + 1} failed to parse`, h.error);
t.push(h.data);

@@ -1272,11 +1290,11 @@ }

transaction() {
return m(this, te, "BEGIN TRANSACTION"), m(this, re, "COMMIT TRANSACTION"), this.execute();
return w(this, te, "BEGIN TRANSACTION"), w(this, re, "COMMIT TRANSACTION"), this.execute();
}
};
let Le = ze;
P = new WeakMap(), J = new WeakMap(), Q = new WeakMap(), te = new WeakMap(), re = new WeakMap(), S = new WeakSet(), A = function(e, t) {
let xe = Ge;
P = new WeakMap(), J = new WeakMap(), Q = new WeakMap(), te = new WeakMap(), re = new WeakMap(), O = new WeakSet(), A = function(e, t) {
for (const n of Object.keys(t))
if (u(this, J)[n])
throw new Error(`Duplicate parameter name: ${n}`);
return new ze(
return new Ge(
u(this, P),

@@ -1286,3 +1304,3 @@ [...u(this, Q), e],

);
}, Se = new WeakSet(), Ze = function() {
}, Oe = new WeakSet(), Xe = function() {
let e = u(this, Q).map((t) => me(t.query));

@@ -1292,14 +1310,14 @@ return u(this, te) && (e = [u(this, te), ...e]), u(this, re) && (e = [...e, u(this, re)]), e.join(`;

};
function Et(r) {
return Re in r;
function qt(r) {
return Fe in r;
}
var D, fe, xe, Oe, We, ve, et;
class Xe extends EventTarget {
var D, fe, Qe, ve, et, Ae, tt;
class We extends EventTarget {
constructor(t) {
super();
c(this, fe);
c(this, Oe);
c(this, ve);
c(this, Ae);
c(this, D, void 0);
m(this, D, t);
w(this, D, t);
}

@@ -1311,3 +1329,3 @@ async execute(t) {

async batch(...t) {
return s(this, fe, xe).call(this, {
return s(this, fe, Qe).call(this, {
queries: t,

@@ -1319,3 +1337,3 @@ prefix: "",

async transaction(...t) {
return s(this, fe, xe).call(this, {
return s(this, fe, Qe).call(this, {
queries: t,

@@ -1329,3 +1347,3 @@ prefix: "BEGIN TRANSACTION",

prepare() {
return new Le(u(this, D), []);
return new xe(u(this, D), []);
}

@@ -1373,3 +1391,3 @@ /** @deprecated Use the new Query API instead */

}
D = new WeakMap(), fe = new WeakSet(), xe = async function(t) {
D = new WeakMap(), fe = new WeakSet(), Qe = async function(t) {
var d;

@@ -1380,3 +1398,3 @@ if (!u(this, D).onRequest())

return [];
const n = s(this, ve, et).call(this, t), i = s(this, Oe, We).call(this, t), l = [];
const n = s(this, Ae, tt).call(this, t), i = s(this, ve, et).call(this, t), l = [];
u(this, D).onLog(i, n);

@@ -1387,14 +1405,14 @@ const o = await u(this, D).onQuery(i, n);

for (let f = 0; f < o.length; f++) {
const { query: w, schema: a } = t.queries[f], { status: h, result: g, detail: E } = o[f], b = w._quantity;
const { query: m, schema: a } = t.queries[f], { status: h, result: g, detail: E } = o[f], S = m._quantity;
if (h !== "OK")
throw new q(`Query ${f + 1} returned a non-successful status code: ${h}: ${E}`, "invalid_response");
if (b == "zero") {
if (S == "zero") {
l.push(void 0);
continue;
}
const F = ((d = w._transform) == null ? void 0 : d.call(w, g)) ?? g, M = (Et(w) ? w._schema : a).array().safeParse(F);
const F = ((d = m._transform) == null ? void 0 : d.call(m, g)) ?? g, M = (qt(m) ? m._schema : a).array().safeParse(F);
if (!M.success)
throw new Ke(`Query ${f + 1} failed to parse`, M.error);
if (b == "one" || b == "maybe") {
if (b == "one" && M.data.length === 0)
throw new Ze(`Query ${f + 1} failed to parse`, M.error);
if (S == "one" || S == "maybe") {
if (S == "one" && M.data.length === 0)
throw new q(`Query ${f + 1} expected at least one result but got ${M.data.length}`, "invalid_response");

@@ -1408,7 +1426,7 @@ if (M.data.length > 1)

return l;
}, Oe = new WeakSet(), We = function(t) {
}, ve = new WeakSet(), et = function(t) {
let n = t.queries.map((i) => i.query.toQuery());
return t.prefix && (n = [t.prefix, ...n]), t.suffix && (n = [...n, t.suffix]), n.join(`;
`);
}, ve = new WeakSet(), et = function(t) {
}, Ae = new WeakSet(), tt = function(t) {
const n = {};

@@ -1424,3 +1442,3 @@ for (const i of t.queries)

var ne, B, z, se, ie;
class Mt extends Xe {
class Lt extends We {
constructor(t) {

@@ -1465,15 +1483,15 @@ super({

connect() {
u(this, z) || u(this, B) || (this.dispatchEvent(new Event("connect")), m(this, B, !0), m(this, ne, lt({
u(this, z) || u(this, B) || (this.dispatchEvent(new Event("connect")), w(this, B, !0), w(this, ne, ct({
connection: this.options.connection,
credentials: this.options.credentials,
onConnect: () => {
clearTimeout(u(this, ie)), m(this, se, 0), m(this, ie, void 0), m(this, z, !0), m(this, B, !1), this.dispatchEvent(new Event("open"));
clearTimeout(u(this, ie)), w(this, se, 0), w(this, ie, void 0), w(this, z, !0), w(this, B, !1), this.dispatchEvent(new Event("open"));
},
onDisconnect: (t, n) => {
m(this, z, !1), m(this, B, !1), this.dispatchEvent(new ut(t, n));
w(this, z, !1), w(this, B, !1), this.dispatchEvent(new ot(t, n));
const { retryCount: i, retryDelay: l } = this.options;
(i < 0 || i > 0 && u(this, se) < i) && (He(this, se)._++, m(this, ie, setTimeout(() => this.connect(), l)));
(i < 0 || i > 0 && u(this, se) < i) && (Ve(this, se)._++, w(this, ie, setTimeout(() => this.connect(), l)));
},
onError: (t) => {
this.dispatchEvent(new ot(t));
this.dispatchEvent(new at(t));
}

@@ -1501,7 +1519,7 @@ })));

ne = new WeakMap(), B = new WeakMap(), z = new WeakMap(), se = new WeakMap(), ie = new WeakMap();
var Ae, tt;
class jt extends Xe {
var Ce, rt;
class jt extends We {
constructor(t) {
super({
onQuery: (n, i) => s(this, Ae, tt).call(this, n, i),
onQuery: (n, i) => s(this, Ce, rt).call(this, n, i),
onRequest: () => !0,

@@ -1512,3 +1530,3 @@ onLog: (n, i) => {

});
c(this, Ae);
c(this, Ce);
$(this, "options");

@@ -1522,6 +1540,6 @@ this.options = {

}
Ae = new WeakSet(), tt = async function(t, n) {
Ce = new WeakSet(), rt = async function(t, n) {
if (Object.keys(n).length > 0)
throw new q("Stateless queries do not support parameters yet. ", "invalid_request");
const { endpoint: i, namespace: l, database: o } = this.options.connection, { user: d, pass: f, DB: w, NS: a, SC: h, token: g } = this.options.credentials, E = new URL("sql", i);
const { endpoint: i, namespace: l, database: o } = this.options.connection, { user: d, pass: f, DB: m, NS: a, SC: h, token: g } = this.options.credentials, E = new URL("sql", i);
if (!d && !f && !g)

@@ -1534,3 +1552,3 @@ throw new q("Missing username & password or token", "invalid_request");

};
return (a || l) && (F.NS = a || l), (w || o) && (F.DB = w || o), h && (F.SC = h), await fetch(E, {
return (a || l) && (F.NS = a || l), (m || o) && (F.DB = m || o), h && (F.SC = h), await fetch(E, {
method: "POST",

@@ -1541,11 +1559,11 @@ headers: F,

};
var ue, vt, Ce, rt;
const Ge = class {
var ue, At, Re, nt;
const Ye = class {
constructor(e) {
c(this, Ce);
c(this, Re);
c(this, ue, void 0);
$(this, vt, !0);
$(this, At, !0);
$(this, "_schema", Y.number());
$(this, "_quantity", "one");
m(this, ue, e);
w(this, ue, e);
}

@@ -1561,3 +1579,3 @@ /**

where(e) {
return typeof e == "object" && (e = ye(e)), s(this, Ce, rt).call(this, { where: e });
return typeof e == "object" && (e = pe(e)), s(this, Re, nt).call(this, { where: e });
}

@@ -1578,5 +1596,5 @@ toQuery() {

};
let Qe = Ge;
vt = Re, ue = new WeakMap(), Ce = new WeakSet(), rt = function(e) {
return new Ge({
let _e = Ye;
At = Fe, ue = new WeakMap(), Re = new WeakSet(), nt = function(e) {
return new Ye({
...u(this, ue),

@@ -1587,3 +1605,3 @@ ...e

function It(r) {
return new Qe({
return new _e({
target: r,

@@ -1593,9 +1611,9 @@ where: void 0

}
var oe, de, At;
const Ye = class {
var oe, de, Ct;
const He = class {
constructor(e, t) {
c(this, oe, void 0);
c(this, de, void 0);
$(this, At, !0);
m(this, oe, e), m(this, de, t);
$(this, Ct, !0);
w(this, oe, e), w(this, de, t);
}

@@ -1611,3 +1629,3 @@ get _quantity() {

single() {
return new Ye(u(this, oe), "maybe");
return new He(u(this, oe), "maybe");
}

@@ -1618,14 +1636,14 @@ toQuery() {

};
let _e = Ye;
At = pe, oe = new WeakMap(), de = new WeakMap();
function Lt(r) {
return new _e(r, "many");
let Ue = He;
Ct = we, oe = new WeakMap(), de = new WeakMap();
function xt(r) {
return new Ue(r, "many");
}
const qt = /^[a-zA-Z0-9_]*$/;
function xt(r, e) {
if (!qt.test(r))
const Nt = /^[a-zA-Z0-9_]*$/;
function Qt(r, e) {
if (!Nt.test(r))
throw new Error(`Invalid LET name: ${r}`);
let t;
return typeof e == "object" && "toQuery" in e ? t = `(${e.toQuery()})` : t = y(e), {
[Re]: !0,
[Fe]: !0,
_quantity: "zero",

@@ -1643,140 +1661,140 @@ _schema: Y.undefined(),

}
function Qt(r) {
function _t(r) {
return p(`= ${y(r)}`);
}
function _t(r) {
function Ut(r) {
return p(`!= ${y(r)}`);
}
function Ut(r) {
function kt(r) {
return p(`== ${y(r)}`);
}
function kt(r) {
function Pt(r) {
return p(`?= ${y(r)}`);
}
function Pt(r) {
function Jt(r) {
return p(`*= ${y(r)}`);
}
function Jt(r) {
function Dt(r) {
return p(`~ ${y(r)}`);
}
function Dt(r) {
function Bt(r) {
return p(`!~ ${y(r)}`);
}
function Bt(r) {
function zt(r) {
return p(`?~ ${y(r)}`);
}
function zt(r) {
function Gt(r) {
return p(`*~ ${y(r)}`);
}
function Gt(r) {
function Yt(r) {
return p(`< ${y(r)}`);
}
function Yt(r) {
function Ht(r) {
return p(`<= ${y(r)}`);
}
function Ht(r) {
function Vt(r) {
return p(`> ${y(r)}`);
}
function Vt(r) {
function Kt(r) {
return p(`>= ${y(r)}`);
}
function Kt(r) {
function Zt(r) {
return p(`CONTAINS ${y(r)}`);
}
function Zt(r) {
function Xt(r) {
return p(`CONTAINSNOT ${y(r)}`);
}
function Xt(r) {
function Wt(r) {
return p(`CONTAINSALL ${y(r)}`);
}
function Wt(r) {
function er(r) {
return p(`CONTAINSANY ${y(r)}`);
}
function er(r) {
function tr(r) {
return p(`CONTAINSNONE ${y(r)}`);
}
function tr(r) {
function rr(r) {
return p(`INSIDE ${y(r)}`);
}
function rr(r) {
function nr(r) {
return p(`NOTINSIDE ${y(r)}`);
}
function nr(r) {
function sr(r) {
return p(`ALLINSIDE ${y(r)}`);
}
function sr(r) {
function ir(r) {
return p(`ANYINSIDE ${y(r)}`);
}
function ir(r) {
function ur(r) {
return p(`NONEINSIDE ${y(r)}`);
}
function ur(r) {
function or(r) {
return p(`OUTSIDE ${y(r)}`);
}
function or(r) {
function ar(r) {
return p(`INTERSECTS ${y(r)}`);
}
function ar(r) {
function lr(r) {
return p(`+= ${y(r)}`);
}
function lr(r) {
function cr(r) {
return p(`-= ${y(r)}`);
}
function cr() {
function hr() {
return p("time::now()");
}
export {
Mt as Cirql,
Lt as Cirql,
q as CirqlError,
Ke as CirqlParseError,
Le as CirqlQuery,
Ze as CirqlParseError,
xe as CirqlQuery,
jt as CirqlStateless,
O as CirqlWriterError,
Qe as CountQueryWriter,
Ne as CreateQueryWriter,
be as DeleteQueryWriter,
N as CirqlWriterError,
_e as CountQueryWriter,
be as CreateQueryWriter,
Se as DeleteQueryWriter,
je as RelateQueryWriter,
qe as SelectQueryWriter,
Ne as SelectQueryWriter,
Te as UpdateQueryWriter,
ar as add,
Pt as all,
nr as allInside,
kt as any,
sr as anyInside,
Kt as contains,
Xt as containsAll,
Wt as containsAny,
er as containsNone,
Zt as containsNot,
lr as add,
Jt as all,
sr as allInside,
Pt as any,
ir as anyInside,
Zt as contains,
Wt as containsAll,
er as containsAny,
tr as containsNone,
Xt as containsNot,
It as count,
ft as create,
dt as createRecord,
dt as create,
yt as createRecord,
mt as del,
wt as delRecord,
Ut as eeq,
Qt as eq,
zt as fall,
Bt as fany,
Jt as feq,
Ht as gt,
Vt as gte,
tr as inside,
or as intersects,
xt as letValue,
Gt as lt,
Yt as lte,
_t as neq,
Dt as nfeq,
ir as noneInside,
rr as notInside,
ur as outside,
Lt as query,
gt as delRecord,
kt as eeq,
_t as eq,
Gt as fall,
zt as fany,
Dt as feq,
Vt as gt,
Kt as gte,
rr as inside,
ar as intersects,
Qt as letValue,
Yt as lt,
Ht as lte,
Ut as neq,
Bt as nfeq,
ur as noneInside,
nr as notInside,
or as outside,
xt as query,
p as raw,
gt as relate,
$t as relateRecords,
lr as remove,
ht as select,
cr as timeNow,
yt as update,
pt as updateRecord
$t as relate,
Et as relateRecords,
cr as remove,
ft as select,
hr as timeNow,
pt as update,
wt as updateRecord
};

@@ -184,3 +184,4 @@ import { ZodTypeAny, ZodNumber, z, ZodUndefined, TypeOf, ZodArray, ZodNullable, input, ZodError } from 'zod';

*/
declare function create(...targets: string[]): CreateQueryWriter<"many">;
declare function create(target: string): CreateQueryWriter<'one'>;
declare function create(...targets: string[]): CreateQueryWriter<'many'>;
/**

@@ -187,0 +188,0 @@ * Start a new CREATE query for the given record. This function

{
"name": "cirql",
"version": "0.2.3",
"version": "0.2.4",
"type": "module",

@@ -5,0 +5,0 @@ "files": [

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