New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@theconcurrent/query

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@theconcurrent/query - npm Package Compare versions

Comparing version 0.0.18 to 0.0.19

dist/generators/templateVariables/encloseFieldsWithName.d.ts

31

./dist/index.umd.js

@@ -1,2 +0,2 @@

(function(l,u){typeof exports=="object"&&typeof module!="undefined"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(l=typeof globalThis!="undefined"?globalThis:l||self,u(l["@theconcurrent/query"]={}))})(this,function(l){"use strict";function u(e,t,i){const{dividedPath:n,name:o,closingBraces:r,variableDeclaration:a,variableUsage:c}=e;return`
(function(l,m){typeof exports=="object"&&typeof module!="undefined"?m(exports):typeof define=="function"&&define.amd?define(["exports"],m):(l=typeof globalThis!="undefined"?globalThis:l||self,m(l["@theconcurrent/query"]={}))})(this,function(l){"use strict";function m(e,t,i){const{dividedPath:n,name:o,closingBraces:r,variableDeclaration:a,variableUsage:c}=e;return`
query ${i}${a} {

@@ -10,8 +10,8 @@ ${n.join(".").replace(/\./g,` {

${n.length===0?"":"}"}${r}
`.trim()}function $(e,t,i){return e.find(n=>n[t]===i)}function p(e,t){return $(e,"typeName",t)}function h(e,t,i){var n;const o=p(e,t);if(!o||o.kind!=="Object"||!o.fields)return;if(i.length===0)return o;const[r,...a]=i,c=(n=o.fields.find(s=>s.name===r))==null?void 0:n.typeName;if(c)return h(e,c,a)}function m(e,t,i){const n=h(e,i,(t==null?void 0:t.split("."))||[]);if(!n)throw new Error("Can't find Entity");return n}function T(e,t){var o;const n=(o=m(e,t,"Query").directives)==null?void 0:o.find(r=>r.name==="collection");if(!n)throw new Error("Can't generate List Query");return n.args}function N(e){return e.args?!e.args.find(t=>t.isNonNull):!0}function v(e){var t,i;return(i=(t=e.fields)==null?void 0:t.filter(n=>n.kind==="Scalar"||n.kind==="Enum"))==null?void 0:i.filter(N).map(n=>n.name)}function Q(e){return v(e).join(`
`)}function k(e,t){var n;const i=m(e,t,"Mutation");return(n=p(e,"Mutation"))==null?void 0:n.fields.find(o=>o.typeName===i.typeName)}function U(e,t){const i=m(e,t,"Mutation");return Q(i)}function L(e){const t=e.isNonNull?"!":"",i=e.isListNonNull?"!":"",n=e.isList?`[${e.typeName}${t||i}]`:`${e.typeName}${t}`;return`$${e.name}: ${n}`}function b(e){return e.length===0?"":`(${e.map(L).join(", ")})`}function E(e){return e.length===0?"":`(${e.map(t=>`${t.name}: $${t.name}`).join(", ")})`}function F(e,t,i){const{simplifiedEntities:n}=e,o=t.split("."),r=o.shift(),a=k(n,r);if(!a)throw new Error(`Can't generate ${i} Mutation`);const c=U(n,t),s="}".repeat(o.length-1),y=b(a.args),d=E(a.args),f=`${c||""}
`,z="mutation",H=o[0];return`
${z} ${r}${y} {
`.trim()}function p(e,t,i){return e.find(n=>n[t]===i)}function $(e,t){return p(e,"typeName",t)}function N(e,t,i){var n;const o=$(e,t);if(!o||o.kind!=="Object"||!o.fields)return;if(i.length===0)return o;const[r,...a]=i,c=(n=o.fields.find(s=>s.name===r))==null?void 0:n.typeName;if(c)return N(e,c,a)}function y(e,t,i){const n=N(e,i,(t==null?void 0:t.split("."))||[]);if(!n)throw new Error("Can't find Entity");return n}function R(e,t){var r;const i=e.find(a=>{var c;return(c=a.directives)==null?void 0:c.find(s=>s.name==="queryRoot")}),o=(r=y(e,t,i.typeName).directives)==null?void 0:r.find(a=>a.name==="collection");if(!o)throw new Error("Can't generate List Query");return o.args}function v(e){return e.args?!e.args.find(t=>t.isNonNull):!0}function b(e){var t,i;return(i=(t=e.fields)==null?void 0:t.filter(n=>n.kind==="Scalar"||n.kind==="Enum"))==null?void 0:i.filter(v).map(n=>n.name)}function E(e){return b(e).join(`
`)}function k(e,t){var n;const i=y(e,t,"Mutation");return(n=$(e,"Mutation"))==null?void 0:n.fields.find(o=>o.typeName===i.typeName)}function L(e,t){const i=y(e,t,"Mutation");return E(i)}function Q(e,t){var i,n;return(n=(i=e.fields)==null?void 0:i.filter(o=>o.kind===t))==null?void 0:n.filter(v)}function U(e,t){return t.map(i=>p(e,"typeName",i))}function C(e){const t=e.isNonNull?"!":"",i=e.isListNonNull?"!":"",n=e.isList?`[${e.typeName}${t||i}]`:`${e.typeName}${t}`;return`$${e.name}: ${n}`}function j(e){return e.length===0?"":`(${e.map(C).join(", ")})`}function w(e){return e.length===0?"":`(${e.map(t=>`${t.name}: $${t.name}`).join(", ")})`}function F(e,t,i){const{simplifiedEntities:n}=e,o=t.split("."),r=o.shift(),a=k(n,r);if(!a)throw new Error(`Can't generate ${i} Mutation`);const c=L(n,t),s="}".repeat(o.length-1),u=j(a.args),d=w(a.args),f=`${c||""}
`,h="mutation",z=o[0];return`
${h} ${r}${u} {
${r}${d} {
${H}{
${z}{
${f}

@@ -21,12 +21,12 @@ }

}${s}
`.trim()}function j(e,t){var o;const i=(o=e==null?void 0:e.fields)==null?void 0:o.filter(r=>r.kind==="Scalar").map(r=>r.name);if(!i)throw new Error("Can't find relatedFields");const n=i.filter(r=>t.includes(r));return n.length===0?i[0]:n.join(`
`)}function w(e,t){var i,n;return(n=(i=e.fields)==null?void 0:i.filter(o=>o.kind===t))==null?void 0:n.filter(N)}function C(e){return`{
`.trim()}function M(e,t,i){var a,c;const n=t.split("."),o=n.pop(),r=y(e,n[0]?n.join("."):void 0,i);if(r.kind==="Object"||r.kind==="Interface")return(c=(a=r==null?void 0:r.fields)==null?void 0:a.find(s=>s.name===o))==null?void 0:c.args}function x(e,t){var o;const i=(o=e==null?void 0:e.fields)==null?void 0:o.filter(r=>r.kind==="Scalar").map(r=>r.name);if(!i)throw new Error("Can't find relatedFields");const n=i.filter(r=>t.includes(r));return n.length===0?i[0]:n.join(`
`)}function S(e){return`{
${e}
}`}function g(e,t){return`${e} ${C(t)}`}function M(e,t,i){const n=$(e,"typeName",i.typeName);return j(n,t)}function R(e,t,i){var n;return(n=w(t,"Object"))==null?void 0:n.map(o=>{const r=M(e,i,o);if(r)return g(o.name,r)}).filter(o=>o)}function P(e,t,i){var n;return(n=R(e,t,i))==null?void 0:n.join(`
`)}function D(e,t){return t.map(i=>$(e,"typeName",i))}function S(e,t,i){return j(t,i)}function V(e,t,i){const n=S(e,t,i);return g(`... on ${t.typeName}`,n)}function O(e,t,i){var n;return(n=w(t,"Union"))==null?void 0:n.map(o=>{const r=D(e,o.possibleTypes||[]).map(a=>V(e,a,i)).join(`
}`}function g(e,t){return`${e} ${S(t)}`}function P(e,t,i){const n=x(t,i)||"__typename";return g(`... on ${t.typeName}`,n)}function q(e,t,i){var n;return(n=Q(t,"Union"))==null?void 0:n.map(o=>{const r=U(e,o.possibleTypes||[]).map(a=>P(e,a,i)).join(`
`);return g(o.name,r)}).join(`
`)}function W(e,t,i){var a,c;const n=t.split("."),o=n.pop(),r=m(e,n[0]?n.join("."):void 0,i);if(r.kind==="Object"||r.kind==="Interface")return(c=(a=r==null?void 0:r.fields)==null?void 0:a.find(s=>s.name===o))==null?void 0:c.args}function x(e,t,i,n,o){const r=i.split("."),a=r.pop(),c=e!=null&&e.fields?Q(e):void 0,s=P(t,e,n),y=O(t,e,n),d=r.length-1>0?"}".repeat(r.length-1):"",f=W(t,i,o);return{dividedPath:r,name:a,fields:c,relatedObjectFields:s,relatedUnionFields:y,closingBraces:d,variableDeclaration:b(f),variableUsage:E(f)}}function B(e,t,i){const{simplifiedEntities:n,config:{nodeRepresentatives:o}}=e,r=T(n,t);if(!r)throw new Error("Can't generate List Query");const a=p(n,r.typeName);if(!a)throw new Error("Can't generate List Query");const c=x(a,n,t,o,"Query"),s=i(r,c,a);return{variables:c,fieldsBlock:s}}function q(e,t){const{config:{nodeRepresentatives:i}}=e,n=(a,c,s)=>{const y=v(s).filter(f=>["id",...i].includes(f)).join(`
`)}function D(e,t,i){const n=p(e,"typeName",i.typeName);return x(n,t)}function V(e,t,i){var n,o;return(o=(n=Q(t,"Object"))==null?void 0:n.reduce((r,a)=>{const c=D(e,i,a);if(c){const s=g(a.name,c);r.push(s)}return r},[]))!=null?o:[]}function _(e,t,i){var n;return(n=V(e,t,i))==null?void 0:n.join(`
`)}function T(e,t,i,n,o){const r=i.split("."),a=r.pop(),c=e!=null&&e.fields?E(e):void 0,s=_(t,e,n),u=q(t,e,n),d=r.length-1>0?"}".repeat(r.length-1):"",f=M(t,i,o);return{dividedPath:r,name:a,fields:c,relatedObjectFields:s,relatedUnionFields:u,closingBraces:d,variableDeclaration:j(f),variableUsage:w(f)}}function B(e,t,i){const{simplifiedEntities:n,config:{nodeRepresentatives:o}}=e,r=R(n,t);if(!r)throw new Error("Can't generate List Query");const a=$(n,r.typeName);if(!a)throw new Error("Can't generate List Query");const c=n.find(d=>{var f;return(f=d.directives)==null?void 0:f.find(h=>h.name==="queryRoot")}),s=T(a,n,t,o,c.typeName),u=i(r,s,a);return{variables:s,fieldsBlock:u}}function O(e,t){const{config:{nodeRepresentatives:i}}=e,n=(a,c,s)=>{const u=b(s).filter(f=>["id",...i].includes(f)).join(`
`),d=a.dataPath.split(".");return`${d.join(` {
`)} {
${y||""}${"}".repeat(d.length)}`},{variables:o,fieldsBlock:r}=B(e,t,n);return u(o,r,o.name.replace(/List$/,"MinimumList"))}function A(e,t){return F(e,t,"Create")}function G(e,t){return F(e,t,"Delete")}function I(e,t){const i=(r,a)=>{const c=r.dataPath.split(".");return`${c.join(` {
${u||""}${"}".repeat(d.length)}`},{variables:o,fieldsBlock:r}=B(e,t,n);return m(o,r,o.name.replace(/List$/,"MinimumList"))}function W(e,t){return F(e,t,"Create")}function A(e,t){return F(e,t,"Delete")}function G(e,t){const i=(r,a)=>{const c=r.dataPath.split(".");return`${c.join(` {
`)} {

@@ -36,5 +36,6 @@ ${a.fields||""}

${a.relatedUnionFields||""}${"}".repeat(c.length)}
${r.totalPath}`},{variables:n,fieldsBlock:o}=B(e,t,i);return u(n,o,n.name)}function K(e,t){const{simplifiedEntities:i,config:{nodeRepresentatives:n}}=e,o=m(i,t,"Query");if(!o)throw new Error("Can't generate Show Query");const r=x(o,i,t,n,"Query"),a=`${r.fields||""}
${r.relatedObjectFields||""}
${r.relatedUnionFields||""}`;return u(r,a,r.name)}function _(e,t){return F(e,t,"Update")}l.createMinimumQueryForList=q,l.createQueryForCreate=A,l.createQueryForDelete=G,l.createQueryForList=I,l.createQueryForShow=K,l.createQueryForUpdate=_,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
${r.totalPath}`},{variables:n,fieldsBlock:o}=B(e,t,i);return m(n,o,n.name)}function I(e,t){const{simplifiedEntities:i,config:{nodeRepresentatives:n}}=e,o=i.find(s=>{var u;return(u=s.directives)==null?void 0:u.find(d=>d.name==="queryRoot")}),r=y(i,t,o.typeName);if(!r)throw new Error("Can't generate Show Query");const a=T(r,i,t,n,o.typeName),c=`${a.fields||""}
${a.relatedObjectFields||""}
__typename
${a.relatedUnionFields||""}`;return m(a,c,a.name)}function K(e,t){return F(e,t,"Update")}l.createMinimumQueryForList=O,l.createQueryForCreate=W,l.createQueryForDelete=A,l.createQueryForList=G,l.createQueryForShow=I,l.createQueryForUpdate=K,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
//# sourceMappingURL=index.umd.js.map

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

function m(e, t, i) {
const { dividedPath: n, name: o, closingBraces: r, variableDeclaration: a, variableUsage: l } = e;
function p(e, t, i) {
const { dividedPath: n, name: o, closingBraces: r, variableDeclaration: a, variableUsage: s } = e;
return `

@@ -7,3 +7,3 @@ query ${i}${a} {

`)} ${n.length === 0 ? "" : "{"}
${o}${l} {
${o}${s} {
${t}

@@ -15,11 +15,11 @@ }

}
function $(e, t, i) {
function y(e, t, i) {
return e.find((n) => n[t] === i);
}
function p(e, t) {
return $(e, "typeName", t);
function $(e, t) {
return y(e, "typeName", t);
}
function g(e, t, i) {
function N(e, t, i) {
var n;
const o = p(e, t);
const o = $(e, t);
if (!o || o.kind !== "Object" || !o.fields)

@@ -29,10 +29,10 @@ return;

return o;
const [r, ...a] = i, l = (n = o.fields.find(
(s) => s.name === r
const [r, ...a] = i, s = (n = o.fields.find(
(l) => l.name === r
)) == null ? void 0 : n.typeName;
if (l)
return g(e, l, a);
if (s)
return N(e, s, a);
}
function f(e, t, i) {
const n = g(
const n = N(
e,

@@ -47,23 +47,32 @@ i,

function T(e, t) {
var o;
const n = (o = f(e, t, "Query").directives) == null ? void 0 : o.find((r) => r.name === "collection");
if (!n)
var r;
const i = e.find(
(a) => {
var s;
return (s = a.directives) == null ? void 0 : s.find((l) => l.name === "queryRoot");
}
), o = (r = f(
e,
t,
i.typeName
).directives) == null ? void 0 : r.find((a) => a.name === "collection");
if (!o)
throw new Error("Can't generate List Query");
return n.args;
return o.args;
}
function N(e) {
function h(e) {
return e.args ? !e.args.find((t) => t.isNonNull) : !0;
}
function h(e) {
function v(e) {
var t, i;
return (i = (t = e.fields) == null ? void 0 : t.filter((n) => n.kind === "Scalar" || n.kind === "Enum")) == null ? void 0 : i.filter(N).map((n) => n.name);
return (i = (t = e.fields) == null ? void 0 : t.filter((n) => n.kind === "Scalar" || n.kind === "Enum")) == null ? void 0 : i.filter(h).map((n) => n.name);
}
function v(e) {
return h(e).join(`
function x(e) {
return v(e).join(`
`);
}
function U(e, t) {
function Q(e, t) {
var n;
const i = f(e, t, "Mutation");
return (n = p(e, "Mutation")) == null ? void 0 : n.fields.find(
return (n = $(e, "Mutation")) == null ? void 0 : n.fields.find(
// @ts-ignore

@@ -74,6 +83,13 @@ // eslint-disable-next-line

}
function L(e, t) {
function U(e, t) {
const i = f(e, t, "Mutation");
return v(i);
return x(i);
}
function E(e, t) {
var i, n;
return (n = (i = e.fields) == null ? void 0 : i.filter((o) => o.kind === t)) == null ? void 0 : n.filter(h);
}
function L(e, t) {
return t.map((i) => y(e, "typeName", i));
}
function C(e) {

@@ -83,25 +99,35 @@ const t = e.isNonNull ? "!" : "", i = e.isListNonNull ? "!" : "", n = e.isList ? `[${e.typeName}${t || i}]` : `${e.typeName}${t}`;

}
function x(e) {
function b(e) {
return e.length === 0 ? "" : `(${e.map(C).join(", ")})`;
}
function b(e) {
function w(e) {
return e.length === 0 ? "" : `(${e.map((t) => `${t.name}: $${t.name}`).join(", ")})`;
}
function y(e, t, i) {
const { simplifiedEntities: n } = e, o = t.split("."), r = o.shift(), a = U(n, r);
function F(e, t, i) {
const { simplifiedEntities: n } = e, o = t.split("."), r = o.shift(), a = Q(n, r);
if (!a)
throw new Error(`Can't generate ${i} Mutation`);
const l = L(n, t), s = "}".repeat(o.length - 1), d = x(a.args), c = b(a.args), u = `${l || ""}
`, j = "mutation", k = o[0];
const s = U(n, t), l = "}".repeat(o.length - 1), c = b(a.args), u = w(a.args), d = `${s || ""}
`, m = "mutation", k = o[0];
return `
${j} ${r}${d} {
${r}${c} {
${m} ${r}${c} {
${r}${u} {
${k}{
${u}
${d}
}
}
}${s}
}${l}
`.trim();
}
function E(e, t) {
function M(e, t, i) {
var a, s;
const n = t.split("."), o = n.pop(), r = f(
e,
n[0] ? n.join(".") : void 0,
i
);
if (r.kind === "Object" || r.kind === "Interface")
return (s = (a = r == null ? void 0 : r.fields) == null ? void 0 : a.find((l) => l.name === o)) == null ? void 0 : s.args;
}
function j(e, t) {
var o;

@@ -115,7 +141,3 @@ const i = (o = e == null ? void 0 : e.fields) == null ? void 0 : o.filter((r) => r.kind === "Scalar").map((r) => r.name);

}
function w(e, t) {
var i, n;
return (n = (i = e.fields) == null ? void 0 : i.filter((o) => o.kind === t)) == null ? void 0 : n.filter(N);
}
function R(e) {
function P(e) {
return `{

@@ -125,82 +147,69 @@ ${e}

}
function F(e, t) {
return `${e} ${R(t)}`;
function g(e, t) {
return `${e} ${P(t)}`;
}
function M(e, t, i) {
const n = $(e, "typeName", i.typeName);
return E(n, t);
function q(e, t, i) {
const n = j(t, i) || "__typename";
return g(`... on ${t.typeName}`, n);
}
function P(e, t, i) {
var n;
return (n = w(t, "Object")) == null ? void 0 : n.map((o) => {
const r = M(
e,
i,
o
);
if (r)
return F(o.name, r);
}).filter((o) => o);
}
function D(e, t, i) {
var n;
return (n = P(e, t, i)) == null ? void 0 : n.join(`
`);
}
function V(e, t) {
return t.map((i) => $(e, "typeName", i));
}
function S(e, t, i) {
return E(t, i);
}
function W(e, t, i) {
const n = S(
e,
t,
i
);
return F(`... on ${t.typeName}`, n);
}
function O(e, t, i) {
var n;
return (n = w(t, "Union")) == null ? void 0 : n.map((o) => {
const r = V(
return (n = E(t, "Union")) == null ? void 0 : n.map((o) => {
const r = L(
e,
o.possibleTypes || []
).map(
(a) => W(e, a, i)
(a) => q(e, a, i)
).join(`
`);
return F(o.name, r);
return g(o.name, r);
}).join(`
`);
}
function q(e, t, i) {
var a, l;
const n = t.split("."), o = n.pop(), r = f(e, n[0] ? n.join(".") : void 0, i);
if (r.kind === "Object" || r.kind === "Interface")
return (l = (a = r == null ? void 0 : r.fields) == null ? void 0 : a.find((s) => s.name === o)) == null ? void 0 : l.args;
function D(e, t, i) {
const n = y(e, "typeName", i.typeName);
return j(n, t);
}
function V(e, t, i) {
var n, o;
return (o = (n = E(t, "Object")) == null ? void 0 : n.reduce((r, a) => {
const s = D(
e,
i,
a
);
if (s) {
const l = g(a.name, s);
r.push(l);
}
return r;
}, [])) != null ? o : [];
}
function _(e, t, i) {
var n;
return (n = V(e, t, i)) == null ? void 0 : n.join(`
`);
}
function B(e, t, i, n, o) {
const r = i.split("."), a = r.pop(), l = e != null && e.fields ? v(e) : void 0, s = D(
const r = i.split("."), a = r.pop(), s = e != null && e.fields ? x(e) : void 0, l = _(
t,
e,
n
), d = O(
), c = S(
t,
e,
n
), c = r.length - 1 > 0 ? "}".repeat(r.length - 1) : "", u = q(t, i, o);
), u = r.length - 1 > 0 ? "}".repeat(r.length - 1) : "", d = M(t, i, o);
return {
dividedPath: r,
name: a,
fields: l,
relatedObjectFields: s,
relatedUnionFields: d,
closingBraces: c,
variableDeclaration: x(u),
variableUsage: b(u)
fields: s,
relatedObjectFields: l,
relatedUnionFields: c,
closingBraces: u,
variableDeclaration: b(d),
variableUsage: w(d)
};
}
function Q(e, t, i) {
function R(e, t, i) {
const {

@@ -212,6 +221,11 @@ simplifiedEntities: n,

throw new Error("Can't generate List Query");
const a = p(n, r.typeName);
const a = $(n, r.typeName);
if (!a)
throw new Error("Can't generate List Query");
const l = B(
const s = n.find(
(u) => {
var d;
return (d = u.directives) == null ? void 0 : d.find((m) => m.name === "queryRoot");
}
), l = B(
a,

@@ -221,17 +235,17 @@ n,

o,
"Query"
), s = i(r, l, a);
return { variables: l, fieldsBlock: s };
s.typeName
), c = i(r, l, a);
return { variables: l, fieldsBlock: c };
}
function A(e, t) {
function O(e, t) {
const {
config: { nodeRepresentatives: i }
} = e, n = (a, l, s) => {
const d = h(s).filter((u) => ["id", ...i].includes(u)).join(`
`), c = a.dataPath.split(".");
return `${c.join(` {
} = e, n = (a, s, l) => {
const c = v(l).filter((d) => ["id", ...i].includes(d)).join(`
`), u = a.dataPath.split(".");
return `${u.join(` {
`)} {
${d || ""}${"}".repeat(c.length)}`;
}, { variables: o, fieldsBlock: r } = Q(e, t, n);
return m(
${c || ""}${"}".repeat(u.length)}`;
}, { variables: o, fieldsBlock: r } = R(e, t, n);
return p(
o,

@@ -242,49 +256,55 @@ r,

}
function G(e, t) {
return y(e, t, "Create");
function W(e, t) {
return F(e, t, "Create");
}
function I(e, t) {
return y(e, t, "Delete");
function A(e, t) {
return F(e, t, "Delete");
}
function K(e, t) {
function G(e, t) {
const i = (r, a) => {
const l = r.dataPath.split(".");
return `${l.join(` {
const s = r.dataPath.split(".");
return `${s.join(` {
`)} {
${a.fields || ""}
${a.relatedObjectFields || ""}
${a.relatedUnionFields || ""}${"}".repeat(l.length)}
${a.relatedUnionFields || ""}${"}".repeat(s.length)}
${r.totalPath}`;
}, { variables: n, fieldsBlock: o } = Q(e, t, i);
return m(n, o, n.name);
}, { variables: n, fieldsBlock: o } = R(e, t, i);
return p(n, o, n.name);
}
function _(e, t) {
function I(e, t) {
const {
simplifiedEntities: i,
config: { nodeRepresentatives: n }
} = e, o = f(i, t, "Query");
if (!o)
} = e, o = i.find(
(l) => {
var c;
return (c = l.directives) == null ? void 0 : c.find((u) => u.name === "queryRoot");
}
), r = f(i, t, o.typeName);
if (!r)
throw new Error("Can't generate Show Query");
const r = B(
o,
const a = B(
r,
i,
t,
n,
"Query"
), a = `${r.fields || ""}
${r.relatedObjectFields || ""}
${r.relatedUnionFields || ""}`;
return m(r, a, r.name);
o.typeName
), s = `${a.fields || ""}
${a.relatedObjectFields || ""}
__typename
${a.relatedUnionFields || ""}`;
return p(a, s, a.name);
}
function z(e, t) {
return y(e, t, "Update");
function K(e, t) {
return F(e, t, "Update");
}
export {
A as createMinimumQueryForList,
G as createQueryForCreate,
I as createQueryForDelete,
K as createQueryForList,
_ as createQueryForShow,
z as createQueryForUpdate
O as createMinimumQueryForList,
W as createQueryForCreate,
A as createQueryForDelete,
G as createQueryForList,
I as createQueryForShow,
K as createQueryForUpdate
};
//# sourceMappingURL=index.es.js.map

@@ -1,2 +0,2 @@

(function(l,u){typeof exports=="object"&&typeof module!="undefined"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(l=typeof globalThis!="undefined"?globalThis:l||self,u(l["@theconcurrent/query"]={}))})(this,function(l){"use strict";function u(e,t,i){const{dividedPath:n,name:o,closingBraces:r,variableDeclaration:a,variableUsage:c}=e;return`
(function(l,m){typeof exports=="object"&&typeof module!="undefined"?m(exports):typeof define=="function"&&define.amd?define(["exports"],m):(l=typeof globalThis!="undefined"?globalThis:l||self,m(l["@theconcurrent/query"]={}))})(this,function(l){"use strict";function m(e,t,i){const{dividedPath:n,name:o,closingBraces:r,variableDeclaration:a,variableUsage:c}=e;return`
query ${i}${a} {

@@ -10,8 +10,8 @@ ${n.join(".").replace(/\./g,` {

${n.length===0?"":"}"}${r}
`.trim()}function $(e,t,i){return e.find(n=>n[t]===i)}function p(e,t){return $(e,"typeName",t)}function h(e,t,i){var n;const o=p(e,t);if(!o||o.kind!=="Object"||!o.fields)return;if(i.length===0)return o;const[r,...a]=i,c=(n=o.fields.find(s=>s.name===r))==null?void 0:n.typeName;if(c)return h(e,c,a)}function m(e,t,i){const n=h(e,i,(t==null?void 0:t.split("."))||[]);if(!n)throw new Error("Can't find Entity");return n}function T(e,t){var o;const n=(o=m(e,t,"Query").directives)==null?void 0:o.find(r=>r.name==="collection");if(!n)throw new Error("Can't generate List Query");return n.args}function N(e){return e.args?!e.args.find(t=>t.isNonNull):!0}function v(e){var t,i;return(i=(t=e.fields)==null?void 0:t.filter(n=>n.kind==="Scalar"||n.kind==="Enum"))==null?void 0:i.filter(N).map(n=>n.name)}function Q(e){return v(e).join(`
`)}function k(e,t){var n;const i=m(e,t,"Mutation");return(n=p(e,"Mutation"))==null?void 0:n.fields.find(o=>o.typeName===i.typeName)}function U(e,t){const i=m(e,t,"Mutation");return Q(i)}function L(e){const t=e.isNonNull?"!":"",i=e.isListNonNull?"!":"",n=e.isList?`[${e.typeName}${t||i}]`:`${e.typeName}${t}`;return`$${e.name}: ${n}`}function b(e){return e.length===0?"":`(${e.map(L).join(", ")})`}function E(e){return e.length===0?"":`(${e.map(t=>`${t.name}: $${t.name}`).join(", ")})`}function F(e,t,i){const{simplifiedEntities:n}=e,o=t.split("."),r=o.shift(),a=k(n,r);if(!a)throw new Error(`Can't generate ${i} Mutation`);const c=U(n,t),s="}".repeat(o.length-1),y=b(a.args),d=E(a.args),f=`${c||""}
`,z="mutation",H=o[0];return`
${z} ${r}${y} {
`.trim()}function p(e,t,i){return e.find(n=>n[t]===i)}function $(e,t){return p(e,"typeName",t)}function N(e,t,i){var n;const o=$(e,t);if(!o||o.kind!=="Object"||!o.fields)return;if(i.length===0)return o;const[r,...a]=i,c=(n=o.fields.find(s=>s.name===r))==null?void 0:n.typeName;if(c)return N(e,c,a)}function y(e,t,i){const n=N(e,i,(t==null?void 0:t.split("."))||[]);if(!n)throw new Error("Can't find Entity");return n}function R(e,t){var r;const i=e.find(a=>{var c;return(c=a.directives)==null?void 0:c.find(s=>s.name==="queryRoot")}),o=(r=y(e,t,i.typeName).directives)==null?void 0:r.find(a=>a.name==="collection");if(!o)throw new Error("Can't generate List Query");return o.args}function v(e){return e.args?!e.args.find(t=>t.isNonNull):!0}function b(e){var t,i;return(i=(t=e.fields)==null?void 0:t.filter(n=>n.kind==="Scalar"||n.kind==="Enum"))==null?void 0:i.filter(v).map(n=>n.name)}function E(e){return b(e).join(`
`)}function k(e,t){var n;const i=y(e,t,"Mutation");return(n=$(e,"Mutation"))==null?void 0:n.fields.find(o=>o.typeName===i.typeName)}function L(e,t){const i=y(e,t,"Mutation");return E(i)}function Q(e,t){var i,n;return(n=(i=e.fields)==null?void 0:i.filter(o=>o.kind===t))==null?void 0:n.filter(v)}function U(e,t){return t.map(i=>p(e,"typeName",i))}function C(e){const t=e.isNonNull?"!":"",i=e.isListNonNull?"!":"",n=e.isList?`[${e.typeName}${t||i}]`:`${e.typeName}${t}`;return`$${e.name}: ${n}`}function j(e){return e.length===0?"":`(${e.map(C).join(", ")})`}function w(e){return e.length===0?"":`(${e.map(t=>`${t.name}: $${t.name}`).join(", ")})`}function F(e,t,i){const{simplifiedEntities:n}=e,o=t.split("."),r=o.shift(),a=k(n,r);if(!a)throw new Error(`Can't generate ${i} Mutation`);const c=L(n,t),s="}".repeat(o.length-1),u=j(a.args),d=w(a.args),f=`${c||""}
`,h="mutation",z=o[0];return`
${h} ${r}${u} {
${r}${d} {
${H}{
${z}{
${f}

@@ -21,12 +21,12 @@ }

}${s}
`.trim()}function j(e,t){var o;const i=(o=e==null?void 0:e.fields)==null?void 0:o.filter(r=>r.kind==="Scalar").map(r=>r.name);if(!i)throw new Error("Can't find relatedFields");const n=i.filter(r=>t.includes(r));return n.length===0?i[0]:n.join(`
`)}function w(e,t){var i,n;return(n=(i=e.fields)==null?void 0:i.filter(o=>o.kind===t))==null?void 0:n.filter(N)}function C(e){return`{
`.trim()}function M(e,t,i){var a,c;const n=t.split("."),o=n.pop(),r=y(e,n[0]?n.join("."):void 0,i);if(r.kind==="Object"||r.kind==="Interface")return(c=(a=r==null?void 0:r.fields)==null?void 0:a.find(s=>s.name===o))==null?void 0:c.args}function x(e,t){var o;const i=(o=e==null?void 0:e.fields)==null?void 0:o.filter(r=>r.kind==="Scalar").map(r=>r.name);if(!i)throw new Error("Can't find relatedFields");const n=i.filter(r=>t.includes(r));return n.length===0?i[0]:n.join(`
`)}function S(e){return`{
${e}
}`}function g(e,t){return`${e} ${C(t)}`}function M(e,t,i){const n=$(e,"typeName",i.typeName);return j(n,t)}function R(e,t,i){var n;return(n=w(t,"Object"))==null?void 0:n.map(o=>{const r=M(e,i,o);if(r)return g(o.name,r)}).filter(o=>o)}function P(e,t,i){var n;return(n=R(e,t,i))==null?void 0:n.join(`
`)}function D(e,t){return t.map(i=>$(e,"typeName",i))}function S(e,t,i){return j(t,i)}function V(e,t,i){const n=S(e,t,i);return g(`... on ${t.typeName}`,n)}function O(e,t,i){var n;return(n=w(t,"Union"))==null?void 0:n.map(o=>{const r=D(e,o.possibleTypes||[]).map(a=>V(e,a,i)).join(`
}`}function g(e,t){return`${e} ${S(t)}`}function P(e,t,i){const n=x(t,i)||"__typename";return g(`... on ${t.typeName}`,n)}function q(e,t,i){var n;return(n=Q(t,"Union"))==null?void 0:n.map(o=>{const r=U(e,o.possibleTypes||[]).map(a=>P(e,a,i)).join(`
`);return g(o.name,r)}).join(`
`)}function W(e,t,i){var a,c;const n=t.split("."),o=n.pop(),r=m(e,n[0]?n.join("."):void 0,i);if(r.kind==="Object"||r.kind==="Interface")return(c=(a=r==null?void 0:r.fields)==null?void 0:a.find(s=>s.name===o))==null?void 0:c.args}function x(e,t,i,n,o){const r=i.split("."),a=r.pop(),c=e!=null&&e.fields?Q(e):void 0,s=P(t,e,n),y=O(t,e,n),d=r.length-1>0?"}".repeat(r.length-1):"",f=W(t,i,o);return{dividedPath:r,name:a,fields:c,relatedObjectFields:s,relatedUnionFields:y,closingBraces:d,variableDeclaration:b(f),variableUsage:E(f)}}function B(e,t,i){const{simplifiedEntities:n,config:{nodeRepresentatives:o}}=e,r=T(n,t);if(!r)throw new Error("Can't generate List Query");const a=p(n,r.typeName);if(!a)throw new Error("Can't generate List Query");const c=x(a,n,t,o,"Query"),s=i(r,c,a);return{variables:c,fieldsBlock:s}}function q(e,t){const{config:{nodeRepresentatives:i}}=e,n=(a,c,s)=>{const y=v(s).filter(f=>["id",...i].includes(f)).join(`
`)}function D(e,t,i){const n=p(e,"typeName",i.typeName);return x(n,t)}function V(e,t,i){var n,o;return(o=(n=Q(t,"Object"))==null?void 0:n.reduce((r,a)=>{const c=D(e,i,a);if(c){const s=g(a.name,c);r.push(s)}return r},[]))!=null?o:[]}function _(e,t,i){var n;return(n=V(e,t,i))==null?void 0:n.join(`
`)}function T(e,t,i,n,o){const r=i.split("."),a=r.pop(),c=e!=null&&e.fields?E(e):void 0,s=_(t,e,n),u=q(t,e,n),d=r.length-1>0?"}".repeat(r.length-1):"",f=M(t,i,o);return{dividedPath:r,name:a,fields:c,relatedObjectFields:s,relatedUnionFields:u,closingBraces:d,variableDeclaration:j(f),variableUsage:w(f)}}function B(e,t,i){const{simplifiedEntities:n,config:{nodeRepresentatives:o}}=e,r=R(n,t);if(!r)throw new Error("Can't generate List Query");const a=$(n,r.typeName);if(!a)throw new Error("Can't generate List Query");const c=n.find(d=>{var f;return(f=d.directives)==null?void 0:f.find(h=>h.name==="queryRoot")}),s=T(a,n,t,o,c.typeName),u=i(r,s,a);return{variables:s,fieldsBlock:u}}function O(e,t){const{config:{nodeRepresentatives:i}}=e,n=(a,c,s)=>{const u=b(s).filter(f=>["id",...i].includes(f)).join(`
`),d=a.dataPath.split(".");return`${d.join(` {
`)} {
${y||""}${"}".repeat(d.length)}`},{variables:o,fieldsBlock:r}=B(e,t,n);return u(o,r,o.name.replace(/List$/,"MinimumList"))}function A(e,t){return F(e,t,"Create")}function G(e,t){return F(e,t,"Delete")}function I(e,t){const i=(r,a)=>{const c=r.dataPath.split(".");return`${c.join(` {
${u||""}${"}".repeat(d.length)}`},{variables:o,fieldsBlock:r}=B(e,t,n);return m(o,r,o.name.replace(/List$/,"MinimumList"))}function W(e,t){return F(e,t,"Create")}function A(e,t){return F(e,t,"Delete")}function G(e,t){const i=(r,a)=>{const c=r.dataPath.split(".");return`${c.join(` {
`)} {

@@ -36,5 +36,6 @@ ${a.fields||""}

${a.relatedUnionFields||""}${"}".repeat(c.length)}
${r.totalPath}`},{variables:n,fieldsBlock:o}=B(e,t,i);return u(n,o,n.name)}function K(e,t){const{simplifiedEntities:i,config:{nodeRepresentatives:n}}=e,o=m(i,t,"Query");if(!o)throw new Error("Can't generate Show Query");const r=x(o,i,t,n,"Query"),a=`${r.fields||""}
${r.relatedObjectFields||""}
${r.relatedUnionFields||""}`;return u(r,a,r.name)}function _(e,t){return F(e,t,"Update")}l.createMinimumQueryForList=q,l.createQueryForCreate=A,l.createQueryForDelete=G,l.createQueryForList=I,l.createQueryForShow=K,l.createQueryForUpdate=_,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
${r.totalPath}`},{variables:n,fieldsBlock:o}=B(e,t,i);return m(n,o,n.name)}function I(e,t){const{simplifiedEntities:i,config:{nodeRepresentatives:n}}=e,o=i.find(s=>{var u;return(u=s.directives)==null?void 0:u.find(d=>d.name==="queryRoot")}),r=y(i,t,o.typeName);if(!r)throw new Error("Can't generate Show Query");const a=T(r,i,t,n,o.typeName),c=`${a.fields||""}
${a.relatedObjectFields||""}
__typename
${a.relatedUnionFields||""}`;return m(a,c,a.name)}function K(e,t){return F(e,t,"Update")}l.createMinimumQueryForList=O,l.createQueryForCreate=W,l.createQueryForDelete=A,l.createQueryForList=G,l.createQueryForShow=I,l.createQueryForUpdate=K,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
//# sourceMappingURL=index.umd.js.map

@@ -113,2 +113,3 @@ /// <reference types="react" />

schemeResourceName?: string;
category?: string;
create?: {

@@ -115,0 +116,0 @@ queries: Array<RawQuery>;

import type { SimplifiedEntityType } from '../types';
export default function findEntityByPath(simplifiedEntities: SimplifiedEntityType[], path: string | undefined, operationType: 'Query' | 'Mutation'): SimplifiedEntityType;
export default function findEntityByPath(simplifiedEntities: SimplifiedEntityType[], path: string | undefined, operationRootType: string): SimplifiedEntityType;
//# sourceMappingURL=findEntityByPath.d.ts.map

@@ -7,4 +7,5 @@ import extractCollection from './extractCollection';

import findEntityByPath from './findEntityByPath';
import hasNonNull from './hasNonNull';
export { extractCollection, extractFields, extractFieldsText, extractMutationFields, extractMutationPayloadFieldsText, findEntityByPath, hasNonNull, };
import fieldsByKind from './fieldsByKind';
import possibleTypesToEntities from './possibleTypesToEntities';
export { extractCollection, extractFields, extractFieldsText, extractMutationFields, extractMutationPayloadFieldsText, findEntityByPath, fieldsByKind, possibleTypesToEntities, };
//# sourceMappingURL=index.d.ts.map
{
"name": "@theconcurrent/query",
"version": "0.0.18",
"version": "0.0.19",
"main": "./dist/index.umd.js",

@@ -27,8 +27,8 @@ "module": "./dist/index.es.js",

"dependencies": {
"@theconcurrent/utility": "0.0.18"
"@theconcurrent/utility": "0.0.19"
},
"peerDependencies": {
"@theconcurrent/utility": "0.0.18"
"@theconcurrent/utility": "0.0.19"
},
"gitHead": "e9b5ea92e453f508265e1693e10b87c3039eec03"
"gitHead": "d92250a7361b0103695a48cc29c8e610f698e487"
}

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

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