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.24 to 0.0.25

20

./dist/index.umd.js

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

(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,m,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 o in i)Object.prototype.hasOwnProperty.call(i,o)&&(t[o]=i[o])}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,o=I(a.loc),r=k.get(n);r&&!r.has(o)?$&&console.warn("Warning: fragment with name "+n+` 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,m){"use strict";var T=function(){return T=Object.assign||function(e){for(var i,a=1,t=arguments.length;a<t;a++){i=arguments[a];for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(e[o]=i[o])}return e},T.apply(this,arguments)};typeof SuppressedError=="function"&&SuppressedError;var F=new Map,j=new Map,O=!0,S=!1;function P(n){return n.replace(/[\s,]+/g," ").trim()}function I(n){return P(n.source.body.substring(n.start,n.end))}function W(n){var e=new Set,i=[];return n.definitions.forEach(function(a){if(a.kind==="FragmentDefinition"){var t=a.name.value,o=I(a.loc),r=j.get(t);r&&!r.has(o)?O&&console.warn("Warning: fragment with name "+t+` 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||k.set(n,r=new Set),r.add(o),t.has(o)||(t.add(o),i.push(a))}else i.push(a)}),E(E({},e),{definitions:i})}function L(e){var t=new Set(e.definitions);t.forEach(function(a){a.loc&&delete a.loc,Object.keys(a).forEach(function(n){var o=a[n];o&&typeof o=="object"&&t.add(o)})});var i=e.loc;return i&&(delete i.startToken,delete i.endToken),e}function C(e){var t=R(e);if(!T.has(t)){var i=m.parse(e,{experimentalFragmentVariables:F,allowLegacyFragmentVariables:F});if(!i||i.kind!=="Document")throw new Error("Not a valid GraphQL document.");T.set(t,L(W(i)))}return T.get(t)}function g(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,o){n&&n.kind==="Document"?a+=n.loc.source.body:a+=n,a+=e[o+1]}),C(a)}function A(){T.clear(),k.clear()}function G(){$=!1}function z(){F=!0}function H(){F=!1}var b={gql:g,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})(g||(g={})),g.default=g;function O(e,t,i,a,n){var s,u,f;if(!e)return;const o=t?(s=d.getField(e,t))==null?void 0:s.fields:e.fields,r=i.find(c=>c.typeName===a.name);return{fields:(o||[]).map(c=>n?n.find(l=>l===c.name)?{...c,isSortable:!0}:{...c}:c),displayColumns:(f=(u=r==null?void 0:r.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,n=i.map(r=>{const s=a.find(u=>u.name===r.name);return s&&s.gql?{name:s.name,queryString:m.print(s.gql)}:s&&s.queryString?{name:s.name,queryString:s.queryString}:{name:r.name,queryString:r.callback(e,t.path)}}),o=a.filter(r=>i.filter(s=>!s.name.includes(r.name))).map(r=>{if(r.gql)return{name:r.name,queryString:m.print(r.gql)};if(r.queryString)return{name:r.name,queryString:r.queryString};throw new Error("query must have gql or queryString")});return[...n,...o]}function S(e,t){if(e)return e.queries.find(i=>i.name===t)}function J(e){return m.isEnumType(e.type)||m.isNonNullType(e.type)&&m.isEnumType(e.type.ofType)}function X(e){return m.isListType(e.type)||m.isNonNullType(e.type)&&m.isListType(e.type.ofType)}function Y(e){return!!(m.isScalarType(e.type)||m.isNonNullType(e.type)&&(m.isScalarType(e.type.ofType)||m.isListType(e.type.ofType)&&(m.isScalarType(e.type.ofType.ofType)||m.isNonNullType(e.type.ofType.ofType)&&m.isScalarType(e.type.ofType.ofType.ofType))))}function Z(e,t){return e?"Scalar":t?"Enum":"Object"}function K(e,t){var a,n,o;if(!t||!t.fields)throw new Error(`Parent entity not found: ${e}`);const i=t.fields.find(r=>r.name===e);return(o=(n=(a=i==null?void 0:i.directives)==null?void 0:a.find(r=>r.name==="label"))==null?void 0:n.args)==null?void 0:o.name}function _(e){if(e&&e.kind==="Enum")return e.enumValues}function U(e,t,i){var p,v;const a=X(e),n=m.isNonNullType(e.type),o=m.getNamedType(e.type).toString(),r=J(e),s=Y(e),u=d.getEntityByName(t,o),f=d.getEntityByName(t,i),c=K(e.name,f),l=_(u);return{name:e.name,isList:a,isNonNull:n,typeName:o,isScalar:s,isEnum:r,kind:Z(s,r),description:e.description,schemaDirectives:u==null?void 0:u.directives,label:c,enumValues:l,collection:(v=(p=u==null?void 0:u.directives)==null?void 0:p.find(Q=>Q.name==="collection"))==null?void 0:v.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(o=>o.fields?{...o,representativeField:o.fields.find(r=>r.name===t.find(s=>{var u;return(u=o.fields)==null?void 0:u.find(f=>f.name===s)})),fields:P(o,t,i+1).fields}:o),a}function x(e,t,i,a){const n=new m.TypeInfo(e);let o=null;const r=[],s=[],u={VariableDefinition:{enter(f){s.push(et(f,i))}},Field:{enter(f){var v,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 p=D(l,f,i,c.name);if(c.toString()===((v=e.getQueryType())==null?void 0:v.name)||c.toString()===((Q=e.getMutationType())==null?void 0:Q.name)){o=p,r.push(p);return}o&&((B=r[r.length-1].fields)==null||B.push(p),!p.isScalar&&!p.isEnum&&r.push(p))},leave(f){r.length>1&&f.selectionSet&&r.pop()}}};if(m.visit(t,m.visitWithTypeInfo(n,u)),!o)throw new Error("Couldn't find query object");return{queryObject:P(o,a),variableDefinitionObjects:s}}function nt(e,t,i,a){const{queryObject:n,variableDefinitionObjects:o}=x(e,t,i,a);if(!n)throw new Error("Query object not generated");return{structure:n,variableDefinitionObjects:o}}function it(e,t,i,a){const{queryObject:n,variableDefinitionObjects:o}=x(e,t,i,a);if(!n)throw new Error("Query object not generated");return{structure:n,variablesStructure:o}}function V(e,t){return it(e.graphqlSchema,g`
${t}
`,e.simplifiedEntities,e.config.nodeRepresentatives)}function M(e,t){return nt(e.graphqlSchema,g`
${t}
`,e.simplifiedEntities,e.config.nodeRepresentatives)}function w(e,t,i,a){var r,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=(r=t.queries)==null?void 0:r.find(u=>u.name==="main"))==null?void 0:s.queryString;if(!n)throw new Error("Can't find gql");const o=g`
${n}
`;return{...t,responseDataPath:{data:`${o.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 r=e.filter(f=>f.kind==="Object").find(f=>{var l;const c=(l=f.directives)==null?void 0:l.find(p=>p.name==="collection");return c?c.args.typeName===i.typeName:!1});if(!r)return;const s=d.generatePath(e,t.typeName,r.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 o=d.generatePath(e,t.typeName,i.typeName,a),r=(n==null?void 0:n.queries)||st();if(o)return{path:o,...n||{},queries:r};if(n!=null&&n.path)return{...n,path:n.path,queries:r}}function ft(){return[]}function ct(e,t,i,a,n){if(!n||!t)return;const o=d.generatePath(e,t.typeName,i.typeName,a),r=o==null?void 0:o.split(".").pop(),s=`${r}Create.${r}`,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 mt(e,t,i,a,n){if(!n||!t)return;const o=d.generatePath(e,t.typeName,i.typeName,a),r=o==null?void 0:o.split(".").pop(),s=`${r}Update.${r}`,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 pt(){return[]}function dt(e,t,i,a,n){if(!n||!t)return;const o=d.generatePath(e,t.typeName,i.typeName,a),r=o==null?void 0:o.split(".").pop(),s=`${r}Delete.${r}`,u=(n==null?void 0:n.queries)||pt();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}.`:"",o=i.find(c=>{var l;return(l=c.directives)==null?void 0:l.find(p=>p.name==="queryRoot")}),r=d.findEntityFromPath(i,o.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,r,e,n,s==null?void 0:s.list),show:ut(i,r,e,n,s==null?void 0:s.show),create:ct(i,r,e,n,s==null?void 0:s.create),update:mt(i,r,e,n,s==null?void 0:s.update),delete:dt(i,r,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 o=n.fields.map(r=>r.typeName);return d.filterEntitiesByDirectiveName(t,"model").filter(r=>o.includes(r.typeName)).map(r=>yt(r,a))}function gt(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 o=n.map(l=>ht(l,t,a,e)).flat(),r=((c=i.resources)==null?void 0:c.map(l=>l.name))||o.map(l=>l.name);return d.sortDataByOrder(o,r,"name")}function vt(e,t){var f,c,l,p,v;const i="main",a="minimum",n=[{name:i,callback:y.createQueryForCreate}],o=[{name:i,callback:y.createQueryForUpdate}],r=[{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,o)}:void 0,delete:(l=t.delete)!=null&&l.path?{...t.delete,queries:N(e,t.delete,r)}:void 0,show:(p=t.show)!=null&&p.path?{...t.show,queries:N(e,t.show,s)}:void 0,list:(v=t.list)!=null&&v.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),o=S(t.show,i),r=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:o?{...t.show,...V(e,o.queryString)}:t.show,list:r?{...t.list,...V(e,r.queryString)}:t.list}}function Nt(e,t){var n,o,r,s,u;const i=(u=(s=(r=(o=(n=e.variablesStructure)==null?void 0:n.find(f=>f.name==="sort"))==null?void 0:o.variable)==null?void 0:r.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:g`
${t.queryString}
`}))}function Et(e){return gt(e).map(t=>vt(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"})});
this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):r||j.set(t,r=new Set),r.add(o),e.has(o)||(e.add(o),i.push(a))}else i.push(a)}),T(T({},n),{definitions:i})}function L(n){var e=new Set(n.definitions);e.forEach(function(a){a.loc&&delete a.loc,Object.keys(a).forEach(function(t){var o=a[t];o&&typeof o=="object"&&e.add(o)})});var i=n.loc;return i&&(delete i.startToken,delete i.endToken),n}function C(n){var e=P(n);if(!F.has(e)){var i=p.parse(n,{experimentalFragmentVariables:S,allowLegacyFragmentVariables:S});if(!i||i.kind!=="Document")throw new Error("Not a valid GraphQL document.");F.set(e,L(W(i)))}return F.get(e)}function g(n){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];typeof n=="string"&&(n=[n]);var a=n[0];return e.forEach(function(t,o){t&&t.kind==="Document"?a+=t.loc.source.body:a+=t,a+=n[o+1]}),C(a)}function A(){F.clear(),j.clear()}function G(){O=!1}function z(){S=!0}function H(){S=!1}var b={gql:g,resetCaches:A,disableFragmentWarnings:G,enableExperimentalFragmentVariables:z,disableExperimentalFragmentVariables:H};(function(n){n.gql=b.gql,n.resetCaches=b.resetCaches,n.disableFragmentWarnings=b.disableFragmentWarnings,n.enableExperimentalFragmentVariables=b.enableExperimentalFragmentVariables,n.disableExperimentalFragmentVariables=b.disableExperimentalFragmentVariables})(g||(g={})),g.default=g;function R(n,e,i,a,t){var s,u,f;if(!n)return;const o=e?(s=m.getField(n,e))==null?void 0:s.fields:n.fields,r=i.find(c=>c.typeName===a.name);return{fields:(o||[]).map(c=>t?t.find(l=>l===c.name)?{...c,isSortable:!0}:{...c}:c),displayColumns:(f=(u=r==null?void 0:r.directives)==null?void 0:u.find(c=>c.name==="model"))==null?void 0:f.args.displayColumns}}function N(n,e,i){const{queries:a}=e,t=i.map(r=>{const s=a.find(u=>u.name===r.name);return s&&s.gql?{name:s.name,queryString:p.print(s.gql)}:s&&s.queryString?{name:s.name,queryString:s.queryString}:{name:r.name,queryString:r.callback(n,e.path)}}),o=a.filter(r=>i.filter(s=>!s.name.includes(r.name))).map(r=>{if(r.gql)return{name:r.name,queryString:p.print(r.gql)};if(r.queryString)return{name:r.name,queryString:r.queryString};throw new Error("query must have gql or queryString")});return[...t,...o]}function Q(n,e){if(n)return n.queries.find(i=>i.name===e)}function J(n){return p.isEnumType(n.type)||p.isNonNullType(n.type)&&p.isEnumType(n.type.ofType)}function X(n){return p.isListType(n.type)||p.isNonNullType(n.type)&&p.isListType(n.type.ofType)}function Y(n){return!!(p.isScalarType(n.type)||p.isNonNullType(n.type)&&(p.isScalarType(n.type.ofType)||p.isListType(n.type.ofType)&&(p.isScalarType(n.type.ofType.ofType)||p.isNonNullType(n.type.ofType.ofType)&&p.isScalarType(n.type.ofType.ofType.ofType))))}function Z(n,e){return n?"Scalar":e?"Enum":"Object"}function K(n,e){var a,t,o;if(!e||!e.fields)throw new Error(`Parent entity not found: ${n}`);const i=e.fields.find(r=>r.name===n);return(o=(t=(a=i==null?void 0:i.directives)==null?void 0:a.find(r=>r.name==="label"))==null?void 0:t.args)==null?void 0:o.name}function _(n){if(n&&n.kind==="Enum")return n.enumValues}function U(n,e){if(n&&(n==null?void 0:n.kind)==="Union")return n.possibleTypes.map(i=>{const a=e.find(t=>t.typeName===i.typeName);if(!a)throw new Error("Object not found");if(a.kind==="Object")return{name:i.name,typeName:i.typeName,kind:i.kind,label:a.description};throw new Error(`Union type can't be object type: ${a.kind}`)})}function D(n,e,i){var v,E;const a=X(n),t=p.isNonNullType(n.type),o=p.getNamedType(n.type).toString(),r=J(n),s=Y(n),u=m.getEntityByName(e,o),f=m.getEntityByName(e,i),c=K(n.name,f),l=_(u),d=U(u,e);return{name:n.name,isList:a,isNonNull:t,typeName:o,isScalar:s,isEnum:r,kind:Z(s,r),description:n.description,schemaDirectives:u==null?void 0:u.directives,label:c,enumValues:l,collection:(E=(v=u==null?void 0:u.directives)==null?void 0:v.find(k=>k.name==="collection"))==null?void 0:E.args,isUnion:(u==null?void 0:u.kind)==="Union",possibleTypes:d}}function ee(n,e,i,a){const t=D(n,i,a);return t.isScalar||t.isEnum?t:{...t,fields:[]}}function ne(n,e){const i=m.getEntityByName(e,n.name.value);if(!i)throw new Error("entity type not found");return i}function $(n,e){switch(n.kind){case"NamedType":return{variable:ne(n,e),isNonNull:!1,isList:!1};case"NonNullType":return{...$(n.type,e),isNonNull:!0};case"ListType":return{...$(n.type,e),isList:!0};default:throw new Error("extractType error")}}function te(n,e){return{...$(n.type,e),name:n.variable.name.value}}function x(n,e,i=0){var t;if(i>=e.length)return n;const a={...n};return a.fields=(t=n.fields)==null?void 0:t.map(o=>o.fields?{...o,representativeField:o.fields.find(r=>r.name===e.find(s=>{var u;return(u=o.fields)==null?void 0:u.find(f=>f.name===s)})),fields:x(o,e,i+1).fields}:o),a}function V(n,e,i,a){const t=new p.TypeInfo(n);let o=null;const r=[],s=[],u={VariableDefinition:{enter(f){s.push(te(f,i))}},Field:{enter(f){var v,E,k;const c=t.getParentType();if(!c)throw new Error("Parent type not found");const l=t.getFieldDef();if(!l)throw new Error("Field definition not found");const d=ee(l,f,i,c.name);if(c.toString()===((v=n.getQueryType())==null?void 0:v.name)||c.toString()===((E=n.getMutationType())==null?void 0:E.name)){o=d,r.push(d);return}o&&((k=r[r.length-1].fields)==null||k.push(d),!d.isScalar&&!d.isEnum&&r.push(d))},leave(f){r.length>1&&f.selectionSet&&r.pop()}}};if(p.visit(e,p.visitWithTypeInfo(t,u)),!o)throw new Error("Couldn't find query object");return{queryObject:x(o,a),variableDefinitionObjects:s}}function ie(n,e,i,a){const{queryObject:t,variableDefinitionObjects:o}=V(n,e,i,a);if(!t)throw new Error("Query object not generated");return{structure:t,variableDefinitionObjects:o}}function ae(n,e,i,a){const{queryObject:t,variableDefinitionObjects:o}=V(n,e,i,a);if(!t)throw new Error("Query object not generated");return{structure:t,variablesStructure:o}}function M(n,e){return ae(n.graphqlSchema,g`
${e}
`,n.simplifiedEntities,n.config.nodeRepresentatives)}function B(n,e){return ie(n.graphqlSchema,g`
${e}
`,n.simplifiedEntities,n.config.nodeRepresentatives)}function w(n,e,i,a){var r,s;if(!e)return;if(a&&i)return{...e,responseDataPath:{data:`${i}.nodes`,total:`${i}.totalCount`}};if(i)return{...e,responseDataPath:{data:`${i}`}};const t=(s=(r=e.queries)==null?void 0:r.find(u=>u.name==="main"))==null?void 0:s.queryString;if(!t)throw new Error("Can't find gql");const o=g`
${t}
`;return{...e,responseDataPath:{data:`${o.definitions[0].name.value}.${m.lowercaseFirstLetter(n)}`}}}function re(n){var e,i;return((i=(e=n==null?void 0:n.find(a=>a.name==="label"))==null?void 0:e.args)==null?void 0:i.name)||void 0}function oe(){return[]}function se(n,e,i,a,t){if(!e)return;const r=n.filter(f=>f.kind==="Object").find(f=>{var l;const c=(l=f.directives)==null?void 0:l.find(d=>d.name==="collection");return c?c.args.typeName===i.typeName:!1});if(!r)return;const s=m.generatePath(n,e.typeName,r.typeName,a),u=(t==null?void 0:t.queries)||oe();if(s)return{path:s,...t||{},queries:u};if(t!=null&&t.path)return{...t,path:t.path,queries:u}}function ue(){return[]}function fe(n,e,i,a,t){if(!e)return;const o=m.generatePath(n,e.typeName,i.typeName,a),r=(t==null?void 0:t.queries)||ue();if(o)return{path:o,...t||{},queries:r};if(t!=null&&t.path)return{...t,path:t.path,queries:r}}function ce(){return[]}function le(n,e,i,a,t){if(!t||!e)return;const o=m.generatePath(n,e.typeName,i.typeName,a),r=o==null?void 0:o.split(".").pop(),s=`${r}Create.${r}`,u=(t==null?void 0:t.queries)||ce();if(s)return{path:s,...t||{},queries:u};if(t!=null&&t.path)return{...t,path:t.path,queries:u}}function pe(){return[]}function me(n,e,i,a,t){if(!t||!e)return;const o=m.generatePath(n,e.typeName,i.typeName,a),r=o==null?void 0:o.split(".").pop(),s=`${r}Update.${r}`,u=(t==null?void 0:t.queries)||pe();if(s)return{path:s,...t||{},queries:u};if(t!=null&&t.path)return{...t,path:t.path,queries:u}}function de(){return[]}function ye(n,e,i,a,t){if(!t||!e)return;const o=m.generatePath(n,e.typeName,i.typeName,a),r=o==null?void 0:o.split(".").pop(),s=`${r}Delete.${r}`,u=(t==null?void 0:t.queries)||de();if(s)return{path:s,...t||{},queries:u};if(t!=null&&t.path)return{...t,path:t.path,queries:u}}function he(n,e){var u,f;const{simplifiedEntities:i,config:a}=e,t=a.adminPath?`${a.adminPath}.`:"",o=i.find(c=>{var l;return(l=c.directives)==null?void 0:l.find(d=>d.name==="queryRoot")}),r=m.findEntityFromPath(i,o.typeName,((u=a.adminPath)==null?void 0:u.split("."))||[]),s=(f=a.resources)==null?void 0:f.find(c=>c.name===n.typeName);return{label:re(n.directives),name:n.typeName,typeName:n.typeName,skipMenu:s==null?void 0:s.skipMenu,list:se(i,r,n,t,s==null?void 0:s.list),show:fe(i,r,n,t,s==null?void 0:s.show),create:le(i,r,n,t,s==null?void 0:s.create),update:me(i,r,n,t,s==null?void 0:s.update),delete:ye(i,r,n,t,s==null?void 0:s.delete)}}function ge(n,e,i,a){const t=n===""?i:m.findEntityFromPath(e,"Query",n.split("."));if(!t)throw new Error("adminEntity not found");const o=t.fields.map(r=>r.typeName);return m.filterEntitiesByDirectiveName(e,"model").filter(r=>o.includes(r.typeName)).map(r=>he(r,a))}function ve(n){var s,u,f,c;const{simplifiedEntities:e,config:i}=n,a=m.findEntityByDirectiveName(e,"queryRoot");if(!a)throw new Error("queryRoot not found");const t=(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(!t)throw new Error("adminPaths not found");const o=t.map(l=>ge(l,e,a,n)).flat(),r=((c=i.resources)==null?void 0:c.map(l=>l.name))||o.map(l=>l.name);return m.sortDataByOrder(o,r,"name")}function be(n,e){var f,c,l,d,v;const i="main",a="minimum",t=[{name:i,callback:y.createQueryForCreate}],o=[{name:i,callback:y.createQueryForUpdate}],r=[{name:i,callback:y.createQueryForDelete}],s=[{name:i,callback:y.createQueryForShow}],u=[{name:i,callback:y.createQueryForList},{name:a,callback:y.createMinimumQueryForList}];return{...e,create:(f=e.create)!=null&&f.path?{...e.create,queries:N(n,e.create,t)}:void 0,update:(c=e.update)!=null&&c.path?{...e.update,queries:N(n,e.update,o)}:void 0,delete:(l=e.delete)!=null&&l.path?{...e.delete,queries:N(n,e.delete,r)}:void 0,show:(d=e.show)!=null&&d.path?{...e.show,queries:N(n,e.show,s)}:void 0,list:(v=e.list)!=null&&v.path?{...e.list,queries:N(n,e.list,u)}:void 0}}function Ne(n,e){const i="main",a=Q(e.create,i),t=Q(e.update,i),o=Q(e.show,i),r=Q(e.list,i);return{...e,create:a?{...e.create,...B(n,a.queryString)}:e.create,update:t?{...e.update,...B(n,t.queryString)}:e.update,show:o?{...e.show,...M(n,o.queryString)}:e.show,list:r?{...e.list,...M(n,r.queryString)}:e.list}}function we(n,e){var t,o,r,s,u;const i=(u=(s=(r=(o=(t=n.variablesStructure)==null?void 0:t.find(f=>f.name==="sort"))==null?void 0:o.variable)==null?void 0:r.inputFields)==null?void 0:s.find(f=>f.name==="field"))==null?void 0:u.typeName,a=e.find(f=>f.typeName===i);return a==null?void 0:a.enumValues.map(f=>f.name)}function qe(n,e){const{simplifiedEntities:i}=n,{show:a,list:t}=e;return{...e,show:a&&{...a,...R(a.structure,a.path,i,e)},list:t&&{...t,...R(t.structure,`${t.path}.nodes`,i,e,we(t,i))}}}function Ee(n,e){var i,a;return{...e,create:w(e.name,e.create),update:w(e.name,e.update),delete:w(e.name,e.delete),show:w(e.name,e.show,(i=e.show)==null?void 0:i.path),list:w(e.name,e.list,(a=e.list)==null?void 0:a.path,!0)}}function q(n){return n.map(e=>({name:e.name,gql:g`
${e.queryString}
`}))}function Te(n){return ve(n).map(e=>be(n,e)).map(e=>Ne(n,e)).map(e=>qe(n,e)).map(e=>Ee(n,e)).map(e=>({...e,create:e.create?{...e.create,queries:q(e.create.queries)}:void 0,delete:e.delete?{...e.delete,queries:q(e.delete.queries)}:void 0,update:e.update?{...e.update,queries:q(e.update.queries)}:void 0,show:e.show?{...e.show,queries:q(e.show.queries)}:void 0,list:e.list?{...e.list,queries:q(e.list.queries)}:void 0}))}h.convert=Te,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
//# sourceMappingURL=index.umd.js.map

@@ -9,13 +9,17 @@ import type { FieldObject, SimplifiedEntityType } from '../type';

typeName: string;
isScalar: boolean;
isEnum: boolean;
isList: boolean;
label: string | undefined;
possibleTypes: {
name: string;
typeName: string;
}[] | undefined;
collection: any;
description: string | undefined;
kind: "Scalar" | "Object" | "Enum";
isList: boolean;
isNonNull: boolean;
isScalar: boolean;
enumValues: any;
label: string | undefined;
isEnum: boolean;
fields?: FieldObject[] | undefined;
schemaDirectives?: import("../shared/base_type").DirectiveInfo[] | undefined;
collection: any;
isUnion: boolean;

@@ -22,0 +26,0 @@ })[];

import { createQueryForCreate as A, createQueryForUpdate as G, createQueryForDelete as z, createQueryForShow as H, createQueryForList as J, createMinimumQueryForList as X } from "@theconcurrent/query";
import { parse as Y, print as O, isEnumType as x, isNonNullType as b, isListType as T, 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 I, findEntityByDirectiveName as nt, sortDataByOrder as et, filterEntitiesByDirectiveName as it } from "@theconcurrent/utility";
import { parse as Y, print as R, isEnumType as x, isNonNullType as q, isListType as k, isScalarType as E, TypeInfo as Z, visit as K, visitWithTypeInfo as _, getNamedType as U } from "graphql";
import { getField as D, getEntityByName as j, lowercaseFirstLetter as tt, generatePath as w, findEntityFromPath as I, findEntityByDirectiveName as nt, sortDataByOrder as et, filterEntitiesByDirectiveName as it } from "@theconcurrent/utility";
var S = function() {

@@ -14,3 +14,3 @@ return S = Object.assign || function(t) {

};
var F = /* @__PURE__ */ new Map(), $ = /* @__PURE__ */ new Map(), W = !0, Q = !1;
var T = /* @__PURE__ */ new Map(), $ = /* @__PURE__ */ new Map(), W = !0, Q = !1;
function B(n) {

@@ -45,5 +45,5 @@ return n.replace(/[\s,]+/g, " ").trim();

}
function ut(n) {
function st(n) {
var t = B(n);
if (!F.has(t)) {
if (!T.has(t)) {
var i = Y(n, {

@@ -55,7 +55,7 @@ experimentalFragmentVariables: Q,

throw new Error("Not a valid GraphQL document.");
F.set(t, ot(rt(i)));
T.set(t, ot(rt(i)));
}
return F.get(t);
return T.get(t);
}
function c(n) {
function m(n) {
for (var t = [], i = 1; i < arguments.length; i++)

@@ -67,6 +67,6 @@ t[i - 1] = arguments[i];

e && e.kind === "Document" ? a += e.loc.source.body : a += e, a += n[o + 1];
}), ut(a);
}), st(a);
}
function st() {
F.clear(), $.clear();
function ut() {
T.clear(), $.clear();
}

@@ -82,5 +82,5 @@ function lt() {

}
var y = {
gql: c,
resetCaches: st,
var g = {
gql: m,
resetCaches: ut,
disableFragmentWarnings: lt,

@@ -91,24 +91,24 @@ enableExperimentalFragmentVariables: ft,

(function(n) {
n.gql = y.gql, n.resetCaches = y.resetCaches, n.disableFragmentWarnings = y.disableFragmentWarnings, n.enableExperimentalFragmentVariables = y.enableExperimentalFragmentVariables, n.disableExperimentalFragmentVariables = y.disableExperimentalFragmentVariables;
})(c || (c = {}));
c.default = c;
function V(n, t, i, a, e) {
var u, s, l;
n.gql = g.gql, n.resetCaches = g.resetCaches, n.disableFragmentWarnings = g.disableFragmentWarnings, n.enableExperimentalFragmentVariables = g.enableExperimentalFragmentVariables, n.disableExperimentalFragmentVariables = g.disableExperimentalFragmentVariables;
})(m || (m = {}));
m.default = m;
function P(n, t, i, a, e) {
var s, u, l;
if (!n)
return;
const o = t ? (u = D(n, t)) == null ? void 0 : u.fields : n.fields, r = i.find((f) => f.typeName === a.name);
const o = t ? (s = D(n, t)) == null ? void 0 : s.fields : n.fields, r = i.find((f) => f.typeName === a.name);
return {
fields: (o || []).map((f) => e ? e.find((p) => p === f.name) ? { ...f, isSortable: !0 } : { ...f } : f),
displayColumns: (l = (s = r == null ? void 0 : r.directives) == null ? void 0 : s.find((f) => f.name === "model")) == null ? void 0 : l.args.displayColumns
displayColumns: (l = (u = r == null ? void 0 : r.directives) == null ? void 0 : u.find((f) => f.name === "model")) == null ? void 0 : l.args.displayColumns
};
}
function g(n, t, i) {
function h(n, t, i) {
const { queries: a } = t, e = i.map((r) => {
const u = a.find((s) => s.name === r.name);
return u && u.gql ? {
name: u.name,
queryString: O(u.gql)
} : u && u.queryString ? {
name: u.name,
queryString: u.queryString
const s = a.find((u) => u.name === r.name);
return s && s.gql ? {
name: s.name,
queryString: R(s.gql)
} : s && s.queryString ? {
name: s.name,
queryString: s.queryString
} : {

@@ -118,7 +118,7 @@ name: r.name,

};
}), o = a.filter((r) => i.filter((u) => !u.name.includes(r.name))).map((r) => {
}), o = a.filter((r) => i.filter((s) => !s.name.includes(r.name))).map((r) => {
if (r.gql)
return {
name: r.name,
queryString: O(r.gql)
queryString: R(r.gql)
};

@@ -134,14 +134,14 @@ if (r.queryString)

}
function E(n, t) {
function F(n, t) {
if (n)
return n.queries.find((i) => i.name === t);
}
function ct(n) {
return x(n.type) || q(n.type) && x(n.type.ofType);
}
function mt(n) {
return x(n.type) || b(n.type) && x(n.type.ofType);
return k(n.type) || q(n.type) && k(n.type.ofType);
}
function ct(n) {
return T(n.type) || b(n.type) && T(n.type.ofType);
}
function dt(n) {
return !!(N(n.type) || b(n.type) && (N(n.type.ofType) || T(n.type.ofType) && (N(n.type.ofType.ofType) || b(n.type.ofType.ofType) && N(n.type.ofType.ofType.ofType))));
return !!(E(n.type) || q(n.type) && (E(n.type.ofType) || k(n.type.ofType) && (E(n.type.ofType.ofType) || q(n.type.ofType.ofType) && E(n.type.ofType.ofType.ofType))));
}

@@ -162,5 +162,21 @@ function yt(n, t) {

}
function vt(n, t, i) {
var m, d;
const a = ct(n), e = b(n.type), o = U(n.type).toString(), r = mt(n), u = dt(n), s = k(t, o), l = k(t, i), f = gt(n.name, l), p = ht(s);
function vt(n, t) {
if (n && (n == null ? void 0 : n.kind) === "Union")
return n.possibleTypes.map((i) => {
const a = t.find((e) => e.typeName === i.typeName);
if (!a)
throw new Error("Object not found");
if (a.kind === "Object")
return {
name: i.name,
typeName: i.typeName,
kind: i.kind,
label: a.description
};
throw new Error(`Union type can't be object type: ${a.kind}`);
});
}
function bt(n, t, i) {
var d, y;
const a = mt(n), e = q(n.type), o = U(n.type).toString(), r = ct(n), s = dt(n), u = j(t, o), l = j(t, i), f = gt(n.name, l), p = ht(u), c = vt(u, t);
return {

@@ -171,15 +187,16 @@ name: n.name,

typeName: o,
isScalar: u,
isScalar: s,
isEnum: r,
kind: yt(u, r),
kind: yt(s, r),
description: n.description,
schemaDirectives: s == null ? void 0 : s.directives,
schemaDirectives: u == null ? void 0 : u.directives,
label: f,
enumValues: p,
collection: (d = (m = s == null ? void 0 : s.directives) == null ? void 0 : m.find((w) => w.name === "collection")) == null ? void 0 : d.args,
isUnion: (s == null ? void 0 : s.kind) === "Union"
collection: (y = (d = u == null ? void 0 : u.directives) == null ? void 0 : d.find((N) => N.name === "collection")) == null ? void 0 : y.args,
isUnion: (u == null ? void 0 : u.kind) === "Union",
possibleTypes: c
};
}
function bt(n, t, i, a) {
const e = vt(n, i, a);
function qt(n, t, i, a) {
const e = bt(n, i, a);
return e.isScalar || e.isEnum ? e : {

@@ -190,4 +207,4 @@ ...e,

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

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

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

@@ -210,5 +227,5 @@ throw new Error("extractType error");

}
function wt(n, t) {
function Nt(n, t) {
return {
...j(n.type, t),
...O(n.type, t),
name: n.variable.name.value

@@ -225,5 +242,5 @@ };

representativeField: o.fields.find(
(r) => r.name === t.find((u) => {
var s;
return (s = o.fields) == null ? void 0 : s.find((l) => l.name === u);
(r) => r.name === t.find((s) => {
var u;
return (u = o.fields) == null ? void 0 : u.find((l) => l.name === s);
})

@@ -237,7 +254,7 @@ ),

let o = null;
const r = [], u = [];
const r = [], s = [];
if (K(t, _(e, {
VariableDefinition: {
enter(l) {
u.push(wt(l, i));
s.push(Nt(l, i));
}

@@ -247,3 +264,3 @@ },

enter(l) {
var d, w, R;
var d, y, N;
const f = e.getParentType();

@@ -255,3 +272,3 @@ if (!f)

throw new Error("Field definition not found");
const m = bt(
const c = qt(
p,

@@ -262,7 +279,7 @@ l,

);
if (f.toString() === ((d = n.getQueryType()) == null ? void 0 : d.name) || f.toString() === ((w = n.getMutationType()) == null ? void 0 : w.name)) {
o = m, r.push(m);
if (f.toString() === ((d = n.getQueryType()) == null ? void 0 : d.name) || f.toString() === ((y = n.getMutationType()) == null ? void 0 : y.name)) {
o = c, r.push(c);
return;
}
o && ((R = r[r.length - 1].fields) == null || R.push(m), !m.isScalar && !m.isEnum && r.push(m));
o && ((N = r[r.length - 1].fields) == null || N.push(c), !c.isScalar && !c.isEnum && r.push(c));
},

@@ -277,6 +294,6 @@ leave(l) {

queryObject: C(o, a),
variableDefinitionObjects: u
variableDefinitionObjects: s
};
}
function Nt(n, t, i, a) {
function Et(n, t, i, a) {
const { queryObject: e, variableDefinitionObjects: o } = L(

@@ -292,3 +309,3 @@ n,

}
function Et(n, t, i, a) {
function Ft(n, t, i, a) {
const { queryObject: e, variableDefinitionObjects: o } = L(

@@ -304,6 +321,6 @@ n,

}
function P(n, t) {
return Et(
function V(n, t) {
return Ft(
n.graphqlSchema,
c`
m`
${t}

@@ -316,5 +333,5 @@ `,

function M(n, t) {
return Nt(
return Et(
n.graphqlSchema,
c`
m`
${t}

@@ -326,4 +343,4 @@ `,

}
function h(n, t, i, a) {
var r, u;
function v(n, t, i, a) {
var r, s;
if (!t)

@@ -341,6 +358,6 @@ return;

};
const e = (u = (r = t.queries) == null ? void 0 : r.find((s) => s.name === "main")) == null ? void 0 : u.queryString;
const e = (s = (r = t.queries) == null ? void 0 : r.find((u) => u.name === "main")) == null ? void 0 : s.queryString;
if (!e)
throw new Error("Can't find gql");
const o = c`
const o = m`
${e}

@@ -357,3 +374,3 @@ `;

}
function Ft(n) {
function Tt(n) {
var t, i;

@@ -370,3 +387,3 @@ 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;

var p;
const f = (p = l.directives) == null ? void 0 : p.find((m) => m.name === "collection");
const f = (p = l.directives) == null ? void 0 : p.find((c) => c.name === "collection");
return f ? f.args.typeName === i.typeName : !1;

@@ -376,15 +393,15 @@ });

return;
const u = q(n, t.typeName, r.typeName, a), s = (e == null ? void 0 : e.queries) || St();
if (u)
return { path: u, ...e || {}, queries: s };
const s = w(n, t.typeName, r.typeName, a), u = (e == null ? void 0 : e.queries) || St();
if (s)
return { path: s, ...e || {}, queries: u };
if (e != null && e.path)
return { ...e, path: e.path, queries: s };
return { ...e, path: e.path, queries: u };
}
function Tt() {
function kt() {
return [];
}
function kt(n, t, i, a, e) {
function jt(n, t, i, a, e) {
if (!t)
return;
const o = q(n, t.typeName, i.typeName, a), r = (e == null ? void 0 : e.queries) || Tt();
const o = w(n, t.typeName, i.typeName, a), r = (e == null ? void 0 : e.queries) || kt();
if (o)

@@ -398,10 +415,10 @@ return { path: o, ...e || {}, queries: r };

}
function jt(n, t, i, a, e) {
function Ot(n, t, i, a, e) {
if (!e || !t)
return;
const o = q(n, t.typeName, i.typeName, a), r = o == null ? void 0 : o.split(".").pop(), u = `${r}Create.${r}`, s = (e == null ? void 0 : e.queries) || $t();
if (u)
return { path: u, ...e || {}, queries: s };
const o = w(n, t.typeName, i.typeName, a), r = o == null ? void 0 : o.split(".").pop(), s = `${r}Create.${r}`, u = (e == null ? void 0 : e.queries) || $t();
if (s)
return { path: s, ...e || {}, queries: u };
if (e != null && e.path)
return { ...e, path: e.path, queries: s };
return { ...e, path: e.path, queries: u };
}

@@ -411,12 +428,12 @@ function Rt() {

}
function Ot(n, t, i, a, e) {
function xt(n, t, i, a, e) {
if (!e || !t)
return;
const o = q(n, t.typeName, i.typeName, a), r = o == null ? void 0 : o.split(".").pop(), u = `${r}Update.${r}`, s = (e == null ? void 0 : e.queries) || Rt();
if (u)
return { path: u, ...e || {}, queries: s };
const o = w(n, t.typeName, i.typeName, a), r = o == null ? void 0 : o.split(".").pop(), s = `${r}Update.${r}`, u = (e == null ? void 0 : e.queries) || Rt();
if (s)
return { path: s, ...e || {}, queries: u };
if (e != null && e.path)
return { ...e, path: e.path, queries: s };
return { ...e, path: e.path, queries: u };
}
function xt() {
function Pt() {
return [];

@@ -427,14 +444,14 @@ }

return;
const o = q(n, t.typeName, i.typeName, a), r = o == null ? void 0 : o.split(".").pop(), u = `${r}Delete.${r}`, s = (e == null ? void 0 : e.queries) || xt();
if (u)
return { path: u, ...e || {}, queries: s };
const o = w(n, t.typeName, i.typeName, a), r = o == null ? void 0 : o.split(".").pop(), s = `${r}Delete.${r}`, u = (e == null ? void 0 : e.queries) || Pt();
if (s)
return { path: s, ...e || {}, queries: u };
if (e != null && e.path)
return { ...e, path: e.path, queries: s };
return { ...e, path: e.path, queries: u };
}
function Pt(n, t) {
var s, l;
function Mt(n, t) {
var u, l;
const { simplifiedEntities: i, config: a } = t, e = a.adminPath ? `${a.adminPath}.` : "", o = i.find(
(f) => {
var p;
return (p = f.directives) == null ? void 0 : p.find((m) => m.name === "queryRoot");
return (p = f.directives) == null ? void 0 : p.find((c) => c.name === "queryRoot");
}

@@ -444,17 +461,17 @@ ), r = I(

o.typeName,
((s = a.adminPath) == null ? void 0 : s.split(".")) || []
), u = (l = a.resources) == null ? void 0 : l.find((f) => f.name === n.typeName);
((u = a.adminPath) == null ? void 0 : u.split(".")) || []
), s = (l = a.resources) == null ? void 0 : l.find((f) => f.name === n.typeName);
return {
label: Ft(n.directives),
label: Tt(n.directives),
name: n.typeName,
typeName: n.typeName,
skipMenu: u == null ? void 0 : u.skipMenu,
list: Qt(i, r, n, e, u == null ? void 0 : u.list),
show: kt(i, r, n, e, u == null ? void 0 : u.show),
create: jt(i, r, n, e, u == null ? void 0 : u.create),
update: Ot(i, r, n, e, u == null ? void 0 : u.update),
delete: Vt(i, r, n, e, u == null ? void 0 : u.delete)
skipMenu: s == null ? void 0 : s.skipMenu,
list: Qt(i, r, n, e, s == null ? void 0 : s.list),
show: jt(i, r, n, e, s == null ? void 0 : s.show),
create: Ot(i, r, n, e, s == null ? void 0 : s.create),
update: xt(i, r, n, e, s == null ? void 0 : s.update),
delete: Vt(i, r, n, e, s == null ? void 0 : s.delete)
};
}
function Mt(n, t, i, a) {
function It(n, t, i, a) {
const e = n === "" ? i : I(t, "Query", n.split("."));

@@ -464,6 +481,6 @@ if (!e)

const o = e.fields.map((r) => r.typeName);
return it(t, "model").filter((r) => o.includes(r.typeName)).map((r) => Pt(r, a));
return it(t, "model").filter((r) => o.includes(r.typeName)).map((r) => Mt(r, a));
}
function It(n) {
var u, s, l, f;
function Wt(n) {
var s, u, l, f;
const { simplifiedEntities: t, config: i } = n, a = nt(

@@ -475,11 +492,11 @@ t,

throw new Error("queryRoot not found");
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;
const e = (l = (u = (s = a.directives) == null ? void 0 : s.find((p) => p.name === "queryRoot")) == null ? void 0 : u.args) == null ? void 0 : l.adminPaths;
if (!e)
throw new Error("adminPaths not found");
const o = e.map((p) => Mt(p, t, a, n)).flat(), r = ((f = i.resources) == null ? void 0 : f.map((p) => p.name)) || o.map((p) => p.name);
const o = e.map((p) => It(p, t, a, n)).flat(), r = ((f = i.resources) == null ? void 0 : f.map((p) => p.name)) || o.map((p) => p.name);
return et(o, r, "name");
}
function Wt(n, t) {
var l, f, p, m, d;
const i = "main", a = "minimum", e = [{ name: i, callback: A }], o = [{ name: i, callback: G }], r = [{ name: i, callback: z }], u = [{ name: i, callback: H }], s = [
function Bt(n, t) {
var l, f, p, c, d;
const i = "main", a = "minimum", e = [{ name: i, callback: A }], o = [{ name: i, callback: G }], r = [{ name: i, callback: z }], s = [{ name: i, callback: H }], u = [
{ name: i, callback: J },

@@ -492,24 +509,24 @@ { name: a, callback: X }

...t.create,
queries: g(n, t.create, e)
queries: h(n, t.create, e)
} : void 0,
update: (f = t.update) != null && f.path ? {
...t.update,
queries: g(n, t.update, o)
queries: h(n, t.update, o)
} : void 0,
delete: (p = t.delete) != null && p.path ? {
...t.delete,
queries: g(n, t.delete, r)
queries: h(n, t.delete, r)
} : void 0,
show: (m = t.show) != null && m.path ? {
show: (c = t.show) != null && c.path ? {
...t.show,
queries: g(n, t.show, u)
queries: h(n, t.show, s)
} : void 0,
list: (d = t.list) != null && d.path ? {
...t.list,
queries: g(n, t.list, s)
queries: h(n, t.list, u)
} : void 0
};
}
function Bt(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);
function Ct(n, t) {
const i = "main", a = F(t.create, i), e = F(t.update, i), o = F(t.show, i), r = F(t.list, i);
return {

@@ -527,16 +544,16 @@ ...t,

...t.show,
...P(n, o.queryString)
...V(n, o.queryString)
} : t.show,
list: r ? {
...t.list,
...P(n, r.queryString)
...V(n, r.queryString)
} : t.list
};
}
function Ct(n, t) {
var e, o, r, u, s;
const i = (s = (u = (r = (o = (e = n.variablesStructure) == null ? void 0 : e.find((l) => l.name === "sort")) == null ? void 0 : o.variable) == null ? void 0 : r.inputFields) == null ? void 0 : u.find((l) => l.name === "field")) == null ? void 0 : s.typeName, a = t.find((l) => l.typeName === i);
function Lt(n, t) {
var e, o, r, s, u;
const i = (u = (s = (r = (o = (e = n.variablesStructure) == null ? void 0 : e.find((l) => l.name === "sort")) == null ? void 0 : o.variable) == null ? void 0 : r.inputFields) == null ? void 0 : s.find((l) => l.name === "field")) == null ? void 0 : u.typeName, a = t.find((l) => l.typeName === i);
return a == null ? void 0 : a.enumValues.map((l) => l.name);
}
function Lt(n, t) {
function At(n, t) {
const { simplifiedEntities: i } = n, { show: a, list: e } = t;

@@ -547,3 +564,3 @@ return {

...a,
...V(
...P(
// @ts-ignore

@@ -559,3 +576,3 @@ // eslint-disable-next-line

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

@@ -568,3 +585,3 @@ // eslint-disable-next-line

t,
Ct(e, i)
Lt(e, i)
// eslint-disable-line

@@ -575,11 +592,11 @@ )

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

@@ -592,6 +609,6 @@ t.list,

}
function v(n) {
function b(n) {
return n.map((t) => ({
name: t.name,
gql: c`
gql: m`
${t.queryString}

@@ -601,24 +618,24 @@ `

}
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) => ({
function Xt(n) {
return Wt(n).map((t) => Bt(n, t)).map((t) => Ct(n, t)).map((t) => At(n, t)).map((t) => Gt(n, t)).map((t) => ({
...t,
create: t.create ? (
// @ts-ignore
{ ...t.create, queries: v(t.create.queries) }
{ ...t.create, queries: b(t.create.queries) }
) : void 0,
delete: t.delete ? (
// @ts-ignore
{ ...t.delete, queries: v(t.delete.queries) }
{ ...t.delete, queries: b(t.delete.queries) }
) : void 0,
update: t.update ? (
// @ts-ignore
{ ...t.update, queries: v(t.update.queries) }
{ ...t.update, queries: b(t.update.queries) }
) : void 0,
show: t.show ? (
// @ts-ignore
{ ...t.show, queries: v(t.show.queries) }
{ ...t.show, queries: b(t.show.queries) }
) : void 0,
list: t.list ? (
// @ts-ignore
{ ...t.list, queries: v(t.list.queries) }
{ ...t.list, queries: b(t.list.queries) }
) : void 0

@@ -628,4 +645,4 @@ }));

export {
Jt as convert
Xt as convert
};
//# sourceMappingURL=index.es.js.map

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

(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,m,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 o in i)Object.prototype.hasOwnProperty.call(i,o)&&(t[o]=i[o])}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,o=I(a.loc),r=k.get(n);r&&!r.has(o)?$&&console.warn("Warning: fragment with name "+n+` 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,m){"use strict";var T=function(){return T=Object.assign||function(e){for(var i,a=1,t=arguments.length;a<t;a++){i=arguments[a];for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(e[o]=i[o])}return e},T.apply(this,arguments)};typeof SuppressedError=="function"&&SuppressedError;var F=new Map,j=new Map,O=!0,S=!1;function P(n){return n.replace(/[\s,]+/g," ").trim()}function I(n){return P(n.source.body.substring(n.start,n.end))}function W(n){var e=new Set,i=[];return n.definitions.forEach(function(a){if(a.kind==="FragmentDefinition"){var t=a.name.value,o=I(a.loc),r=j.get(t);r&&!r.has(o)?O&&console.warn("Warning: fragment with name "+t+` 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||k.set(n,r=new Set),r.add(o),t.has(o)||(t.add(o),i.push(a))}else i.push(a)}),E(E({},e),{definitions:i})}function L(e){var t=new Set(e.definitions);t.forEach(function(a){a.loc&&delete a.loc,Object.keys(a).forEach(function(n){var o=a[n];o&&typeof o=="object"&&t.add(o)})});var i=e.loc;return i&&(delete i.startToken,delete i.endToken),e}function C(e){var t=R(e);if(!T.has(t)){var i=m.parse(e,{experimentalFragmentVariables:F,allowLegacyFragmentVariables:F});if(!i||i.kind!=="Document")throw new Error("Not a valid GraphQL document.");T.set(t,L(W(i)))}return T.get(t)}function g(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,o){n&&n.kind==="Document"?a+=n.loc.source.body:a+=n,a+=e[o+1]}),C(a)}function A(){T.clear(),k.clear()}function G(){$=!1}function z(){F=!0}function H(){F=!1}var b={gql:g,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})(g||(g={})),g.default=g;function O(e,t,i,a,n){var s,u,f;if(!e)return;const o=t?(s=d.getField(e,t))==null?void 0:s.fields:e.fields,r=i.find(c=>c.typeName===a.name);return{fields:(o||[]).map(c=>n?n.find(l=>l===c.name)?{...c,isSortable:!0}:{...c}:c),displayColumns:(f=(u=r==null?void 0:r.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,n=i.map(r=>{const s=a.find(u=>u.name===r.name);return s&&s.gql?{name:s.name,queryString:m.print(s.gql)}:s&&s.queryString?{name:s.name,queryString:s.queryString}:{name:r.name,queryString:r.callback(e,t.path)}}),o=a.filter(r=>i.filter(s=>!s.name.includes(r.name))).map(r=>{if(r.gql)return{name:r.name,queryString:m.print(r.gql)};if(r.queryString)return{name:r.name,queryString:r.queryString};throw new Error("query must have gql or queryString")});return[...n,...o]}function S(e,t){if(e)return e.queries.find(i=>i.name===t)}function J(e){return m.isEnumType(e.type)||m.isNonNullType(e.type)&&m.isEnumType(e.type.ofType)}function X(e){return m.isListType(e.type)||m.isNonNullType(e.type)&&m.isListType(e.type.ofType)}function Y(e){return!!(m.isScalarType(e.type)||m.isNonNullType(e.type)&&(m.isScalarType(e.type.ofType)||m.isListType(e.type.ofType)&&(m.isScalarType(e.type.ofType.ofType)||m.isNonNullType(e.type.ofType.ofType)&&m.isScalarType(e.type.ofType.ofType.ofType))))}function Z(e,t){return e?"Scalar":t?"Enum":"Object"}function K(e,t){var a,n,o;if(!t||!t.fields)throw new Error(`Parent entity not found: ${e}`);const i=t.fields.find(r=>r.name===e);return(o=(n=(a=i==null?void 0:i.directives)==null?void 0:a.find(r=>r.name==="label"))==null?void 0:n.args)==null?void 0:o.name}function _(e){if(e&&e.kind==="Enum")return e.enumValues}function U(e,t,i){var p,v;const a=X(e),n=m.isNonNullType(e.type),o=m.getNamedType(e.type).toString(),r=J(e),s=Y(e),u=d.getEntityByName(t,o),f=d.getEntityByName(t,i),c=K(e.name,f),l=_(u);return{name:e.name,isList:a,isNonNull:n,typeName:o,isScalar:s,isEnum:r,kind:Z(s,r),description:e.description,schemaDirectives:u==null?void 0:u.directives,label:c,enumValues:l,collection:(v=(p=u==null?void 0:u.directives)==null?void 0:p.find(Q=>Q.name==="collection"))==null?void 0:v.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(o=>o.fields?{...o,representativeField:o.fields.find(r=>r.name===t.find(s=>{var u;return(u=o.fields)==null?void 0:u.find(f=>f.name===s)})),fields:P(o,t,i+1).fields}:o),a}function x(e,t,i,a){const n=new m.TypeInfo(e);let o=null;const r=[],s=[],u={VariableDefinition:{enter(f){s.push(et(f,i))}},Field:{enter(f){var v,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 p=D(l,f,i,c.name);if(c.toString()===((v=e.getQueryType())==null?void 0:v.name)||c.toString()===((Q=e.getMutationType())==null?void 0:Q.name)){o=p,r.push(p);return}o&&((B=r[r.length-1].fields)==null||B.push(p),!p.isScalar&&!p.isEnum&&r.push(p))},leave(f){r.length>1&&f.selectionSet&&r.pop()}}};if(m.visit(t,m.visitWithTypeInfo(n,u)),!o)throw new Error("Couldn't find query object");return{queryObject:P(o,a),variableDefinitionObjects:s}}function nt(e,t,i,a){const{queryObject:n,variableDefinitionObjects:o}=x(e,t,i,a);if(!n)throw new Error("Query object not generated");return{structure:n,variableDefinitionObjects:o}}function it(e,t,i,a){const{queryObject:n,variableDefinitionObjects:o}=x(e,t,i,a);if(!n)throw new Error("Query object not generated");return{structure:n,variablesStructure:o}}function V(e,t){return it(e.graphqlSchema,g`
${t}
`,e.simplifiedEntities,e.config.nodeRepresentatives)}function M(e,t){return nt(e.graphqlSchema,g`
${t}
`,e.simplifiedEntities,e.config.nodeRepresentatives)}function w(e,t,i,a){var r,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=(r=t.queries)==null?void 0:r.find(u=>u.name==="main"))==null?void 0:s.queryString;if(!n)throw new Error("Can't find gql");const o=g`
${n}
`;return{...t,responseDataPath:{data:`${o.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 r=e.filter(f=>f.kind==="Object").find(f=>{var l;const c=(l=f.directives)==null?void 0:l.find(p=>p.name==="collection");return c?c.args.typeName===i.typeName:!1});if(!r)return;const s=d.generatePath(e,t.typeName,r.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 o=d.generatePath(e,t.typeName,i.typeName,a),r=(n==null?void 0:n.queries)||st();if(o)return{path:o,...n||{},queries:r};if(n!=null&&n.path)return{...n,path:n.path,queries:r}}function ft(){return[]}function ct(e,t,i,a,n){if(!n||!t)return;const o=d.generatePath(e,t.typeName,i.typeName,a),r=o==null?void 0:o.split(".").pop(),s=`${r}Create.${r}`,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 mt(e,t,i,a,n){if(!n||!t)return;const o=d.generatePath(e,t.typeName,i.typeName,a),r=o==null?void 0:o.split(".").pop(),s=`${r}Update.${r}`,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 pt(){return[]}function dt(e,t,i,a,n){if(!n||!t)return;const o=d.generatePath(e,t.typeName,i.typeName,a),r=o==null?void 0:o.split(".").pop(),s=`${r}Delete.${r}`,u=(n==null?void 0:n.queries)||pt();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}.`:"",o=i.find(c=>{var l;return(l=c.directives)==null?void 0:l.find(p=>p.name==="queryRoot")}),r=d.findEntityFromPath(i,o.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,r,e,n,s==null?void 0:s.list),show:ut(i,r,e,n,s==null?void 0:s.show),create:ct(i,r,e,n,s==null?void 0:s.create),update:mt(i,r,e,n,s==null?void 0:s.update),delete:dt(i,r,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 o=n.fields.map(r=>r.typeName);return d.filterEntitiesByDirectiveName(t,"model").filter(r=>o.includes(r.typeName)).map(r=>yt(r,a))}function gt(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 o=n.map(l=>ht(l,t,a,e)).flat(),r=((c=i.resources)==null?void 0:c.map(l=>l.name))||o.map(l=>l.name);return d.sortDataByOrder(o,r,"name")}function vt(e,t){var f,c,l,p,v;const i="main",a="minimum",n=[{name:i,callback:y.createQueryForCreate}],o=[{name:i,callback:y.createQueryForUpdate}],r=[{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,o)}:void 0,delete:(l=t.delete)!=null&&l.path?{...t.delete,queries:N(e,t.delete,r)}:void 0,show:(p=t.show)!=null&&p.path?{...t.show,queries:N(e,t.show,s)}:void 0,list:(v=t.list)!=null&&v.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),o=S(t.show,i),r=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:o?{...t.show,...V(e,o.queryString)}:t.show,list:r?{...t.list,...V(e,r.queryString)}:t.list}}function Nt(e,t){var n,o,r,s,u;const i=(u=(s=(r=(o=(n=e.variablesStructure)==null?void 0:n.find(f=>f.name==="sort"))==null?void 0:o.variable)==null?void 0:r.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:g`
${t.queryString}
`}))}function Et(e){return gt(e).map(t=>vt(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"})});
this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):r||j.set(t,r=new Set),r.add(o),e.has(o)||(e.add(o),i.push(a))}else i.push(a)}),T(T({},n),{definitions:i})}function L(n){var e=new Set(n.definitions);e.forEach(function(a){a.loc&&delete a.loc,Object.keys(a).forEach(function(t){var o=a[t];o&&typeof o=="object"&&e.add(o)})});var i=n.loc;return i&&(delete i.startToken,delete i.endToken),n}function C(n){var e=P(n);if(!F.has(e)){var i=p.parse(n,{experimentalFragmentVariables:S,allowLegacyFragmentVariables:S});if(!i||i.kind!=="Document")throw new Error("Not a valid GraphQL document.");F.set(e,L(W(i)))}return F.get(e)}function g(n){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];typeof n=="string"&&(n=[n]);var a=n[0];return e.forEach(function(t,o){t&&t.kind==="Document"?a+=t.loc.source.body:a+=t,a+=n[o+1]}),C(a)}function A(){F.clear(),j.clear()}function G(){O=!1}function z(){S=!0}function H(){S=!1}var b={gql:g,resetCaches:A,disableFragmentWarnings:G,enableExperimentalFragmentVariables:z,disableExperimentalFragmentVariables:H};(function(n){n.gql=b.gql,n.resetCaches=b.resetCaches,n.disableFragmentWarnings=b.disableFragmentWarnings,n.enableExperimentalFragmentVariables=b.enableExperimentalFragmentVariables,n.disableExperimentalFragmentVariables=b.disableExperimentalFragmentVariables})(g||(g={})),g.default=g;function R(n,e,i,a,t){var s,u,f;if(!n)return;const o=e?(s=m.getField(n,e))==null?void 0:s.fields:n.fields,r=i.find(c=>c.typeName===a.name);return{fields:(o||[]).map(c=>t?t.find(l=>l===c.name)?{...c,isSortable:!0}:{...c}:c),displayColumns:(f=(u=r==null?void 0:r.directives)==null?void 0:u.find(c=>c.name==="model"))==null?void 0:f.args.displayColumns}}function N(n,e,i){const{queries:a}=e,t=i.map(r=>{const s=a.find(u=>u.name===r.name);return s&&s.gql?{name:s.name,queryString:p.print(s.gql)}:s&&s.queryString?{name:s.name,queryString:s.queryString}:{name:r.name,queryString:r.callback(n,e.path)}}),o=a.filter(r=>i.filter(s=>!s.name.includes(r.name))).map(r=>{if(r.gql)return{name:r.name,queryString:p.print(r.gql)};if(r.queryString)return{name:r.name,queryString:r.queryString};throw new Error("query must have gql or queryString")});return[...t,...o]}function Q(n,e){if(n)return n.queries.find(i=>i.name===e)}function J(n){return p.isEnumType(n.type)||p.isNonNullType(n.type)&&p.isEnumType(n.type.ofType)}function X(n){return p.isListType(n.type)||p.isNonNullType(n.type)&&p.isListType(n.type.ofType)}function Y(n){return!!(p.isScalarType(n.type)||p.isNonNullType(n.type)&&(p.isScalarType(n.type.ofType)||p.isListType(n.type.ofType)&&(p.isScalarType(n.type.ofType.ofType)||p.isNonNullType(n.type.ofType.ofType)&&p.isScalarType(n.type.ofType.ofType.ofType))))}function Z(n,e){return n?"Scalar":e?"Enum":"Object"}function K(n,e){var a,t,o;if(!e||!e.fields)throw new Error(`Parent entity not found: ${n}`);const i=e.fields.find(r=>r.name===n);return(o=(t=(a=i==null?void 0:i.directives)==null?void 0:a.find(r=>r.name==="label"))==null?void 0:t.args)==null?void 0:o.name}function _(n){if(n&&n.kind==="Enum")return n.enumValues}function U(n,e){if(n&&(n==null?void 0:n.kind)==="Union")return n.possibleTypes.map(i=>{const a=e.find(t=>t.typeName===i.typeName);if(!a)throw new Error("Object not found");if(a.kind==="Object")return{name:i.name,typeName:i.typeName,kind:i.kind,label:a.description};throw new Error(`Union type can't be object type: ${a.kind}`)})}function D(n,e,i){var v,E;const a=X(n),t=p.isNonNullType(n.type),o=p.getNamedType(n.type).toString(),r=J(n),s=Y(n),u=m.getEntityByName(e,o),f=m.getEntityByName(e,i),c=K(n.name,f),l=_(u),d=U(u,e);return{name:n.name,isList:a,isNonNull:t,typeName:o,isScalar:s,isEnum:r,kind:Z(s,r),description:n.description,schemaDirectives:u==null?void 0:u.directives,label:c,enumValues:l,collection:(E=(v=u==null?void 0:u.directives)==null?void 0:v.find(k=>k.name==="collection"))==null?void 0:E.args,isUnion:(u==null?void 0:u.kind)==="Union",possibleTypes:d}}function ee(n,e,i,a){const t=D(n,i,a);return t.isScalar||t.isEnum?t:{...t,fields:[]}}function ne(n,e){const i=m.getEntityByName(e,n.name.value);if(!i)throw new Error("entity type not found");return i}function $(n,e){switch(n.kind){case"NamedType":return{variable:ne(n,e),isNonNull:!1,isList:!1};case"NonNullType":return{...$(n.type,e),isNonNull:!0};case"ListType":return{...$(n.type,e),isList:!0};default:throw new Error("extractType error")}}function te(n,e){return{...$(n.type,e),name:n.variable.name.value}}function x(n,e,i=0){var t;if(i>=e.length)return n;const a={...n};return a.fields=(t=n.fields)==null?void 0:t.map(o=>o.fields?{...o,representativeField:o.fields.find(r=>r.name===e.find(s=>{var u;return(u=o.fields)==null?void 0:u.find(f=>f.name===s)})),fields:x(o,e,i+1).fields}:o),a}function V(n,e,i,a){const t=new p.TypeInfo(n);let o=null;const r=[],s=[],u={VariableDefinition:{enter(f){s.push(te(f,i))}},Field:{enter(f){var v,E,k;const c=t.getParentType();if(!c)throw new Error("Parent type not found");const l=t.getFieldDef();if(!l)throw new Error("Field definition not found");const d=ee(l,f,i,c.name);if(c.toString()===((v=n.getQueryType())==null?void 0:v.name)||c.toString()===((E=n.getMutationType())==null?void 0:E.name)){o=d,r.push(d);return}o&&((k=r[r.length-1].fields)==null||k.push(d),!d.isScalar&&!d.isEnum&&r.push(d))},leave(f){r.length>1&&f.selectionSet&&r.pop()}}};if(p.visit(e,p.visitWithTypeInfo(t,u)),!o)throw new Error("Couldn't find query object");return{queryObject:x(o,a),variableDefinitionObjects:s}}function ie(n,e,i,a){const{queryObject:t,variableDefinitionObjects:o}=V(n,e,i,a);if(!t)throw new Error("Query object not generated");return{structure:t,variableDefinitionObjects:o}}function ae(n,e,i,a){const{queryObject:t,variableDefinitionObjects:o}=V(n,e,i,a);if(!t)throw new Error("Query object not generated");return{structure:t,variablesStructure:o}}function M(n,e){return ae(n.graphqlSchema,g`
${e}
`,n.simplifiedEntities,n.config.nodeRepresentatives)}function B(n,e){return ie(n.graphqlSchema,g`
${e}
`,n.simplifiedEntities,n.config.nodeRepresentatives)}function w(n,e,i,a){var r,s;if(!e)return;if(a&&i)return{...e,responseDataPath:{data:`${i}.nodes`,total:`${i}.totalCount`}};if(i)return{...e,responseDataPath:{data:`${i}`}};const t=(s=(r=e.queries)==null?void 0:r.find(u=>u.name==="main"))==null?void 0:s.queryString;if(!t)throw new Error("Can't find gql");const o=g`
${t}
`;return{...e,responseDataPath:{data:`${o.definitions[0].name.value}.${m.lowercaseFirstLetter(n)}`}}}function re(n){var e,i;return((i=(e=n==null?void 0:n.find(a=>a.name==="label"))==null?void 0:e.args)==null?void 0:i.name)||void 0}function oe(){return[]}function se(n,e,i,a,t){if(!e)return;const r=n.filter(f=>f.kind==="Object").find(f=>{var l;const c=(l=f.directives)==null?void 0:l.find(d=>d.name==="collection");return c?c.args.typeName===i.typeName:!1});if(!r)return;const s=m.generatePath(n,e.typeName,r.typeName,a),u=(t==null?void 0:t.queries)||oe();if(s)return{path:s,...t||{},queries:u};if(t!=null&&t.path)return{...t,path:t.path,queries:u}}function ue(){return[]}function fe(n,e,i,a,t){if(!e)return;const o=m.generatePath(n,e.typeName,i.typeName,a),r=(t==null?void 0:t.queries)||ue();if(o)return{path:o,...t||{},queries:r};if(t!=null&&t.path)return{...t,path:t.path,queries:r}}function ce(){return[]}function le(n,e,i,a,t){if(!t||!e)return;const o=m.generatePath(n,e.typeName,i.typeName,a),r=o==null?void 0:o.split(".").pop(),s=`${r}Create.${r}`,u=(t==null?void 0:t.queries)||ce();if(s)return{path:s,...t||{},queries:u};if(t!=null&&t.path)return{...t,path:t.path,queries:u}}function pe(){return[]}function me(n,e,i,a,t){if(!t||!e)return;const o=m.generatePath(n,e.typeName,i.typeName,a),r=o==null?void 0:o.split(".").pop(),s=`${r}Update.${r}`,u=(t==null?void 0:t.queries)||pe();if(s)return{path:s,...t||{},queries:u};if(t!=null&&t.path)return{...t,path:t.path,queries:u}}function de(){return[]}function ye(n,e,i,a,t){if(!t||!e)return;const o=m.generatePath(n,e.typeName,i.typeName,a),r=o==null?void 0:o.split(".").pop(),s=`${r}Delete.${r}`,u=(t==null?void 0:t.queries)||de();if(s)return{path:s,...t||{},queries:u};if(t!=null&&t.path)return{...t,path:t.path,queries:u}}function he(n,e){var u,f;const{simplifiedEntities:i,config:a}=e,t=a.adminPath?`${a.adminPath}.`:"",o=i.find(c=>{var l;return(l=c.directives)==null?void 0:l.find(d=>d.name==="queryRoot")}),r=m.findEntityFromPath(i,o.typeName,((u=a.adminPath)==null?void 0:u.split("."))||[]),s=(f=a.resources)==null?void 0:f.find(c=>c.name===n.typeName);return{label:re(n.directives),name:n.typeName,typeName:n.typeName,skipMenu:s==null?void 0:s.skipMenu,list:se(i,r,n,t,s==null?void 0:s.list),show:fe(i,r,n,t,s==null?void 0:s.show),create:le(i,r,n,t,s==null?void 0:s.create),update:me(i,r,n,t,s==null?void 0:s.update),delete:ye(i,r,n,t,s==null?void 0:s.delete)}}function ge(n,e,i,a){const t=n===""?i:m.findEntityFromPath(e,"Query",n.split("."));if(!t)throw new Error("adminEntity not found");const o=t.fields.map(r=>r.typeName);return m.filterEntitiesByDirectiveName(e,"model").filter(r=>o.includes(r.typeName)).map(r=>he(r,a))}function ve(n){var s,u,f,c;const{simplifiedEntities:e,config:i}=n,a=m.findEntityByDirectiveName(e,"queryRoot");if(!a)throw new Error("queryRoot not found");const t=(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(!t)throw new Error("adminPaths not found");const o=t.map(l=>ge(l,e,a,n)).flat(),r=((c=i.resources)==null?void 0:c.map(l=>l.name))||o.map(l=>l.name);return m.sortDataByOrder(o,r,"name")}function be(n,e){var f,c,l,d,v;const i="main",a="minimum",t=[{name:i,callback:y.createQueryForCreate}],o=[{name:i,callback:y.createQueryForUpdate}],r=[{name:i,callback:y.createQueryForDelete}],s=[{name:i,callback:y.createQueryForShow}],u=[{name:i,callback:y.createQueryForList},{name:a,callback:y.createMinimumQueryForList}];return{...e,create:(f=e.create)!=null&&f.path?{...e.create,queries:N(n,e.create,t)}:void 0,update:(c=e.update)!=null&&c.path?{...e.update,queries:N(n,e.update,o)}:void 0,delete:(l=e.delete)!=null&&l.path?{...e.delete,queries:N(n,e.delete,r)}:void 0,show:(d=e.show)!=null&&d.path?{...e.show,queries:N(n,e.show,s)}:void 0,list:(v=e.list)!=null&&v.path?{...e.list,queries:N(n,e.list,u)}:void 0}}function Ne(n,e){const i="main",a=Q(e.create,i),t=Q(e.update,i),o=Q(e.show,i),r=Q(e.list,i);return{...e,create:a?{...e.create,...B(n,a.queryString)}:e.create,update:t?{...e.update,...B(n,t.queryString)}:e.update,show:o?{...e.show,...M(n,o.queryString)}:e.show,list:r?{...e.list,...M(n,r.queryString)}:e.list}}function we(n,e){var t,o,r,s,u;const i=(u=(s=(r=(o=(t=n.variablesStructure)==null?void 0:t.find(f=>f.name==="sort"))==null?void 0:o.variable)==null?void 0:r.inputFields)==null?void 0:s.find(f=>f.name==="field"))==null?void 0:u.typeName,a=e.find(f=>f.typeName===i);return a==null?void 0:a.enumValues.map(f=>f.name)}function qe(n,e){const{simplifiedEntities:i}=n,{show:a,list:t}=e;return{...e,show:a&&{...a,...R(a.structure,a.path,i,e)},list:t&&{...t,...R(t.structure,`${t.path}.nodes`,i,e,we(t,i))}}}function Ee(n,e){var i,a;return{...e,create:w(e.name,e.create),update:w(e.name,e.update),delete:w(e.name,e.delete),show:w(e.name,e.show,(i=e.show)==null?void 0:i.path),list:w(e.name,e.list,(a=e.list)==null?void 0:a.path,!0)}}function q(n){return n.map(e=>({name:e.name,gql:g`
${e.queryString}
`}))}function Te(n){return ve(n).map(e=>be(n,e)).map(e=>Ne(n,e)).map(e=>qe(n,e)).map(e=>Ee(n,e)).map(e=>({...e,create:e.create?{...e.create,queries:q(e.create.queries)}:void 0,delete:e.delete?{...e.delete,queries:q(e.delete.queries)}:void 0,update:e.update?{...e.update,queries:q(e.update.queries)}:void 0,show:e.show?{...e.show,queries:q(e.show.queries)}:void 0,list:e.list?{...e.list,queries:q(e.list.queries)}:void 0}))}h.convert=Te,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
//# sourceMappingURL=index.umd.js.map

@@ -29,3 +29,3 @@ import type { DocumentNode } from 'graphql';

fields: Array<SimplifiedField>;
possibleTypes: Array<SimplifiedEntityTypeRef>;
possibleTypes: Array<SimplifiedPossibleType>;
} & TypeNameAndDescriptionAndDirective;

@@ -61,9 +61,7 @@ export type UnionSimplifiedEntityType = {

};
type SimplifiedPossibleType = {
export type SimplifiedPossibleType = {
kind: string;
name: string;
typeName: string;
};
type SimplifiedEntityTypeRef = {
kind: string;
ofType?: SimplifiedEntityTypeRef;
};
export type SimplifiedEntityType = ScalarSimplifiedEntityType | ObjectSimplifiedEntityType | InterfaceSimplifiedEntityType | UnionSimplifiedEntityType | EnumSimplifiedEntityType | InputObjectSimplifiedEntityType;

@@ -74,35 +72,41 @@ type RawQuery = {

};
type Field = {
export type VariableDefinitionObject = {
name: string;
label: string;
isList: boolean;
isNonNull: boolean;
variable: ScalarSimplifiedEntityType | InputObjectSimplifiedEntityType | EnumSimplifiedEntityType;
};
type FieldCommon = {
name: string;
typeName: string;
isScalar: boolean;
isEnum: boolean;
isSortable: boolean;
isList: boolean;
};
type ResourceActionField = FieldCommon & {
label: string;
possibleTypes: Array<{
name: string;
typeName: string;
label: string;
}> | undefined;
collection: {
totalPath: string;
};
isList: boolean;
isSortable: boolean;
representativeField?: FieldObject | undefined;
};
export type VariableDefinitionObject = {
name: string;
isList: boolean;
isNonNull: boolean;
variable: ScalarSimplifiedEntityType | InputObjectSimplifiedEntityType | EnumSimplifiedEntityType;
};
export type FieldObject = {
name: string;
typeName: string;
export type FieldObject = FieldCommon & {
label: string | undefined;
possibleTypes: Array<{
name: string;
typeName: string;
}> | undefined;
collection: any;
description: string | undefined;
kind: 'Scalar' | 'Object' | 'Enum';
isList: boolean;
isNonNull: boolean;
isScalar: boolean;
enumValues: any;
label: string | undefined;
isEnum: boolean;
fields?: FieldObject[];
schemaDirectives?: DirectiveInfo[];
collection: any;
isUnion: boolean;

@@ -121,3 +125,3 @@ };

};
fields: Array<Field>;
fields: Array<ResourceActionField>;
variableDefinitionObjects: VariableDefinitionObject[];

@@ -131,3 +135,3 @@ structure: FieldObject;

};
fields: Array<Field>;
fields: Array<ResourceActionField>;
variableDefinitionObjects: VariableDefinitionObject[];

@@ -142,3 +146,3 @@ structure: FieldObject;

};
fields: Array<Field>;
fields: Array<ResourceActionField>;
variablesStructure?: VariableDefinitionObject[];

@@ -154,3 +158,3 @@ structure: FieldObject;

};
fields: Array<Field>;
fields: Array<ResourceActionField>;
variablesStructure?: VariableDefinitionObject[];

@@ -157,0 +161,0 @@ structure: FieldObject;

{
"name": "@theconcurrent/resource",
"version": "0.0.24",
"version": "0.0.25",
"main": "./dist/index.umd.js",

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

"dependencies": {
"@theconcurrent/query": "0.0.24",
"@theconcurrent/simplified-entity": "0.0.24",
"@theconcurrent/utility": "0.0.24",
"@theconcurrent/query": "0.0.25",
"@theconcurrent/simplified-entity": "0.0.25",
"@theconcurrent/utility": "0.0.25",
"graphql": "16.0.1"
},
"peerDependencies": {
"@theconcurrent/query": "0.0.24",
"@theconcurrent/simplified-entity": "0.0.24",
"@theconcurrent/utility": "0.0.24",
"@theconcurrent/query": "0.0.25",
"@theconcurrent/simplified-entity": "0.0.25",
"@theconcurrent/utility": "0.0.25",
"graphql": "16.0.1"
},
"gitHead": "b168c3ab44d2a756eb743804d13192ecd1e869d1"
"gitHead": "ee18af36373b818c8918ddb36c5bcf81cb61df16"
}

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