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

@theconcurrent/resource

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/resource - npm Package Compare versions

Comparing version 0.0.22 to 0.0.23

15

./dist/index.umd.js

@@ -1,7 +0,12 @@

(function(h,y){typeof exports=="object"&&typeof module!="undefined"?y(exports,require("@theconcurrent/query"),require("@theconcurrent/utility"),require("graphql")):typeof define=="function"&&define.amd?define(["exports","@theconcurrent/query","@theconcurrent/utility","graphql"],y):(h=typeof globalThis!="undefined"?globalThis:h||self,y(h["@theconcurrent/resource"]={},h.query,h.utility,h.graphql))})(this,function(h,y,m,c){"use strict";function O(n,t,i,a,e){var u,f,s;if(!n)return;const o=t?(u=m.getField(n,t))==null?void 0:u.fields:n.fields,r=i.find(p=>p.typeName===a.name);return{fields:(o||[]).map(p=>e?e.find(l=>l.name===p.name)?{...p,isSortable:!0}:{...p}:p),displayColumns:(s=(f=r==null?void 0:r.directives)==null?void 0:f.find(p=>p.name==="model"))==null?void 0:s.args.displayColumns}}var T=function(){return T=Object.assign||function(t){for(var i,a=1,e=arguments.length;a<e;a++){i=arguments[a];for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(t[o]=i[o])}return t},T.apply(this,arguments)};typeof SuppressedError=="function"&&SuppressedError;var w=new Map,$=new Map,P=!0,q=!1;function R(n){return n.replace(/[\s,]+/g," ").trim()}function B(n){return R(n.source.body.substring(n.start,n.end))}function I(n){var t=new Set,i=[];return n.definitions.forEach(function(a){if(a.kind==="FragmentDefinition"){var e=a.name.value,o=B(a.loc),r=$.get(e);r&&!r.has(o)?P&&console.warn("Warning: fragment with name "+e+` already exists.
(function(h,y){typeof exports=="object"&&typeof module!="undefined"?y(exports,require("@theconcurrent/query"),require("graphql"),require("@theconcurrent/utility")):typeof define=="function"&&define.amd?define(["exports","@theconcurrent/query","graphql","@theconcurrent/utility"],y):(h=typeof globalThis!="undefined"?globalThis:h||self,y(h["@theconcurrent/resource"]={},h.query,h.graphql,h.utility))})(this,function(h,y,p,d){"use strict";var E=function(){return E=Object.assign||function(t){for(var i,a=1,n=arguments.length;a<n;a++){i=arguments[a];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t},E.apply(this,arguments)};typeof SuppressedError=="function"&&SuppressedError;var T=new Map,k=new Map,$=!0,F=!1;function R(e){return e.replace(/[\s,]+/g," ").trim()}function I(e){return R(e.source.body.substring(e.start,e.end))}function W(e){var t=new Set,i=[];return e.definitions.forEach(function(a){if(a.kind==="FragmentDefinition"){var n=a.name.value,r=I(a.loc),o=k.get(n);o&&!o.has(r)?$&&console.warn("Warning: fragment with name "+n+` already exists.
graphql-tag enforces all fragment names across your application to be unique; read more about
this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):r||$.set(e,r=new Set),r.add(o),t.has(o)||(t.add(o),i.push(a))}else i.push(a)}),T(T({},n),{definitions:i})}function W(n){var t=new Set(n.definitions);t.forEach(function(a){a.loc&&delete a.loc,Object.keys(a).forEach(function(e){var o=a[e];o&&typeof o=="object"&&t.add(o)})});var i=n.loc;return i&&(delete i.startToken,delete i.endToken),n}function A(n){var t=R(n);if(!w.has(t)){var i=c.parse(n,{experimentalFragmentVariables:q,allowLegacyFragmentVariables:q});if(!i||i.kind!=="Document")throw new Error("Not a valid GraphQL document.");w.set(t,W(I(i)))}return w.get(t)}function g(n){for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];typeof n=="string"&&(n=[n]);var a=n[0];return t.forEach(function(e,o){e&&e.kind==="Document"?a+=e.loc.source.body:a+=e,a+=n[o+1]}),A(a)}function z(){w.clear(),$.clear()}function G(){P=!1}function L(){q=!0}function H(){q=!1}var N={gql:g,resetCaches:z,disableFragmentWarnings:G,enableExperimentalFragmentVariables:L,disableExperimentalFragmentVariables:H};(function(n){n.gql=N.gql,n.resetCaches=N.resetCaches,n.disableFragmentWarnings=N.disableFragmentWarnings,n.enableExperimentalFragmentVariables=N.enableExperimentalFragmentVariables,n.disableExperimentalFragmentVariables=N.disableExperimentalFragmentVariables})(g||(g={})),g.default=g;function b(n,t,i,a){if(t.queries.find(r=>r.name===i))return t.queries;const o=`${a(n,t.path)}`;try{const r=g`
${o}
`;return[...t.queries,{name:i,gql:r}]}catch(r){throw console.error(r,t,i),console.error(o.replace(/\\n/g,`
`)),new Error(`Failed to create query for ${i}`)}}function E(n,t){if(n)return n.queries.find(i=>i.name===t)}function J(n){return c.isEnumType(n.type)||c.isNonNullType(n.type)&&c.isEnumType(n.type.ofType)}function X(n){return c.isListType(n.type)||c.isNonNullType(n.type)&&c.isListType(n.type.ofType)}function Y(n){return!!(c.isScalarType(n.type)||c.isNonNullType(n.type)&&(c.isScalarType(n.type.ofType)||c.isListType(n.type.ofType)&&(c.isScalarType(n.type.ofType.ofType)||c.isNonNullType(n.type.ofType.ofType)&&c.isScalarType(n.type.ofType.ofType.ofType))))}function Z(n,t){return n?"Scalar":t?"Enum":"Object"}function K(n,t){var a,e,o;if(!t||!t.fields)throw new Error(`Parent entity not found: ${n}`);const i=t.fields.find(r=>r.name===n);return(o=(e=(a=i==null?void 0:i.directives)==null?void 0:a.find(r=>r.name==="label"))==null?void 0:e.args)==null?void 0:o.name}function _(n){if(n&&n.kind==="Enum")return n.enumValues}function C(n,t,i){var d,v;const a=X(n),e=c.isNonNullType(n.type),o=c.getNamedType(n.type).toString(),r=J(n),u=Y(n),f=m.getEntityByName(t,o),s=m.getEntityByName(t,i),p=K(n.name,s),l=_(f);return{name:n.name,isList:a,isNonNull:e,typeName:o,isScalar:u,isEnum:r,kind:Z(u,r),description:n.description,schemaDirectives:f==null?void 0:f.directives,label:p,enumValues:l,collection:(v=(d=f==null?void 0:f.directives)==null?void 0:d.find(Q=>Q.name==="collection"))==null?void 0:v.args,isUnion:(f==null?void 0:f.kind)==="Union"}}function U(n,t,i,a){const e=C(n,i,a);return e.isScalar||e.isEnum?e:{...e,fields:[]}}function D(n,t){const i=m.getEntityByName(t,n.name.value);if(!i)throw new Error("entity type not found");return i}function j(n,t){switch(n.kind){case"NamedType":return{variable:D(n,t),isNonNull:!1,isList:!1};case"NonNullType":return{...j(n.type,t),isNonNull:!0};case"ListType":return{...j(n.type,t),isList:!0};default:throw new Error("extractType error")}}function nn(n,t){return{...j(n.type,t),name:n.variable.name.value}}function k(n,t,i=0){var e;if(i>=t.length)return n;const a={...n};return a.fields=(e=n.fields)==null?void 0:e.map(o=>o.fields?{...o,representativeField:o.fields.find(r=>r.name===t.find(u=>{var f;return(f=o.fields)==null?void 0:f.find(s=>s.name===u)})),fields:k(o,t,i+1).fields}:o),a}function x(n,t,i,a){const e=new c.TypeInfo(n);let o=null;const r=[],u=[],f={VariableDefinition:{enter(s){u.push(nn(s,i))}},Field:{enter(s){var v,Q,M;const p=e.getParentType();if(!p)throw new Error("Parent type not found");const l=e.getFieldDef();if(!l)throw new Error("Field definition not found");const d=U(l,s,i,p.name);if(p.toString()===((v=n.getQueryType())==null?void 0:v.name)||p.toString()===((Q=n.getMutationType())==null?void 0:Q.name)){o=d,r.push(d);return}o&&((M=r[r.length-1].fields)==null||M.push(d),!d.isScalar&&!d.isEnum&&r.push(d))},leave(s){r.length>1&&s.selectionSet&&r.pop()}}};if(c.visit(t,c.visitWithTypeInfo(e,f)),!o)throw new Error("Couldn't find query object");return{queryObject:k(o,a),variableDefinitionObjects:u}}function tn(n,t,i,a){const{queryObject:e,variableDefinitionObjects:o}=x(n,t,i,a);if(!e)throw new Error("Query object not generated");return{structure:e,variableDefinitionObjects:o}}function en(n,t,i,a){const{queryObject:e,variableDefinitionObjects:o}=x(n,t,i,a);if(!e)throw new Error("Query object not generated");return{structure:e,variablesStructure:o}}function S(n,t){return en(n.graphqlSchema,t,n.simplifiedEntities,n.config.nodeRepresentatives)}function V(n,t){return tn(n.graphqlSchema,t,n.simplifiedEntities,n.config.nodeRepresentatives)}function F(n,t,i,a){var o,r;if(!t)return;if(a&&i)return{...t,responseDataPath:{data:`${i}.nodes`,total:`${i}.totalCount`}};if(i)return{...t,responseDataPath:{data:`${i}`}};const e=(r=(o=t.queries)==null?void 0:o.find(u=>u.name==="main"))==null?void 0:r.gql;if(!e)throw new Error("Can't find gql");return{...t,responseDataPath:{data:`${e.definitions[0].name.value}.${m.lowercaseFirstLetter(n)}`}}}function an(n){var t,i;return((i=(t=n==null?void 0:n.find(a=>a.name==="label"))==null?void 0:t.args)==null?void 0:i.name)||void 0}function rn(n){if(n)return c.print(n)}function on(){return[]}function un(n,t,i,a,e){if(!t)return;const o=rn(e==null?void 0:e.gql),u=n.filter(p=>p.kind==="Object").find(p=>{var d;const l=(d=p.directives)==null?void 0:d.find(v=>v.name==="collection");return l?l.args.typeName===i.typeName:!1});if(!u)return;const f=m.generatePath(n,t.typeName,u.typeName,a),s=(e==null?void 0:e.queries)||on();if(f)return{path:f,...e||{},query:o,queries:s};if(e!=null&&e.path)return{...e,path:e.path,queries:s}}function fn(n){if(n)return c.print(n)}function sn(){return[]}function pn(n,t,i,a,e){if(!t)return;const o=fn(e==null?void 0:e.gql),r=m.generatePath(n,t.typeName,i.typeName,a),u=(e==null?void 0:e.queries)||sn();if(r)return{path:r,...e||{},query:o,queries:u};if(e!=null&&e.path)return{...e,path:e.path,queries:u}}function cn(n){if(n)return c.print(n)}function ln(){return[]}function mn(n,t,i,a,e){if(!e||!t)return;const o=cn(e==null?void 0:e.gql),r=m.generatePath(n,t.typeName,i.typeName,a),u=r==null?void 0:r.split(".").pop(),f=`${u}Create.${u}`,s=(e==null?void 0:e.queries)||ln();if(f)return{path:f,...e||{},query:o,queries:s};if(e!=null&&e.path)return{...e,path:e.path,queries:s}}function dn(n){if(n)return c.print(n)}function yn(){return[]}function hn(n,t,i,a,e){if(!e||!t)return;const o=dn(e==null?void 0:e.gql),r=m.generatePath(n,t.typeName,i.typeName,a),u=r==null?void 0:r.split(".").pop(),f=`${u}Update.${u}`,s=(e==null?void 0:e.queries)||yn();if(f)return{path:f,...e||{},query:o,queries:s};if(e!=null&&e.path)return{...e,path:e.path,queries:s}}function vn(n){if(n)return c.print(n)}function gn(){return[]}function bn(n,t,i,a,e){if(!e||!t)return;const o=vn(e==null?void 0:e.gql),r=m.generatePath(n,t.typeName,i.typeName,a),u=r==null?void 0:r.split(".").pop(),f=`${u}Delete.${u}`,s=(e==null?void 0:e.queries)||gn();if(f)return{path:f,...e||{},query:o,queries:s};if(e!=null&&e.path)return{...e,path:e.path,queries:s}}function Nn(n,t){var f,s;const{simplifiedEntities:i,config:a}=t,e=a.adminPath?`${a.adminPath}.`:"",o=i.find(p=>{var l;return(l=p.directives)==null?void 0:l.find(d=>d.name==="queryRoot")}),r=m.findEntityFromPath(i,o.typeName,((f=a.adminPath)==null?void 0:f.split("."))||[]),u=(s=a.resources)==null?void 0:s.find(p=>p.name===n.typeName);return{label:an(n.directives),name:n.typeName,typeName:n.typeName,skipMenu:u==null?void 0:u.skipMenu,list:un(i,r,n,e,u==null?void 0:u.list),show:pn(i,r,n,e,u==null?void 0:u.show),create:mn(i,r,n,e,u==null?void 0:u.create),update:hn(i,r,n,e,u==null?void 0:u.update),delete:bn(i,r,n,e,u==null?void 0:u.delete)}}function En(n,t,i,a){const e=n===""?i:m.findEntityFromPath(t,"Query",n.split("."));if(!e)throw new Error("adminEntity not found");const o=e.fields.map(r=>r.typeName);return m.filterEntitiesByDirectiveName(t,"model").filter(r=>o.includes(r.typeName)).map(r=>Nn(r,a))}function Fn(n){var u,f,s,p;const{simplifiedEntities:t,config:i}=n,a=m.findEntityByDirectiveName(t,"queryRoot");if(!a)throw new Error("queryRoot not found");const e=(s=(f=(u=a.directives)==null?void 0:u.find(l=>l.name==="queryRoot"))==null?void 0:f.args)==null?void 0:s.adminPaths;if(!e)throw new Error("adminPaths not found");const o=e.map(l=>En(l,t,a,n)).flat(),r=((p=i.resources)==null?void 0:p.map(l=>l.name))||o.map(l=>l.name);return m.sortDataByOrder(o,r,"name")}function Tn(n,t){var a,e,o,r,u;const i="main";return{...t,create:(a=t.create)!=null&&a.path?{...t.create,queries:b(n,t.create,i,y.createQueryForCreate)}:t.create,update:(e=t.update)!=null&&e.path?{...t.update,queries:b(n,t.update,i,y.createQueryForUpdate)}:t.update,delete:(o=t.delete)!=null&&o.path?{...t.delete,queries:b(n,t.delete,i,y.createQueryForDelete)}:t.delete,show:(r=t.show)!=null&&r.path?{...t.show,queries:b(n,t.show,i,y.createQueryForShow)}:t.show,list:(u=t.list)!=null&&u.path?{...t.list,queries:b(n,t.list,i,y.createQueryForList)}:t.list}}function wn(n,t){var a;const i=E(t.list,"minimum");return{...t,list:(a=t.list)!=null&&a.path&&!i?{...t.list,queries:b(n,t.list,"minimum",y.createMinimumQueryForList)}:t.list}}function qn(n,t){const i="main",a=E(t.create,i),e=E(t.update,i),o=E(t.show,i),r=E(t.list,i);return{...t,create:a?{...t.create,...V(n,a.gql)}:t.create,update:e?{...t.update,...V(n,e.gql)}:t.update,show:o?{...t.show,...S(n,o.gql)}:t.show,list:r?{...t.list,...S(n,r.gql)}:t.list}}function Qn(n,t){var o,r,u,f;const{simplifiedEntities:i}=n,{show:a,list:e}=t;return{...t,show:a&&{...a,...O(a.structure,a.path,i,t)},list:e&&{...e,...O(e.structure,`${e.path}.nodes`,i,t,(f=(u=(r=(o=e==null?void 0:e.variablesStructure.find(s=>s.name==="sort"))==null?void 0:o.inputFields)==null?void 0:r.find(s=>s.typeName!=="BaseSortOrder"))==null?void 0:u.enumValues)==null?void 0:f.map(s=>({name:s.name})))}}}function $n(n,t){var i,a;return{...t,create:F(t.name,t.create),update:F(t.name,t.update),delete:F(t.name,t.delete),show:F(t.name,t.show,(i=t.show)==null?void 0:i.path),list:F(t.name,t.list,(a=t.list)==null?void 0:a.path,!0)}}function jn(n){return Fn(n).map(t=>Tn(n,t)).map(t=>wn(n,t)).map(t=>qn(n,t)).map(t=>Qn(n,t)).map(t=>$n(n,t))}h.convert=jn,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):o||k.set(n,o=new Set),o.add(r),t.has(r)||(t.add(r),i.push(a))}else i.push(a)}),E(E({},e),{definitions:i})}function C(e){var t=new Set(e.definitions);t.forEach(function(a){a.loc&&delete a.loc,Object.keys(a).forEach(function(n){var r=a[n];r&&typeof r=="object"&&t.add(r)})});var i=e.loc;return i&&(delete i.startToken,delete i.endToken),e}function L(e){var t=R(e);if(!T.has(t)){var i=p.parse(e,{experimentalFragmentVariables:F,allowLegacyFragmentVariables:F});if(!i||i.kind!=="Document")throw new Error("Not a valid GraphQL document.");T.set(t,C(W(i)))}return T.get(t)}function v(e){for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];typeof e=="string"&&(e=[e]);var a=e[0];return t.forEach(function(n,r){n&&n.kind==="Document"?a+=n.loc.source.body:a+=n,a+=e[r+1]}),L(a)}function A(){T.clear(),k.clear()}function G(){$=!1}function z(){F=!0}function H(){F=!1}var b={gql:v,resetCaches:A,disableFragmentWarnings:G,enableExperimentalFragmentVariables:z,disableExperimentalFragmentVariables:H};(function(e){e.gql=b.gql,e.resetCaches=b.resetCaches,e.disableFragmentWarnings=b.disableFragmentWarnings,e.enableExperimentalFragmentVariables=b.enableExperimentalFragmentVariables,e.disableExperimentalFragmentVariables=b.disableExperimentalFragmentVariables})(v||(v={})),v.default=v;function O(e,t,i,a,n){var s,u,f;if(!e)return;const r=t?(s=d.getField(e,t))==null?void 0:s.fields:e.fields,o=i.find(c=>c.typeName===a.name);return{fields:(r||[]).map(c=>n?n.find(l=>l===c.name)?{...c,isSortable:!0}:{...c}:c),displayColumns:(f=(u=o==null?void 0:o.directives)==null?void 0:u.find(c=>c.name==="model"))==null?void 0:f.args.displayColumns}}function N(e,t,i){const{queries:a}=t;return i.map(n=>{const r=a.find(o=>o.name===n.name);return r&&r.gql?{name:r.name,queryString:p.print(r.gql)}:r&&r.queryString?{name:r.name,queryString:r.queryString}:{name:n.name,queryString:n.callback(e,t.path)}})}function S(e,t){if(e)return e.queries.find(i=>i.name===t)}function J(e){return p.isEnumType(e.type)||p.isNonNullType(e.type)&&p.isEnumType(e.type.ofType)}function X(e){return p.isListType(e.type)||p.isNonNullType(e.type)&&p.isListType(e.type.ofType)}function Y(e){return!!(p.isScalarType(e.type)||p.isNonNullType(e.type)&&(p.isScalarType(e.type.ofType)||p.isListType(e.type.ofType)&&(p.isScalarType(e.type.ofType.ofType)||p.isNonNullType(e.type.ofType.ofType)&&p.isScalarType(e.type.ofType.ofType.ofType))))}function Z(e,t){return e?"Scalar":t?"Enum":"Object"}function K(e,t){var a,n,r;if(!t||!t.fields)throw new Error(`Parent entity not found: ${e}`);const i=t.fields.find(o=>o.name===e);return(r=(n=(a=i==null?void 0:i.directives)==null?void 0:a.find(o=>o.name==="label"))==null?void 0:n.args)==null?void 0:r.name}function _(e){if(e&&e.kind==="Enum")return e.enumValues}function U(e,t,i){var m,g;const a=X(e),n=p.isNonNullType(e.type),r=p.getNamedType(e.type).toString(),o=J(e),s=Y(e),u=d.getEntityByName(t,r),f=d.getEntityByName(t,i),c=K(e.name,f),l=_(u);return{name:e.name,isList:a,isNonNull:n,typeName:r,isScalar:s,isEnum:o,kind:Z(s,o),description:e.description,schemaDirectives:u==null?void 0:u.directives,label:c,enumValues:l,collection:(g=(m=u==null?void 0:u.directives)==null?void 0:m.find(Q=>Q.name==="collection"))==null?void 0:g.args,isUnion:(u==null?void 0:u.kind)==="Union"}}function D(e,t,i,a){const n=U(e,i,a);return n.isScalar||n.isEnum?n:{...n,fields:[]}}function tt(e,t){const i=d.getEntityByName(t,e.name.value);if(!i)throw new Error("entity type not found");return i}function j(e,t){switch(e.kind){case"NamedType":return{variable:tt(e,t),isNonNull:!1,isList:!1};case"NonNullType":return{...j(e.type,t),isNonNull:!0};case"ListType":return{...j(e.type,t),isList:!0};default:throw new Error("extractType error")}}function et(e,t){return{...j(e.type,t),name:e.variable.name.value}}function P(e,t,i=0){var n;if(i>=t.length)return e;const a={...e};return a.fields=(n=e.fields)==null?void 0:n.map(r=>r.fields?{...r,representativeField:r.fields.find(o=>o.name===t.find(s=>{var u;return(u=r.fields)==null?void 0:u.find(f=>f.name===s)})),fields:P(r,t,i+1).fields}:r),a}function x(e,t,i,a){const n=new p.TypeInfo(e);let r=null;const o=[],s=[],u={VariableDefinition:{enter(f){s.push(et(f,i))}},Field:{enter(f){var g,Q,B;const c=n.getParentType();if(!c)throw new Error("Parent type not found");const l=n.getFieldDef();if(!l)throw new Error("Field definition not found");const m=D(l,f,i,c.name);if(c.toString()===((g=e.getQueryType())==null?void 0:g.name)||c.toString()===((Q=e.getMutationType())==null?void 0:Q.name)){r=m,o.push(m);return}r&&((B=o[o.length-1].fields)==null||B.push(m),!m.isScalar&&!m.isEnum&&o.push(m))},leave(f){o.length>1&&f.selectionSet&&o.pop()}}};if(p.visit(t,p.visitWithTypeInfo(n,u)),!r)throw new Error("Couldn't find query object");return{queryObject:P(r,a),variableDefinitionObjects:s}}function nt(e,t,i,a){const{queryObject:n,variableDefinitionObjects:r}=x(e,t,i,a);if(!n)throw new Error("Query object not generated");return{structure:n,variableDefinitionObjects:r}}function it(e,t,i,a){const{queryObject:n,variableDefinitionObjects:r}=x(e,t,i,a);if(!n)throw new Error("Query object not generated");return{structure:n,variablesStructure:r}}function V(e,t){return it(e.graphqlSchema,v`
${t}
`,e.simplifiedEntities,e.config.nodeRepresentatives)}function M(e,t){return nt(e.graphqlSchema,v`
${t}
`,e.simplifiedEntities,e.config.nodeRepresentatives)}function w(e,t,i,a){var o,s;if(!t)return;if(a&&i)return{...t,responseDataPath:{data:`${i}.nodes`,total:`${i}.totalCount`}};if(i)return{...t,responseDataPath:{data:`${i}`}};const n=(s=(o=t.queries)==null?void 0:o.find(u=>u.name==="main"))==null?void 0:s.queryString;if(!n)throw new Error("Can't find gql");const r=v`
${n}
`;return{...t,responseDataPath:{data:`${r.definitions[0].name.value}.${d.lowercaseFirstLetter(e)}`}}}function at(e){var t,i;return((i=(t=e==null?void 0:e.find(a=>a.name==="label"))==null?void 0:t.args)==null?void 0:i.name)||void 0}function rt(){return[]}function ot(e,t,i,a,n){if(!t)return;const o=e.filter(f=>f.kind==="Object").find(f=>{var l;const c=(l=f.directives)==null?void 0:l.find(m=>m.name==="collection");return c?c.args.typeName===i.typeName:!1});if(!o)return;const s=d.generatePath(e,t.typeName,o.typeName,a),u=(n==null?void 0:n.queries)||rt();if(s)return{path:s,...n||{},queries:u};if(n!=null&&n.path)return{...n,path:n.path,queries:u}}function st(){return[]}function ut(e,t,i,a,n){if(!t)return;const r=d.generatePath(e,t.typeName,i.typeName,a),o=(n==null?void 0:n.queries)||st();if(r)return{path:r,...n||{},queries:o};if(n!=null&&n.path)return{...n,path:n.path,queries:o}}function ft(){return[]}function ct(e,t,i,a,n){if(!n||!t)return;const r=d.generatePath(e,t.typeName,i.typeName,a),o=r==null?void 0:r.split(".").pop(),s=`${o}Create.${o}`,u=(n==null?void 0:n.queries)||ft();if(s)return{path:s,...n||{},queries:u};if(n!=null&&n.path)return{...n,path:n.path,queries:u}}function lt(){return[]}function pt(e,t,i,a,n){if(!n||!t)return;const r=d.generatePath(e,t.typeName,i.typeName,a),o=r==null?void 0:r.split(".").pop(),s=`${o}Update.${o}`,u=(n==null?void 0:n.queries)||lt();if(s)return{path:s,...n||{},queries:u};if(n!=null&&n.path)return{...n,path:n.path,queries:u}}function mt(){return[]}function dt(e,t,i,a,n){if(!n||!t)return;const r=d.generatePath(e,t.typeName,i.typeName,a),o=r==null?void 0:r.split(".").pop(),s=`${o}Delete.${o}`,u=(n==null?void 0:n.queries)||mt();if(s)return{path:s,...n||{},queries:u};if(n!=null&&n.path)return{...n,path:n.path,queries:u}}function yt(e,t){var u,f;const{simplifiedEntities:i,config:a}=t,n=a.adminPath?`${a.adminPath}.`:"",r=i.find(c=>{var l;return(l=c.directives)==null?void 0:l.find(m=>m.name==="queryRoot")}),o=d.findEntityFromPath(i,r.typeName,((u=a.adminPath)==null?void 0:u.split("."))||[]),s=(f=a.resources)==null?void 0:f.find(c=>c.name===e.typeName);return{label:at(e.directives),name:e.typeName,typeName:e.typeName,skipMenu:s==null?void 0:s.skipMenu,list:ot(i,o,e,n,s==null?void 0:s.list),show:ut(i,o,e,n,s==null?void 0:s.show),create:ct(i,o,e,n,s==null?void 0:s.create),update:pt(i,o,e,n,s==null?void 0:s.update),delete:dt(i,o,e,n,s==null?void 0:s.delete)}}function ht(e,t,i,a){const n=e===""?i:d.findEntityFromPath(t,"Query",e.split("."));if(!n)throw new Error("adminEntity not found");const r=n.fields.map(o=>o.typeName);return d.filterEntitiesByDirectiveName(t,"model").filter(o=>r.includes(o.typeName)).map(o=>yt(o,a))}function vt(e){var s,u,f,c;const{simplifiedEntities:t,config:i}=e,a=d.findEntityByDirectiveName(t,"queryRoot");if(!a)throw new Error("queryRoot not found");const n=(f=(u=(s=a.directives)==null?void 0:s.find(l=>l.name==="queryRoot"))==null?void 0:u.args)==null?void 0:f.adminPaths;if(!n)throw new Error("adminPaths not found");const r=n.map(l=>ht(l,t,a,e)).flat(),o=((c=i.resources)==null?void 0:c.map(l=>l.name))||r.map(l=>l.name);return d.sortDataByOrder(r,o,"name")}function gt(e,t){var f,c,l,m,g;const i="main",a="minimum",n=[{name:i,callback:y.createQueryForCreate}],r=[{name:i,callback:y.createQueryForUpdate}],o=[{name:i,callback:y.createQueryForDelete}],s=[{name:i,callback:y.createQueryForShow}],u=[{name:i,callback:y.createQueryForList},{name:a,callback:y.createMinimumQueryForList}];return{...t,create:(f=t.create)!=null&&f.path?{...t.create,queries:N(e,t.create,n)}:void 0,update:(c=t.update)!=null&&c.path?{...t.update,queries:N(e,t.update,r)}:void 0,delete:(l=t.delete)!=null&&l.path?{...t.delete,queries:N(e,t.delete,o)}:void 0,show:(m=t.show)!=null&&m.path?{...t.show,queries:N(e,t.show,s)}:void 0,list:(g=t.list)!=null&&g.path?{...t.list,queries:N(e,t.list,u)}:void 0}}function bt(e,t){const i="main",a=S(t.create,i),n=S(t.update,i),r=S(t.show,i),o=S(t.list,i);return{...t,create:a?{...t.create,...M(e,a.queryString)}:t.create,update:n?{...t.update,...M(e,n.queryString)}:t.update,show:r?{...t.show,...V(e,r.queryString)}:t.show,list:o?{...t.list,...V(e,o.queryString)}:t.list}}function Nt(e,t){var n,r,o,s,u;const i=(u=(s=(o=(r=(n=e.variablesStructure)==null?void 0:n.find(f=>f.name==="sort"))==null?void 0:r.variable)==null?void 0:o.inputFields)==null?void 0:s.find(f=>f.name==="field"))==null?void 0:u.typeName,a=t.find(f=>f.typeName===i);return a==null?void 0:a.enumValues.map(f=>f.name)}function wt(e,t){const{simplifiedEntities:i}=e,{show:a,list:n}=t;return{...t,show:a&&{...a,...O(a.structure,a.path,i,t)},list:n&&{...n,...O(n.structure,`${n.path}.nodes`,i,t,Nt(n,i))}}}function qt(e,t){var i,a;return{...t,create:w(t.name,t.create),update:w(t.name,t.update),delete:w(t.name,t.delete),show:w(t.name,t.show,(i=t.show)==null?void 0:i.path),list:w(t.name,t.list,(a=t.list)==null?void 0:a.path,!0)}}function q(e){return e.map(t=>({name:t.name,gql:v`
${t.queryString}
`}))}function Et(e){return vt(e).map(t=>gt(e,t)).map(t=>bt(e,t)).map(t=>wt(e,t)).map(t=>qt(e,t)).map(t=>({...t,create:t.create?{...t.create,queries:q(t.create.queries)}:void 0,delete:t.delete?{...t.delete,queries:q(t.delete.queries)}:void 0,update:t.update?{...t.update,queries:q(t.update.queries)}:void 0,show:t.show?{...t.show,queries:q(t.show.queries)}:void 0,list:t.list?{...t.list,queries:q(t.list.queries)}:void 0}))}h.convert=Et,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
//# sourceMappingURL=index.umd.js.map

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

/// <reference types="react" />
import type { InitialParams } from './type';

@@ -9,9 +8,7 @@ export default function createResources(params: InitialParams): {

list: {
query: string | undefined;
queries: {
name: string;
gql: import("graphql").DocumentNode;
gql?: import("graphql").DocumentNode | undefined;
queryString?: string | undefined;
}[];
gql?: import("graphql").DocumentNode | undefined;
component?: ((props: any) => JSX.Element) | undefined;
responseDataPath?: {

@@ -23,24 +20,9 @@ data: string;

displayColumns?: string[] | undefined;
} | {
path: string;
queries: {
name: string;
gql: import("graphql").DocumentNode;
}[];
gql?: import("graphql").DocumentNode | undefined;
component?: ((props: any) => JSX.Element) | undefined;
responseDataPath?: {
data: string;
total: string;
} | undefined;
displayColumns?: string[] | undefined;
} | undefined;
show: {
query: string | undefined;
queries: {
name: string;
gql: import("graphql").DocumentNode;
gql?: import("graphql").DocumentNode | undefined;
queryString?: string | undefined;
}[];
gql?: import("graphql").DocumentNode | undefined;
component?: ((props: any) => JSX.Element) | undefined;
responseDataPath?: {

@@ -50,22 +32,9 @@ data: string;

path: string;
} | {
path: string;
queries: {
name: string;
gql: import("graphql").DocumentNode;
}[];
gql?: import("graphql").DocumentNode | undefined;
component?: ((props: any) => JSX.Element) | undefined;
responseDataPath?: {
data: string;
} | undefined;
} | undefined;
create: {
query: string | undefined;
queries: {
name: string;
gql: import("graphql").DocumentNode;
gql?: import("graphql").DocumentNode | undefined;
queryString?: string | undefined;
}[];
gql?: import("graphql").DocumentNode | undefined;
component?: ((props: any) => JSX.Element) | undefined;
responseDataPath?: {

@@ -75,22 +44,9 @@ data: string;

path: string;
} | {
path: string;
queries: {
name: string;
gql: import("graphql").DocumentNode;
}[];
gql?: import("graphql").DocumentNode | undefined;
component?: ((props: any) => JSX.Element) | undefined;
responseDataPath?: {
data: string;
} | undefined;
} | undefined;
update: {
query: string | undefined;
queries: {
name: string;
gql: import("graphql").DocumentNode;
gql?: import("graphql").DocumentNode | undefined;
queryString?: string | undefined;
}[];
gql?: import("graphql").DocumentNode | undefined;
component?: ((props: any) => JSX.Element) | undefined;
responseDataPath?: {

@@ -100,21 +56,9 @@ data: string;

path: string;
} | {
path: string;
queries: {
name: string;
gql: import("graphql").DocumentNode;
}[];
gql?: import("graphql").DocumentNode | undefined;
component?: ((props: any) => JSX.Element) | undefined;
responseDataPath?: {
data: string;
} | undefined;
} | undefined;
delete: {
query: string | undefined;
queries: {
name: string;
gql: import("graphql").DocumentNode;
gql?: import("graphql").DocumentNode | undefined;
queryString?: string | undefined;
}[];
gql?: import("graphql").DocumentNode | undefined;
responseDataPath?: {

@@ -124,14 +68,4 @@ data: string;

path: string;
} | {
path: string;
queries: {
name: string;
gql: import("graphql").DocumentNode;
}[];
gql?: import("graphql").DocumentNode | undefined;
responseDataPath?: {
data: string;
} | undefined;
} | undefined;
}[];
//# sourceMappingURL=createResources.d.ts.map
import type { FieldObject, SimplifiedEntityType } from '../type';
export default function createFieldWithSorting(structure: FieldObject, fieldPath: string | undefined, simplifiedEntities: SimplifiedEntityType[], resource: {
name: string;
}, sortableFields?: Array<{
name: string;
}>): {
}, sortableFields?: string[]): {
fields: (FieldObject | {

@@ -8,0 +6,0 @@ isSortable: boolean;

@@ -11,10 +11,14 @@ import { DocumentNode, GraphQLSchema } from 'graphql';

name: string;
gql: DocumentNode;
gql?: DocumentNode;
queryString?: string;
}>;
path: string;
}, name: string, callback: (params: Params, path: string) => string): Array<{
}, queriesConf: {
callback: (params: Params, path: string) => string;
name: string;
gql: DocumentNode;
}[]): Array<{
name: string;
queryString: string;
}>;
export {};
//# sourceMappingURL=createQueriesAction.d.ts.map

@@ -17,3 +17,3 @@ import { DocumentNode, GraphQLSchema } from 'graphql';

simplifiedEntities: SimplifiedEntityType[];
}, document: DocumentNode): {
}, queryString: string): {
structure: FieldObject;

@@ -28,3 +28,3 @@ variablesStructure: VariableDefinitionObject[];

simplifiedEntities: SimplifiedEntityType[];
}, document: DocumentNode): {
}, queryString: string): {
structure: FieldObject;

@@ -31,0 +31,0 @@ variableDefinitionObjects: VariableDefinitionObject[];

@@ -1,13 +0,9 @@

/// <reference types="react" />
import type { SimplifiedEntityType } from '@theconcurrent/simplified-entity';
import { DocumentNode } from 'graphql';
import type { InitialResource } from '../type';
export default function generateCreate(entities: SimplifiedEntityType[], adminEntity: SimplifiedEntityType | undefined, item: SimplifiedEntityType, adminPath: string, resourceCreate?: InitialResource['create']): {
query: string | undefined;
queries: {
name: string;
gql: DocumentNode;
gql?: import("graphql").DocumentNode | undefined;
queryString?: string | undefined;
}[];
gql?: DocumentNode | undefined;
component?: ((props: any) => JSX.Element) | undefined;
responseDataPath?: {

@@ -17,14 +13,3 @@ data: string;

path: string;
} | {
path: string;
queries: {
name: string;
gql: DocumentNode;
}[];
gql?: DocumentNode | undefined;
component?: ((props: any) => JSX.Element) | undefined;
responseDataPath?: {
data: string;
} | undefined;
} | undefined;
//# sourceMappingURL=generateCreate.d.ts.map
import type { SimplifiedEntityType } from '@theconcurrent/simplified-entity';
import { DocumentNode } from 'graphql';
import type { InitialResource } from '../type';
export default function generateDelete(entities: SimplifiedEntityType[], adminEntity: SimplifiedEntityType | undefined, item: SimplifiedEntityType, adminPath: string, resourceDelete?: InitialResource['delete']): {
query: string | undefined;
queries: {
name: string;
gql: DocumentNode;
gql?: import("graphql").DocumentNode | undefined;
queryString?: string | undefined;
}[];
gql?: DocumentNode | undefined;
responseDataPath?: {

@@ -15,13 +13,3 @@ data: string;

path: string;
} | {
path: string;
queries: {
name: string;
gql: DocumentNode;
}[];
gql?: DocumentNode | undefined;
responseDataPath?: {
data: string;
} | undefined;
} | undefined;
//# sourceMappingURL=generateDelete.d.ts.map

@@ -1,13 +0,9 @@

/// <reference types="react" />
import type { SimplifiedEntityType } from '@theconcurrent/simplified-entity';
import { DocumentNode } from 'graphql';
import type { InitialResource } from '../type';
export default function generateList(entities: SimplifiedEntityType[], adminEntity: SimplifiedEntityType | undefined, item: SimplifiedEntityType, adminPath: string, resourceList?: InitialResource['list']): {
query: string | undefined;
queries: {
name: string;
gql: DocumentNode;
gql?: import("graphql").DocumentNode | undefined;
queryString?: string | undefined;
}[];
gql?: DocumentNode | undefined;
component?: ((props: any) => JSX.Element) | undefined;
responseDataPath?: {

@@ -19,16 +15,3 @@ data: string;

displayColumns?: string[] | undefined;
} | {
path: string;
queries: {
name: string;
gql: DocumentNode;
}[];
gql?: DocumentNode | undefined;
component?: ((props: any) => JSX.Element) | undefined;
responseDataPath?: {
data: string;
total: string;
} | undefined;
displayColumns?: string[] | undefined;
} | undefined;
//# sourceMappingURL=generateList.d.ts.map

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

/// <reference types="react" />
import type { SimplifiedEntityType } from '@theconcurrent/simplified-entity';

@@ -13,9 +12,7 @@ import type { InitialConfig } from '../type';

list: {
query: string | undefined;
queries: {
name: string;
gql: import("graphql").DocumentNode;
gql?: import("graphql").DocumentNode | undefined;
queryString?: string | undefined;
}[];
gql?: import("graphql").DocumentNode | undefined;
component?: ((props: any) => JSX.Element) | undefined;
responseDataPath?: {

@@ -27,24 +24,9 @@ data: string;

displayColumns?: string[] | undefined;
} | {
path: string;
queries: {
name: string;
gql: import("graphql").DocumentNode;
}[];
gql?: import("graphql").DocumentNode | undefined;
component?: ((props: any) => JSX.Element) | undefined;
responseDataPath?: {
data: string;
total: string;
} | undefined;
displayColumns?: string[] | undefined;
} | undefined;
show: {
query: string | undefined;
queries: {
name: string;
gql: import("graphql").DocumentNode;
gql?: import("graphql").DocumentNode | undefined;
queryString?: string | undefined;
}[];
gql?: import("graphql").DocumentNode | undefined;
component?: ((props: any) => JSX.Element) | undefined;
responseDataPath?: {

@@ -54,22 +36,9 @@ data: string;

path: string;
} | {
path: string;
queries: {
name: string;
gql: import("graphql").DocumentNode;
}[];
gql?: import("graphql").DocumentNode | undefined;
component?: ((props: any) => JSX.Element) | undefined;
responseDataPath?: {
data: string;
} | undefined;
} | undefined;
create: {
query: string | undefined;
queries: {
name: string;
gql: import("graphql").DocumentNode;
gql?: import("graphql").DocumentNode | undefined;
queryString?: string | undefined;
}[];
gql?: import("graphql").DocumentNode | undefined;
component?: ((props: any) => JSX.Element) | undefined;
responseDataPath?: {

@@ -79,22 +48,9 @@ data: string;

path: string;
} | {
path: string;
queries: {
name: string;
gql: import("graphql").DocumentNode;
}[];
gql?: import("graphql").DocumentNode | undefined;
component?: ((props: any) => JSX.Element) | undefined;
responseDataPath?: {
data: string;
} | undefined;
} | undefined;
update: {
query: string | undefined;
queries: {
name: string;
gql: import("graphql").DocumentNode;
gql?: import("graphql").DocumentNode | undefined;
queryString?: string | undefined;
}[];
gql?: import("graphql").DocumentNode | undefined;
component?: ((props: any) => JSX.Element) | undefined;
responseDataPath?: {

@@ -104,21 +60,9 @@ data: string;

path: string;
} | {
path: string;
queries: {
name: string;
gql: import("graphql").DocumentNode;
}[];
gql?: import("graphql").DocumentNode | undefined;
component?: ((props: any) => JSX.Element) | undefined;
responseDataPath?: {
data: string;
} | undefined;
} | undefined;
delete: {
query: string | undefined;
queries: {
name: string;
gql: import("graphql").DocumentNode;
gql?: import("graphql").DocumentNode | undefined;
queryString?: string | undefined;
}[];
gql?: import("graphql").DocumentNode | undefined;
responseDataPath?: {

@@ -128,14 +72,4 @@ data: string;

path: string;
} | {
path: string;
queries: {
name: string;
gql: import("graphql").DocumentNode;
}[];
gql?: import("graphql").DocumentNode | undefined;
responseDataPath?: {
data: string;
} | undefined;
} | undefined;
};
//# sourceMappingURL=generateResource.d.ts.map

@@ -1,13 +0,9 @@

/// <reference types="react" />
import type { SimplifiedEntityType } from '@theconcurrent/simplified-entity';
import { DocumentNode } from 'graphql';
import type { InitialResource } from '../type';
export default function generateShow(entities: SimplifiedEntityType[], adminEntity: SimplifiedEntityType | undefined, item: SimplifiedEntityType, adminPath: string, resourceShow?: InitialResource['show']): {
query: string | undefined;
queries: {
name: string;
gql: DocumentNode;
gql?: import("graphql").DocumentNode | undefined;
queryString?: string | undefined;
}[];
gql?: DocumentNode | undefined;
component?: ((props: any) => JSX.Element) | undefined;
responseDataPath?: {

@@ -17,14 +13,3 @@ data: string;

path: string;
} | {
path: string;
queries: {
name: string;
gql: DocumentNode;
}[];
gql?: DocumentNode | undefined;
component?: ((props: any) => JSX.Element) | undefined;
responseDataPath?: {
data: string;
} | undefined;
} | undefined;
//# sourceMappingURL=generateShow.d.ts.map

@@ -1,13 +0,9 @@

/// <reference types="react" />
import type { SimplifiedEntityType } from '@theconcurrent/simplified-entity';
import { DocumentNode } from 'graphql';
import type { InitialResource } from '../type';
export default function generateUpdate(entities: SimplifiedEntityType[], adminEntity: SimplifiedEntityType | undefined, item: SimplifiedEntityType, adminPath: string, resourceUpdate?: InitialResource['update']): {
query: string | undefined;
queries: {
name: string;
gql: DocumentNode;
gql?: import("graphql").DocumentNode | undefined;
queryString?: string | undefined;
}[];
gql?: DocumentNode | undefined;
component?: ((props: any) => JSX.Element) | undefined;
responseDataPath?: {

@@ -17,14 +13,3 @@ data: string;

path: string;
} | {
path: string;
queries: {
name: string;
gql: DocumentNode;
}[];
gql?: DocumentNode | undefined;
component?: ((props: any) => JSX.Element) | undefined;
responseDataPath?: {
data: string;
} | undefined;
} | undefined;
//# sourceMappingURL=generateUpdate.d.ts.map

@@ -1,58 +0,48 @@

import { createQueryForCreate as z, createQueryForUpdate as G, createQueryForDelete as H, createQueryForShow as J, createQueryForList as X, createMinimumQueryForList as Y } from "@theconcurrent/query";
import { getField as Z, getEntityByName as $, lowercaseFirstLetter as L, generatePath as q, findEntityFromPath as M, findEntityByDirectiveName as K, sortDataByOrder as _, filterEntitiesByDirectiveName as C } from "@theconcurrent/utility";
import { parse as U, isEnumType as x, isNonNullType as b, isListType as j, isScalarType as F, TypeInfo as D, visit as tt, visitWithTypeInfo as nt, getNamedType as et, print as E } from "graphql";
function V(t, n, i, a, e) {
var u, f, s;
if (!t)
return;
const o = n ? (u = Z(t, n)) == null ? void 0 : u.fields : t.fields, r = i.find((l) => l.typeName === a.name);
return {
fields: (o || []).map((l) => e ? e.find((p) => p.name === l.name) ? { ...l, isSortable: !0 } : { ...l } : l),
displayColumns: (s = (f = r == null ? void 0 : r.directives) == null ? void 0 : f.find((l) => l.name === "model")) == null ? void 0 : s.args.displayColumns
};
}
import { createQueryForCreate as L, createQueryForUpdate as A, createQueryForDelete as G, createQueryForShow as z, createQueryForList as H, createMinimumQueryForList as J } from "@theconcurrent/query";
import { parse as X, print as Y, isEnumType as O, isNonNullType as b, isListType as S, isScalarType as N, TypeInfo as Z, visit as K, visitWithTypeInfo as _, getNamedType as U } from "graphql";
import { getField as D, getEntityByName as k, lowercaseFirstLetter as tt, generatePath as q, findEntityFromPath as M, findEntityByDirectiveName as nt, sortDataByOrder as et, filterEntitiesByDirectiveName as it } from "@theconcurrent/utility";
var Q = function() {
return Q = Object.assign || function(n) {
return Q = Object.assign || function(t) {
for (var i, a = 1, e = arguments.length; a < e; a++) {
i = arguments[a];
for (var o in i)
Object.prototype.hasOwnProperty.call(i, o) && (n[o] = i[o]);
for (var r in i)
Object.prototype.hasOwnProperty.call(i, r) && (t[r] = i[r]);
}
return n;
return t;
}, Q.apply(this, arguments);
};
var N = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new Map(), I = !0, T = !1;
function W(t) {
return t.replace(/[\s,]+/g, " ").trim();
var F = /* @__PURE__ */ new Map(), $ = /* @__PURE__ */ new Map(), I = !0, T = !1;
function W(n) {
return n.replace(/[\s,]+/g, " ").trim();
}
function it(t) {
return W(t.source.body.substring(t.start, t.end));
function at(n) {
return W(n.source.body.substring(n.start, n.end));
}
function at(t) {
var n = /* @__PURE__ */ new Set(), i = [];
return t.definitions.forEach(function(a) {
function rt(n) {
var t = /* @__PURE__ */ new Set(), i = [];
return n.definitions.forEach(function(a) {
if (a.kind === "FragmentDefinition") {
var e = a.name.value, o = it(a.loc), r = O.get(e);
r && !r.has(o) ? I && console.warn("Warning: fragment with name " + e + ` already exists.
var e = a.name.value, r = at(a.loc), o = $.get(e);
o && !o.has(r) ? I && console.warn("Warning: fragment with name " + e + ` already exists.
graphql-tag enforces all fragment names across your application to be unique; read more about
this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`) : r || O.set(e, r = /* @__PURE__ */ new Set()), r.add(o), n.has(o) || (n.add(o), i.push(a));
this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`) : o || $.set(e, o = /* @__PURE__ */ new Set()), o.add(r), t.has(r) || (t.add(r), i.push(a));
} else
i.push(a);
}), Q(Q({}, t), { definitions: i });
}), Q(Q({}, n), { definitions: i });
}
function rt(t) {
var n = new Set(t.definitions);
n.forEach(function(a) {
function ot(n) {
var t = new Set(n.definitions);
t.forEach(function(a) {
a.loc && delete a.loc, Object.keys(a).forEach(function(e) {
var o = a[e];
o && typeof o == "object" && n.add(o);
var r = a[e];
r && typeof r == "object" && t.add(r);
});
});
var i = t.loc;
return i && (delete i.startToken, delete i.endToken), t;
var i = n.loc;
return i && (delete i.startToken, delete i.endToken), n;
}
function ot(t) {
var n = W(t);
if (!N.has(n)) {
var i = U(t, {
function ut(n) {
var t = W(n);
if (!F.has(t)) {
var i = X(n, {
experimentalFragmentVariables: T,

@@ -63,106 +53,112 @@ allowLegacyFragmentVariables: T

throw new Error("Not a valid GraphQL document.");
N.set(n, rt(at(i)));
F.set(t, ot(rt(i)));
}
return N.get(n);
return F.get(t);
}
function y(t) {
for (var n = [], i = 1; i < arguments.length; i++)
n[i - 1] = arguments[i];
typeof t == "string" && (t = [t]);
var a = t[0];
return n.forEach(function(e, o) {
e && e.kind === "Document" ? a += e.loc.source.body : a += e, a += t[o + 1];
}), ot(a);
function m(n) {
for (var t = [], i = 1; i < arguments.length; i++)
t[i - 1] = arguments[i];
typeof n == "string" && (n = [n]);
var a = n[0];
return t.forEach(function(e, r) {
e && e.kind === "Document" ? a += e.loc.source.body : a += e, a += n[r + 1];
}), ut(a);
}
function ut() {
N.clear(), O.clear();
function st() {
F.clear(), $.clear();
}
function ft() {
function lt() {
I = !1;
}
function st() {
function ft() {
T = !0;
}
function lt() {
function pt() {
T = !1;
}
var g = {
gql: y,
resetCaches: ut,
disableFragmentWarnings: ft,
enableExperimentalFragmentVariables: st,
disableExperimentalFragmentVariables: lt
var y = {
gql: m,
resetCaches: st,
disableFragmentWarnings: lt,
enableExperimentalFragmentVariables: ft,
disableExperimentalFragmentVariables: pt
};
(function(t) {
t.gql = g.gql, t.resetCaches = g.resetCaches, t.disableFragmentWarnings = g.disableFragmentWarnings, t.enableExperimentalFragmentVariables = g.enableExperimentalFragmentVariables, t.disableExperimentalFragmentVariables = g.disableExperimentalFragmentVariables;
})(y || (y = {}));
y.default = y;
function d(t, n, i, a) {
if (n.queries.find((r) => r.name === i))
return n.queries;
const o = `${a(t, n.path)}`;
try {
const r = y`
${o}
`;
return [
...n.queries,
{
name: i,
gql: r
}
];
} catch (r) {
throw console.error(r, n, i), console.error(o.replace(/\\n/g, `
`)), new Error(`Failed to create query for ${i}`);
}
(function(n) {
n.gql = y.gql, n.resetCaches = y.resetCaches, n.disableFragmentWarnings = y.disableFragmentWarnings, n.enableExperimentalFragmentVariables = y.enableExperimentalFragmentVariables, n.disableExperimentalFragmentVariables = y.disableExperimentalFragmentVariables;
})(m || (m = {}));
m.default = m;
function x(n, t, i, a, e) {
var u, s, l;
if (!n)
return;
const r = t ? (u = D(n, t)) == null ? void 0 : u.fields : n.fields, o = i.find((f) => f.typeName === a.name);
return {
fields: (r || []).map((f) => e ? e.find((p) => p === f.name) ? { ...f, isSortable: !0 } : { ...f } : f),
displayColumns: (l = (s = o == null ? void 0 : o.directives) == null ? void 0 : s.find((f) => f.name === "model")) == null ? void 0 : l.args.displayColumns
};
}
function v(t, n) {
if (t)
return t.queries.find((i) => i.name === n);
function h(n, t, i) {
const { queries: a } = t;
return i.map((e) => {
const r = a.find((o) => o.name === e.name);
return r && r.gql ? {
name: r.name,
queryString: Y(r.gql)
} : r && r.queryString ? {
name: r.name,
queryString: r.queryString
} : {
name: e.name,
queryString: e.callback(n, t.path)
};
});
}
function pt(t) {
return x(t.type) || b(t.type) && x(t.type.ofType);
function E(n, t) {
if (n)
return n.queries.find((i) => i.name === t);
}
function mt(t) {
return j(t.type) || b(t.type) && j(t.type.ofType);
function ct(n) {
return O(n.type) || b(n.type) && O(n.type.ofType);
}
function ct(t) {
return !!(F(t.type) || b(t.type) && (F(t.type.ofType) || j(t.type.ofType) && (F(t.type.ofType.ofType) || b(t.type.ofType.ofType) && F(t.type.ofType.ofType.ofType))));
function mt(n) {
return S(n.type) || b(n.type) && S(n.type.ofType);
}
function dt(t, n) {
return t ? "Scalar" : n ? "Enum" : "Object";
function dt(n) {
return !!(N(n.type) || b(n.type) && (N(n.type.ofType) || S(n.type.ofType) && (N(n.type.ofType.ofType) || b(n.type.ofType.ofType) && N(n.type.ofType.ofType.ofType))));
}
function yt(t, n) {
var a, e, o;
if (!n || !n.fields)
throw new Error(`Parent entity not found: ${t}`);
const i = n.fields.find((r) => r.name === t);
return (o = (e = (a = i == null ? void 0 : i.directives) == null ? void 0 : a.find((r) => r.name === "label")) == null ? void 0 : e.args) == null ? void 0 : o.name;
function yt(n, t) {
return n ? "Scalar" : t ? "Enum" : "Object";
}
function gt(t) {
if (t && t.kind === "Enum")
return t.enumValues;
function ht(n, t) {
var a, e, r;
if (!t || !t.fields)
throw new Error(`Parent entity not found: ${n}`);
const i = t.fields.find((o) => o.name === n);
return (r = (e = (a = i == null ? void 0 : i.directives) == null ? void 0 : a.find((o) => o.name === "label")) == null ? void 0 : e.args) == null ? void 0 : r.name;
}
function ht(t, n, i) {
var m, c;
const a = mt(t), e = b(t.type), o = et(t.type).toString(), r = pt(t), u = ct(t), f = $(n, o), s = $(n, i), l = yt(t.name, s), p = gt(f);
function gt(n) {
if (n && n.kind === "Enum")
return n.enumValues;
}
function vt(n, t, i) {
var c, d;
const a = mt(n), e = b(n.type), r = U(n.type).toString(), o = ct(n), u = dt(n), s = k(t, r), l = k(t, i), f = ht(n.name, l), p = gt(s);
return {
name: t.name,
name: n.name,
isList: a,
isNonNull: e,
typeName: o,
typeName: r,
isScalar: u,
isEnum: r,
kind: dt(u, r),
description: t.description,
schemaDirectives: f == null ? void 0 : f.directives,
label: l,
isEnum: o,
kind: yt(u, o),
description: n.description,
schemaDirectives: s == null ? void 0 : s.directives,
label: f,
enumValues: p,
collection: (c = (m = f == null ? void 0 : f.directives) == null ? void 0 : m.find((w) => w.name === "collection")) == null ? void 0 : c.args,
isUnion: (f == null ? void 0 : f.kind) === "Union"
collection: (d = (c = s == null ? void 0 : s.directives) == null ? void 0 : c.find((w) => w.name === "collection")) == null ? void 0 : d.args,
isUnion: (s == null ? void 0 : s.kind) === "Union"
};
}
function vt(t, n, i, a) {
const e = ht(t, i, a);
function bt(n, t, i, a) {
const e = vt(n, i, a);
return e.isScalar || e.isEnum ? e : {

@@ -173,4 +169,4 @@ ...e,

}
function bt(t, n) {
const i = $(n, t.name.value);
function qt(n, t) {
const i = k(t, n.name.value);
if (!i)

@@ -180,10 +176,10 @@ throw new Error("entity type not found");

}
function R(t, n) {
switch (t.kind) {
function j(n, t) {
switch (n.kind) {
case "NamedType":
return { variable: bt(t, n), isNonNull: !1, isList: !1 };
return { variable: qt(n, t), isNonNull: !1, isList: !1 };
case "NonNullType":
return { ...R(t.type, n), isNonNull: !0 };
return { ...j(n.type, t), isNonNull: !0 };
case "ListType":
return { ...R(t.type, n), isList: !0 };
return { ...j(n.type, t), isList: !0 };
default:

@@ -193,39 +189,39 @@ throw new Error("extractType error");

}
function qt(t, n) {
function wt(n, t) {
return {
...R(t.type, n),
name: t.variable.name.value
...j(n.type, t),
name: n.variable.name.value
};
}
function B(t, n, i = 0) {
function B(n, t, i = 0) {
var e;
if (i >= n.length)
return t;
const a = { ...t };
return a.fields = (e = t.fields) == null ? void 0 : e.map((o) => o.fields ? {
...o,
representativeField: o.fields.find(
(r) => r.name === n.find((u) => {
var f;
return (f = o.fields) == null ? void 0 : f.find((s) => s.name === u);
if (i >= t.length)
return n;
const a = { ...n };
return a.fields = (e = n.fields) == null ? void 0 : e.map((r) => r.fields ? {
...r,
representativeField: r.fields.find(
(o) => o.name === t.find((u) => {
var s;
return (s = r.fields) == null ? void 0 : s.find((l) => l.name === u);
})
),
fields: B(o, n, i + 1).fields
} : o), a;
fields: B(r, t, i + 1).fields
} : r), a;
}
function A(t, n, i, a) {
const e = new D(t);
let o = null;
const r = [], u = [];
if (tt(n, nt(e, {
function C(n, t, i, a) {
const e = new Z(n);
let r = null;
const o = [], u = [];
if (K(t, _(e, {
VariableDefinition: {
enter(s) {
u.push(qt(s, i));
enter(l) {
u.push(wt(l, i));
}
},
Field: {
enter(s) {
var c, w, k;
const l = e.getParentType();
if (!l)
enter(l) {
var d, w, R;
const f = e.getParentType();
if (!f)
throw new Error("Parent type not found");

@@ -235,29 +231,29 @@ const p = e.getFieldDef();

throw new Error("Field definition not found");
const m = vt(
const c = bt(
p,
s,
l,
i,
l.name
f.name
);
if (l.toString() === ((c = t.getQueryType()) == null ? void 0 : c.name) || l.toString() === ((w = t.getMutationType()) == null ? void 0 : w.name)) {
o = m, r.push(m);
if (f.toString() === ((d = n.getQueryType()) == null ? void 0 : d.name) || f.toString() === ((w = n.getMutationType()) == null ? void 0 : w.name)) {
r = c, o.push(c);
return;
}
o && ((k = r[r.length - 1].fields) == null || k.push(m), !m.isScalar && !m.isEnum && r.push(m));
r && ((R = o[o.length - 1].fields) == null || R.push(c), !c.isScalar && !c.isEnum && o.push(c));
},
leave(s) {
r.length > 1 && s.selectionSet && r.pop();
leave(l) {
o.length > 1 && l.selectionSet && o.pop();
}
}
})), !o)
})), !r)
throw new Error("Couldn't find query object");
return {
queryObject: B(o, a),
queryObject: B(r, a),
variableDefinitionObjects: u
};
}
function Et(t, n, i, a) {
const { queryObject: e, variableDefinitionObjects: o } = A(
function Nt(n, t, i, a) {
const { queryObject: e, variableDefinitionObjects: r } = C(
n,
t,
n,
i,

@@ -268,8 +264,8 @@ a

throw new Error("Query object not generated");
return { structure: e, variableDefinitionObjects: o };
return { structure: e, variableDefinitionObjects: r };
}
function wt(t, n, i, a) {
const { queryObject: e, variableDefinitionObjects: o } = A(
function Et(n, t, i, a) {
const { queryObject: e, variableDefinitionObjects: r } = C(
n,
t,
n,
i,

@@ -280,27 +276,31 @@ a

throw new Error("Query object not generated");
return { structure: e, variablesStructure: o };
return { structure: e, variablesStructure: r };
}
function P(t, n) {
return wt(
t.graphqlSchema,
n,
t.simplifiedEntities,
t.config.nodeRepresentatives
function V(n, t) {
return Et(
n.graphqlSchema,
m`
${t}
`,
n.simplifiedEntities,
n.config.nodeRepresentatives
);
}
function S(t, n) {
return Et(
t.graphqlSchema,
n,
t.simplifiedEntities,
t.config.nodeRepresentatives
function P(n, t) {
return Nt(
n.graphqlSchema,
m`
${t}
`,
n.simplifiedEntities,
n.config.nodeRepresentatives
);
}
function h(t, n, i, a) {
var o, r;
if (!n)
function g(n, t, i, a) {
var o, u;
if (!t)
return;
if (a && i)
return {
...n,
...t,
responseDataPath: { data: `${i}.nodes`, total: `${i}.totalCount` }

@@ -310,143 +310,126 @@ };

return {
...n,
...t,
responseDataPath: { data: `${i}` }
};
const e = (r = (o = n.queries) == null ? void 0 : o.find((u) => u.name === "main")) == null ? void 0 : r.gql;
const e = (u = (o = t.queries) == null ? void 0 : o.find((s) => s.name === "main")) == null ? void 0 : u.queryString;
if (!e)
throw new Error("Can't find gql");
const r = m`
${e}
`;
return {
...n,
...t,
responseDataPath: {
// @ts-ignore
// eslint-disable-next-line
data: `${e.definitions[0].name.value}.${L(t)}`
data: `${r.definitions[0].name.value}.${tt(n)}`
}
};
}
function Ft(t) {
var n, i;
return ((i = (n = t == null ? void 0 : t.find((a) => a.name === "label")) == null ? void 0 : n.args) == null ? void 0 : i.name) || void 0;
function Ft(n) {
var t, i;
return ((i = (t = n == null ? void 0 : n.find((a) => a.name === "label")) == null ? void 0 : t.args) == null ? void 0 : i.name) || void 0;
}
function Nt(t) {
if (t)
return E(t);
}
function Qt() {
return [];
}
function Tt(t, n, i, a, e) {
if (!n)
function Tt(n, t, i, a, e) {
if (!t)
return;
const o = Nt(e == null ? void 0 : e.gql), u = t.filter((l) => l.kind === "Object").find((l) => {
var m;
const p = (m = l.directives) == null ? void 0 : m.find((c) => c.name === "collection");
return p ? p.args.typeName === i.typeName : !1;
const o = n.filter((l) => l.kind === "Object").find((l) => {
var p;
const f = (p = l.directives) == null ? void 0 : p.find((c) => c.name === "collection");
return f ? f.args.typeName === i.typeName : !1;
});
if (!u)
if (!o)
return;
const f = q(t, n.typeName, u.typeName, a), s = (e == null ? void 0 : e.queries) || Qt();
if (f)
return { path: f, ...e || {}, query: o, queries: s };
const u = q(n, t.typeName, o.typeName, a), s = (e == null ? void 0 : e.queries) || Qt();
if (u)
return { path: u, ...e || {}, queries: s };
if (e != null && e.path)
return { ...e, path: e.path, queries: s };
}
function $t(t) {
if (t)
return E(t);
}
function jt() {
function St() {
return [];
}
function Ot(t, n, i, a, e) {
if (!n)
function kt(n, t, i, a, e) {
if (!t)
return;
const o = $t(e == null ? void 0 : e.gql), r = q(t, n.typeName, i.typeName, a), u = (e == null ? void 0 : e.queries) || jt();
const r = q(n, t.typeName, i.typeName, a), o = (e == null ? void 0 : e.queries) || St();
if (r)
return { path: r, ...e || {}, query: o, queries: u };
return { path: r, ...e || {}, queries: o };
if (e != null && e.path)
return { ...e, path: e.path, queries: u };
return { ...e, path: e.path, queries: o };
}
function Rt(t) {
if (t)
return E(t);
}
function kt() {
function $t() {
return [];
}
function xt(t, n, i, a, e) {
if (!e || !n)
function jt(n, t, i, a, e) {
if (!e || !t)
return;
const o = Rt(e == null ? void 0 : e.gql), r = q(t, n.typeName, i.typeName, a), u = r == null ? void 0 : r.split(".").pop(), f = `${u}Create.${u}`, s = (e == null ? void 0 : e.queries) || kt();
if (f)
return { path: f, ...e || {}, query: o, queries: s };
const r = q(n, t.typeName, i.typeName, a), o = r == null ? void 0 : r.split(".").pop(), u = `${o}Create.${o}`, s = (e == null ? void 0 : e.queries) || $t();
if (u)
return { path: u, ...e || {}, queries: s };
if (e != null && e.path)
return { ...e, path: e.path, queries: s };
}
function Vt(t) {
if (t)
return E(t);
}
function Pt() {
function Rt() {
return [];
}
function St(t, n, i, a, e) {
if (!e || !n)
function Ot(n, t, i, a, e) {
if (!e || !t)
return;
const o = Vt(e == null ? void 0 : e.gql), r = q(t, n.typeName, i.typeName, a), u = r == null ? void 0 : r.split(".").pop(), f = `${u}Update.${u}`, s = (e == null ? void 0 : e.queries) || Pt();
if (f)
return { path: f, ...e || {}, query: o, queries: s };
const r = q(n, t.typeName, i.typeName, a), o = r == null ? void 0 : r.split(".").pop(), u = `${o}Update.${o}`, s = (e == null ? void 0 : e.queries) || Rt();
if (u)
return { path: u, ...e || {}, queries: s };
if (e != null && e.path)
return { ...e, path: e.path, queries: s };
}
function Mt(t) {
if (t)
return E(t);
}
function It() {
function xt() {
return [];
}
function Wt(t, n, i, a, e) {
if (!e || !n)
function Vt(n, t, i, a, e) {
if (!e || !t)
return;
const o = Mt(e == null ? void 0 : e.gql), r = q(t, n.typeName, i.typeName, a), u = r == null ? void 0 : r.split(".").pop(), f = `${u}Delete.${u}`, s = (e == null ? void 0 : e.queries) || It();
if (f)
return { path: f, ...e || {}, query: o, queries: s };
const r = q(n, t.typeName, i.typeName, a), o = r == null ? void 0 : r.split(".").pop(), u = `${o}Delete.${o}`, s = (e == null ? void 0 : e.queries) || xt();
if (u)
return { path: u, ...e || {}, queries: s };
if (e != null && e.path)
return { ...e, path: e.path, queries: s };
}
function Bt(t, n) {
var f, s;
const { simplifiedEntities: i, config: a } = n, e = a.adminPath ? `${a.adminPath}.` : "", o = i.find(
(l) => {
function Pt(n, t) {
var s, l;
const { simplifiedEntities: i, config: a } = t, e = a.adminPath ? `${a.adminPath}.` : "", r = i.find(
(f) => {
var p;
return (p = l.directives) == null ? void 0 : p.find((m) => m.name === "queryRoot");
return (p = f.directives) == null ? void 0 : p.find((c) => c.name === "queryRoot");
}
), r = M(
), o = M(
i,
o.typeName,
((f = a.adminPath) == null ? void 0 : f.split(".")) || []
), u = (s = a.resources) == null ? void 0 : s.find((l) => l.name === t.typeName);
r.typeName,
((s = a.adminPath) == null ? void 0 : s.split(".")) || []
), u = (l = a.resources) == null ? void 0 : l.find((f) => f.name === n.typeName);
return {
label: Ft(t.directives),
name: t.typeName,
typeName: t.typeName,
label: Ft(n.directives),
name: n.typeName,
typeName: n.typeName,
skipMenu: u == null ? void 0 : u.skipMenu,
list: Tt(i, r, t, e, u == null ? void 0 : u.list),
show: Ot(i, r, t, e, u == null ? void 0 : u.show),
create: xt(i, r, t, e, u == null ? void 0 : u.create),
update: St(i, r, t, e, u == null ? void 0 : u.update),
delete: Wt(i, r, t, e, u == null ? void 0 : u.delete)
list: Tt(i, o, n, e, u == null ? void 0 : u.list),
show: kt(i, o, n, e, u == null ? void 0 : u.show),
create: jt(i, o, n, e, u == null ? void 0 : u.create),
update: Ot(i, o, n, e, u == null ? void 0 : u.update),
delete: Vt(i, o, n, e, u == null ? void 0 : u.delete)
};
}
function At(t, n, i, a) {
const e = t === "" ? i : M(n, "Query", t.split("."));
function Mt(n, t, i, a) {
const e = n === "" ? i : M(t, "Query", n.split("."));
if (!e)
throw new Error("adminEntity not found");
const o = e.fields.map((r) => r.typeName);
return C(n, "model").filter((r) => o.includes(r.typeName)).map((r) => Bt(r, a));
const r = e.fields.map((o) => o.typeName);
return it(t, "model").filter((o) => r.includes(o.typeName)).map((o) => Pt(o, a));
}
function zt(t) {
var u, f, s, l;
const { simplifiedEntities: n, config: i } = t, a = K(
n,
function It(n) {
var u, s, l, f;
const { simplifiedEntities: t, config: i } = n, a = nt(
t,
"queryRoot"

@@ -456,81 +439,72 @@ );

throw new Error("queryRoot not found");
const e = (s = (f = (u = a.directives) == null ? void 0 : u.find((p) => p.name === "queryRoot")) == null ? void 0 : f.args) == null ? void 0 : s.adminPaths;
const e = (l = (s = (u = a.directives) == null ? void 0 : u.find((p) => p.name === "queryRoot")) == null ? void 0 : s.args) == null ? void 0 : l.adminPaths;
if (!e)
throw new Error("adminPaths not found");
const o = e.map((p) => At(p, n, a, t)).flat(), r = ((l = i.resources) == null ? void 0 : l.map((p) => p.name)) || o.map((p) => p.name);
return _(o, r, "name");
const r = e.map((p) => Mt(p, t, a, n)).flat(), o = ((f = i.resources) == null ? void 0 : f.map((p) => p.name)) || r.map((p) => p.name);
return et(r, o, "name");
}
function Gt(t, n) {
var a, e, o, r, u;
const i = "main";
function Wt(n, t) {
var l, f, p, c, d;
const i = "main", a = "minimum", e = [{ name: i, callback: L }], r = [{ name: i, callback: A }], o = [{ name: i, callback: G }], u = [{ name: i, callback: z }], s = [
{ name: i, callback: H },
{ name: a, callback: J }
];
return {
...n,
create: (a = n.create) != null && a.path ? {
...n.create,
queries: d(t, n.create, i, z)
} : n.create,
update: (e = n.update) != null && e.path ? {
...n.update,
queries: d(t, n.update, i, G)
} : n.update,
delete: (o = n.delete) != null && o.path ? {
...n.delete,
queries: d(t, n.delete, i, H)
} : n.delete,
show: (r = n.show) != null && r.path ? {
...n.show,
queries: d(t, n.show, i, J)
} : n.show,
list: (u = n.list) != null && u.path ? {
...n.list,
queries: d(t, n.list, i, X)
} : n.list
...t,
create: (l = t.create) != null && l.path ? {
...t.create,
queries: h(n, t.create, e)
} : void 0,
update: (f = t.update) != null && f.path ? {
...t.update,
queries: h(n, t.update, r)
} : void 0,
delete: (p = t.delete) != null && p.path ? {
...t.delete,
queries: h(n, t.delete, o)
} : void 0,
show: (c = t.show) != null && c.path ? {
...t.show,
queries: h(n, t.show, u)
} : void 0,
list: (d = t.list) != null && d.path ? {
...t.list,
queries: h(n, t.list, s)
} : void 0
};
}
function Ht(t, n) {
var a;
const i = v(n.list, "minimum");
function Bt(n, t) {
const i = "main", a = E(t.create, i), e = E(t.update, i), r = E(t.show, i), o = E(t.list, i);
return {
...n,
list: (a = n.list) != null && a.path && !i ? {
...n.list,
queries: d(
t,
n.list,
"minimum",
Y
)
} : n.list
};
}
function Jt(t, n) {
const i = "main", a = v(n.create, i), e = v(n.update, i), o = v(n.show, i), r = v(n.list, i);
return {
...n,
...t,
create: a ? {
...n.create,
...S(t, a.gql)
} : n.create,
...t.create,
...P(n, a.queryString)
} : t.create,
update: e ? {
...n.update,
...S(t, e.gql)
} : n.update,
show: o ? {
...n.show,
...P(t, o.gql)
} : n.show,
list: r ? {
...n.list,
...P(t, r.gql)
} : n.list
...t.update,
...P(n, e.queryString)
} : t.update,
show: r ? {
...t.show,
...V(n, r.queryString)
} : t.show,
list: o ? {
...t.list,
...V(n, o.queryString)
} : t.list
};
}
function Xt(t, n) {
var o, r, u, f;
const { simplifiedEntities: i } = t, { show: a, list: e } = n;
function Ct(n, t) {
var e, r, o, u, s;
const i = (s = (u = (o = (r = (e = n.variablesStructure) == null ? void 0 : e.find((l) => l.name === "sort")) == null ? void 0 : r.variable) == null ? void 0 : o.inputFields) == null ? void 0 : u.find((l) => l.name === "field")) == null ? void 0 : s.typeName, a = t.find((l) => l.typeName === i);
return a == null ? void 0 : a.enumValues.map((l) => l.name);
}
function Lt(n, t) {
const { simplifiedEntities: i } = n, { show: a, list: e } = t;
return {
...n,
...t,
show: a && {
...a,
...V(
...x(
// @ts-ignore

@@ -541,3 +515,3 @@ // eslint-disable-next-line

i,
n
t
)

@@ -547,3 +521,3 @@ },

...e,
...V(
...x(
// @ts-ignore

@@ -555,10 +529,5 @@ // eslint-disable-next-line

i,
n,
// @ts-ignore
// eslint-disable-next-line
(f = (u = (r = (o = e == null ? void 0 : e.variablesStructure.find((s) => s.name === "sort")) == null ? void 0 : o.inputFields) == null ? void 0 : r.find((s) => s.typeName !== "BaseSortOrder")) == null ? void 0 : u.enumValues) == null ? void 0 : f.map((s) => ({
// @ts-ignore
// eslint-disable-next-line
name: s.name
}))
t,
Ct(e, i)
// eslint-disable-line
)

@@ -568,14 +537,14 @@ }

}
function Yt(t, n) {
function At(n, t) {
var i, a;
return {
...n,
create: h(n.name, n.create),
update: h(n.name, n.update),
delete: h(n.name, n.delete),
show: h(n.name, n.show, (i = n.show) == null ? void 0 : i.path),
list: h(
n.name,
n.list,
(a = n.list) == null ? void 0 : a.path,
...t,
create: g(t.name, t.create),
update: g(t.name, t.update),
delete: g(t.name, t.delete),
show: g(t.name, t.show, (i = t.show) == null ? void 0 : i.path),
list: g(
t.name,
t.list,
(a = t.list) == null ? void 0 : a.path,
!0

@@ -585,8 +554,38 @@ )

}
function _t(t) {
return zt(t).map((n) => Gt(t, n)).map((n) => Ht(t, n)).map((n) => Jt(t, n)).map((n) => Xt(t, n)).map((n) => Yt(t, n));
function v(n) {
return n.map((t) => ({
name: t.name,
gql: m`
${t.queryString}
`
}));
}
function Jt(n) {
return It(n).map((t) => Wt(n, t)).map((t) => Bt(n, t)).map((t) => Lt(n, t)).map((t) => At(n, t)).map((t) => ({
...t,
create: t.create ? (
// @ts-ignore
{ ...t.create, queries: v(t.create.queries) }
) : void 0,
delete: t.delete ? (
// @ts-ignore
{ ...t.delete, queries: v(t.delete.queries) }
) : void 0,
update: t.update ? (
// @ts-ignore
{ ...t.update, queries: v(t.update.queries) }
) : void 0,
show: t.show ? (
// @ts-ignore
{ ...t.show, queries: v(t.show.queries) }
) : void 0,
list: t.list ? (
// @ts-ignore
{ ...t.list, queries: v(t.list.queries) }
) : void 0
}));
}
export {
_t as convert
Jt as convert
};
//# sourceMappingURL=index.es.js.map

@@ -1,7 +0,12 @@

(function(h,y){typeof exports=="object"&&typeof module!="undefined"?y(exports,require("@theconcurrent/query"),require("@theconcurrent/utility"),require("graphql")):typeof define=="function"&&define.amd?define(["exports","@theconcurrent/query","@theconcurrent/utility","graphql"],y):(h=typeof globalThis!="undefined"?globalThis:h||self,y(h["@theconcurrent/resource"]={},h.query,h.utility,h.graphql))})(this,function(h,y,m,c){"use strict";function O(n,t,i,a,e){var u,f,s;if(!n)return;const o=t?(u=m.getField(n,t))==null?void 0:u.fields:n.fields,r=i.find(p=>p.typeName===a.name);return{fields:(o||[]).map(p=>e?e.find(l=>l.name===p.name)?{...p,isSortable:!0}:{...p}:p),displayColumns:(s=(f=r==null?void 0:r.directives)==null?void 0:f.find(p=>p.name==="model"))==null?void 0:s.args.displayColumns}}var T=function(){return T=Object.assign||function(t){for(var i,a=1,e=arguments.length;a<e;a++){i=arguments[a];for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(t[o]=i[o])}return t},T.apply(this,arguments)};typeof SuppressedError=="function"&&SuppressedError;var w=new Map,$=new Map,P=!0,q=!1;function R(n){return n.replace(/[\s,]+/g," ").trim()}function B(n){return R(n.source.body.substring(n.start,n.end))}function I(n){var t=new Set,i=[];return n.definitions.forEach(function(a){if(a.kind==="FragmentDefinition"){var e=a.name.value,o=B(a.loc),r=$.get(e);r&&!r.has(o)?P&&console.warn("Warning: fragment with name "+e+` already exists.
(function(h,y){typeof exports=="object"&&typeof module!="undefined"?y(exports,require("@theconcurrent/query"),require("graphql"),require("@theconcurrent/utility")):typeof define=="function"&&define.amd?define(["exports","@theconcurrent/query","graphql","@theconcurrent/utility"],y):(h=typeof globalThis!="undefined"?globalThis:h||self,y(h["@theconcurrent/resource"]={},h.query,h.graphql,h.utility))})(this,function(h,y,p,d){"use strict";var E=function(){return E=Object.assign||function(t){for(var i,a=1,n=arguments.length;a<n;a++){i=arguments[a];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t},E.apply(this,arguments)};typeof SuppressedError=="function"&&SuppressedError;var T=new Map,k=new Map,$=!0,F=!1;function R(e){return e.replace(/[\s,]+/g," ").trim()}function I(e){return R(e.source.body.substring(e.start,e.end))}function W(e){var t=new Set,i=[];return e.definitions.forEach(function(a){if(a.kind==="FragmentDefinition"){var n=a.name.value,r=I(a.loc),o=k.get(n);o&&!o.has(r)?$&&console.warn("Warning: fragment with name "+n+` already exists.
graphql-tag enforces all fragment names across your application to be unique; read more about
this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):r||$.set(e,r=new Set),r.add(o),t.has(o)||(t.add(o),i.push(a))}else i.push(a)}),T(T({},n),{definitions:i})}function W(n){var t=new Set(n.definitions);t.forEach(function(a){a.loc&&delete a.loc,Object.keys(a).forEach(function(e){var o=a[e];o&&typeof o=="object"&&t.add(o)})});var i=n.loc;return i&&(delete i.startToken,delete i.endToken),n}function A(n){var t=R(n);if(!w.has(t)){var i=c.parse(n,{experimentalFragmentVariables:q,allowLegacyFragmentVariables:q});if(!i||i.kind!=="Document")throw new Error("Not a valid GraphQL document.");w.set(t,W(I(i)))}return w.get(t)}function g(n){for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];typeof n=="string"&&(n=[n]);var a=n[0];return t.forEach(function(e,o){e&&e.kind==="Document"?a+=e.loc.source.body:a+=e,a+=n[o+1]}),A(a)}function z(){w.clear(),$.clear()}function G(){P=!1}function L(){q=!0}function H(){q=!1}var N={gql:g,resetCaches:z,disableFragmentWarnings:G,enableExperimentalFragmentVariables:L,disableExperimentalFragmentVariables:H};(function(n){n.gql=N.gql,n.resetCaches=N.resetCaches,n.disableFragmentWarnings=N.disableFragmentWarnings,n.enableExperimentalFragmentVariables=N.enableExperimentalFragmentVariables,n.disableExperimentalFragmentVariables=N.disableExperimentalFragmentVariables})(g||(g={})),g.default=g;function b(n,t,i,a){if(t.queries.find(r=>r.name===i))return t.queries;const o=`${a(n,t.path)}`;try{const r=g`
${o}
`;return[...t.queries,{name:i,gql:r}]}catch(r){throw console.error(r,t,i),console.error(o.replace(/\\n/g,`
`)),new Error(`Failed to create query for ${i}`)}}function E(n,t){if(n)return n.queries.find(i=>i.name===t)}function J(n){return c.isEnumType(n.type)||c.isNonNullType(n.type)&&c.isEnumType(n.type.ofType)}function X(n){return c.isListType(n.type)||c.isNonNullType(n.type)&&c.isListType(n.type.ofType)}function Y(n){return!!(c.isScalarType(n.type)||c.isNonNullType(n.type)&&(c.isScalarType(n.type.ofType)||c.isListType(n.type.ofType)&&(c.isScalarType(n.type.ofType.ofType)||c.isNonNullType(n.type.ofType.ofType)&&c.isScalarType(n.type.ofType.ofType.ofType))))}function Z(n,t){return n?"Scalar":t?"Enum":"Object"}function K(n,t){var a,e,o;if(!t||!t.fields)throw new Error(`Parent entity not found: ${n}`);const i=t.fields.find(r=>r.name===n);return(o=(e=(a=i==null?void 0:i.directives)==null?void 0:a.find(r=>r.name==="label"))==null?void 0:e.args)==null?void 0:o.name}function _(n){if(n&&n.kind==="Enum")return n.enumValues}function C(n,t,i){var d,v;const a=X(n),e=c.isNonNullType(n.type),o=c.getNamedType(n.type).toString(),r=J(n),u=Y(n),f=m.getEntityByName(t,o),s=m.getEntityByName(t,i),p=K(n.name,s),l=_(f);return{name:n.name,isList:a,isNonNull:e,typeName:o,isScalar:u,isEnum:r,kind:Z(u,r),description:n.description,schemaDirectives:f==null?void 0:f.directives,label:p,enumValues:l,collection:(v=(d=f==null?void 0:f.directives)==null?void 0:d.find(Q=>Q.name==="collection"))==null?void 0:v.args,isUnion:(f==null?void 0:f.kind)==="Union"}}function U(n,t,i,a){const e=C(n,i,a);return e.isScalar||e.isEnum?e:{...e,fields:[]}}function D(n,t){const i=m.getEntityByName(t,n.name.value);if(!i)throw new Error("entity type not found");return i}function j(n,t){switch(n.kind){case"NamedType":return{variable:D(n,t),isNonNull:!1,isList:!1};case"NonNullType":return{...j(n.type,t),isNonNull:!0};case"ListType":return{...j(n.type,t),isList:!0};default:throw new Error("extractType error")}}function nn(n,t){return{...j(n.type,t),name:n.variable.name.value}}function k(n,t,i=0){var e;if(i>=t.length)return n;const a={...n};return a.fields=(e=n.fields)==null?void 0:e.map(o=>o.fields?{...o,representativeField:o.fields.find(r=>r.name===t.find(u=>{var f;return(f=o.fields)==null?void 0:f.find(s=>s.name===u)})),fields:k(o,t,i+1).fields}:o),a}function x(n,t,i,a){const e=new c.TypeInfo(n);let o=null;const r=[],u=[],f={VariableDefinition:{enter(s){u.push(nn(s,i))}},Field:{enter(s){var v,Q,M;const p=e.getParentType();if(!p)throw new Error("Parent type not found");const l=e.getFieldDef();if(!l)throw new Error("Field definition not found");const d=U(l,s,i,p.name);if(p.toString()===((v=n.getQueryType())==null?void 0:v.name)||p.toString()===((Q=n.getMutationType())==null?void 0:Q.name)){o=d,r.push(d);return}o&&((M=r[r.length-1].fields)==null||M.push(d),!d.isScalar&&!d.isEnum&&r.push(d))},leave(s){r.length>1&&s.selectionSet&&r.pop()}}};if(c.visit(t,c.visitWithTypeInfo(e,f)),!o)throw new Error("Couldn't find query object");return{queryObject:k(o,a),variableDefinitionObjects:u}}function tn(n,t,i,a){const{queryObject:e,variableDefinitionObjects:o}=x(n,t,i,a);if(!e)throw new Error("Query object not generated");return{structure:e,variableDefinitionObjects:o}}function en(n,t,i,a){const{queryObject:e,variableDefinitionObjects:o}=x(n,t,i,a);if(!e)throw new Error("Query object not generated");return{structure:e,variablesStructure:o}}function S(n,t){return en(n.graphqlSchema,t,n.simplifiedEntities,n.config.nodeRepresentatives)}function V(n,t){return tn(n.graphqlSchema,t,n.simplifiedEntities,n.config.nodeRepresentatives)}function F(n,t,i,a){var o,r;if(!t)return;if(a&&i)return{...t,responseDataPath:{data:`${i}.nodes`,total:`${i}.totalCount`}};if(i)return{...t,responseDataPath:{data:`${i}`}};const e=(r=(o=t.queries)==null?void 0:o.find(u=>u.name==="main"))==null?void 0:r.gql;if(!e)throw new Error("Can't find gql");return{...t,responseDataPath:{data:`${e.definitions[0].name.value}.${m.lowercaseFirstLetter(n)}`}}}function an(n){var t,i;return((i=(t=n==null?void 0:n.find(a=>a.name==="label"))==null?void 0:t.args)==null?void 0:i.name)||void 0}function rn(n){if(n)return c.print(n)}function on(){return[]}function un(n,t,i,a,e){if(!t)return;const o=rn(e==null?void 0:e.gql),u=n.filter(p=>p.kind==="Object").find(p=>{var d;const l=(d=p.directives)==null?void 0:d.find(v=>v.name==="collection");return l?l.args.typeName===i.typeName:!1});if(!u)return;const f=m.generatePath(n,t.typeName,u.typeName,a),s=(e==null?void 0:e.queries)||on();if(f)return{path:f,...e||{},query:o,queries:s};if(e!=null&&e.path)return{...e,path:e.path,queries:s}}function fn(n){if(n)return c.print(n)}function sn(){return[]}function pn(n,t,i,a,e){if(!t)return;const o=fn(e==null?void 0:e.gql),r=m.generatePath(n,t.typeName,i.typeName,a),u=(e==null?void 0:e.queries)||sn();if(r)return{path:r,...e||{},query:o,queries:u};if(e!=null&&e.path)return{...e,path:e.path,queries:u}}function cn(n){if(n)return c.print(n)}function ln(){return[]}function mn(n,t,i,a,e){if(!e||!t)return;const o=cn(e==null?void 0:e.gql),r=m.generatePath(n,t.typeName,i.typeName,a),u=r==null?void 0:r.split(".").pop(),f=`${u}Create.${u}`,s=(e==null?void 0:e.queries)||ln();if(f)return{path:f,...e||{},query:o,queries:s};if(e!=null&&e.path)return{...e,path:e.path,queries:s}}function dn(n){if(n)return c.print(n)}function yn(){return[]}function hn(n,t,i,a,e){if(!e||!t)return;const o=dn(e==null?void 0:e.gql),r=m.generatePath(n,t.typeName,i.typeName,a),u=r==null?void 0:r.split(".").pop(),f=`${u}Update.${u}`,s=(e==null?void 0:e.queries)||yn();if(f)return{path:f,...e||{},query:o,queries:s};if(e!=null&&e.path)return{...e,path:e.path,queries:s}}function vn(n){if(n)return c.print(n)}function gn(){return[]}function bn(n,t,i,a,e){if(!e||!t)return;const o=vn(e==null?void 0:e.gql),r=m.generatePath(n,t.typeName,i.typeName,a),u=r==null?void 0:r.split(".").pop(),f=`${u}Delete.${u}`,s=(e==null?void 0:e.queries)||gn();if(f)return{path:f,...e||{},query:o,queries:s};if(e!=null&&e.path)return{...e,path:e.path,queries:s}}function Nn(n,t){var f,s;const{simplifiedEntities:i,config:a}=t,e=a.adminPath?`${a.adminPath}.`:"",o=i.find(p=>{var l;return(l=p.directives)==null?void 0:l.find(d=>d.name==="queryRoot")}),r=m.findEntityFromPath(i,o.typeName,((f=a.adminPath)==null?void 0:f.split("."))||[]),u=(s=a.resources)==null?void 0:s.find(p=>p.name===n.typeName);return{label:an(n.directives),name:n.typeName,typeName:n.typeName,skipMenu:u==null?void 0:u.skipMenu,list:un(i,r,n,e,u==null?void 0:u.list),show:pn(i,r,n,e,u==null?void 0:u.show),create:mn(i,r,n,e,u==null?void 0:u.create),update:hn(i,r,n,e,u==null?void 0:u.update),delete:bn(i,r,n,e,u==null?void 0:u.delete)}}function En(n,t,i,a){const e=n===""?i:m.findEntityFromPath(t,"Query",n.split("."));if(!e)throw new Error("adminEntity not found");const o=e.fields.map(r=>r.typeName);return m.filterEntitiesByDirectiveName(t,"model").filter(r=>o.includes(r.typeName)).map(r=>Nn(r,a))}function Fn(n){var u,f,s,p;const{simplifiedEntities:t,config:i}=n,a=m.findEntityByDirectiveName(t,"queryRoot");if(!a)throw new Error("queryRoot not found");const e=(s=(f=(u=a.directives)==null?void 0:u.find(l=>l.name==="queryRoot"))==null?void 0:f.args)==null?void 0:s.adminPaths;if(!e)throw new Error("adminPaths not found");const o=e.map(l=>En(l,t,a,n)).flat(),r=((p=i.resources)==null?void 0:p.map(l=>l.name))||o.map(l=>l.name);return m.sortDataByOrder(o,r,"name")}function Tn(n,t){var a,e,o,r,u;const i="main";return{...t,create:(a=t.create)!=null&&a.path?{...t.create,queries:b(n,t.create,i,y.createQueryForCreate)}:t.create,update:(e=t.update)!=null&&e.path?{...t.update,queries:b(n,t.update,i,y.createQueryForUpdate)}:t.update,delete:(o=t.delete)!=null&&o.path?{...t.delete,queries:b(n,t.delete,i,y.createQueryForDelete)}:t.delete,show:(r=t.show)!=null&&r.path?{...t.show,queries:b(n,t.show,i,y.createQueryForShow)}:t.show,list:(u=t.list)!=null&&u.path?{...t.list,queries:b(n,t.list,i,y.createQueryForList)}:t.list}}function wn(n,t){var a;const i=E(t.list,"minimum");return{...t,list:(a=t.list)!=null&&a.path&&!i?{...t.list,queries:b(n,t.list,"minimum",y.createMinimumQueryForList)}:t.list}}function qn(n,t){const i="main",a=E(t.create,i),e=E(t.update,i),o=E(t.show,i),r=E(t.list,i);return{...t,create:a?{...t.create,...V(n,a.gql)}:t.create,update:e?{...t.update,...V(n,e.gql)}:t.update,show:o?{...t.show,...S(n,o.gql)}:t.show,list:r?{...t.list,...S(n,r.gql)}:t.list}}function Qn(n,t){var o,r,u,f;const{simplifiedEntities:i}=n,{show:a,list:e}=t;return{...t,show:a&&{...a,...O(a.structure,a.path,i,t)},list:e&&{...e,...O(e.structure,`${e.path}.nodes`,i,t,(f=(u=(r=(o=e==null?void 0:e.variablesStructure.find(s=>s.name==="sort"))==null?void 0:o.inputFields)==null?void 0:r.find(s=>s.typeName!=="BaseSortOrder"))==null?void 0:u.enumValues)==null?void 0:f.map(s=>({name:s.name})))}}}function $n(n,t){var i,a;return{...t,create:F(t.name,t.create),update:F(t.name,t.update),delete:F(t.name,t.delete),show:F(t.name,t.show,(i=t.show)==null?void 0:i.path),list:F(t.name,t.list,(a=t.list)==null?void 0:a.path,!0)}}function jn(n){return Fn(n).map(t=>Tn(n,t)).map(t=>wn(n,t)).map(t=>qn(n,t)).map(t=>Qn(n,t)).map(t=>$n(n,t))}h.convert=jn,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):o||k.set(n,o=new Set),o.add(r),t.has(r)||(t.add(r),i.push(a))}else i.push(a)}),E(E({},e),{definitions:i})}function C(e){var t=new Set(e.definitions);t.forEach(function(a){a.loc&&delete a.loc,Object.keys(a).forEach(function(n){var r=a[n];r&&typeof r=="object"&&t.add(r)})});var i=e.loc;return i&&(delete i.startToken,delete i.endToken),e}function L(e){var t=R(e);if(!T.has(t)){var i=p.parse(e,{experimentalFragmentVariables:F,allowLegacyFragmentVariables:F});if(!i||i.kind!=="Document")throw new Error("Not a valid GraphQL document.");T.set(t,C(W(i)))}return T.get(t)}function v(e){for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];typeof e=="string"&&(e=[e]);var a=e[0];return t.forEach(function(n,r){n&&n.kind==="Document"?a+=n.loc.source.body:a+=n,a+=e[r+1]}),L(a)}function A(){T.clear(),k.clear()}function G(){$=!1}function z(){F=!0}function H(){F=!1}var b={gql:v,resetCaches:A,disableFragmentWarnings:G,enableExperimentalFragmentVariables:z,disableExperimentalFragmentVariables:H};(function(e){e.gql=b.gql,e.resetCaches=b.resetCaches,e.disableFragmentWarnings=b.disableFragmentWarnings,e.enableExperimentalFragmentVariables=b.enableExperimentalFragmentVariables,e.disableExperimentalFragmentVariables=b.disableExperimentalFragmentVariables})(v||(v={})),v.default=v;function O(e,t,i,a,n){var s,u,f;if(!e)return;const r=t?(s=d.getField(e,t))==null?void 0:s.fields:e.fields,o=i.find(c=>c.typeName===a.name);return{fields:(r||[]).map(c=>n?n.find(l=>l===c.name)?{...c,isSortable:!0}:{...c}:c),displayColumns:(f=(u=o==null?void 0:o.directives)==null?void 0:u.find(c=>c.name==="model"))==null?void 0:f.args.displayColumns}}function N(e,t,i){const{queries:a}=t;return i.map(n=>{const r=a.find(o=>o.name===n.name);return r&&r.gql?{name:r.name,queryString:p.print(r.gql)}:r&&r.queryString?{name:r.name,queryString:r.queryString}:{name:n.name,queryString:n.callback(e,t.path)}})}function S(e,t){if(e)return e.queries.find(i=>i.name===t)}function J(e){return p.isEnumType(e.type)||p.isNonNullType(e.type)&&p.isEnumType(e.type.ofType)}function X(e){return p.isListType(e.type)||p.isNonNullType(e.type)&&p.isListType(e.type.ofType)}function Y(e){return!!(p.isScalarType(e.type)||p.isNonNullType(e.type)&&(p.isScalarType(e.type.ofType)||p.isListType(e.type.ofType)&&(p.isScalarType(e.type.ofType.ofType)||p.isNonNullType(e.type.ofType.ofType)&&p.isScalarType(e.type.ofType.ofType.ofType))))}function Z(e,t){return e?"Scalar":t?"Enum":"Object"}function K(e,t){var a,n,r;if(!t||!t.fields)throw new Error(`Parent entity not found: ${e}`);const i=t.fields.find(o=>o.name===e);return(r=(n=(a=i==null?void 0:i.directives)==null?void 0:a.find(o=>o.name==="label"))==null?void 0:n.args)==null?void 0:r.name}function _(e){if(e&&e.kind==="Enum")return e.enumValues}function U(e,t,i){var m,g;const a=X(e),n=p.isNonNullType(e.type),r=p.getNamedType(e.type).toString(),o=J(e),s=Y(e),u=d.getEntityByName(t,r),f=d.getEntityByName(t,i),c=K(e.name,f),l=_(u);return{name:e.name,isList:a,isNonNull:n,typeName:r,isScalar:s,isEnum:o,kind:Z(s,o),description:e.description,schemaDirectives:u==null?void 0:u.directives,label:c,enumValues:l,collection:(g=(m=u==null?void 0:u.directives)==null?void 0:m.find(Q=>Q.name==="collection"))==null?void 0:g.args,isUnion:(u==null?void 0:u.kind)==="Union"}}function D(e,t,i,a){const n=U(e,i,a);return n.isScalar||n.isEnum?n:{...n,fields:[]}}function tt(e,t){const i=d.getEntityByName(t,e.name.value);if(!i)throw new Error("entity type not found");return i}function j(e,t){switch(e.kind){case"NamedType":return{variable:tt(e,t),isNonNull:!1,isList:!1};case"NonNullType":return{...j(e.type,t),isNonNull:!0};case"ListType":return{...j(e.type,t),isList:!0};default:throw new Error("extractType error")}}function et(e,t){return{...j(e.type,t),name:e.variable.name.value}}function P(e,t,i=0){var n;if(i>=t.length)return e;const a={...e};return a.fields=(n=e.fields)==null?void 0:n.map(r=>r.fields?{...r,representativeField:r.fields.find(o=>o.name===t.find(s=>{var u;return(u=r.fields)==null?void 0:u.find(f=>f.name===s)})),fields:P(r,t,i+1).fields}:r),a}function x(e,t,i,a){const n=new p.TypeInfo(e);let r=null;const o=[],s=[],u={VariableDefinition:{enter(f){s.push(et(f,i))}},Field:{enter(f){var g,Q,B;const c=n.getParentType();if(!c)throw new Error("Parent type not found");const l=n.getFieldDef();if(!l)throw new Error("Field definition not found");const m=D(l,f,i,c.name);if(c.toString()===((g=e.getQueryType())==null?void 0:g.name)||c.toString()===((Q=e.getMutationType())==null?void 0:Q.name)){r=m,o.push(m);return}r&&((B=o[o.length-1].fields)==null||B.push(m),!m.isScalar&&!m.isEnum&&o.push(m))},leave(f){o.length>1&&f.selectionSet&&o.pop()}}};if(p.visit(t,p.visitWithTypeInfo(n,u)),!r)throw new Error("Couldn't find query object");return{queryObject:P(r,a),variableDefinitionObjects:s}}function nt(e,t,i,a){const{queryObject:n,variableDefinitionObjects:r}=x(e,t,i,a);if(!n)throw new Error("Query object not generated");return{structure:n,variableDefinitionObjects:r}}function it(e,t,i,a){const{queryObject:n,variableDefinitionObjects:r}=x(e,t,i,a);if(!n)throw new Error("Query object not generated");return{structure:n,variablesStructure:r}}function V(e,t){return it(e.graphqlSchema,v`
${t}
`,e.simplifiedEntities,e.config.nodeRepresentatives)}function M(e,t){return nt(e.graphqlSchema,v`
${t}
`,e.simplifiedEntities,e.config.nodeRepresentatives)}function w(e,t,i,a){var o,s;if(!t)return;if(a&&i)return{...t,responseDataPath:{data:`${i}.nodes`,total:`${i}.totalCount`}};if(i)return{...t,responseDataPath:{data:`${i}`}};const n=(s=(o=t.queries)==null?void 0:o.find(u=>u.name==="main"))==null?void 0:s.queryString;if(!n)throw new Error("Can't find gql");const r=v`
${n}
`;return{...t,responseDataPath:{data:`${r.definitions[0].name.value}.${d.lowercaseFirstLetter(e)}`}}}function at(e){var t,i;return((i=(t=e==null?void 0:e.find(a=>a.name==="label"))==null?void 0:t.args)==null?void 0:i.name)||void 0}function rt(){return[]}function ot(e,t,i,a,n){if(!t)return;const o=e.filter(f=>f.kind==="Object").find(f=>{var l;const c=(l=f.directives)==null?void 0:l.find(m=>m.name==="collection");return c?c.args.typeName===i.typeName:!1});if(!o)return;const s=d.generatePath(e,t.typeName,o.typeName,a),u=(n==null?void 0:n.queries)||rt();if(s)return{path:s,...n||{},queries:u};if(n!=null&&n.path)return{...n,path:n.path,queries:u}}function st(){return[]}function ut(e,t,i,a,n){if(!t)return;const r=d.generatePath(e,t.typeName,i.typeName,a),o=(n==null?void 0:n.queries)||st();if(r)return{path:r,...n||{},queries:o};if(n!=null&&n.path)return{...n,path:n.path,queries:o}}function ft(){return[]}function ct(e,t,i,a,n){if(!n||!t)return;const r=d.generatePath(e,t.typeName,i.typeName,a),o=r==null?void 0:r.split(".").pop(),s=`${o}Create.${o}`,u=(n==null?void 0:n.queries)||ft();if(s)return{path:s,...n||{},queries:u};if(n!=null&&n.path)return{...n,path:n.path,queries:u}}function lt(){return[]}function pt(e,t,i,a,n){if(!n||!t)return;const r=d.generatePath(e,t.typeName,i.typeName,a),o=r==null?void 0:r.split(".").pop(),s=`${o}Update.${o}`,u=(n==null?void 0:n.queries)||lt();if(s)return{path:s,...n||{},queries:u};if(n!=null&&n.path)return{...n,path:n.path,queries:u}}function mt(){return[]}function dt(e,t,i,a,n){if(!n||!t)return;const r=d.generatePath(e,t.typeName,i.typeName,a),o=r==null?void 0:r.split(".").pop(),s=`${o}Delete.${o}`,u=(n==null?void 0:n.queries)||mt();if(s)return{path:s,...n||{},queries:u};if(n!=null&&n.path)return{...n,path:n.path,queries:u}}function yt(e,t){var u,f;const{simplifiedEntities:i,config:a}=t,n=a.adminPath?`${a.adminPath}.`:"",r=i.find(c=>{var l;return(l=c.directives)==null?void 0:l.find(m=>m.name==="queryRoot")}),o=d.findEntityFromPath(i,r.typeName,((u=a.adminPath)==null?void 0:u.split("."))||[]),s=(f=a.resources)==null?void 0:f.find(c=>c.name===e.typeName);return{label:at(e.directives),name:e.typeName,typeName:e.typeName,skipMenu:s==null?void 0:s.skipMenu,list:ot(i,o,e,n,s==null?void 0:s.list),show:ut(i,o,e,n,s==null?void 0:s.show),create:ct(i,o,e,n,s==null?void 0:s.create),update:pt(i,o,e,n,s==null?void 0:s.update),delete:dt(i,o,e,n,s==null?void 0:s.delete)}}function ht(e,t,i,a){const n=e===""?i:d.findEntityFromPath(t,"Query",e.split("."));if(!n)throw new Error("adminEntity not found");const r=n.fields.map(o=>o.typeName);return d.filterEntitiesByDirectiveName(t,"model").filter(o=>r.includes(o.typeName)).map(o=>yt(o,a))}function vt(e){var s,u,f,c;const{simplifiedEntities:t,config:i}=e,a=d.findEntityByDirectiveName(t,"queryRoot");if(!a)throw new Error("queryRoot not found");const n=(f=(u=(s=a.directives)==null?void 0:s.find(l=>l.name==="queryRoot"))==null?void 0:u.args)==null?void 0:f.adminPaths;if(!n)throw new Error("adminPaths not found");const r=n.map(l=>ht(l,t,a,e)).flat(),o=((c=i.resources)==null?void 0:c.map(l=>l.name))||r.map(l=>l.name);return d.sortDataByOrder(r,o,"name")}function gt(e,t){var f,c,l,m,g;const i="main",a="minimum",n=[{name:i,callback:y.createQueryForCreate}],r=[{name:i,callback:y.createQueryForUpdate}],o=[{name:i,callback:y.createQueryForDelete}],s=[{name:i,callback:y.createQueryForShow}],u=[{name:i,callback:y.createQueryForList},{name:a,callback:y.createMinimumQueryForList}];return{...t,create:(f=t.create)!=null&&f.path?{...t.create,queries:N(e,t.create,n)}:void 0,update:(c=t.update)!=null&&c.path?{...t.update,queries:N(e,t.update,r)}:void 0,delete:(l=t.delete)!=null&&l.path?{...t.delete,queries:N(e,t.delete,o)}:void 0,show:(m=t.show)!=null&&m.path?{...t.show,queries:N(e,t.show,s)}:void 0,list:(g=t.list)!=null&&g.path?{...t.list,queries:N(e,t.list,u)}:void 0}}function bt(e,t){const i="main",a=S(t.create,i),n=S(t.update,i),r=S(t.show,i),o=S(t.list,i);return{...t,create:a?{...t.create,...M(e,a.queryString)}:t.create,update:n?{...t.update,...M(e,n.queryString)}:t.update,show:r?{...t.show,...V(e,r.queryString)}:t.show,list:o?{...t.list,...V(e,o.queryString)}:t.list}}function Nt(e,t){var n,r,o,s,u;const i=(u=(s=(o=(r=(n=e.variablesStructure)==null?void 0:n.find(f=>f.name==="sort"))==null?void 0:r.variable)==null?void 0:o.inputFields)==null?void 0:s.find(f=>f.name==="field"))==null?void 0:u.typeName,a=t.find(f=>f.typeName===i);return a==null?void 0:a.enumValues.map(f=>f.name)}function wt(e,t){const{simplifiedEntities:i}=e,{show:a,list:n}=t;return{...t,show:a&&{...a,...O(a.structure,a.path,i,t)},list:n&&{...n,...O(n.structure,`${n.path}.nodes`,i,t,Nt(n,i))}}}function qt(e,t){var i,a;return{...t,create:w(t.name,t.create),update:w(t.name,t.update),delete:w(t.name,t.delete),show:w(t.name,t.show,(i=t.show)==null?void 0:i.path),list:w(t.name,t.list,(a=t.list)==null?void 0:a.path,!0)}}function q(e){return e.map(t=>({name:t.name,gql:v`
${t.queryString}
`}))}function Et(e){return vt(e).map(t=>gt(e,t)).map(t=>bt(e,t)).map(t=>wt(e,t)).map(t=>qt(e,t)).map(t=>({...t,create:t.create?{...t.create,queries:q(t.create.queries)}:void 0,delete:t.delete?{...t.delete,queries:q(t.delete.queries)}:void 0,update:t.update?{...t.update,queries:q(t.update.queries)}:void 0,show:t.show?{...t.show,queries:q(t.show.queries)}:void 0,list:t.list?{...t.list,queries:q(t.list.queries)}:void 0}))}h.convert=Et,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
//# sourceMappingURL=index.umd.js.map

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

/// <reference types="react" />
import type { DocumentNode } from 'graphql';

@@ -116,3 +115,2 @@ type Description = string | undefined;

queries: Array<RawQuery>;
component?: (props: any) => JSX.Element;
responseDataPath: {

@@ -127,3 +125,2 @@ data: string;

queries: Array<RawQuery>;
component?: (props: any) => JSX.Element;
responseDataPath: {

@@ -138,3 +135,2 @@ data: string;

queries: Array<RawQuery>;
component?: (props: any) => JSX.Element;
responseDataPath: {

@@ -152,3 +148,2 @@ data: string;

queries: Array<RawQuery>;
component?: (props: any) => JSX.Element;
responseDataPath: {

@@ -155,0 +150,0 @@ data: string;

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

/// <reference types="react" />
import { DocumentNode, GraphQLSchema } from 'graphql';

@@ -12,3 +11,4 @@ import type { EnumSimplifiedEntityType, FieldObject, FinalResource, InputObjectSimplifiedEntityType, ObjectSimplifiedEntityType, ScalarSimplifiedEntityType, SimplifiedEntityType, VariableDefinitionObject } from './shared/base_type';

name: string;
gql: DocumentNode;
gql?: DocumentNode;
queryString?: string;
};

@@ -20,4 +20,2 @@ export type InitialResource = {

create?: {
gql?: DocumentNode;
component?: (props: any) => JSX.Element;
responseDataPath?: {

@@ -30,4 +28,2 @@ data: string;

update?: {
gql?: DocumentNode;
component?: (props: any) => JSX.Element;
responseDataPath?: {

@@ -40,4 +36,2 @@ data: string;

list?: {
gql?: DocumentNode;
component?: (props: any) => JSX.Element;
responseDataPath?: {

@@ -52,4 +46,2 @@ data: string;

show?: {
gql?: DocumentNode;
component?: (props: any) => JSX.Element;
responseDataPath?: {

@@ -62,3 +54,2 @@ data: string;

delete?: {
gql?: DocumentNode;
responseDataPath?: {

@@ -78,2 +69,5 @@ data: string;

dashboard?: any;
resources?: {
[name: string]: any;
};
};

@@ -80,0 +74,0 @@ resources?: Array<InitialResource>;

@@ -1,11 +0,10 @@

import { DocumentNode } from 'graphql';
export default function findQueryByName<T extends {
queries: Array<{
name: string;
gql: DocumentNode;
queryString: string;
}>;
}>(action: T | undefined, name: string): {
name: string;
gql: DocumentNode;
queryString: string;
} | undefined;
//# sourceMappingURL=findQueryByName.d.ts.map
{
"name": "@theconcurrent/resource",
"version": "0.0.22",
"version": "0.0.23",
"main": "./dist/index.umd.js",

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

"dependencies": {
"@theconcurrent/query": "0.0.22",
"@theconcurrent/simplified-entity": "0.0.22",
"@theconcurrent/utility": "0.0.22",
"@theconcurrent/query": "0.0.23",
"@theconcurrent/simplified-entity": "0.0.23",
"@theconcurrent/utility": "0.0.23",
"graphql": "16.0.1"
},
"peerDependencies": {
"@theconcurrent/query": "0.0.22",
"@theconcurrent/simplified-entity": "0.0.22",
"@theconcurrent/utility": "0.0.22",
"@theconcurrent/query": "0.0.23",
"@theconcurrent/simplified-entity": "0.0.23",
"@theconcurrent/utility": "0.0.23",
"graphql": "16.0.1"
},
"gitHead": "4e04af73d3dfd9447118398d97ede00237e6bc48"
"gitHead": "ae6d0257ef1fa7a5f55dfcf6d862886e80517fe5"
}

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

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

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