@flexkit/studio 0.0.13 → 0.0.14
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/asset-65455B7V.js +2 -0
- package/dist/{asset-2IWHRTPZ.js.map → asset-65455B7V.js.map} +1 -1
- package/dist/boolean-3ZHXDPHB.js +2 -0
- package/dist/{boolean-OC4EQEDW.js.map → boolean-3ZHXDPHB.js.map} +1 -1
- package/dist/chunk-7DMOGZE6.js +2 -0
- package/dist/chunk-7DMOGZE6.js.map +1 -0
- package/dist/chunk-NJN7EGGK.js +2 -0
- package/dist/chunk-NJN7EGGK.js.map +1 -0
- package/dist/datetime-XX4YBITU.js +2 -0
- package/dist/{datetime-E36AZJZE.js.map → datetime-XX4YBITU.js.map} +1 -1
- package/dist/editor-ZLTDOUPT.js +2 -0
- package/dist/{editor-A6ZBSVFX.js.map → editor-ZLTDOUPT.js.map} +1 -1
- package/dist/index.js +92 -92
- package/dist/index.js.map +1 -1
- package/dist/logo-LB22KTDD.js +3 -0
- package/dist/{logo-XE2KYB64.js.map → logo-LB22KTDD.js.map} +1 -1
- package/dist/project-selector-4G4WL2XQ.js +2 -0
- package/dist/{project-selector-EC52GCO3.js.map → project-selector-4G4WL2XQ.js.map} +1 -1
- package/dist/search-JJI6BIRU.js +2 -0
- package/dist/{search-ZSMT34RQ.js.map → search-JJI6BIRU.js.map} +1 -1
- package/dist/switch-FU7XZ34K.js +2 -0
- package/dist/{switch-RTOPEJUM.js.map → switch-FU7XZ34K.js.map} +1 -1
- package/dist/text-DFG6LLN6.js +2 -0
- package/dist/{text-4V63FVFM.js.map → text-DFG6LLN6.js.map} +1 -1
- package/dist/text-LNFBPXBT.js +2 -0
- package/dist/{text-6SMN3R4Y.js.map → text-LNFBPXBT.js.map} +1 -1
- package/dist/textarea-XFHA5IEI.js +2 -0
- package/dist/{textarea-EMZIRBVZ.js.map → textarea-XFHA5IEI.js.map} +1 -1
- package/dist/ui.js +1 -1
- package/dist/ui.js.map +1 -1
- package/dist/user-nav-5LW5USDZ.js +2 -0
- package/dist/{user-nav-ORQ6W5W3.js.map → user-nav-5LW5USDZ.js.map} +1 -1
- package/package.json +1 -1
- package/dist/asset-2IWHRTPZ.js +0 -2
- package/dist/boolean-OC4EQEDW.js +0 -2
- package/dist/chunk-J63QWF2X.js +0 -14
- package/dist/chunk-J63QWF2X.js.map +0 -1
- package/dist/chunk-P745RJ7B.js +0 -2
- package/dist/chunk-P745RJ7B.js.map +0 -1
- package/dist/chunk-UKRYV5CE.js +0 -2
- package/dist/chunk-UKRYV5CE.js.map +0 -1
- package/dist/chunk-XSNFFA5W.js +0 -2
- package/dist/chunk-XSNFFA5W.js.map +0 -1
- package/dist/datetime-E36AZJZE.js +0 -2
- package/dist/editor-A6ZBSVFX.js +0 -2
- package/dist/logo-XE2KYB64.js +0 -3
- package/dist/project-selector-EC52GCO3.js +0 -2
- package/dist/search-ZSMT34RQ.js +0 -2
- package/dist/switch-RTOPEJUM.js +0 -2
- package/dist/text-4V63FVFM.js +0 -2
- package/dist/text-6SMN3R4Y.js +0 -2
- package/dist/textarea-EMZIRBVZ.js +0 -2
- package/dist/user-nav-ORQ6W5W3.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"asset-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"asset-65455B7V.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"boolean-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"boolean-3ZHXDPHB.js"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import'./index.css';import {c}from'./chunk-7YBJLUUE.js';import {createContext,useReducer,useContext,useMemo}from'react';import {jsx}from'react/jsx-runtime';import {path,has,find,propEq}from'ramda';import {useParams}from'react-router-dom';import k from'swr';var J="core.context.scope:",E={breadcrumbs:[],isRouteLoading:false,pageTitle:"",scope:"",relationships:{}},w=createContext(E),v=createContext(()=>{});function U(t,o){let{type:n,payload:e}=o;switch(n){case "setScope":return typeof localStorage<"u"&&e.projectId&&localStorage.setItem(`${J}${e.projectId}`,e.scope),{...t,scope:e.scope};case "setRelationship":return {...t,relationships:{...t.relationships,...e}};default:throw Error(`Unknown action: ${n}`)}}function Q({children:t}){let[o,n]=useReducer(U,E);return jsx(w.Provider,{value:o,children:jsx(v.Provider,{value:n,children:t})})}function I(){return useContext(w)}function Z(){return useContext(v)}var h={name:"_asset",plural:"_assets",menu:{hidden:true},attributes:[{name:"path",label:"Asset",scope:"global",options:{size:140},isEditable:true,dataType:"string",inputType:"text",previewType:"assetPreviewField",defaultValue:""},{name:"originalFilename",label:"Filename",scope:"global",options:{size:280},isEditable:true,dataType:"string",inputType:"text",previewType:"text",isPrimary:true,defaultValue:""},{name:"size",label:"Size",scope:"global",options:{size:120},isEditable:true,dataType:"int",inputType:"text",previewType:"text",defaultValue:""},{name:"width",label:"Width",scope:"global",options:{size:80},isEditable:true,dataType:"int",inputType:"text",previewType:"text",defaultValue:""},{name:"height",label:"Height",scope:"global",options:{size:80},isEditable:true,dataType:"int",inputType:"text",previewType:"text",defaultValue:""},{name:"mimeType",label:"Mime Type",scope:"global",options:{size:160},isEditable:true,dataType:"string",inputType:"text",previewType:"text",defaultValue:""},{name:"lqip",label:"lqip",scope:"global",isHidden:true,isEditable:true,dataType:"string",inputType:"text",previewType:"text",defaultValue:""},{name:"_updatedAt",label:"Last Updated",scope:"global",options:{size:140},isEditable:true,dataType:"string",inputType:"text",previewType:"text",defaultValue:""},{name:"tags",label:"Tags",scope:"relationship",dataType:"string",inputType:"relationship",defaultValue:"",previewType:"tags",options:{size:300},relationship:{mode:"multiple",field:"name",entity:"_tag"}}]};var T={name:"_tag",plural:"_tags",menu:{hidden:true},attributes:[{name:"name",label:"Tag Name",scope:"global",options:{size:220},isEditable:true,dataType:"string",inputType:"text",previewType:"text",isPrimary:true,defaultValue:""},{name:"_updatedAt",label:"Last Updated",scope:"global",options:{size:140},isEditable:true,dataType:"string",inputType:"text",previewType:"text",defaultValue:""},{name:"assets",label:"Assets",scope:"relationship",dataType:"string",inputType:"relationship",defaultValue:"",relationship:{mode:"multiple",field:"originalFilename",entity:"_asset"}}]};var N=createContext({contributions:{apps:[]},currentProjectId:void 0,currentProjectSchema:[],getContributionPointConfig:()=>[],plugins:[],projects:[]}),b=t=>Object.prototype.hasOwnProperty.call(t,"projectId"),C=t=>Object.prototype.hasOwnProperty.call(t,"contributes");function lt({config:t,children:o}){let{projectId:n}=useParams(),e=useMemo(()=>{let i=s=>[...s.filter(l=>l.name!==h.name&&l.name!==T.name),h,T];return t.map(s=>({...s,schema:i(s.schema)}))},[t]),r=useMemo(()=>m(["plugins"],e),[e]),u=useMemo(()=>m(["plugins"],e.filter(i=>i.projectId===n)),[e,n]),c=r.filter(i=>!b(i)&&C(i)),p=u.filter(i=>!b(i)&&C(i)),a=useMemo(()=>({contributions:{apps:x("apps",[],p)},currentProjectId:n,currentProjectSchema:e.find(i=>i.projectId===n)?.schema??[],getContributionPointConfig:(i,s=[])=>x(i,s,p),plugins:c,projects:r.filter(i=>b(i))}),[c,n,p,r]);return jsx(N.Provider,{value:{...a,contributions:{...a.contributions,apps:a.contributions.apps}},children:o})}function V(){return useContext(N)}function m(t,o){return Array.isArray(o)?o.reduce((n,e)=>path(t,e)?[...n,e,...m(t,path(t,e)??[])]:[...n,e],[]):[o]}function x(t,o=[],n){let e=["contributes",t,...o];return m(e.flat(),n).filter(r=>has("component",r))}function ut(t){let n=m(["plugins"],t).filter(e=>!b(e)&&C(e));return x("apps",[],n)}function bt(t,o){let{scope:n}=I(),{projects:e,currentProjectId:r}=V(),{schema:u,scopes:c$1}=find(propEq(r??"","projectId"))(e),p=c$1?.find(g=>g.isDefault)?.name??"default",a=o?.commonParams.q?JSON.stringify(o):null,{data:i,error:s,isLoading:d}=k(a,()=>fetch(c(t).search,{headers:{"Content-Type":"application/json"},body:JSON.stringify(o),method:"POST",mode:"cors"}).then(g=>g.json()));return {results:G(i?.results??[],t,u,n,p)??[],error:s,isLoading:d}}function B(t){return t.find(o=>o.isPrimary)?.name??t[0]?.name}function G(t,o,n,e,r){return t?.filter(u=>u?.hits?.length>0).map(u=>{let c=u,p=c.collection.replace(`${o}_`,"").replace(/_\d+$/,""),a=find(propEq(p,"plural"))(n);if(!a)return [];let i=B(a?.attributes??[]),s=a?.name??p;return c.hits.map(({document:d})=>{let l=d[i],F=(l&&typeof l!="string"?l[e]??l[r]:null)??d[i],L=Object.entries(d).reduce((O,[y,f])=>{if(y!==i&&y!=="id"&&y!=="_updatedAt"){let $=typeof f!="string"?f[e]??f[r]:f;O[y]=$;}return O},{});return {_id:d.id,_entityName:s,_entityNamePlural:p,[i]:F,...L}})}).flat()}export{J as a,Q as b,I as c,Z as d,h as e,T as f,lt as g,V as h,ut as i,bt as j};//# sourceMappingURL=chunk-7DMOGZE6.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-7DMOGZE6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/app-context.tsx","../src/entities/assets-schema.ts","../src/entities/tags-schema.ts","../src/core/config/config-context.tsx","../src/core/use-search.tsx"],"names":["SCOPE_STORAGE_KEY","initialState","AppContext","createContext","AppDispatchContext","reducer","state","action","type","payload","AppProvider","children","dispatch","useReducer","jsx","useAppContext","useContext","useAppDispatch","assetSchema","tagSchema","ConfigContext","hasProjectIdProperty","configItem","hasContributesProperty","ConfigProvider","config","currentProjectId","useParams","enhancedConfig","useMemo","upsertReservedEntities","schema","entity","project","globalFlattenedConfig","flattenConfigByProperty","currentProjectFlattenedConfig","item","allPlugins","currentProjectPlugins","globalConfig","_getContributionPointConfig","contributionPoint","subPath","useConfig","property","acc","curr","path","pathArray","has","getApps","plugins","useSearch","projectId","searchRequest","scope","projects","scopes","find","propEq","defaultScope","s","swrKey","data","error","isLoading","useSWR","apiPaths","res","mapResults","getPrimaryAttributeName","schemaAttributes","attr","results","result","entityNamePlural","entitySchema","primaryAttributeName","entityName","document","primaryAttribute","primaryAttributeValue","attributes","key","value","scopedValue"],"mappings":"iQAMO,IAAMA,CAAAA,CAAoB,sBAE3BC,CAAAA,CAAe,CACnB,WAAA,CAAa,EAAC,CACd,cAAA,CAAgB,KAAA,CAChB,SAAA,CAAW,GACX,KAAA,CAAO,EAAA,CACP,aAAA,CAAe,EACjB,CAAA,CAEMC,CAAAA,CAAaC,aAAAA,CAA8BF,CAAY,CAAA,CAEvDG,CAAAA,CAAqBD,aAAAA,CAAgE,IAAM,CAEjG,CAAC,EAED,SAASE,EAAQC,CAAAA,CAAuBC,CAAAA,CAAgE,CACtG,GAAM,CAAE,IAAA,CAAAC,CAAAA,CAAM,OAAA,CAAAC,CAAQ,CAAA,CAAIF,CAAAA,CAE1B,OAAQC,CAAAA,EACN,KAAK,UAAA,CACH,OAAI,OAAO,YAAA,CAAiB,GAAA,EAAeC,CAAAA,CAAQ,SAAA,EACjD,YAAA,CAAa,OAAA,CAAQ,CAAA,EAAGT,CAAiB,GAAGS,CAAAA,CAAQ,SAAS,CAAA,CAAA,CAAIA,CAAAA,CAAQ,KAAK,CAAA,CAGzE,CACL,GAAGH,EACH,KAAA,CAAOG,CAAAA,CAAQ,KACjB,CAAA,CACF,KAAK,iBAAA,CACH,OAAO,CACL,GAAGH,CAAAA,CACH,aAAA,CAAe,CAAE,GAAGA,CAAAA,CAAM,aAAA,CAAe,GAAGG,CAAQ,CACtD,CAAA,CACF,QACE,MAAM,KAAA,CAAM,CAAA,gBAAA,EAAmBD,CAAc,CAAA,CAAE,CACnD,CACF,CAEO,SAASE,CAAAA,CAAY,CAAE,QAAA,CAAAC,CAAS,CAAA,CAAyC,CAC9E,GAAM,CAACL,CAAAA,CAAOM,CAAQ,CAAA,CAAIC,UAAAA,CAAWR,CAAAA,CAASJ,CAAY,CAAA,CAE1D,OACEa,GAAAA,CAACZ,CAAAA,CAAW,QAAA,CAAX,CAAoB,K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,CAAAA,CACb,iBAAA,CAAmBH,CAAAA,CACnB,CAACE,CAAoB,EAAGI,CAAAA,CACxB,GAAGC,CACL,CACF,CAAC,CACH,CAAC,CAAA,CACA,MACL","file":"chunk-7DMOGZE6.js","sourcesContent":["'use client';\n\nimport { createContext, useContext, useReducer } from 'react';\nimport type { Dispatch, ReactNode } from 'react';\nimport type { ActionSetRelationship, ActionSetScope, AppContextType } from './types';\n\nexport const SCOPE_STORAGE_KEY = 'core.context.scope:';\n\nconst initialState = {\n breadcrumbs: [],\n isRouteLoading: false,\n pageTitle: '',\n scope: '',\n relationships: {},\n};\n\nconst AppContext = createContext<AppContextType>(initialState);\n\nconst AppDispatchContext = createContext<Dispatch<ActionSetRelationship | ActionSetScope>>(() => {\n /* void */\n});\n\nfunction reducer(state: AppContextType, action: ActionSetRelationship | ActionSetScope): AppContextType {\n const { type, payload } = action;\n\n switch (type) {\n case 'setScope':\n if (typeof localStorage !== 'undefined' && payload.projectId) {\n localStorage.setItem(`${SCOPE_STORAGE_KEY}${payload.projectId}`, payload.scope);\n }\n\n return {\n ...state,\n scope: payload.scope,\n };\n case 'setRelationship':\n return {\n ...state,\n relationships: { ...state.relationships, ...payload },\n };\n default:\n throw Error(`Unknown action: ${type as string}`);\n }\n}\n\nexport function AppProvider({ children }: { children: ReactNode }): JSX.Element {\n const [state, dispatch] = useReducer(reducer, initialState);\n\n return (\n <AppContext.Provider value={state}>\n <AppDispatchContext.Provider value={dispatch}>{children}</AppDispatchContext.Provider>\n </AppContext.Provider>\n );\n}\n\nexport function useAppContext(): AppContextType {\n return useContext(AppContext);\n}\n\nexport function useAppDispatch(): Dispatch<ActionSetRelationship | ActionSetScope> {\n return useContext(AppDispatchContext);\n}\n","import type { Entity } from '../core/types';\n\nexport const assetSchema: Entity = {\n name: '_asset',\n plural: '_assets',\n menu: {\n hidden: true,\n },\n attributes: [\n {\n name: 'path',\n label: 'Asset',\n scope: 'global',\n options: {\n size: 140,\n },\n isEditable: true,\n dataType: 'string',\n inputType: 'text',\n previewType: 'assetPreviewField',\n defaultValue: '',\n },\n {\n name: 'originalFilename',\n label: 'Filename',\n scope: 'global',\n options: {\n size: 280,\n },\n isEditable: true,\n dataType: 'string',\n inputType: 'text',\n previewType: 'text',\n isPrimary: true,\n defaultValue: '',\n },\n {\n name: 'size',\n label: 'Size',\n scope: 'global',\n options: {\n size: 120,\n },\n isEditable: true,\n dataType: 'int',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: 'width',\n label: 'Width',\n scope: 'global',\n options: {\n size: 80,\n },\n isEditable: true,\n dataType: 'int',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: 'height',\n label: 'Height',\n scope: 'global',\n options: {\n size: 80,\n },\n isEditable: true,\n dataType: 'int',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: 'mimeType',\n label: 'Mime Type',\n scope: 'global',\n options: {\n size: 160,\n },\n isEditable: true,\n dataType: 'string',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: 'lqip',\n label: 'lqip',\n scope: 'global',\n isHidden: true,\n isEditable: true,\n dataType: 'string',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: '_updatedAt',\n label: 'Last Updated',\n scope: 'global',\n options: {\n size: 140,\n },\n isEditable: true,\n dataType: 'string',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: 'tags',\n label: 'Tags',\n scope: 'relationship',\n dataType: 'string',\n inputType: 'relationship',\n defaultValue: '',\n previewType: 'tags',\n options: {\n size: 300,\n },\n relationship: {\n mode: 'multiple',\n field: 'name',\n entity: '_tag',\n },\n },\n ],\n};\n","import type { Entity } from '../core/types';\n\nexport const tagSchema: Entity = {\n name: '_tag',\n plural: '_tags',\n menu: {\n hidden: true,\n },\n attributes: [\n {\n name: 'name',\n label: 'Tag Name',\n scope: 'global',\n options: {\n size: 220,\n },\n isEditable: true,\n dataType: 'string',\n inputType: 'text',\n previewType: 'text',\n isPrimary: true,\n defaultValue: '',\n },\n {\n name: '_updatedAt',\n label: 'Last Updated',\n scope: 'global',\n options: {\n size: 140,\n },\n isEditable: true,\n dataType: 'string',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: 'assets',\n label: 'Assets',\n scope: 'relationship',\n dataType: 'string',\n inputType: 'relationship',\n defaultValue: '',\n relationship: {\n mode: 'multiple',\n field: 'originalFilename',\n entity: '_asset',\n },\n },\n ],\n};\n","'use client';\n\nimport { createContext, useContext, useMemo } from 'react';\nimport { has, path } from 'ramda';\nimport { useParams } from 'react-router-dom';\nimport { assetSchema } from '../../entities/assets-schema';\nimport { tagSchema } from '../../entities/tags-schema';\nimport type { AppOptions, PluginOptions, ProjectOptions } from './types';\nimport type { Entity } from '../types';\n\ntype Contributes = NonNullable<PluginOptions['contributes']>;\nexport interface ConfigContext {\n contributions: {\n apps: AppOptions[] | [];\n };\n currentProjectId?: string;\n currentProjectSchema: Entity[];\n getContributionPointConfig: <T extends keyof Contributes>(\n contributionPoint: T,\n subPath?: string[]\n ) => Contributes[T][] | [];\n plugins: PluginOptions[];\n projects: ProjectOptions[];\n}\n\nconst ConfigContext = createContext<ConfigContext>({\n contributions: {\n apps: [],\n },\n currentProjectId: undefined,\n currentProjectSchema: [],\n getContributionPointConfig: () => [],\n plugins: [] as PluginOptions[],\n projects: [] as ProjectOptions[],\n});\nconst hasProjectIdProperty = (configItem: ProjectOptions | PluginOptions): boolean =>\n Object.prototype.hasOwnProperty.call(configItem, 'projectId');\nconst hasContributesProperty = (configItem: ProjectOptions | PluginOptions): boolean =>\n Object.prototype.hasOwnProperty.call(configItem, 'contributes');\n\nexport function ConfigProvider({\n config,\n children,\n}: {\n config: ProjectOptions[];\n children: React.ReactNode;\n}): JSX.Element {\n /**\n * Getting the projectId from the URL via react-router-dom's useParams hook triggers a rerender of this Context\n * every time the URL changes.\n */\n const { projectId: currentProjectId } = useParams<{ projectId: string }>();\n const enhancedConfig = useMemo(() => {\n const upsertReservedEntities = (schema: Entity[]): Entity[] => {\n const withoutReserved = schema.filter(\n (entity) => entity.name !== assetSchema.name && entity.name !== tagSchema.name\n );\n\n return [...withoutReserved, assetSchema, tagSchema];\n };\n\n return config.map((project) => ({\n ...project,\n schema: upsertReservedEntities(project.schema),\n }));\n }, [config]);\n\n const globalFlattenedConfig = useMemo(() => flattenConfigByProperty(['plugins'], enhancedConfig), [enhancedConfig]);\n const currentProjectFlattenedConfig = useMemo(\n () =>\n flattenConfigByProperty(\n ['plugins'],\n enhancedConfig.filter((item) => item.projectId === currentProjectId)\n ),\n [enhancedConfig, currentProjectId]\n );\n const allPlugins = globalFlattenedConfig.filter(\n (item: ProjectOptions | PluginOptions) => !hasProjectIdProperty(item) && hasContributesProperty(item)\n ) as PluginOptions[];\n const currentProjectPlugins = currentProjectFlattenedConfig.filter(\n (item: ProjectOptions | PluginOptions) => !hasProjectIdProperty(item) && hasContributesProperty(item)\n ) as PluginOptions[];\n\n const globalConfig = useMemo(\n () => ({\n contributions: {\n apps: _getContributionPointConfig('apps', [], currentProjectPlugins),\n },\n currentProjectId,\n currentProjectSchema: enhancedConfig.find((item) => item.projectId === currentProjectId)?.schema ?? [],\n getContributionPointConfig: <T extends keyof Contributes>(\n contributionPoint: T,\n subPath: string[] = []\n ): Contributes[T][] =>\n _getContributionPointConfig(contributionPoint, subPath, currentProjectPlugins) as Contributes[T][],\n plugins: allPlugins,\n projects: globalFlattenedConfig.filter((item: ProjectOptions | PluginOptions) =>\n hasProjectIdProperty(item)\n ) as ProjectOptions[],\n }),\n [allPlugins, currentProjectId, currentProjectPlugins, globalFlattenedConfig]\n );\n\n return (\n <ConfigContext.Provider\n value={{\n ...globalConfig,\n contributions: {\n ...globalConfig.contributions,\n apps: globalConfig.contributions.apps as AppOptions[] | [],\n },\n }}\n >\n {children}\n </ConfigContext.Provider>\n );\n}\n\nexport function useConfig(): ConfigContext {\n return useContext(ConfigContext);\n}\n\nfunction flattenConfigByProperty(\n property: string[],\n config: (ProjectOptions | PluginOptions)[]\n): (ProjectOptions | PluginOptions)[] | [] {\n if (!Array.isArray(config)) {\n return [config];\n }\n\n return config.reduce<(ProjectOptions | PluginOptions)[]>((acc, curr) => {\n if (path(property, curr)) {\n return [...acc, curr, ...flattenConfigByProperty(property, path(property, curr) ?? [])];\n }\n\n return [...acc, curr];\n }, []);\n}\n\nfunction _getContributionPointConfig<T extends keyof Contributes>(\n contributionPoint: T,\n subPath: string[] = [],\n config: PluginOptions[]\n): Contributes[T] {\n const pathArray = ['contributes', contributionPoint, ...subPath];\n\n return flattenConfigByProperty(pathArray.flat(), config).filter((item) => has('component', item)) as Contributes[T];\n}\n\nexport function getApps(config: ProjectOptions[]): AppOptions[] | [] {\n const flattenedConfig = flattenConfigByProperty(['plugins'], config);\n const plugins = flattenedConfig.filter(\n (item: ProjectOptions | PluginOptions) => !hasProjectIdProperty(item) && hasContributesProperty(item)\n ) as PluginOptions[];\n return _getContributionPointConfig('apps', [], plugins) as AppOptions[] | [];\n}\n","'use client';\n\nimport useSWR from 'swr';\nimport { find, propEq } from 'ramda';\nimport { apiPaths } from './api-paths';\nimport { useAppContext } from './app-context';\nimport { useConfig } from './config/config-context';\nimport type { SingleProject } from './config/types';\nimport type {\n Attribute,\n Entity,\n RawResultItem,\n RawSearchResultItems,\n SearchRequestProps,\n SearchResultItem,\n} from './types';\n\nexport function useSearch(\n projectId: string,\n searchRequest: SearchRequestProps | null\n): { results: SearchResultItem[] | []; error: Error; isLoading: boolean } {\n const { scope } = useAppContext();\n const { projects, currentProjectId } = useConfig();\n const { schema, scopes } = find(propEq(currentProjectId ?? '', 'projectId'))(projects) as SingleProject;\n const defaultScope = scopes?.find((s) => s.isDefault)?.name ?? 'default';\n const swrKey = searchRequest?.commonParams.q ? JSON.stringify(searchRequest) : null;\n const { data, error, isLoading } = useSWR(swrKey, () =>\n fetch(apiPaths(projectId).search, {\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(searchRequest),\n method: 'POST',\n mode: 'cors',\n }).then((res) => res.json() as Promise<{ results: RawSearchResultItems }>)\n );\n const results = mapResults(data?.results ?? [], projectId, schema, scope, defaultScope);\n\n return { results: results ?? [], error, isLoading };\n}\n\n/**\n * Find the name of the attribute of an entity with isPrimary === true.\n * The value of that attribute is returned as the value for the relationship attribute\n */\nfunction getPrimaryAttributeName(schemaAttributes: Attribute[]): string {\n return schemaAttributes.find((attr) => attr.isPrimary)?.name ?? schemaAttributes[0]?.name;\n}\n\nfunction mapResults(\n results: RawSearchResultItems | undefined,\n projectId: string,\n schema: Entity[],\n scope: string,\n defaultScope: string\n): SearchResultItem[] | undefined {\n return results\n ?.filter((result) => (result as RawResultItem)?.hits?.length > 0)\n .map((result) => {\n const item = result as RawResultItem;\n const entityNamePlural = item.collection.replace(`${projectId}_`, '').replace(/_\\d+$/, '');\n const entitySchema = find<Entity>(propEq(entityNamePlural, 'plural'))(schema);\n\n if (!entitySchema) {\n return [];\n }\n\n const primaryAttributeName = getPrimaryAttributeName(entitySchema?.attributes ?? []);\n const entityName = entitySchema?.name ?? entityNamePlural;\n\n // iterate over the hits and return an object with the primary attribute value first and then the rest of the attributes.\n return item.hits.map(({ document }) => {\n const primaryAttribute = document[primaryAttributeName];\n const scopedPrimaryAttribute =\n primaryAttribute && typeof primaryAttribute !== 'string'\n ? (primaryAttribute[scope] ?? primaryAttribute[defaultScope])\n : null;\n const primaryAttributeValue = scopedPrimaryAttribute ?? document[primaryAttributeName];\n const attributes = Object.entries(document).reduce(\n (acc: Omit<SearchResultItem, '_id' | '_entityName' | '_entityNamePlural'>, [key, value]) => {\n if (key !== primaryAttributeName && key !== 'id' && key !== '_updatedAt') {\n const scopedValue = typeof value !== 'string' ? (value[scope] ?? value[defaultScope]) : value;\n\n acc[key] = scopedValue;\n }\n\n return acc;\n },\n {}\n );\n\n return {\n _id: document.id,\n _entityName: entityName,\n _entityNamePlural: entityNamePlural,\n [primaryAttributeName]: primaryAttributeValue as string,\n ...attributes,\n };\n });\n })\n .flat();\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import'./index.css';import {c as c$1}from'./chunk-7YBJLUUE.js';import {createContext,useContext}from'react';import c from'swr';import {useParams}from'react-router-dom';import {jsx}from'react/jsx-runtime';function i(){let{projectId:e}=useParams(),{data:t,isLoading:o}=c(c$1(e??"").currentUser,u=>fetch(u,{mode:"cors",credentials:"include"}).then(n=>n.json()));return [o,{user:t,logout:async()=>{await fetch(c$1(e??"").logout("/studio"),{method:"POST",mode:"cors",credentials:"include"}),await fetch("/api/flexkit/logout",{method:"GET",credentials:"include"}),window.location.reload();}}]}var s=createContext([true,{user:null,logout:()=>Promise.resolve()}]);function P({children:e}){let[t,o]=i();return jsx(s.Provider,{value:[t,o],children:e})}function x(){return useContext(s)}export{P as a,x as b};//# sourceMappingURL=chunk-NJN7EGGK.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-NJN7EGGK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/auth/use-auth-service.ts","../src/auth/auth-context.tsx"],"names":["useAuthService","projectId","useParams","user","isLoadingUser","useSWR","apiPaths","url","res","AuthContext","createContext","AuthProvider","children","isLoading","auth","jsx","useAuth","useContext"],"mappings":"4MAOe,SAARA,CAAAA,EAA+C,CACpD,GAAM,CAAE,SAAA,CAAAC,CAAU,CAAA,CAAIC,SAAAA,EAAU,CAC1B,CAAE,KAAMC,CAAAA,CAAM,SAAA,CAAWC,CAAc,CAAA,CAAIC,EAAOC,GAAAA,CAASL,CAAAA,EAAa,EAAE,CAAA,CAAE,YAAcM,CAAAA,EAC9F,KAAA,CAAMA,CAAAA,CAAK,CAAE,IAAA,CAAM,MAAA,CAAQ,WAAA,CAAa,SAAU,CAAC,CAAA,CAAE,IAAA,CAAMC,CAAAA,EAAQA,CAAAA,CAAI,MAAuB,CAChG,CAAA,CAGA,OAAO,CAFWJ,CAAAA,CAIhB,CACE,IAAA,CAAAD,CAAAA,CACA,MAAA,CAAQ,SAAY,CAElB,MAAM,MAAMG,GAAAA,CAASL,CAAAA,EAAa,EAAE,CAAA,CAAE,OAAO,SAAS,CAAA,CAAG,CACvD,MAAA,CAAQ,OACR,IAAA,CAAM,MAAA,CACN,WAAA,CAAa,SACf,CAAC,CAAA,CAGD,MAAM,KAAA,CAAM,sBAAuB,CAAE,MAAA,CAAQ,KAAA,CAAO,WAAA,CAAa,SAAU,CAAC,CAAA,CAE5E,MAAA,CAAO,QAAA,CAAS,SAClB,CACF,CACF,CACF,CC3BA,IAAMQ,CAAAA,CAAcC,aAAAA,CAAc,CAChC,IAAA,CACA,CACE,IAAA,CAAM,IAAA,CACN,MAAA,CAAQ,IAAM,QAAQ,OAAA,EACxB,CACF,CAAC,CAAA,CAEM,SAASC,CAAAA,CAAa,CAAE,SAAAC,CAAS,CAAA,CAA+C,CACrF,GAAM,CAACC,CAAAA,CAAWC,CAAI,CAAA,CAAId,CAAAA,GAE1B,OAAOe,GAAAA,CAACN,CAAAA,CAAY,QAAA,CAAZ,CAAqB,KAAA,CAAO,CAACI,CAAAA,CAAWC,CAAI,EAAI,QAAA,CAAAF,CAAAA,CAAS,CACnE,CAEO,SAASI,CAAAA,EAAuB,CACrC,OAAOC,UAAAA,CAAWR,CAAW,CAC/B","file":"chunk-NJN7EGGK.js","sourcesContent":["'use client';\n\nimport useSWR from 'swr';\nimport { useParams } from 'react-router-dom';\nimport { apiPaths } from '../core/api-paths';\nimport type { AuthService, User } from './types';\n\nexport default function useAuthService(): AuthService {\n const { projectId } = useParams();\n const { data: user, isLoading: isLoadingUser } = useSWR(apiPaths(projectId ?? '').currentUser, (url: string) =>\n fetch(url, { mode: 'cors', credentials: 'include' }).then((res) => res.json() as Promise<User>)\n );\n const isLoading = isLoadingUser;\n\n return [\n isLoading,\n {\n user,\n logout: async () => {\n // wipe remote session\n await fetch(apiPaths(projectId ?? '').logout('/studio'), {\n method: 'POST',\n mode: 'cors',\n credentials: 'include',\n });\n\n // delete first-party auth cookie\n await fetch('/api/flexkit/logout', { method: 'GET', credentials: 'include' });\n\n window.location.reload();\n },\n },\n ];\n}\n","'use client';\n\nimport { createContext, useContext } from 'react';\nimport useAuthService from './use-auth-service';\nimport type { Auth, AuthService, User } from './types';\n\nconst AuthContext = createContext([\n true,\n {\n user: null as User | null,\n logout: () => Promise.resolve(),\n } as Auth,\n]);\n\nexport function AuthProvider({ children }: { children: React.ReactNode }): JSX.Element {\n const [isLoading, auth] = useAuthService();\n\n return <AuthContext.Provider value={[isLoading, auth]}>{children}</AuthContext.Provider>;\n}\n\nexport function useAuth(): AuthService {\n return useContext(AuthContext) as AuthService;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"datetime-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"datetime-XX4YBITU.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"editor-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"editor-ZLTDOUPT.js"}
|