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.2 to 0.2.3

955

dist/cirql.js

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

var He = Object.defineProperty;
var Ke = (r, e, t) => e in r ? He(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
var q = (r, e, t) => (Ke(r, typeof e != "symbol" ? e + "" : e, t), t), ve = (r, e, t) => {
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) => {
if (!e.has(r))
throw TypeError("Cannot " + t);
};
var u = (r, e, t) => (ve(r, e, "read from private field"), t ? t.call(r) : e.get(r)), f = (r, e, t) => {
var u = (r, e, t) => (Fe(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);
}, g = (r, e, t, n) => (ve(r, e, "write to private field"), n ? n.call(r, t) : e.set(r, t), t), ke = (r, e, t, n) => ({
}, 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) => ({
set _(i) {
g(r, e, i, t);
m(r, e, i, t);
},

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

}
}), s = (r, e, t) => (ve(r, e, "access private method"), t);
import Ve from "isomorphic-ws";
import { z as ue } from "zod";
class We extends Event {
}), s = (r, e, t) => (Fe(r, e, "access private method"), t);
import it from "isomorphic-ws";
import { z as Y } from "zod";
class ut extends Event {
constructor(t, n) {
super("close");
q(this, "code");
q(this, "reason");
$(this, "code");
$(this, "reason");
this.code = t, this.reason = n;
}
}
class Ze extends Event {
class ot extends Event {
constructor(t) {
super("error");
q(this, "error");
$(this, "error");
this.error = t;
}
}
const z = Symbol("Query Raw"), Pe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
function Xe(r) {
const G = Symbol("Query Raw"), Ve = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
function at(r) {
let e = "";
for (let t = 0; t < 7; t++)
e += Pe.charAt(Math.floor(Math.random() * Pe.length));
e += Ve.charAt(Math.floor(Math.random() * Ve.length));
return r ? `${e}_${r}` : e;
}
function he(r) {
function me(r) {
return typeof r == "string" ? r : r.toQuery();
}
function oe(r) {
return typeof r == "object" && !!r[z];
function le(r) {
return typeof r == "object" && !!r[G];
}
function y(r) {
return oe(r) ? r[z] : r === null ? "NONE" : JSON.stringify(r);
return le(r) ? r[G] : r === null ? "NONE" : JSON.stringify(r);
}
function et(r) {
const e = new URL("rpc", r.connection.endpoint.replace("http", "ws")), t = setInterval(() => o("ping"), 3e4), n = new Ve(e), i = /* @__PURE__ */ new Map();
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();
let l = !1;
const o = (a, c = []) => {
const w = Xe();
return new Promise(($, S) => {
i.set(w, [$, S]), n.send(JSON.stringify({
id: w,
const o = (a, h = []) => {
const g = at();
return new Promise((E, b) => {
i.set(g, [E, b]), n.send(JSON.stringify({
id: g,
method: a,
params: c
params: h
})), setTimeout(() => {
i.delete(w) && S(new Error("Request timed out"));
i.delete(g) && b(new Error("Request timed out"));
}, 5e3);
});
}, d = (a, c) => {
var w;
clearInterval(t), (w = r.onDisconnect) == null || w.call(r, a, c);
}, h = () => {
}, d = (a, h) => {
var g;
clearInterval(t), (g = r.onDisconnect) == null || g.call(r, a, h);
}, f = () => {
l = !0, n.close(), d(-1, "connection terminated");
}, m = async (a, c) => o("query", c ? [a, c] : [a]);
}, w = async (a, h) => o("query", h ? [a, h] : [a]);
return n.addEventListener("open", async () => {
var w;
const { namespace: a, database: c } = r.connection;
var g;
const { namespace: a, database: h } = r.connection;
try {
"token" in r.credentials ? await o("authenticate", [r.credentials.token]) : await o("signin", [r.credentials]);
} catch {
h();
f();
return;
}
a && c && o("use", [a, c]), (w = r.onConnect) == null || w.call(r);
a && h && o("use", [a, h]), (g = r.onConnect) == null || g.call(r);
}), n.addEventListener("close", (a) => {
l || d(a.code, a.reason);
}), n.addEventListener("message", (a) => {
const { id: c, result: w, method: $, error: S } = JSON.parse(a.data);
if ($ !== "notify")
if (!i.has(c))
const { id: h, result: g, method: E, error: b } = JSON.parse(a.data);
if (E !== "notify")
if (!i.has(h))
console.warn("No callback for message", a.data);
else {
const [F, ie] = i.get(c);
i.delete(c), S ? ie(S) : F(w);
const [F, ae] = i.get(h);
i.delete(h), b ? ae(b) : F(g);
}
}), n.addEventListener("error", (a) => {
var c;
(c = r.onError) == null || c.call(r, a.error);
var h;
(h = r.onError) == null || h.call(r, a.error);
}), {
close: h,
query: m
close: f,
query: w
};
}
const tt = (r) => r.errors.map((t) => `- @${t.path.join(".")}: ${t.message}`).join(`
const ct = (r) => r.errors.map((t) => `- @${t.path.join(".")}: ${t.message}`).join(`
`);
class E extends Error {
class q extends Error {
constructor(t, n) {
super(t);
q(this, "code");
$(this, "code");
this.code = n;
}
}
class _e extends E {
class Ke extends q {
constructor(t, n) {
super(t + `
` + tt(n), "parse_failure");
q(this, "reason");
` + ct(n), "parse_failure");
$(this, "reason");
this.reason = n;
}
}
class v extends E {
class O extends q {
constructor(t, n) {
super(t, "invalid_query");
q(this, "query");
$(this, "query");
this.query = n;
}
}
function Ie(r) {
function Ue(r) {
const e = [];

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

if (typeof o == "object" && !Array.isArray(o)) {
const d = o[z];
const d = o[G];
d ? e.push(`${i}${l} ${d}`) : t(o, `${i}${l}.`);

@@ -141,3 +141,3 @@ } else

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

@@ -148,23 +148,23 @@ for (const n of e)

if (i === void 0)
throw new E("Received expected undefined property in where clause", "invalid_request");
throw new q("Received expected undefined property in where clause", "invalid_request");
for (const o of i)
l.push(`(${Se(o)})`);
l.push(`(${ye(o)})`);
t.push(`(${l.join(` ${n} `)})`);
} else {
const i = r[n];
oe(i) ? t.push(`${n} ${i[z]}`) : t.push(`${n} = ${JSON.stringify(i)}`);
le(i) ? t.push(`${n} ${i[G]}`) : t.push(`${n} = ${JSON.stringify(i)}`);
}
return t.join(" AND ");
}
const be = Symbol("Fuzzy Query"), Je = Symbol("Dynamic Query");
var G, ft, N, T;
const Me = class {
const pe = Symbol("Fuzzy Query"), Re = Symbol("Dynamic Query");
var H, Nt, N, T;
const ke = class {
constructor(e) {
f(this, N);
f(this, G, void 0);
q(this, ft, !0);
g(this, G, e);
c(this, N);
c(this, H, void 0);
$(this, Nt, !0);
m(this, H, e);
}
get _quantity() {
return u(this, G).quantity;
return u(this, H).quantity;
}

@@ -208,3 +208,3 @@ /**

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

@@ -315,7 +315,7 @@ /**

limit: d,
start: h,
fetch: m,
start: f,
fetch: w,
timeout: a,
parallel: c
} = u(this, G);
parallel: h
} = u(this, H);
if (e) {

@@ -326,20 +326,20 @@ if (!t)

throw new Error("No projections specified");
const w = Object.entries(o);
let $ = `SELECT ${e} FROM ${t}`;
if (n && ($ += ` WHERE ${n}`), i.length > 0 && ($ += ` SPLIT ${i.join(", ")}`), l === "all" ? $ += " GROUP BY ALL" : l.length > 0 && ($ += ` GROUP BY ${l.join(", ")}`), w.length > 0) {
const S = w.map(([F, ie]) => `${F} ${ie.toUpperCase()}`);
$ += ` ORDER BY ${S.join(", ")}`;
const g = Object.entries(o);
let E = `SELECT ${e} FROM ${t}`;
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(", ")}`;
}
return d && ($ += ` LIMIT BY ${d}`), h && ($ += ` START AT ${h}`), m.length > 0 && ($ += ` FETCH ${m.join(", ")}`), a && ($ += ` TIMEOUT ${a}s`), c && ($ += " PARALLEL"), $;
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;
}
};
let me = Me;
ft = be, G = new WeakMap(), N = new WeakSet(), T = function(e) {
return new Me({
...u(this, G),
let qe = ke;
Nt = pe, H = new WeakMap(), N = new WeakSet(), T = function(e) {
return new ke({
...u(this, H),
...e
});
};
function rt(...r) {
return new me({
function ht(...r) {
return new qe({
quantity: "many",

@@ -359,14 +359,14 @@ projections: r.join(", ") || "*",

}
var A, dt, j, U, ae, Oe, V, fe;
const je = class {
var C, Tt, I, _, ce, Me, Z, we;
const Pe = class {
constructor(e) {
f(this, j);
f(this, ae);
f(this, V);
f(this, A, void 0);
q(this, dt, !0);
g(this, A, e);
c(this, I);
c(this, ce);
c(this, Z);
c(this, C, void 0);
$(this, Tt, !0);
m(this, C, e);
}
get _quantity() {
return u(this, A).quantity;
return u(this, C).quantity;
}

@@ -381,7 +381,7 @@ /**

set(e, t) {
if (s(this, V, fe).call(this))
throw new v("Cannot set field when content is set");
return s(this, j, U).call(this, {
if (s(this, Z, we).call(this))
throw new O("Cannot set field when content is set");
return s(this, I, _).call(this, {
setFields: {
...u(this, A).setFields,
...u(this, C).setFields,
[e]: t

@@ -400,7 +400,7 @@ }

setAll(e) {
if (s(this, V, fe).call(this))
throw new v("Cannot set fields when content is set");
return s(this, j, U).call(this, {
if (s(this, Z, we).call(this))
throw new O("Cannot set fields when content is set");
return s(this, I, _).call(this, {
setFields: {
...u(this, A).setFields,
...u(this, C).setFields,
...e

@@ -420,5 +420,5 @@ }

content(e) {
if (s(this, ae, Oe).call(this))
throw new v("Cannot set content when fields are set");
return s(this, j, U).call(this, { 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 });
}

@@ -432,3 +432,3 @@ /**

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

@@ -442,3 +442,3 @@ /**

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

@@ -455,3 +455,3 @@ returnFields: e

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

@@ -464,3 +464,3 @@ /**

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

@@ -476,26 +476,26 @@ toQuery() {

parallel: d
} = u(this, A);
} = u(this, C);
if (!e)
throw new Error("No targets specified");
let h = `CREATE ${e}`;
if (s(this, ae, Oe).call(this)) {
const m = Ie(n);
m && (h += ` SET ${m}`);
let f = `CREATE ${e}`;
if (s(this, ce, Me).call(this)) {
const w = Ue(n);
w && (f += ` SET ${w}`);
} else
s(this, V, fe).call(this) && (h += ` CONTENT ${JSON.stringify(t)}`);
return i === "fields" ? h += ` RETURN ${l.join(", ")}` : i && (h += ` RETURN ${i.toUpperCase()}`), o && (h += ` TIMEOUT ${o}s`), d && (h += " PARALLEL"), h;
s(this, Z, we).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 ge = je;
dt = be, A = new WeakMap(), j = new WeakSet(), U = function(e) {
return new je({ ...u(this, A), ...e });
}, ae = new WeakSet(), Oe = function() {
return Object.keys(u(this, A).setFields).length > 0;
}, V = new WeakSet(), fe = function() {
return Object.keys(u(this, A).content).length > 0;
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() {
return Object.keys(u(this, C).setFields).length > 0;
}, Z = new WeakSet(), we = function() {
return Object.keys(u(this, C).content).length > 0;
};
function nt(...r) {
function ft(...r) {
if (r.length === 0)
throw new v("At least one target must be specified");
return new ge({
throw new O("At least one target must be specified");
return new Ne({
quantity: "many",

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

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

@@ -524,11 +524,11 @@ targets: `type::thing(${JSON.stringify(r)}, ${JSON.stringify(e)})`,

}
var R, yt, O, M, W, de, Z, ye;
const Le = class {
var R, bt, v, j, X, ge, W, $e;
const Je = class {
constructor(e) {
f(this, O);
f(this, W);
f(this, Z);
f(this, R, void 0);
q(this, yt, !0);
g(this, R, e);
c(this, v);
c(this, X);
c(this, W);
c(this, R, void 0);
$(this, bt, !0);
m(this, R, e);
}

@@ -546,5 +546,5 @@ get _quantity() {

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

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

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

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

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

@@ -603,5 +603,5 @@ contentMode: "replace"

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

@@ -620,3 +620,3 @@ contentMode: "merge"

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

@@ -630,3 +630,3 @@ /**

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

@@ -640,3 +640,3 @@ /**

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

@@ -653,3 +653,3 @@ returnFields: e

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

@@ -662,3 +662,3 @@ /**

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

@@ -674,4 +674,4 @@ toQuery() {

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

@@ -681,25 +681,25 @@ if (!e)

let a = `UPDATE ${e}`;
if (s(this, W, de).call(this)) {
const c = Ie(i);
c && (a += ` SET ${c}`);
if (s(this, X, ge).call(this)) {
const h = Ue(i);
h && (a += ` SET ${h}`);
} else
s(this, Z, ye).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()}`), h && (a += ` TIMEOUT ${h}s`), m && (a += " PARALLEL"), a;
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;
}
};
let we = Le;
yt = be, R = new WeakMap(), O = new WeakSet(), M = function(e) {
return new Le({
let Te = Je;
bt = pe, R = new WeakMap(), v = new WeakSet(), j = function(e) {
return new Je({
...u(this, R),
...e
});
}, W = new WeakSet(), de = function() {
}, X = new WeakSet(), ge = function() {
return Object.keys(u(this, R).setFields).length > 0;
}, Z = new WeakSet(), ye = function() {
}, W = new WeakSet(), $e = function() {
return Object.keys(u(this, R).content).length > 0;
};
function it(...r) {
function yt(...r) {
if (r.length === 0)
throw new v("At least one target must be specified");
return new we({
throw new O("At least one target must be specified");
return new Te({
quantity: "many",

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

}
function ut(r, e) {
return new we({
function pt(r, e) {
return new Te({
quantity: "maybe",

@@ -732,12 +732,12 @@ targets: `type::thing(${JSON.stringify(r)}, ${JSON.stringify(e)})`,

}
var H, pt, P, K;
const xe = class {
var V, St, k, K;
const De = class {
constructor(e) {
f(this, P);
f(this, H, void 0);
q(this, pt, !0);
g(this, H, e);
c(this, k);
c(this, V, void 0);
$(this, St, !0);
m(this, V, e);
}
get _quantity() {
return u(this, H).quantity;
return u(this, V).quantity;
}

@@ -753,3 +753,3 @@ /**

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

@@ -763,3 +763,3 @@ /**

return(e) {
return s(this, P, K).call(this, { returnMode: e });
return s(this, k, K).call(this, { returnMode: e });
}

@@ -773,3 +773,3 @@ /**

returnFields(...e) {
return s(this, P, K).call(this, {
return s(this, k, K).call(this, {
returnMode: "fields",

@@ -786,3 +786,3 @@ returnFields: e

timeout(e) {
return s(this, P, K).call(this, { timeout: e });
return s(this, k, K).call(this, { timeout: e });
}

@@ -795,3 +795,3 @@ /**

parallel() {
return s(this, P, K).call(this, { parallel: !0 });
return s(this, k, K).call(this, { parallel: !0 });
}

@@ -806,3 +806,3 @@ toQuery() {

parallel: o
} = u(this, H);
} = u(this, V);
if (!e)

@@ -814,13 +814,13 @@ throw new Error("No targets specified");

};
let $e = xe;
pt = be, H = new WeakMap(), P = new WeakSet(), K = function(e) {
return new xe({
...u(this, H),
let be = De;
St = pe, V = new WeakMap(), k = new WeakSet(), K = function(e) {
return new De({
...u(this, V),
...e
});
};
function ot(...r) {
function mt(...r) {
if (r.length === 0)
throw new v("At least one target must be specified");
return new $e({
throw new O("At least one target must be specified");
return new be({
quantity: "many",

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

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

@@ -847,13 +847,13 @@ targets: `type::thing(${JSON.stringify(r)}, ${JSON.stringify(e)})`,

}
var L, mt, x, k, le, Ae, X, pe;
const Qe = class {
var L, Ot, x, U, he, Ie, ee, Ee;
const Be = class {
constructor(e) {
f(this, x);
f(this, le);
f(this, X);
f(this, L, void 0);
q(this, mt, !0);
q(this, "_schema", ue.undefined());
q(this, "_quantity", "zero");
g(this, L, e);
c(this, x);
c(this, he);
c(this, ee);
c(this, L, void 0);
$(this, Ot, !0);
$(this, "_schema", Y.undefined());
$(this, "_quantity", "zero");
m(this, L, e);
}

@@ -868,5 +868,5 @@ /**

set(e, t) {
if (s(this, X, pe).call(this))
throw new v("Cannot set field when content is set");
return s(this, x, k).call(this, {
if (s(this, ee, Ee).call(this))
throw new O("Cannot set field when content is set");
return s(this, x, U).call(this, {
setFields: {

@@ -887,5 +887,5 @@ ...u(this, L).setFields,

setAll(e) {
if (s(this, X, pe).call(this))
throw new v("Cannot set fields when content is set");
return s(this, x, k).call(this, {
if (s(this, ee, Ee).call(this))
throw new O("Cannot set fields when content is set");
return s(this, x, U).call(this, {
setFields: {

@@ -907,5 +907,5 @@ ...u(this, L).setFields,

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

@@ -919,3 +919,3 @@ /**

return(e) {
return s(this, x, k).call(this, { returnMode: e });
return s(this, x, U).call(this, { returnMode: e });
}

@@ -929,3 +929,3 @@ /**

returnFields(...e) {
return s(this, x, k).call(this, {
return s(this, x, U).call(this, {
returnMode: "fields",

@@ -942,3 +942,3 @@ returnFields: e

timeout(e) {
return s(this, x, k).call(this, { timeout: e });
return s(this, x, U).call(this, { timeout: e });
}

@@ -951,3 +951,3 @@ /**

parallel() {
return s(this, x, k).call(this, { parallel: !0 });
return s(this, x, U).call(this, { parallel: !0 });
}

@@ -963,4 +963,4 @@ toQuery() {

returnFields: d,
timeout: h,
parallel: m
timeout: f,
parallel: w
} = u(this, L);

@@ -970,23 +970,23 @@ if (!e || !t || !n)

let a = `RELATE ${e}->${t}->${n}`;
if (s(this, le, Ae).call(this)) {
const c = Ie(l);
c && (a += ` SET ${c}`);
if (s(this, he, Ie).call(this)) {
const h = Ue(l);
h && (a += ` SET ${h}`);
} else
s(this, X, pe).call(this) && (a += ` CONTENT ${JSON.stringify(i)}`);
return o === "fields" ? a += ` RETURN ${d.join(", ")}` : o && (a += ` RETURN ${o.toUpperCase()}`), h && (a += ` TIMEOUT ${h}s`), m && (a += " PARALLEL"), a;
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;
}
};
let Ce = Qe;
mt = Je, L = new WeakMap(), x = new WeakSet(), k = function(e) {
return new Qe({
let je = Be;
Ot = Re, L = new WeakMap(), x = new WeakSet(), U = function(e) {
return new Be({
...u(this, L),
...e
});
}, le = new WeakSet(), Ae = function() {
}, he = new WeakSet(), Ie = function() {
return Object.keys(u(this, L).setFields).length > 0;
}, X = new WeakSet(), pe = function() {
}, ee = new WeakSet(), Ee = function() {
return Object.keys(u(this, L).content).length > 0;
};
function lt(r, e, t) {
return new Ce({
function gt(r, e, t) {
return new je({
from: r,

@@ -1003,17 +1003,17 @@ edge: e,

}
function ct(r, e, t, n, i) {
function $t(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 lt(l, t, o);
return gt(l, t, o);
}
var _, J, Q, ee, te, b, C, Ee, De;
const Ue = class {
var P, J, Q, te, re, S, A, Se, Ze;
const ze = class {
constructor(e, t, n) {
f(this, b);
f(this, Ee);
f(this, _, void 0);
f(this, J, void 0);
f(this, Q, void 0);
f(this, ee, void 0);
f(this, te, void 0);
g(this, _, e), g(this, Q, t), g(this, J, n || {});
c(this, S);
c(this, Se);
c(this, P, void 0);
c(this, J, void 0);
c(this, Q, void 0);
c(this, te, void 0);
c(this, re, void 0);
m(this, P, e), m(this, Q, t), m(this, J, n || {});
}

@@ -1030,3 +1030,3 @@ /**

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

@@ -1045,3 +1045,3 @@ schema: e.schema

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

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

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

@@ -1068,3 +1068,3 @@ schema: e.schema.nullable(),

if (n.length > 1)
throw new E("Query returned multiple results, only one was expected", "too_many_results");
throw new q("Query returned multiple results, only one was expected", "too_many_results");
return n[0] ?? null;

@@ -1083,4 +1083,4 @@ }

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

@@ -1090,3 +1090,3 @@ schema: e.schema,

if (n.length > 1)
throw new E("Create only supports single targets", "too_many_results");
throw new q("Create only supports single targets", "too_many_results");
return n[0];

@@ -1105,4 +1105,4 @@ }

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

@@ -1123,6 +1123,6 @@ schema: e.schema,

delete(e) {
let t = e.id ? at(e.table, e.id) : ot(e.table);
return e.where && (t = t.where(e.where)), s(this, b, C).call(this, {
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, {
query: t,
schema: ue.undefined(),
schema: Y.undefined(),
skip: !0

@@ -1139,6 +1139,6 @@ }, e.params || {});

count(e) {
let t = rt("count()").from(e.table).groupAll();
return e.where && (t = t.where(e.where)), s(this, b, C).call(this, {
let t = ht("count()").from(e.table).groupAll();
return e.where && (t = t.where(e.where)), s(this, S, A).call(this, {
query: t,
schema: ue.number(),
schema: Y.number(),
transform(n) {

@@ -1158,6 +1158,6 @@ return n[0].count;

relate(e) {
let t = ct(e.fromTable, e.fromId, e.edge, e.toTable, e.toId);
return e.data && (t = t.setAll(e.data)), s(this, b, C).call(this, {
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, {
query: t,
schema: ue.undefined(),
schema: Y.undefined(),
skip: !0

@@ -1175,5 +1175,5 @@ }, e.params || {});

let t;
return typeof e.value == "object" && "toQuery" in e.value ? t = `(${e.value.toQuery()})` : t = y(e.value), s(this, b, C).call(this, {
return typeof e.value == "object" && "toQuery" in e.value ? t = `(${e.value.toQuery()})` : t = y(e.value), s(this, S, A).call(this, {
query: `LET $${e.name} = ${t}`,
schema: ue.undefined(),
schema: Y.undefined(),
skip: !0

@@ -1194,5 +1194,5 @@ }, {});

if ((t || n) && (!t || !n))
throw new E("Both thenSchema and elseSchema must be provided if either is specified", "invalid_request");
const i = oe(e.if) ? e.if[z] : he(e.if), l = oe(e.then) ? e.then[z] : he(e.then), o = oe(e.else) ? e.else[z] : he(e.else);
return s(this, b, C).call(this, {
throw new q("Both thenSchema and elseSchema must be provided if either is specified", "invalid_request");
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, {
query: `IF ${i} THEN (${l}) ELSE (${o}) END`,

@@ -1209,22 +1209,22 @@ schema: t.or(n)

async execute() {
if (!u(this, _).onRequest())
throw new E("There is no active connection to the database", "no_connection");
if (!u(this, P).onRequest())
throw new q("There is no active connection to the database", "no_connection");
if (u(this, Q).length === 0)
return [];
const e = s(this, Ee, De).call(this), t = [];
u(this, _).onLog(e, u(this, J));
const n = await u(this, _).onQuery(e, u(this, J));
const e = s(this, Se, Ze).call(this), t = [];
u(this, P).onLog(e, u(this, J));
const n = await u(this, P).onQuery(e, u(this, J));
if (!Array.isArray(n) || n.length !== u(this, Q).length)
throw new E("The response from the database was invalid", "invalid_response");
throw new q("The response from the database was invalid", "invalid_response");
for (let i = 0; i < n.length; i++) {
const { schema: l, transform: o, skip: d } = u(this, Q)[i], { status: h, result: m } = n[i];
if (h !== "OK")
throw new E(`Query ${i + 1} returned a non-successful status code: ${h}`, "invalid_response");
const { schema: l, transform: o, skip: d } = u(this, Q)[i], { status: f, result: w } = n[i];
if (f !== "OK")
throw new q(`Query ${i + 1} returned a non-successful status code: ${f}`, "invalid_response");
if (d)
t.push(void 0);
else {
const a = o ? o(m) : m, c = l.safeParse(a);
if (!c.success)
throw new _e(`Query ${i + 1} failed to parse`, c.error);
t.push(c.data);
const a = o ? o(w) : w, h = l.safeParse(a);
if (!h.success)
throw new Ke(`Query ${i + 1} failed to parse`, h.error);
t.push(h.data);
}

@@ -1243,3 +1243,3 @@ }

if (e.length === 0)
throw new E("You must specify at least on query", "invalid_request");
throw new q("You must specify at least on query", "invalid_request");
return e[0];

@@ -1254,32 +1254,32 @@ }

transaction() {
return g(this, ee, "BEGIN TRANSACTION"), g(this, te, "COMMIT TRANSACTION"), this.execute();
return m(this, te, "BEGIN TRANSACTION"), m(this, re, "COMMIT TRANSACTION"), this.execute();
}
};
let Re = Ue;
_ = new WeakMap(), J = new WeakMap(), Q = new WeakMap(), ee = new WeakMap(), te = new WeakMap(), b = new WeakSet(), C = function(e, t) {
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) {
for (const n of Object.keys(t))
if (u(this, J)[n])
throw new Error(`Duplicate parameter name: ${n}`);
return new Ue(
u(this, _),
return new ze(
u(this, P),
[...u(this, Q), e],
{ ...u(this, J), ...t }
);
}, Ee = new WeakSet(), De = function() {
let e = u(this, Q).map((t) => he(t.query));
return u(this, ee) && (e = [u(this, ee), ...e]), u(this, te) && (e = [...e, u(this, te)]), e.join(`;
}, Se = new WeakSet(), Ze = function() {
let e = u(this, Q).map((t) => me(t.query));
return u(this, te) && (e = [u(this, te), ...e]), u(this, re) && (e = [...e, u(this, re)]), e.join(`;
`);
};
function ht(r) {
return Je in r;
function Et(r) {
return Re in r;
}
var D, ce, Fe, qe, Ye, Ne, ze;
class Be extends EventTarget {
var D, fe, xe, Oe, We, ve, et;
class Xe extends EventTarget {
constructor(t) {
super();
f(this, ce);
f(this, qe);
f(this, Ne);
f(this, D, void 0);
g(this, D, t);
c(this, fe);
c(this, Oe);
c(this, ve);
c(this, D, void 0);
m(this, D, t);
}

@@ -1291,3 +1291,3 @@ async execute(t) {

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

@@ -1299,3 +1299,3 @@ prefix: "",

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

@@ -1309,3 +1309,3 @@ prefix: "BEGIN TRANSACTION",

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

@@ -1353,39 +1353,39 @@ /** @deprecated Use the new Query API instead */

}
D = new WeakMap(), ce = new WeakSet(), Fe = async function(t) {
D = new WeakMap(), fe = new WeakSet(), xe = async function(t) {
var d;
if (!u(this, D).onRequest())
throw new E("There is no active connection to the database", "no_connection");
throw new q("There is no active connection to the database", "no_connection");
if (t.queries.length === 0)
return [];
const n = s(this, Ne, ze).call(this, t), i = s(this, qe, Ye).call(this, t), l = [];
const n = s(this, ve, et).call(this, t), i = s(this, Oe, We).call(this, t), l = [];
u(this, D).onLog(i, n);
const o = await u(this, D).onQuery(i, n);
if (!Array.isArray(o) || o.length !== t.queries.length)
throw new E("The response from the database was invalid", "invalid_response");
for (let h = 0; h < o.length; h++) {
const { query: m, schema: a } = t.queries[h], { status: c, result: w, detail: $ } = o[h], S = m._quantity;
if (c !== "OK")
throw new E(`Query ${h + 1} returned a non-successful status code: ${c}: ${$}`, "invalid_response");
if (S == "zero") {
throw new q("The response from the database was invalid", "invalid_response");
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;
if (h !== "OK")
throw new q(`Query ${f + 1} returned a non-successful status code: ${h}: ${E}`, "invalid_response");
if (b == "zero") {
l.push(void 0);
continue;
}
const F = ((d = m._transform) == null ? void 0 : d.call(m, w)) ?? w, I = (ht(m) ? m._schema : a).array().safeParse(F);
if (!I.success)
throw new _e(`Query ${h + 1} failed to parse`, I.error);
if (S == "one" || S == "maybe") {
if (S == "one" && I.data.length === 0)
throw new E(`Query ${h + 1} expected at least one result but got ${I.data.length}`, "invalid_response");
if (I.data.length > 1)
throw new E(`Query ${h + 1} expected at most one result but got ${I.data.length}`, "invalid_response");
l.push(I.data[0] || null);
const F = ((d = w._transform) == null ? void 0 : d.call(w, g)) ?? g, M = (Et(w) ? w._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 q(`Query ${f + 1} expected at least one result but got ${M.data.length}`, "invalid_response");
if (M.data.length > 1)
throw new q(`Query ${f + 1} expected at most one result but got ${M.data.length}`, "invalid_response");
l.push(M.data[0] || null);
} else
l.push(I.data);
l.push(M.data);
}
return l;
}, qe = new WeakSet(), Ye = function(t) {
}, Oe = new WeakSet(), We = 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(`;
`);
}, Ne = new WeakSet(), ze = function(t) {
}, ve = new WeakSet(), et = function(t) {
const n = {};

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

if (l in n)
throw new E(`The parameter "${l}" was defined multiple times`, "invalid_query");
throw new q(`The parameter "${l}" was defined multiple times`, "invalid_query");
n[l] = o;

@@ -1401,4 +1401,4 @@ }

};
var re, B, Y, ne, se;
class Et extends Be {
var ne, B, z, se, ie;
class Mt extends Xe {
constructor(t) {

@@ -1412,8 +1412,8 @@ super({

});
q(this, "options");
f(this, re, null);
f(this, B, !1);
f(this, Y, !1);
f(this, ne, 0);
f(this, se, void 0);
$(this, "options");
c(this, ne, null);
c(this, B, !1);
c(this, z, !1);
c(this, se, 0);
c(this, ie, void 0);
this.options = {

@@ -1432,3 +1432,3 @@ autoConnect: !0,

get isConnected() {
return u(this, Y) && !u(this, B);
return u(this, z) && !u(this, B);
}

@@ -1439,3 +1439,3 @@ /**

get handle() {
return u(this, re);
return u(this, ne);
}

@@ -1446,15 +1446,15 @@ /**

connect() {
u(this, Y) || u(this, B) || (this.dispatchEvent(new Event("connect")), g(this, B, !0), g(this, re, et({
u(this, z) || u(this, B) || (this.dispatchEvent(new Event("connect")), m(this, B, !0), m(this, ne, lt({
connection: this.options.connection,
credentials: this.options.credentials,
onConnect: () => {
clearTimeout(u(this, se)), g(this, ne, 0), g(this, se, void 0), g(this, Y, !0), g(this, B, !1), this.dispatchEvent(new Event("open"));
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"));
},
onDisconnect: (t, n) => {
g(this, Y, !1), g(this, B, !1), this.dispatchEvent(new We(t, n));
m(this, z, !1), m(this, B, !1), this.dispatchEvent(new ut(t, n));
const { retryCount: i, retryDelay: l } = this.options;
(i < 0 || i > 0 && u(this, ne) < i) && (ke(this, ne)._++, g(this, se, setTimeout(() => this.connect(), l)));
(i < 0 || i > 0 && u(this, se) < i) && (He(this, se)._++, m(this, ie, setTimeout(() => this.connect(), l)));
},
onError: (t) => {
this.dispatchEvent(new Ze(t));
this.dispatchEvent(new ot(t));
}

@@ -1468,3 +1468,3 @@ })));

var t;
u(this, Y) && ((t = u(this, re)) == null || t.close());
u(this, z) && ((t = u(this, ne)) == null || t.close());
}

@@ -1482,8 +1482,8 @@ /**

}
re = new WeakMap(), B = new WeakMap(), Y = new WeakMap(), ne = new WeakMap(), se = new WeakMap();
var Te, Ge;
class qt extends Be {
ne = new WeakMap(), B = new WeakMap(), z = new WeakMap(), se = new WeakMap(), ie = new WeakMap();
var Ae, tt;
class jt extends Xe {
constructor(t) {
super({
onQuery: (n, i) => s(this, Te, Ge).call(this, n, i),
onQuery: (n, i) => s(this, Ae, tt).call(this, n, i),
onRequest: () => !0,

@@ -1494,4 +1494,4 @@ onLog: (n, i) => {

});
f(this, Te);
q(this, "options");
c(this, Ae);
$(this, "options");
this.options = {

@@ -1504,159 +1504,252 @@ logging: !1,

}
Te = new WeakSet(), Ge = async function(t, n) {
Ae = new WeakSet(), tt = async function(t, n) {
if (Object.keys(n).length > 0)
throw new E("Stateless queries do not support parameters yet. ", "invalid_request");
const { endpoint: i, namespace: l, database: o } = this.options.connection, { user: d, pass: h, DB: m, NS: a, SC: c, token: w } = this.options.credentials, $ = new URL("sql", i);
if (!d && !h && !w)
throw new E("Missing username & password or token", "invalid_request");
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);
if (!d && !f && !g)
throw new q("Missing username & password or token", "invalid_request");
const F = {
"User-Agent": "Cirql",
Authorization: w ? `Bearer ${w}` : `Basic ${btoa(`${d}:${h}`)}`,
Authorization: g ? `Bearer ${g}` : `Basic ${btoa(`${d}:${f}`)}`,
Accept: "application/json"
};
return (a || l) && (F.NS = a || l), (m || o) && (F.DB = m || o), c && (F.SC = c), await fetch($, {
return (a || l) && (F.NS = a || l), (w || o) && (F.DB = w || o), h && (F.SC = h), await fetch(E, {
method: "POST",
headers: F,
body: t
}).then((I) => I.json());
}).then((M) => M.json());
};
var ue, vt, Ce, rt;
const Ge = class {
constructor(e) {
c(this, Ce);
c(this, ue, void 0);
$(this, vt, !0);
$(this, "_schema", Y.number());
$(this, "_quantity", "one");
m(this, ue, e);
}
/**
* Define the where clause for the query. All values will be escaped
* automatically. Use of `raw` is supported, as well as any operators
* wrapping the raw function.
*
* @param where The where clause
* @returns The query writer
*/
where(e) {
return typeof e == "object" && (e = ye(e)), s(this, Ce, rt).call(this, { where: e });
}
toQuery() {
const {
target: e,
where: t
} = u(this, ue);
if (!e)
throw new Error("No target specified");
let n = `SELECT count() FROM ${e}`;
return t && (n += ` WHERE ${t}`), n += " GROUP BY ALL", n;
}
_transform(e) {
return e.map((t) => t.count);
}
};
let Qe = Ge;
vt = Re, ue = new WeakMap(), Ce = new WeakSet(), rt = function(e) {
return new Ge({
...u(this, ue),
...e
});
};
function It(r) {
return new Qe({
target: r,
where: void 0
});
}
var oe, de, At;
const Ye = 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);
}
get _quantity() {
return u(this, de);
}
/**
* Expect at most one record to be returned
*
* @returns The query writer
*/
single() {
return new Ye(u(this, oe), "maybe");
}
toQuery() {
return u(this, oe);
}
};
let _e = Ye;
At = pe, oe = new WeakMap(), de = new WeakMap();
function Lt(r) {
return new _e(r, "many");
}
const qt = /^[a-zA-Z0-9_]*$/;
function xt(r, e) {
if (!qt.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,
_quantity: "zero",
_schema: Y.undefined(),
toQuery() {
return `LET $${r} = ${t}`;
}
};
}
function p(r) {
return {
[z]: r
[G]: r
};
}
function Nt(r) {
function Qt(r) {
return p(`= ${y(r)}`);
}
function Tt(r) {
function _t(r) {
return p(`!= ${y(r)}`);
}
function St(r) {
function Ut(r) {
return p(`== ${y(r)}`);
}
function bt(r) {
function kt(r) {
return p(`?= ${y(r)}`);
}
function vt(r) {
function Pt(r) {
return p(`*= ${y(r)}`);
}
function Ot(r) {
function Jt(r) {
return p(`~ ${y(r)}`);
}
function Ct(r) {
function Dt(r) {
return p(`!~ ${y(r)}`);
}
function At(r) {
function Bt(r) {
return p(`?~ ${y(r)}`);
}
function Rt(r) {
function zt(r) {
return p(`*~ ${y(r)}`);
}
function Ft(r) {
function Gt(r) {
return p(`< ${y(r)}`);
}
function It(r) {
function Yt(r) {
return p(`<= ${y(r)}`);
}
function Mt(r) {
function Ht(r) {
return p(`> ${y(r)}`);
}
function jt(r) {
function Vt(r) {
return p(`>= ${y(r)}`);
}
function Lt(r) {
function Kt(r) {
return p(`CONTAINS ${y(r)}`);
}
function xt(r) {
function Zt(r) {
return p(`CONTAINSNOT ${y(r)}`);
}
function Qt(r) {
function Xt(r) {
return p(`CONTAINSALL ${y(r)}`);
}
function Ut(r) {
function Wt(r) {
return p(`CONTAINSANY ${y(r)}`);
}
function kt(r) {
function er(r) {
return p(`CONTAINSNONE ${y(r)}`);
}
function Pt(r) {
function tr(r) {
return p(`INSIDE ${y(r)}`);
}
function _t(r) {
function rr(r) {
return p(`NOTINSIDE ${y(r)}`);
}
function Jt(r) {
function nr(r) {
return p(`ALLINSIDE ${y(r)}`);
}
function Dt(r) {
function sr(r) {
return p(`ANYINSIDE ${y(r)}`);
}
function Bt(r) {
function ir(r) {
return p(`NONEINSIDE ${y(r)}`);
}
function Yt(r) {
function ur(r) {
return p(`OUTSIDE ${y(r)}`);
}
function zt(r) {
function or(r) {
return p(`INTERSECTS ${y(r)}`);
}
function Gt(r) {
function ar(r) {
return p(`+= ${y(r)}`);
}
function Ht(r) {
function lr(r) {
return p(`-= ${y(r)}`);
}
function Kt() {
function cr() {
return p("time::now()");
}
export {
Et as Cirql,
E as CirqlError,
_e as CirqlParseError,
Re as CirqlQuery,
qt as CirqlStateless,
v as CirqlWriterError,
ge as CreateQueryWriter,
$e as DeleteQueryWriter,
Ce as RelateQueryWriter,
me as SelectQueryWriter,
we as UpdateQueryWriter,
Gt as add,
vt as all,
Jt as allInside,
bt as any,
Dt as anyInside,
Lt as contains,
Qt as containsAll,
Ut as containsAny,
kt as containsNone,
xt as containsNot,
nt as create,
st as createRecord,
ot as del,
at as delRecord,
St as eeq,
Nt as eq,
Rt as fall,
At as fany,
Ot as feq,
Mt as gt,
jt as gte,
Pt as inside,
zt as intersects,
Ft as lt,
It as lte,
Tt as neq,
Ct as nfeq,
Bt as noneInside,
_t as notInside,
Yt as outside,
Ie as parseSetFields,
Se as parseWhereClause,
lt as relate,
ct as relateRecords,
Ht as remove,
rt as select,
Kt as timeNow,
it as update,
ut as updateRecord
Mt as Cirql,
q as CirqlError,
Ke as CirqlParseError,
Le as CirqlQuery,
jt as CirqlStateless,
O as CirqlWriterError,
Qe as CountQueryWriter,
Ne as CreateQueryWriter,
be as DeleteQueryWriter,
je as RelateQueryWriter,
qe 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,
It as count,
ft as create,
dt 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,
p as raw,
gt as relate,
$t as relateRecords,
lr as remove,
ht as select,
cr as timeNow,
yt as update,
pt as updateRecord
};

@@ -1,3 +0,43 @@

import { ZodTypeAny, ZodUndefined, z, TypeOf, ZodArray, ZodNullable, input, ZodError } from 'zod';
import { ZodTypeAny, ZodNumber, z, ZodUndefined, TypeOf, ZodArray, ZodNullable, input, ZodError } from 'zod';
interface RootAuth {
user: string;
pass: string;
}
interface NamespaceAuth {
NS: string;
user: string;
pass: string;
}
interface DatabaseAuth {
NS: string;
DB: string;
user: string;
pass: string;
}
interface ScopeAuth {
NS: string;
DB: string;
SC: string;
[key: string]: unknown;
}
interface TokenAuth {
token: string;
}
type CredentialDetails = RootAuth | NamespaceAuth | DatabaseAuth | ScopeAuth | TokenAuth;
interface ConnectionDetails {
/**
* The endpoint to connect to e.g. http://localhost:8000
*/
endpoint: string;
/**
* The namespace to connect to for executing queries
*/
namespace?: string;
/**
* The database to connect to for executing queries
*/
database?: string;
}
declare const Generic: unique symbol;

@@ -156,2 +196,44 @@ declare const Schemaful: unique symbol;

interface CountQueryState {
target: string;
where: string | undefined;
}
/**
* The query writer implementations for SELECT queries. Remember to
* always make sure of parameters to avoid potential SQL injection.
*
* When prevention of SQL injections is important, avoid passing
* variables to all functions except `where`.
*
* When using Cirql server side, never trust record ids directly
* passed to the query writer. Always use the `fromRecord` function
* to ensure the record id has an intended table name.
*/
declare class CountQueryWriter implements SchemafulQueryWriter<ZodNumber, 'one'> {
#private;
constructor(state: CountQueryState);
readonly [Schemaful] = true;
readonly _schema: z.ZodNumber;
readonly _quantity = "one";
/**
* Define the where clause for the query. All values will be escaped
* automatically. Use of `raw` is supported, as well as any operators
* wrapping the raw function.
*
* @param where The where clause
* @returns The query writer
*/
where(where: string | Where): CountQueryWriter;
toQuery(): string;
_transform(response: any[]): any[];
}
/**
* Start a new count query which will return the amount of
* rows in a given table.
*
* @param target The target table
* @returns The query writer
*/
declare function count(target: string): CountQueryWriter;
interface DeleteQueryState<Q extends Quantity> {

@@ -608,54 +690,38 @@ quantity: Q;

/**
* Builds the SET operators for a query based on the input object
* A special query writer implementation for executing raw queries.
*
* @param input The input object
* When prevention of SQL injections is important, avoid passing
* any variables directly to this query. Instead, use params.
*/
declare function parseSetFields(input: object): string;
declare class PlainQueryWriter<Q extends Quantity> implements GenericQueryWriter<Q> {
#private;
constructor(query: string, quantity: Q);
readonly [Generic] = true;
get _quantity(): Q;
/**
* Expect at most one record to be returned
*
* @returns The query writer
*/
single(): PlainQueryWriter<"maybe">;
toQuery(): string;
}
/**
* Parse a where clause into a string
* Create a query writer for the given raw query string
*
* @param clause The where clause
* @returns The string representation of the where clause
* @param rawQuery The
* @returns The query writer
*/
declare function parseWhereClause(clause: Where): string;
declare function query(rawQuery: string): PlainQueryWriter<"many">;
interface RootAuth {
user: string;
pass: string;
}
interface NamespaceAuth {
NS: string;
user: string;
pass: string;
}
interface DatabaseAuth {
NS: string;
DB: string;
user: string;
pass: string;
}
interface ScopeAuth {
NS: string;
DB: string;
SC: string;
[key: string]: unknown;
}
interface TokenAuth {
token: string;
}
type CredentialDetails = RootAuth | NamespaceAuth | DatabaseAuth | ScopeAuth | TokenAuth;
interface ConnectionDetails {
/**
* The endpoint to connect to e.g. http://localhost:8000
*/
endpoint: string;
/**
* The namespace to connect to for executing queries
*/
namespace?: string;
/**
* The database to connect to for executing queries
*/
database?: string;
}
/**
* Create a LET query assigning the supplied value to the
* given parameter name. The value can be any value, including
* a raw value or another query writer.
*
* @param name The parameter name
* @param value The value, raw value, or query writer
* @returns The query writer
*/
declare function letValue(name: string, value: any | QueryWriter<any>): SchemafulQueryWriter<ZodUndefined, 'zero'>;

@@ -1329,2 +1395,9 @@ /**

export { Cirql, CirqlBaseOptions, CirqlError, CirqlOptions, CirqlParseError, CirqlQueries, CirqlQuery, CirqlStateless, CirqlStatelessOptions, CirqlWriterError, ConnectionDetails, CountQueryOptions, CreateQueryOptions, CreateQueryWriter, CredentialDetails, DatabaseAuth, DeleteQueryOptions, DeleteQueryWriter, ErrorCodes, GenericQueryRequest, GenericQueryWriter, IfQueryOptions, Input, LetQueryOptions, MultiTypeOf, NamespaceAuth, Order, Ordering, ParameterizedQuery, Params, QuantitativeTypeOf, Quantity, Query, QueryRequest, QueryWriter, RelateQueryOptions, RelateQueryWriter, Result, ReturnMode, RootAuth, SchemafulQuery, SchemafulQueryRequest, SchemafulQueryWriter, ScopeAuth, SelectQueryOptions, SelectQueryWriter, SimpleQueryOptions, SingleResult, TokenAuth, UpdateQueryOptions, UpdateQueryWriter, Where, add, all, allInside, any, anyInside, contains, containsAll, containsAny, containsNone, containsNot, create, createRecord, del, delRecord, eeq, eq, fall, fany, feq, gt, gte, inside, intersects, lt, lte, neq, nfeq, noneInside, notInside, outside, parseSetFields, parseWhereClause, relate, relateRecords, remove, select, timeNow, update, updateRecord };
/**
* Used to insert raw values into a query
*
* @param value The raw query content
*/
declare function raw(value: string): RawQuery;
export { Cirql, CirqlBaseOptions, CirqlError, CirqlOptions, CirqlParseError, CirqlQueries, CirqlQuery, CirqlStateless, CirqlStatelessOptions, CirqlWriterError, ConnectionDetails, CountQueryOptions, CountQueryWriter, CreateQueryOptions, CreateQueryWriter, CredentialDetails, DatabaseAuth, DeleteQueryOptions, DeleteQueryWriter, ErrorCodes, GenericQueryRequest, GenericQueryWriter, IfQueryOptions, Input, LetQueryOptions, MultiTypeOf, NamespaceAuth, Order, Ordering, ParameterizedQuery, Params, QuantitativeTypeOf, Quantity, Query, QueryRequest, QueryWriter, RelateQueryOptions, RelateQueryWriter, Result, ReturnMode, RootAuth, SchemafulQuery, SchemafulQueryRequest, SchemafulQueryWriter, ScopeAuth, SelectQueryOptions, SelectQueryWriter, SimpleQueryOptions, SingleResult, TokenAuth, UpdateQueryOptions, UpdateQueryWriter, Where, add, all, allInside, any, anyInside, contains, containsAll, containsAny, containsNone, containsNot, count, create, createRecord, del, delRecord, eeq, eq, fall, fany, feq, gt, gte, inside, intersects, letValue, lt, lte, neq, nfeq, noneInside, notInside, outside, query, raw, relate, relateRecords, remove, select, timeNow, update, updateRecord };
{
"name": "cirql",
"version": "0.2.2",
"version": "0.2.3",
"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