@theconcurrent/query
Advanced tools
Comparing version
@@ -1,15 +0,15 @@ | ||
(function(c,u){typeof exports=="object"&&typeof module!="undefined"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(c=typeof globalThis!="undefined"?globalThis:c||self,u(c["@theconcurrent/query"]={}))})(this,function(c){"use strict";function u(e,t,r){const{dividedPath:n,name:o,closingBraces:i,variableDeclaration:a,variableUsage:l}=e;return` | ||
query ${r}${a} { | ||
(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` | ||
query ${i}${a} { | ||
${n.join(".").replace(/\./g,` { | ||
`)} ${n.length===0?"":"{"} | ||
${o}${l} { | ||
${o}${c} { | ||
${t} | ||
} | ||
} | ||
${n.length===0?"":"}"}${i} | ||
`.trim()}function $(e,t,r){return e.find(n=>n[t]===r)}function p(e,t){return $(e,"typeName",t)}function h(e,t,r){var n;const o=p(e,t);if(!o||o.kind!=="Object"||!o.fields)return;if(r.length===0)return o;const[i,...a]=r,l=(n=o.fields.find(s=>s.name===i))==null?void 0:n.typeName;if(l)return h(e,l,a)}function m(e,t,r){const n=h(e,r,(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(i=>i.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.nonNull):!0}function v(e){var t,r;return(r=(t=e.fields)==null?void 0:t.filter(n=>n.kind==="Scalar"||n.kind==="Enum"))==null?void 0:r.filter(N).map(n=>n.name)}function Q(e){return v(e).join(` | ||
`)}function k(e,t){var n;const r=m(e,t,"Mutation");return(n=p(e,"Mutation"))==null?void 0:n.fields.find(o=>o.typeName===r.typeName)}function U(e,t){const r=m(e,t,"Mutation");return Q(r)}function C(e){const t=e.nonNull?"!":"",r=e.listNonNull?"!":"",n=e.list?`[${e.typeName}${t||r}]`:`${e.typeName}${t}`;return`$${e.name}: ${n}`}function b(e){return e.length===0?"":`(${e.map(C).join(", ")})`}function E(e){return e.length===0?"":`(${e.map(t=>`${t.name}: $${t.name}`).join(", ")})`}function F(e,t,r){const{simplifiedEntities:n}=e,o=t.split("."),i=o.shift(),a=k(n,i);if(!a)throw new Error(`Can't generate ${r} Mutation`);const l=U(n,t),s="}".repeat(o.length-1),y=b(a.args),d=E(a.args),f=`${l||""} | ||
${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} ${i}${y} { | ||
${i}${d} { | ||
${z} ${r}${y} { | ||
${r}${d} { | ||
${H}{ | ||
@@ -20,19 +20,19 @@ ${f} | ||
}${s} | ||
`.trim()}function j(e,t){var o;const r=(o=e==null?void 0:e.fields)==null?void 0:o.filter(i=>i.kind==="Scalar").map(i=>i.name);if(!r)throw new Error("Can't find relatedFields");const n=r.filter(i=>t.includes(i));return n.length===0?r[0]:n.join(` | ||
`)}function w(e,t){var r,n;return(n=(r=e.fields)==null?void 0:r.filter(o=>o.kind===t))==null?void 0:n.filter(N)}function L(e){return`{ | ||
`.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`{ | ||
${e} | ||
}`}function g(e,t){return`${e} ${L(t)}`}function M(e,t,r){const n=$(e,"typeName",r.typeName);return j(n,t)}function R(e,t,r){var n;return(n=w(t,"Object"))==null?void 0:n.map(o=>{const i=M(e,r,o);if(i)return g(o.name,i)}).filter(o=>o)}function P(e,t,r){var n;return(n=R(e,t,r))==null?void 0:n.join(` | ||
`)}function D(e,t){return t.map(r=>$(e,"typeName",r))}function S(e,t,r){return j(t,r)}function V(e,t,r){const n=S(e,t,r);return g(`... on ${t.typeName}`,n)}function O(e,t,r){var n;return(n=w(t,"Union"))==null?void 0:n.map(o=>{const i=D(e,o.possibleTypes||[]).map(a=>V(e,a,r)).join(` | ||
`);return g(o.name,i)}).join(` | ||
`)}function W(e,t,r){var a,l;const n=t.split("."),o=n.pop(),i=m(e,n[0]?n.join("."):void 0,r);if(i.kind==="Object"||i.kind==="Interface")return(l=(a=i==null?void 0:i.fields)==null?void 0:a.find(s=>s.name===o))==null?void 0:l.args}function x(e,t,r,n,o){const i=r.split("."),a=i.pop(),l=e!=null&&e.fields?Q(e):void 0,s=P(t,e,n),y=O(t,e,n),d=i.length-1>0?"}".repeat(i.length-1):"",f=W(t,r,o);return{dividedPath:i,name:a,fields:l,relatedObjectFields:s,relatedUnionFields:y,closingBraces:d,variableDeclaration:b(f),variableUsage:E(f)}}function B(e,t,r){const{simplifiedEntities:n,config:{nodeRepresentatives:o}}=e,i=T(n,t);if(!i)throw new Error("Can't generate List Query");const a=p(n,i.typeName);if(!a)throw new Error("Can't generate List Query");const l=x(a,n,t,o,"Query"),s=r(i,l,a);return{variables:l,fieldsBlock:s}}function q(e,t){const{config:{nodeRepresentatives:r}}=e,n=(a,l,s)=>{const y=v(s).filter(f=>["id",...r].includes(f)).join(` | ||
}`}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(` | ||
`);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(` | ||
`),d=a.dataPath.split(".");return`${d.join(` { | ||
`)} { | ||
${y||""}${"}".repeat(d.length)}`},{variables:o,fieldsBlock:i}=B(e,t,n);return u(o,i,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 r=(i,a)=>{const l=i.dataPath.split(".");return`${l.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(` { | ||
`)} { | ||
${a.fields||""} | ||
${a.relatedObjectFields||""} | ||
${a.relatedUnionFields||""}${"}".repeat(l.length)} | ||
${i.totalPath}`},{variables:n,fieldsBlock:o}=B(e,t,r);return u(n,o,n.name)}function K(e,t){const{simplifiedEntities:r,config:{nodeRepresentatives:n}}=e,o=m(r,t,"Query");if(!o)throw new Error("Can't generate Show Query");const i=x(o,r,t,n,"Query"),a=`${i.fields||""} | ||
${i.relatedObjectFields||""} | ||
${i.relatedUnionFields||""}`;return u(i,a,i.name)}function _(e,t){return F(e,t,"Update")}c.createMinimumQueryForList=q,c.createQueryForCreate=A,c.createQueryForDelete=G,c.createQueryForList=I,c.createQueryForShow=K,c.createQueryForUpdate=_,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}); | ||
${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"})}); | ||
//# sourceMappingURL=index.umd.js.map |
@@ -28,3 +28,3 @@ function m(e, t, i) { | ||
const [r, ...a] = i, l = (n = o.fields.find( | ||
(c) => c.name === r | ||
(s) => s.name === r | ||
)) == null ? void 0 : n.typeName; | ||
@@ -52,3 +52,3 @@ if (l) | ||
function N(e) { | ||
return e.args ? !e.args.find((t) => t.nonNull) : !0; | ||
return e.args ? !e.args.find((t) => t.isNonNull) : !0; | ||
} | ||
@@ -72,12 +72,12 @@ function h(e) { | ||
} | ||
function C(e, t) { | ||
function L(e, t) { | ||
const i = f(e, t, "Mutation"); | ||
return v(i); | ||
} | ||
function R(e) { | ||
const t = e.nonNull ? "!" : "", i = e.listNonNull ? "!" : "", n = e.list ? `[${e.typeName}${t || i}]` : `${e.typeName}${t}`; | ||
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 x(e) { | ||
return e.length === 0 ? "" : `(${e.map(R).join(", ")})`; | ||
return e.length === 0 ? "" : `(${e.map(C).join(", ")})`; | ||
} | ||
@@ -91,7 +91,7 @@ function b(e) { | ||
throw new Error(`Can't generate ${i} Mutation`); | ||
const l = C(n, t), c = "}".repeat(o.length - 1), d = x(a.args), s = b(a.args), u = `${l || ""} | ||
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]; | ||
return ` | ||
${j} ${r}${d} { | ||
${r}${s} { | ||
${r}${c} { | ||
${k}{ | ||
@@ -101,3 +101,3 @@ ${u} | ||
} | ||
}${c} | ||
}${s} | ||
`.trim(); | ||
@@ -118,3 +118,3 @@ } | ||
} | ||
function L(e) { | ||
function R(e) { | ||
return `{ | ||
@@ -125,3 +125,3 @@ ${e} | ||
function F(e, t) { | ||
return `${e} ${L(t)}`; | ||
return `${e} ${R(t)}`; | ||
} | ||
@@ -181,6 +181,6 @@ function M(e, t, i) { | ||
if (r.kind === "Object" || r.kind === "Interface") | ||
return (l = (a = r == null ? void 0 : r.fields) == null ? void 0 : a.find((c) => c.name === o)) == null ? void 0 : l.args; | ||
return (l = (a = r == null ? void 0 : r.fields) == null ? void 0 : a.find((s) => s.name === o)) == null ? void 0 : l.args; | ||
} | ||
function B(e, t, i, n, o) { | ||
const r = i.split("."), a = r.pop(), l = e != null && e.fields ? v(e) : void 0, c = D( | ||
const r = i.split("."), a = r.pop(), l = e != null && e.fields ? v(e) : void 0, s = D( | ||
t, | ||
@@ -193,3 +193,3 @@ e, | ||
n | ||
), s = r.length - 1 > 0 ? "}".repeat(r.length - 1) : "", u = q(t, i, o); | ||
), c = r.length - 1 > 0 ? "}".repeat(r.length - 1) : "", u = q(t, i, o); | ||
return { | ||
@@ -199,5 +199,5 @@ dividedPath: r, | ||
fields: l, | ||
relatedObjectFields: c, | ||
relatedObjectFields: s, | ||
relatedUnionFields: d, | ||
closingBraces: s, | ||
closingBraces: c, | ||
variableDeclaration: x(u), | ||
@@ -223,4 +223,4 @@ variableUsage: b(u) | ||
"Query" | ||
), c = i(r, l, a); | ||
return { variables: l, fieldsBlock: c }; | ||
), s = i(r, l, a); | ||
return { variables: l, fieldsBlock: s }; | ||
} | ||
@@ -230,8 +230,8 @@ function A(e, t) { | ||
config: { nodeRepresentatives: i } | ||
} = e, n = (a, l, c) => { | ||
const d = h(c).filter((u) => ["id", ...i].includes(u)).join(` | ||
`), s = a.dataPath.split("."); | ||
return `${s.join(` { | ||
} = e, n = (a, l, s) => { | ||
const d = h(s).filter((u) => ["id", ...i].includes(u)).join(` | ||
`), c = a.dataPath.split("."); | ||
return `${c.join(` { | ||
`)} { | ||
${d || ""}${"}".repeat(s.length)}`; | ||
${d || ""}${"}".repeat(c.length)}`; | ||
}, { variables: o, fieldsBlock: r } = Q(e, t, n); | ||
@@ -238,0 +238,0 @@ return m( |
@@ -1,15 +0,15 @@ | ||
(function(c,u){typeof exports=="object"&&typeof module!="undefined"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(c=typeof globalThis!="undefined"?globalThis:c||self,u(c["@theconcurrent/query"]={}))})(this,function(c){"use strict";function u(e,t,r){const{dividedPath:n,name:o,closingBraces:i,variableDeclaration:a,variableUsage:l}=e;return` | ||
query ${r}${a} { | ||
(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` | ||
query ${i}${a} { | ||
${n.join(".").replace(/\./g,` { | ||
`)} ${n.length===0?"":"{"} | ||
${o}${l} { | ||
${o}${c} { | ||
${t} | ||
} | ||
} | ||
${n.length===0?"":"}"}${i} | ||
`.trim()}function $(e,t,r){return e.find(n=>n[t]===r)}function p(e,t){return $(e,"typeName",t)}function h(e,t,r){var n;const o=p(e,t);if(!o||o.kind!=="Object"||!o.fields)return;if(r.length===0)return o;const[i,...a]=r,l=(n=o.fields.find(s=>s.name===i))==null?void 0:n.typeName;if(l)return h(e,l,a)}function m(e,t,r){const n=h(e,r,(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(i=>i.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.nonNull):!0}function v(e){var t,r;return(r=(t=e.fields)==null?void 0:t.filter(n=>n.kind==="Scalar"||n.kind==="Enum"))==null?void 0:r.filter(N).map(n=>n.name)}function Q(e){return v(e).join(` | ||
`)}function k(e,t){var n;const r=m(e,t,"Mutation");return(n=p(e,"Mutation"))==null?void 0:n.fields.find(o=>o.typeName===r.typeName)}function U(e,t){const r=m(e,t,"Mutation");return Q(r)}function C(e){const t=e.nonNull?"!":"",r=e.listNonNull?"!":"",n=e.list?`[${e.typeName}${t||r}]`:`${e.typeName}${t}`;return`$${e.name}: ${n}`}function b(e){return e.length===0?"":`(${e.map(C).join(", ")})`}function E(e){return e.length===0?"":`(${e.map(t=>`${t.name}: $${t.name}`).join(", ")})`}function F(e,t,r){const{simplifiedEntities:n}=e,o=t.split("."),i=o.shift(),a=k(n,i);if(!a)throw new Error(`Can't generate ${r} Mutation`);const l=U(n,t),s="}".repeat(o.length-1),y=b(a.args),d=E(a.args),f=`${l||""} | ||
${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} ${i}${y} { | ||
${i}${d} { | ||
${z} ${r}${y} { | ||
${r}${d} { | ||
${H}{ | ||
@@ -20,19 +20,19 @@ ${f} | ||
}${s} | ||
`.trim()}function j(e,t){var o;const r=(o=e==null?void 0:e.fields)==null?void 0:o.filter(i=>i.kind==="Scalar").map(i=>i.name);if(!r)throw new Error("Can't find relatedFields");const n=r.filter(i=>t.includes(i));return n.length===0?r[0]:n.join(` | ||
`)}function w(e,t){var r,n;return(n=(r=e.fields)==null?void 0:r.filter(o=>o.kind===t))==null?void 0:n.filter(N)}function L(e){return`{ | ||
`.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`{ | ||
${e} | ||
}`}function g(e,t){return`${e} ${L(t)}`}function M(e,t,r){const n=$(e,"typeName",r.typeName);return j(n,t)}function R(e,t,r){var n;return(n=w(t,"Object"))==null?void 0:n.map(o=>{const i=M(e,r,o);if(i)return g(o.name,i)}).filter(o=>o)}function P(e,t,r){var n;return(n=R(e,t,r))==null?void 0:n.join(` | ||
`)}function D(e,t){return t.map(r=>$(e,"typeName",r))}function S(e,t,r){return j(t,r)}function V(e,t,r){const n=S(e,t,r);return g(`... on ${t.typeName}`,n)}function O(e,t,r){var n;return(n=w(t,"Union"))==null?void 0:n.map(o=>{const i=D(e,o.possibleTypes||[]).map(a=>V(e,a,r)).join(` | ||
`);return g(o.name,i)}).join(` | ||
`)}function W(e,t,r){var a,l;const n=t.split("."),o=n.pop(),i=m(e,n[0]?n.join("."):void 0,r);if(i.kind==="Object"||i.kind==="Interface")return(l=(a=i==null?void 0:i.fields)==null?void 0:a.find(s=>s.name===o))==null?void 0:l.args}function x(e,t,r,n,o){const i=r.split("."),a=i.pop(),l=e!=null&&e.fields?Q(e):void 0,s=P(t,e,n),y=O(t,e,n),d=i.length-1>0?"}".repeat(i.length-1):"",f=W(t,r,o);return{dividedPath:i,name:a,fields:l,relatedObjectFields:s,relatedUnionFields:y,closingBraces:d,variableDeclaration:b(f),variableUsage:E(f)}}function B(e,t,r){const{simplifiedEntities:n,config:{nodeRepresentatives:o}}=e,i=T(n,t);if(!i)throw new Error("Can't generate List Query");const a=p(n,i.typeName);if(!a)throw new Error("Can't generate List Query");const l=x(a,n,t,o,"Query"),s=r(i,l,a);return{variables:l,fieldsBlock:s}}function q(e,t){const{config:{nodeRepresentatives:r}}=e,n=(a,l,s)=>{const y=v(s).filter(f=>["id",...r].includes(f)).join(` | ||
}`}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(` | ||
`);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(` | ||
`),d=a.dataPath.split(".");return`${d.join(` { | ||
`)} { | ||
${y||""}${"}".repeat(d.length)}`},{variables:o,fieldsBlock:i}=B(e,t,n);return u(o,i,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 r=(i,a)=>{const l=i.dataPath.split(".");return`${l.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(` { | ||
`)} { | ||
${a.fields||""} | ||
${a.relatedObjectFields||""} | ||
${a.relatedUnionFields||""}${"}".repeat(l.length)} | ||
${i.totalPath}`},{variables:n,fieldsBlock:o}=B(e,t,r);return u(n,o,n.name)}function K(e,t){const{simplifiedEntities:r,config:{nodeRepresentatives:n}}=e,o=m(r,t,"Query");if(!o)throw new Error("Can't generate Show Query");const i=x(o,r,t,n,"Query"),a=`${i.fields||""} | ||
${i.relatedObjectFields||""} | ||
${i.relatedUnionFields||""}`;return u(i,a,i.name)}function _(e,t){return F(e,t,"Update")}c.createMinimumQueryForList=q,c.createQueryForCreate=A,c.createQueryForDelete=G,c.createQueryForList=I,c.createQueryForShow=K,c.createQueryForUpdate=_,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}); | ||
${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"})}); | ||
//# sourceMappingURL=index.umd.js.map |
@@ -49,6 +49,6 @@ /// <reference types="react" /> | ||
kind: 'Object' | 'Scalar' | 'Enum' | 'InputObject' | 'Union' | 'Interface'; | ||
nonNull: boolean; | ||
listNonNull?: boolean; | ||
list: boolean; | ||
enum: boolean; | ||
isNonNull: boolean; | ||
isListNonNull?: boolean; | ||
isList: boolean; | ||
isEnum: boolean; | ||
possibleTypes?: Array<string>; | ||
@@ -75,6 +75,2 @@ args?: Array<SimplifiedField>; | ||
}; | ||
type Directive = { | ||
name: string; | ||
args: Record<string, unknown> | undefined; | ||
}; | ||
type Field = { | ||
@@ -95,15 +91,5 @@ name: string; | ||
name: string; | ||
typeName: string; | ||
description: string; | ||
kind: string; | ||
isList: boolean; | ||
isNonNull: boolean; | ||
isScalar: boolean; | ||
enumValues: Array<{ | ||
name: string; | ||
description: string; | ||
}>; | ||
label: string | undefined; | ||
directives: Array<Directive> | undefined; | ||
inputFields: VariableDefinitionObject[]; | ||
variable: ScalarSimplifiedEntityType | InputObjectSimplifiedEntityType | EnumSimplifiedEntityType; | ||
}; | ||
@@ -114,3 +100,3 @@ export type FieldObject = { | ||
description: string | undefined; | ||
kind: 'Scalar' | 'Object' | 'Enum'; | ||
kind: 'Scalar' | 'Object' | 'Enum' | 'InputObject'; | ||
isList: boolean; | ||
@@ -117,0 +103,0 @@ isNonNull: boolean; |
@@ -5,6 +5,6 @@ import type { DirectiveInfo, EnumSimplifiedEntityType, InputObjectSimplifiedEntityType, InterfaceSimplifiedEntityType, ObjectSimplifiedEntityType, ScalarSimplifiedEntityType, SimplifiedDirectiveType, SimplifiedEntityType, SimplifiedField, TypeNameAndDescriptionAndDirective, UnionSimplifiedEntityType } from './shared/base_type'; | ||
name: string; | ||
nonNull: boolean; | ||
listNonNull?: boolean; | ||
isNonNull: boolean; | ||
isListNonNull?: boolean; | ||
typeName: string; | ||
list: boolean; | ||
isList: boolean; | ||
}; | ||
@@ -11,0 +11,0 @@ export type Variables = { |
{ | ||
"name": "@theconcurrent/query", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"main": "./dist/index.umd.js", | ||
@@ -27,8 +27,8 @@ "module": "./dist/index.es.js", | ||
"dependencies": { | ||
"@theconcurrent/utility": "0.0.15" | ||
"@theconcurrent/utility": "0.0.16" | ||
}, | ||
"peerDependencies": { | ||
"@theconcurrent/utility": "0.0.15" | ||
"@theconcurrent/utility": "0.0.16" | ||
}, | ||
"gitHead": "0be5547c52194a6f3163980362213f38446db02f" | ||
"gitHead": "65f44097b9fb1d2ec36c92b8d530db725aa71f52" | ||
} |
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
104795
0.46%646
-2.12%+ Added
- Removed