@flexkit/studio 0.2.20 → 0.2.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/activity-nav-button-7RLCHOFV.js +2 -0
- package/dist/{activity-nav-button-V5DFHADL.js.map → activity-nav-button-7RLCHOFV.js.map} +1 -1
- package/dist/astro.js +1 -1
- package/dist/chat-page-WLKJ3QNZ.js +4 -0
- package/dist/chat-page-WLKJ3QNZ.js.map +1 -0
- package/dist/{chunk-D5WYD5M4.js → chunk-4LVMCUHR.js} +2 -2
- package/dist/{chunk-D5WYD5M4.js.map → chunk-4LVMCUHR.js.map} +1 -1
- package/dist/{chunk-ME55YNBF.js → chunk-4PUMSUJL.js} +2 -2
- package/dist/{chunk-ME55YNBF.js.map → chunk-4PUMSUJL.js.map} +1 -1
- package/dist/{chunk-B7QMGBK5.js → chunk-6AI7322C.js} +3 -3
- package/dist/{chunk-B7QMGBK5.js.map → chunk-6AI7322C.js.map} +1 -1
- package/dist/{chunk-BMX4URYN.js → chunk-7ERLYAPR.js} +2 -2
- package/dist/{chunk-BMX4URYN.js.map → chunk-7ERLYAPR.js.map} +1 -1
- package/dist/chunk-7KLXWCDS.js +3 -0
- package/dist/chunk-7KLXWCDS.js.map +1 -0
- package/dist/chunk-BM7INZL3.js +3 -0
- package/dist/chunk-BM7INZL3.js.map +1 -0
- package/dist/chunk-ELOJGLAR.js +2 -0
- package/dist/chunk-ELOJGLAR.js.map +1 -0
- package/dist/{chunk-GFAOY74A.js → chunk-GGC75EMC.js} +2 -0
- package/dist/{chunk-HLHLBMLJ.js → chunk-HBTMGDOM.js} +2 -2
- package/dist/{chunk-HLHLBMLJ.js.map → chunk-HBTMGDOM.js.map} +1 -1
- package/dist/{chunk-MKK65RQB.js → chunk-HGXYSP47.js} +5 -5
- package/dist/{chunk-MKK65RQB.js.map → chunk-HGXYSP47.js.map} +1 -1
- package/dist/chunk-HKN6BX5U.js +2 -0
- package/dist/chunk-HKN6BX5U.js.map +1 -0
- package/dist/chunk-JIB4PRLH.js +3 -0
- package/dist/chunk-JIB4PRLH.js.map +1 -0
- package/dist/{chunk-2P2QV3K6.js → chunk-K2KW6UYG.js} +2 -2
- package/dist/{chunk-2P2QV3K6.js.map → chunk-K2KW6UYG.js.map} +1 -1
- package/dist/{chunk-ZZRA4567.js → chunk-LIMXKPEK.js} +2 -2
- package/dist/{chunk-ZZRA4567.js.map → chunk-LIMXKPEK.js.map} +1 -1
- package/dist/chunk-MHVZXDVL.js +2 -0
- package/dist/{chunk-BXN72PW2.js.map → chunk-MHVZXDVL.js.map} +1 -1
- package/dist/chunk-MLHXPTBT.js +2 -0
- package/dist/chunk-MLHXPTBT.js.map +1 -0
- package/dist/{chunk-UOR437J2.js → chunk-QCVQJN5O.js} +2 -2
- package/dist/{chunk-UOR437J2.js.map → chunk-QCVQJN5O.js.map} +1 -1
- package/dist/{chunk-F2DT6NRK.js → chunk-QTFFVG7C.js} +2 -2
- package/dist/{chunk-F2DT6NRK.js.map → chunk-QTFFVG7C.js.map} +1 -1
- package/dist/chunk-RPLKJVDQ.js +7 -0
- package/dist/{chunk-NYSQU73M.js.map → chunk-RPLKJVDQ.js.map} +1 -1
- package/dist/{chunk-RY6PECIT.js → chunk-SE4HJCGA.js} +2 -2
- package/dist/{chunk-RY6PECIT.js.map → chunk-SE4HJCGA.js.map} +1 -1
- package/dist/{chunk-DHVKE36X.js → chunk-SY67F62K.js} +3 -3
- package/dist/{chunk-DHVKE36X.js.map → chunk-SY67F62K.js.map} +1 -1
- package/dist/chunk-UCHWUGRT.js +378 -0
- package/dist/chunk-UCHWUGRT.js.map +1 -0
- package/dist/{chunk-JWBER5NX.js → chunk-UJEDL3IZ.js} +2 -2
- package/dist/{chunk-JWBER5NX.js.map → chunk-UJEDL3IZ.js.map} +1 -1
- package/dist/chunk-YXUEPR7K.js +4 -0
- package/dist/{chunk-LK67JOQA.js.map → chunk-YXUEPR7K.js.map} +1 -1
- package/dist/electron.js +1 -1
- package/dist/{entry-XVLXKEQV.js → entry-GWZ7DELK.js} +2 -2
- package/dist/{entry-XVLXKEQV.js.map → entry-GWZ7DELK.js.map} +1 -1
- package/dist/index.css +21 -0
- package/dist/index.js +10 -8
- package/dist/index.js.map +1 -1
- package/dist/list-FQZII7QD.js +3 -0
- package/dist/{list-4OJMI4CB.js.map → list-FQZII7QD.js.map} +1 -1
- package/dist/list-LMIKCT2W.js +2 -0
- package/dist/{list-RABV2F3H.js.map → list-LMIKCT2W.js.map} +1 -1
- package/dist/nextjs.js +1 -1
- package/dist/{pages-7LWBCW2X.js → pages-NKE7FV34.js} +3 -3
- package/dist/{pages-7LWBCW2X.js.map → pages-NKE7FV34.js.map} +1 -1
- package/dist/plugin-pages-4HTADSK3.js +2 -0
- package/dist/{plugin-pages-PQWTH7P5.js.map → plugin-pages-4HTADSK3.js.map} +1 -1
- package/dist/record-links-FDWV4X5W.js +2 -0
- package/dist/{record-links-BFHPBOAL.js.map → record-links-FDWV4X5W.js.map} +1 -1
- package/dist/{root-COI626G2.js → root-GYJGAS22.js} +2 -2
- package/dist/{root-COI626G2.js.map → root-GYJGAS22.js.map} +1 -1
- package/dist/root-OSXC52GL.js +2 -0
- package/dist/{root-PDSTTPHO.js.map → root-OSXC52GL.js.map} +1 -1
- package/dist/root-VL4EM2IS.js +23 -0
- package/dist/{root-FTT4XDCE.js.map → root-VL4EM2IS.js.map} +1 -1
- package/dist/{root-RXMRNU4M.js → root-X3V4NC2D.js} +2 -2
- package/dist/{root-RXMRNU4M.js.map → root-X3V4NC2D.js.map} +1 -1
- package/dist/root-YDHREGTF.js +14 -0
- package/dist/root-YDHREGTF.js.map +1 -0
- package/dist/{root-BS6QCYLO.js → root-ZYUSZZWR.js} +3 -3
- package/dist/{root-BS6QCYLO.js.map → root-ZYUSZZWR.js.map} +1 -1
- package/dist/{search-VPS2UHPQ.js → search-UW7WE2CS.js} +2 -2
- package/dist/{search-VPS2UHPQ.js.map → search-UW7WE2CS.js.map} +1 -1
- package/dist/skills-pages-Q4YSUQVZ.js +2 -0
- package/dist/skills-pages-Q4YSUQVZ.js.map +1 -0
- package/dist/source-PGSWL4DQ.js +2 -0
- package/dist/{source-MNHZQD4T.js.map → source-PGSWL4DQ.js.map} +1 -1
- package/dist/tanstack-start.js +1 -1
- package/dist/{user-nav-36ACWXOW.js → user-nav-B37OEVQN.js} +2 -2
- package/dist/{user-nav-36ACWXOW.js.map → user-nav-B37OEVQN.js.map} +1 -1
- package/package.json +9 -6
- package/dist/activity-nav-button-V5DFHADL.js +0 -2
- package/dist/chat-page-4G4XQ26P.js +0 -4
- package/dist/chat-page-4G4XQ26P.js.map +0 -1
- package/dist/chunk-2HYQVMP3.js +0 -3
- package/dist/chunk-2HYQVMP3.js.map +0 -1
- package/dist/chunk-445XKMAG.js +0 -379
- package/dist/chunk-445XKMAG.js.map +0 -1
- package/dist/chunk-A7XHA2P6.js +0 -3
- package/dist/chunk-A7XHA2P6.js.map +0 -1
- package/dist/chunk-BMO7JFAX.js +0 -2
- package/dist/chunk-BMO7JFAX.js.map +0 -1
- package/dist/chunk-BXN72PW2.js +0 -2
- package/dist/chunk-LK67JOQA.js +0 -4
- package/dist/chunk-NYSQU73M.js +0 -7
- package/dist/list-4OJMI4CB.js +0 -3
- package/dist/list-RABV2F3H.js +0 -2
- package/dist/plugin-pages-PQWTH7P5.js +0 -2
- package/dist/record-links-BFHPBOAL.js +0 -2
- package/dist/root-FTT4XDCE.js +0 -23
- package/dist/root-PDSTTPHO.js +0 -2
- package/dist/root-TZYOIXVG.js +0 -2
- package/dist/root-TZYOIXVG.js.map +0 -1
- package/dist/skills-pages-G6JK7KKQ.js +0 -2
- package/dist/skills-pages-G6JK7KKQ.js.map +0 -1
- package/dist/source-MNHZQD4T.js +0 -2
package/dist/chunk-445XKMAG.js
DELETED
|
@@ -1,379 +0,0 @@
|
|
|
1
|
-
import'./index.css';import {a}from'./chunk-YDVO6XWD.js';import {a as a$1}from'./chunk-ERDARDGB.js';import {b,f,c}from'./chunk-B7QMGBK5.js';import {find,propEq,omit,pick,toPairs,uniq,uniqBy,prop}from'ramda';import {gql,NetworkStatus,ApolloClient,InMemoryCache,defaultDataIdFromObject,from,HttpLink}from'@apollo/client';import {ApolloProvider,useQuery}from'@apollo/client/react';import {ErrorLink}from'@apollo/client/link/error';import {ServerError,CombinedGraphQLErrors,CombinedProtocolErrors}from'@apollo/client/errors';import {createContext,useContext,useState,useMemo,useRef,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var Wt=25,Ln=3,Pt=3,wn=["id","string"],Cn=["date","datetime","duration","time"],St=`_id
|
|
2
|
-
originalFilename
|
|
3
|
-
mimeType
|
|
4
|
-
path
|
|
5
|
-
url
|
|
6
|
-
size
|
|
7
|
-
height
|
|
8
|
-
width
|
|
9
|
-
lqip`,Rt=`_id
|
|
10
|
-
originalFilename
|
|
11
|
-
mimeType
|
|
12
|
-
path
|
|
13
|
-
url
|
|
14
|
-
size
|
|
15
|
-
height
|
|
16
|
-
width`,In=`_id
|
|
17
|
-
path
|
|
18
|
-
url`;function Y(t){return t?a(t)==="relationship"&&t.relationship?.mode==="multiple"&&t.relationship.entity==="_asset":false}function _t(t,n){return !t||!Y(t)?false:n?.name!==c.name||t.name!=="assets"}function ft(t){return t?.dataType==="asset"||t?.inputType==="asset"}function zt(t){let n=t,e=n?.edges??[],r=n?.aggregate?.count?.nodes??e.length;return e.reduce((i,s,o)=>(s.node&&i.push({...s.node,sortOrder:s.properties?.sortOrder??o,totalCount:r}),i),[]).sort((i,s)=>(i.sortOrder??Number.MAX_SAFE_INTEGER)-(s.sortOrder??Number.MAX_SAFE_INTEGER))}function Mn(t){return t.reduce((n,e,r)=>e._id?{...n,[e._id]:e.sortOrder??r}:n,{})}function U(t){return Array.isArray(t)?t[0]??null:t??null}function Qn(t,n){return n?In:t?St:Rt}function Jt(t,n=true,e=true,r=Wt,i=false){let s=n?` properties {
|
|
19
|
-
sortOrder
|
|
20
|
-
}
|
|
21
|
-
`:"",o=Qn(e,i),a=n?`(first: ${r}, sort: [{ edge: { sortOrder: ASC } }])`:`(first: ${r})`;return ` ${t}Connection${a} {
|
|
22
|
-
aggregate {
|
|
23
|
-
count {
|
|
24
|
-
nodes
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
edges {
|
|
28
|
-
`+s+` node {
|
|
29
|
-
${o}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
`}function Nt(t){return t?.aggregate?.count?.nodes??0}function Kt(t,n){let e=t[`${n}Total`];return typeof e=="number"?e:Nt(t[`${n}Connection`])}function Lt(t,n=""){return ` ${t}Connection${n} {
|
|
34
|
-
aggregate {
|
|
35
|
-
count {
|
|
36
|
-
nodes
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
`}function On(t,n,e){return n?e==="total"?` ${t}Total
|
|
41
|
-
`:Lt(t,"(where: $where)"):""}function kn(t,n,e,r=false){if(!t)return "";let i=n==="default"?"":`${n}
|
|
42
|
-
`;if(ft(t))return r?` ${t.name} {
|
|
43
|
-
_id
|
|
44
|
-
path
|
|
45
|
-
url
|
|
46
|
-
}
|
|
47
|
-
`:` ${t.name} {
|
|
48
|
-
${St}
|
|
49
|
-
}
|
|
50
|
-
`;if(a(t)==="local")return ` ${t.name} {
|
|
51
|
-
_id
|
|
52
|
-
default
|
|
53
|
-
${i}}
|
|
54
|
-
`;if(a(t)==="relationship"){let s=t.relationship?.field;if(!s)return ` ${t.name}
|
|
55
|
-
`;let o=find(propEq(t.relationship?.entity,"name"))(e),a$1=find(propEq(s,"name"))(o?.attributes??[]),u=a$1&&a(a$1)==="local"?`{
|
|
56
|
-
_id
|
|
57
|
-
default
|
|
58
|
-
${i}}
|
|
59
|
-
`:"";return t.relationship?.mode==="single"?` ${t.name} {
|
|
60
|
-
${s} ${u}}
|
|
61
|
-
`:` ${t.name} (limit: 3, offset: 0) {
|
|
62
|
-
${s} ${u}}
|
|
63
|
-
`}return ` ${t.name}
|
|
64
|
-
`}function Fn(t,n,e){return t?.attributes.reduce((r,i)=>{let s=n==="default"?"":`${n}
|
|
65
|
-
`;if(ft(i))return `${r}
|
|
66
|
-
${i.name} {
|
|
67
|
-
${Rt}
|
|
68
|
-
}
|
|
69
|
-
`;if(a(i)==="local")return `${r}
|
|
70
|
-
${i.name} {
|
|
71
|
-
_id
|
|
72
|
-
default
|
|
73
|
-
${s}
|
|
74
|
-
}
|
|
75
|
-
`;if(a(i)==="relationship"){let o=find(propEq(i.relationship?.entity,"name"))(e),a$1=find(propEq(i.relationship?.field,"name"))(o?.attributes??[]),u=a(a$1)==="local"?`{
|
|
76
|
-
_id
|
|
77
|
-
default
|
|
78
|
-
${s}}
|
|
79
|
-
`:"";if(i.relationship?.mode==="single")return `${r}
|
|
80
|
-
${i.name} {
|
|
81
|
-
${i.relationship.field} ${u}}
|
|
82
|
-
`;if(i.relationship?.field)return `${r}
|
|
83
|
-
${i.name} (limit: ${Pt}, offset: 0) {
|
|
84
|
-
${i.relationship.field} ${u}}
|
|
85
|
-
`}return `${r}
|
|
86
|
-
${i.name}
|
|
87
|
-
`},"")??""}function Tn(t){let n={};for(let e of t)n[e.name]=e;return n}function At(t){return t?t.name==="url"?true:!(t.hidden===true||t.name==="lqip"):false}function Le(t,n){if(!Array.isArray(t)||t.length===0)return;let[e]=t;if(!e||typeof e!="object")return;let[r]=Object.keys(e);if(!r||["_id","_createdAt","_updatedAt"].includes(r))return;let i=n?.attributes.find(s=>s.name===r);if(!(!i||a(i)!=="global"||i.dataType==="asset"))return {NOT:{[r]:{eq:null}}}}function pt(t,n,e,r){let i=r?.selection??"full",s=i==="display"?"list":i,o=r?.includeCount??true,a$2=r?.countMode??"aggregate",u="(where: $where, limit: $limit, offset: $offset, sort: $sort)",l=D(e,t),c=l?.name??t,d=a$1(l),f=i==="display"?d?[d]:[]:l?.attributes??[],g=Tn(f),h=`$where: ${c}Where, $limit: Int, $offset: Int, $sort: [${c}Sort!]`,y=r?.operationName??`Get${q(t)}`;if(!l)throw new Error(`Entity '${c}' not found in the schema`);if(f.length===0)throw new Error(`Entity '${c}' has no attributes defined in the schema`);let E=I("global",f).filter($=>$==="_updatedAt"?false:s==="list"?i==="display"||At(g[$]):true).join(`
|
|
88
|
-
`),p=tt(f).filter($=>s!=="list"||i==="display"||At(g[$])),m=I(["local"],f).filter($=>s!=="list"?true:i==="display"||At(g[$])),A=m.reduce(($,_)=>`${$}
|
|
89
|
-
${_} {
|
|
90
|
-
_id
|
|
91
|
-
default
|
|
92
|
-
}
|
|
93
|
-
`,""),O=m.reduce(($,_)=>`${$}
|
|
94
|
-
${_} {
|
|
95
|
-
_id
|
|
96
|
-
default
|
|
97
|
-
${n}
|
|
98
|
-
}
|
|
99
|
-
`,""),M=n==="default"?A:O,b=`_id
|
|
100
|
-
path
|
|
101
|
-
url`;s!=="list"&&(b=`_id
|
|
102
|
-
originalFilename
|
|
103
|
-
mimeType
|
|
104
|
-
path
|
|
105
|
-
url
|
|
106
|
-
size
|
|
107
|
-
height
|
|
108
|
-
width
|
|
109
|
-
lqip`);let F=p.reduce(($,_)=>`${$}
|
|
110
|
-
${_} {
|
|
111
|
-
${b}
|
|
112
|
-
}
|
|
113
|
-
`,""),B=f.filter($=>a($)==="relationship").reduce(($,_)=>{if(s==="list"&&i!=="display"&&_.hidden===true)return $;if(Y(_))return `${$}
|
|
114
|
-
${Jt(_.name,_t(_,l),s!=="list",s==="list"?Ln:Wt,s==="list")}`;let T=find(propEq(_.relationship?.entity,"name"))(e);if(s==="list"){let ut=a$1(T),lt=kn(ut,n,e,true),at=_.relationship?.mode==="single"?1:3;return `${$}
|
|
115
|
-
${_.name} (limit: ${at}, offset: 0) {
|
|
116
|
-
_id
|
|
117
|
-
${lt} }
|
|
118
|
-
`}let G=Fn(T,n,e);return `${Lt(_.name).trim()}${$}
|
|
119
|
-
${_.name} (limit: 25, offset: 0) { _id ${G}}
|
|
120
|
-
`},"");return {queryEntityName:t,query:`query ${y}(${h}) {
|
|
121
|
-
`+On(t,o,a$2)+` ${t}${u} {
|
|
122
|
-
_id
|
|
123
|
-
_updatedAt
|
|
124
|
-
${E} ${M} ${F} ${B}}
|
|
125
|
-
}
|
|
126
|
-
`}}function Ht(t,n,e,r){let s=D(r,t)?.attributes??[];if(s.length===0)return {count:0,results:[]};let o=Kt(e,t),a$2=e[t],u=(c,d)=>{let f=d.name;return c.slice(0,3).map(g=>{if(a(d)!=="local")return g[f];let h=U(g[f]);return h?.[n]??h?.default}).join(", ")},l=a$2.map(c=>{let{_id:d}=c,f=typeof c._updatedAt=="string"?c._updatedAt:"",g=I("global",s).filter(p=>p!=="_updatedAt").reduce((p,m)=>({...p,[m]:c[m]}),{}),h=I("local",s).reduce((p,m)=>{let A=U(c[m]);return {...p,[m]:A?.[n]?A[n]:A?.default}},{}),y=tt(s).reduce((p,m)=>({...p,[m]:U(c[m])}),{}),E=I(["relationship"],s).reduce((p,m)=>{let A=find(propEq(m,"name"))(s),O=A.relationship?.entity??"",M=find(propEq(O,"name"))(r),b=a$1(M),F=c[m];if(Y(A)){let T=zt(c[`${m}Connection`]);return {...p,[m]:T}}if(!b)throw new Error(`There is an error in the schema for the relationship attribute "${m}"`);let J=b.name,B=a(b);if(A.relationship?.mode==="multiple"){let T=Array.isArray(F)?F:[];return {...p,[m]:u(T,b)}}let $=U(F);if(B==="global")return {...p,[m]:$?.[J]};let _=U($?.[J]);return {...p,[m]:_?.[n]??_?.default}},{});return {_id:d,...g,...h,...y,...E,_updatedAt:f}});return {count:o,results:l}}function Xt(t,n,e,r){let s=D(r,t)?.attributes??[];if(s.length===0)return {count:0,results:[]};let o=Kt(e,t),u=e[t].map(l=>{let c=I("global",s).reduce((h,y)=>({...h,[y]:{value:l[y],disabled:false,scope:"default",_id:""}}),{}),d=I("local",s).reduce((h,y)=>{let E=find(propEq(y,"name"))(s),p=U(l[y]);return {...h,[y]:{value:p?xn(p,n):null,disabled:!!(p&&p[n]===null&&a(E)==="local"&&n!=="default"),scope:n,_id:p?p._id:null}}},{}),f=tt(s).reduce((h,y)=>({...h,[y]:{value:U(l[y]),disabled:false,scope:"default",_id:""}}),{}),g=I(["relationship"],s).reduce((h,y)=>{let E=find(propEq(y,"name"))(s),p=l[y],m=E.relationship?.mode==="single"?U(p):p,A=m?._id,O=Nt(l[`${y}Connection`]);if(Y(E)){let M=zt(l[`${y}Connection`]);return {...h,[y]:{count:O,_id:A,knownAssetSortOrders:Mn(M),value:M,disabled:false,scope:n}}}return {...h,[y]:{count:O,_id:A,value:m,disabled:false,scope:n}}},{});return {...c,...d,...f,...g}});return {count:o,results:u}}function xn(t,n){return Array.isArray(t)?t.reduce((e,r)=>{if(r[n]??r.default){let i={_id:r._id,disabled:r.scope===null&&n!=="default",scope:n,value:r[n]??r.default};e.push(i);}return e},[]):t[n]??t.default??null}function we(t,n,e,r,i,s,o){let a=D(r,t),u=a?.name??t,l=a?.attributes??[],c=nt(t);if(l.length===0)return "";let d=Zt(l,s),f=Yt(l,d),g=Gn(n,l,d,e),h=vn(l,i,d),y=jn(l,i,d),E=t,p=o?.responseFields??nn(r,t,e);return `mutation ${`Update${q(t)}`}($where: ${u}Where) {
|
|
127
|
-
update${c}(
|
|
128
|
-
where: $where
|
|
129
|
-
update: {${f}${g}${h}${y}
|
|
130
|
-
}
|
|
131
|
-
) {
|
|
132
|
-
${E} {
|
|
133
|
-
_id
|
|
134
|
-
${p} }
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
`}function Zt(t,n){let e=t.filter(i=>i.readOnly===true).map(i=>i.name),r=omit(e,n);return pick(t.map(i=>i.name),r)}function I(t,n){return Array.isArray(t)?t.reduce((r,i)=>r.concat(I(i,n)),[]):n.filter(r=>a(r)===t&&r.inputType!=="asset").map(r=>r.name)}function tt(t){return t.filter(ft).map(e=>e.name)}function Yt(t,n,e="update"){let r=pick(I("global",t),n);return toPairs(r).reduce((s,[o,a])=>{let u=find(propEq(o,"name"))(t),l=Array.isArray(a?.value)?null:a?.value??null,c=wt(u.dataType,l);return e==="create"&&(c===null||c==="")?s:e==="update"?`${s}
|
|
138
|
-
${o}: { set: ${c} }`:`${s}
|
|
139
|
-
${o}: ${c}`},"")}function bt(t){return !t?._id||!t.path?"":t._id}function vn(t,n,e){let r=pick(tt(t),e);return toPairs(r).reduce((o,[a,u])=>{let l=bt(u.value),c=bt(n[a]?.value);if(l===c)return o;let d=c?` {
|
|
140
|
-
disconnect: [{
|
|
141
|
-
where: {
|
|
142
|
-
node: {
|
|
143
|
-
_id: { eq: ${C(c)} }
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}]
|
|
147
|
-
}
|
|
148
|
-
`:"",f=l?` {
|
|
149
|
-
connect: [{
|
|
150
|
-
where: {
|
|
151
|
-
node: {
|
|
152
|
-
_id: { eq: ${C(l)} }
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}]
|
|
156
|
-
}
|
|
157
|
-
`:"";return `${o}
|
|
158
|
-
${a}: [
|
|
159
|
-
${d}${f} ]`},"")}function qn(t,n){let e=pick(tt(t),n);return toPairs(e).reduce((s,[o,a])=>{let u=bt(a.value);return u?`${s}
|
|
160
|
-
${o}: {
|
|
161
|
-
connect: [{
|
|
162
|
-
where: {
|
|
163
|
-
node: {
|
|
164
|
-
_id: { eq: ${C(u)} }
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}]
|
|
168
|
-
}`:s},"")}function Gn(t,n,e,r){let i=pick(I("local",n),e);return toPairs(i).reduce((a,[u,l])=>{let c=find(propEq(u,"name"))(n),{dataType:d}=c,f=l.disabled||Array.isArray(l.value)?"null":wt(d,l.value);return l._id?`${a}
|
|
169
|
-
${u}: [{
|
|
170
|
-
update: {
|
|
171
|
-
node: {
|
|
172
|
-
${r}: { set: ${f} }
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}]`:l.disabled||Array.isArray(l.value)||l.value===void 0||l.value===null||l.value===""||f===null||f===""?a:`${a}
|
|
176
|
-
${u}: [{
|
|
177
|
-
create: {
|
|
178
|
-
node: {
|
|
179
|
-
_id: ${C(`${t}:${u}`)}
|
|
180
|
-
_type: "${d}"
|
|
181
|
-
${r}: ${f}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}]`},"")}function jn(t,n,e){let r=pick(I("relationship",t),e);return toPairs(r).reduce((o,[a,u])=>{let l=find(propEq(a,"name"))(t),{inputType:c,relationship:d}=l;if(c==="relationship"&&d?.mode==="single"){let f=n[a]._id??"",g=u._id??"";if(f===g)return o;let h=f?` {
|
|
185
|
-
disconnect: [{
|
|
186
|
-
where: {
|
|
187
|
-
node: {
|
|
188
|
-
_id: { eq: ${C(f)} }
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}]
|
|
192
|
-
}
|
|
193
|
-
`:"",y=g?` {
|
|
194
|
-
connect: [{
|
|
195
|
-
where: {
|
|
196
|
-
node: {
|
|
197
|
-
_id: { eq: ${C(g)} }
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}]
|
|
201
|
-
}
|
|
202
|
-
`:"";return `${o}
|
|
203
|
-
${a}: [
|
|
204
|
-
${h}${y} ]`}if(c==="relationship"&&d?.mode==="multiple"){if(d.entity==="_asset")return `${o}${Dn(a,n[a],u)}`;let f=uniq(u.relationships?.disconnect??[]).filter(Boolean),h=(u.relationships?.connect??[]).map(p=>C(p._id)).join(", "),y=f.length?` {
|
|
205
|
-
disconnect: [
|
|
206
|
-
${f.map(p=>` {
|
|
207
|
-
where: {
|
|
208
|
-
node: {
|
|
209
|
-
_id: { eq: ${C(p)} }
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
`).join("")} ]
|
|
214
|
-
}
|
|
215
|
-
`:"",E=h?` {
|
|
216
|
-
connect: [{
|
|
217
|
-
where: {
|
|
218
|
-
node: {
|
|
219
|
-
_id: { in: [${h}] }
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}]
|
|
223
|
-
}
|
|
224
|
-
`:"";return !y&&!E?o:`${o}
|
|
225
|
-
${a}: [
|
|
226
|
-
${y}${E} ]`}return `${o}
|
|
227
|
-
`},"")}function Dn(t,n,e){let i=(e.relationships?.connect??[]).map((g,h)=>({...g,sortOrder:g.sortOrder??h})),s=i.map(g=>g._id),o={...Vn(n),...n?.knownAssetSortOrders??{},...e.knownAssetSortOrders??{}},a=uniq(e.relationships?.disconnect??[]).filter(g=>g&&!s.includes(g)),u=i.filter(g=>o[g._id]===void 0),l=i.filter(g=>{let h=o[g._id];return h!==void 0&&h!==g.sortOrder}),c=Un(a),d=Bn(u),f=Wn(l);return !c&&!d&&!f?"":`
|
|
228
|
-
${t}: [
|
|
229
|
-
${c}${d}${f} ]`}function Vn(t){let n=t?.value;return Array.isArray(n)?n.reduce((e,r,i)=>{if(typeof r!="object"||!r||!("_id"in r))return e;let{_id:s}=r;if(typeof s!="string"||s.length===0)return e;let o="sortOrder"in r&&typeof r.sortOrder=="number"?r.sortOrder:i;return {...e,[s]:o}},{}):{}}function Un(t){return t.length===0?"":` {
|
|
230
|
-
disconnect: [
|
|
231
|
-
${t.reduce((e,r)=>`${e} {
|
|
232
|
-
where: { node: { _id: { eq: ${C(r)} } } }
|
|
233
|
-
}
|
|
234
|
-
`,"")} ]
|
|
235
|
-
}
|
|
236
|
-
`}function Bn(t){return t.length===0?"":` {
|
|
237
|
-
connect: [
|
|
238
|
-
${tn(t)} ]
|
|
239
|
-
}
|
|
240
|
-
`}function tn(t){return t.reduce((n,e,r)=>{let i=e.sortOrder??r;return `${n} {
|
|
241
|
-
where: { node: { _id: { eq: ${C(e._id)} } } }
|
|
242
|
-
edge: { sortOrder: ${i} }
|
|
243
|
-
}
|
|
244
|
-
`},"")}function Wn(t){return t.length===0?"":t.reduce((e,r,i)=>{let s=r.sortOrder??i;return `${e} {
|
|
245
|
-
update: {
|
|
246
|
-
where: { node: { _id: { eq: ${C(r._id)} } } }
|
|
247
|
-
edge: { sortOrder: { set: ${s} } }
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
`},"")}function wt(t,n){return Cn.includes(t)?n?.toString()?C(n.toString()):null:wn.includes(t)?n==null?null:C(n.toString()):n==null||n===""?null:n.toString()}function C(t){return JSON.stringify(t)}function nn(t,n,e){let r=D(t,n),i=r?.attributes??[],s=I("global",i),o=I("local",i),a$1=I("relationship",i),u=s.reduce((l,c)=>`${l}${c}
|
|
251
|
-
`,"");return u+=o.reduce((l,c)=>`${l} ${c} {
|
|
252
|
-
_id
|
|
253
|
-
${e}
|
|
254
|
-
}
|
|
255
|
-
`,""),u+=a$1.reduce((l,c)=>{let d=find(propEq(c,"name"))(i),f=d?.relationship?.mode??"single";if(Y(d))return `${l}${Jt(c,_t(d,r))}`;let g=d?.relationship?.entity??"",y=find(propEq(g,"name"))(t)?.attributes??[],E=d?.relationship?.field??"[invalid_relationship_field_name_in_schema]",p=find(propEq(E,"name"))(y),m=a(p),A="";if(f==="single"&&(m==="global"&&(A=` ${c} {
|
|
256
|
-
_id
|
|
257
|
-
${E}
|
|
258
|
-
}
|
|
259
|
-
`),m==="local"&&(A=` ${c} {
|
|
260
|
-
_id
|
|
261
|
-
${E} {
|
|
262
|
-
_id
|
|
263
|
-
default
|
|
264
|
-
${e}
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
`)),f==="multiple"&&y.length){let O=y.reduce((M,b)=>{if(a(b)==="local")return `${M} ${b.name} {
|
|
268
|
-
_id
|
|
269
|
-
default
|
|
270
|
-
${e}
|
|
271
|
-
}
|
|
272
|
-
`;if(a(b)==="relationship"){let F=e==="default"?"":`${e}
|
|
273
|
-
`,J=find(propEq(b.relationship?.entity,"name"))(t),B=find(propEq(b.relationship?.field,"name"))(J?.attributes??[]),$=a(B)==="local"?`{
|
|
274
|
-
_id
|
|
275
|
-
default
|
|
276
|
-
${F}}
|
|
277
|
-
`:"";if(b.relationship?.mode==="single")return `${M} ${b.name} {
|
|
278
|
-
${b.relationship.field} ${$}}
|
|
279
|
-
`;if(b.relationship?.field)return `${M} ${b.name} (limit: ${Pt}, offset: 0) {
|
|
280
|
-
${b.relationship.field} ${$}}
|
|
281
|
-
`}return ft(b)?`${M} ${b.name} {
|
|
282
|
-
${Rt}
|
|
283
|
-
}
|
|
284
|
-
`:`${M} ${b.name}
|
|
285
|
-
`},"");A=Lt(c)+` ${c} (limit: 25, offset: 0) {
|
|
286
|
-
${O} }
|
|
287
|
-
`;}return `${l}${A}`},""),u}function Ce(t,n,e){let r=typeof e=="string"?[e]:[...e],i=find(propEq(t,"name"))(n),s=i?.attributes??[],o=nt(i?.plural??""),a=Pn(s,r),u=`Delete${q(i?.plural??t)}`;return t==="_asset"?`mutation ${u}($where: ${t}Where) {
|
|
288
|
-
delete_assets(
|
|
289
|
-
where: $where
|
|
290
|
-
) {
|
|
291
|
-
nodesDeleted
|
|
292
|
-
relationshipsDeleted
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
`:`mutation ${u}($where: ${t}Where) {
|
|
296
|
-
delete${o}(
|
|
297
|
-
where: $where
|
|
298
|
-
${a?` delete: {
|
|
299
|
-
${a}
|
|
300
|
-
}
|
|
301
|
-
`:""} ) {
|
|
302
|
-
nodesDeleted
|
|
303
|
-
relationshipsDeleted
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
`}function Ie(t){let n=typeof t=="string"?[t]:[...t];return n.length===1?{_id:{eq:n[0]}}:{_id:{in:n}}}function Pn(t,n){return I("local",t).reduce((i,s)=>{let o=n.map(u=>C(`${u}:${s}`)).join(", "),a=n.length===1?`_id: { eq: ${o} }`:`_id: { in: [${o}] }`;return `${i}
|
|
307
|
-
${s}: [{
|
|
308
|
-
where: {
|
|
309
|
-
node: {
|
|
310
|
-
${a}
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
}]`},"")}function Me(t,n,e,r,i){let s=D(n,t),o=s?.attributes??[],a=nt(s?.plural??"");if(o.length===0)return "";let u=Zt(o,e),l=Yt(o,u,"create"),c=zn(o,u,"default",r),d=qn(o,u),f=Jn(o,u),g=t,h=nn(n,g,"default");return `mutation ${`Create${q(t)}`} {
|
|
314
|
-
create${a}(
|
|
315
|
-
input: [{
|
|
316
|
-
_id: ${C(r)} ${l} ${c}
|
|
317
|
-
${d}
|
|
318
|
-
${f}
|
|
319
|
-
}]
|
|
320
|
-
) {
|
|
321
|
-
${g} {
|
|
322
|
-
_id
|
|
323
|
-
${h} }
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
`}function zn(t,n,e,r){let i=pick(I("local",t),n);return toPairs(i).reduce((a,[u,l])=>{if(l?.value===void 0||l.value===null||l.value==="")return a;let c=find(propEq(u,"name"))(t),d=Array.isArray(l.value)?"null":wt(c.dataType,l.value);return `${a}
|
|
327
|
-
${u}: {
|
|
328
|
-
create: [{
|
|
329
|
-
node: {
|
|
330
|
-
_id: ${C(`${r}:${u}`)}
|
|
331
|
-
_type: "${c.dataType}"
|
|
332
|
-
${e}: ${d}
|
|
333
|
-
}
|
|
334
|
-
}]
|
|
335
|
-
}`},"")}function Jn(t,n){let e=pick(I("relationship",t),n);return toPairs(e).reduce((s,[o,a])=>{let u=find(propEq(o,"name"))(t),{inputType:l,relationship:c}=u;if(l==="relationship"&&c?.mode==="single"){if(!a._id)return s;let g=`connect: [{
|
|
336
|
-
where: {
|
|
337
|
-
node: {
|
|
338
|
-
_id: { eq: ${C(a._id)} }
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
}]
|
|
342
|
-
`;return `${s}
|
|
343
|
-
${o}: {
|
|
344
|
-
${g} }`}let d=l==="relationship"&&c?.mode==="multiple",f=Array.isArray(a.relationships?.connect)&&a.relationships.connect.length>0;if(d&&f){let g=a.relationships?.connect??[];if(c?.entity==="_asset"){let E=tn(g.map((p,m)=>({...p,sortOrder:p.sortOrder??m})));return `${s}
|
|
345
|
-
${o}: {
|
|
346
|
-
connect: [
|
|
347
|
-
${E} ]
|
|
348
|
-
}`}let h=g.map(E=>C(E._id)).join(", "),y=h?`connect: {
|
|
349
|
-
where: {
|
|
350
|
-
node: {
|
|
351
|
-
_id: { in: [${h}] }
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
`:"";return `${s}
|
|
356
|
-
${o}: {
|
|
357
|
-
${y} }`}return `${s}
|
|
358
|
-
`},"")}function Qe({relatedEntityName:t,scope:n,schema:e}){let i=find(propEq(t,"name"))(e)?.plural??"";return i?pt(i,n,e,{selection:"list",operationName:`GetRelated${q(i)}`}):{queryEntityName:"",query:""}}function Oe({attributeName:t,entityName:n,entityNamePlural:e,schema:r}){let i=D(r,e),s=find(propEq(t,"name"))(i?.attributes??[]),o=_t(s,i),a=o?` properties {
|
|
359
|
-
sortOrder
|
|
360
|
-
}
|
|
361
|
-
`:"",u=o?"(first: $first, sort: [{ edge: { sortOrder: ASC } }])":"(first: $first)",l=`Get${q(n)}AssetConnection`;return {queryEntityName:e,query:`query ${l}($where: ${n}Where, $first: Int) {
|
|
362
|
-
${e}(where: $where) {
|
|
363
|
-
${t}Connection${u} {
|
|
364
|
-
aggregate {
|
|
365
|
-
count {
|
|
366
|
-
nodes
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
edges {
|
|
370
|
-
`+a+` node {
|
|
371
|
-
${St}
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
`}}var nt=t=>t.charAt(0).toUpperCase()+t.slice(1);function q(t){let n=t.split(/[^0-9A-Za-z]+/).filter(Boolean).map(nt).join("");return n?/^[A-Za-z_]/.test(n)?n:`Entity${n}`:"Entity"}function D(t,n){return n==="_assets"?b:find(propEq(n,"plural"))(t)}function ke(t,n,e){if(!t||typeof t!="object")return {};let r=D(e,n);if(!r)return {};let i=`update${nt(n)}`,s=t[i];if(!s||typeof s!="object")return {};let o=s[n],a$1=Array.isArray(o)?o[0]:void 0;return !a$1||typeof a$1!="object"?{}:r.attributes.reduce((u,l)=>{if(a(l)!=="local")return u;let d=U(a$1[l.name])?._id;return typeof d!="string"||d.length===0?u:{...u,[l.name]:d}},{})}function sn(t){return t?"cause"in t:false}function rt(t){if(!t)return null;if(ServerError.is(t))return t;if(sn(t)){let n=t.cause;if(ServerError.is(n))return n}return null}function on(t){if(!t||typeof t!="object")return null;let{message:n}=t;return typeof n=="string"?n:null}function it(t){if(!t)return null;try{return JSON.parse(t)}catch{return null}}function gt(t){if(!t)return null;let n=ln(t).filter(e=>!Xn(e));return n.length===0?null:["The deployed schema is out of sync with your local Flexkit schema.","Run `flexkit deploy` using the CLI to apply your latest schema changes.",...n.map(e=>`- ${e}`)].join(`
|
|
378
|
-
`)}function un(t,n){return t?ln(t).some(e=>e.includes(`Cannot query field "${n}"`)):false}function ln(t){if(CombinedGraphQLErrors.is(t))return t.errors.filter(rn).map(({message:i})=>i);let n=on(t);if(n&&et(n))return [n];let e=rt(t);if(e?.statusCode!==400)return [];let r=it(e.bodyText)??Kn(e)??Hn(t);return r?Array.isArray(r.errors)?r.errors.filter(rn).map(i=>i.message):typeof r.message=="string"&&et(r.message)?[r.message]:typeof r.error=="string"&&et(r.error)?[r.error]:[]:[]}function Kn(t){let{result:n}=t;return !n||typeof n!="object"?null:n}function Hn(t){if(!sn(t))return null;let{cause:n}=t,e=on(n);if(e&&et(e))return {message:e};if(!n||typeof n!="object")return null;let{result:r}=n;return r&&typeof r=="object"?r:null}function rn(t){if(!t||typeof t!="object")return false;let{extensions:n,message:e}=t;return n?.code==="GRAPHQL_VALIDATION_FAILED"&&typeof e=="string"?true:typeof e=="string"&&et(e)}function et(t){return t.startsWith("Cannot query field ")||t.startsWith("Unknown type ")||t.startsWith('Cannot query field "')||t.includes("GRAPHQL_VALIDATION_FAILED")}function Xn(t){return /Cannot query field "[_A-Za-z][_0-9A-Za-z]*Total" on type "Query"/.test(t)}var ce=ApolloProvider,dn=createContext(void 0);function fn(){let t=useContext(dn);if(!t)throw new Error("useGraphQLError must be used within GraphQLProvider");return t}function de(t){return new ErrorLink(({error:n})=>{let e=gt(n);if(e){t(e);return}CombinedGraphQLErrors.is(n)?n.errors.forEach(({message:i,locations:s,path:o})=>{console.warn(`[GraphQL error]: Message: ${i}, Location: ${s}, Path: ${o}`);}):CombinedProtocolErrors.is(n)&&n.errors.forEach(({message:i,extensions:s})=>{console.warn(`[Protocol error]: Message: ${i}, Extensions: ${JSON.stringify(s)}`);});let r=rt(n);if(r?.statusCode===400){let i=it(r.bodyText),s=null;if(i&&typeof i=="object"){let{error:o,errors:a,message:u}=i;if(typeof u=="string")s=u;else if(Array.isArray(a)){let[l]=a;if(l&&typeof l.message=="string"){let{message:c}=l;s=c;}}else typeof o=="string"?s=o:s=JSON.stringify(i);}else s=r.bodyText;t(s??"There is an error in the deployed Flexkit schema. Fix flexkit.config.ts and run flexkit deploy.");}if(r){console.warn(`[Network error]: ${r.message}`);return}n&&console.warn(`[Network error]: ${n.message}`);})}function fe(t,n){return from([de(n),new HttpLink({uri:`/api/flexkit/${t}/graphql`})])}function pe(t,n){return new ApolloClient({link:fe(t??"",n),cache:new InMemoryCache({dataIdFromObject:e=>e._id?e._id:defaultDataIdFromObject(e)})})}function We({children:t}){let{currentProjectId:n}=f(),[e,r]=useState(null),i=useMemo(()=>({schemaErrorMessage:e,setSchemaErrorMessage:r}),[e]),s=useMemo(()=>pe(n,r),[n]);return jsx(dn.Provider,{value:i,children:jsx(ce,{client:s,children:t})})}var yt=null,Ct=new Set,pn=[],It=new Set,Mt=new Set,Qt=new Set;function Ke(t,n){if(t==="_asset"||t==="_assets")return `Get${q(b.plural)}`;let e=n.find(s=>s.plural===t),r=n.find(s=>s.name===t),i=e?.plural??r?.plural??t;return `Get${q(i)}`}function gn(t){return It.add(t),()=>{It.delete(t);}}function yn(t){return Mt.add(t),()=>{Mt.delete(t);}}function mn(t){return Qt.add(t),()=>{Qt.delete(t);}}function He(t,n,e){let r=new Set(e.filter(Boolean));if(r.size>0)for(let i of Mt)i(n,r);return ge(t,n)}function Xe(t,n){let e=n.filter(r=>!!r._id);if(e.length!==0)for(let r of Qt)r(t,e);}function ge(t,n){return Ct.add(n),new Promise((e,r)=>{pn.push({resolve:e,reject:r}),yt&&clearTimeout(yt),yt=setTimeout(()=>{let i=new Set(Ct),s=pn.splice(0);Ct.clear(),yt=null,Promise.all([...It].map(o=>Promise.resolve(o(i)))).then(()=>{for(let{resolve:o}of s)o();}).catch(o=>{console.error("Error refreshing entity lists:",o);for(let{reject:a}of s)a(o);});},50);})}function ur({entityNamePlural:t,schema:n,scope:e,variables:r,isForm:i,selection:s="full",includeCount:o=true}){let[a,u]=useState({count:0,results:[]}),[l,c]=useState(false),[d,f]=useState(false),[g,h]=useState(null),y=useRef(false),E=useRef(false),p=useRef(0),m=useRef(null),A=useRef(null),O=`${t}Total`,M=D(n,t),F=r?.where===void 0&&(M?.spaces?.length??0)===0&&(g?.field!==O||g.schema!==n)?"total":"aggregate",J=useMemo(()=>gql(pt(t,e,n,{selection:s,countMode:F,includeCount:o}).query),[t,e,n,s,F,o]),B=useMemo(()=>gql(pt(t,e,n,{selection:s,includeCount:false}).query),[t,e,n,s]),{schemaErrorMessage:$,setSchemaErrorMessage:_}=fn(),{loading:T,data:G,fetchMore:ut,refetch:lt,error:at,networkStatus:X}=useQuery(J,{variables:r,notifyOnNetworkStatusChange:true}),kt=useRef(ut),$t=useRef(lt),Ft=useRef(B),Tt=useRef(X),xt=useRef(r);kt.current=ut,$t.current=lt,Ft.current=B,xt.current=r;let Et=o&&un(at,O),vt=F==="total"&&Et,W=Et?void 0:at,Z=Et&&!G?.[t],qt=rt(W),N=gt(W),{isProjectDisabled:An,isProjectReadOnly:bn}=(()=>{if(qt?.statusCode===403){let L=it(qt.bodyText);if(L&&typeof L.code=="string"){if(L.code==="PROJECT_PAUSED")return {isProjectDisabled:true,isProjectReadOnly:false};if(L.code==="READ_ONLY_MODE")return {isProjectDisabled:false,isProjectReadOnly:true}}return {isProjectDisabled:true,isProjectReadOnly:false}}return {isProjectDisabled:false,isProjectReadOnly:false}})();useEffect(()=>{vt&&h({field:O,schema:n});},[n,vt,O]);let Sn=useCallback(L=>{if(y.current||E.current)return;y.current=true,c(true);let{limit:x}=L.variables,v=p.current;kt.current({...L,query:Ft.current,variables:{...xt.current,...L.variables,offset:v,limit:x}}).then(({data:K})=>{let k=ot({data:K,entityNamePlural:t,isForm:i,schema:n,scope:e}),j=k.results.length;p.current=v+(j===0?0:Math.min(j,x)),u(Q=>{let P=uniqBy(prop("_id"),[...Q.results,...k.results]);return P.length===Q.results.length?{count:Q.results.length,results:Q.results}:{count:k.count||Q.count,results:P}});}).catch(K=>{console.error("Error fetching more data:",K);}).finally(()=>{y.current=false,c(false);});},[t,i,n,e]),Rn=useCallback(L=>{if(E.current)return Promise.resolve();let x=L?.preserve===true;return E.current=true,y.current=false,c(false),x||(m.current=null,A.current=null,p.current=0,f(true),u({count:0,results:[]})),$t.current().then(({data:v})=>{let K=JSON.stringify({entityNamePlural:t,scope:e,selection:s,includeCount:o,variables:r}),k=ot({data:v,entityNamePlural:t,isForm:i,schema:n,scope:e});m.current=K,A.current=null,p.current=ht(r)+k.results.length,u(k);}).catch(v=>{console.error("Error reloading data:",v);}).finally(()=>{E.current=false,f(false);})},[t,i,n,e,s,o,r]);return useEffect(()=>{if(N){_(N);return}G&&$&&!W&&_(null);},[G,W,$,N,_]),useEffect(()=>{if(W||N||Z)return;let L=JSON.stringify({entityNamePlural:t,scope:e,selection:s,includeCount:o,variables:r});if(m.current===L)return;if(T&&A.current!==L){A.current=L,p.current=0,u({count:0,results:[]});return}if(T)return;let x=ot({data:G,entityNamePlural:t,isForm:i,schema:n,scope:e});m.current=L,A.current=null,p.current=ht(r)+x.results.length,u(x);},[G,W,t,i,T,Z,n,N,e,s,o,r]),useEffect(()=>{let L=Tt.current;if(Tt.current=X,W||N||E.current||Z||L!==NetworkStatus.refetch||X!==NetworkStatus.ready||!G)return;let x=JSON.stringify({entityNamePlural:t,scope:e,selection:s,includeCount:o,variables:r}),v=ot({data:G,entityNamePlural:t,isForm:i,schema:n,scope:e});m.current=x,A.current=null,p.current=ht(r)+v.results.length,u(v);},[G,W,t,i,Z,X,n,N,e,s,o,r]),useEffect(()=>{if(i)return;let L=`Get${q(t)}`,x=gn(k=>{if(!(!k.has(L)||y.current||E.current))return $t.current().then(({data:j})=>{let Q=JSON.stringify({entityNamePlural:t,scope:e,selection:s,includeCount:o,variables:r}),P=ot({data:j,entityNamePlural:t,isForm:i,schema:n,scope:e});m.current=Q,A.current=null,p.current=ht(r)+P.results.length,u(P);}).catch(j=>{console.error("Error soft-refreshing entity list:",j);})}),v=yn((k,j)=>{k===L&&u(Q=>{let P=Q.results.filter(jt=>{let Dt=typeof jt._id=="string"?jt._id:void 0;return !Dt||!j.has(Dt)}),Gt=Q.results.length-P.length;return Gt===0?Q:{count:Math.max(0,Q.count-Gt),results:P}});}),K=mn((k,j)=>{k===L&&u(Q=>$e(Q,j,r?.sort));});return ()=>{x(),v(),K();}},[t,i,n,e,s,o,r]),{isLoading:T&&X!==NetworkStatus.refetch||d||Z,isLoadingMore:l,fetchMore:Sn,reload:Rn,count:a.count,data:a.results,isProjectDisabled:An,isProjectReadOnly:bn,schemaErrorMessage:$}}function ht(t){let n=t?.offset;return typeof n=="number"&&Number.isFinite(n)?n:0}function ot(t){let n=t.entityNamePlural;return t.data?.[n]?t.isForm?Xt(t.entityNamePlural,t.scope,t.data,t.schema):Ht(t.entityNamePlural,t.scope,t.data,t.schema):{count:0,results:[]}}function $e(t,n,e){let r=new Map(n.map(o=>[o._id,o])),i=false,s=t.results.map(o=>{let a=typeof o._id=="string"?o._id:void 0;if(!a)return o;let u=r.get(a);return u?(i=true,{...o,...u.attributes}):o});return i?{count:t.count,results:Ee(s,e)}:t}function Ee(t,n){if(!Array.isArray(n)||n.length===0)return t;let[e]=n;if(!e||typeof e!="object")return t;let[r]=Object.entries(e),[i,s]=r??[];if(!i||s!=="ASC"&&s!=="DESC")return t;let o=s==="DESC"?-1:1;return [...t].sort((a,u)=>{let l=a[i],c=u[i],d=typeof l=="string"?l:"",f=typeof c=="string"?c:"";return d.localeCompare(f)*o})}export{Wt as a,zt as b,Mn as c,Le as d,pt as e,Ht as f,we as g,Ce as h,Ie as i,Me as j,Qe as k,Oe as l,D as m,ke as n,rt as o,it as p,Ke as q,He as r,Xe as s,ge as t,fn as u,We as v,ur as w};//# sourceMappingURL=chunk-445XKMAG.js.map
|
|
379
|
-
//# sourceMappingURL=chunk-445XKMAG.js.map
|