twenty-sdk 2.14.0 → 2.16.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.
Files changed (75) hide show
  1. package/README.md +4 -0
  2. package/dist/{AllIcons-BwIoyggb-BCMFgulw.mjs → AllIcons-CdbaxNyc-CJcUHQBl.mjs} +492 -493
  3. package/dist/AllIcons-CdbaxNyc-DR-8e_UM.js +1 -0
  4. package/dist/assets/halftone-backdrop.png +0 -0
  5. package/dist/billing/index.cjs +1 -1
  6. package/dist/billing/index.cjs.map +1 -1
  7. package/dist/billing/index.mjs +2 -1
  8. package/dist/billing/index.mjs.map +1 -1
  9. package/dist/{catalog-sync-CXDxoJ8O.mjs → catalog-sync-BYM3GqZl.mjs} +1 -1
  10. package/dist/catalog-sync-w6yKppKP.js +1 -0
  11. package/dist/cli/commands/dev/dev.d.ts +1 -0
  12. package/dist/cli/operations/index.d.ts +2 -0
  13. package/dist/cli/operations/server-start.d.ts +1 -0
  14. package/dist/cli/utilities/api/api-client.d.ts +3 -1
  15. package/dist/cli/utilities/api/api-response-type.d.ts +1 -0
  16. package/dist/cli/utilities/auth/reauth-helper.d.ts +2 -0
  17. package/dist/cli/utilities/build/common/build-application.d.ts +2 -0
  18. package/dist/cli/utilities/build/cover/apply-generated-cover.d.ts +9 -0
  19. package/dist/cli/utilities/build/cover/assets/twenty-logo-mark-path.d.ts +1 -0
  20. package/dist/cli/utilities/build/cover/generate-cover-image.d.ts +5 -0
  21. package/dist/cli/utilities/build/cover/generated-asset.type.d.ts +4 -0
  22. package/dist/cli/utilities/build/cover/generated-cover-path.d.ts +1 -0
  23. package/dist/cli/utilities/server/docker-container.d.ts +1 -0
  24. package/dist/cli/utilities/version/get-engine-version-range.d.ts +1 -0
  25. package/dist/cli/utilities/version/resolve-highest-engine-version.d.ts +1 -0
  26. package/dist/cli.cjs +34 -34
  27. package/dist/cli.mjs +1605 -1600
  28. package/dist/define/index.cjs +21 -21
  29. package/dist/define/index.cjs.map +1 -1
  30. package/dist/define/index.d.ts +127 -7
  31. package/dist/define/index.mjs +36027 -34678
  32. package/dist/define/index.mjs.map +1 -1
  33. package/dist/front-component/index.cjs +1 -1
  34. package/dist/front-component/index.cjs.map +1 -1
  35. package/dist/front-component/index.d.ts +2 -2
  36. package/dist/front-component/index.mjs +3 -3
  37. package/dist/front-component/index.mjs.map +1 -1
  38. package/dist/front-component-renderer.cjs +1 -1
  39. package/dist/get-function-input-schema-GNk3NRLJ-D8x7FINz.js +1 -0
  40. package/dist/{get-function-input-schema-NI9y_bIk-Cdh2RIb9.mjs → get-function-input-schema-GNk3NRLJ-zQkANyT3.mjs} +31 -21
  41. package/dist/icon-DMT-YeKi-C9-AduNa.mjs +10168 -0
  42. package/dist/icon-DMT-YeKi-Cz0W5sJA.js +1 -0
  43. package/dist/isDefined-Dtu5EYqP-Dp026Ry1.js +1 -0
  44. package/dist/logic-function/get-function-input-schema-GNk3NRLJ-D8x7FINz.js +2 -0
  45. package/dist/logic-function/get-function-input-schema-GNk3NRLJ-D8x7FINz.js.map +1 -0
  46. package/dist/logic-function/get-function-input-schema-GNk3NRLJ-DSc3lI49.mjs +75 -0
  47. package/dist/logic-function/get-function-input-schema-GNk3NRLJ-DSc3lI49.mjs.map +1 -0
  48. package/dist/logic-function/index.cjs +4 -4
  49. package/dist/logic-function/index.cjs.map +1 -1
  50. package/dist/logic-function/index.d.ts +26 -5
  51. package/dist/logic-function/index.mjs +144 -28
  52. package/dist/logic-function/index.mjs.map +1 -1
  53. package/dist/logic-function/isDefined-Dtu5EYqP-CMNeFg4z.mjs +7 -0
  54. package/dist/logic-function/isDefined-Dtu5EYqP-CMNeFg4z.mjs.map +1 -0
  55. package/dist/logic-function/isDefined-Dtu5EYqP-Dp026Ry1.js +2 -0
  56. package/dist/logic-function/isDefined-Dtu5EYqP-Dp026Ry1.js.map +1 -0
  57. package/dist/login-D7nyXinY.js +345 -0
  58. package/dist/{login-oauth-BRpqOH2x.mjs → login-rU5te3B6.mjs} +43931 -42338
  59. package/dist/operations.cjs +1 -1
  60. package/dist/operations.mjs +4 -4
  61. package/dist/ui/index.cjs +25 -6
  62. package/dist/ui/index.d.ts +18 -12
  63. package/dist/ui/index.mjs +15247 -1078
  64. package/dist/utils/index.cjs +1 -1
  65. package/dist/utils/index.cjs.map +1 -1
  66. package/dist/utils/index.d.ts +3 -1
  67. package/dist/utils/index.mjs +11 -9
  68. package/dist/utils/index.mjs.map +1 -1
  69. package/package.json +6 -3
  70. package/dist/AllIcons-BwIoyggb-Pq3paugc.js +0 -1
  71. package/dist/catalog-sync-sANH0f3Y.js +0 -1
  72. package/dist/display-Co0K-nTB-CGtaWbMi.js +0 -83
  73. package/dist/display-Co0K-nTB-DAirZFT6.mjs +0 -54635
  74. package/dist/get-function-input-schema-NI9y_bIk-CqUY25sG.js +0 -1
  75. package/dist/login-oauth-0T8eWvyh.js +0 -345
@@ -0,0 +1 @@
1
+ let e=require("@sniptt/guards");var t=t=>!(0,e.isUndefined)(t)&&!(0,e.isNull)(t);Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return t}});
@@ -0,0 +1,2 @@
1
+ const e=require("./isDefined-Dtu5EYqP-Dp026Ry1.js");let t=require("typescript");var n=`TwentyRecord`,r=n=>{let r=n.typeArguments?.[0];if(e.t(r)&&r.kind===t.SyntaxKind.LiteralType&&r.literal.kind===t.SyntaxKind.StringLiteral)return r.literal.text},i=e=>e.type===`record`?{type:`records`,objectUniversalIdentifier:e.objectUniversalIdentifier}:{type:`array`,items:e},a=o=>{switch(o.kind){case t.SyntaxKind.NumberKeyword:return{type:`number`};case t.SyntaxKind.StringKeyword:return{type:`string`};case t.SyntaxKind.BooleanKeyword:return{type:`boolean`};case t.SyntaxKind.ArrayType:return i(a(o.elementType));case t.SyntaxKind.TypeReference:{let s=o,c=s.typeName.kind===t.SyntaxKind.Identifier?s.typeName.text:void 0;if(c===`Array`||c===`ReadonlyArray`){let t=s.typeArguments?.[0];return i(e.t(t)?a(t):{})}if(c===n){let t=r(s);if(e.t(t))return{type:`record`,objectUniversalIdentifier:t}}return{}}case t.SyntaxKind.ObjectKeyword:return{type:`object`};case t.SyntaxKind.TypeLiteral:{let t={};return o.members.forEach(n=>{if(e.t(n.name)&&e.t(n.type)){let e=n.name.text;t[e]=a(n.type)}}),{type:`object`,properties:t}}case t.SyntaxKind.UnionType:{let e=o,n=[],r=!0;return e.types.forEach(e=>{if(e.kind===t.SyntaxKind.LiteralType){let i=e.literal;i.kind===t.SyntaxKind.StringLiteral?n.push(i.text):r=!1}else r=!1}),r?{type:`string`,enum:n}:{}}default:return{}}},o=(t,n)=>t.parameters.reduce((t,n)=>{let r=n.type;return e.t(r)?[...t,a(r)]:[...t,{}]},n),s=n=>n.kind===t.SyntaxKind.FunctionDeclaration?[n]:n.kind===t.SyntaxKind.VariableStatement?n.declarationList.declarations.filter(n=>e.t(n.initializer)&&n.initializer.kind===t.SyntaxKind.ArrowFunction).map(e=>e.initializer):[],c=e=>{let n=(0,t.createSourceFile)(`temp.ts`,e,t.ScriptTarget.ESNext,!0),r=[];return n.forEachChild(e=>{(e.kind===t.SyntaxKind.FunctionDeclaration||e.kind===t.SyntaxKind.VariableStatement)&&s(e).forEach(e=>{r=o(e,r)})}),r};exports.getFunctionInputSchema=c;
2
+ //# sourceMappingURL=get-function-input-schema-GNk3NRLJ-D8x7FINz.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-function-input-schema-GNk3NRLJ-D8x7FINz.js","names":["e","n","t"],"sources":["../../../twenty-shared/dist/get-function-input-schema-GNk3NRLJ.mjs"],"sourcesContent":["import { t as e } from \"./isDefined-Dtu5EYqP.mjs\";\nimport { ScriptTarget as t, SyntaxKind as n, createSourceFile as r } from \"typescript\";\n//#region src/logic-function/get-function-input-schema.ts\nvar i = \"TwentyRecord\", a = (t) => {\n\tlet r = t.typeArguments?.[0];\n\tif (e(r) && r.kind === n.LiteralType && r.literal.kind === n.StringLiteral) return r.literal.text;\n}, o = (e) => e.type === \"record\" ? {\n\ttype: \"records\",\n\tobjectUniversalIdentifier: e.objectUniversalIdentifier\n} : {\n\ttype: \"array\",\n\titems: e\n}, s = (t) => {\n\tswitch (t.kind) {\n\t\tcase n.NumberKeyword: return { type: \"number\" };\n\t\tcase n.StringKeyword: return { type: \"string\" };\n\t\tcase n.BooleanKeyword: return { type: \"boolean\" };\n\t\tcase n.ArrayType: return o(s(t.elementType));\n\t\tcase n.TypeReference: {\n\t\t\tlet r = t, c = r.typeName.kind === n.Identifier ? r.typeName.text : void 0;\n\t\t\tif (c === \"Array\" || c === \"ReadonlyArray\") {\n\t\t\t\tlet t = r.typeArguments?.[0];\n\t\t\t\treturn o(e(t) ? s(t) : {});\n\t\t\t}\n\t\t\tif (c === i) {\n\t\t\t\tlet t = a(r);\n\t\t\t\tif (e(t)) return {\n\t\t\t\t\ttype: \"record\",\n\t\t\t\t\tobjectUniversalIdentifier: t\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {};\n\t\t}\n\t\tcase n.ObjectKeyword: return { type: \"object\" };\n\t\tcase n.TypeLiteral: {\n\t\t\tlet n = {};\n\t\t\treturn t.members.forEach((t) => {\n\t\t\t\tif (e(t.name) && e(t.type)) {\n\t\t\t\t\tlet e = t.name.text;\n\t\t\t\t\tn[e] = s(t.type);\n\t\t\t\t}\n\t\t\t}), {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: n\n\t\t\t};\n\t\t}\n\t\tcase n.UnionType: {\n\t\t\tlet e = t, r = [], i = !0;\n\t\t\treturn e.types.forEach((e) => {\n\t\t\t\tif (e.kind === n.LiteralType) {\n\t\t\t\t\tlet t = e.literal;\n\t\t\t\t\tt.kind === n.StringLiteral ? r.push(t.text) : i = !1;\n\t\t\t\t} else i = !1;\n\t\t\t}), i ? {\n\t\t\t\ttype: \"string\",\n\t\t\t\tenum: r\n\t\t\t} : {};\n\t\t}\n\t\tdefault: return {};\n\t}\n}, c = (t, n) => t.parameters.reduce((t, n) => {\n\tlet r = n.type;\n\treturn e(r) ? [...t, s(r)] : [...t, {}];\n}, n), l = (t) => t.kind === n.FunctionDeclaration ? [t] : t.kind === n.VariableStatement ? t.declarationList.declarations.filter((t) => e(t.initializer) && t.initializer.kind === n.ArrowFunction).map((e) => e.initializer) : [], u = (e) => {\n\tlet i = r(\"temp.ts\", e, t.ESNext, !0), a = [];\n\treturn i.forEachChild((e) => {\n\t\t(e.kind === n.FunctionDeclaration || e.kind === n.VariableStatement) && l(e).forEach((e) => {\n\t\t\ta = c(e, a);\n\t\t});\n\t}), a;\n};\n//#endregion\nexport { u as getFunctionInputSchema };\n"],"mappings":"gFAGA,IAAI,EAAI,eAAgB,EAAK,GAAM,CAClC,IAAI,EAAI,EAAE,gBAAgB,GAC1B,GAAIA,EAAAA,EAAE,CAAC,GAAK,EAAE,OAASC,EAAAA,WAAE,aAAe,EAAE,QAAQ,OAASA,EAAAA,WAAE,cAAe,OAAO,EAAE,QAAQ,IAC9F,EAAG,EAAK,GAAM,EAAE,OAAS,SAAW,CACnC,KAAM,UACN,0BAA2B,EAAE,yBAC9B,EAAI,CACH,KAAM,QACN,MAAO,CACR,EAAG,EAAK,GAAM,CACb,OAAQ,EAAE,KAAV,CACC,KAAKA,EAAAA,WAAE,cAAe,MAAO,CAAE,KAAM,QAAS,EAC9C,KAAKA,EAAAA,WAAE,cAAe,MAAO,CAAE,KAAM,QAAS,EAC9C,KAAKA,EAAAA,WAAE,eAAgB,MAAO,CAAE,KAAM,SAAU,EAChD,KAAKA,EAAAA,WAAE,UAAW,OAAO,EAAE,EAAE,EAAE,WAAW,CAAC,EAC3C,KAAKA,EAAAA,WAAE,cAAe,CACrB,IAAI,EAAI,EAAG,EAAI,EAAE,SAAS,OAASA,EAAAA,WAAE,WAAa,EAAE,SAAS,KAAO,IAAK,GACzE,GAAI,IAAM,SAAW,IAAM,gBAAiB,CAC3C,IAAI,EAAI,EAAE,gBAAgB,GAC1B,OAAO,EAAED,EAAAA,EAAE,CAAC,EAAI,EAAE,CAAC,E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EAAE,gBAAgB,aAAa,OAAQ,GAAMD,EAAAA,EAAE,EAAE,WAAW,GAAK,EAAE,YAAY,OAASC,EAAAA,WAAE,aAAa,EAAE,IAAK,GAAM,EAAE,WAAW,EAAI,CAAC,EAAG,EAAK,GAAM,CAC/O,IAAI,GAAA,EAAA,EAAA,kBAAM,UAAW,EAAGC,EAAAA,aAAE,OAAQ,CAAC,CAAC,EAAG,EAAI,CAAC,EAC5C,OAAO,EAAE,aAAc,GAAM,EAC3B,EAAE,OAASD,EAAAA,WAAE,qBAAuB,EAAE,OAASA,EAAAA,WAAE,oBAAsB,EAAE,CAAC,EAAE,QAAS,GAAM,CAC3F,EAAI,EAAE,EAAG,CAAC,CACX,CAAC,CACF,CAAC,EAAG,CACL"}
@@ -0,0 +1,75 @@
1
+ import { t as e } from "./isDefined-Dtu5EYqP-CMNeFg4z.mjs";
2
+ import { ScriptTarget as t, SyntaxKind as n, createSourceFile as r } from "typescript";
3
+ //#region ../twenty-shared/dist/get-function-input-schema-GNk3NRLJ.mjs
4
+ var i = "TwentyRecord", a = (t) => {
5
+ let r = t.typeArguments?.[0];
6
+ if (e(r) && r.kind === n.LiteralType && r.literal.kind === n.StringLiteral) return r.literal.text;
7
+ }, o = (e) => e.type === "record" ? {
8
+ type: "records",
9
+ objectUniversalIdentifier: e.objectUniversalIdentifier
10
+ } : {
11
+ type: "array",
12
+ items: e
13
+ }, s = (t) => {
14
+ switch (t.kind) {
15
+ case n.NumberKeyword: return { type: "number" };
16
+ case n.StringKeyword: return { type: "string" };
17
+ case n.BooleanKeyword: return { type: "boolean" };
18
+ case n.ArrayType: return o(s(t.elementType));
19
+ case n.TypeReference: {
20
+ let r = t, c = r.typeName.kind === n.Identifier ? r.typeName.text : void 0;
21
+ if (c === "Array" || c === "ReadonlyArray") {
22
+ let t = r.typeArguments?.[0];
23
+ return o(e(t) ? s(t) : {});
24
+ }
25
+ if (c === i) {
26
+ let t = a(r);
27
+ if (e(t)) return {
28
+ type: "record",
29
+ objectUniversalIdentifier: t
30
+ };
31
+ }
32
+ return {};
33
+ }
34
+ case n.ObjectKeyword: return { type: "object" };
35
+ case n.TypeLiteral: {
36
+ let n = {};
37
+ return t.members.forEach((t) => {
38
+ if (e(t.name) && e(t.type)) {
39
+ let e = t.name.text;
40
+ n[e] = s(t.type);
41
+ }
42
+ }), {
43
+ type: "object",
44
+ properties: n
45
+ };
46
+ }
47
+ case n.UnionType: {
48
+ let e = t, r = [], i = !0;
49
+ return e.types.forEach((e) => {
50
+ if (e.kind === n.LiteralType) {
51
+ let t = e.literal;
52
+ t.kind === n.StringLiteral ? r.push(t.text) : i = !1;
53
+ } else i = !1;
54
+ }), i ? {
55
+ type: "string",
56
+ enum: r
57
+ } : {};
58
+ }
59
+ default: return {};
60
+ }
61
+ }, c = (t, n) => t.parameters.reduce((t, n) => {
62
+ let r = n.type;
63
+ return e(r) ? [...t, s(r)] : [...t, {}];
64
+ }, n), l = (t) => t.kind === n.FunctionDeclaration ? [t] : t.kind === n.VariableStatement ? t.declarationList.declarations.filter((t) => e(t.initializer) && t.initializer.kind === n.ArrowFunction).map((e) => e.initializer) : [], u = (e) => {
65
+ let i = r("temp.ts", e, t.ESNext, !0), a = [];
66
+ return i.forEachChild((e) => {
67
+ (e.kind === n.FunctionDeclaration || e.kind === n.VariableStatement) && l(e).forEach((e) => {
68
+ a = c(e, a);
69
+ });
70
+ }), a;
71
+ };
72
+ //#endregion
73
+ export { u as getFunctionInputSchema };
74
+
75
+ //# sourceMappingURL=get-function-input-schema-GNk3NRLJ-DSc3lI49.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-function-input-schema-GNk3NRLJ-DSc3lI49.mjs","names":["e","n","r","t"],"sources":["../../../twenty-shared/dist/get-function-input-schema-GNk3NRLJ.mjs"],"sourcesContent":["import { t as e } from \"./isDefined-Dtu5EYqP.mjs\";\nimport { ScriptTarget as t, SyntaxKind as n, createSourceFile as r } from \"typescript\";\n//#region src/logic-function/get-function-input-schema.ts\nvar i = \"TwentyRecord\", a = (t) => {\n\tlet r = t.typeArguments?.[0];\n\tif (e(r) && r.kind === n.LiteralType && r.literal.kind === n.StringLiteral) return r.literal.text;\n}, o = (e) => e.type === \"record\" ? {\n\ttype: \"records\",\n\tobjectUniversalIdentifier: e.objectUniversalIdentifier\n} : {\n\ttype: \"array\",\n\titems: e\n}, s = (t) => {\n\tswitch (t.kind) {\n\t\tcase n.NumberKeyword: return { type: \"number\" };\n\t\tcase n.StringKeyword: return { type: \"string\" };\n\t\tcase n.BooleanKeyword: return { type: \"boolean\" };\n\t\tcase n.ArrayType: return o(s(t.elementType));\n\t\tcase n.TypeReference: {\n\t\t\tlet r = t, c = r.typeName.kind === n.Identifier ? r.typeName.text : void 0;\n\t\t\tif (c === \"Array\" || c === \"ReadonlyArray\") {\n\t\t\t\tlet t = r.typeArguments?.[0];\n\t\t\t\treturn o(e(t) ? s(t) : {});\n\t\t\t}\n\t\t\tif (c === i) {\n\t\t\t\tlet t = a(r);\n\t\t\t\tif (e(t)) return {\n\t\t\t\t\ttype: \"record\",\n\t\t\t\t\tobjectUniversalIdentifier: t\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {};\n\t\t}\n\t\tcase n.ObjectKeyword: return { type: \"object\" };\n\t\tcase n.TypeLiteral: {\n\t\t\tlet n = {};\n\t\t\treturn t.members.forEach((t) => {\n\t\t\t\tif (e(t.name) && e(t.type)) {\n\t\t\t\t\tlet e = t.name.text;\n\t\t\t\t\tn[e] = s(t.type);\n\t\t\t\t}\n\t\t\t}), {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: n\n\t\t\t};\n\t\t}\n\t\tcase n.UnionType: {\n\t\t\tlet e = t, r = [], i = !0;\n\t\t\treturn e.types.forEach((e) => {\n\t\t\t\tif (e.kind === n.LiteralType) {\n\t\t\t\t\tlet t = e.literal;\n\t\t\t\t\tt.kind === n.StringLiteral ? r.push(t.text) : i = !1;\n\t\t\t\t} else i = !1;\n\t\t\t}), i ? {\n\t\t\t\ttype: \"string\",\n\t\t\t\tenum: r\n\t\t\t} : {};\n\t\t}\n\t\tdefault: return {};\n\t}\n}, c = (t, n) => t.parameters.reduce((t, n) => {\n\tlet r = n.type;\n\treturn e(r) ? [...t, s(r)] : [...t, {}];\n}, n), l = (t) => t.kind === n.FunctionDeclaration ? [t] : t.kind === n.VariableStatement ? t.declarationList.declarations.filter((t) => e(t.initializer) && t.initializer.kind === n.ArrowFunction).map((e) => e.initializer) : [], u = (e) => {\n\tlet i = r(\"temp.ts\", e, t.ESNext, !0), a = [];\n\treturn i.forEachChild((e) => {\n\t\t(e.kind === n.FunctionDeclaration || e.kind === n.VariableStatement) && l(e).forEach((e) => {\n\t\t\ta = c(e, a);\n\t\t});\n\t}), a;\n};\n//#endregion\nexport { u as getFunctionInputSchema };\n"],"mappings":";;;AAGA,IAAI,IAAI,gBAAgB,KAAK,MAAM;CAClC,IAAI,IAAI,EAAE,gBAAgB;CAC1B,IAAIA,EAAE,CAAC,KAAK,EAAE,SAASC,EAAE,eAAe,EAAE,QAAQ,SAASA,EAAE,eAAe,OAAO,EAAE,QAAQ;AAC9F,GAAG,KAAK,MAAM,EAAE,SAAS,WAAW;CACnC,MAAM;CACN,2BAA2B,EAAE;AAC9B,IAAI;CACH,MAAM;CACN,OAAO;AACR,GAAG,KAAK,MAAM;CACb,QAAQ,EAAE,MAAV;EACC,KAAKA,EAAE,eAAe,OAAO,EAAE,MAAM,SAAS;EAC9C,KAAKA,EAAE,eAAe,OAAO,EAAE,MAAM,SAAS;EAC9C,KAAKA,EAAE,gBAAgB,OAAO,EAAE,MAAM,UAAU;EAChD,KAAKA,EAAE,WAAW,OAAO,EAAE,EAAE,EAAE,WAAW,CAAC;EAC3C,KAAKA,EAAE,eAAe;GACrB,IAAI,IAAI,GAAG,IAAI,EAAE,SAAS,SAASA,EAAE,aAAa,EAAE,SAAS,OAAO,KAAK;GACzE,IAAI,MAAM,WAAW,MAAM,iBAAiB;IAC3C,IAAI,IAAI,EAAE,gB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Aa,QAAQ,MAAMD,EAAE,EAAE,WAAW,KAAK,EAAE,YAAY,SAASC,EAAE,aAAa,EAAE,KAAK,MAAM,EAAE,WAAW,IAAI,CAAC,GAAG,KAAK,MAAM;CAC/O,IAAI,IAAIC,EAAE,WAAW,GAAGC,EAAE,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC;CAC5C,OAAO,EAAE,cAAc,MAAM;EAC5B,CAAC,EAAE,SAASF,EAAE,uBAAuB,EAAE,SAASA,EAAE,sBAAsB,EAAE,CAAC,EAAE,SAAS,MAAM;GAC3F,IAAI,EAAE,GAAG,CAAC;EACX,CAAC;CACF,CAAC,GAAG;AACL"}
@@ -1,4 +1,4 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=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}},t=`TWENTY_API_URL`,n=`TWENTY_APP_ACCESS_TOKEN`,r=async({query:e,variables:r,caller:i})=>{let a=process.env[t],o=process.env[n];if(!a||!o)throw Error(`${i}() requires the app runtime env vars ${t} and ${n}.`);let s=await fetch(`${a}/metadata`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${o}`},body:JSON.stringify({query:e,variables:r})});if(!s.ok)throw Error(`${i}() failed: HTTP ${s.status} ${s.statusText}`);let c=await s.json();if(c.errors&&c.errors.length>0)throw Error(`${i}() failed: ${c.errors.map(e=>e.message).join(`, `)}`);if(!c.data)throw Error(`${i}() failed: response contained no data.`);return c.data},i=`
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./isDefined-Dtu5EYqP-Dp026Ry1.js");let t=require("@sniptt/guards");require("uuid");var n=e=>(e?.type===`record`||e?.type===`object`)&&(0,t.isNonEmptyString)(e.objectUniversalIdentifier),r=(e,n)=>{let r=(0,t.isNonEmptyString)(e)?n?.(e):void 0;return`Id of the ${(0,t.isNonEmptyString)(r)?r:`linked`} record`},i=(a,o)=>{if(n(a))return{type:`string`,description:r(a.objectUniversalIdentifier,o)};if(a.type===`records`)return{type:`array`,items:{type:`string`,description:r(a.objectUniversalIdentifier,o)}};let{objectUniversalIdentifier:s,multiline:c,label:l,items:u,properties:d,additionalProperties:f,...p}=a,m={...p};return e.t(u)&&(m.items=i(u,o)),e.t(d)&&(m.properties=Object.fromEntries(Object.entries(d).map(([e,t])=>[e,i(t,o)]))),e.t(f)&&(m.additionalProperties=(0,t.isObject)(f)?i(f,o):f),m},a=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=a(e.items));break;case`object`:n.type=`object`,e.properties&&(n.properties=Object.fromEntries(Object.entries(e.properties).map(([e,t])=>[e,a(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},o=e=>[a(e)];o({type:`object`,properties:{a:{type:`string`},b:{type:`number`}}});var s=t=>!e.t(t)||t===null?`unknown`:typeof t==`string`?`string`:typeof t==`number`?`number`:typeof t==`boolean`?`boolean`:Array.isArray(t)?`array`:`unknown`,c=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:c(r)}:e[n]={isLeaf:!0,value:r,type:s(r),label:n},e),{}):{},l=(e,t)=>e?`${e}.${t}`:t,u=(t,n,r=``)=>{let i=[];for(let[a,o]of Object.entries(n)){let n=l(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(...u(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},d=[`string`,`number`,`boolean`,`array`,`unknown`],f=e=>d.includes(e),p=(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)?m(n.properties):{}}:{isLeaf:!0,type:f(n.type)?n.type:`unknown`,label:r,value:null}},m=e=>Object.entries(e).reduce((e,[t,n])=>(e[t]=p(t,n),e),{}),h=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}},g=`TWENTY_API_URL`,_=`TWENTY_APP_ACCESS_TOKEN`,v=async({query:e,variables:t,caller:n})=>{let r=process.env[g],i=process.env[_];if(!r||!i)throw Error(`${n}() requires the app runtime env vars ${g} and ${_}.`);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},y=`
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`});var e=class e
12
12
  authFailedAt
13
13
  }
14
14
  }
15
- `,a=async t=>{let{appConnection:n}=await r({query:i,variables:{id:t},caller:`getConnection`});if(n.authFailedAt!==null)throw new e(n.id);return n},o=`
15
+ `,b=async e=>{let{appConnection:t}=await v({query:y,variables:{id:e},caller:`getConnection`});if(t.authFailedAt!==null)throw new h(t.id);return t},x=`
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`});var e=class e
26
26
  authFailedAt
27
27
  }
28
28
  }
29
- `,s=async(e={})=>{let{appConnections:t}=await r({query:o,variables:{filter:e},caller:`listConnections`});return t},c=(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},l=`
29
+ `,S=async(e={})=>{let{appConnections:t}=await v({query:x,variables:{filter:e},caller:`listConnections`});return t},C=(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},w=`
30
30
  mutation RunAgent($input: RunAgentInput!) {
31
31
  runAgent(input: $input) {
32
32
  result
@@ -34,5 +34,5 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=class e
34
34
  success
35
35
  }
36
36
  }
37
- `,u=async e=>{let{runAgent:t}=await r({query:l,variables:{input:e},caller:`runAgent`});return t},d=class{constructor(e,t){this.__twentyHttpResponse=!0,this.body=e,this.status=t?.status,this.headers=t?.headers}};exports.AppConnectionAuthFailedError=e,exports.Response=d,exports.findConnectionForRequest=c,exports.getConnection=a,exports.listConnections=s,exports.runAgent=u;
37
+ `,T=async e=>{let{runAgent:t}=await v({query:w,variables:{input:e},caller:`runAgent`});return t},E=class{constructor(e,t){this.__twentyHttpResponse=!0,this.body=e,this.status=t?.status,this.headers=t?.headers}};exports.AppConnectionAuthFailedError=h,exports.Response=E,exports.findConnectionForRequest=C,exports.getConnection=b,exports.jsonSchemaToInputSchema=o,exports.listConnections=S,exports.runAgent=T;
38
38
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../../src/sdk/logic-function/connections/errors/app-connection-auth-failed.error.ts","../../../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/response.ts"],"sourcesContent":["// 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/application/constants/AssetDirectory.ts\nvar e = \"public\", t = \"TWENTY_API_KEY\", n = \"TWENTY_API_URL\", r = \"TWENTY_APP_ACCESS_TOKEN\", i = \"generated\", a = { js: \"import { createRequire as __createRequire } from 'module';\\nconst require = __createRequire(import.meta.url);\" }, o = \".twenty/output\", s = \"Standard\", c = \"20202020-64aa-4b6f-b003-9c74b97cee20\", l = /* @__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}({});\n//#endregion\nexport { e as ASSETS_DIR, t as DEFAULT_API_KEY_NAME, n as DEFAULT_API_URL_NAME, r as DEFAULT_APP_ACCESS_TOKEN_NAME, i as GENERATED_DIR, a as NODE_ESM_CJS_BANNER, o as OUTPUT_DIR, l as SyncableEntity, s as TWENTY_STANDARD_APPLICATION_NAME, c as TWENTY_STANDARD_APPLICATION_UNIVERSAL_IDENTIFIER };\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 { 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":"mEASA,IAAa,EAAb,cAAkD,KAAM,CAGtD,YAAY,EAAsB,CAChC,MACE,kBAAkB,EAAa,gGAEjC,EACA,KAAK,KAAO,+BACZ,KAAK,aAAe,CACtB,CACF,ECnBwC,EAAI,iBAAkB,EAAI,0BCIrD,EAAqB,MAA0B,CAC1D,QACA,YACA,YAKoB,CACpB,IAAM,EAAS,QAAQ,IAAI,GACrB,EAAc,QAAQ,IAAI,GAEhC,GAAI,CAAC,GAAU,CAAC,EACd,MAAU,MACR,GAAG,EAAO,uCACL,EAAqB,OAAO,EAA8B,EACjE,EAGF,IAAM,EAAW,MAAM,MAAM,GAAG,EAAO,WAAY,CACjD,OAAQ,OACR,QAAS,CACP,eAAgB,mBAChB,cAAe,UAAU,GAC3B,EACA,KAAM,KAAK,UAAU,CAAE,QAAO,WAAU,CAAC,CAC3C,CAAC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B,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","c"],"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-Dib-Wyry.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/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/ViewKey.ts\nvar e = /* @__PURE__ */ function(e) {\n\treturn e.INDEX = \"INDEX\", e;\n}({});\n//#endregion\nexport { e as t };\n","import { t as e } from \"./ViewKey-Dib-Wyry.mjs\";\nimport { v5 as t } from \"uuid\";\n//#region src/application/constants/AssetDirectory.ts\nvar n = \"public\", r = \"TWENTY_API_KEY\", i = \"TWENTY_API_URL\", a = \"TWENTY_APP_ACCESS_TOKEN\", o = \"TWENTY_FUNCTIONS_URL\", s = \"generated\", c = { js: \"import { createRequire as __createRequire } from 'module';\\nconst require = __createRequire(import.meta.url);\" }, l = \".twenty/output\", u = \"Standard\", d = \"20202020-64aa-4b6f-b003-9c74b97cee20\", f = ({ entityNamespace: e, value: n, applicationUniversalIdentifier: r }) => t(`${e}:${n}`, r), p = ({ applicationUniversalIdentifier: e, name: t }) => f({\n\tentityNamespace: \"agent\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), m = ({ applicationUniversalIdentifier: e, key: t }) => f({\n\tentityNamespace: \"applicationVariable\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), h = \"navigation\", g = ({ applicationUniversalIdentifier: e, engineComponentKey: t }) => f({\n\tentityNamespace: \"commandMenuItem\",\n\tvalue: `GLOBAL:${t}`,\n\tapplicationUniversalIdentifier: e\n}), _ = ({ applicationUniversalIdentifier: e, engineComponentKey: t }) => f({\n\tentityNamespace: \"commandMenuItem\",\n\tvalue: `GLOBAL_OBJECT_CONTEXT:${t}`,\n\tapplicationUniversalIdentifier: e\n}), v = ({ applicationUniversalIdentifier: e, engineComponentKey: t, objectUniversalIdentifier: n }) => f({\n\tentityNamespace: \"commandMenuItem\",\n\tvalue: `RECORD_SELECTION:${t}:${n ?? \"\"}`,\n\tapplicationUniversalIdentifier: e\n}), y = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t }) => f({\n\tentityNamespace: \"commandMenuItem\",\n\tvalue: `${t}:${h}`,\n\tapplicationUniversalIdentifier: e\n}), b = ({ applicationUniversalIdentifier: e, name: t }) => f({\n\tentityNamespace: \"connectionProvider\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), x = ({ applicationUniversalIdentifier: e, roleUniversalIdentifier: t, fieldUniversalIdentifier: n }) => f({\n\tentityNamespace: \"fieldPermission\",\n\tvalue: `${t}:${n}`,\n\tapplicationUniversalIdentifier: e\n}), S = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t, name: n }) => f({\n\tentityNamespace: \"fieldMetadata\",\n\tvalue: `${t}:${n}`,\n\tapplicationUniversalIdentifier: e\n}), C = ({ applicationUniversalIdentifier: e, componentName: t }) => f({\n\tentityNamespace: \"frontComponent\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), w = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t, name: n }) => f({\n\tentityNamespace: \"index\",\n\tvalue: `${t}:${n}`,\n\tapplicationUniversalIdentifier: e\n}), T = ({ applicationUniversalIdentifier: e, name: t }) => f({\n\tentityNamespace: \"logicFunction\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), E = ({ applicationUniversalIdentifier: e, name: t }) => f({\n\tentityNamespace: \"navigationMenuItem\",\n\tvalue: `FOLDER:${t}`,\n\tapplicationUniversalIdentifier: e\n}), D = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t }) => f({\n\tentityNamespace: \"navigationMenuItem\",\n\tvalue: `OBJECT:${t}`,\n\tapplicationUniversalIdentifier: e\n}), O = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t }) => f({\n\tentityNamespace: \"navigationMenuItem\",\n\tvalue: `VIEW:${t}`,\n\tapplicationUniversalIdentifier: e\n}), k = ({ applicationUniversalIdentifier: e, link: t }) => f({\n\tentityNamespace: \"navigationMenuItem\",\n\tvalue: `LINK:${t}`,\n\tapplicationUniversalIdentifier: e\n}), A = ({ applicationUniversalIdentifier: e, roleUniversalIdentifier: t, objectUniversalIdentifier: n }) => f({\n\tentityNamespace: \"objectPermission\",\n\tvalue: `${t}:${n}`,\n\tapplicationUniversalIdentifier: e\n}), j = ({ applicationUniversalIdentifier: e, nameSingular: t }) => f({\n\tentityNamespace: \"objectMetadata\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), M = ({ applicationUniversalIdentifier: e, pageLayoutUniversalIdentifier: t, title: n }) => f({\n\tentityNamespace: \"pageLayoutTab\",\n\tvalue: `${t}:${n}`,\n\tapplicationUniversalIdentifier: e\n}), N = \"RECORD_PAGE\", P = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t, name: n }) => f({\n\tentityNamespace: \"pageLayout\",\n\tvalue: t ? `${t}:${n}` : n,\n\tapplicationUniversalIdentifier: e\n}), F = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t }) => f({\n\tentityNamespace: \"pageLayout\",\n\tvalue: `${t}:${N}`,\n\tapplicationUniversalIdentifier: e\n}), I = ({ applicationUniversalIdentifier: e, pageLayoutTabUniversalIdentifier: t, title: n }) => f({\n\tentityNamespace: \"pageLayoutWidget\",\n\tvalue: `${t}:${n}`,\n\tapplicationUniversalIdentifier: e\n}), L = ({ applicationUniversalIdentifier: e, key: t }) => f({\n\tentityNamespace: \"permissionFlag\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), R = ({ applicationUniversalIdentifier: e, roleUniversalIdentifier: t, permissionFlagUniversalIdentifier: n }) => f({\n\tentityNamespace: \"rolePermissionFlag\",\n\tvalue: `${t}:${n}`,\n\tapplicationUniversalIdentifier: e\n}), z = ({ applicationUniversalIdentifier: e, label: t }) => f({\n\tentityNamespace: \"role\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), B = ({ applicationUniversalIdentifier: e, fieldMetadataUniversalIdentifier: t }) => f({\n\tentityNamespace: \"searchFieldMetadata\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), V = ({ applicationUniversalIdentifier: e, fieldUniversalIdentifier: t, value: n }) => f({\n\tentityNamespace: \"selectOption\",\n\tvalue: `${t}:${n}`,\n\tapplicationUniversalIdentifier: e\n}), H = ({ applicationUniversalIdentifier: e, name: t }) => f({\n\tentityNamespace: \"skill\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), U = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t, name: n }) => f({\n\tentityNamespace: \"viewFieldGroup\",\n\tvalue: `${t}:${n}`,\n\tapplicationUniversalIdentifier: e\n}), W = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t, fieldMetadataUniversalIdentifier: n }) => f({\n\tentityNamespace: \"viewField\",\n\tvalue: `${t}:${n}`,\n\tapplicationUniversalIdentifier: e\n}), G = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t, fieldMetadataUniversalIdentifier: n, operand: r, subFieldName: i }) => f({\n\tentityNamespace: \"viewFilter\",\n\tvalue: `${t}:${n}:${r}:${i ?? \"\"}`,\n\tapplicationUniversalIdentifier: e\n}), K = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t, fieldValue: n }) => f({\n\tentityNamespace: \"viewGroup\",\n\tvalue: `${t}:${n}`,\n\tapplicationUniversalIdentifier: e\n}), q = ({ applicationUniversalIdentifier: e, viewUniversalIdentifier: t, fieldMetadataUniversalIdentifier: n }) => f({\n\tentityNamespace: \"viewSort\",\n\tvalue: `${t}:${n}`,\n\tapplicationUniversalIdentifier: e\n}), J = ({ applicationUniversalIdentifier: e, objectUniversalIdentifier: t, name: n }) => f({\n\tentityNamespace: \"view\",\n\tvalue: `${t}:${n}`,\n\tapplicationUniversalIdentifier: e\n}), Y = ({ applicationUniversalIdentifier: t, objectUniversalIdentifier: n }) => f({\n\tentityNamespace: \"view\",\n\tvalue: `${n}:${e.INDEX}`,\n\tapplicationUniversalIdentifier: t\n}), X = ({ applicationUniversalIdentifier: e, pageLayoutWidgetUniversalIdentifier: t }) => f({\n\tentityNamespace: \"view\",\n\tvalue: t,\n\tapplicationUniversalIdentifier: e\n}), Z = /* @__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}({});\n//#endregion\nexport { n as ASSETS_DIR, r as DEFAULT_API_KEY_NAME, i as DEFAULT_API_URL_NAME, a as DEFAULT_APP_ACCESS_TOKEN_NAME, o as DEFAULT_FUNCTIONS_URL_NAME, s as GENERATED_DIR, c as NODE_ESM_CJS_BANNER, l as OUTPUT_DIR, Z as SyncableEntity, u as TWENTY_STANDARD_APPLICATION_NAME, d as TWENTY_STANDARD_APPLICATION_UNIVERSAL_IDENTIFIER, f as computeDeterministicUuid, p as getAgentUniversalIdentifier, m as getApplicationVariableUniversalIdentifier, b as getConnectionProviderUniversalIdentifier, x as getFieldPermissionUniversalIdentifier, S as getFieldUniversalIdentifier, X as getFieldsWidgetViewUniversalIdentifier, E as getFolderNavigationMenuItemUniversalIdentifier, C as getFrontComponentUniversalIdentifier, g as getGlobalCommandMenuItemUniversalIdentifier, _ as getGlobalObjectContextCommandMenuItemUniversalIdentifier, w as getIndexUniversalIdentifier, Y as getIndexViewUniversalIdentifier, k as getLinkNavigationMenuItemUniversalIdentifier, T as getLogicFunctionUniversalIdentifier, y as getNavigationCommandUniversalIdentifier, D as getObjectNavigationMenuItemUniversalIdentifier, A as getObjectPermissionUniversalIdentifier, j as getObjectUniversalIdentifier, M as getPageLayoutTabUniversalIdentifier, P as getPageLayoutUniversalIdentifier, I as getPageLayoutWidgetUniversalIdentifier, L as getPermissionFlagUniversalIdentifier, F as getRecordPageLayoutUniversalIdentifier, v as getRecordSelectionCommandMenuItemUniversalIdentifier, R as getRolePermissionFlagUniversalIdentifier, z as getRoleUniversalIdentifier, B as getSearchFieldUniversalIdentifier, V as getSelectOptionUniversalIdentifier, H as getSkillUniversalIdentifier, U as getViewFieldGroupUniversalIdentifier, W as getViewFieldUniversalIdentifier, G as getViewFilterUniversalIdentifier, K as getViewGroupUniversalIdentifier, O as getViewNavigationMenuItemUniversalIdentifier, q as getViewSortUniversalIdentifier, J as getViewUniversalIdentifier };\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 { 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,EAAGC,GAAK,EAAG,IAAM,CAChB,GAAIC,EAAE,CAAC,EAAG,MAAO,CAChB,KAAM,SACN,YAAaF,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,EAAG,MAAO,EAAG,MAAO,EAAG,WAAY,EAAG,qBAAsB,EAAG,GAAG,GAAM,EAAG,EAAI,CAAE,GAAG,CAAE,EACrI,OAAOG,EAAAA,EAAE,CAAC,IAAM,EAAE,MAAQF,EAAE,EAAG,CAAC,GAAIE,EAAAA,EAAE,CAAC,IAAM,EAAE,WAAa,OAAO,YAAY,OAAO,QAAQ,CAAC,EAAE,KAAK,CAAC,EAAG,KAAO,CAAC,EAAGF,EAAE,EAAG,CAAC,CAAC,CAAC,CAAC,GAAIE,EAAAA,EAAE,CAAC,IAAM,EAAE,sBAAA,EAAA,EAAA,UAAyB,CAAC,EAAIF,EAAE,EAAG,CAAC,EAAI,GAAI,CAC1L,EAGGI,EAAK,GAAM,CACb,IAAI,EAAI,CAAE,KAAM,SAAU,EAC1B,OAAQ,EAAE,KAAV,CACC,IAAK,SACJ,EAAE,KAAO,SACT,MACD,IAAK,SACL,IAAK,UACJ,EAAE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U,MAAM,GAAG,EAAO,uCAAuC,EAGnE,OAAO,EAAK,IACd,ECnDM,EAA2B;;;;;;;;;;;;;;EAgBpB,EAAgB,KAAO,IAAuC,CACzE,GAAM,CAAE,iBAAkB,MAAM,EAG9B,CACA,MAAO,EACP,UAAW,CAAE,IAAG,EAChB,OAAQ,eACV,CAAC,EAED,GAAI,EAAc,eAAiB,KACjC,MAAM,IAAI,EAA6B,EAAc,EAAE,EAGzD,OAAO,CACT,EChCM,EAA6B;;;;;;;;;;;;;;EAsBtB,EAAkB,MAC7B,EAAgC,CAAC,IACJ,CAC7B,GAAM,CAAE,kBAAmB,MAAM,EAG/B,CACA,MAAO,EACP,UAAW,CAAE,QAAO,EACpB,OAAQ,iBACV,CAAC,EAED,OAAO,CACT,ECpCa,GACX,EACA,IACyB,CACzB,GAAI,EAAM,kBAAoB,KAAM,CAClC,IAAM,EAAW,EAAY,KAC1B,GACC,EAAW,aAAe,QAC1B,EAAW,kBAAoB,EAAM,eACzC,EAEA,GAAI,EACF,OAAO,CAEX,CAMA,OAJwB,EAAY,KACjC,GAAe,EAAW,aAAe,WAGrC,GAAmB,IAC5B,EChBM,EAAqB;;;;;;;;EAUd,EAAW,KACtB,IAC4B,CAC5B,GAAM,CAAE,SAAU,GAAW,MAAM,EAGjC,CACA,MAAO,EACP,UAAW,CAAE,OAAM,EACnB,OAAQ,UACV,CAAC,EAED,OAAO,CACT,ECvBa,EAAb,KAA2D,CAMzD,YAAY,EAAe,EAAqB,2BALhB,GAM9B,KAAK,KAAO,EACZ,KAAK,OAAS,GAAM,OACpB,KAAK,QAAU,GAAM,OACvB,CACF"}
@@ -73,8 +73,12 @@ type LogicFunctionHttpResponse = {
73
73
  headers?: Record<string, string>;
74
74
  };
75
75
 
76
+ type ServerRouteTriggerSettings = {
77
+ forwardedRequestHeaders?: string[];
78
+ };
79
+
76
80
  type InputJsonSchema = {
77
- type?: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'integer' | 'null';
81
+ type?: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'integer' | 'null' | 'record' | 'records';
78
82
  description?: string;
79
83
  enum?: unknown[];
80
84
  items?: InputJsonSchema;
@@ -85,6 +89,7 @@ type InputJsonSchema = {
85
89
  maximum?: number;
86
90
  multiline?: boolean;
87
91
  label?: string;
92
+ objectUniversalIdentifier?: string;
88
93
  };
89
94
 
90
95
  type ToolTriggerSettings = {
@@ -94,7 +99,10 @@ type ToolTriggerSettings = {
94
99
  type LeafType = 'string' | 'number' | 'boolean' | 'array' | 'unknown';
95
100
  type NodeType = 'object' | 'unknown';
96
101
 
97
- type InputSchemaPropertyType = LeafType | NodeType | FieldMetadataType;
102
+ declare const jsonSchemaToInputSchema: (jsonSchema: InputJsonSchema) => InputSchema;
103
+
104
+ type RecordSchemaType = 'record' | 'records';
105
+ type InputSchemaPropertyType = LeafType | NodeType | RecordSchemaType | FieldMetadataType;
98
106
  type InputSchemaProperty = {
99
107
  type: InputSchemaPropertyType;
100
108
  enum?: string[];
@@ -102,6 +110,7 @@ type InputSchemaProperty = {
102
110
  properties?: Properties$1;
103
111
  multiline?: boolean;
104
112
  label?: string;
113
+ objectUniversalIdentifier?: string;
105
114
  };
106
115
  type Properties$1 = {
107
116
  [name: string]: InputSchemaProperty;
@@ -122,6 +131,7 @@ type LogicFunctionManifest = SyncableEntityOptions & {
122
131
  cronTriggerSettings?: CronTriggerSettings;
123
132
  databaseEventTriggerSettings?: DatabaseEventTriggerSettings;
124
133
  httpRouteTriggerSettings?: HttpRouteTriggerSettings;
134
+ serverRouteTriggerSettings?: ServerRouteTriggerSettings;
125
135
  toolTriggerSettings?: ToolTriggerSettings;
126
136
  workflowActionTriggerSettings?: WorkflowActionTriggerSettings;
127
137
  sourceHandlerPath: string;
@@ -154,9 +164,20 @@ type RunAgentResult = {
154
164
  };
155
165
 
156
166
  type LogicFunctionHandler = (...args: any[]) => any | Promise<any>;
157
- type LogicFunctionConfig = Omit<LogicFunctionManifest, 'sourceHandlerPath' | 'builtHandlerPath' | 'builtHandlerChecksum' | 'handlerName'> & {
158
- handler: LogicFunctionHandler;
167
+ type ServerRouteResolverResult = {
168
+ workspaceId: string;
169
+ targetLogicFunctionUniversalIdentifier: string;
170
+ payload?: object;
159
171
  };
172
+ type ServerRouteResolverHandler = (...args: any[]) => ServerRouteResolverResult | Promise<ServerRouteResolverResult>;
173
+ type LogicFunctionConfigBase = Omit<LogicFunctionManifest, 'sourceHandlerPath' | 'builtHandlerPath' | 'builtHandlerChecksum' | 'handlerName' | 'serverRouteTriggerSettings'>;
174
+ type LogicFunctionConfig = LogicFunctionConfigBase & ({
175
+ serverRouteTriggerSettings?: undefined;
176
+ handler: LogicFunctionHandler;
177
+ } | {
178
+ serverRouteTriggerSettings: ServerRouteTriggerSettings;
179
+ handler: ServerRouteResolverHandler;
180
+ });
160
181
 
161
182
  type InstallPayload = {
162
183
  previousVersion?: string;
@@ -313,5 +334,5 @@ declare class Response implements LogicFunctionHttpResponse {
313
334
  constructor(body: unknown, init?: ResponseInit);
314
335
  }
315
336
 
316
- export { AppConnectionAuthFailedError, ObjectRecordBaseEvent, ObjectRecordCreateEvent, ObjectRecordDeleteEvent, ObjectRecordDestroyEvent, ObjectRecordRestoreEvent, ObjectRecordUpdateEvent, ObjectRecordUpsertEvent, Response, findConnectionForRequest, getConnection, listConnections, runAgent };
337
+ export { AppConnectionAuthFailedError, ObjectRecordBaseEvent, ObjectRecordCreateEvent, ObjectRecordDeleteEvent, ObjectRecordDestroyEvent, ObjectRecordRestoreEvent, ObjectRecordUpdateEvent, ObjectRecordUpsertEvent, Response, findConnectionForRequest, getConnection, jsonSchemaToInputSchema, listConnections, runAgent };
317
338
  export type { AppConnection, CronPayload, DatabaseEventPayload, InputJsonSchema, InstallHandler, InstallPayload, ListConnectionsFilter, LogicFunctionConfig, LogicFunctionHandler, ObjectRecordEvent, ResponseInit, LogicFunctionEvent as RoutePayload, RunAgentInput, RunAgentResult };
@@ -1,61 +1,177 @@
1
- //#region src/sdk/logic-function/connections/errors/app-connection-auth-failed.error.ts
2
- var e = class extends Error {
1
+ import { t as e } from "./isDefined-Dtu5EYqP-CMNeFg4z.mjs";
2
+ import { isNonEmptyString as t, isObject as n } from "@sniptt/guards";
3
+ import "uuid";
4
+ //#region ../twenty-shared/dist/is-record-object-schema-CwzshFdt.mjs
5
+ var r = (e) => (e?.type === "record" || e?.type === "object") && t(e.objectUniversalIdentifier), i = (e, n) => {
6
+ let r = t(e) ? n?.(e) : void 0;
7
+ return `Id of the ${t(r) ? r : "linked"} record`;
8
+ }, a = (t, o) => {
9
+ if (r(t)) return {
10
+ type: "string",
11
+ description: i(t.objectUniversalIdentifier, o)
12
+ };
13
+ if (t.type === "records") return {
14
+ type: "array",
15
+ items: {
16
+ type: "string",
17
+ description: i(t.objectUniversalIdentifier, o)
18
+ }
19
+ };
20
+ let { objectUniversalIdentifier: s, multiline: c, label: l, items: u, properties: d, additionalProperties: f, ...p } = t, m = { ...p };
21
+ return 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 = n(f) ? a(f, o) : f), m;
22
+ }, o = (e) => {
23
+ let n = { type: "unknown" };
24
+ switch (e.type) {
25
+ case "string":
26
+ n.type = "string";
27
+ break;
28
+ case "number":
29
+ case "integer":
30
+ n.type = "number";
31
+ break;
32
+ case "boolean":
33
+ n.type = "boolean";
34
+ break;
35
+ case "array":
36
+ n.type = "array", e.items && (n.items = o(e.items));
37
+ break;
38
+ case "object":
39
+ n.type = "object", e.properties && (n.properties = Object.fromEntries(Object.entries(e.properties).map(([e, t]) => [e, o(t)])));
40
+ break;
41
+ case "record":
42
+ n.type = "record";
43
+ break;
44
+ case "records":
45
+ n.type = "records";
46
+ break;
47
+ default: n.type = "unknown";
48
+ }
49
+ 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
+ }, s = (e) => [o(e)];
51
+ s({
52
+ type: "object",
53
+ properties: {
54
+ a: { type: "string" },
55
+ b: { type: "number" }
56
+ }
57
+ });
58
+ //#endregion
59
+ //#region ../twenty-shared/dist/logic-function.mjs
60
+ var c = (t) => !e(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, [t, r]) => (n(r) && !Array.isArray(r) ? e[t] = {
61
+ isLeaf: !1,
62
+ type: "object",
63
+ label: t,
64
+ value: l(r)
65
+ } : e[t] = {
66
+ isLeaf: !0,
67
+ value: r,
68
+ type: c(r),
69
+ label: t
70
+ }, e), {}) : {}, u = (e, t) => e ? `${e}.${t}` : t, d = (t, n, r = "") => {
71
+ let i = [];
72
+ for (let [a, o] of Object.entries(n)) {
73
+ let n = u(r, a), s = t[a];
74
+ if (!e(s)) {
75
+ i.push(`Missing key "${n}" in declared output schema.`);
76
+ continue;
77
+ }
78
+ if (o.isLeaf !== s.isLeaf) {
79
+ i.push(`Type mismatch at "${n}": expected ${o.isLeaf ? o.type : "object"} but declared ${s.isLeaf ? s.type : "object"}.`);
80
+ continue;
81
+ }
82
+ if (!o.isLeaf && !s.isLeaf) {
83
+ i.push(...d(s.value, o.value, n));
84
+ continue;
85
+ }
86
+ 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
+ return i;
89
+ }, f = [
90
+ "string",
91
+ "number",
92
+ "boolean",
93
+ "array",
94
+ "unknown"
95
+ ], p = (e) => f.includes(e), m = (e, t) => {
96
+ let r = t.label ?? e;
97
+ return t.type === "record" ? {
98
+ isLeaf: !0,
99
+ type: "string",
100
+ label: r,
101
+ value: null
102
+ } : t.type === "records" ? {
103
+ isLeaf: !0,
104
+ type: "array",
105
+ label: r,
106
+ value: null
107
+ } : t.type === "object" ? {
108
+ isLeaf: !1,
109
+ type: "object",
110
+ label: r,
111
+ value: n(t.properties) ? h(t.properties) : {}
112
+ } : {
113
+ isLeaf: !0,
114
+ type: p(t.type) ? t.type : "unknown",
115
+ label: r,
116
+ value: null
117
+ };
118
+ }, h = (e) => Object.entries(e).reduce((e, [t, n]) => (e[t] = m(t, n), e), {}), g = class extends Error {
3
119
  constructor(e) {
4
120
  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;
5
121
  }
6
- }, t = "TWENTY_API_URL", n = "TWENTY_APP_ACCESS_TOKEN", r = async ({ query: e, variables: r, caller: i }) => {
7
- let a = process.env[t], o = process.env[n];
8
- if (!a || !o) throw Error(`${i}() requires the app runtime env vars ${t} and ${n}.`);
9
- let s = await fetch(`${a}/metadata`, {
122
+ }, _ = "TWENTY_API_URL", v = "TWENTY_APP_ACCESS_TOKEN", y = async ({ query: e, variables: t, caller: n }) => {
123
+ let r = process.env[_], i = process.env[v];
124
+ if (!r || !i) throw Error(`${n}() requires the app runtime env vars ${_} and ${v}.`);
125
+ let a = await fetch(`${r}/metadata`, {
10
126
  method: "POST",
11
127
  headers: {
12
128
  "Content-Type": "application/json",
13
- Authorization: `Bearer ${o}`
129
+ Authorization: `Bearer ${i}`
14
130
  },
15
131
  body: JSON.stringify({
16
132
  query: e,
17
- variables: r
133
+ variables: t
18
134
  })
19
135
  });
20
- if (!s.ok) throw Error(`${i}() failed: HTTP ${s.status} ${s.statusText}`);
21
- let c = await s.json();
22
- if (c.errors && c.errors.length > 0) throw Error(`${i}() failed: ${c.errors.map((e) => e.message).join(", ")}`);
23
- if (!c.data) throw Error(`${i}() failed: response contained no data.`);
24
- return c.data;
25
- }, i = "\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", a = async (t) => {
26
- let { appConnection: n } = await r({
27
- query: i,
28
- variables: { id: t },
136
+ if (!a.ok) throw Error(`${n}() failed: HTTP ${a.status} ${a.statusText}`);
137
+ let o = await a.json();
138
+ if (o.errors && o.errors.length > 0) throw Error(`${n}() failed: ${o.errors.map((e) => e.message).join(", ")}`);
139
+ if (!o.data) throw Error(`${n}() failed: response contained no data.`);
140
+ return o.data;
141
+ }, b = "\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", x = async (e) => {
142
+ let { appConnection: t } = await y({
143
+ query: b,
144
+ variables: { id: e },
29
145
  caller: "getConnection"
30
146
  });
31
- if (n.authFailedAt !== null) throw new e(n.id);
32
- return n;
33
- }, o = "\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", s = async (e = {}) => {
34
- let { appConnections: t } = await r({
35
- query: o,
147
+ if (t.authFailedAt !== null) throw new g(t.id);
148
+ return t;
149
+ }, S = "\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", C = async (e = {}) => {
150
+ let { appConnections: t } = await y({
151
+ query: S,
36
152
  variables: { filter: e },
37
153
  caller: "listConnections"
38
154
  });
39
155
  return t;
40
- }, c = (e, t) => {
156
+ }, w = (e, t) => {
41
157
  if (t.userWorkspaceId !== null) {
42
158
  let n = e.find((e) => e.visibility === "user" && e.userWorkspaceId === t.userWorkspaceId);
43
159
  if (n) return n;
44
160
  }
45
161
  return e.find((e) => e.visibility === "workspace") ?? null;
46
- }, l = "\n mutation RunAgent($input: RunAgentInput!) {\n runAgent(input: $input) {\n result\n error\n success\n }\n }\n", u = async (e) => {
47
- let { runAgent: t } = await r({
48
- query: l,
162
+ }, T = "\n mutation RunAgent($input: RunAgentInput!) {\n runAgent(input: $input) {\n result\n error\n success\n }\n }\n", E = async (e) => {
163
+ let { runAgent: t } = await y({
164
+ query: T,
49
165
  variables: { input: e },
50
166
  caller: "runAgent"
51
167
  });
52
168
  return t;
53
- }, d = class {
169
+ }, D = class {
54
170
  constructor(e, t) {
55
171
  this.__twentyHttpResponse = !0, this.body = e, this.status = t?.status, this.headers = t?.headers;
56
172
  }
57
173
  };
58
174
  //#endregion
59
- export { e as AppConnectionAuthFailedError, d as Response, c as findConnectionForRequest, a as getConnection, s as listConnections, u as runAgent };
175
+ export { g as AppConnectionAuthFailedError, D as Response, w as findConnectionForRequest, x as getConnection, s as jsonSchemaToInputSchema, C as listConnections, E as runAgent };
60
176
 
61
177
  //# sourceMappingURL=index.mjs.map