twenty-sdk 0.6.2 → 0.6.3-alpha

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.
Files changed (49) hide show
  1. package/dist/cli.cjs +1 -1
  2. package/dist/cli.mjs +1 -1
  3. package/dist/front-component-renderer/index.cjs +1 -1
  4. package/dist/front-component-renderer/index.mjs +1 -1
  5. package/dist/front-component-renderer/types/FrontComponentExecutionContext.d.ts +1 -0
  6. package/dist/front-component-renderer/types/FrontComponentHostCommunicationApi.d.ts +2 -1
  7. package/dist/index.cjs +2 -2
  8. package/dist/index.mjs +121 -114
  9. package/dist/sdk/front-component-api/functions/openAskAIWithPrompt.d.ts +2 -0
  10. package/dist/sdk/front-component-api/functions/openAskAIWithPrompt.js +12 -0
  11. package/dist/sdk/front-component-api/functions/openAskAIWithPrompt.js.map +1 -0
  12. package/dist/sdk/front-component-api/globals/frontComponentHostCommunicationApi.d.ts +4 -0
  13. package/dist/sdk/front-component-api/globals/frontComponentHostCommunicationApi.js.map +1 -1
  14. package/dist/sdk/front-component-api/hooks/useRecordId.d.ts +1 -0
  15. package/dist/sdk/front-component-api/hooks/useRecordId.js +6 -0
  16. package/dist/sdk/front-component-api/hooks/useRecordId.js.map +1 -0
  17. package/dist/sdk/front-component-api/index.d.ts +2 -0
  18. package/dist/sdk/front-component-api/types/FrontComponentExecutionContext.d.ts +1 -0
  19. package/dist/sdk/index.d.ts +1 -1
  20. package/dist/sdk/index.js +59 -55
  21. package/dist/sdk/index.js.map +1 -1
  22. package/package.json +1 -1
  23. package/generated/core/index.ts +0 -406
  24. package/generated/core/runtime/batcher.ts +0 -265
  25. package/generated/core/runtime/createClient.ts +0 -68
  26. package/generated/core/runtime/error.ts +0 -29
  27. package/generated/core/runtime/fetcher.ts +0 -98
  28. package/generated/core/runtime/generateGraphqlOperation.ts +0 -225
  29. package/generated/core/runtime/index.ts +0 -13
  30. package/generated/core/runtime/linkTypeMap.ts +0 -139
  31. package/generated/core/runtime/typeSelection.ts +0 -98
  32. package/generated/core/runtime/types.ts +0 -69
  33. package/generated/core/schema.graphql +0 -36745
  34. package/generated/core/schema.ts +0 -39341
  35. package/generated/core/types.ts +0 -45860
  36. package/generated/index.ts +0 -2
  37. package/generated/metadata/index.ts +0 -469
  38. package/generated/metadata/runtime/batcher.ts +0 -265
  39. package/generated/metadata/runtime/createClient.ts +0 -68
  40. package/generated/metadata/runtime/error.ts +0 -29
  41. package/generated/metadata/runtime/fetcher.ts +0 -98
  42. package/generated/metadata/runtime/generateGraphqlOperation.ts +0 -225
  43. package/generated/metadata/runtime/index.ts +0 -13
  44. package/generated/metadata/runtime/linkTypeMap.ts +0 -139
  45. package/generated/metadata/runtime/typeSelection.ts +0 -98
  46. package/generated/metadata/runtime/types.ts +0 -69
  47. package/generated/metadata/schema.graphql +0 -3971
  48. package/generated/metadata/schema.ts +0 -8357
  49. package/generated/metadata/types.ts +0 -10044
@@ -1,4 +1,5 @@
1
1
  export type FrontComponentExecutionContext = {
2
2
  frontComponentId: string;
3
3
  userId: string | null;
4
+ recordId: string | null;
4
5
  };
@@ -1,4 +1,4 @@
1
- import { type CloseSidePanelFunction, type EnqueueSnackbarFunction, type NavigateFunction, type OpenSidePanelPageFunction, type RequestAccessTokenRefreshFunction, type UnmountFrontComponentFunction } from '../../sdk/front-component-api/globals/frontComponentHostCommunicationApi';
1
+ import { type CloseSidePanelFunction, type EnqueueSnackbarFunction, type NavigateFunction, type OpenAskAIWithPromptFunction, type OpenSidePanelPageFunction, type RequestAccessTokenRefreshFunction, type UnmountFrontComponentFunction } from '../../sdk/front-component-api/globals/frontComponentHostCommunicationApi';
2
2
  export type FrontComponentHostCommunicationApi = {
3
3
  navigate: NavigateFunction;
4
4
  requestAccessTokenRefresh: RequestAccessTokenRefreshFunction;
@@ -6,4 +6,5 @@ export type FrontComponentHostCommunicationApi = {
6
6
  unmountFrontComponent: UnmountFrontComponentFunction;
7
7
  enqueueSnackbar: EnqueueSnackbarFunction;
8
8
  closeSidePanel: CloseSidePanelFunction;
9
+ openAskAIWithPrompt: OpenAskAIWithPromptFunction;
9
10
  };
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=require("@sniptt/guards"),p=require("react"),a=require("./HtmlTagToRemoteComponent-CgtwxDeH.js"),d=({config:e,errors:t=[]})=>({success:t.length===0,config:e,errors:t}),G=e=>{const t=[];return e.universalIdentifier||t.push("Application must have a universalIdentifier"),e.defaultRoleUniversalIdentifier||t.push("Application must have a defaultRoleUniversalIdentifier"),(!e.displayName||e.displayName.length===0)&&t.push("Application must have a non empty display name"),d({config:e,errors:t})},q=e=>{const t=[];return e.universalIdentifier||t.push("Front component must have a universalIdentifier"),e.component||t.push("Front component must have a component"),typeof e.component!="function"&&t.push("Front component component must be a React component"),e.command&&(e.command.universalIdentifier||t.push("Command must have a universalIdentifier"),e.command.label||t.push("Command must have a label")),d({config:e,errors:t})};var v=(e=>(e.DAY="DAY",e.MONTH="MONTH",e.QUARTER="QUARTER",e.YEAR="YEAR",e.WEEK="WEEK",e.DAY_OF_THE_WEEK="DAY_OF_THE_WEEK",e.MONTH_OF_THE_YEAR="MONTH_OF_THE_YEAR",e.QUARTER_OF_THE_YEAR="QUARTER_OF_THE_YEAR",e.NONE="NONE",e))(v||{});const _=e=>{if(!e)return[];const t=[];for(const n of e)y.isNonEmptyString(n.label)||t.push("Field must have a label"),y.isNonEmptyString(n.name)||t.push(`Field "${n.label}" must have a name`),y.isNonEmptyString(n.universalIdentifier)||t.push(`Field "${n.label}" must have a universalIdentifier`),(n.type===a.R.SELECT||n.type===a.R.MULTI_SELECT)&&(!Array.isArray(n.options)||n.options.length===0)&&t.push(`Field "${n.label}" is a SELECT/MULTI_SELECT type and must have options`);return t},Q=e=>{const t=[];e.objectUniversalIdentifier||t.push("Field must have an objectUniversalIdentifier");const n=_([e]);return t.push(...n),d({config:e,errors:t})},$=e=>{const t=[];return e.universalIdentifier||t.push("Logic function must have a universalIdentifier"),e.handler||t.push("Logic function must have a handler"),typeof e.handler!="function"&&t.push("Logic function handler must be a function"),e.httpRouteTriggerSettings&&(e.httpRouteTriggerSettings.path||t.push("Route trigger must have a path"),e.httpRouteTriggerSettings.httpMethod||t.push("Route trigger must have an httpMethod")),e.cronTriggerSettings&&(e.cronTriggerSettings.pattern||t.push("Cron trigger must have a pattern")),e.databaseEventTriggerSettings&&(e.databaseEventTriggerSettings.eventName||t.push("Database event trigger must have an eventName")),d({config:e,errors:t})},X=e=>{const t=[];return e.universalIdentifier||t.push("Pre install logic function must have a universalIdentifier"),e.handler||t.push("Pre install logic function must have a handler"),typeof e.handler!="function"&&t.push("Pre install logic function handler must be a function"),d({config:e,errors:t})},J=e=>{const t=[];return e.universalIdentifier||t.push("Post install logic function must have a universalIdentifier"),e.handler||t.push("Post install logic function must have a handler"),typeof e.handler!="function"&&t.push("Post install logic function handler must be a function"),d({config:e,errors:t})},z=e=>{const t=[];return e.universalIdentifier||t.push("NavigationMenuItem must have a universalIdentifier"),typeof e.position!="number"&&t.push("NavigationMenuItem must have a position"),d({config:e,errors:t})},Z=e=>{const t=[];e.universalIdentifier||t.push("Object must have a universalIdentifier"),e.nameSingular||t.push("Object must have a nameSingular"),e.namePlural||t.push("Object must have a namePlural"),e.labelSingular||t.push("Object must have a labelSingular"),e.labelPlural||t.push("Object must have a labelPlural");const n=_(e.fields);return t.push(...n),a.o(e.labelIdentifierFieldMetadataUniversalIdentifier)&&!e.fields.some(o=>o.universalIdentifier===e.labelIdentifierFieldMetadataUniversalIdentifier)&&t.push("labelIdentifierFieldMetadataUniversalIdentifier must reference a field defined in the fields array"),d({config:e,errors:t})},ee=e=>{const t=[];if(e.universalIdentifier||t.push("PageLayout must have a universalIdentifier"),e.name||t.push("PageLayout must have a name"),e.tabs){for(const n of e.tabs)if(n.universalIdentifier||t.push("PageLayoutTab must have a universalIdentifier"),n.title||t.push("PageLayoutTab must have a title"),n.widgets)for(const o of n.widgets)o.universalIdentifier||t.push("PageLayoutWidget must have a universalIdentifier"),o.title||t.push("PageLayoutWidget must have a title"),o.type||t.push("PageLayoutWidget must have a type")}return d({config:e,errors:t})},te=e=>{const t=[];if(e.universalIdentifier||t.push("Role must have a universalIdentifier"),e.label||t.push("Role must have a label"),e.objectPermissions)for(const n of e.objectPermissions)n.objectUniversalIdentifier||t.push("Object permission must have an objectUniversalIdentifier");if(e.fieldPermissions)for(const n of e.fieldPermissions)n.objectUniversalIdentifier||t.push("Field permission must have an objectUniversalIdentifier"),n.fieldUniversalIdentifier||t.push("Field permission must have a fieldUniversalIdentifier");return d({config:e,errors:t})};v.DAY,v.WEEK,v.MONTH,v.QUARTER,v.YEAR;var w=(e=>(e.API_KEYS_AND_WEBHOOKS="API_KEYS_AND_WEBHOOKS",e.WORKSPACE="WORKSPACE",e.WORKSPACE_MEMBERS="WORKSPACE_MEMBERS",e.ROLES="ROLES",e.DATA_MODEL="DATA_MODEL",e.SECURITY="SECURITY",e.WORKFLOWS="WORKFLOWS",e.IMPERSONATE="IMPERSONATE",e.SSO_BYPASS="SSO_BYPASS",e.APPLICATIONS="APPLICATIONS",e.MARKETPLACE_APPS="MARKETPLACE_APPS",e.LAYOUTS="LAYOUTS",e.BILLING="BILLING",e.AI_SETTINGS="AI_SETTINGS",e.AI="AI",e.VIEWS="VIEWS",e.UPLOAD_FILE="UPLOAD_FILE",e.DOWNLOAD_FILE="DOWNLOAD_FILE",e.SEND_EMAIL_TOOL="SEND_EMAIL_TOOL",e.HTTP_REQUEST_TOOL="HTTP_REQUEST_TOOL",e.CODE_INTERPRETER_TOOL="CODE_INTERPRETER_TOOL",e.IMPORT_CSV="IMPORT_CSV",e.EXPORT_CSV="EXPORT_CSV",e.CONNECTED_ACCOUNTS="CONNECTED_ACCOUNTS",e.PROFILE_INFORMATION="PROFILE_INFORMATION",e))(w||{});const ne=e=>{const t=[];return e.universalIdentifier||t.push("Skill must have a universalIdentifier"),e.name||t.push("Skill must have a name"),e.label||t.push("Skill must have a label"),e.content||t.push("Skill must have content"),d({config:e,errors:t})},ie=e=>{const t=[];if(e.universalIdentifier||t.push("View must have a universalIdentifier"),e.name||t.push("View must have a name"),e.objectUniversalIdentifier||t.push("View must have an objectUniversalIdentifier"),e.fields)for(const n of e.fields)n.universalIdentifier||t.push("ViewField must have a universalIdentifier"),n.fieldMetadataUniversalIdentifier||t.push("ViewField must have a fieldMetadataUniversalIdentifier");if(e.filters)for(const n of e.filters)n.universalIdentifier||t.push("ViewFilter must have a universalIdentifier"),n.fieldMetadataUniversalIdentifier||t.push("ViewFilter must have a fieldMetadataUniversalIdentifier");if(e.filterGroups)for(const n of e.filterGroups)n.universalIdentifier||t.push("ViewFilterGroup must have a universalIdentifier");if(e.groups)for(const n of e.groups)n.universalIdentifier||t.push("ViewGroup must have a universalIdentifier");if(e.fieldGroups)for(const n of e.fieldGroups)n.universalIdentifier||t.push("ViewFieldGroup must have a universalIdentifier");return d({config:e,errors:t})},re="__twentySdkExecutionContext__",P="__twentySdkContextListeners__",D=()=>(globalThis[P]||(globalThis[P]=new Set),globalThis[P]),N=()=>globalThis[re],oe=e=>{D().add(e)},se=e=>{D().delete(e)},ae=()=>{const e=a.frontComponentHostCommunicationApi.closeSidePanel;if(!a.o(e))throw new Error("closeSidePanelFunction is not set");return e()},T=e=>{const t=a.frontComponentHostCommunicationApi.enqueueSnackbar;if(!a.o(t))throw new Error("enqueueSnackbarFunction is not set");return t(e)},x=(e,t,n,o)=>{const l=a.frontComponentHostCommunicationApi.navigate;if(!a.o(l))throw new Error("navigateFunction is not set");return l(e,t,n,o)},U=e=>{const t=a.frontComponentHostCommunicationApi.openSidePanelPage;if(!a.o(t))throw new Error("openSidePanelPageFunction is not set");return t(e)},C=()=>{const e=a.frontComponentHostCommunicationApi.unmountFrontComponent;if(!a.o(e))throw new Error("unmountFrontComponentFunction is not set");return e()},R=e=>{const[t,n]=p.useState(()=>e(N())),o=p.useRef(t);return p.useEffect(()=>{const l=()=>{const r=e(N());r!==o.current&&(o.current=r,n(r))};return oe(l),l(),()=>se(l)},[e]),t},ue=e=>e.frontComponentId,b=()=>R(ue),le=e=>e.userId,de=()=>R(le),g=e=>`${e}-action-error`,ce=["click","dblclick","mousedown","mouseup","mouseover","mouseout","mouseenter","mouseleave","keydown","keyup","keypress","focus","blur","change","input","submit","scroll","wheel","contextmenu","drag"],pe={click:"onClick",dblclick:"onDoubleClick",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mouseout:"onMouseOut",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",keydown:"onKeyDown",keyup:"onKeyUp",keypress:"onKeyPress",focus:"onFocus",blur:"onBlur",change:"onChange",input:"onInput",submit:"onSubmit",scroll:"onScroll",wheel:"onWheel",contextmenu:"onContextMenu",drag:"onDrag",timeupdate:"onTimeUpdate",play:"onPlay",pause:"onPause",ended:"onEnded",loadedmetadata:"onLoadedMetadata",loadeddata:"onLoadedData",volumechange:"onVolumeChange",seeking:"onSeeking",seeked:"onSeeked",error:"onError",canplay:"onCanPlay",canplaythrough:"onCanPlayThrough",waiting:"onWaiting",progress:"onProgress",durationchange:"onDurationChange",ratechange:"onRateChange",stalled:"onStalled",suspend:"onSuspend",emptied:"onEmptied"},fe={id:{type:"string",optional:!0},className:{type:"string",optional:!0},style:{type:"string",optional:!0},title:{type:"string",optional:!0},tabIndex:{type:"number",optional:!0},role:{type:"string",optional:!0},"aria-label":{type:"string",optional:!0},"aria-hidden":{type:"boolean",optional:!0},"data-testid":{type:"string",optional:!0}},he=({execute:e})=>{const[t,n]=p.useState(!1),o=b();return p.useEffect(()=>{if(t)return;n(!0),(async()=>{try{await e()}catch(r){r instanceof Error&&await T({message:"Action failed",detailedMessage:r.message,variant:"error",dedupeKey:g(o)})}finally{await C()}})()},[e,t,o]),null},me=({to:e,params:t,queryParams:n,options:o})=>{const[l,r]=p.useState(!1),h=b();return p.useEffect(()=>{if(l)return;r(!0),(async()=>{try{await x(e,t,n,o)}catch(S){S instanceof Error&&await T({message:"Action failed",detailedMessage:S.message,variant:"error",dedupeKey:g(h)})}finally{await C()}})()},[e,t,n,o,l,h]),null},ve=({page:e,pageTitle:t,pageIcon:n,onClick:o,shouldResetSearchState:l=!1})=>{const[r,h]=p.useState(!1),E=b();return p.useEffect(()=>{if(r)return;h(!0),(async()=>{o?.();try{await U({page:e,pageTitle:t,pageIcon:n,shouldResetSearchState:l})}catch(O){O instanceof Error&&await T({message:"Action failed",detailedMessage:O.message,variant:"error",dedupeKey:g(E)})}finally{await C()}})()},[e,t,n,l,o,r,E]),null};class Ee{constructor(t){this.cssText=t}}class Se extends Array{item(t){return this[t]??null}}class Oe{constructor(t){this.cssRules=new Se,this.onChange=t}insertRule(t,n){const o=n??this.cssRules.length;return this.cssRules.splice(o,0,new Ee(t)),this.notify(),o}deleteRule(t){this.cssRules.splice(t,1),this.notify()}notify(){const t=this.cssRules.map(n=>n.cssText).join(`
2
- `);this.onChange(t)}}const Ie=e=>{const t=new WeakMap,n=new WeakMap,o=i=>{if(t.has(i))return;const s=document.createElement("remote-style");t.set(i,s);const L=(i.getAttributeNames?.()??[]).filter(u=>u.startsWith("data-")).map(u=>`${u}=${i.getAttribute(u)??""}`).join(";");L.length>0&&(s.styleKey=L);const I=()=>{s.cssText=i.textContent??""},j=new Oe(u=>{s.cssText=u});try{Object.defineProperty(i,"sheet",{get:()=>j,configurable:!0})}catch{}const M=Object.getPrototypeOf(i),A=Object.getOwnPropertyDescriptor(i,"textContent")??Object.getOwnPropertyDescriptor(M,"textContent")??Object.getOwnPropertyDescriptor(Object.getPrototypeOf(M),"textContent");if(A?.set){const u=A.set;try{Object.defineProperty(i,"textContent",{get:A.get,set(f){u.call(this,f),s.cssText=f??""},configurable:!0})}catch{}}const W=i.appendChild.bind(i);try{i.appendChild=u=>{const f=W(u);return I(),f}}catch{}const K=i.insertBefore.bind(i);try{i.insertBefore=(u,f)=>{const B=K(u,f);return I(),B}}catch{}const Y=i.removeChild.bind(i);try{i.removeChild=u=>{const f=Y(u);return I(),f}}catch{}if(typeof MutationObserver=="function")try{const u=new MutationObserver(()=>{I()});typeof u.observe=="function"&&(u.observe(i,{subtree:!0,childList:!0,characterData:!0}),n.set(i,u))}catch{}const F=i.textContent;F&&(s.cssText=F),e.appendChild(s)},l=i=>{const s=n.get(i);s&&(s.disconnect(),n.delete(i));const c=t.get(i);c&&c.parentNode&&(c.parentNode.removeChild(c),t.delete(i))},r=document.head,h=r.appendChild.bind(r),E=r.insertBefore.bind(r),S=r.append.bind(r),O=r.prepend.bind(r),k=r.replaceChild.bind(r),V=r.removeChild.bind(r);r.appendChild=i=>{const s=h(i);return m(i)&&o(i),s},r.insertBefore=(i,s)=>{const c=E(i,s);return m(i)&&o(i),c},r.append=(...i)=>{S(...i);for(const s of i)m(s)&&o(s)},r.prepend=(...i)=>{O(...i);for(const s of i)m(s)&&o(s)},r.replaceChild=(i,s)=>{const c=k(i,s);return m(s)&&l(s),m(i)&&o(i),c},r.removeChild=i=>{const s=V(i);return m(i)&&l(i),s};const H=Array.from(r.querySelectorAll("style"));for(const i of H)o(i);Object.defineProperty(document,"styleSheets",{get:()=>[],configurable:!0})},m=e=>typeof e!="string"&&"localName"in e&&e.localName==="style",Te=e=>{for(const[t,n]of Object.entries(e))globalThis[t]=n};exports.ALLOWED_HTML_ELEMENTS=a.ALLOWED_HTML_ELEMENTS;exports.AggregateOperations=a.n;exports.AppPath=a.s;exports.CommandMenuPages=a.p;exports.FieldType=a.R;exports.HTML_TAG_TO_REMOTE_COMPONENT=a.HTML_TAG_TO_REMOTE_COMPONENT;exports.OnDeleteAction=a.W;exports.PageLayoutTabLayoutMode=a.v;exports.RelationType=a.V;exports.STANDARD_OBJECT=a.y;exports.STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS=a.y;exports.Action=he;exports.ActionLink=me;exports.ActionOpenSidePanelPage=ve;exports.COMMON_HTML_EVENTS=ce;exports.EVENT_TO_REACT=pe;exports.HTML_COMMON_PROPERTIES=fe;exports.ObjectRecordGroupByDateGranularity=v;exports.PermissionFlag=w;exports.closeSidePanel=ae;exports.createValidationResult=d;exports.defineApplication=G;exports.defineField=Q;exports.defineFrontComponent=q;exports.defineLogicFunction=$;exports.defineNavigationMenuItem=z;exports.defineObject=Z;exports.definePageLayout=ee;exports.definePostInstallLogicFunction=J;exports.definePreInstallLogicFunction=X;exports.defineRole=te;exports.defineSkill=ne;exports.defineView=ie;exports.enqueueSnackbar=T;exports.exposeGlobals=Te;exports.getFrontComponentActionErrorDedupeKey=g;exports.installStyleBridge=Ie;exports.navigate=x;exports.openSidePanelPage=U;exports.unmountFrontComponent=C;exports.useFrontComponentExecutionContext=R;exports.useFrontComponentId=b;exports.useUserId=de;exports.validateFields=_;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=require("@sniptt/guards"),p=require("react"),a=require("./HtmlTagToRemoteComponent-CgtwxDeH.js"),d=({config:e,errors:t=[]})=>({success:t.length===0,config:e,errors:t}),G=e=>{const t=[];return e.universalIdentifier||t.push("Application must have a universalIdentifier"),e.defaultRoleUniversalIdentifier||t.push("Application must have a defaultRoleUniversalIdentifier"),(!e.displayName||e.displayName.length===0)&&t.push("Application must have a non empty display name"),d({config:e,errors:t})},q=e=>{const t=[];return e.universalIdentifier||t.push("Front component must have a universalIdentifier"),e.component||t.push("Front component must have a component"),typeof e.component!="function"&&t.push("Front component component must be a React component"),e.command&&(e.command.universalIdentifier||t.push("Command must have a universalIdentifier"),e.command.label||t.push("Command must have a label")),d({config:e,errors:t})};var v=(e=>(e.DAY="DAY",e.MONTH="MONTH",e.QUARTER="QUARTER",e.YEAR="YEAR",e.WEEK="WEEK",e.DAY_OF_THE_WEEK="DAY_OF_THE_WEEK",e.MONTH_OF_THE_YEAR="MONTH_OF_THE_YEAR",e.QUARTER_OF_THE_YEAR="QUARTER_OF_THE_YEAR",e.NONE="NONE",e))(v||{});const R=e=>{if(!e)return[];const t=[];for(const n of e)y.isNonEmptyString(n.label)||t.push("Field must have a label"),y.isNonEmptyString(n.name)||t.push(`Field "${n.label}" must have a name`),y.isNonEmptyString(n.universalIdentifier)||t.push(`Field "${n.label}" must have a universalIdentifier`),(n.type===a.R.SELECT||n.type===a.R.MULTI_SELECT)&&(!Array.isArray(n.options)||n.options.length===0)&&t.push(`Field "${n.label}" is a SELECT/MULTI_SELECT type and must have options`);return t},Q=e=>{const t=[];e.objectUniversalIdentifier||t.push("Field must have an objectUniversalIdentifier");const n=R([e]);return t.push(...n),d({config:e,errors:t})},$=e=>{const t=[];return e.universalIdentifier||t.push("Logic function must have a universalIdentifier"),e.handler||t.push("Logic function must have a handler"),typeof e.handler!="function"&&t.push("Logic function handler must be a function"),e.httpRouteTriggerSettings&&(e.httpRouteTriggerSettings.path||t.push("Route trigger must have a path"),e.httpRouteTriggerSettings.httpMethod||t.push("Route trigger must have an httpMethod")),e.cronTriggerSettings&&(e.cronTriggerSettings.pattern||t.push("Cron trigger must have a pattern")),e.databaseEventTriggerSettings&&(e.databaseEventTriggerSettings.eventName||t.push("Database event trigger must have an eventName")),d({config:e,errors:t})},X=e=>{const t=[];return e.universalIdentifier||t.push("Pre install logic function must have a universalIdentifier"),e.handler||t.push("Pre install logic function must have a handler"),typeof e.handler!="function"&&t.push("Pre install logic function handler must be a function"),d({config:e,errors:t})},J=e=>{const t=[];return e.universalIdentifier||t.push("Post install logic function must have a universalIdentifier"),e.handler||t.push("Post install logic function must have a handler"),typeof e.handler!="function"&&t.push("Post install logic function handler must be a function"),d({config:e,errors:t})},z=e=>{const t=[];return e.universalIdentifier||t.push("NavigationMenuItem must have a universalIdentifier"),typeof e.position!="number"&&t.push("NavigationMenuItem must have a position"),d({config:e,errors:t})},Z=e=>{const t=[];e.universalIdentifier||t.push("Object must have a universalIdentifier"),e.nameSingular||t.push("Object must have a nameSingular"),e.namePlural||t.push("Object must have a namePlural"),e.labelSingular||t.push("Object must have a labelSingular"),e.labelPlural||t.push("Object must have a labelPlural");const n=R(e.fields);return t.push(...n),a.o(e.labelIdentifierFieldMetadataUniversalIdentifier)&&!e.fields.some(o=>o.universalIdentifier===e.labelIdentifierFieldMetadataUniversalIdentifier)&&t.push("labelIdentifierFieldMetadataUniversalIdentifier must reference a field defined in the fields array"),d({config:e,errors:t})},ee=e=>{const t=[];if(e.universalIdentifier||t.push("PageLayout must have a universalIdentifier"),e.name||t.push("PageLayout must have a name"),e.tabs){for(const n of e.tabs)if(n.universalIdentifier||t.push("PageLayoutTab must have a universalIdentifier"),n.title||t.push("PageLayoutTab must have a title"),n.widgets)for(const o of n.widgets)o.universalIdentifier||t.push("PageLayoutWidget must have a universalIdentifier"),o.title||t.push("PageLayoutWidget must have a title"),o.type||t.push("PageLayoutWidget must have a type")}return d({config:e,errors:t})},te=e=>{const t=[];if(e.universalIdentifier||t.push("Role must have a universalIdentifier"),e.label||t.push("Role must have a label"),e.objectPermissions)for(const n of e.objectPermissions)n.objectUniversalIdentifier||t.push("Object permission must have an objectUniversalIdentifier");if(e.fieldPermissions)for(const n of e.fieldPermissions)n.objectUniversalIdentifier||t.push("Field permission must have an objectUniversalIdentifier"),n.fieldUniversalIdentifier||t.push("Field permission must have a fieldUniversalIdentifier");return d({config:e,errors:t})};v.DAY,v.WEEK,v.MONTH,v.QUARTER,v.YEAR;var w=(e=>(e.API_KEYS_AND_WEBHOOKS="API_KEYS_AND_WEBHOOKS",e.WORKSPACE="WORKSPACE",e.WORKSPACE_MEMBERS="WORKSPACE_MEMBERS",e.ROLES="ROLES",e.DATA_MODEL="DATA_MODEL",e.SECURITY="SECURITY",e.WORKFLOWS="WORKFLOWS",e.IMPERSONATE="IMPERSONATE",e.SSO_BYPASS="SSO_BYPASS",e.APPLICATIONS="APPLICATIONS",e.MARKETPLACE_APPS="MARKETPLACE_APPS",e.LAYOUTS="LAYOUTS",e.BILLING="BILLING",e.AI_SETTINGS="AI_SETTINGS",e.AI="AI",e.VIEWS="VIEWS",e.UPLOAD_FILE="UPLOAD_FILE",e.DOWNLOAD_FILE="DOWNLOAD_FILE",e.SEND_EMAIL_TOOL="SEND_EMAIL_TOOL",e.HTTP_REQUEST_TOOL="HTTP_REQUEST_TOOL",e.CODE_INTERPRETER_TOOL="CODE_INTERPRETER_TOOL",e.IMPORT_CSV="IMPORT_CSV",e.EXPORT_CSV="EXPORT_CSV",e.CONNECTED_ACCOUNTS="CONNECTED_ACCOUNTS",e.PROFILE_INFORMATION="PROFILE_INFORMATION",e))(w||{});const ne=e=>{const t=[];return e.universalIdentifier||t.push("Skill must have a universalIdentifier"),e.name||t.push("Skill must have a name"),e.label||t.push("Skill must have a label"),e.content||t.push("Skill must have content"),d({config:e,errors:t})},ie=e=>{const t=[];if(e.universalIdentifier||t.push("View must have a universalIdentifier"),e.name||t.push("View must have a name"),e.objectUniversalIdentifier||t.push("View must have an objectUniversalIdentifier"),e.fields)for(const n of e.fields)n.universalIdentifier||t.push("ViewField must have a universalIdentifier"),n.fieldMetadataUniversalIdentifier||t.push("ViewField must have a fieldMetadataUniversalIdentifier");if(e.filters)for(const n of e.filters)n.universalIdentifier||t.push("ViewFilter must have a universalIdentifier"),n.fieldMetadataUniversalIdentifier||t.push("ViewFilter must have a fieldMetadataUniversalIdentifier");if(e.filterGroups)for(const n of e.filterGroups)n.universalIdentifier||t.push("ViewFilterGroup must have a universalIdentifier");if(e.groups)for(const n of e.groups)n.universalIdentifier||t.push("ViewGroup must have a universalIdentifier");if(e.fieldGroups)for(const n of e.fieldGroups)n.universalIdentifier||t.push("ViewFieldGroup must have a universalIdentifier");return d({config:e,errors:t})},re="__twentySdkExecutionContext__",_="__twentySdkContextListeners__",D=()=>(globalThis[_]||(globalThis[_]=new Set),globalThis[_]),N=()=>globalThis[re],oe=e=>{D().add(e)},se=e=>{D().delete(e)},ae=()=>{const e=a.frontComponentHostCommunicationApi.closeSidePanel;if(!a.o(e))throw new Error("closeSidePanelFunction is not set");return e()},T=e=>{const t=a.frontComponentHostCommunicationApi.enqueueSnackbar;if(!a.o(t))throw new Error("enqueueSnackbarFunction is not set");return t(e)},k=(e,t,n,o)=>{const l=a.frontComponentHostCommunicationApi.navigate;if(!a.o(l))throw new Error("navigateFunction is not set");return l(e,t,n,o)},ue=e=>{const t=a.frontComponentHostCommunicationApi.openAskAIWithPrompt;if(!a.o(t))throw new Error("openAskAIWithPromptFunction is not set");return t(e)},x=e=>{const t=a.frontComponentHostCommunicationApi.openSidePanelPage;if(!a.o(t))throw new Error("openSidePanelPageFunction is not set");return t(e)},C=()=>{const e=a.frontComponentHostCommunicationApi.unmountFrontComponent;if(!a.o(e))throw new Error("unmountFrontComponentFunction is not set");return e()},A=e=>{const[t,n]=p.useState(()=>e(N())),o=p.useRef(t);return p.useEffect(()=>{const l=()=>{const r=e(N());r!==o.current&&(o.current=r,n(r))};return oe(l),l(),()=>se(l)},[e]),t},le=e=>e.frontComponentId,b=()=>A(le),de=e=>e.recordId,ce=()=>A(de),pe=e=>e.userId,fe=()=>A(pe),g=e=>`${e}-action-error`,he=["click","dblclick","mousedown","mouseup","mouseover","mouseout","mouseenter","mouseleave","keydown","keyup","keypress","focus","blur","change","input","submit","scroll","wheel","contextmenu","drag"],me={click:"onClick",dblclick:"onDoubleClick",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mouseout:"onMouseOut",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",keydown:"onKeyDown",keyup:"onKeyUp",keypress:"onKeyPress",focus:"onFocus",blur:"onBlur",change:"onChange",input:"onInput",submit:"onSubmit",scroll:"onScroll",wheel:"onWheel",contextmenu:"onContextMenu",drag:"onDrag",timeupdate:"onTimeUpdate",play:"onPlay",pause:"onPause",ended:"onEnded",loadedmetadata:"onLoadedMetadata",loadeddata:"onLoadedData",volumechange:"onVolumeChange",seeking:"onSeeking",seeked:"onSeeked",error:"onError",canplay:"onCanPlay",canplaythrough:"onCanPlayThrough",waiting:"onWaiting",progress:"onProgress",durationchange:"onDurationChange",ratechange:"onRateChange",stalled:"onStalled",suspend:"onSuspend",emptied:"onEmptied"},ve={id:{type:"string",optional:!0},className:{type:"string",optional:!0},style:{type:"string",optional:!0},title:{type:"string",optional:!0},tabIndex:{type:"number",optional:!0},role:{type:"string",optional:!0},"aria-label":{type:"string",optional:!0},"aria-hidden":{type:"boolean",optional:!0},"data-testid":{type:"string",optional:!0}},Ee=({execute:e})=>{const[t,n]=p.useState(!1),o=b();return p.useEffect(()=>{if(t)return;n(!0),(async()=>{try{await e()}catch(r){r instanceof Error&&await T({message:"Action failed",detailedMessage:r.message,variant:"error",dedupeKey:g(o)})}finally{await C()}})()},[e,t,o]),null},Se=({to:e,params:t,queryParams:n,options:o})=>{const[l,r]=p.useState(!1),h=b();return p.useEffect(()=>{if(l)return;r(!0),(async()=>{try{await k(e,t,n,o)}catch(S){S instanceof Error&&await T({message:"Action failed",detailedMessage:S.message,variant:"error",dedupeKey:g(h)})}finally{await C()}})()},[e,t,n,o,l,h]),null},Ie=({page:e,pageTitle:t,pageIcon:n,onClick:o,shouldResetSearchState:l=!1})=>{const[r,h]=p.useState(!1),E=b();return p.useEffect(()=>{if(r)return;h(!0),(async()=>{o?.();try{await x({page:e,pageTitle:t,pageIcon:n,shouldResetSearchState:l})}catch(I){I instanceof Error&&await T({message:"Action failed",detailedMessage:I.message,variant:"error",dedupeKey:g(E)})}finally{await C()}})()},[e,t,n,l,o,r,E]),null};class Oe{constructor(t){this.cssText=t}}class Te extends Array{item(t){return this[t]??null}}class Ce{constructor(t){this.cssRules=new Te,this.onChange=t}insertRule(t,n){const o=n??this.cssRules.length;return this.cssRules.splice(o,0,new Oe(t)),this.notify(),o}deleteRule(t){this.cssRules.splice(t,1),this.notify()}notify(){const t=this.cssRules.map(n=>n.cssText).join(`
2
+ `);this.onChange(t)}}const Ae=e=>{const t=new WeakMap,n=new WeakMap,o=i=>{if(t.has(i))return;const s=document.createElement("remote-style");t.set(i,s);const L=(i.getAttributeNames?.()??[]).filter(u=>u.startsWith("data-")).map(u=>`${u}=${i.getAttribute(u)??""}`).join(";");L.length>0&&(s.styleKey=L);const O=()=>{s.cssText=i.textContent??""},V=new Ce(u=>{s.cssText=u});try{Object.defineProperty(i,"sheet",{get:()=>V,configurable:!0})}catch{}const M=Object.getPrototypeOf(i),P=Object.getOwnPropertyDescriptor(i,"textContent")??Object.getOwnPropertyDescriptor(M,"textContent")??Object.getOwnPropertyDescriptor(Object.getPrototypeOf(M),"textContent");if(P?.set){const u=P.set;try{Object.defineProperty(i,"textContent",{get:P.get,set(f){u.call(this,f),s.cssText=f??""},configurable:!0})}catch{}}const j=i.appendChild.bind(i);try{i.appendChild=u=>{const f=j(u);return O(),f}}catch{}const K=i.insertBefore.bind(i);try{i.insertBefore=(u,f)=>{const B=K(u,f);return O(),B}}catch{}const Y=i.removeChild.bind(i);try{i.removeChild=u=>{const f=Y(u);return O(),f}}catch{}if(typeof MutationObserver=="function")try{const u=new MutationObserver(()=>{O()});typeof u.observe=="function"&&(u.observe(i,{subtree:!0,childList:!0,characterData:!0}),n.set(i,u))}catch{}const F=i.textContent;F&&(s.cssText=F),e.appendChild(s)},l=i=>{const s=n.get(i);s&&(s.disconnect(),n.delete(i));const c=t.get(i);c&&c.parentNode&&(c.parentNode.removeChild(c),t.delete(i))},r=document.head,h=r.appendChild.bind(r),E=r.insertBefore.bind(r),S=r.append.bind(r),I=r.prepend.bind(r),U=r.replaceChild.bind(r),W=r.removeChild.bind(r);r.appendChild=i=>{const s=h(i);return m(i)&&o(i),s},r.insertBefore=(i,s)=>{const c=E(i,s);return m(i)&&o(i),c},r.append=(...i)=>{S(...i);for(const s of i)m(s)&&o(s)},r.prepend=(...i)=>{I(...i);for(const s of i)m(s)&&o(s)},r.replaceChild=(i,s)=>{const c=U(i,s);return m(s)&&l(s),m(i)&&o(i),c},r.removeChild=i=>{const s=W(i);return m(i)&&l(i),s};const H=Array.from(r.querySelectorAll("style"));for(const i of H)o(i);Object.defineProperty(document,"styleSheets",{get:()=>[],configurable:!0})},m=e=>typeof e!="string"&&"localName"in e&&e.localName==="style",be=e=>{for(const[t,n]of Object.entries(e))globalThis[t]=n};exports.ALLOWED_HTML_ELEMENTS=a.ALLOWED_HTML_ELEMENTS;exports.AggregateOperations=a.n;exports.AppPath=a.s;exports.CommandMenuPages=a.p;exports.FieldType=a.R;exports.HTML_TAG_TO_REMOTE_COMPONENT=a.HTML_TAG_TO_REMOTE_COMPONENT;exports.OnDeleteAction=a.W;exports.PageLayoutTabLayoutMode=a.v;exports.RelationType=a.V;exports.STANDARD_OBJECT=a.y;exports.STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS=a.y;exports.Action=Ee;exports.ActionLink=Se;exports.ActionOpenSidePanelPage=Ie;exports.COMMON_HTML_EVENTS=he;exports.EVENT_TO_REACT=me;exports.HTML_COMMON_PROPERTIES=ve;exports.ObjectRecordGroupByDateGranularity=v;exports.PermissionFlag=w;exports.closeSidePanel=ae;exports.createValidationResult=d;exports.defineApplication=G;exports.defineField=Q;exports.defineFrontComponent=q;exports.defineLogicFunction=$;exports.defineNavigationMenuItem=z;exports.defineObject=Z;exports.definePageLayout=ee;exports.definePostInstallLogicFunction=J;exports.definePreInstallLogicFunction=X;exports.defineRole=te;exports.defineSkill=ne;exports.defineView=ie;exports.enqueueSnackbar=T;exports.exposeGlobals=be;exports.getFrontComponentActionErrorDedupeKey=g;exports.installStyleBridge=Ae;exports.navigate=k;exports.openAskAIWithPrompt=ue;exports.openSidePanelPage=x;exports.unmountFrontComponent=C;exports.useFrontComponentExecutionContext=A;exports.useFrontComponentId=b;exports.useRecordId=ce;exports.useUserId=fe;exports.validateFields=R;
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { isNonEmptyString as y } from "@sniptt/guards";
1
+ import { isNonEmptyString as A } from "@sniptt/guards";
2
2
  import { useState as T, useRef as G, useEffect as b } from "react";
3
- import { R as N, o as m, f as S } from "./HtmlTagToRemoteComponent-D_EW5OLu.mjs";
4
- import { A as Fe, n as Me, s as Ne, p as we, H as De, W as xe, v as Ue, V as ke, y as je, y as Ve } from "./HtmlTagToRemoteComponent-D_EW5OLu.mjs";
3
+ import { R as w, o as h, f as v } from "./HtmlTagToRemoteComponent-D_EW5OLu.mjs";
4
+ import { A as we, n as De, s as xe, p as Ue, H as ke, W as We, v as je, V as Ve, y as Ke, y as He } from "./HtmlTagToRemoteComponent-D_EW5OLu.mjs";
5
5
  const l = ({
6
6
  config: e,
7
7
  errors: t = []
@@ -9,63 +9,63 @@ const l = ({
9
9
  success: t.length === 0,
10
10
  config: e,
11
11
  errors: t
12
- }), ae = (e) => {
12
+ }), ue = (e) => {
13
13
  const t = [];
14
14
  return e.universalIdentifier || t.push("Application must have a universalIdentifier"), e.defaultRoleUniversalIdentifier || t.push("Application must have a defaultRoleUniversalIdentifier"), (!e.displayName || e.displayName.length === 0) && t.push("Application must have a non empty display name"), l({
15
15
  config: e,
16
16
  errors: t
17
17
  });
18
- }, ue = (e) => {
18
+ }, le = (e) => {
19
19
  const t = [];
20
20
  return e.universalIdentifier || t.push("Front component must have a universalIdentifier"), e.component || t.push("Front component must have a component"), typeof e.component != "function" && t.push("Front component component must be a React component"), e.command && (e.command.universalIdentifier || t.push("Command must have a universalIdentifier"), e.command.label || t.push("Command must have a label")), l({
21
21
  config: e,
22
22
  errors: t
23
23
  });
24
24
  };
25
- var h = /* @__PURE__ */ ((e) => (e.DAY = "DAY", e.MONTH = "MONTH", e.QUARTER = "QUARTER", e.YEAR = "YEAR", e.WEEK = "WEEK", e.DAY_OF_THE_WEEK = "DAY_OF_THE_WEEK", e.MONTH_OF_THE_YEAR = "MONTH_OF_THE_YEAR", e.QUARTER_OF_THE_YEAR = "QUARTER_OF_THE_YEAR", e.NONE = "NONE", e))(h || {});
26
- const D = (e) => {
25
+ var m = /* @__PURE__ */ ((e) => (e.DAY = "DAY", e.MONTH = "MONTH", e.QUARTER = "QUARTER", e.YEAR = "YEAR", e.WEEK = "WEEK", e.DAY_OF_THE_WEEK = "DAY_OF_THE_WEEK", e.MONTH_OF_THE_YEAR = "MONTH_OF_THE_YEAR", e.QUARTER_OF_THE_YEAR = "QUARTER_OF_THE_YEAR", e.NONE = "NONE", e))(m || {});
26
+ const x = (e) => {
27
27
  if (!e)
28
28
  return [];
29
29
  const t = [];
30
30
  for (const n of e)
31
- y(n.label) || t.push("Field must have a label"), y(n.name) || t.push(`Field "${n.label}" must have a name`), y(n.universalIdentifier) || t.push(`Field "${n.label}" must have a universalIdentifier`), (n.type === N.SELECT || n.type === N.MULTI_SELECT) && (!Array.isArray(n.options) || n.options.length === 0) && t.push(
31
+ A(n.label) || t.push("Field must have a label"), A(n.name) || t.push(`Field "${n.label}" must have a name`), A(n.universalIdentifier) || t.push(`Field "${n.label}" must have a universalIdentifier`), (n.type === w.SELECT || n.type === w.MULTI_SELECT) && (!Array.isArray(n.options) || n.options.length === 0) && t.push(
32
32
  `Field "${n.label}" is a SELECT/MULTI_SELECT type and must have options`
33
33
  );
34
34
  return t;
35
- }, le = (e) => {
35
+ }, de = (e) => {
36
36
  const t = [];
37
37
  e.objectUniversalIdentifier || t.push("Field must have an objectUniversalIdentifier");
38
- const n = D([e]);
38
+ const n = x([e]);
39
39
  return t.push(...n), l({
40
40
  config: e,
41
41
  errors: t
42
42
  });
43
- }, de = (e) => {
43
+ }, ce = (e) => {
44
44
  const t = [];
45
45
  return e.universalIdentifier || t.push("Logic function must have a universalIdentifier"), e.handler || t.push("Logic function must have a handler"), typeof e.handler != "function" && t.push("Logic function handler must be a function"), e.httpRouteTriggerSettings && (e.httpRouteTriggerSettings.path || t.push("Route trigger must have a path"), e.httpRouteTriggerSettings.httpMethod || t.push("Route trigger must have an httpMethod")), e.cronTriggerSettings && (e.cronTriggerSettings.pattern || t.push("Cron trigger must have a pattern")), e.databaseEventTriggerSettings && (e.databaseEventTriggerSettings.eventName || t.push("Database event trigger must have an eventName")), l({
46
46
  config: e,
47
47
  errors: t
48
48
  });
49
- }, ce = (e) => {
49
+ }, pe = (e) => {
50
50
  const t = [];
51
51
  return e.universalIdentifier || t.push("Pre install logic function must have a universalIdentifier"), e.handler || t.push("Pre install logic function must have a handler"), typeof e.handler != "function" && t.push("Pre install logic function handler must be a function"), l({
52
52
  config: e,
53
53
  errors: t
54
54
  });
55
- }, pe = (e) => {
55
+ }, fe = (e) => {
56
56
  const t = [];
57
57
  return e.universalIdentifier || t.push("Post install logic function must have a universalIdentifier"), e.handler || t.push("Post install logic function must have a handler"), typeof e.handler != "function" && t.push("Post install logic function handler must be a function"), l({
58
58
  config: e,
59
59
  errors: t
60
60
  });
61
- }, fe = (e) => {
61
+ }, he = (e) => {
62
62
  const t = [];
63
63
  return e.universalIdentifier || t.push("NavigationMenuItem must have a universalIdentifier"), typeof e.position != "number" && t.push("NavigationMenuItem must have a position"), l({ config: e, errors: t });
64
- }, he = (e) => {
64
+ }, me = (e) => {
65
65
  const t = [];
66
66
  e.universalIdentifier || t.push("Object must have a universalIdentifier"), e.nameSingular || t.push("Object must have a nameSingular"), e.namePlural || t.push("Object must have a namePlural"), e.labelSingular || t.push("Object must have a labelSingular"), e.labelPlural || t.push("Object must have a labelPlural");
67
- const n = D(e.fields);
68
- return t.push(...n), m(e.labelIdentifierFieldMetadataUniversalIdentifier) && !e.fields.some(
67
+ const n = x(e.fields);
68
+ return t.push(...n), h(e.labelIdentifierFieldMetadataUniversalIdentifier) && !e.fields.some(
69
69
  (s) => s.universalIdentifier === e.labelIdentifierFieldMetadataUniversalIdentifier
70
70
  ) && t.push(
71
71
  "labelIdentifierFieldMetadataUniversalIdentifier must reference a field defined in the fields array"
@@ -73,7 +73,7 @@ const D = (e) => {
73
73
  config: e,
74
74
  errors: t
75
75
  });
76
- }, me = (e) => {
76
+ }, ve = (e) => {
77
77
  const t = [];
78
78
  if (e.universalIdentifier || t.push("PageLayout must have a universalIdentifier"), e.name || t.push("PageLayout must have a name"), e.tabs) {
79
79
  for (const n of e.tabs)
@@ -82,7 +82,7 @@ const D = (e) => {
82
82
  s.universalIdentifier || t.push("PageLayoutWidget must have a universalIdentifier"), s.title || t.push("PageLayoutWidget must have a title"), s.type || t.push("PageLayoutWidget must have a type");
83
83
  }
84
84
  return l({ config: e, errors: t });
85
- }, ve = (e) => {
85
+ }, Ie = (e) => {
86
86
  const t = [];
87
87
  if (e.universalIdentifier || t.push("Role must have a universalIdentifier"), e.label || t.push("Role must have a label"), e.objectPermissions)
88
88
  for (const n of e.objectPermissions)
@@ -92,7 +92,7 @@ const D = (e) => {
92
92
  n.objectUniversalIdentifier || t.push("Field permission must have an objectUniversalIdentifier"), n.fieldUniversalIdentifier || t.push("Field permission must have a fieldUniversalIdentifier");
93
93
  return l({ config: e, errors: t });
94
94
  };
95
- h.DAY, h.WEEK, h.MONTH, h.QUARTER, h.YEAR;
95
+ m.DAY, m.WEEK, m.MONTH, m.QUARTER, m.YEAR;
96
96
  var Q = /* @__PURE__ */ ((e) => (e.API_KEYS_AND_WEBHOOKS = "API_KEYS_AND_WEBHOOKS", e.WORKSPACE = "WORKSPACE", e.WORKSPACE_MEMBERS = "WORKSPACE_MEMBERS", e.ROLES = "ROLES", e.DATA_MODEL = "DATA_MODEL", e.SECURITY = "SECURITY", e.WORKFLOWS = "WORKFLOWS", e.IMPERSONATE = "IMPERSONATE", e.SSO_BYPASS = "SSO_BYPASS", e.APPLICATIONS = "APPLICATIONS", e.MARKETPLACE_APPS = "MARKETPLACE_APPS", e.LAYOUTS = "LAYOUTS", e.BILLING = "BILLING", e.AI_SETTINGS = "AI_SETTINGS", e.AI = "AI", e.VIEWS = "VIEWS", e.UPLOAD_FILE = "UPLOAD_FILE", e.DOWNLOAD_FILE = "DOWNLOAD_FILE", e.SEND_EMAIL_TOOL = "SEND_EMAIL_TOOL", e.HTTP_REQUEST_TOOL = "HTTP_REQUEST_TOOL", e.CODE_INTERPRETER_TOOL = "CODE_INTERPRETER_TOOL", e.IMPORT_CSV = "IMPORT_CSV", e.EXPORT_CSV = "EXPORT_CSV", e.CONNECTED_ACCOUNTS = "CONNECTED_ACCOUNTS", e.PROFILE_INFORMATION = "PROFILE_INFORMATION", e))(Q || {});
97
97
  const Ee = (e) => {
98
98
  const t = [];
@@ -115,47 +115,52 @@ const Ee = (e) => {
115
115
  for (const n of e.fieldGroups)
116
116
  n.universalIdentifier || t.push("ViewFieldGroup must have a universalIdentifier");
117
117
  return l({ config: e, errors: t });
118
- }, $ = "__twentySdkExecutionContext__", g = "__twentySdkContextListeners__", x = () => (globalThis[g] || (globalThis[g] = /* @__PURE__ */ new Set()), globalThis[g]), w = () => globalThis[$], q = (e) => {
119
- x().add(e);
118
+ }, $ = "__twentySdkExecutionContext__", y = "__twentySdkContextListeners__", U = () => (globalThis[y] || (globalThis[y] = /* @__PURE__ */ new Set()), globalThis[y]), D = () => globalThis[$], q = (e) => {
119
+ U().add(e);
120
120
  }, X = (e) => {
121
- x().delete(e);
122
- }, Ie = () => {
123
- const e = S.closeSidePanel;
124
- if (!m(e))
121
+ U().delete(e);
122
+ }, Oe = () => {
123
+ const e = v.closeSidePanel;
124
+ if (!h(e))
125
125
  throw new Error("closeSidePanelFunction is not set");
126
126
  return e();
127
- }, A = (e) => {
128
- const t = S.enqueueSnackbar;
129
- if (!m(t))
127
+ }, g = (e) => {
128
+ const t = v.enqueueSnackbar;
129
+ if (!h(t))
130
130
  throw new Error("enqueueSnackbarFunction is not set");
131
131
  return t(e);
132
132
  }, J = (e, t, n, s) => {
133
- const u = S.navigate;
134
- if (!m(u))
133
+ const u = v.navigate;
134
+ if (!h(u))
135
135
  throw new Error("navigateFunction is not set");
136
136
  return u(e, t, n, s);
137
+ }, Te = (e) => {
138
+ const t = v.openAskAIWithPrompt;
139
+ if (!h(t))
140
+ throw new Error("openAskAIWithPromptFunction is not set");
141
+ return t(e);
137
142
  }, z = (e) => {
138
- const t = S.openSidePanelPage;
139
- if (!m(t))
143
+ const t = v.openSidePanelPage;
144
+ if (!h(t))
140
145
  throw new Error("openSidePanelPageFunction is not set");
141
146
  return t(e);
142
147
  }, P = () => {
143
- const e = S.unmountFrontComponent;
144
- if (!m(e))
148
+ const e = v.unmountFrontComponent;
149
+ if (!h(e))
145
150
  throw new Error("unmountFrontComponentFunction is not set");
146
151
  return e();
147
- }, U = (e) => {
152
+ }, R = (e) => {
148
153
  const [t, n] = T(
149
- () => e(w())
154
+ () => e(D())
150
155
  ), s = G(t);
151
156
  return b(() => {
152
157
  const u = () => {
153
- const i = e(w());
158
+ const i = e(D());
154
159
  i !== s.current && (s.current = i, n(i));
155
160
  };
156
161
  return q(u), u(), () => X(u);
157
162
  }, [e]), t;
158
- }, Z = (e) => e.frontComponentId, R = () => U(Z), ee = (e) => e.userId, Oe = () => U(ee), _ = (e) => `${e}-action-error`, Te = [
163
+ }, Z = (e) => e.frontComponentId, _ = () => R(Z), ee = (e) => e.recordId, be = () => R(ee), te = (e) => e.userId, Ce = () => R(te), L = (e) => `${e}-action-error`, Ae = [
159
164
  "click",
160
165
  "dblclick",
161
166
  "mousedown",
@@ -176,7 +181,7 @@ const Ee = (e) => {
176
181
  "wheel",
177
182
  "contextmenu",
178
183
  "drag"
179
- ], be = {
184
+ ], ye = {
180
185
  click: "onClick",
181
186
  dblclick: "onDoubleClick",
182
187
  mousedown: "onMouseDown",
@@ -216,7 +221,7 @@ const Ee = (e) => {
216
221
  stalled: "onStalled",
217
222
  suspend: "onSuspend",
218
223
  emptied: "onEmptied"
219
- }, Ce = {
224
+ }, ge = {
220
225
  id: { type: "string", optional: !0 },
221
226
  className: { type: "string", optional: !0 },
222
227
  style: { type: "string", optional: !0 },
@@ -226,8 +231,8 @@ const Ee = (e) => {
226
231
  "aria-label": { type: "string", optional: !0 },
227
232
  "aria-hidden": { type: "boolean", optional: !0 },
228
233
  "data-testid": { type: "string", optional: !0 }
229
- }, ye = ({ execute: e }) => {
230
- const [t, n] = T(!1), s = R();
234
+ }, Pe = ({ execute: e }) => {
235
+ const [t, n] = T(!1), s = _();
231
236
  return b(() => {
232
237
  if (t)
233
238
  return;
@@ -235,24 +240,24 @@ const Ee = (e) => {
235
240
  try {
236
241
  await e();
237
242
  } catch (i) {
238
- i instanceof Error && await A({
243
+ i instanceof Error && await g({
239
244
  message: "Action failed",
240
245
  detailedMessage: i.message,
241
246
  variant: "error",
242
- dedupeKey: _(s)
247
+ dedupeKey: L(s)
243
248
  });
244
249
  } finally {
245
250
  await P();
246
251
  }
247
252
  })();
248
253
  }, [e, t, s]), null;
249
- }, ge = ({
254
+ }, Re = ({
250
255
  to: e,
251
256
  params: t,
252
257
  queryParams: n,
253
258
  options: s
254
259
  }) => {
255
- const [u, i] = T(!1), p = R();
260
+ const [u, i] = T(!1), p = _();
256
261
  return b(() => {
257
262
  if (u)
258
263
  return;
@@ -260,25 +265,25 @@ const Ee = (e) => {
260
265
  try {
261
266
  await J(e, t, n, s);
262
267
  } catch (E) {
263
- E instanceof Error && await A({
268
+ E instanceof Error && await g({
264
269
  message: "Action failed",
265
270
  detailedMessage: E.message,
266
271
  variant: "error",
267
- dedupeKey: _(p)
272
+ dedupeKey: L(p)
268
273
  });
269
274
  } finally {
270
275
  await P();
271
276
  }
272
277
  })();
273
278
  }, [e, t, n, s, u, p]), null;
274
- }, Ae = ({
279
+ }, _e = ({
275
280
  page: e,
276
281
  pageTitle: t,
277
282
  pageIcon: n,
278
283
  onClick: s,
279
284
  shouldResetSearchState: u = !1
280
285
  }) => {
281
- const [i, p] = T(!1), v = R();
286
+ const [i, p] = T(!1), I = _();
282
287
  return b(() => {
283
288
  if (i)
284
289
  return;
@@ -291,12 +296,12 @@ const Ee = (e) => {
291
296
  pageIcon: n,
292
297
  shouldResetSearchState: u
293
298
  });
294
- } catch (I) {
295
- I instanceof Error && await A({
299
+ } catch (S) {
300
+ S instanceof Error && await g({
296
301
  message: "Action failed",
297
- detailedMessage: I.message,
302
+ detailedMessage: S.message,
298
303
  variant: "error",
299
- dedupeKey: _(v)
304
+ dedupeKey: L(I)
300
305
  });
301
306
  } finally {
302
307
  await P();
@@ -309,26 +314,26 @@ const Ee = (e) => {
309
314
  u,
310
315
  s,
311
316
  i,
312
- v
317
+ I
313
318
  ]), null;
314
319
  };
315
- class te {
320
+ class ne {
316
321
  constructor(t) {
317
322
  this.cssText = t;
318
323
  }
319
324
  }
320
- class ne extends Array {
325
+ class re extends Array {
321
326
  item(t) {
322
327
  return this[t] ?? null;
323
328
  }
324
329
  }
325
- class re {
330
+ class ie {
326
331
  constructor(t) {
327
- this.cssRules = new ne(), this.onChange = t;
332
+ this.cssRules = new re(), this.onChange = t;
328
333
  }
329
334
  insertRule(t, n) {
330
335
  const s = n ?? this.cssRules.length;
331
- return this.cssRules.splice(s, 0, new te(t)), this.notify(), s;
336
+ return this.cssRules.splice(s, 0, new ne(t)), this.notify(), s;
332
337
  }
333
338
  deleteRule(t) {
334
339
  this.cssRules.splice(t, 1), this.notify();
@@ -339,7 +344,7 @@ class re {
339
344
  this.onChange(t);
340
345
  }
341
346
  }
342
- const Pe = (e) => {
347
+ const Le = (e) => {
343
348
  const t = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), s = (r) => {
344
349
  if (t.has(r))
345
350
  return;
@@ -347,24 +352,24 @@ const Pe = (e) => {
347
352
  "remote-style"
348
353
  );
349
354
  t.set(r, o);
350
- const L = (r.getAttributeNames?.() ?? []).filter((a) => a.startsWith("data-")).map(
355
+ const F = (r.getAttributeNames?.() ?? []).filter((a) => a.startsWith("data-")).map(
351
356
  (a) => `${a}=${r.getAttribute(a) ?? ""}`
352
357
  ).join(";");
353
- L.length > 0 && (o.styleKey = L);
358
+ F.length > 0 && (o.styleKey = F);
354
359
  const O = () => {
355
360
  o.cssText = r.textContent ?? "";
356
- }, W = new re((a) => {
361
+ }, V = new ie((a) => {
357
362
  o.cssText = a;
358
363
  });
359
364
  try {
360
365
  Object.defineProperty(r, "sheet", {
361
- get: () => W,
366
+ get: () => V,
362
367
  configurable: !0
363
368
  });
364
369
  } catch {
365
370
  }
366
- const F = Object.getPrototypeOf(r), C = Object.getOwnPropertyDescriptor(r, "textContent") ?? Object.getOwnPropertyDescriptor(F, "textContent") ?? Object.getOwnPropertyDescriptor(
367
- Object.getPrototypeOf(F),
371
+ const M = Object.getPrototypeOf(r), C = Object.getOwnPropertyDescriptor(r, "textContent") ?? Object.getOwnPropertyDescriptor(M, "textContent") ?? Object.getOwnPropertyDescriptor(
372
+ Object.getPrototypeOf(M),
368
373
  "textContent"
369
374
  );
370
375
  if (C?.set) {
@@ -416,91 +421,93 @@ const Pe = (e) => {
416
421
  }), n.set(r, a));
417
422
  } catch {
418
423
  }
419
- const M = r.textContent;
420
- M && (o.cssText = M), e.appendChild(o);
424
+ const N = r.textContent;
425
+ N && (o.cssText = N), e.appendChild(o);
421
426
  }, u = (r) => {
422
427
  const o = n.get(r);
423
428
  o && (o.disconnect(), n.delete(r));
424
429
  const d = t.get(r);
425
430
  d && d.parentNode && (d.parentNode.removeChild(d), t.delete(r));
426
- }, i = document.head, p = i.appendChild.bind(i), v = i.insertBefore.bind(i), E = i.append.bind(i), I = i.prepend.bind(i), k = i.replaceChild.bind(i), j = i.removeChild.bind(i);
431
+ }, i = document.head, p = i.appendChild.bind(i), I = i.insertBefore.bind(i), E = i.append.bind(i), S = i.prepend.bind(i), k = i.replaceChild.bind(i), W = i.removeChild.bind(i);
427
432
  i.appendChild = (r) => {
428
433
  const o = p(r);
429
434
  return f(r) && s(r), o;
430
435
  }, i.insertBefore = (r, o) => {
431
- const d = v(r, o);
436
+ const d = I(r, o);
432
437
  return f(r) && s(r), d;
433
438
  }, i.append = (...r) => {
434
439
  E(...r);
435
440
  for (const o of r)
436
441
  f(o) && s(o);
437
442
  }, i.prepend = (...r) => {
438
- I(...r);
443
+ S(...r);
439
444
  for (const o of r)
440
445
  f(o) && s(o);
441
446
  }, i.replaceChild = (r, o) => {
442
447
  const d = k(r, o);
443
448
  return f(o) && u(o), f(r) && s(r), d;
444
449
  }, i.removeChild = (r) => {
445
- const o = j(r);
450
+ const o = W(r);
446
451
  return f(r) && u(r), o;
447
452
  };
448
- const V = Array.from(
453
+ const j = Array.from(
449
454
  i.querySelectorAll("style")
450
455
  );
451
- for (const r of V)
456
+ for (const r of j)
452
457
  s(r);
453
458
  Object.defineProperty(document, "styleSheets", {
454
459
  get: () => [],
455
460
  configurable: !0
456
461
  });
457
- }, f = (e) => typeof e != "string" && "localName" in e && e.localName === "style", Re = (e) => {
462
+ }, f = (e) => typeof e != "string" && "localName" in e && e.localName === "style", Fe = (e) => {
458
463
  for (const [t, n] of Object.entries(e))
459
464
  globalThis[t] = n;
460
465
  };
461
466
  export {
462
- Fe as ALLOWED_HTML_ELEMENTS,
463
- ye as Action,
464
- ge as ActionLink,
465
- Ae as ActionOpenSidePanelPage,
466
- Me as AggregateOperations,
467
- Ne as AppPath,
468
- Te as COMMON_HTML_EVENTS,
469
- we as CommandMenuPages,
470
- be as EVENT_TO_REACT,
471
- N as FieldType,
472
- Ce as HTML_COMMON_PROPERTIES,
473
- De as HTML_TAG_TO_REMOTE_COMPONENT,
474
- h as ObjectRecordGroupByDateGranularity,
475
- xe as OnDeleteAction,
476
- Ue as PageLayoutTabLayoutMode,
467
+ we as ALLOWED_HTML_ELEMENTS,
468
+ Pe as Action,
469
+ Re as ActionLink,
470
+ _e as ActionOpenSidePanelPage,
471
+ De as AggregateOperations,
472
+ xe as AppPath,
473
+ Ae as COMMON_HTML_EVENTS,
474
+ Ue as CommandMenuPages,
475
+ ye as EVENT_TO_REACT,
476
+ w as FieldType,
477
+ ge as HTML_COMMON_PROPERTIES,
478
+ ke as HTML_TAG_TO_REMOTE_COMPONENT,
479
+ m as ObjectRecordGroupByDateGranularity,
480
+ We as OnDeleteAction,
481
+ je as PageLayoutTabLayoutMode,
477
482
  Q as PermissionFlag,
478
- ke as RelationType,
479
- je as STANDARD_OBJECT,
480
- Ve as STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS,
481
- Ie as closeSidePanel,
483
+ Ve as RelationType,
484
+ Ke as STANDARD_OBJECT,
485
+ He as STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS,
486
+ Oe as closeSidePanel,
482
487
  l as createValidationResult,
483
- ae as defineApplication,
484
- le as defineField,
485
- ue as defineFrontComponent,
486
- de as defineLogicFunction,
487
- fe as defineNavigationMenuItem,
488
- he as defineObject,
489
- me as definePageLayout,
490
- pe as definePostInstallLogicFunction,
491
- ce as definePreInstallLogicFunction,
492
- ve as defineRole,
488
+ ue as defineApplication,
489
+ de as defineField,
490
+ le as defineFrontComponent,
491
+ ce as defineLogicFunction,
492
+ he as defineNavigationMenuItem,
493
+ me as defineObject,
494
+ ve as definePageLayout,
495
+ fe as definePostInstallLogicFunction,
496
+ pe as definePreInstallLogicFunction,
497
+ Ie as defineRole,
493
498
  Ee as defineSkill,
494
499
  Se as defineView,
495
- A as enqueueSnackbar,
496
- Re as exposeGlobals,
497
- _ as getFrontComponentActionErrorDedupeKey,
498
- Pe as installStyleBridge,
500
+ g as enqueueSnackbar,
501
+ Fe as exposeGlobals,
502
+ L as getFrontComponentActionErrorDedupeKey,
503
+ Le as installStyleBridge,
499
504
  J as navigate,
505
+ Te as openAskAIWithPrompt,
500
506
  z as openSidePanelPage,
501
507
  P as unmountFrontComponent,
502
- U as useFrontComponentExecutionContext,
503
- R as useFrontComponentId,
504
- Oe as useUserId,
505
- D as validateFields
508
+ R as useFrontComponentExecutionContext,
509
+ _ as useFrontComponentId,
510
+ be as useRecordId,
511
+ Ce as useUserId,
512
+ x as validateFields
506
513
  };
@@ -0,0 +1,2 @@
1
+ import { type OpenAskAIWithPromptFunction } from '../globals/frontComponentHostCommunicationApi';
2
+ export declare const openAskAIWithPrompt: OpenAskAIWithPromptFunction;
@@ -0,0 +1,12 @@
1
+ import { isDefined as n } from "twenty-shared/utils";
2
+ import { frontComponentHostCommunicationApi as r } from "../globals/frontComponentHostCommunicationApi.js";
3
+ const e = (t) => {
4
+ const o = r.openAskAIWithPrompt;
5
+ if (!n(o))
6
+ throw new Error("openAskAIWithPromptFunction is not set");
7
+ return o(t);
8
+ };
9
+ export {
10
+ e as openAskAIWithPrompt
11
+ };
12
+ //# sourceMappingURL=openAskAIWithPrompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openAskAIWithPrompt.js","sources":["../../../../src/sdk/front-component-api/functions/openAskAIWithPrompt.ts"],"sourcesContent":["import { isDefined } from 'twenty-shared/utils';\n\nimport {\n frontComponentHostCommunicationApi,\n type OpenAskAIWithPromptFunction,\n} from '../globals/frontComponentHostCommunicationApi';\n\nexport const openAskAIWithPrompt: OpenAskAIWithPromptFunction = (params) => {\n const openAskAIWithPromptFunction =\n frontComponentHostCommunicationApi.openAskAIWithPrompt;\n\n if (!isDefined(openAskAIWithPromptFunction)) {\n throw new Error('openAskAIWithPromptFunction is not set');\n }\n\n return openAskAIWithPromptFunction(params);\n};\n"],"names":["openAskAIWithPrompt","params","openAskAIWithPromptFunction","frontComponentHostCommunicationApi","isDefined"],"mappings":";;AAOO,MAAMA,IAAmD,CAACC,MAAW;AAC1E,QAAMC,IACJC,EAAmC;AAErC,MAAI,CAACC,EAAUF,CAA2B;AACxC,UAAM,IAAI,MAAM,wCAAwC;AAG1D,SAAOA,EAA4BD,CAAM;AAC3C;"}
@@ -11,6 +11,9 @@ export type UnmountFrontComponentFunction = () => Promise<void>;
11
11
  export type EnqueueSnackbarFunction = (params: EnqueueSnackbarParams) => Promise<void>;
12
12
  export type CloseSidePanelFunction = () => Promise<void>;
13
13
  export type RequestAccessTokenRefreshFunction = () => Promise<string>;
14
+ export type OpenAskAIWithPromptFunction = (params: {
15
+ prompt: string;
16
+ }) => Promise<void>;
14
17
  export type FrontComponentHostCommunicationApiStore = {
15
18
  navigate?: NavigateFunction;
16
19
  requestAccessTokenRefresh?: RequestAccessTokenRefreshFunction;
@@ -18,6 +21,7 @@ export type FrontComponentHostCommunicationApiStore = {
18
21
  unmountFrontComponent?: UnmountFrontComponentFunction;
19
22
  enqueueSnackbar?: EnqueueSnackbarFunction;
20
23
  closeSidePanel?: CloseSidePanelFunction;
24
+ openAskAIWithPrompt?: OpenAskAIWithPromptFunction;
21
25
  };
22
26
  declare global {
23
27
  var frontComponentHostCommunicationApi: FrontComponentHostCommunicationApiStore;