twenty-sdk 2.25.0 → 2.27.0
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/LICENSE +21 -0
- package/dist/billing/index.cjs.map +1 -1
- package/dist/billing/index.mjs +1 -1
- package/dist/billing/index.mjs.map +1 -1
- package/dist/{catalog-sync-BQ4qqj5b.js → catalog-sync-Bh6piElD.js} +1 -1
- package/dist/{catalog-sync-Bd0XMuNL.mjs → catalog-sync-DV73gNDG.mjs} +1 -1
- package/dist/cli/utilities/entity/entity-page-layout-template.d.ts +1 -1
- package/dist/cli.cjs +18 -12
- package/dist/cli.mjs +3260 -3251
- package/dist/define/index.cjs +18 -18
- package/dist/define/index.cjs.map +1 -1
- package/dist/define/index.d.ts +834 -1295
- package/dist/define/index.mjs +5927 -5835
- package/dist/define/index.mjs.map +1 -1
- package/dist/front-component/index.cjs.map +1 -1
- package/dist/front-component/index.mjs +1 -1
- package/dist/front-component/index.mjs.map +1 -1
- package/dist/front-component-renderer/build.cjs +1 -1
- package/dist/front-component-renderer/build.mjs +1 -1
- package/dist/{get-front-component-build-plugins-klRAsPTE.mjs → get-front-component-build-plugins-B5IvUvSS.mjs} +1 -1
- package/dist/{get-front-component-build-plugins-C7h3DVdC.js → get-front-component-build-plugins-TJrFS3_p.js} +1 -1
- package/dist/{get-function-input-schema-GNk3NRLJ-DmwN8d1n.mjs → get-function-input-schema-GNk3NRLJ-CVWRriuo.mjs} +1 -1
- package/dist/logic-function/index.cjs +7 -7
- package/dist/logic-function/index.cjs.map +1 -1
- package/dist/logic-function/index.d.ts +17 -2
- package/dist/logic-function/index.mjs +58 -50
- package/dist/logic-function/index.mjs.map +1 -1
- package/dist/{login-CjlKXuH6.mjs → login-DhEE-uFP.mjs} +6020 -5925
- package/dist/{login-C1meSrEJ.js → login-wTIo0AV7.js} +52 -52
- package/dist/operations.cjs +1 -1
- package/dist/operations.mjs +1 -1
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.mjs +1 -1
- package/dist/utils/index.mjs.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../get-front-component-build-plugins-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../get-front-component-build-plugins-TJrFS3_p.js");exports.getFrontComponentBuildPlugins=e.t;
|
|
@@ -2,5 +2,5 @@ import { createRequire as e } from "node:module";
|
|
|
2
2
|
import { fileURLToPath as t } from "node:url";
|
|
3
3
|
import { dirname as n } from "node:path";
|
|
4
4
|
e(import.meta.url), n(t(import.meta.url));
|
|
5
|
-
import { t as r } from "../get-front-component-build-plugins-
|
|
5
|
+
import { t as r } from "../get-front-component-build-plugins-B5IvUvSS.mjs";
|
|
6
6
|
export { r as getFrontComponentBuildPlugins };
|
|
@@ -71,7 +71,7 @@ var o = (e) => `if (typeof document !== 'undefined') {
|
|
|
71
71
|
}));
|
|
72
72
|
}
|
|
73
73
|
};
|
|
74
|
-
}, f = /import\s*\{\s*
|
|
74
|
+
}, f = /import\s*\{\s*define(?:Settings)?FrontComponent\s*\}\s*from\s*['"][^'"]+['"];?\n?/g, p = /export\s+default\s+define(?:Settings)?FrontComponent\s*\(/, m = /component\s*:\s*([A-Za-z_$][\w$]*)\s*[,}]/, h = "__frontComponentDefinition", g = (e) => {
|
|
75
75
|
let t = e.replace(f, "");
|
|
76
76
|
if (!p.test(t)) return t;
|
|
77
77
|
t = t.replace(p, `const ${h} = (`);
|
|
@@ -167,6 +167,6 @@ function createElement(type) {
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
export { createElement };
|
|
170
|
-
export default Object.assign({}, _React, { createElement: createElement });`,_=e=>{let t=e?.usePreact??!1,n=t?`preact/jsx-runtime`:`react/jsx-runtime`,r=t?`preact/compat`:`react`;return{name:`jsx-runtime-remote-wrapper`,setup:e=>{let t,i;e.onResolve({filter:/^__jsx_shared_helpers__$/},()=>({path:`__jsx_shared_helpers__`,namespace:`jsx-shared-helpers`})),e.onLoad({filter:/.*/,namespace:`jsx-shared-helpers`},()=>({contents:m,loader:`js`})),e.onResolve({filter:/^react\/jsx-runtime$/},async r=>{if(!r.pluginData?.skipJsxWrapper)return t||=(await e.resolve(n,{kind:r.kind,resolveDir:r.resolveDir,pluginData:{skipJsxWrapper:!0}})).path,{path:`react/jsx-runtime`,namespace:`jsx-runtime-wrapper`}}),e.onResolve({filter:/^__real_react_jsx_runtime__$/},()=>{if(!t)throw Error(`jsx-runtime-remote-wrapper: real jsx-runtime path not resolved yet`);return{path:t}}),e.onLoad({filter:/.*/,namespace:`jsx-runtime-wrapper`},()=>({contents:h,loader:`js`})),e.onResolve({filter:/^react$/},async t=>{if(!t.pluginData?.skipJsxWrapper)return i||=(await e.resolve(r,{kind:t.kind,resolveDir:t.resolveDir,pluginData:{skipJsxWrapper:!0}})).path,{path:`react`,namespace:`react-wrapper`}}),e.onResolve({filter:/^__real_react__$/},()=>{if(!i)throw Error(`jsx-runtime-remote-wrapper: real react path not resolved yet`);return{path:i}}),e.onLoad({filter:/.*/,namespace:`react-wrapper`},()=>({contents:g,loader:`js`}))}}},v=/import\s*\{\s*
|
|
170
|
+
export default Object.assign({}, _React, { createElement: createElement });`,_=e=>{let t=e?.usePreact??!1,n=t?`preact/jsx-runtime`:`react/jsx-runtime`,r=t?`preact/compat`:`react`;return{name:`jsx-runtime-remote-wrapper`,setup:e=>{let t,i;e.onResolve({filter:/^__jsx_shared_helpers__$/},()=>({path:`__jsx_shared_helpers__`,namespace:`jsx-shared-helpers`})),e.onLoad({filter:/.*/,namespace:`jsx-shared-helpers`},()=>({contents:m,loader:`js`})),e.onResolve({filter:/^react\/jsx-runtime$/},async r=>{if(!r.pluginData?.skipJsxWrapper)return t||=(await e.resolve(n,{kind:r.kind,resolveDir:r.resolveDir,pluginData:{skipJsxWrapper:!0}})).path,{path:`react/jsx-runtime`,namespace:`jsx-runtime-wrapper`}}),e.onResolve({filter:/^__real_react_jsx_runtime__$/},()=>{if(!t)throw Error(`jsx-runtime-remote-wrapper: real jsx-runtime path not resolved yet`);return{path:t}}),e.onLoad({filter:/.*/,namespace:`jsx-runtime-wrapper`},()=>({contents:h,loader:`js`})),e.onResolve({filter:/^react$/},async t=>{if(!t.pluginData?.skipJsxWrapper)return i||=(await e.resolve(r,{kind:t.kind,resolveDir:t.resolveDir,pluginData:{skipJsxWrapper:!0}})).path,{path:`react`,namespace:`react-wrapper`}}),e.onResolve({filter:/^__real_react__$/},()=>{if(!i)throw Error(`jsx-runtime-remote-wrapper: real react path not resolved yet`);return{path:i}}),e.onLoad({filter:/.*/,namespace:`react-wrapper`},()=>({contents:g,loader:`js`}))}}},v=/import\s*\{\s*define(?:Settings)?FrontComponent\s*\}\s*from\s*['"][^'"]+['"];?\n?/g,y=/export\s+default\s+define(?:Settings)?FrontComponent\s*\(/,b=/component\s*:\s*([A-Za-z_$][\w$]*)\s*[,}]/,x=`__frontComponentDefinition`,S=e=>{let t=e.replace(v,``);if(!y.test(t))return t;t=t.replace(y,`const ${x} = (`);let n=t.match(b);if(n){let e=n[1];t=t.replace(RegExp(`export\\s+(const|function)\\s+${e}\\b`),`$1 ${e}`)}return`import { createRoot as __createRoot } from 'react-dom/client';
|
|
171
171
|
import { jsx as __frontComponentJsx } from 'react/jsx-runtime';
|
|
172
172
|
`+t+`\nexport default function __renderFrontComponent(__container) { __createRoot(__container).render(__frontComponentJsx(${x}.component, {})); }\n`},C={name:`jsx-transform-to-remote-dom-worker-format-plugin`,setup:e=>{e.onLoad({filter:/\.tsx$/},async({path:e})=>{try{return{contents:S(await(0,d.readFile)(e,`utf8`)),loader:`tsx`}}catch(t){return{errors:[{text:`Failed to transform front component: ${t instanceof Error?t.message:String(t)}`,location:{file:e}}]}}})}},w=()=>({name:`preact-alias`,setup:e=>{let t;e.onResolve({filter:/^react-dom\/client$/},async n=>(t||=(await e.resolve(`preact/compat/client`,{kind:n.kind,resolveDir:n.resolveDir})).path,{path:t})),e.onResolve({filter:/^react-dom$/},async t=>({path:(await e.resolve(`preact/compat`,{kind:t.kind,resolveDir:t.resolveDir})).path}))}}),T=/^\/\/.*$\n/gm,E={name:`strip-comments`,setup:e=>{e.onEnd(async e=>{if(e.errors.length>0)return;let t=Object.keys(e.metafile?.outputs??{}).filter(e=>e.endsWith(`.mjs`));for(let e of t){let t=u.default.resolve(e),n=await(0,d.readFile)(t,`utf-8`),r=n.replace(T,``);r!==n&&await(0,d.writeFile)(t,r,`utf-8`)}})}},D=e=>[_(e?.usePreact?{usePreact:!0}:void 0),...e?.usePreact?[w()]:[],C,p,E];Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return D}});
|
|
@@ -2,7 +2,7 @@ import { createRequire as e } from "node:module";
|
|
|
2
2
|
import { fileURLToPath as t } from "node:url";
|
|
3
3
|
import { dirname as n } from "node:path";
|
|
4
4
|
e(import.meta.url), n(t(import.meta.url));
|
|
5
|
-
import {
|
|
5
|
+
import { kt as r } from "./login-DhEE-uFP.mjs";
|
|
6
6
|
import { ScriptTarget as i, SyntaxKind as a, createSourceFile as o } from "typescript";
|
|
7
7
|
//#region ../twenty-shared/dist/get-function-input-schema-GNk3NRLJ.mjs
|
|
8
8
|
var s = "TwentyRecord", c = (e) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./isDefined-Dtu5EYqP-Dp026Ry1.js");let t=require("@sniptt/guards");require("uuid");
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./isDefined-Dtu5EYqP-Dp026Ry1.js");let t=require("@sniptt/guards");require("uuid");let n=require("twenty-client-sdk/metadata");var r=e=>(e?.type===`record`||e?.type===`object`)&&(0,t.isNonEmptyString)(e.objectUniversalIdentifier),i=(e,n)=>{let r=(0,t.isNonEmptyString)(e)?n?.(e):void 0;return`Id of the ${(0,t.isNonEmptyString)(r)?r:`linked`} record`},a=(n,o)=>{if(r(n))return{type:`string`,description:i(n.objectUniversalIdentifier,o)};if(n.type===`records`)return{type:`array`,items:{type:`string`,description:i(n.objectUniversalIdentifier,o)}};let{objectUniversalIdentifier:s,multiline:c,label:l,items:u,properties:d,additionalProperties:f,...p}=n,m={...p};return e.t(u)&&(m.items=a(u,o)),e.t(d)&&(m.properties=Object.fromEntries(Object.entries(d).map(([e,t])=>[e,a(t,o)]))),e.t(f)&&(m.additionalProperties=(0,t.isObject)(f)?a(f,o):f),m},o=e=>{let n={type:`unknown`};switch(e.type){case`string`:n.type=`string`;break;case`number`:case`integer`:n.type=`number`;break;case`boolean`:n.type=`boolean`;break;case`array`:n.type=`array`,e.items&&(n.items=o(e.items));break;case`object`:n.type=`object`,e.properties&&(n.properties=Object.fromEntries(Object.entries(e.properties).map(([e,t])=>[e,o(t)])));break;case`record`:n.type=`record`;break;case`records`:n.type=`records`;break;default:n.type=`unknown`}return Array.isArray(e.enum)&&(n.enum=e.enum.filter(e=>typeof e==`string`)),e.multiline===!0&&(n.multiline=!0),(0,t.isNonEmptyString)(e.label)&&(n.label=e.label),(0,t.isNonEmptyString)(e.objectUniversalIdentifier)&&(n.objectUniversalIdentifier=e.objectUniversalIdentifier),n},s=e=>[o(e)];s({type:`object`,properties:{a:{type:`string`},b:{type:`number`}}});var c=t=>!e.t(t)||t===null?`unknown`:typeof t==`string`?`string`:typeof t==`number`?`number`:typeof t==`boolean`?`boolean`:Array.isArray(t)?`array`:`unknown`,l=e=>e?Object.entries(e).reduce((e,[n,r])=>((0,t.isObject)(r)&&!Array.isArray(r)?e[n]={isLeaf:!1,type:`object`,label:n,value:l(r)}:e[n]={isLeaf:!0,value:r,type:c(r),label:n},e),{}):{},u=(e,t)=>e?`${e}.${t}`:t,d=(t,n,r=``)=>{let i=[];for(let[a,o]of Object.entries(n)){let n=u(r,a),s=t[a];if(!e.t(s)){i.push(`Missing key "${n}" in declared output schema.`);continue}if(o.isLeaf!==s.isLeaf){i.push(`Type mismatch at "${n}": expected ${o.isLeaf?o.type:`object`} but declared ${s.isLeaf?s.type:`object`}.`);continue}if(!o.isLeaf&&!s.isLeaf){i.push(...d(s.value,o.value,n));continue}o.isLeaf&&s.isLeaf&&o.type!==`unknown`&&s.type!==`unknown`&&o.type!==s.type&&i.push(`Type mismatch at "${n}": expected ${o.type} but declared ${s.type}.`)}return i},f=[`string`,`number`,`boolean`,`array`,`unknown`],p=e=>f.includes(e),m=(e,n)=>{let r=n.label??e;return n.type===`record`?{isLeaf:!0,type:`string`,label:r,value:null}:n.type===`records`?{isLeaf:!0,type:`array`,label:r,value:null}:n.type===`object`?{isLeaf:!1,type:`object`,label:r,value:(0,t.isObject)(n.properties)?h(n.properties):{}}:{isLeaf:!0,type:p(n.type)?n.type:`unknown`,label:r,value:null}},h=e=>Object.entries(e).reduce((e,[t,n])=>(e[t]=m(t,n),e),{}),g=class extends Error{constructor(e){super(`App connection ${e} requires the user to reconnect (authFailedAt is set). Surface a "Reconnect" prompt in your UI.`),this.name=`AppConnectionAuthFailedError`,this.connectionId=e}},_=function(e){return e.ACTOR=`ACTOR`,e.ADDRESS=`ADDRESS`,e.ARRAY=`ARRAY`,e.BOOLEAN=`BOOLEAN`,e.CURRENCY=`CURRENCY`,e.DATE=`DATE`,e.DATE_TIME=`DATE_TIME`,e.EMAILS=`EMAILS`,e.FILES=`FILES`,e.FULL_NAME=`FULL_NAME`,e.LINKS=`LINKS`,e.MORPH_RELATION=`MORPH_RELATION`,e.MULTI_SELECT=`MULTI_SELECT`,e.NUMBER=`NUMBER`,e.NUMERIC=`NUMERIC`,e.PHONES=`PHONES`,e.POSITION=`POSITION`,e.RATING=`RATING`,e.RAW_JSON=`RAW_JSON`,e.RELATION=`RELATION`,e.RICH_TEXT=`RICH_TEXT`,e.SELECT=`SELECT`,e.TEXT=`TEXT`,e.TS_VECTOR=`TS_VECTOR`,e.UUID=`UUID`,e}({});_.TEXT,_.ARRAY,_.BOOLEAN,_.DATE,_.DATE_TIME,_.NUMBER,_.NUMERIC,_.RAW_JSON,_.RICH_TEXT,_.SELECT,_.MULTI_SELECT;var v=`TWENTY_API_URL`,y=`TWENTY_APP_ACCESS_TOKEN`,b=async({query:e,variables:t,caller:n})=>{let r=process.env[v],i=process.env[y];if(!r||!i)throw Error(`${n}() requires the app runtime env vars ${v} and ${y}.`);let a=await fetch(`${r}/metadata`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${i}`},body:JSON.stringify({query:e,variables:t})});if(!a.ok)throw Error(`${n}() failed: HTTP ${a.status} ${a.statusText}`);let o=await a.json();if(o.errors&&o.errors.length>0)throw Error(`${n}() failed: ${o.errors.map(e=>e.message).join(`, `)}`);if(!o.data)throw Error(`${n}() failed: response contained no data.`);return o.data},x=`
|
|
2
2
|
query GetAppConnection($id: ID!) {
|
|
3
3
|
appConnection(id: $id) {
|
|
4
4
|
id
|
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
12
12
|
authFailedAt
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
`,
|
|
15
|
+
`,S=async e=>{let{appConnection:t}=await b({query:x,variables:{id:e},caller:`getConnection`});if(t.authFailedAt!==null)throw new g(t.id);return t},C=`
|
|
16
16
|
query ListAppConnections($filter: ListAppConnectionsInput) {
|
|
17
17
|
appConnections(filter: $filter) {
|
|
18
18
|
id
|
|
@@ -26,7 +26,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
26
26
|
authFailedAt
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
`,
|
|
29
|
+
`,w=async(e={})=>{let{appConnections:t}=await b({query:C,variables:{filter:e},caller:`listConnections`});return t},T=(e,t)=>{if(t.userWorkspaceId!==null){let n=e.find(e=>e.visibility===`user`&&e.userWorkspaceId===t.userWorkspaceId);if(n)return n}return e.find(e=>e.visibility===`workspace`)??null},E=`
|
|
30
30
|
mutation RunAgent($input: RunAgentInput!) {
|
|
31
31
|
runAgent(input: $input) {
|
|
32
32
|
result
|
|
@@ -34,7 +34,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
34
34
|
success
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
`,
|
|
37
|
+
`,D=async e=>{let{runAgent:t}=await b({query:E,variables:{input:e},caller:`runAgent`});return t},O=async e=>{let{enqueueJob:t}=await new n.MetadataApiClient().mutation({enqueueJob:{__args:{input:e},enqueued:!0,logicFunctionUniversalIdentifier:!0}});return t},k=`
|
|
38
38
|
query GetAppKeyValue($key: String!, $scope: AppKeyValueScope) {
|
|
39
39
|
appKeyValue(key: $key, scope: $scope) {
|
|
40
40
|
key
|
|
@@ -42,7 +42,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
42
42
|
scope
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
`,
|
|
45
|
+
`,A=`
|
|
46
46
|
mutation SetAppKeyValue($input: SetAppKeyValueInput!) {
|
|
47
47
|
setAppKeyValue(input: $input) {
|
|
48
48
|
key
|
|
@@ -50,9 +50,9 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
50
50
|
scope
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
`,
|
|
53
|
+
`,j=`
|
|
54
54
|
mutation DeleteAppKeyValue($key: String!, $scope: AppKeyValueScope) {
|
|
55
55
|
deleteAppKeyValue(key: $key, scope: $scope)
|
|
56
56
|
}
|
|
57
|
-
`,
|
|
57
|
+
`,M=`WORKSPACE`,N={async get(e,t){let{appKeyValue:n}=await b({query:k,variables:{key:e,scope:t?.scope??M},caller:`kv.get`});return n?.value??null},async set(e,t,n){await b({query:A,variables:{input:{key:e,value:t,scope:n?.scope??M}},caller:`kv.set`})},async delete(e,t){let{deleteAppKeyValue:n}=await b({query:j,variables:{key:e,scope:t?.scope??M},caller:`kv.delete`});return n}},P=class{constructor(e,t){this.__twentyHttpResponse=!0,this.body=e,this.status=t?.status,this.headers=t?.headers}};exports.AppConnectionAuthFailedError=g,exports.Response=P,exports.enqueueJob=O,exports.findConnectionForRequest=T,exports.getConnection=S,exports.jsonSchemaToInputSchema=s,exports.kv=N,exports.listConnections=w,exports.runAgent=D;
|
|
58
58
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["t","i","t","e","o","s","l","u","d","f","p","m","h","g","_","v","y","b","e","t","c","e","i","n","t"],"sources":["../../../twenty-shared/dist/is-record-object-schema-CwzshFdt.mjs","../../../twenty-shared/dist/logic-function.mjs","../../src/sdk/logic-function/connections/errors/app-connection-auth-failed.error.ts","../../../twenty-shared/dist/ViewKey-YV4NySfb.mjs","../../../twenty-shared/dist/get-system-relation-field-universal-identifier.util-DGoOUfu_.mjs","../../../twenty-shared/dist/application.mjs","../../src/sdk/logic-function/utils/post-graphql-request.util.ts","../../src/sdk/logic-function/connections/get-connection.ts","../../src/sdk/logic-function/connections/list-connections.ts","../../src/sdk/logic-function/connections/find-connection-for-request.ts","../../src/sdk/logic-function/agents/run-agent.ts","../../src/sdk/logic-function/key-value/kv.ts","../../src/sdk/logic-function/response.ts"],"sourcesContent":["import { isNonEmptyString as e } from \"@sniptt/guards\";\n//#region src/logic-function/is-record-object-schema.ts\nvar t = (t) => (t?.type === \"record\" || t?.type === \"object\") && e(t.objectUniversalIdentifier);\n//#endregion\nexport { t };\n","import { t as e } from \"./isDefined-Dtu5EYqP.mjs\";\nimport { t } from \"./is-record-object-schema-CwzshFdt.mjs\";\nimport { isNonEmptyString as n, isObject as r } from \"@sniptt/guards\";\n//#region src/logic-function/build-tool-input-json-schema.ts\nvar i = (e, t) => {\n\tlet r = n(e) ? t?.(e) : void 0;\n\treturn `Id of the ${n(r) ? r : \"linked\"} record`;\n}, a = (n, o) => {\n\tif (t(n)) return {\n\t\ttype: \"string\",\n\t\tdescription: i(n.objectUniversalIdentifier, o)\n\t};\n\tif (n.type === \"records\") return {\n\t\ttype: \"array\",\n\t\titems: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: i(n.objectUniversalIdentifier, o)\n\t\t}\n\t};\n\tlet { objectUniversalIdentifier: s, multiline: c, label: l, items: u, properties: d, additionalProperties: f, ...p } = n, m = { ...p };\n\treturn e(u) && (m.items = a(u, o)), e(d) && (m.properties = Object.fromEntries(Object.entries(d).map(([e, t]) => [e, a(t, o)]))), e(f) && (m.additionalProperties = r(f) ? a(f, o) : f), m;\n}, o = {\n\ttype: \"object\",\n\tproperties: {}\n}, s = (e) => {\n\tlet t = { type: \"unknown\" };\n\tswitch (e.type) {\n\t\tcase \"string\":\n\t\t\tt.type = \"string\";\n\t\t\tbreak;\n\t\tcase \"number\":\n\t\tcase \"integer\":\n\t\t\tt.type = \"number\";\n\t\t\tbreak;\n\t\tcase \"boolean\":\n\t\t\tt.type = \"boolean\";\n\t\t\tbreak;\n\t\tcase \"array\":\n\t\t\tt.type = \"array\", e.items && (t.items = s(e.items));\n\t\t\tbreak;\n\t\tcase \"object\":\n\t\t\tt.type = \"object\", e.properties && (t.properties = Object.fromEntries(Object.entries(e.properties).map(([e, t]) => [e, s(t)])));\n\t\t\tbreak;\n\t\tcase \"record\":\n\t\t\tt.type = \"record\";\n\t\t\tbreak;\n\t\tcase \"records\":\n\t\t\tt.type = \"records\";\n\t\t\tbreak;\n\t\tdefault: t.type = \"unknown\";\n\t}\n\treturn Array.isArray(e.enum) && (t.enum = e.enum.filter((e) => typeof e == \"string\")), e.multiline === !0 && (t.multiline = !0), n(e.label) && (t.label = e.label), n(e.objectUniversalIdentifier) && (t.objectUniversalIdentifier = e.objectUniversalIdentifier), t;\n}, c = (e) => [s(e)], l = { inputSchema: c({\n\ttype: \"object\",\n\tproperties: {\n\t\ta: { type: \"string\" },\n\t\tb: { type: \"number\" }\n\t}\n}) }, u = async (t) => {\n\tlet { getFunctionInputSchema: n } = await import(\"./get-function-input-schema-GNk3NRLJ.mjs\"), r = n(t)[0];\n\treturn r?.type === \"object\" && e(r.properties) ? {\n\t\ttype: \"object\",\n\t\tproperties: r.properties\n\t} : o;\n}, d = (t) => !e(t) || t === null ? \"unknown\" : typeof t == \"string\" ? \"string\" : typeof t == \"number\" ? \"number\" : typeof t == \"boolean\" ? \"boolean\" : Array.isArray(t) ? \"array\" : \"unknown\", f = (e) => e ? Object.entries(e).reduce((e, [t, n]) => (r(n) && !Array.isArray(n) ? e[t] = {\n\tisLeaf: !1,\n\ttype: \"object\",\n\tlabel: t,\n\tvalue: f(n)\n} : e[t] = {\n\tisLeaf: !0,\n\tvalue: n,\n\ttype: d(n),\n\tlabel: t\n}, e), {}) : {}, p = (e, t) => e ? `${e}.${t}` : t, m = (t, n, r = \"\") => {\n\tlet i = [];\n\tfor (let [a, o] of Object.entries(n)) {\n\t\tlet n = p(r, a), s = t[a];\n\t\tif (!e(s)) {\n\t\t\ti.push(`Missing key \"${n}\" in declared output schema.`);\n\t\t\tcontinue;\n\t\t}\n\t\tif (o.isLeaf !== s.isLeaf) {\n\t\t\ti.push(`Type mismatch at \"${n}\": expected ${o.isLeaf ? o.type : \"object\"} but declared ${s.isLeaf ? s.type : \"object\"}.`);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!o.isLeaf && !s.isLeaf) {\n\t\t\ti.push(...m(s.value, o.value, n));\n\t\t\tcontinue;\n\t\t}\n\t\to.isLeaf && s.isLeaf && o.type !== \"unknown\" && s.type !== \"unknown\" && o.type !== s.type && i.push(`Type mismatch at \"${n}\": expected ${o.type} but declared ${s.type}.`);\n\t}\n\treturn i;\n}, h = [\n\t\"string\",\n\t\"number\",\n\t\"boolean\",\n\t\"array\",\n\t\"unknown\"\n], g = (e) => h.includes(e), _ = (e, t) => {\n\tlet n = t.label ?? e;\n\treturn t.type === \"record\" ? {\n\t\tisLeaf: !0,\n\t\ttype: \"string\",\n\t\tlabel: n,\n\t\tvalue: null\n\t} : t.type === \"records\" ? {\n\t\tisLeaf: !0,\n\t\ttype: \"array\",\n\t\tlabel: n,\n\t\tvalue: null\n\t} : t.type === \"object\" ? {\n\t\tisLeaf: !1,\n\t\ttype: \"object\",\n\t\tlabel: n,\n\t\tvalue: r(t.properties) ? v(t.properties) : {}\n\t} : {\n\t\tisLeaf: !0,\n\t\ttype: g(t.type) ? t.type : \"unknown\",\n\t\tlabel: n,\n\t\tvalue: null\n\t};\n}, v = (e) => Object.entries(e).reduce((e, [t, n]) => (e[t] = _(t, n), e), {}), y = (e) => {\n\tlet t = e[0];\n\treturn t?.type !== \"object\" || !r(t.properties) ? {} : v(t.properties);\n}, b = (e) => e?.type === \"records\" && n(e.objectUniversalIdentifier) || e?.type === \"array\" && t(e?.items);\n//#endregion\nexport { o as DEFAULT_TOOL_INPUT_SCHEMA, l as SEED_WORKFLOW_ACTION_TRIGGER_SETTINGS, a as buildToolInputJsonSchema, u as getInputSchemaFromSourceCode, f as getOutputSchemaFromValue, m as getOutputSchemaMismatchIssues, y as inputSchemaToOutputSchema, b as isRecordArraySchema, t as isRecordObjectSchema, c as jsonSchemaToInputSchema };\n","// Thrown when the platform asks the SDK to operate on a connection whose\n// OAuth refresh failed permanently (`authFailedAt` is set). The end user\n// must reconnect from the app's settings tab — the app cannot recover on\n// its own.\n//\n// `listConnections` filters these out by default (the user can't act on\n// them anyway). `getConnection` throws this when the looked-up connection\n// is in this state, so a stored connection id can be safely retried until\n// it works again.\nexport class AppConnectionAuthFailedError extends Error {\n readonly connectionId: string;\n\n constructor(connectionId: string) {\n super(\n `App connection ${connectionId} requires the user to reconnect ` +\n `(authFailedAt is set). Surface a \"Reconnect\" prompt in your UI.`,\n );\n this.name = 'AppConnectionAuthFailedError';\n this.connectionId = connectionId;\n }\n}\n","//#region src/types/FieldMetadataType.ts\nvar e = /* @__PURE__ */ function(e) {\n\treturn e.ACTOR = \"ACTOR\", e.ADDRESS = \"ADDRESS\", e.ARRAY = \"ARRAY\", e.BOOLEAN = \"BOOLEAN\", e.CURRENCY = \"CURRENCY\", e.DATE = \"DATE\", e.DATE_TIME = \"DATE_TIME\", e.EMAILS = \"EMAILS\", e.FILES = \"FILES\", e.FULL_NAME = \"FULL_NAME\", e.LINKS = \"LINKS\", e.MORPH_RELATION = \"MORPH_RELATION\", e.MULTI_SELECT = \"MULTI_SELECT\", e.NUMBER = \"NUMBER\", e.NUMERIC = \"NUMERIC\", e.PHONES = \"PHONES\", e.POSITION = \"POSITION\", e.RATING = \"RATING\", e.RAW_JSON = \"RAW_JSON\", e.RELATION = \"RELATION\", e.RICH_TEXT = \"RICH_TEXT\", e.SELECT = \"SELECT\", e.TEXT = \"TEXT\", e.TS_VECTOR = \"TS_VECTOR\", e.UUID = \"UUID\", e;\n}({}), t = /* @__PURE__ */ function(e) {\n\treturn e.INDEX = \"INDEX\", e;\n}({});\n//#endregion\nexport { e as n, t };\n","import { v5 as e } from \"uuid\";\n//#region src/application/constants/TwentyStandardApplicationUniversalIdentifier.ts\nvar t = \"20202020-64aa-4b6f-b003-9c74b97cee20\", n = ({ entityNamespace: t, value: n, applicationUniversalIdentifier: r }) => e(`${t}:${n}`, r), r = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t, name: r }) => n({\n\tentityNamespace: \"fieldMetadata\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), i = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t, relationTargetObjectUniversalIdentifier: r }) => n({\n\tentityNamespace: \"fieldMetadata\",\n\tvalue: `${t}:systemRelation:${r}`,\n\tapplicationUniversalIdentifier: e\n});\n//#endregion\nexport { t as i, r as n, n as r, i as t };\n","import { n as e, t } from \"./ViewKey-YV4NySfb.mjs\";\nimport { i as n, n as r, r as i, t as a } from \"./get-system-relation-field-universal-identifier.util-DGoOUfu_.mjs\";\n//#region src/application/applicationCategoryType.ts\nvar o = [\n\t\"Communication\",\n\t\"Productivity\",\n\t\"Product management\",\n\t\"Sales\",\n\t\"Marketing\",\n\t\"Enrichment\",\n\t\"Data\",\n\t\"Search\",\n\t\"Other\"\n], s = (e) => o.includes(e), c = [\n\te.TEXT,\n\te.ARRAY,\n\te.BOOLEAN,\n\te.DATE,\n\te.DATE_TIME,\n\te.NUMBER,\n\te.NUMERIC,\n\te.RAW_JSON,\n\te.RICH_TEXT,\n\te.SELECT,\n\te.MULTI_SELECT\n], l = \"public\", u = \"TWENTY_API_KEY\", d = \"TWENTY_API_URL\", f = \"TWENTY_APP_ACCESS_TOKEN\", p = \"TWENTY_FUNCTIONS_URL\", m = \"generated\", h = { js: \"import { createRequire as __createRequire } from 'module';\\nconst require = __createRequire(import.meta.url);\" }, g = \".twenty/output\", _ = \"Standard\", v = ({ applicationUniversalIdentifier: e, name: t }) => i({\n\tentityNamespace: \"agent\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), y = ({ applicationUniversalIdentifier: e, key: t }) => i({\n\tentityNamespace: \"applicationVariable\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), b = \"navigation\", x = ({ applicationUniversalIdentifier: e, engineComponentKey: t }) => i({\n\tentityNamespace: \"commandMenuItem\",\n\tvalue: `GLOBAL:${t}`,\n\tapplicationUniversalIdentifier: e\n}), S = ({ applicationUniversalIdentifier: e, engineComponentKey: t }) => i({\n\tentityNamespace: \"commandMenuItem\",\n\tvalue: `GLOBAL_OBJECT_CONTEXT:${t}`,\n\tapplicationUniversalIdentifier: e\n}), C = ({ applicationUniversalIdentifier: e, engineComponentKey: t, objectUniversalIdentifier: n }) => i({\n\tentityNamespace: \"commandMenuItem\",\n\tvalue: `RECORD_SELECTION:${t}:${n ?? \"\"}`,\n\tapplicationUniversalIdentifier: e\n}), w = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t }) => i({\n\tentityNamespace: \"commandMenuItem\",\n\tvalue: `${t}:${b}`,\n\tapplicationUniversalIdentifier: e\n}), T = ({ applicationUniversalIdentifier: e, name: t }) => i({\n\tentityNamespace: \"connectionProvider\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), E = ({ applicationUniversalIdentifier: e, roleUniversalIdentifier: t, fieldUniversalIdentifier: n }) => i({\n\tentityNamespace: \"fieldPermission\",\n\tvalue: `${t}:${n}`,\n\tapplicationUniversalIdentifier: e\n}), D = ({ applicationUniversalIdentifier: e, componentName: t }) => i({\n\tentityNamespace: \"frontComponent\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), O = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t, name: n }) => i({\n\tentityNamespace: \"index\",\n\tvalue: `${t}:${n}`,\n\tapplicationUniversalIdentifier: e\n}), k = ({ applicationUniversalIdentifier: e, name: t }) => i({\n\tentityNamespace: \"logicFunction\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), A = ({ applicationUniversalIdentifier: e, name: t }) => i({\n\tentityNamespace: \"navigationMenuItem\",\n\tvalue: `FOLDER:${t}`,\n\tapplicationUniversalIdentifier: e\n}), j = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t }) => i({\n\tentityNamespace: \"navigationMenuItem\",\n\tvalue: `OBJECT:${t}`,\n\tapplicationUniversalIdentifier: e\n}), ee = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t }) => i({\n\tentityNamespace: \"navigationMenuItem\",\n\tvalue: `VIEW:${t}`,\n\tapplicationUniversalIdentifier: e\n}), M = ({ applicationUniversalIdentifier: e, link: t }) => i({\n\tentityNamespace: \"navigationMenuItem\",\n\tvalue: `LINK:${t}`,\n\tapplicationUniversalIdentifier: e\n}), N = ({ applicationUniversalIdentifier: e, roleUniversalIdentifier: t, objectUniversalIdentifier: n }) => i({\n\tentityNamespace: \"objectPermission\",\n\tvalue: `${t}:${n}`,\n\tapplicationUniversalIdentifier: e\n}), P = ({ applicationUniversalIdentifier: e, nameSingular: t }) => i({\n\tentityNamespace: \"objectMetadata\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), F = ({ applicationUniversalIdentifier: e, pageLayoutUniversalIdentifier: t, title: n }) => i({\n\tentityNamespace: \"pageLayoutTab\",\n\tvalue: `${t}:${n}`,\n\tapplicationUniversalIdentifier: e\n}), I = \"RECORD_PAGE\", L = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t, name: n }) => i({\n\tentityNamespace: \"pageLayout\",\n\tvalue: t ? `${t}:${n}` : n,\n\tapplicationUniversalIdentifier: e\n}), R = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t }) => i({\n\tentityNamespace: \"pageLayout\",\n\tvalue: `${t}:${I}`,\n\tapplicationUniversalIdentifier: e\n}), z = ({ applicationUniversalIdentifier: e, pageLayoutTabUniversalIdentifier: t, title: n }) => i({\n\tentityNamespace: \"pageLayoutWidget\",\n\tvalue: `${t}:${n}`,\n\tapplicationUniversalIdentifier: e\n}), B = ({ applicationUniversalIdentifier: e, key: t }) => i({\n\tentityNamespace: \"permissionFlag\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), V = ({ applicationUniversalIdentifier: e, roleUniversalIdentifier: t, permissionFlagUniversalIdentifier: n }) => i({\n\tentityNamespace: \"rolePermissionFlag\",\n\tvalue: `${t}:${n}`,\n\tapplicationUniversalIdentifier: e\n}), H = ({ applicationUniversalIdentifier: e, agentUniversalIdentifier: t }) => i({\n\tentityNamespace: \"roleTarget\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), U = ({ applicationUniversalIdentifier: e, label: t }) => i({\n\tentityNamespace: \"role\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), W = ({ applicationUniversalIdentifier: e, fieldMetadataUniversalIdentifier: t }) => i({\n\tentityNamespace: \"searchFieldMetadata\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), G = ({ applicationUniversalIdentifier: e, fieldUniversalIdentifier: t, value: n }) => i({\n\tentityNamespace: \"selectOption\",\n\tvalue: `${t}:${n}`,\n\tapplicationUniversalIdentifier: e\n}), K = ({ applicationUniversalIdentifier: e, name: t }) => i({\n\tentityNamespace: \"skill\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), q = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t, name: n }) => i({\n\tentityNamespace: \"viewFieldGroup\",\n\tvalue: `${t}:${n}`,\n\tapplicationUniversalIdentifier: e\n}), J = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t, fieldMetadataUniversalIdentifier: n }) => i({\n\tentityNamespace: \"viewField\",\n\tvalue: `${t}:${n}`,\n\tapplicationUniversalIdentifier: e\n}), Y = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t, fieldMetadataUniversalIdentifier: n, operand: r, subFieldName: a }) => i({\n\tentityNamespace: \"viewFilter\",\n\tvalue: `${t}:${n}:${r}:${a ?? \"\"}`,\n\tapplicationUniversalIdentifier: e\n}), X = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t, fieldValue: n }) => i({\n\tentityNamespace: \"viewGroup\",\n\tvalue: `${t}:${n}`,\n\tapplicationUniversalIdentifier: e\n}), Z = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t, fieldMetadataUniversalIdentifier: n }) => i({\n\tentityNamespace: \"viewSort\",\n\tvalue: `${t}:${n}`,\n\tapplicationUniversalIdentifier: e\n}), Q = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t, name: n }) => i({\n\tentityNamespace: \"view\",\n\tvalue: `${t}:${n}`,\n\tapplicationUniversalIdentifier: e\n}), $ = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: n }) => i({\n\tentityNamespace: \"view\",\n\tvalue: `${n}:${t.INDEX}`,\n\tapplicationUniversalIdentifier: e\n}), te = ({ applicationUniversalIdentifier: e, pageLayoutWidgetUniversalIdentifier: t }) => i({\n\tentityNamespace: \"view\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), ne = /* @__PURE__ */ function(e) {\n\treturn e.Object = \"object\", e.Field = \"field\", e.LogicFunction = \"logicFunction\", e.FrontComponent = \"frontComponent\", e.Role = \"role\", e.Skill = \"skill\", e.Agent = \"agent\", e.ConnectionProvider = \"connectionProvider\", e.View = \"view\", e.ViewField = \"viewField\", e.NavigationMenuItem = \"navigationMenuItem\", e.PageLayout = \"pageLayout\", e.PageLayoutTab = \"pageLayoutTab\", e.CommandMenuItem = \"commandMenuItem\", e;\n}({}), re = (t, n = e.TEXT) => {\n\tif (t == null) return \"\";\n\tswitch (n) {\n\t\tcase e.BOOLEAN: return String(t) === \"true\" ? \"true\" : \"false\";\n\t\tcase e.NUMBER:\n\t\tcase e.NUMERIC: return String(t);\n\t\tcase e.ARRAY:\n\t\tcase e.MULTI_SELECT:\n\t\t\tif (Array.isArray(t)) return JSON.stringify(t);\n\t\t\tif (typeof t == \"string\") {\n\t\t\t\ttry {\n\t\t\t\t\tlet e = JSON.parse(t);\n\t\t\t\t\tif (Array.isArray(e)) return t;\n\t\t\t\t} catch {}\n\t\t\t\treturn JSON.stringify([t]);\n\t\t\t}\n\t\t\treturn JSON.stringify(t);\n\t\tcase e.RAW_JSON:\n\t\tcase e.RICH_TEXT: return typeof t == \"string\" ? t : JSON.stringify(t);\n\t\tdefault: return typeof t == \"string\" ? t : String(t);\n\t}\n}, ie = (t, n = e.TEXT) => {\n\tif (t === \"\") return n === e.ARRAY || n === e.MULTI_SELECT ? [] : \"\";\n\tswitch (n) {\n\t\tcase e.BOOLEAN: return t === \"true\";\n\t\tcase e.NUMBER:\n\t\tcase e.NUMERIC: {\n\t\t\tlet e = Number(t);\n\t\t\treturn Number.isNaN(e) ? t : e;\n\t\t}\n\t\tcase e.ARRAY:\n\t\tcase e.MULTI_SELECT: try {\n\t\t\tlet e = JSON.parse(t);\n\t\t\treturn Array.isArray(e) ? e : [];\n\t\t} catch {\n\t\t\treturn [];\n\t\t}\n\t\tcase e.RAW_JSON:\n\t\tcase e.RICH_TEXT: try {\n\t\t\treturn JSON.parse(t);\n\t\t} catch {\n\t\t\treturn t;\n\t\t}\n\t\tdefault: return t;\n\t}\n};\n//#endregion\nexport { o as APPLICATION_CATEGORIES, c as APPLICATION_VARIABLE_FIELD_METADATA_TYPES, l as ASSETS_DIR, u as DEFAULT_API_KEY_NAME, d as DEFAULT_API_URL_NAME, f as DEFAULT_APP_ACCESS_TOKEN_NAME, p as DEFAULT_FUNCTIONS_URL_NAME, m as GENERATED_DIR, h as NODE_ESM_CJS_BANNER, g as OUTPUT_DIR, ne as SyncableEntity, _ as TWENTY_STANDARD_APPLICATION_NAME, n as TWENTY_STANDARD_APPLICATION_UNIVERSAL_IDENTIFIER, i as computeDeterministicUuid, ie as deserializeApplicationVariableValue, v as getAgentUniversalIdentifier, y as getApplicationVariableUniversalIdentifier, T as getConnectionProviderUniversalIdentifier, E as getFieldPermissionUniversalIdentifier, r as getFieldUniversalIdentifier, te as getFieldsWidgetViewUniversalIdentifier, A as getFolderNavigationMenuItemUniversalIdentifier, D as getFrontComponentUniversalIdentifier, x as getGlobalCommandMenuItemUniversalIdentifier, S as getGlobalObjectContextCommandMenuItemUniversalIdentifier, O as getIndexUniversalIdentifier, $ as getIndexViewUniversalIdentifier, M as getLinkNavigationMenuItemUniversalIdentifier, k as getLogicFunctionUniversalIdentifier, w as getNavigationCommandUniversalIdentifier, j as getObjectNavigationMenuItemUniversalIdentifier, N as getObjectPermissionUniversalIdentifier, P as getObjectUniversalIdentifier, F as getPageLayoutTabUniversalIdentifier, L as getPageLayoutUniversalIdentifier, z as getPageLayoutWidgetUniversalIdentifier, B as getPermissionFlagUniversalIdentifier, R as getRecordPageLayoutUniversalIdentifier, C as getRecordSelectionCommandMenuItemUniversalIdentifier, V as getRolePermissionFlagUniversalIdentifier, H as getRoleTargetUniversalIdentifier, U as getRoleUniversalIdentifier, W as getSearchFieldUniversalIdentifier, G as getSelectOptionUniversalIdentifier, K as getSkillUniversalIdentifier, a as getSystemRelationFieldUniversalIdentifier, q as getViewFieldGroupUniversalIdentifier, J as getViewFieldUniversalIdentifier, Y as getViewFilterUniversalIdentifier, X as getViewGroupUniversalIdentifier, ee as getViewNavigationMenuItemUniversalIdentifier, Z as getViewSortUniversalIdentifier, Q as getViewUniversalIdentifier, s as isKnownApplicationCategory, re as serializeApplicationVariableValue };\n","import {\n DEFAULT_API_URL_NAME,\n DEFAULT_APP_ACCESS_TOKEN_NAME,\n} from 'twenty-shared/application';\n\nexport const postGraphqlRequest = async <TVariables, TData>({\n query,\n variables,\n caller,\n}: {\n query: string;\n variables: TVariables;\n caller: string;\n}): Promise<TData> => {\n const apiUrl = process.env[DEFAULT_API_URL_NAME];\n const accessToken = process.env[DEFAULT_APP_ACCESS_TOKEN_NAME];\n\n if (!apiUrl || !accessToken) {\n throw new Error(\n `${caller}() requires the app runtime env vars ` +\n `${DEFAULT_API_URL_NAME} and ${DEFAULT_APP_ACCESS_TOKEN_NAME}.`,\n );\n }\n\n const response = await fetch(`${apiUrl}/metadata`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${accessToken}`,\n },\n body: JSON.stringify({ query, variables }),\n });\n\n if (!response.ok) {\n throw new Error(\n `${caller}() failed: HTTP ${response.status} ${response.statusText}`,\n );\n }\n\n const body = (await response.json()) as {\n data?: TData;\n errors?: { message: string }[];\n };\n\n if (body.errors && body.errors.length > 0) {\n throw new Error(\n `${caller}() failed: ${body.errors.map((error) => error.message).join(', ')}`,\n );\n }\n\n if (!body.data) {\n throw new Error(`${caller}() failed: response contained no data.`);\n }\n\n return body.data;\n};\n","import { AppConnectionAuthFailedError } from '@/sdk/logic-function/connections/errors/app-connection-auth-failed.error';\nimport { type AppConnection } from '@/sdk/logic-function/connections/types/app-connection.type';\nimport { postGraphqlRequest } from '@/sdk/logic-function/utils/post-graphql-request.util';\n\nconst GET_APP_CONNECTION_QUERY = `\n query GetAppConnection($id: ID!) {\n appConnection(id: $id) {\n id\n providerName\n name\n handle\n visibility\n userWorkspaceId\n accessToken\n scopes\n authFailedAt\n }\n }\n`;\n\nexport const getConnection = async (id: string): Promise<AppConnection> => {\n const { appConnection } = await postGraphqlRequest<\n { id: string },\n { appConnection: AppConnection }\n >({\n query: GET_APP_CONNECTION_QUERY,\n variables: { id },\n caller: 'getConnection',\n });\n\n if (appConnection.authFailedAt !== null) {\n throw new AppConnectionAuthFailedError(appConnection.id);\n }\n\n return appConnection;\n};\n","import { type AppConnection } from '@/sdk/logic-function/connections/types/app-connection.type';\nimport { postGraphqlRequest } from '@/sdk/logic-function/utils/post-graphql-request.util';\n\nconst LIST_APP_CONNECTIONS_QUERY = `\n query ListAppConnections($filter: ListAppConnectionsInput) {\n appConnections(filter: $filter) {\n id\n providerName\n name\n handle\n visibility\n userWorkspaceId\n accessToken\n scopes\n authFailedAt\n }\n }\n`;\n\nexport type ListConnectionsFilter = {\n providerName?: string;\n userWorkspaceId?: string;\n visibility?: 'user' | 'workspace';\n};\n\nexport const listConnections = async (\n filter: ListConnectionsFilter = {},\n): Promise<AppConnection[]> => {\n const { appConnections } = await postGraphqlRequest<\n { filter: ListConnectionsFilter },\n { appConnections: AppConnection[] }\n >({\n query: LIST_APP_CONNECTIONS_QUERY,\n variables: { filter },\n caller: 'listConnections',\n });\n\n return appConnections;\n};\n","import { type AppConnection } from '@/sdk/logic-function/connections/types/app-connection.type';\n\nexport const findConnectionForRequest = (\n connections: AppConnection[],\n event: { userWorkspaceId: string | null },\n): AppConnection | null => {\n if (event.userWorkspaceId !== null) {\n const personal = connections.find(\n (connection) =>\n connection.visibility === 'user' &&\n connection.userWorkspaceId === event.userWorkspaceId,\n );\n\n if (personal) {\n return personal;\n }\n }\n\n const workspaceShared = connections.find(\n (connection) => connection.visibility === 'workspace',\n );\n\n return workspaceShared ?? null;\n};\n","import {\n type RunAgentInput,\n type RunAgentResult,\n} from 'twenty-shared/application';\n\nimport { postGraphqlRequest } from '@/sdk/logic-function/utils/post-graphql-request.util';\n\nconst RUN_AGENT_MUTATION = `\n mutation RunAgent($input: RunAgentInput!) {\n runAgent(input: $input) {\n result\n error\n success\n }\n }\n`;\n\nexport const runAgent = async (\n input: RunAgentInput,\n): Promise<RunAgentResult> => {\n const { runAgent: result } = await postGraphqlRequest<\n { input: RunAgentInput },\n { runAgent: RunAgentResult }\n >({\n query: RUN_AGENT_MUTATION,\n variables: { input },\n caller: 'runAgent',\n });\n\n return result;\n};\n","import {\n type AppKeyValue,\n type AppKeyValueScope,\n} from 'twenty-shared/application';\n\nimport { postGraphqlRequest } from '@/sdk/logic-function/utils/post-graphql-request.util';\n\nconst GET_APP_KEY_VALUE_QUERY = `\n query GetAppKeyValue($key: String!, $scope: AppKeyValueScope) {\n appKeyValue(key: $key, scope: $scope) {\n key\n value\n scope\n }\n }\n`;\n\nconst SET_APP_KEY_VALUE_MUTATION = `\n mutation SetAppKeyValue($input: SetAppKeyValueInput!) {\n setAppKeyValue(input: $input) {\n key\n value\n scope\n }\n }\n`;\n\nconst DELETE_APP_KEY_VALUE_MUTATION = `\n mutation DeleteAppKeyValue($key: String!, $scope: AppKeyValueScope) {\n deleteAppKeyValue(key: $key, scope: $scope)\n }\n`;\n\nconst DEFAULT_APP_KEY_VALUE_SCOPE: AppKeyValueScope = 'WORKSPACE';\n\ntype KvOptions = {\n scope?: AppKeyValueScope;\n};\n\nexport const kv = {\n async get<TValue = unknown>(\n key: string,\n options?: KvOptions,\n ): Promise<TValue | null> {\n const { appKeyValue } = await postGraphqlRequest<\n { key: string; scope: AppKeyValueScope },\n { appKeyValue: AppKeyValue | null }\n >({\n query: GET_APP_KEY_VALUE_QUERY,\n variables: { key, scope: options?.scope ?? DEFAULT_APP_KEY_VALUE_SCOPE },\n caller: 'kv.get',\n });\n\n return (appKeyValue?.value ?? null) as TValue | null;\n },\n\n async set<TValue>(\n key: string,\n value: TValue,\n options?: KvOptions,\n ): Promise<void> {\n await postGraphqlRequest<\n {\n input: { key: string; value: TValue; scope: AppKeyValueScope };\n },\n { setAppKeyValue: AppKeyValue }\n >({\n query: SET_APP_KEY_VALUE_MUTATION,\n variables: {\n input: {\n key,\n value,\n scope: options?.scope ?? DEFAULT_APP_KEY_VALUE_SCOPE,\n },\n },\n caller: 'kv.set',\n });\n },\n\n async delete(key: string, options?: KvOptions): Promise<boolean> {\n const { deleteAppKeyValue } = await postGraphqlRequest<\n { key: string; scope: AppKeyValueScope },\n { deleteAppKeyValue: boolean }\n >({\n query: DELETE_APP_KEY_VALUE_MUTATION,\n variables: { key, scope: options?.scope ?? DEFAULT_APP_KEY_VALUE_SCOPE },\n caller: 'kv.delete',\n });\n\n return deleteAppKeyValue;\n },\n};\n","import { type LogicFunctionHttpResponse } from 'twenty-shared/types';\n\nexport type ResponseInit = {\n status?: number;\n headers?: Record<string, string>;\n};\n\nexport class Response implements LogicFunctionHttpResponse {\n readonly __twentyHttpResponse = true as const;\n readonly body: unknown;\n readonly status?: number;\n readonly headers?: Record<string, string>;\n\n constructor(body: unknown, init?: ResponseInit) {\n this.body = body;\n this.status = init?.status;\n this.headers = init?.headers;\n }\n}\n"],"mappings":"uKAEA,IAAIA,EAAK,IAAO,GAAG,OAAS,UAAY,GAAG,OAAS,YAAA,EAAA,EAAA,kBAAe,EAAE,yBAAyB,ECE1FC,GAAK,EAAG,IAAM,CACjB,IAAI,GAAA,EAAA,EAAA,kBAAM,CAAC,EAAI,IAAI,CAAC,EAAI,IAAK,GAC7B,MAAO,cAAA,EAAA,EAAA,kBAAe,CAAC,EAAI,EAAI,SAAS,QACzC,EAAG,GAAK,EAAG,IAAM,CAChB,GAAIC,EAAE,CAAC,EAAG,MAAO,CAChB,KAAM,SACN,YAAaD,EAAE,EAAE,0BAA2B,CAAC,CAC9C,EACA,GAAI,EAAE,OAAS,UAAW,MAAO,CAChC,KAAM,QACN,MAAO,CACN,KAAM,SACN,YAAaA,EAAE,EAAE,0BAA2B,CAAC,CAC9C,CACD,EACA,GAAI,CAAE,0BAA2B,EAAG,UAAW,EAA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W,CACT,MAAO,CACL,MACA,QACA,MAAO,GAAS,OAAS,CAC3B,CACF,EACA,OAAQ,QACV,CAAC,CACH,EAEA,MAAM,OAAO,EAAa,EAAuC,CAC/D,GAAM,CAAE,qBAAsB,MAAM,EAGlC,CACA,MAAO,EACP,UAAW,CAAE,MAAK,MAAO,GAAS,OAAS,CAA4B,EACvE,OAAQ,WACV,CAAC,EAED,OAAO,CACT,CACF,ECpFa,EAAb,KAA2D,CAMzD,YAAY,EAAe,EAAqB,2BALhB,GAM9B,KAAK,KAAO,EACZ,KAAK,OAAS,GAAM,OACpB,KAAK,QAAU,GAAM,OACvB,CACF"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["t","i","a","t","e","o","s","l","u","d","f","p","m","h","g","_","v","y","b","e","c","e","n","t"],"sources":["../../../twenty-shared/dist/is-record-object-schema-CwzshFdt.mjs","../../../twenty-shared/dist/logic-function.mjs","../../src/sdk/logic-function/connections/errors/app-connection-auth-failed.error.ts","../../../twenty-shared/dist/FieldMetadataType-PppCGM82.mjs","../../../twenty-shared/dist/get-system-view-universal-identifier.util-CJoglbKX.mjs","../../../twenty-shared/dist/application.mjs","../../src/sdk/logic-function/utils/post-graphql-request.util.ts","../../src/sdk/logic-function/connections/get-connection.ts","../../src/sdk/logic-function/connections/list-connections.ts","../../src/sdk/logic-function/connections/find-connection-for-request.ts","../../src/sdk/logic-function/agents/run-agent.ts","../../src/sdk/logic-function/jobs/enqueue-job.ts","../../src/sdk/logic-function/key-value/kv.ts","../../src/sdk/logic-function/response.ts"],"sourcesContent":["import { isNonEmptyString as e } from \"@sniptt/guards\";\n//#region src/logic-function/is-record-object-schema.ts\nvar t = (t) => (t?.type === \"record\" || t?.type === \"object\") && e(t.objectUniversalIdentifier);\n//#endregion\nexport { t };\n","import { t as e } from \"./isDefined-Dtu5EYqP.mjs\";\nimport { t } from \"./is-record-object-schema-CwzshFdt.mjs\";\nimport { isNonEmptyString as n, isObject as r } from \"@sniptt/guards\";\n//#region src/logic-function/build-tool-input-json-schema.ts\nvar i = (e, t) => {\n\tlet r = n(e) ? t?.(e) : void 0;\n\treturn `Id of the ${n(r) ? r : \"linked\"} record`;\n}, a = (n, o) => {\n\tif (t(n)) return {\n\t\ttype: \"string\",\n\t\tdescription: i(n.objectUniversalIdentifier, o)\n\t};\n\tif (n.type === \"records\") return {\n\t\ttype: \"array\",\n\t\titems: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: i(n.objectUniversalIdentifier, o)\n\t\t}\n\t};\n\tlet { objectUniversalIdentifier: s, multiline: c, label: l, items: u, properties: d, additionalProperties: f, ...p } = n, m = { ...p };\n\treturn e(u) && (m.items = a(u, o)), e(d) && (m.properties = Object.fromEntries(Object.entries(d).map(([e, t]) => [e, a(t, o)]))), e(f) && (m.additionalProperties = r(f) ? a(f, o) : f), m;\n}, o = {\n\ttype: \"object\",\n\tproperties: {}\n}, s = (e) => {\n\tlet t = { type: \"unknown\" };\n\tswitch (e.type) {\n\t\tcase \"string\":\n\t\t\tt.type = \"string\";\n\t\t\tbreak;\n\t\tcase \"number\":\n\t\tcase \"integer\":\n\t\t\tt.type = \"number\";\n\t\t\tbreak;\n\t\tcase \"boolean\":\n\t\t\tt.type = \"boolean\";\n\t\t\tbreak;\n\t\tcase \"array\":\n\t\t\tt.type = \"array\", e.items && (t.items = s(e.items));\n\t\t\tbreak;\n\t\tcase \"object\":\n\t\t\tt.type = \"object\", e.properties && (t.properties = Object.fromEntries(Object.entries(e.properties).map(([e, t]) => [e, s(t)])));\n\t\t\tbreak;\n\t\tcase \"record\":\n\t\t\tt.type = \"record\";\n\t\t\tbreak;\n\t\tcase \"records\":\n\t\t\tt.type = \"records\";\n\t\t\tbreak;\n\t\tdefault: t.type = \"unknown\";\n\t}\n\treturn Array.isArray(e.enum) && (t.enum = e.enum.filter((e) => typeof e == \"string\")), e.multiline === !0 && (t.multiline = !0), n(e.label) && (t.label = e.label), n(e.objectUniversalIdentifier) && (t.objectUniversalIdentifier = e.objectUniversalIdentifier), t;\n}, c = (e) => [s(e)], l = { inputSchema: c({\n\ttype: \"object\",\n\tproperties: {\n\t\ta: { type: \"string\" },\n\t\tb: { type: \"number\" }\n\t}\n}) }, u = async (t) => {\n\tlet { getFunctionInputSchema: n } = await import(\"./get-function-input-schema-GNk3NRLJ.mjs\"), r = n(t)[0];\n\treturn r?.type === \"object\" && e(r.properties) ? {\n\t\ttype: \"object\",\n\t\tproperties: r.properties\n\t} : o;\n}, d = (t) => !e(t) || t === null ? \"unknown\" : typeof t == \"string\" ? \"string\" : typeof t == \"number\" ? \"number\" : typeof t == \"boolean\" ? \"boolean\" : Array.isArray(t) ? \"array\" : \"unknown\", f = (e) => e ? Object.entries(e).reduce((e, [t, n]) => (r(n) && !Array.isArray(n) ? e[t] = {\n\tisLeaf: !1,\n\ttype: \"object\",\n\tlabel: t,\n\tvalue: f(n)\n} : e[t] = {\n\tisLeaf: !0,\n\tvalue: n,\n\ttype: d(n),\n\tlabel: t\n}, e), {}) : {}, p = (e, t) => e ? `${e}.${t}` : t, m = (t, n, r = \"\") => {\n\tlet i = [];\n\tfor (let [a, o] of Object.entries(n)) {\n\t\tlet n = p(r, a), s = t[a];\n\t\tif (!e(s)) {\n\t\t\ti.push(`Missing key \"${n}\" in declared output schema.`);\n\t\t\tcontinue;\n\t\t}\n\t\tif (o.isLeaf !== s.isLeaf) {\n\t\t\ti.push(`Type mismatch at \"${n}\": expected ${o.isLeaf ? o.type : \"object\"} but declared ${s.isLeaf ? s.type : \"object\"}.`);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!o.isLeaf && !s.isLeaf) {\n\t\t\ti.push(...m(s.value, o.value, n));\n\t\t\tcontinue;\n\t\t}\n\t\to.isLeaf && s.isLeaf && o.type !== \"unknown\" && s.type !== \"unknown\" && o.type !== s.type && i.push(`Type mismatch at \"${n}\": expected ${o.type} but declared ${s.type}.`);\n\t}\n\treturn i;\n}, h = [\n\t\"string\",\n\t\"number\",\n\t\"boolean\",\n\t\"array\",\n\t\"unknown\"\n], g = (e) => h.includes(e), _ = (e, t) => {\n\tlet n = t.label ?? e;\n\treturn t.type === \"record\" ? {\n\t\tisLeaf: !0,\n\t\ttype: \"string\",\n\t\tlabel: n,\n\t\tvalue: null\n\t} : t.type === \"records\" ? {\n\t\tisLeaf: !0,\n\t\ttype: \"array\",\n\t\tlabel: n,\n\t\tvalue: null\n\t} : t.type === \"object\" ? {\n\t\tisLeaf: !1,\n\t\ttype: \"object\",\n\t\tlabel: n,\n\t\tvalue: r(t.properties) ? v(t.properties) : {}\n\t} : {\n\t\tisLeaf: !0,\n\t\ttype: g(t.type) ? t.type : \"unknown\",\n\t\tlabel: n,\n\t\tvalue: null\n\t};\n}, v = (e) => Object.entries(e).reduce((e, [t, n]) => (e[t] = _(t, n), e), {}), y = (e) => {\n\tlet t = e[0];\n\treturn t?.type !== \"object\" || !r(t.properties) ? {} : v(t.properties);\n}, b = (e) => e?.type === \"records\" && n(e.objectUniversalIdentifier) || e?.type === \"array\" && t(e?.items);\n//#endregion\nexport { o as DEFAULT_TOOL_INPUT_SCHEMA, l as SEED_WORKFLOW_ACTION_TRIGGER_SETTINGS, a as buildToolInputJsonSchema, u as getInputSchemaFromSourceCode, f as getOutputSchemaFromValue, m as getOutputSchemaMismatchIssues, y as inputSchemaToOutputSchema, b as isRecordArraySchema, t as isRecordObjectSchema, c as jsonSchemaToInputSchema };\n","// Thrown when the platform asks the SDK to operate on a connection whose\n// OAuth refresh failed permanently (`authFailedAt` is set). The end user\n// must reconnect from the app's settings tab — the app cannot recover on\n// its own.\n//\n// `listConnections` filters these out by default (the user can't act on\n// them anyway). `getConnection` throws this when the looked-up connection\n// is in this state, so a stored connection id can be safely retried until\n// it works again.\nexport class AppConnectionAuthFailedError extends Error {\n readonly connectionId: string;\n\n constructor(connectionId: string) {\n super(\n `App connection ${connectionId} requires the user to reconnect ` +\n `(authFailedAt is set). Surface a \"Reconnect\" prompt in your UI.`,\n );\n this.name = 'AppConnectionAuthFailedError';\n this.connectionId = connectionId;\n }\n}\n","//#region src/types/FieldMetadataType.ts\nvar e = /* @__PURE__ */ function(e) {\n\treturn e.ACTOR = \"ACTOR\", e.ADDRESS = \"ADDRESS\", e.ARRAY = \"ARRAY\", e.BOOLEAN = \"BOOLEAN\", e.CURRENCY = \"CURRENCY\", e.DATE = \"DATE\", e.DATE_TIME = \"DATE_TIME\", e.EMAILS = \"EMAILS\", e.FILES = \"FILES\", e.FULL_NAME = \"FULL_NAME\", e.LINKS = \"LINKS\", e.MORPH_RELATION = \"MORPH_RELATION\", e.MULTI_SELECT = \"MULTI_SELECT\", e.NUMBER = \"NUMBER\", e.NUMERIC = \"NUMERIC\", e.PHONES = \"PHONES\", e.POSITION = \"POSITION\", e.RATING = \"RATING\", e.RAW_JSON = \"RAW_JSON\", e.RELATION = \"RELATION\", e.RICH_TEXT = \"RICH_TEXT\", e.SELECT = \"SELECT\", e.TEXT = \"TEXT\", e.TS_VECTOR = \"TS_VECTOR\", e.UUID = \"UUID\", e;\n}({});\n//#endregion\nexport { e as t };\n","import { v5 as e } from \"uuid\";\n//#region src/application/constants/TwentyStandardApplicationUniversalIdentifier.ts\nvar t = \"20202020-64aa-4b6f-b003-9c74b97cee20\", n = ({ entityNamespace: t, value: n, applicationUniversalIdentifier: r }) => e(`${t}:${n}`, r), r = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t, name: r }) => n({\n\tentityNamespace: \"fieldMetadata\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), i = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t, relationTargetObjectUniversalIdentifier: r }) => n({\n\tentityNamespace: \"fieldMetadata\",\n\tvalue: `${t}:systemRelation:${r}`,\n\tapplicationUniversalIdentifier: e\n}), a = ({ fieldMetadataApplicationUniversalIdentifier: e, viewUniversalIdentifier: t, fieldMetadataUniversalIdentifier: r }) => n({\n\tentityNamespace: \"viewField\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), o = ({ objectMetadataApplicationUniversalIdentifier: e, objectUniversalIdentifier: t, viewKey: r }) => n({\n\tentityNamespace: \"view\",\n\tvalue: `${t}:${r}`,\n\tapplicationUniversalIdentifier: e\n});\n//#endregion\nexport { n as a, r as i, a as n, t as o, i as r, o as t };\n","import { t as e } from \"./FieldMetadataType-PppCGM82.mjs\";\nimport { a as t, i as n, n as r, o as i, r as a, t as o } from \"./get-system-view-universal-identifier.util-CJoglbKX.mjs\";\n//#region src/application/applicationCategoryType.ts\nvar s = [\n\t\"Communication\",\n\t\"Productivity\",\n\t\"Product management\",\n\t\"Sales\",\n\t\"Marketing\",\n\t\"Enrichment\",\n\t\"Data\",\n\t\"Search\",\n\t\"Other\"\n], c = (e) => s.includes(e), l = [\n\te.TEXT,\n\te.ARRAY,\n\te.BOOLEAN,\n\te.DATE,\n\te.DATE_TIME,\n\te.NUMBER,\n\te.NUMERIC,\n\te.RAW_JSON,\n\te.RICH_TEXT,\n\te.SELECT,\n\te.MULTI_SELECT\n], u = \"public\", d = \"TWENTY_API_KEY\", f = \"TWENTY_API_URL\", p = \"TWENTY_APP_ACCESS_TOKEN\", m = \"TWENTY_FUNCTIONS_URL\", h = \"generated\", g = { js: \"import { createRequire as __createRequire } from 'module';\\nconst require = __createRequire(import.meta.url);\" }, _ = \".twenty/output\", v = \"Standard\", y = ({ applicationUniversalIdentifier: e, name: n }) => t({\n\tentityNamespace: \"agent\",\n\tvalue: n,\n\tapplicationUniversalIdentifier: e\n}), b = ({ applicationUniversalIdentifier: e, key: n }) => t({\n\tentityNamespace: \"applicationVariable\",\n\tvalue: n,\n\tapplicationUniversalIdentifier: e\n}), x = \"navigation\", S = ({ applicationUniversalIdentifier: e, engineComponentKey: n }) => t({\n\tentityNamespace: \"commandMenuItem\",\n\tvalue: `GLOBAL:${n}`,\n\tapplicationUniversalIdentifier: e\n}), C = ({ applicationUniversalIdentifier: e, engineComponentKey: n }) => t({\n\tentityNamespace: \"commandMenuItem\",\n\tvalue: `GLOBAL_OBJECT_CONTEXT:${n}`,\n\tapplicationUniversalIdentifier: e\n}), w = ({ applicationUniversalIdentifier: e, engineComponentKey: n, objectUniversalIdentifier: r }) => t({\n\tentityNamespace: \"commandMenuItem\",\n\tvalue: `RECORD_SELECTION:${n}:${r ?? \"\"}`,\n\tapplicationUniversalIdentifier: e\n}), T = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: n }) => t({\n\tentityNamespace: \"commandMenuItem\",\n\tvalue: `${n}:${x}`,\n\tapplicationUniversalIdentifier: e\n}), E = ({ applicationUniversalIdentifier: e, name: n }) => t({\n\tentityNamespace: \"connectionProvider\",\n\tvalue: n,\n\tapplicationUniversalIdentifier: e\n}), D = ({ applicationUniversalIdentifier: e, roleUniversalIdentifier: n, fieldUniversalIdentifier: r }) => t({\n\tentityNamespace: \"fieldPermission\",\n\tvalue: `${n}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), O = ({ applicationUniversalIdentifier: e, pageLayoutWidgetUniversalIdentifier: n }) => t({\n\tentityNamespace: \"view\",\n\tvalue: n,\n\tapplicationUniversalIdentifier: e\n}), k = ({ applicationUniversalIdentifier: e, componentName: n }) => t({\n\tentityNamespace: \"frontComponent\",\n\tvalue: n,\n\tapplicationUniversalIdentifier: e\n}), A = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: n, name: r }) => t({\n\tentityNamespace: \"index\",\n\tvalue: `${n}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), j = ({ applicationUniversalIdentifier: e, name: n }) => t({\n\tentityNamespace: \"logicFunction\",\n\tvalue: n,\n\tapplicationUniversalIdentifier: e\n}), ee = ({ applicationUniversalIdentifier: e, name: n }) => t({\n\tentityNamespace: \"navigationMenuItem\",\n\tvalue: `FOLDER:${n}`,\n\tapplicationUniversalIdentifier: e\n}), M = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: n }) => t({\n\tentityNamespace: \"navigationMenuItem\",\n\tvalue: `OBJECT:${n}`,\n\tapplicationUniversalIdentifier: e\n}), N = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: n }) => t({\n\tentityNamespace: \"navigationMenuItem\",\n\tvalue: `VIEW:${n}`,\n\tapplicationUniversalIdentifier: e\n}), P = ({ applicationUniversalIdentifier: e, link: n }) => t({\n\tentityNamespace: \"navigationMenuItem\",\n\tvalue: `LINK:${n}`,\n\tapplicationUniversalIdentifier: e\n}), F = ({ applicationUniversalIdentifier: e, roleUniversalIdentifier: n, objectUniversalIdentifier: r }) => t({\n\tentityNamespace: \"objectPermission\",\n\tvalue: `${n}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), I = ({ applicationUniversalIdentifier: e, nameSingular: n }) => t({\n\tentityNamespace: \"objectMetadata\",\n\tvalue: n,\n\tapplicationUniversalIdentifier: e\n}), L = ({ applicationUniversalIdentifier: e, pageLayoutUniversalIdentifier: n, title: r }) => t({\n\tentityNamespace: \"pageLayoutTab\",\n\tvalue: `${n}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), R = \"RECORD_PAGE\", z = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: n, name: r }) => t({\n\tentityNamespace: \"pageLayout\",\n\tvalue: n ? `${n}:${r}` : r,\n\tapplicationUniversalIdentifier: e\n}), B = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: n }) => t({\n\tentityNamespace: \"pageLayout\",\n\tvalue: `${n}:${R}`,\n\tapplicationUniversalIdentifier: e\n}), V = ({ applicationUniversalIdentifier: e, pageLayoutTabUniversalIdentifier: n, title: r }) => t({\n\tentityNamespace: \"pageLayoutWidget\",\n\tvalue: `${n}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), H = ({ applicationUniversalIdentifier: e, key: n }) => t({\n\tentityNamespace: \"permissionFlag\",\n\tvalue: n,\n\tapplicationUniversalIdentifier: e\n}), U = ({ applicationUniversalIdentifier: e, roleUniversalIdentifier: n, permissionFlagUniversalIdentifier: r }) => t({\n\tentityNamespace: \"rolePermissionFlag\",\n\tvalue: `${n}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), W = ({ applicationUniversalIdentifier: e, agentUniversalIdentifier: n }) => t({\n\tentityNamespace: \"roleTarget\",\n\tvalue: n,\n\tapplicationUniversalIdentifier: e\n}), G = ({ applicationUniversalIdentifier: e, label: n }) => t({\n\tentityNamespace: \"role\",\n\tvalue: n,\n\tapplicationUniversalIdentifier: e\n}), K = ({ applicationUniversalIdentifier: e, fieldMetadataUniversalIdentifier: n }) => t({\n\tentityNamespace: \"searchFieldMetadata\",\n\tvalue: n,\n\tapplicationUniversalIdentifier: e\n}), q = ({ applicationUniversalIdentifier: e, fieldUniversalIdentifier: n, value: r }) => t({\n\tentityNamespace: \"selectOption\",\n\tvalue: `${n}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), J = ({ applicationUniversalIdentifier: e, name: n }) => t({\n\tentityNamespace: \"skill\",\n\tvalue: n,\n\tapplicationUniversalIdentifier: e\n}), Y = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: n, name: r }) => t({\n\tentityNamespace: \"viewFieldGroup\",\n\tvalue: `${n}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), X = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: n, fieldMetadataUniversalIdentifier: r }) => t({\n\tentityNamespace: \"viewField\",\n\tvalue: `${n}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), Z = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: n, fieldMetadataUniversalIdentifier: r, operand: i, subFieldName: a }) => t({\n\tentityNamespace: \"viewFilter\",\n\tvalue: `${n}:${r}:${i}:${a ?? \"\"}`,\n\tapplicationUniversalIdentifier: e\n}), Q = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: n, fieldValue: r }) => t({\n\tentityNamespace: \"viewGroup\",\n\tvalue: `${n}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), $ = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: n, fieldMetadataUniversalIdentifier: r }) => t({\n\tentityNamespace: \"viewSort\",\n\tvalue: `${n}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), te = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: n, name: r }) => t({\n\tentityNamespace: \"view\",\n\tvalue: `${n}:${r}`,\n\tapplicationUniversalIdentifier: e\n}), ne = /* @__PURE__ */ function(e) {\n\treturn e.Object = \"object\", e.Field = \"field\", e.LogicFunction = \"logicFunction\", e.FrontComponent = \"frontComponent\", e.Role = \"role\", e.Skill = \"skill\", e.Agent = \"agent\", e.ConnectionProvider = \"connectionProvider\", e.View = \"view\", e.ViewField = \"viewField\", e.NavigationMenuItem = \"navigationMenuItem\", e.PageLayout = \"pageLayout\", e.PageLayoutTab = \"pageLayoutTab\", e.CommandMenuItem = \"commandMenuItem\", e;\n}({}), re = (t, n = e.TEXT) => {\n\tif (t == null) return \"\";\n\tswitch (n) {\n\t\tcase e.BOOLEAN: return String(t) === \"true\" ? \"true\" : \"false\";\n\t\tcase e.NUMBER:\n\t\tcase e.NUMERIC: return String(t);\n\t\tcase e.ARRAY:\n\t\tcase e.MULTI_SELECT:\n\t\t\tif (Array.isArray(t)) return JSON.stringify(t);\n\t\t\tif (typeof t == \"string\") {\n\t\t\t\ttry {\n\t\t\t\t\tlet e = JSON.parse(t);\n\t\t\t\t\tif (Array.isArray(e)) return t;\n\t\t\t\t} catch {}\n\t\t\t\treturn JSON.stringify([t]);\n\t\t\t}\n\t\t\treturn JSON.stringify(t);\n\t\tcase e.RAW_JSON:\n\t\tcase e.RICH_TEXT: return typeof t == \"string\" ? t : JSON.stringify(t);\n\t\tdefault: return typeof t == \"string\" ? t : String(t);\n\t}\n}, ie = (t, n = e.TEXT) => {\n\tif (t === \"\") return n === e.ARRAY || n === e.MULTI_SELECT ? [] : \"\";\n\tswitch (n) {\n\t\tcase e.BOOLEAN: return t === \"true\";\n\t\tcase e.NUMBER:\n\t\tcase e.NUMERIC: {\n\t\t\tlet e = Number(t);\n\t\t\treturn Number.isNaN(e) ? t : e;\n\t\t}\n\t\tcase e.ARRAY:\n\t\tcase e.MULTI_SELECT: try {\n\t\t\tlet e = JSON.parse(t);\n\t\t\treturn Array.isArray(e) ? e : [];\n\t\t} catch {\n\t\t\treturn [];\n\t\t}\n\t\tcase e.RAW_JSON:\n\t\tcase e.RICH_TEXT: try {\n\t\t\treturn JSON.parse(t);\n\t\t} catch {\n\t\t\treturn t;\n\t\t}\n\t\tdefault: return t;\n\t}\n};\n//#endregion\nexport { s as APPLICATION_CATEGORIES, l as APPLICATION_VARIABLE_FIELD_METADATA_TYPES, u as ASSETS_DIR, d as DEFAULT_API_KEY_NAME, f as DEFAULT_API_URL_NAME, p as DEFAULT_APP_ACCESS_TOKEN_NAME, m as DEFAULT_FUNCTIONS_URL_NAME, h as GENERATED_DIR, g as NODE_ESM_CJS_BANNER, _ as OUTPUT_DIR, ne as SyncableEntity, v as TWENTY_STANDARD_APPLICATION_NAME, i as TWENTY_STANDARD_APPLICATION_UNIVERSAL_IDENTIFIER, t as computeDeterministicUuid, ie as deserializeApplicationVariableValue, y as getAgentUniversalIdentifier, b as getApplicationVariableUniversalIdentifier, E as getConnectionProviderUniversalIdentifier, D as getFieldPermissionUniversalIdentifier, n as getFieldUniversalIdentifier, O as getFieldsWidgetViewUniversalIdentifier, ee as getFolderNavigationMenuItemUniversalIdentifier, k as getFrontComponentUniversalIdentifier, S as getGlobalCommandMenuItemUniversalIdentifier, C as getGlobalObjectContextCommandMenuItemUniversalIdentifier, A as getIndexUniversalIdentifier, P as getLinkNavigationMenuItemUniversalIdentifier, j as getLogicFunctionUniversalIdentifier, T as getNavigationCommandUniversalIdentifier, M as getObjectNavigationMenuItemUniversalIdentifier, F as getObjectPermissionUniversalIdentifier, I as getObjectUniversalIdentifier, L as getPageLayoutTabUniversalIdentifier, z as getPageLayoutUniversalIdentifier, V as getPageLayoutWidgetUniversalIdentifier, H as getPermissionFlagUniversalIdentifier, B as getRecordPageLayoutUniversalIdentifier, w as getRecordSelectionCommandMenuItemUniversalIdentifier, U as getRolePermissionFlagUniversalIdentifier, W as getRoleTargetUniversalIdentifier, G as getRoleUniversalIdentifier, K as getSearchFieldUniversalIdentifier, q as getSelectOptionUniversalIdentifier, J as getSkillUniversalIdentifier, a as getSystemRelationFieldUniversalIdentifier, r as getSystemViewFieldUniversalIdentifier, o as getSystemViewUniversalIdentifier, Y as getViewFieldGroupUniversalIdentifier, X as getViewFieldUniversalIdentifier, Z as getViewFilterUniversalIdentifier, Q as getViewGroupUniversalIdentifier, N as getViewNavigationMenuItemUniversalIdentifier, $ as getViewSortUniversalIdentifier, te as getViewUniversalIdentifier, c as isKnownApplicationCategory, re as serializeApplicationVariableValue };\n","import {\n DEFAULT_API_URL_NAME,\n DEFAULT_APP_ACCESS_TOKEN_NAME,\n} from 'twenty-shared/application';\n\nexport const postGraphqlRequest = async <TVariables, TData>({\n query,\n variables,\n caller,\n}: {\n query: string;\n variables: TVariables;\n caller: string;\n}): Promise<TData> => {\n const apiUrl = process.env[DEFAULT_API_URL_NAME];\n const accessToken = process.env[DEFAULT_APP_ACCESS_TOKEN_NAME];\n\n if (!apiUrl || !accessToken) {\n throw new Error(\n `${caller}() requires the app runtime env vars ` +\n `${DEFAULT_API_URL_NAME} and ${DEFAULT_APP_ACCESS_TOKEN_NAME}.`,\n );\n }\n\n const response = await fetch(`${apiUrl}/metadata`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${accessToken}`,\n },\n body: JSON.stringify({ query, variables }),\n });\n\n if (!response.ok) {\n throw new Error(\n `${caller}() failed: HTTP ${response.status} ${response.statusText}`,\n );\n }\n\n const body = (await response.json()) as {\n data?: TData;\n errors?: { message: string }[];\n };\n\n if (body.errors && body.errors.length > 0) {\n throw new Error(\n `${caller}() failed: ${body.errors.map((error) => error.message).join(', ')}`,\n );\n }\n\n if (!body.data) {\n throw new Error(`${caller}() failed: response contained no data.`);\n }\n\n return body.data;\n};\n","import { AppConnectionAuthFailedError } from '@/sdk/logic-function/connections/errors/app-connection-auth-failed.error';\nimport { type AppConnection } from '@/sdk/logic-function/connections/types/app-connection.type';\nimport { postGraphqlRequest } from '@/sdk/logic-function/utils/post-graphql-request.util';\n\nconst GET_APP_CONNECTION_QUERY = `\n query GetAppConnection($id: ID!) {\n appConnection(id: $id) {\n id\n providerName\n name\n handle\n visibility\n userWorkspaceId\n accessToken\n scopes\n authFailedAt\n }\n }\n`;\n\nexport const getConnection = async (id: string): Promise<AppConnection> => {\n const { appConnection } = await postGraphqlRequest<\n { id: string },\n { appConnection: AppConnection }\n >({\n query: GET_APP_CONNECTION_QUERY,\n variables: { id },\n caller: 'getConnection',\n });\n\n if (appConnection.authFailedAt !== null) {\n throw new AppConnectionAuthFailedError(appConnection.id);\n }\n\n return appConnection;\n};\n","import { type AppConnection } from '@/sdk/logic-function/connections/types/app-connection.type';\nimport { postGraphqlRequest } from '@/sdk/logic-function/utils/post-graphql-request.util';\n\nconst LIST_APP_CONNECTIONS_QUERY = `\n query ListAppConnections($filter: ListAppConnectionsInput) {\n appConnections(filter: $filter) {\n id\n providerName\n name\n handle\n visibility\n userWorkspaceId\n accessToken\n scopes\n authFailedAt\n }\n }\n`;\n\nexport type ListConnectionsFilter = {\n providerName?: string;\n userWorkspaceId?: string;\n visibility?: 'user' | 'workspace';\n};\n\nexport const listConnections = async (\n filter: ListConnectionsFilter = {},\n): Promise<AppConnection[]> => {\n const { appConnections } = await postGraphqlRequest<\n { filter: ListConnectionsFilter },\n { appConnections: AppConnection[] }\n >({\n query: LIST_APP_CONNECTIONS_QUERY,\n variables: { filter },\n caller: 'listConnections',\n });\n\n return appConnections;\n};\n","import { type AppConnection } from '@/sdk/logic-function/connections/types/app-connection.type';\n\nexport const findConnectionForRequest = (\n connections: AppConnection[],\n event: { userWorkspaceId: string | null },\n): AppConnection | null => {\n if (event.userWorkspaceId !== null) {\n const personal = connections.find(\n (connection) =>\n connection.visibility === 'user' &&\n connection.userWorkspaceId === event.userWorkspaceId,\n );\n\n if (personal) {\n return personal;\n }\n }\n\n const workspaceShared = connections.find(\n (connection) => connection.visibility === 'workspace',\n );\n\n return workspaceShared ?? null;\n};\n","import {\n type RunAgentInput,\n type RunAgentResult,\n} from 'twenty-shared/application';\n\nimport { postGraphqlRequest } from '@/sdk/logic-function/utils/post-graphql-request.util';\n\nconst RUN_AGENT_MUTATION = `\n mutation RunAgent($input: RunAgentInput!) {\n runAgent(input: $input) {\n result\n error\n success\n }\n }\n`;\n\nexport const runAgent = async (\n input: RunAgentInput,\n): Promise<RunAgentResult> => {\n const { runAgent: result } = await postGraphqlRequest<\n { input: RunAgentInput },\n { runAgent: RunAgentResult }\n >({\n query: RUN_AGENT_MUTATION,\n variables: { input },\n caller: 'runAgent',\n });\n\n return result;\n};\n","import { MetadataApiClient } from 'twenty-client-sdk/metadata';\nimport {\n type EnqueueJobInput,\n type EnqueueJobResult,\n} from 'twenty-shared/application';\n\nexport const enqueueJob = async (\n input: EnqueueJobInput,\n): Promise<EnqueueJobResult> => {\n const client = new MetadataApiClient();\n\n const { enqueueJob: result } = await client.mutation({\n enqueueJob: {\n __args: { input },\n enqueued: true,\n logicFunctionUniversalIdentifier: true,\n },\n });\n\n return result;\n};\n","import {\n type AppKeyValue,\n type AppKeyValueScope,\n} from 'twenty-shared/application';\n\nimport { postGraphqlRequest } from '@/sdk/logic-function/utils/post-graphql-request.util';\n\nconst GET_APP_KEY_VALUE_QUERY = `\n query GetAppKeyValue($key: String!, $scope: AppKeyValueScope) {\n appKeyValue(key: $key, scope: $scope) {\n key\n value\n scope\n }\n }\n`;\n\nconst SET_APP_KEY_VALUE_MUTATION = `\n mutation SetAppKeyValue($input: SetAppKeyValueInput!) {\n setAppKeyValue(input: $input) {\n key\n value\n scope\n }\n }\n`;\n\nconst DELETE_APP_KEY_VALUE_MUTATION = `\n mutation DeleteAppKeyValue($key: String!, $scope: AppKeyValueScope) {\n deleteAppKeyValue(key: $key, scope: $scope)\n }\n`;\n\nconst DEFAULT_APP_KEY_VALUE_SCOPE: AppKeyValueScope = 'WORKSPACE';\n\ntype KvOptions = {\n scope?: AppKeyValueScope;\n};\n\nexport const kv = {\n async get<TValue = unknown>(\n key: string,\n options?: KvOptions,\n ): Promise<TValue | null> {\n const { appKeyValue } = await postGraphqlRequest<\n { key: string; scope: AppKeyValueScope },\n { appKeyValue: AppKeyValue | null }\n >({\n query: GET_APP_KEY_VALUE_QUERY,\n variables: { key, scope: options?.scope ?? DEFAULT_APP_KEY_VALUE_SCOPE },\n caller: 'kv.get',\n });\n\n return (appKeyValue?.value ?? null) as TValue | null;\n },\n\n async set<TValue>(\n key: string,\n value: TValue,\n options?: KvOptions,\n ): Promise<void> {\n await postGraphqlRequest<\n {\n input: { key: string; value: TValue; scope: AppKeyValueScope };\n },\n { setAppKeyValue: AppKeyValue }\n >({\n query: SET_APP_KEY_VALUE_MUTATION,\n variables: {\n input: {\n key,\n value,\n scope: options?.scope ?? DEFAULT_APP_KEY_VALUE_SCOPE,\n },\n },\n caller: 'kv.set',\n });\n },\n\n async delete(key: string, options?: KvOptions): Promise<boolean> {\n const { deleteAppKeyValue } = await postGraphqlRequest<\n { key: string; scope: AppKeyValueScope },\n { deleteAppKeyValue: boolean }\n >({\n query: DELETE_APP_KEY_VALUE_MUTATION,\n variables: { key, scope: options?.scope ?? DEFAULT_APP_KEY_VALUE_SCOPE },\n caller: 'kv.delete',\n });\n\n return deleteAppKeyValue;\n },\n};\n","import { type LogicFunctionHttpResponse } from 'twenty-shared/types';\n\nexport type ResponseInit = {\n status?: number;\n headers?: Record<string, string>;\n};\n\nexport class Response implements LogicFunctionHttpResponse {\n readonly __twentyHttpResponse = true as const;\n readonly body: unknown;\n readonly status?: number;\n readonly headers?: Record<string, string>;\n\n constructor(body: unknown, init?: ResponseInit) {\n this.body = body;\n this.status = init?.status;\n this.headers = init?.headers;\n }\n}\n"],"mappings":"mNAEA,IAAIA,EAAK,IAAO,GAAG,OAAS,UAAY,GAAG,OAAS,YAAA,EAAA,EAAA,kBAAe,EAAE,yBAAyB,ECE1FC,G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,SAAU,GAAW,MAAM,EAGjC,CACA,MAAO,EACP,UAAW,CAAE,OAAM,EACnB,OAAQ,UACV,CAAC,EAED,OAAO,CACT,ECxBa,EAAa,KACxB,IAC8B,CAG9B,GAAM,CAAE,WAAY,GAAW,MAAM,IAFlB,EAAA,kBAEkB,EAAO,SAAS,CACnD,WAAY,CACV,OAAQ,CAAE,OAAM,EAChB,SAAU,GACV,iCAAkC,EACpC,CACF,CAAC,EAED,OAAO,CACT,ECbM,EAA0B;;;;;;;;EAU1B,EAA6B;;;;;;;;EAU7B,EAAgC;;;;EAMhC,EAAgD,YAMzC,EAAK,CAChB,MAAM,IACJ,EACA,EACwB,CACxB,GAAM,CAAE,eAAgB,MAAM,EAG5B,CACA,MAAO,EACP,UAAW,CAAE,MAAK,MAAO,GAAS,OAAS,CAA4B,EACvE,OAAQ,QACV,CAAC,EAED,OAAQ,GAAa,OAAS,IAChC,EAEA,MAAM,IACJ,EACA,EACA,EACe,CACf,MAAM,EAKJ,CACA,MAAO,EACP,UAAW,CACT,MAAO,CACL,MACA,QACA,MAAO,GAAS,OAAS,CAC3B,CACF,EACA,OAAQ,QACV,CAAC,CACH,EAEA,MAAM,OAAO,EAAa,EAAuC,CAC/D,GAAM,CAAE,qBAAsB,MAAM,EAGlC,CACA,MAAO,EACP,UAAW,CAAE,MAAK,MAAO,GAAS,OAAS,CAA4B,EACvE,OAAQ,WACV,CAAC,EAED,OAAO,CACT,CACF,ECpFa,EAAb,KAA2D,CAMzD,YAAY,EAAe,EAAqB,2BALhB,GAM9B,KAAK,KAAO,EACZ,KAAK,OAAS,GAAM,OACpB,KAAK,QAAU,GAAM,OACvB,CACF"}
|
|
@@ -50,6 +50,19 @@ declare enum FieldMetadataType {
|
|
|
50
50
|
UUID = "UUID"
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
type EnqueueJobOptions = {
|
|
54
|
+
retryLimit?: number;
|
|
55
|
+
delayMs?: number;
|
|
56
|
+
};
|
|
57
|
+
type EnqueueJobInput = EnqueueJobOptions & {
|
|
58
|
+
logicFunctionUniversalIdentifier: string;
|
|
59
|
+
payload?: Record<string, unknown>;
|
|
60
|
+
};
|
|
61
|
+
type EnqueueJobResult = {
|
|
62
|
+
enqueued: boolean;
|
|
63
|
+
logicFunctionUniversalIdentifier: string;
|
|
64
|
+
};
|
|
65
|
+
|
|
53
66
|
declare enum HTTPMethod {
|
|
54
67
|
GET = "GET",
|
|
55
68
|
POST = "POST",
|
|
@@ -337,6 +350,8 @@ declare class AppConnectionAuthFailedError extends Error {
|
|
|
337
350
|
|
|
338
351
|
declare const runAgent: (input: RunAgentInput) => Promise<RunAgentResult>;
|
|
339
352
|
|
|
353
|
+
declare const enqueueJob: (input: EnqueueJobInput) => Promise<EnqueueJobResult>;
|
|
354
|
+
|
|
340
355
|
type KvOptions = {
|
|
341
356
|
scope?: AppKeyValueScope;
|
|
342
357
|
};
|
|
@@ -358,5 +373,5 @@ declare class Response implements LogicFunctionHttpResponse {
|
|
|
358
373
|
constructor(body: unknown, init?: ResponseInit);
|
|
359
374
|
}
|
|
360
375
|
|
|
361
|
-
export { AppConnectionAuthFailedError, ObjectRecordBaseEvent, ObjectRecordCreateEvent, ObjectRecordDeleteEvent, ObjectRecordDestroyEvent, ObjectRecordRestoreEvent, ObjectRecordUpdateEvent, ObjectRecordUpsertEvent, Response, findConnectionForRequest, getConnection, jsonSchemaToInputSchema, kv, listConnections, runAgent };
|
|
362
|
-
export type { AppConnection, AppKeyValue, AppKeyValueScope, CronPayload, DatabaseEventPayload, InputJsonSchema, InstallHandler, InstallPayload, ListConnectionsFilter, LogicFunctionConfig, LogicFunctionHandler, ObjectRecordEvent, ResponseInit, LogicFunctionEvent as RoutePayload, RunAgentInput, RunAgentResult, ServerRouteDispatchResult, ServerRouteResolverResult, UninstallHandler, UninstallPayload };
|
|
376
|
+
export { AppConnectionAuthFailedError, ObjectRecordBaseEvent, ObjectRecordCreateEvent, ObjectRecordDeleteEvent, ObjectRecordDestroyEvent, ObjectRecordRestoreEvent, ObjectRecordUpdateEvent, ObjectRecordUpsertEvent, Response, enqueueJob, findConnectionForRequest, getConnection, jsonSchemaToInputSchema, kv, listConnections, runAgent };
|
|
377
|
+
export type { AppConnection, AppKeyValue, AppKeyValueScope, CronPayload, DatabaseEventPayload, EnqueueJobInput, EnqueueJobOptions, EnqueueJobResult, InputJsonSchema, InstallHandler, InstallPayload, ListConnectionsFilter, LogicFunctionConfig, LogicFunctionHandler, ObjectRecordEvent, ResponseInit, LogicFunctionEvent as RoutePayload, RunAgentInput, RunAgentResult, ServerRouteDispatchResult, ServerRouteResolverResult, UninstallHandler, UninstallPayload };
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import { t as e } from "./isDefined-Dtu5EYqP-CMNeFg4z.mjs";
|
|
2
2
|
import { isNonEmptyString as t, isObject as n } from "@sniptt/guards";
|
|
3
3
|
import "uuid";
|
|
4
|
+
import { MetadataApiClient as r } from "twenty-client-sdk/metadata";
|
|
4
5
|
//#region ../twenty-shared/dist/is-record-object-schema-CwzshFdt.mjs
|
|
5
|
-
var
|
|
6
|
+
var i = (e) => (e?.type === "record" || e?.type === "object") && t(e.objectUniversalIdentifier), a = (e, n) => {
|
|
6
7
|
let r = t(e) ? n?.(e) : void 0;
|
|
7
8
|
return `Id of the ${t(r) ? r : "linked"} record`;
|
|
8
|
-
},
|
|
9
|
-
if (
|
|
9
|
+
}, o = (t, r) => {
|
|
10
|
+
if (i(t)) return {
|
|
10
11
|
type: "string",
|
|
11
|
-
description:
|
|
12
|
+
description: a(t.objectUniversalIdentifier, r)
|
|
12
13
|
};
|
|
13
14
|
if (t.type === "records") return {
|
|
14
15
|
type: "array",
|
|
15
16
|
items: {
|
|
16
17
|
type: "string",
|
|
17
|
-
description:
|
|
18
|
+
description: a(t.objectUniversalIdentifier, r)
|
|
18
19
|
}
|
|
19
20
|
};
|
|
20
21
|
let { objectUniversalIdentifier: s, multiline: c, label: l, items: u, properties: d, additionalProperties: f, ...p } = t, m = { ...p };
|
|
21
|
-
return e(u) && (m.items =
|
|
22
|
-
},
|
|
22
|
+
return e(u) && (m.items = o(u, r)), e(d) && (m.properties = Object.fromEntries(Object.entries(d).map(([e, t]) => [e, o(t, r)]))), e(f) && (m.additionalProperties = n(f) ? o(f, r) : f), m;
|
|
23
|
+
}, s = (e) => {
|
|
23
24
|
let n = { type: "unknown" };
|
|
24
25
|
switch (e.type) {
|
|
25
26
|
case "string":
|
|
@@ -33,10 +34,10 @@ var r = (e) => (e?.type === "record" || e?.type === "object") && t(e.objectUnive
|
|
|
33
34
|
n.type = "boolean";
|
|
34
35
|
break;
|
|
35
36
|
case "array":
|
|
36
|
-
n.type = "array", e.items && (n.items =
|
|
37
|
+
n.type = "array", e.items && (n.items = s(e.items));
|
|
37
38
|
break;
|
|
38
39
|
case "object":
|
|
39
|
-
n.type = "object", e.properties && (n.properties = Object.fromEntries(Object.entries(e.properties).map(([e, t]) => [e,
|
|
40
|
+
n.type = "object", e.properties && (n.properties = Object.fromEntries(Object.entries(e.properties).map(([e, t]) => [e, s(t)])));
|
|
40
41
|
break;
|
|
41
42
|
case "record":
|
|
42
43
|
n.type = "record";
|
|
@@ -47,8 +48,8 @@ var r = (e) => (e?.type === "record" || e?.type === "object") && t(e.objectUnive
|
|
|
47
48
|
default: n.type = "unknown";
|
|
48
49
|
}
|
|
49
50
|
return Array.isArray(e.enum) && (n.enum = e.enum.filter((e) => typeof e == "string")), e.multiline === !0 && (n.multiline = !0), t(e.label) && (n.label = e.label), t(e.objectUniversalIdentifier) && (n.objectUniversalIdentifier = e.objectUniversalIdentifier), n;
|
|
50
|
-
},
|
|
51
|
-
|
|
51
|
+
}, c = (e) => [s(e)];
|
|
52
|
+
c({
|
|
52
53
|
type: "object",
|
|
53
54
|
properties: {
|
|
54
55
|
a: { type: "string" },
|
|
@@ -57,20 +58,20 @@ s({
|
|
|
57
58
|
});
|
|
58
59
|
//#endregion
|
|
59
60
|
//#region ../twenty-shared/dist/logic-function.mjs
|
|
60
|
-
var
|
|
61
|
+
var l = (t) => !e(t) || t === null ? "unknown" : typeof t == "string" ? "string" : typeof t == "number" ? "number" : typeof t == "boolean" ? "boolean" : Array.isArray(t) ? "array" : "unknown", u = (e) => e ? Object.entries(e).reduce((e, [t, r]) => (n(r) && !Array.isArray(r) ? e[t] = {
|
|
61
62
|
isLeaf: !1,
|
|
62
63
|
type: "object",
|
|
63
64
|
label: t,
|
|
64
|
-
value:
|
|
65
|
+
value: u(r)
|
|
65
66
|
} : e[t] = {
|
|
66
67
|
isLeaf: !0,
|
|
67
68
|
value: r,
|
|
68
|
-
type:
|
|
69
|
+
type: l(r),
|
|
69
70
|
label: t
|
|
70
|
-
}, e), {}) : {},
|
|
71
|
+
}, e), {}) : {}, d = (e, t) => e ? `${e}.${t}` : t, f = (t, n, r = "") => {
|
|
71
72
|
let i = [];
|
|
72
73
|
for (let [a, o] of Object.entries(n)) {
|
|
73
|
-
let n =
|
|
74
|
+
let n = d(r, a), s = t[a];
|
|
74
75
|
if (!e(s)) {
|
|
75
76
|
i.push(`Missing key "${n}" in declared output schema.`);
|
|
76
77
|
continue;
|
|
@@ -80,19 +81,19 @@ var c = (t) => !e(t) || t === null ? "unknown" : typeof t == "string" ? "string"
|
|
|
80
81
|
continue;
|
|
81
82
|
}
|
|
82
83
|
if (!o.isLeaf && !s.isLeaf) {
|
|
83
|
-
i.push(...
|
|
84
|
+
i.push(...f(s.value, o.value, n));
|
|
84
85
|
continue;
|
|
85
86
|
}
|
|
86
87
|
o.isLeaf && s.isLeaf && o.type !== "unknown" && s.type !== "unknown" && o.type !== s.type && i.push(`Type mismatch at "${n}": expected ${o.type} but declared ${s.type}.`);
|
|
87
88
|
}
|
|
88
89
|
return i;
|
|
89
|
-
},
|
|
90
|
+
}, p = [
|
|
90
91
|
"string",
|
|
91
92
|
"number",
|
|
92
93
|
"boolean",
|
|
93
94
|
"array",
|
|
94
95
|
"unknown"
|
|
95
|
-
],
|
|
96
|
+
], m = (e) => p.includes(e), h = (e, t) => {
|
|
96
97
|
let r = t.label ?? e;
|
|
97
98
|
return t.type === "record" ? {
|
|
98
99
|
isLeaf: !0,
|
|
@@ -108,26 +109,26 @@ var c = (t) => !e(t) || t === null ? "unknown" : typeof t == "string" ? "string"
|
|
|
108
109
|
isLeaf: !1,
|
|
109
110
|
type: "object",
|
|
110
111
|
label: r,
|
|
111
|
-
value: n(t.properties) ?
|
|
112
|
+
value: n(t.properties) ? g(t.properties) : {}
|
|
112
113
|
} : {
|
|
113
114
|
isLeaf: !0,
|
|
114
|
-
type:
|
|
115
|
+
type: m(t.type) ? t.type : "unknown",
|
|
115
116
|
label: r,
|
|
116
117
|
value: null
|
|
117
118
|
};
|
|
118
|
-
},
|
|
119
|
+
}, g = (e) => Object.entries(e).reduce((e, [t, n]) => (e[t] = h(t, n), e), {}), _ = class extends Error {
|
|
119
120
|
constructor(e) {
|
|
120
121
|
super(`App connection ${e} requires the user to reconnect (authFailedAt is set). Surface a "Reconnect" prompt in your UI.`), this.name = "AppConnectionAuthFailedError", this.connectionId = e;
|
|
121
122
|
}
|
|
122
|
-
},
|
|
123
|
+
}, v = /* @__PURE__ */ function(e) {
|
|
123
124
|
return e.ACTOR = "ACTOR", e.ADDRESS = "ADDRESS", e.ARRAY = "ARRAY", e.BOOLEAN = "BOOLEAN", e.CURRENCY = "CURRENCY", e.DATE = "DATE", e.DATE_TIME = "DATE_TIME", e.EMAILS = "EMAILS", e.FILES = "FILES", e.FULL_NAME = "FULL_NAME", e.LINKS = "LINKS", e.MORPH_RELATION = "MORPH_RELATION", e.MULTI_SELECT = "MULTI_SELECT", e.NUMBER = "NUMBER", e.NUMERIC = "NUMERIC", e.PHONES = "PHONES", e.POSITION = "POSITION", e.RATING = "RATING", e.RAW_JSON = "RAW_JSON", e.RELATION = "RELATION", e.RICH_TEXT = "RICH_TEXT", e.SELECT = "SELECT", e.TEXT = "TEXT", e.TS_VECTOR = "TS_VECTOR", e.UUID = "UUID", e;
|
|
124
125
|
}({});
|
|
125
|
-
|
|
126
|
+
v.TEXT, v.ARRAY, v.BOOLEAN, v.DATE, v.DATE_TIME, v.NUMBER, v.NUMERIC, v.RAW_JSON, v.RICH_TEXT, v.SELECT, v.MULTI_SELECT;
|
|
126
127
|
//#endregion
|
|
127
128
|
//#region ../twenty-shared/dist/application.mjs
|
|
128
|
-
var
|
|
129
|
-
let r = process.env[
|
|
130
|
-
if (!r || !i) throw Error(`${n}() requires the app runtime env vars ${
|
|
129
|
+
var y = "TWENTY_API_URL", b = "TWENTY_APP_ACCESS_TOKEN", x = async ({ query: e, variables: t, caller: n }) => {
|
|
130
|
+
let r = process.env[y], i = process.env[b];
|
|
131
|
+
if (!r || !i) throw Error(`${n}() requires the app runtime env vars ${y} and ${b}.`);
|
|
131
132
|
let a = await fetch(`${r}/metadata`, {
|
|
132
133
|
method: "POST",
|
|
133
134
|
headers: {
|
|
@@ -144,74 +145,81 @@ var v = "TWENTY_API_URL", y = "TWENTY_APP_ACCESS_TOKEN", b = async ({ query: e,
|
|
|
144
145
|
if (o.errors && o.errors.length > 0) throw Error(`${n}() failed: ${o.errors.map((e) => e.message).join(", ")}`);
|
|
145
146
|
if (!o.data) throw Error(`${n}() failed: response contained no data.`);
|
|
146
147
|
return o.data;
|
|
147
|
-
},
|
|
148
|
-
let { appConnection: t } = await
|
|
149
|
-
query:
|
|
148
|
+
}, S = "\n query GetAppConnection($id: ID!) {\n appConnection(id: $id) {\n id\n providerName\n name\n handle\n visibility\n userWorkspaceId\n accessToken\n scopes\n authFailedAt\n }\n }\n", C = async (e) => {
|
|
149
|
+
let { appConnection: t } = await x({
|
|
150
|
+
query: S,
|
|
150
151
|
variables: { id: e },
|
|
151
152
|
caller: "getConnection"
|
|
152
153
|
});
|
|
153
|
-
if (t.authFailedAt !== null) throw new
|
|
154
|
+
if (t.authFailedAt !== null) throw new _(t.id);
|
|
154
155
|
return t;
|
|
155
|
-
},
|
|
156
|
-
let { appConnections: t } = await
|
|
157
|
-
query:
|
|
156
|
+
}, w = "\n query ListAppConnections($filter: ListAppConnectionsInput) {\n appConnections(filter: $filter) {\n id\n providerName\n name\n handle\n visibility\n userWorkspaceId\n accessToken\n scopes\n authFailedAt\n }\n }\n", T = async (e = {}) => {
|
|
157
|
+
let { appConnections: t } = await x({
|
|
158
|
+
query: w,
|
|
158
159
|
variables: { filter: e },
|
|
159
160
|
caller: "listConnections"
|
|
160
161
|
});
|
|
161
162
|
return t;
|
|
162
|
-
},
|
|
163
|
+
}, E = (e, t) => {
|
|
163
164
|
if (t.userWorkspaceId !== null) {
|
|
164
165
|
let n = e.find((e) => e.visibility === "user" && e.userWorkspaceId === t.userWorkspaceId);
|
|
165
166
|
if (n) return n;
|
|
166
167
|
}
|
|
167
168
|
return e.find((e) => e.visibility === "workspace") ?? null;
|
|
168
|
-
},
|
|
169
|
-
let { runAgent: t } = await
|
|
170
|
-
query:
|
|
169
|
+
}, D = "\n mutation RunAgent($input: RunAgentInput!) {\n runAgent(input: $input) {\n result\n error\n success\n }\n }\n", O = async (e) => {
|
|
170
|
+
let { runAgent: t } = await x({
|
|
171
|
+
query: D,
|
|
171
172
|
variables: { input: e },
|
|
172
173
|
caller: "runAgent"
|
|
173
174
|
});
|
|
174
175
|
return t;
|
|
175
|
-
},
|
|
176
|
+
}, k = async (e) => {
|
|
177
|
+
let { enqueueJob: t } = await new r().mutation({ enqueueJob: {
|
|
178
|
+
__args: { input: e },
|
|
179
|
+
enqueued: !0,
|
|
180
|
+
logicFunctionUniversalIdentifier: !0
|
|
181
|
+
} });
|
|
182
|
+
return t;
|
|
183
|
+
}, A = "\n query GetAppKeyValue($key: String!, $scope: AppKeyValueScope) {\n appKeyValue(key: $key, scope: $scope) {\n key\n value\n scope\n }\n }\n", j = "\n mutation SetAppKeyValue($input: SetAppKeyValueInput!) {\n setAppKeyValue(input: $input) {\n key\n value\n scope\n }\n }\n", M = "\n mutation DeleteAppKeyValue($key: String!, $scope: AppKeyValueScope) {\n deleteAppKeyValue(key: $key, scope: $scope)\n }\n", N = "WORKSPACE", P = {
|
|
176
184
|
async get(e, t) {
|
|
177
|
-
let { appKeyValue: n } = await
|
|
178
|
-
query:
|
|
185
|
+
let { appKeyValue: n } = await x({
|
|
186
|
+
query: A,
|
|
179
187
|
variables: {
|
|
180
188
|
key: e,
|
|
181
|
-
scope: t?.scope ??
|
|
189
|
+
scope: t?.scope ?? N
|
|
182
190
|
},
|
|
183
191
|
caller: "kv.get"
|
|
184
192
|
});
|
|
185
193
|
return n?.value ?? null;
|
|
186
194
|
},
|
|
187
195
|
async set(e, t, n) {
|
|
188
|
-
await
|
|
189
|
-
query:
|
|
196
|
+
await x({
|
|
197
|
+
query: j,
|
|
190
198
|
variables: { input: {
|
|
191
199
|
key: e,
|
|
192
200
|
value: t,
|
|
193
|
-
scope: n?.scope ??
|
|
201
|
+
scope: n?.scope ?? N
|
|
194
202
|
} },
|
|
195
203
|
caller: "kv.set"
|
|
196
204
|
});
|
|
197
205
|
},
|
|
198
206
|
async delete(e, t) {
|
|
199
|
-
let { deleteAppKeyValue: n } = await
|
|
200
|
-
query:
|
|
207
|
+
let { deleteAppKeyValue: n } = await x({
|
|
208
|
+
query: M,
|
|
201
209
|
variables: {
|
|
202
210
|
key: e,
|
|
203
|
-
scope: t?.scope ??
|
|
211
|
+
scope: t?.scope ?? N
|
|
204
212
|
},
|
|
205
213
|
caller: "kv.delete"
|
|
206
214
|
});
|
|
207
215
|
return n;
|
|
208
216
|
}
|
|
209
|
-
},
|
|
217
|
+
}, F = class {
|
|
210
218
|
constructor(e, t) {
|
|
211
219
|
this.__twentyHttpResponse = !0, this.body = e, this.status = t?.status, this.headers = t?.headers;
|
|
212
220
|
}
|
|
213
221
|
};
|
|
214
222
|
//#endregion
|
|
215
|
-
export {
|
|
223
|
+
export { _ as AppConnectionAuthFailedError, F as Response, k as enqueueJob, E as findConnectionForRequest, C as getConnection, c as jsonSchemaToInputSchema, P as kv, T as listConnections, O as runAgent };
|
|
216
224
|
|
|
217
225
|
//# sourceMappingURL=index.mjs.map
|