@theconcurrent/simplified-entity
Advanced tools
Comparing version
@@ -5,5 +5,5 @@ (function(c,n){typeof exports=="object"&&typeof module!="undefined"?n(exports,require("graphql")):typeof define=="function"&&define.amd?define(["exports","graphql"],n):(c=typeof globalThis!="undefined"?globalThis:c||self,n(c["@theconcurrent/simplified-entity"]={},c.graphql))})(this,function(c,n){"use strict";const y="Collection";function E(e,i){var d;const{config:{collection:{typeNameSuffix:a},resources:t,autoAddResources:u}}=i,o=a||y,r=e.name.value;return!t||u?r.endsWith(o)?r.replace(o,""):void 0:(d=t.find(s=>`${s.name}${o}`===r?!0:s.schemeResourceName?`${s.schemeResourceName}${o}`===r:!1))==null?void 0:d.name}const G=` | ||
directive @label(name: String!) on FIELD_DEFINITION | OBJECT | INPUT_FIELD_DEFINITION | ARGUMENT_DEFINITION | SCALAR | ||
`,I=n.parse(b).definitions[0];function m(e){var i,a;if((i=e.description)!=null&&i.value)return{kind:n.Kind.DIRECTIVE,name:{kind:n.Kind.NAME,value:I.name.value},arguments:[{kind:n.Kind.ARGUMENT,name:{kind:n.Kind.NAME,value:"name"},value:{kind:n.Kind.STRING,value:((a=e.description)==null?void 0:a.value)||""}}]}}function O(e,i){var o,r,d;const{resources:a}=i.config,t=a==null?void 0:a.find(s=>s.name===e.name.value);if(!t)return;const u=((o=t.list)==null?void 0:o.displayColumns)||((d=(r=t.list)==null?void 0:r.fields)==null?void 0:d.map(s=>s.name))||[];if(u.length!==0)return(u==null?void 0:u.map(s=>({kind:n.Kind.STRING,value:s})))||[]}const Q=` | ||
`,I=n.parse(b).definitions[0];function m(e){var i,a;if((i=e.description)!=null&&i.value)return{kind:n.Kind.DIRECTIVE,name:{kind:n.Kind.NAME,value:I.name.value},arguments:[{kind:n.Kind.ARGUMENT,name:{kind:n.Kind.NAME,value:"name"},value:{kind:n.Kind.STRING,value:((a=e.description)==null?void 0:a.value)||""}}]}}function O(e,i){var o,r,d;const{resources:a}=i.config,t=a==null?void 0:a.find(s=>s.name===e.name.value);if(!t)return;const u=((o=t.list)==null?void 0:o.displayColumns)||((d=(r=t.list)==null?void 0:r.fields)==null?void 0:d.map(s=>s.name))||[];if(u.length!==0)return(u==null?void 0:u.map(s=>({kind:n.Kind.STRING,value:s})))||[]}const j=` | ||
directive @model(name: String!, representative: String!, displayColumns: [String]) on OBJECT | ||
`,p=n.parse(Q).definitions[0];function j(e,i){var d;const{config:{resources:a,autoAddResources:t}}=i,u=E(e,i),o=e.name.value;if(!a)return o==="Mutation"||o==="Query"||o.endsWith("Payload")||u?void 0:o;const r=(d=a==null?void 0:a.find(s=>s.name===o||s.schemeResourceName===o))==null?void 0:d.name;if(r)return r;if(t)return o==="Mutation"||o==="Query"||o.endsWith("Payload")||u?void 0:o}function C(e,i){var u,o;const a=(u=e.fields)==null?void 0:u.map(r=>r.name.value);return((o=i.config.nodeRepresentatives)==null?void 0:o.find(r=>a==null?void 0:a.includes(r)))||a[0]}function V(e,i){const a=j(e,i),t=C(e,i),u=O(e,i);if(a)return{kind:n.Kind.DIRECTIVE,name:{kind:n.Kind.NAME,value:p.name.value},arguments:[{kind:n.Kind.ARGUMENT,name:{kind:n.Kind.NAME,value:"name"},value:{kind:n.Kind.STRING,value:a}},{kind:n.Kind.ARGUMENT,name:{kind:n.Kind.NAME,value:"representative"},value:{kind:n.Kind.STRING,value:t}},...u?[{kind:n.Kind.ARGUMENT,name:{kind:n.Kind.NAME,value:"displayColumns"},value:{kind:n.Kind.LIST,values:u}}]:[]]}}const F=` | ||
`,p=n.parse(j).definitions[0];function Q(e,i){var d;const{config:{resources:a,autoAddResources:t}}=i,u=E(e,i),o=e.name.value;if(!a)return o==="Mutation"||o==="Query"||o.endsWith("Payload")||u?void 0:o;const r=(d=a==null?void 0:a.find(s=>s.name===o||s.schemeResourceName===o))==null?void 0:d.name;if(r)return r;if(t)return o==="Mutation"||o==="Query"||o.endsWith("Payload")||u?void 0:o}function C(e,i){var u,o;const a=(u=e.fields)==null?void 0:u.map(r=>r.name.value);return((o=i.config.nodeRepresentatives)==null?void 0:o.find(r=>a==null?void 0:a.includes(r)))||a[0]}function V(e,i){const a=Q(e,i),t=C(e,i),u=O(e,i);if(a)return{kind:n.Kind.DIRECTIVE,name:{kind:n.Kind.NAME,value:p.name.value},arguments:[{kind:n.Kind.ARGUMENT,name:{kind:n.Kind.NAME,value:"name"},value:{kind:n.Kind.STRING,value:a}},{kind:n.Kind.ARGUMENT,name:{kind:n.Kind.NAME,value:"representative"},value:{kind:n.Kind.STRING,value:t}},...u?[{kind:n.Kind.ARGUMENT,name:{kind:n.Kind.NAME,value:"displayColumns"},value:{kind:n.Kind.LIST,values:u}}]:[]]}}const F=` | ||
directive @queryRoot(adminPaths: [String]!) on OBJECT | ||
@@ -10,0 +10,0 @@ `,T=n.parse(F).definitions[0];function P(e,i){var t;const a=(t=i.graphqlSchema.getQueryType())==null?void 0:t.name;if(e.name.value===a){const u=[i.config.adminPath||""];return{kind:n.Kind.DIRECTIVE,name:{kind:n.Kind.NAME,value:T.name.value},arguments:[{kind:n.Kind.ARGUMENT,name:{kind:n.Kind.NAME,value:"adminPaths"},value:{kind:n.Kind.LIST,values:u.map(o=>({kind:n.Kind.STRING,value:o}))}}]}}}const U=` |
@@ -1,5 +0,5 @@ | ||
import { DocumentNode } from 'graphql'; | ||
import inject from './inject'; | ||
import type { Params } from './type'; | ||
export type { Params }; | ||
export default function main<T extends Params>(astSchema: DocumentNode, params: T): DocumentNode; | ||
export default inject; | ||
//# sourceMappingURL=index.d.ts.map |
import { parse as l, Kind as a, visit as V, GraphQLScalarType as p, GraphQLObjectType as S, GraphQLInterfaceType as E, GraphQLUnionType as h, GraphQLEnumType as k, GraphQLInputObjectType as I, GraphQLNonNull as j, GraphQLList as P, buildSchema as U, buildASTSchema as F, printSchema as Q, print as B } from "graphql"; | ||
const g = "Collection"; | ||
function A(e, n) { | ||
var c; | ||
var s; | ||
const { | ||
@@ -12,3 +12,3 @@ config: { | ||
} = n, u = t || g, o = e.name.value; | ||
return !i || r ? o.endsWith(u) ? o.replace(u, "") : void 0 : (c = i.find((s) => `${s.name}${u}` === o ? !0 : s.schemeResourceName ? `${s.schemeResourceName}${u}` === o : !1)) == null ? void 0 : c.name; | ||
return !i || r ? o.endsWith(u) ? o.replace(u, "") : void 0 : (s = i.find((c) => `${c.name}${u}` === o ? !0 : c.schemeResourceName ? `${c.schemeResourceName}${u}` === o : !1)) == null ? void 0 : s.name; | ||
} | ||
@@ -66,4 +66,4 @@ const $ = ` | ||
function J(e, n) { | ||
var u, o, c; | ||
const { resources: t } = n.config, i = t == null ? void 0 : t.find((s) => s.name === e.name.value); | ||
var u, o, s; | ||
const { resources: t } = n.config, i = t == null ? void 0 : t.find((c) => c.name === e.name.value); | ||
if (!i) | ||
@@ -74,8 +74,8 @@ return; | ||
// eslint-disable-next-line | ||
((u = i.list) == null ? void 0 : u.displayColumns) || ((c = (o = i.list) == null ? void 0 : o.fields) == null ? void 0 : c.map((s) => s.name)) || [] | ||
((u = i.list) == null ? void 0 : u.displayColumns) || ((s = (o = i.list) == null ? void 0 : o.fields) == null ? void 0 : s.map((c) => c.name)) || [] | ||
); | ||
if (r.length !== 0) | ||
return (r == null ? void 0 : r.map((s) => ({ | ||
return (r == null ? void 0 : r.map((c) => ({ | ||
kind: a.STRING, | ||
value: s | ||
value: c | ||
}))) || []; | ||
@@ -87,3 +87,3 @@ } | ||
function W(e, n) { | ||
var c; | ||
var s; | ||
const { | ||
@@ -94,5 +94,5 @@ config: { resources: t, autoAddResources: i } | ||
return u === "Mutation" || u === "Query" || u.endsWith("Payload") || r ? void 0 : u; | ||
const o = (c = t == null ? void 0 : t.find( | ||
(s) => s.name === u || s.schemeResourceName === u | ||
)) == null ? void 0 : c.name; | ||
const o = (s = t == null ? void 0 : t.find( | ||
(c) => c.name === u || c.schemeResourceName === u | ||
)) == null ? void 0 : s.name; | ||
if (o) | ||
@@ -405,3 +405,3 @@ return o; | ||
} | ||
function se(e) { | ||
function ce(e) { | ||
const n = F(e); | ||
@@ -413,3 +413,3 @@ return Object.values(n.getTypeMap()).map(oe).filter((t) => !!t); | ||
return { | ||
simplifiedEntities: se(n), | ||
simplifiedEntities: ce(n), | ||
graphqlSchema: e.graphqlSchema, | ||
@@ -416,0 +416,0 @@ injectedSchemaSDL: B(n) |
@@ -5,5 +5,5 @@ (function(c,n){typeof exports=="object"&&typeof module!="undefined"?n(exports,require("graphql")):typeof define=="function"&&define.amd?define(["exports","graphql"],n):(c=typeof globalThis!="undefined"?globalThis:c||self,n(c["@theconcurrent/simplified-entity"]={},c.graphql))})(this,function(c,n){"use strict";const y="Collection";function E(e,i){var d;const{config:{collection:{typeNameSuffix:a},resources:t,autoAddResources:u}}=i,o=a||y,r=e.name.value;return!t||u?r.endsWith(o)?r.replace(o,""):void 0:(d=t.find(s=>`${s.name}${o}`===r?!0:s.schemeResourceName?`${s.schemeResourceName}${o}`===r:!1))==null?void 0:d.name}const G=` | ||
directive @label(name: String!) on FIELD_DEFINITION | OBJECT | INPUT_FIELD_DEFINITION | ARGUMENT_DEFINITION | SCALAR | ||
`,I=n.parse(b).definitions[0];function m(e){var i,a;if((i=e.description)!=null&&i.value)return{kind:n.Kind.DIRECTIVE,name:{kind:n.Kind.NAME,value:I.name.value},arguments:[{kind:n.Kind.ARGUMENT,name:{kind:n.Kind.NAME,value:"name"},value:{kind:n.Kind.STRING,value:((a=e.description)==null?void 0:a.value)||""}}]}}function O(e,i){var o,r,d;const{resources:a}=i.config,t=a==null?void 0:a.find(s=>s.name===e.name.value);if(!t)return;const u=((o=t.list)==null?void 0:o.displayColumns)||((d=(r=t.list)==null?void 0:r.fields)==null?void 0:d.map(s=>s.name))||[];if(u.length!==0)return(u==null?void 0:u.map(s=>({kind:n.Kind.STRING,value:s})))||[]}const Q=` | ||
`,I=n.parse(b).definitions[0];function m(e){var i,a;if((i=e.description)!=null&&i.value)return{kind:n.Kind.DIRECTIVE,name:{kind:n.Kind.NAME,value:I.name.value},arguments:[{kind:n.Kind.ARGUMENT,name:{kind:n.Kind.NAME,value:"name"},value:{kind:n.Kind.STRING,value:((a=e.description)==null?void 0:a.value)||""}}]}}function O(e,i){var o,r,d;const{resources:a}=i.config,t=a==null?void 0:a.find(s=>s.name===e.name.value);if(!t)return;const u=((o=t.list)==null?void 0:o.displayColumns)||((d=(r=t.list)==null?void 0:r.fields)==null?void 0:d.map(s=>s.name))||[];if(u.length!==0)return(u==null?void 0:u.map(s=>({kind:n.Kind.STRING,value:s})))||[]}const j=` | ||
directive @model(name: String!, representative: String!, displayColumns: [String]) on OBJECT | ||
`,p=n.parse(Q).definitions[0];function j(e,i){var d;const{config:{resources:a,autoAddResources:t}}=i,u=E(e,i),o=e.name.value;if(!a)return o==="Mutation"||o==="Query"||o.endsWith("Payload")||u?void 0:o;const r=(d=a==null?void 0:a.find(s=>s.name===o||s.schemeResourceName===o))==null?void 0:d.name;if(r)return r;if(t)return o==="Mutation"||o==="Query"||o.endsWith("Payload")||u?void 0:o}function C(e,i){var u,o;const a=(u=e.fields)==null?void 0:u.map(r=>r.name.value);return((o=i.config.nodeRepresentatives)==null?void 0:o.find(r=>a==null?void 0:a.includes(r)))||a[0]}function V(e,i){const a=j(e,i),t=C(e,i),u=O(e,i);if(a)return{kind:n.Kind.DIRECTIVE,name:{kind:n.Kind.NAME,value:p.name.value},arguments:[{kind:n.Kind.ARGUMENT,name:{kind:n.Kind.NAME,value:"name"},value:{kind:n.Kind.STRING,value:a}},{kind:n.Kind.ARGUMENT,name:{kind:n.Kind.NAME,value:"representative"},value:{kind:n.Kind.STRING,value:t}},...u?[{kind:n.Kind.ARGUMENT,name:{kind:n.Kind.NAME,value:"displayColumns"},value:{kind:n.Kind.LIST,values:u}}]:[]]}}const F=` | ||
`,p=n.parse(j).definitions[0];function Q(e,i){var d;const{config:{resources:a,autoAddResources:t}}=i,u=E(e,i),o=e.name.value;if(!a)return o==="Mutation"||o==="Query"||o.endsWith("Payload")||u?void 0:o;const r=(d=a==null?void 0:a.find(s=>s.name===o||s.schemeResourceName===o))==null?void 0:d.name;if(r)return r;if(t)return o==="Mutation"||o==="Query"||o.endsWith("Payload")||u?void 0:o}function C(e,i){var u,o;const a=(u=e.fields)==null?void 0:u.map(r=>r.name.value);return((o=i.config.nodeRepresentatives)==null?void 0:o.find(r=>a==null?void 0:a.includes(r)))||a[0]}function V(e,i){const a=Q(e,i),t=C(e,i),u=O(e,i);if(a)return{kind:n.Kind.DIRECTIVE,name:{kind:n.Kind.NAME,value:p.name.value},arguments:[{kind:n.Kind.ARGUMENT,name:{kind:n.Kind.NAME,value:"name"},value:{kind:n.Kind.STRING,value:a}},{kind:n.Kind.ARGUMENT,name:{kind:n.Kind.NAME,value:"representative"},value:{kind:n.Kind.STRING,value:t}},...u?[{kind:n.Kind.ARGUMENT,name:{kind:n.Kind.NAME,value:"displayColumns"},value:{kind:n.Kind.LIST,values:u}}]:[]]}}const F=` | ||
directive @queryRoot(adminPaths: [String]!) on OBJECT | ||
@@ -10,0 +10,0 @@ `,T=n.parse(F).definitions[0];function P(e,i){var t;const a=(t=i.graphqlSchema.getQueryType())==null?void 0:t.name;if(e.name.value===a){const u=[i.config.adminPath||""];return{kind:n.Kind.DIRECTIVE,name:{kind:n.Kind.NAME,value:T.name.value},arguments:[{kind:n.Kind.ARGUMENT,name:{kind:n.Kind.NAME,value:"adminPaths"},value:{kind:n.Kind.LIST,values:u.map(o=>({kind:n.Kind.STRING,value:o}))}}]}}}const U=` |
@@ -111,3 +111,3 @@ import type { DocumentNode } from 'graphql'; | ||
}; | ||
type Relation = { | ||
export type Relation = { | ||
name: string; | ||
@@ -119,2 +119,5 @@ label: string; | ||
isCollection: boolean; | ||
filter?: { | ||
[k: string]: any; | ||
}; | ||
}; | ||
@@ -162,2 +165,3 @@ export type FinalResource = { | ||
path: string; | ||
removingTabs?: string[]; | ||
}; | ||
@@ -164,0 +168,0 @@ delete?: { |
{ | ||
"name": "@theconcurrent/simplified-entity", | ||
"version": "0.0.28", | ||
"version": "0.0.29", | ||
"main": "./dist/index.umd.js", | ||
@@ -32,3 +32,3 @@ "module": "./dist/index.es.js", | ||
}, | ||
"gitHead": "8bba0da91e098154ee722a9bef4132caecd8fbdd" | ||
"gitHead": "20a0ac17e76087beeab1c2808f709a412b4060e6" | ||
} |
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
119378
0.51%40
5.26%795
1.02%