Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 22, 20:45 UTC
feat(cli): generate TS types for trigger payloads and events (#1830)
Co-authored-by: jkomyno <12381818+jkomyno@users.noreply.github.com>
Alberto Schiabel committed
Aug 13, 2025 at 02:46 UTC
9c2761da992db230b07ecb1a02dd7cf272270c92
22 files changed
+1767
-295
pnpm-lock.yaml
+218
-29
@@ -565,6 +565,9 @@ importers:
565
open:
566
specifier: ^10.2.0
567
version: 10.2.0
568
+ openapi-typescript:
569
+ specifier: ^7.8.0
570
+ version: 7.8.0(typescript@5.8.3)
571
picocolors:
572
specifier: ^1.1.1
573
version: 1.1.1
@@ -577,6 +580,9 @@ importers:
580
superjson:
581
specifier: ^2.2.2
582
version: 2.2.2
583
+ ts-morph:
584
+ specifier: ^26.0.0
585
+ version: 26.0.0
586
devDependencies:
587
'@effect/eslint-plugin':
588
specifier: ^0.3.2
@@ -1062,6 +1068,10 @@ packages:
1068
resolution: {integrity: sha512-DIIotRnefVL6DiaHtO6/21DhJ4JZnnIwdNbpwiAhdt/AVbttcE4yw925gsjur0OGv5BTYXQXU3YnANBYnZjuQA==}
1069
engines: {node: '>=18.0.0'}
1070
1071
+ '@babel/code-frame@7.27.1':
1072
+ resolution: {integrity: sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==}
1073
+ engines: {node: '>=6.9.0'}
1074
+
1075
'@babel/helper-validator-identifier@7.27.1':
1076
resolution: {integrity: sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==}
1077
engines: {node: '>=6.9.0'}
@@ -2038,6 +2048,14 @@ packages:
2048
resolution: {integrity: sha512-XvJRx+2KR3YXyYtPUUy+qd9i7p+GO9Ko6VIIpWlBrpWwXDv8WLFeHTxz35CfQFUiBMLXlGHhGzys7lqit9gWag==}
2049
engines: {node: '>=18'}
2050
2051
+ '@isaacs/balanced-match@4.0.1':
2052
+ resolution: {integrity: sha512-yzMTt9lEb8Gv7zRioUilSglI0c0smZ9k5D65677DLWLtWJaXIS3CqcGyUFByYKlnUj6TkjLVs54fBl6+TiGQDQ==}
2053
+ engines: {node: 20 || >=22}
2054
+
2055
+ '@isaacs/brace-expansion@5.0.0':
2056
+ resolution: {integrity: sha512-ZT55BDLV0yv0RBm2czMiZ+SqCGO7AvmOM3G/w2xhVPH+te0aKgFjmBvGlL1dH+ql2tgGO3MVrbb3jCKyvpgnxA==}
2057
+ engines: {node: 20 || >=22}
2058
+
2059
'@isaacs/cliui@8.0.2':
2060
resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==}
2061
engines: {node: '>=12'}
@@ -2869,6 +2887,16 @@ packages:
2887
'@protobufjs/utf8@1.1.0':
2888
resolution: {integrity: sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==}
2889
2890
+ '@redocly/ajv@8.11.3':
2891
+ resolution: {integrity: sha512-4P3iZse91TkBiY+Dx5DUgxQ9GXkVJf++cmI0MOyLDxV9b5MUBI4II6ES8zA5JCbO72nKAJxWrw4PUPW+YP3ZDQ==}
2892
+
2893
+ '@redocly/config@0.22.2':
2894
+ resolution: {integrity: sha512-roRDai8/zr2S9YfmzUfNhKjOF0NdcOIqF7bhf4MVC5UxpjIysDjyudvlAiVbpPHp3eDRWbdzUgtkK1a7YiDNyQ==}
2895
+
2896
+ '@redocly/openapi-core@1.34.5':
2897
+ resolution: {integrity: sha512-0EbE8LRbkogtcCXU7liAyC00n9uNG9hJ+eMyHFdUsy9lB/WGqnEBgwjA9q2cyzAVcdTkQqTBBU1XePNnN3OijA==}
2898
+ engines: {node: '>=18.17.0', npm: '>=9.5.0'}
2899
+
2900
'@rollup/rollup-android-arm-eabi@4.43.0':
2901
resolution: {integrity: sha512-Krjy9awJl6rKbruhQDgivNbD1WuLb8xAclM4IR4cN5pHGAs2oIMMQJEiC3IC/9TZJ+QZkmZhlMO/6MBGxPidpw==}
2902
cpu: [arm]
@@ -3219,6 +3247,9 @@ packages:
3247
'@swc/helpers@0.5.15':
3248
resolution: {integrity: sha512-JQ5TuMi45Owi4/BIMAJBoSQoOJu12oOk/gADqlcUL9JEdHB8vyjUSsxqeNXnmXHjYKMi2WcYtezGEEhqUI/E2g==}
3249
3250
+ '@ts-morph/common@0.27.0':
3251
+ resolution: {integrity: sha512-Wf29UqxWDpc+i61k3oIOzcUfQt79PIT9y/MWfAGlrkjg6lBC1hwDECLXPVJAhWjiGbfBCxZd65F/LIZF3+jeJQ==}
3252
+
3253
'@types/aws-lambda@8.10.147':
3254
resolution: {integrity: sha512-nD0Z9fNIZcxYX5Mai2CTmFD7wX7UldCkW2ezCF8D1T5hdiLsnTWDGRpfRYntU6VjTdLQjOvyszru7I1c1oCQew==}
3255
@@ -3705,6 +3736,9 @@ packages:
3736
resolution: {integrity: sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w==}
3737
engines: {node: ^12.17.0 || ^14.13 || >=16.0.0}
3738
3739
+ change-case@5.4.4:
3740
+ resolution: {integrity: sha512-HRQyTk2/YPEkt9TnUPbOpr64Uw3KOicFWPVBb+xiHvd6eBx/qPr9xqfBFDT8P2vWsvvz4jbEkfDe71W3VyNu2w==}
3741
+
3742
chardet@0.7.0:
3743
resolution: {integrity: sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==}
3744
@@ -3754,6 +3788,9 @@ packages:
3788
resolution: {integrity: sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==}
3789
engines: {node: '>=0.8'}
3790
3791
+ code-block-writer@13.0.3:
3792
+ resolution: {integrity: sha512-Oofo0pq3IKnsFtuHqSF7TqBfr71aeyZDVJ0HpmqB7FBM2qEigL0iPONSCZSO9pE9dZTAxANe5XHG9Uy0YMv8cg==}
3793
+
3794
cohere-ai@7.17.1:
3795
resolution: {integrity: sha512-GI/uWVYYGIN3gdjJRlbjEaLJNJVXsUJyOlPqwBWgAmK18kP4CJoErxKwU0aLe3tHHOBcC2RqXe6PmGO0dz7dpQ==}
3796
@@ -3771,6 +3808,9 @@ packages:
3808
resolution: {integrity: sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==}
3809
engines: {node: '>=12.5.0'}
3810
3811
+ colorette@1.4.0:
3812
+ resolution: {integrity: sha512-Y2oEozpomLn7Q3HFP7dpww7AtMJplbM9lGZP6RDfHqmbeRjiwRg4n6VM6j4KLmRke85uWEI7JqF17f3pqdRA0g==}
3813
+
3814
colorette@2.0.20:
3815
resolution: {integrity: sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==}
3816
@@ -4636,6 +4676,10 @@ packages:
4676
resolution: {integrity: sha512-m6FAo/spmsW2Ab2fU35JTYwtOKa2yAwXSwgjSv1TJzh4Mh7mC3lzAOVLBprb72XsTrgkEIsl7YrFNAiDiRhIGg==}
4677
engines: {node: '>=12'}
4678
4679
+ index-to-position@1.1.0:
4680
+ resolution: {integrity: sha512-XPdx9Dq4t9Qk1mTMbWONJqU7boCoumEH7fRET37HX5+khDUl3J2W6PdALxhILYlIYx2amlwYcRPp28p0tSiojg==}
4681
+ engines: {node: '>=18'}
4682
+
4683
inherits@2.0.4:
4684
resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==}
4685
@@ -4774,6 +4818,10 @@ packages:
4818
js-base64@3.7.2:
4819
resolution: {integrity: sha512-NnRs6dsyqUXejqk/yv2aiXlAvOs56sLkX6nUdeaNezI5LFFLlsZjOThmwnrcwh5ZZRwZlCMnVAY3CvhIhoVEKQ==}
4820
4821
+ js-levenshtein@1.1.6:
4822
+ resolution: {integrity: sha512-X2BB11YZtrRqY4EnQcLX5Rh373zbK4alC1FW7D7MBhL2gtcC17cTnr6DmfHZeS0s2rTHjUTMMHfG7gO8SSdw+g==}
4823
+ engines: {node: '>=0.10.0'}
4824
+
4825
js-tiktoken@1.0.20:
4826
resolution: {integrity: sha512-Xlaqhhs8VfCd6Sh7a1cFkZHQbYTLCwVJJWiHVxBYzLPxW0XsoxBy1hitmjkdIjD3Aon5BXLHFwU5O8WUx6HH+A==}
4827
@@ -4804,6 +4852,9 @@ packages:
4852
json-schema-traverse@0.4.1:
4853
resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==}
4854
4855
+ json-schema-traverse@1.0.0:
4856
+ resolution: {integrity: sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==}
4857
+
4858
json-schema-walker@2.0.0:
4859
resolution: {integrity: sha512-nXN2cMky0Iw7Af28w061hmxaPDaML5/bQD9nwm1lOoIKEGjHcRGxqWe4MfrkYThYAPjSUhmsp4bJNoLAyVn9Xw==}
4860
engines: {node: '>=10'}
@@ -5071,9 +5122,17 @@ packages:
5122
engines: {node: '>=18.0.0'}
5123
hasBin: true
5124
5125
+ minimatch@10.0.3:
5126
+ resolution: {integrity: sha512-IPZ167aShDZZUMdRk66cyQAW3qr0WzbHkPdMYa8bzZhlHhO3jALbKdxcaak7W9FfT2rZNpQuUu4Od7ILEpXSaw==}
5127
+ engines: {node: 20 || >=22}
5128
+
5129
minimatch@3.1.2:
5130
resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==}
5131
5132
+ minimatch@5.1.6:
5133
+ resolution: {integrity: sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==}
5134
+ engines: {node: '>=10'}
5135
+
5136
minimatch@9.0.5:
5137
resolution: {integrity: sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==}
5138
engines: {node: '>=16 || 14 >=14.17'}
@@ -5265,6 +5324,12 @@ packages:
5324
openapi-types@12.1.3:
5325
resolution: {integrity: sha512-N4YtSYJqghVu4iek2ZUvcN/0aqH1kRDuNqzcycDxhOUpg7GdvLa2F3DgS6yBNhInhv2r/6I0Flkn7CqL8+nIcw==}
5326
5327
+ openapi-typescript@7.8.0:
5328
+ resolution: {integrity: sha512-1EeVWmDzi16A+siQlo/SwSGIT7HwaFAVjvMA7/jG5HMLSnrUOzPL7uSTRZZa4v/LCRxHTApHKtNY6glApEoiUQ==}
5329
+ hasBin: true
5330
+ peerDependencies:
5331
+ typescript: ^5.x
5332
+
5333
optionator@0.9.4:
5334
resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==}
5335
engines: {node: '>= 0.8.0'}
@@ -5330,10 +5395,17 @@ packages:
5395
resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==}
5396
engines: {node: '>=6'}
5397
5398
+ parse-json@8.3.0:
5399
+ resolution: {integrity: sha512-ybiGyvspI+fAoRQbIPRddCcSTV9/LsJbf0e/S85VLowVGzRmokfneg2kwVW/KU5rOXrPSbF1qAKPMgNTqqROQQ==}
5400
+ engines: {node: '>=18'}
5401
+
5402
parseurl@1.3.3:
5403
resolution: {integrity: sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==}
5404
engines: {node: '>= 0.8'}
5405
5406
+ path-browserify@1.0.1:
5407
+ resolution: {integrity: sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==}
5408
+
5409
path-exists@4.0.0:
5410
resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==}
5411
engines: {node: '>=8'}
@@ -5457,6 +5529,10 @@ packages:
5529
pkg-types@1.3.1:
5530
resolution: {integrity: sha512-/Jm5M4RvtBFVkKWRu2BLUTNP8/M2a+UwuAX+ae4770q1qVGtfjG+WTCupoZixokjmHiry8uI+dlY8KXYV5HVVQ==}
5531
5532
+ pluralize@8.0.0:
5533
+ resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==}
5534
+ engines: {node: '>=4'}
5535
+
5536
possible-typed-array-names@1.1.0:
5537
resolution: {integrity: sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==}
5538
engines: {node: '>= 0.4'}
@@ -5682,6 +5758,10 @@ packages:
5758
resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==}
5759
engines: {node: '>=0.10.0'}
5760
5761
+ require-from-string@2.0.2:
5762
+ resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==}
5763
+ engines: {node: '>=0.10.0'}
5764
+
5765
require-in-the-middle@7.5.2:
5766
resolution: {integrity: sha512-gAZ+kLqBdHarXB64XpAe2VCjB7rIRv+mU8tfRWziHRJ5umKsIHN2tLLv6EtMw7WCdP19S0ERVMldNvxYCHnhSQ==}
5767
engines: {node: '>=8.6.0'}
@@ -6120,6 +6200,9 @@ packages:
6200
ts-interface-checker@0.1.13:
6201
resolution: {integrity: sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==}
6202
6203
+ ts-morph@26.0.0:
6204
+ resolution: {integrity: sha512-ztMO++owQnz8c/gIENcM9XfCEzgoGphTv+nKpYNM1bgsdOVC/jRZuEBf6N+mLLDNg68Kl+GgUZfOySaRiG1/Ug==}
6205
+
6206
tslib@1.14.1:
6207
resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==}
6208
@@ -6203,6 +6286,10 @@ packages:
6286
resolution: {integrity: sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==}
6287
engines: {node: '>=12.20'}
6288
6289
+ type-fest@4.41.0:
6290
+ resolution: {integrity: sha512-TeTSQ6H5YHvpqVwBRcnLDCBnDOHWYu7IvGbHT6N8AOymcr9PJGjc1GTtiWZTYg0NCgYwvnYWEkVChQAr9bjfwA==}
6291
+ engines: {node: '>=16'}
6292
+
6293
type-is@1.6.18:
6294
resolution: {integrity: sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==}
6295
engines: {node: '>= 0.6'}
@@ -6289,6 +6376,9 @@ packages:
6376
resolution: {integrity: sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==}
6377
engines: {node: '>= 0.8'}
6378
6379
+ uri-js-replace@1.0.1:
6380
+ resolution: {integrity: sha512-W+C9NWNLFOoBI2QWDp4UT9pv65r2w5Cx+3sTYFvtMdDBxkKt1syCqsUdSFAChbEe1uK5TfS04wt/nGwmaeIQ0g==}
6381
+
6382
uri-js@4.4.1:
6383
resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==}
6384
@@ -6522,6 +6612,9 @@ packages:
6612
resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==}
6613
engines: {node: '>=10'}
6614
6615
+ yaml-ast-parser@0.0.43:
6616
+ resolution: {integrity: sha512-2PTINUwsRqSd+s8XxKaJWQlUuEMHJQyEuh2edBbW8KNJz0SJPwUSD2zRWqezFEdN7IzAgeuYHFUCF7o8zRdZ0A==}
6617
+
6618
yaml@2.8.0:
6619
resolution: {integrity: sha512-4lLa/EcQCB0cJkyts+FpIRx5G/llPxfP6VQU5KByHEhLxY3IJCH0f0Hy1MHI8sClTvsIb8qwRJ6R/ZdlDJ/leQ==}
6620
engines: {node: '>= 14.6'}
@@ -7103,6 +7196,12 @@ snapshots:
7196
'@smithy/types': 4.3.1
7197
tslib: 2.8.1
7198
7199
+ '@babel/code-frame@7.27.1':
7200
+ dependencies:
7201
+ '@babel/helper-validator-identifier': 7.27.1
7202
+ js-tokens: 4.0.0
7203
+ picocolors: 1.1.1
7204
+
7205
'@babel/helper-validator-identifier@7.27.1': {}
7206
7207
'@babel/runtime@7.27.6': {}
@@ -7630,7 +7729,7 @@ snapshots:
7729
'@eslint/config-array@0.20.1':
7730
dependencies:
7731
'@eslint/object-schema': 2.1.6
7633
- debug: 4.4.1
7732
+ debug: 4.4.1(supports-color@10.0.0)
7733
minimatch: 3.1.2
7734
transitivePeerDependencies:
7735
- supports-color
@@ -7648,7 +7747,7 @@ snapshots:
7747
'@eslint/eslintrc@3.3.1':
7748
dependencies:
7749
ajv: 6.12.6
7651
- debug: 4.4.1
7750
+ debug: 4.4.1(supports-color@10.0.0)
7751
espree: 10.4.0
7752
globals: 14.0.0
7753
ignore: 5.3.2
@@ -7977,6 +8076,12 @@ snapshots:
8076
dependencies:
8077
mute-stream: 1.0.0
8078
8079
+ '@isaacs/balanced-match@4.0.1': {}
8080
+
8081
+ '@isaacs/brace-expansion@5.0.0':
8082
+ dependencies:
8083
+ '@isaacs/balanced-match': 4.0.1
8084
+
8085
'@isaacs/cliui@8.0.2':
8086
dependencies:
8087
string-width: 5.1.2
@@ -8286,7 +8391,7 @@ snapshots:
8391
'@openai/agents-core@0.0.7(ws@8.18.2)(zod@3.25.67)':
8392
dependencies:
8393
'@openai/zod': zod@3.25.67
8289
- debug: 4.4.1
8394
+ debug: 4.4.1(supports-color@10.0.0)
8395
openai: 5.5.1(ws@8.18.2)(zod@3.25.67)
8396
optionalDependencies:
8397
'@modelcontextprotocol/sdk': 1.13.0
@@ -8299,7 +8404,7 @@ snapshots:
8404
dependencies:
8405
'@openai/agents-core': 0.0.7(ws@8.18.2)(zod@3.25.67)
8406
'@openai/zod': zod@3.25.67
8302
- debug: 4.4.1
8407
+ debug: 4.4.1(supports-color@10.0.0)
8408
openai: 5.5.1(ws@8.18.2)(zod@3.25.67)
8409
transitivePeerDependencies:
8410
- supports-color
@@ -8311,7 +8416,7 @@ snapshots:
8416
'@openai/agents-core': 0.0.7(ws@8.18.2)(zod@3.25.67)
8417
'@openai/zod': zod@3.25.67
8418
'@types/ws': 8.18.1
8314
- debug: 4.4.1
8419
+ debug: 4.4.1(supports-color@10.0.0)
8420
ws: 8.18.2
8421
transitivePeerDependencies:
8422
- bufferutil
@@ -8324,7 +8429,7 @@ snapshots:
8429
'@openai/agents-core': 0.0.7(ws@8.18.2)(zod@3.25.67)
8430
'@openai/agents-openai': 0.0.7(ws@8.18.2)(zod@3.25.67)
8431
'@openai/agents-realtime': 0.0.7(zod@3.25.67)
8327
- debug: 4.4.1
8432
+ debug: 4.4.1(supports-color@10.0.0)
8433
openai: 5.5.1(ws@8.18.2)(zod@3.25.67)
8434
transitivePeerDependencies:
8435
- bufferutil
@@ -9119,6 +9224,29 @@ snapshots:
9224
9225
'@protobufjs/utf8@1.1.0': {}
9226
9227
+ '@redocly/ajv@8.11.3':
9228
+ dependencies:
9229
+ fast-deep-equal: 3.1.3
9230
+ json-schema-traverse: 1.0.0
9231
+ require-from-string: 2.0.2
9232
+ uri-js-replace: 1.0.1
9233
+
9234
+ '@redocly/config@0.22.2': {}
9235
+
9236
+ '@redocly/openapi-core@1.34.5(supports-color@10.0.0)':
9237
+ dependencies:
9238
+ '@redocly/ajv': 8.11.3
9239
+ '@redocly/config': 0.22.2
9240
+ colorette: 1.4.0
9241
+ https-proxy-agent: 7.0.6(supports-color@10.0.0)
9242
+ js-levenshtein: 1.1.6
9243
+ js-yaml: 4.1.0
9244
+ minimatch: 5.1.6
9245
+ pluralize: 8.0.0
9246
+ yaml-ast-parser: 0.0.43
9247
+ transitivePeerDependencies:
9248
+ - supports-color
9249
+
9250
'@rollup/rollup-android-arm-eabi@4.43.0':
9251
optional: true
9252
@@ -9548,6 +9676,12 @@ snapshots:
9676
dependencies:
9677
tslib: 2.8.1
9678
9679
+ '@ts-morph/common@0.27.0':
9680
+ dependencies:
9681
+ fast-glob: 3.3.3
9682
+ minimatch: 10.0.3
9683
+ path-browserify: 1.0.1
9684
+
9685
'@types/aws-lambda@8.10.147': {}
9686
9687
'@types/babel__helper-validator-identifier@7.15.2': {}
@@ -9702,7 +9836,7 @@ snapshots:
9836
'@typescript-eslint/types': 8.34.1
9837
'@typescript-eslint/typescript-estree': 8.34.1(typescript@5.8.3)
9838
'@typescript-eslint/visitor-keys': 8.34.1
9705
- debug: 4.4.1
9839
+ debug: 4.4.1(supports-color@10.0.0)
9840
eslint: 9.29.0(jiti@1.21.7)
9841
typescript: 5.8.3
9842
transitivePeerDependencies:
@@ -9712,7 +9846,7 @@ snapshots:
9846
dependencies:
9847
'@typescript-eslint/tsconfig-utils': 8.34.1(typescript@5.8.3)
9848
'@typescript-eslint/types': 8.34.1
9715
- debug: 4.4.1
9849
+ debug: 4.4.1(supports-color@10.0.0)
9850
typescript: 5.8.3
9851
transitivePeerDependencies:
9852
- supports-color
@@ -9730,7 +9864,7 @@ snapshots:
9864
dependencies:
9865
'@typescript-eslint/typescript-estree': 8.34.1(typescript@5.8.3)
9866
'@typescript-eslint/utils': 8.34.1(eslint@9.29.0(jiti@1.21.7))(typescript@5.8.3)
9733
- debug: 4.4.1
9867
+ debug: 4.4.1(supports-color@10.0.0)
9868
eslint: 9.29.0(jiti@1.21.7)
9869
ts-api-utils: 2.1.0(typescript@5.8.3)
9870
typescript: 5.8.3
@@ -9745,7 +9879,7 @@ snapshots:
9879
'@typescript-eslint/tsconfig-utils': 8.34.1(typescript@5.8.3)
9880
'@typescript-eslint/types': 8.34.1
9881
'@typescript-eslint/visitor-keys': 8.34.1
9748
- debug: 4.4.1
9882
+ debug: 4.4.1(supports-color@10.0.0)
9883
fast-glob: 3.3.3
9884
is-glob: 4.0.3
9885
minimatch: 9.0.5
@@ -9986,7 +10120,7 @@ snapshots:
10120
dependencies:
10121
bytes: 3.1.2
10122
content-type: 1.0.5
9989
- debug: 4.4.1
10123
+ debug: 4.4.1(supports-color@10.0.0)
10124
http-errors: 2.0.0
10125
iconv-lite: 0.6.3
10126
on-finished: 2.4.1
@@ -10095,6 +10229,8 @@ snapshots:
10229
10230
chalk@5.4.1: {}
10231
10232
+ change-case@5.4.4: {}
10233
+
10234
chardet@0.7.0: {}
10235
10236
check-error@2.1.1: {}
@@ -10144,6 +10280,8 @@ snapshots:
10280
10281
clone@2.1.2: {}
10282
10283
+ code-block-writer@13.0.3: {}
10284
+
10285
cohere-ai@7.17.1:
10286
dependencies:
10287
'@aws-sdk/client-sagemaker': 3.832.0
@@ -10179,6 +10317,8 @@ snapshots:
10317
color-convert: 2.0.1
10318
color-string: 1.9.1
10319
10320
+ colorette@1.4.0: {}
10321
+
10322
colorette@2.0.20: {}
10323
10324
combined-stream@1.0.8:
@@ -10298,9 +10438,11 @@ snapshots:
10438
dependencies:
10439
ms: 2.0.0
10440
10301
- debug@4.4.1:
10441
+ debug@4.4.1(supports-color@10.0.0):
10442
dependencies:
10443
ms: 2.1.3
10444
+ optionalDependencies:
10445
+ supports-color: 10.0.0
10446
10447
decamelize@1.2.0: {}
10448
@@ -10545,7 +10687,7 @@ snapshots:
10687
ajv: 6.12.6
10688
chalk: 4.1.2
10689
cross-spawn: 7.0.6
10548
- debug: 4.4.1
10690
+ debug: 4.4.1(supports-color@10.0.0)
10691
escape-string-regexp: 4.0.0
10692
eslint-scope: 8.4.0
10693
eslint-visitor-keys: 4.2.1
@@ -10677,7 +10819,7 @@ snapshots:
10819
content-type: 1.0.5
10820
cookie: 0.7.2
10821
cookie-signature: 1.2.2
10680
- debug: 4.4.1
10822
+ debug: 4.4.1(supports-color@10.0.0)
10823
encodeurl: 2.0.0
10824
escape-html: 1.0.3
10825
etag: 1.8.1
@@ -10791,7 +10933,7 @@ snapshots:
10933
10934
finalhandler@2.1.0:
10935
dependencies:
10794
- debug: 4.4.1
10936
+ debug: 4.4.1(supports-color@10.0.0)
10937
encodeurl: 2.0.0
10938
escape-html: 1.0.3
10939
on-finished: 2.4.1
@@ -10885,7 +11027,7 @@ snapshots:
11027
gaxios@6.7.1:
11028
dependencies:
11029
extend: 3.0.2
10888
- https-proxy-agent: 7.0.6
11030
+ https-proxy-agent: 7.0.6(supports-color@10.0.0)
11031
is-stream: 2.0.1
11032
node-fetch: 2.7.0
11033
uuid: 9.0.1
@@ -11046,10 +11188,10 @@ snapshots:
11188
statuses: 2.0.1
11189
toidentifier: 1.0.1
11190
11049
- https-proxy-agent@7.0.6:
11191
+ https-proxy-agent@7.0.6(supports-color@10.0.0):
11192
dependencies:
11193
agent-base: 7.1.3
11052
- debug: 4.4.1
11194
+ debug: 4.4.1(supports-color@10.0.0)
11195
transitivePeerDependencies:
11196
- supports-color
11197
@@ -11093,6 +11235,8 @@ snapshots:
11235
11236
indent-string@5.0.0: {}
11237
11238
+ index-to-position@1.1.0: {}
11239
+
11240
inherits@2.0.4: {}
11241
11242
ini@4.1.3: {}
@@ -11196,6 +11340,8 @@ snapshots:
11340
11341
js-base64@3.7.2: {}
11342
11343
+ js-levenshtein@1.1.6: {}
11344
+
11345
js-tiktoken@1.0.20:
11346
dependencies:
11347
base64-js: 1.5.1
@@ -11223,6 +11369,8 @@ snapshots:
11369
11370
json-schema-traverse@0.4.1: {}
11371
11372
+ json-schema-traverse@1.0.0: {}
11373
+
11374
json-schema-walker@2.0.0:
11375
dependencies:
11376
'@apidevtools/json-schema-ref-parser': 11.9.3
@@ -11325,7 +11473,7 @@ snapshots:
11473
dependencies:
11474
chalk: 5.4.1
11475
commander: 13.1.0
11328
- debug: 4.4.1
11476
+ debug: 4.4.1(supports-color@10.0.0)
11477
execa: 8.0.1
11478
lilconfig: 3.1.3
11479
listr2: 8.3.3
@@ -11481,10 +11629,18 @@ snapshots:
11629
- bufferutil
11630
- utf-8-validate
11631
11632
+ minimatch@10.0.3:
11633
+ dependencies:
11634
+ '@isaacs/brace-expansion': 5.0.0
11635
+
11636
minimatch@3.1.2:
11637
dependencies:
11638
brace-expansion: 1.1.12
11639
11640
+ minimatch@5.1.6:
11641
+ dependencies:
11642
+ brace-expansion: 2.0.2
11643
+
11644
minimatch@9.0.5:
11645
dependencies:
11646
brace-expansion: 2.0.2
@@ -11671,6 +11827,16 @@ snapshots:
11827
11828
openapi-types@12.1.3: {}
11829
11830
+ openapi-typescript@7.8.0(typescript@5.8.3):
11831
+ dependencies:
11832
+ '@redocly/openapi-core': 1.34.5(supports-color@10.0.0)
11833
+ ansi-colors: 4.1.3
11834
+ change-case: 5.4.4
11835
+ parse-json: 8.3.0
11836
+ supports-color: 10.0.0
11837
+ typescript: 5.8.3
11838
+ yargs-parser: 21.1.1
11839
+
11840
optionator@0.9.4:
11841
dependencies:
11842
deep-is: 0.1.4
@@ -11734,8 +11900,16 @@ snapshots:
11900
dependencies:
11901
callsites: 3.1.0
11902
11903
+ parse-json@8.3.0:
11904
+ dependencies:
11905
+ '@babel/code-frame': 7.27.1
11906
+ index-to-position: 1.1.0
11907
+ type-fest: 4.41.0
11908
+
11909
parseurl@1.3.3: {}
11910
11911
+ path-browserify@1.0.1: {}
11912
+
11913
path-exists@4.0.0: {}
11914
11915
path-key@3.1.1: {}
@@ -11847,6 +12021,8 @@ snapshots:
12021
mlly: 1.7.4
12022
pathe: 2.0.3
12023
12024
+ pluralize@8.0.0: {}
12025
+
12026
possible-typed-array-names@1.1.0: {}
12027
12028
postcss-import@15.1.0(postcss@8.5.6):
@@ -12056,9 +12232,11 @@ snapshots:
12232
12233
require-directory@2.1.1: {}
12234
12235
+ require-from-string@2.0.2: {}
12236
+
12237
require-in-the-middle@7.5.2:
12238
dependencies:
12061
- debug: 4.4.1
12239
+ debug: 4.4.1(supports-color@10.0.0)
12240
module-details-from-path: 1.0.4
12241
resolve: 1.22.10
12242
transitivePeerDependencies:
@@ -12119,7 +12297,7 @@ snapshots:
12297
12298
router@2.2.0:
12299
dependencies:
12122
- debug: 4.4.1
12300
+ debug: 4.4.1(supports-color@10.0.0)
12301
depd: 2.0.0
12302
is-promise: 4.0.0
12303
parseurl: 1.3.3
@@ -12182,7 +12360,7 @@ snapshots:
12360
12361
send@1.2.0:
12362
dependencies:
12185
- debug: 4.4.1
12363
+ debug: 4.4.1(supports-color@10.0.0)
12364
encodeurl: 2.0.0
12365
escape-html: 1.0.3
12366
etag: 1.8.1
@@ -12601,6 +12779,11 @@ snapshots:
12779
12780
ts-interface-checker@0.1.13: {}
12781
12782
+ ts-morph@26.0.0:
12783
+ dependencies:
12784
+ '@ts-morph/common': 0.27.0
12785
+ code-block-writer: 13.0.3
12786
+
12787
tslib@1.14.1: {}
12788
12789
tslib@2.8.1: {}
@@ -12611,7 +12794,7 @@ snapshots:
12794
cac: 6.7.14
12795
chokidar: 4.0.3
12796
consola: 3.4.2
12614
- debug: 4.4.1
12797
+ debug: 4.4.1(supports-color@10.0.0)
12798
esbuild: 0.25.5
12799
fix-dts-default-cjs-exports: 1.0.1
12800
joycon: 3.1.1
@@ -12679,6 +12862,8 @@ snapshots:
12862
12863
type-fest@2.19.0: {}
12864
12865
+ type-fest@4.41.0: {}
12866
+
12867
type-is@1.6.18:
12868
dependencies:
12869
media-typer: 0.3.0
@@ -12770,6 +12955,8 @@ snapshots:
12955
12956
unpipe@1.0.0: {}
12957
12958
+ uri-js-replace@1.0.1: {}
12959
+
12960
uri-js@4.4.1:
12961
dependencies:
12962
punycode: 2.3.1
@@ -12795,7 +12982,7 @@ snapshots:
12982
vite-node@3.2.4(@types/node@20.19.1)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0):
12983
dependencies:
12984
cac: 6.7.14
12798
- debug: 4.4.1
12985
+ debug: 4.4.1(supports-color@10.0.0)
12986
es-module-lexer: 1.7.0
12987
pathe: 2.0.3
12988
vite: 6.3.5(@types/node@20.19.1)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0)
@@ -12816,7 +13003,7 @@ snapshots:
13003
vite-node@3.2.4(@types/node@22.15.32)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0):
13004
dependencies:
13005
cac: 6.7.14
12819
- debug: 4.4.1
13006
+ debug: 4.4.1(supports-color@10.0.0)
13007
es-module-lexer: 1.7.0
13008
pathe: 2.0.3
13009
vite: 6.3.5(@types/node@22.15.32)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0)
@@ -12837,7 +13024,7 @@ snapshots:
13024
vite-node@3.2.4(@types/node@24.0.3)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0):
13025
dependencies:
13026
cac: 6.7.14
12840
- debug: 4.4.1
13027
+ debug: 4.4.1(supports-color@10.0.0)
13028
es-module-lexer: 1.7.0
13029
pathe: 2.0.3
13030
vite: 6.3.5(@types/node@24.0.3)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0)
@@ -12911,7 +13098,7 @@ snapshots:
13098
'@vitest/spy': 3.2.4
13099
'@vitest/utils': 3.2.4
13100
chai: 5.2.0
12914
- debug: 4.4.1
13101
+ debug: 4.4.1(supports-color@10.0.0)
13102
expect-type: 1.2.1
13103
magic-string: 0.30.17
13104
pathe: 2.0.3
@@ -12953,7 +13140,7 @@ snapshots:
13140
'@vitest/spy': 3.2.4
13141
'@vitest/utils': 3.2.4
13142
chai: 5.2.0
12956
- debug: 4.4.1
13143
+ debug: 4.4.1(supports-color@10.0.0)
13144
expect-type: 1.2.1
13145
magic-string: 0.30.17
13146
pathe: 2.0.3
@@ -12995,7 +13182,7 @@ snapshots:
13182
'@vitest/spy': 3.2.4
13183
'@vitest/utils': 3.2.4
13184
chai: 5.2.0
12998
- debug: 4.4.1
13185
+ debug: 4.4.1(supports-color@10.0.0)
13186
expect-type: 1.2.1
13187
magic-string: 0.30.17
13188
pathe: 2.0.3
@@ -13156,6 +13343,8 @@ snapshots:
13343
13344
y18n@5.0.8: {}
13345
13346
+ yaml-ast-parser@0.0.43: {}
13347
+
13348
yaml@2.8.0: {}
13349
13350
yargs-parser@20.2.9: {}
ts/packages/cli/package.json
+3
-1
@@ -72,10 +72,12 @@
72
"effect": "^3.16.16",
73
"indent-string": "^5.0.0",
74
"open": "^10.2.0",
75
+ "openapi-typescript": "^7.8.0",
76
"picocolors": "^1.1.1",
77
"semver": "^7.7.2",
78
"source-map-js": "^1.2.1",
78
- "superjson": "^2.2.2"
79
+ "superjson": "^2.2.2",
80
+ "ts-morph": "^26.0.0"
81
},
82
"gitHead": "4fae6e54d5c150fba955cc5fa314281da5a1e064"
83
}
ts/packages/cli/src/commands/ts/commands/ts.generate.cmd.ts
+1
-1
@@ -134,7 +134,7 @@ export function generateTypescriptTypeStubs({
134
const index = createToolkitIndex({ toolkits, tools, triggerTypes });
135
136
// Generate TypeScript sources
137
- const sources = generateTypeScriptSources({
137
+ const sources = yield* generateTypeScriptSources({
138
outputDir,
139
emitSingleFile: Boolean(compact), // Ensure boolean type
140
banner: BANNER,
ts/packages/cli/src/generation/typescript/generate-toolkit-sources.ts
+137
-50
@@ -24,11 +24,15 @@
24
*/
25
26
import * as ts from '@composio/ts-builders';
27
-import { pipe, Record } from 'effect';
27
+import { Effect, pipe, Record, Array as Arr } from 'effect';
28
import type { ToolkitName } from 'src/models/toolkits';
29
import type { ToolkitIndex, ToolkitIndexData } from 'src/generation/create-toolkit-index';
30
import type { SourceFile } from 'src/generation/types';
31
import type { TriggerType } from 'src/models/trigger-types';
32
+import {
33
+ generateTypeFromJsonSchema,
34
+ GenerateTypeFromJsonSchemaError,
35
+} from './generate-type-from-json-schema';
36
37
function jsValueToTsValue(value: unknown): ts.ValueBuilder {
38
if (value === null) {
@@ -97,65 +101,148 @@ function generateTriggerTypeObjectValue(triggerType: TriggerType): ts.ValueBuild
101
* Generates a list of TypeScript source files that should be written to disk by the caller.
102
*/
103
export function generateTypeScriptToolkitSources(banner: string) {
100
- return (index: ToolkitIndex): Array<SourceFile> => {
101
- const toolkitSources = pipe(
102
- index,
103
- Record.mapEntries(generateTypeScriptToolkitSource(banner)),
104
- Record.toEntries
105
- );
106
-
107
- return toolkitSources;
108
- };
104
+ return (index: ToolkitIndex) =>
105
+ Effect.gen(function* () {
106
+ const toolkitSources = yield* Effect.all(
107
+ Record.toEntries(index).map(([key, value]) =>
108
+ generateTypeScriptToolkitSource(banner)(key, value)
109
+ )
110
+ );
111
+
112
+ return toolkitSources;
113
+ });
114
}
115
116
function generateTypeScriptToolkitSource(_banner: string) {
117
return (
113
- { slug, tools, triggerTypes }: ToolkitIndexData,
114
- toolkitName: ToolkitName
115
- ): SourceFile => {
116
- const filename = `${slug}.ts`;
117
-
118
- const file = ts.file();
119
-
120
- const entry = ts.propertyValue(
121
- toolkitName,
122
- ts
123
- .objectValue()
124
- .add(ts.propertyValue('slug', ts.stringLiteral(slug).asValue()))
125
- .add(
126
- ts.propertyValue(
127
- 'tools',
128
- ts
129
- .objectValue()
130
- .addMultiple(
131
- Object.entries(tools).map(([toolName, tool]) =>
132
- ts.propertyValue(toolName, ts.stringLiteral(tool).asValue())
118
+ toolkitName: ToolkitName,
119
+ { slug, tools, triggerTypes }: ToolkitIndexData
120
+ ): Effect.Effect<SourceFile, GenerateTypeFromJsonSchemaError, never> => {
121
+ return Effect.gen(function* () {
122
+ const filename = `${slug}.ts`;
123
+ const file = ts.file();
124
+
125
+ // add `import { type TriggerEvent } from "@composio/core"`, if there are trigger types
126
+ if (Object.keys(triggerTypes).length > 0) {
127
+ file.addImport(
128
+ ts.moduleImport('@composio/core').named(ts.namedImport('TriggerEvent').typeOnly())
129
+ );
130
+ }
131
+
132
+ // write type declarations for each trigger payload, without exporting them
133
+ for (const [triggerTypeSlug, triggerType] of Record.toEntries(triggerTypes)) {
134
+ // e.g., `type GMAIL_NEW_GMAIL_MESSAGE_PAYLOAD = { .. }`
135
+ const triggerPayloadType = yield* generateTypeFromJsonSchema(
136
+ `${toolkitName}_${triggerTypeSlug}_PAYLOAD`,
137
+ triggerType.payload
138
+ );
139
+ file.add(ts.typeDeclaration(triggerTypeSlug, triggerPayloadType));
140
+ }
141
+
142
+ // write the toolkit const object declaration
143
+ const toolValueDeclaration = ts.propertyValue(
144
+ toolkitName,
145
+ ts
146
+ .objectValue()
147
+ .add(ts.propertyValue('slug', ts.stringLiteral(slug).asValue()))
148
+ .add(
149
+ ts.propertyValue(
150
+ 'tools',
151
+ ts
152
+ .objectValue()
153
+ .addMultiple(
154
+ Object.entries(tools).map(([toolName, tool]) =>
155
+ ts.propertyValue(toolName, ts.stringLiteral(tool).asValue())
156
+ )
157
)
134
- )
158
+ )
159
)
136
- )
137
- .add(
138
- ts.propertyValue(
139
- 'triggerTypes',
140
- ts
141
- .objectValue()
142
- .addMultiple(
143
- Object.entries(triggerTypes).map(([triggerTypeSlug, triggerType]) =>
144
- ts.propertyValue(triggerTypeSlug, generateTriggerTypeObjectValue(triggerType))
160
+ .add(
161
+ ts.propertyValue(
162
+ 'triggerTypes',
163
+ ts
164
+ .objectValue()
165
+ .addMultiple(
166
+ Object.entries(triggerTypes).map(([triggerTypeSlug, triggerType]) =>
167
+ ts.propertyValue(triggerTypeSlug, generateTriggerTypeObjectValue(triggerType))
168
+ )
169
)
146
- )
170
+ )
171
)
148
- )
149
- );
172
+ );
173
151
- file.add(
152
- ts
153
- .moduleExport(ts.constDeclaration(entry.name as string).setValue(entry.value))
154
- .setDocComment(ts.docComment(`Map of Composio's ${entry.name} toolkit.`))
155
- );
174
+ file.add(
175
+ ts
176
+ .moduleExport(
177
+ ts
178
+ .constDeclaration(toolValueDeclaration.name as string)
179
+ .setValue(toolValueDeclaration.value)
180
+ )
181
+ .setDocComment(ts.docComment(`Map of Composio's ${toolValueDeclaration.name} toolkit.`))
182
+ );
183
+
184
+ // write the map of trigger payload types
185
+ {
186
+ const triggerPayloadTypeEntries = pipe(
187
+ triggerTypes,
188
+ Record.map((_, triggerTypeSlug) =>
189
+ ts.property(triggerTypeSlug, ts.namedType(`${toolkitName}_${triggerTypeSlug}_PAYLOAD`))
190
+ ),
191
+ Record.toEntries,
192
+ Arr.map(([_, value]) => value)
193
+ );
194
+
195
+ const doc = ts.docComment(
196
+ `Type map of all available trigger payloads for toolkit "${toolkitName}".`
197
+ );
198
+
199
+ file.add(
200
+ ts
201
+ .moduleExport(
202
+ ts.typeDeclaration(
203
+ `${toolkitName}_TRIGGER_PAYLOADS`,
204
+ ts.objectType().addMultiple(triggerPayloadTypeEntries)
205
+ )
206
+ )
207
+ .setDocComment(doc)
208
+ );
209
+ }
210
+
211
+ // write the map of trigger events
212
+ {
213
+ const triggerEventTypeEntries = pipe(
214
+ triggerTypes,
215
+ Record.map((_, triggerTypeSlug) =>
216
+ ts.property(
217
+ triggerTypeSlug,
218
+ ts
219
+ .namedType('TriggerEvent')
220
+ .addGenericArgument(ts.namedType(`${toolkitName}_${triggerTypeSlug}_PAYLOAD`))
221
+ )
222
+ ),
223
+ Record.toEntries,
224
+ Arr.map(([_, value]) => value)
225
+ );
226
+
227
+ const doc = ts.docComment(
228
+ `Type map of all available trigger events for toolkit "${toolkitName}".`
229
+ );
230
+
231
+ file.add(
232
+ ts
233
+ .moduleExport(
234
+ ts.typeDeclaration(
235
+ `${toolkitName}_TRIGGER_EVENTS`,
236
+ ts.objectType().addMultiple(triggerEventTypeEntries)
237
+ )
238
+ )
239
+ .setDocComment(doc)
240
+ );
241
+ }
242
157
- const filesource = ts.stringify(file);
243
+ const filesource = ts.stringify(file);
244
159
- return [filename, filesource];
245
+ return [filename, filesource];
246
+ });
247
};
248
}
ts/packages/cli/src/generation/typescript/generate-type-from-json-schema.ts
new
+142
@@ -0,0 +1,142 @@
1
+import ts from 'typescript';
2
+import openapiTS, { type OpenAPI3, astToString } from 'openapi-typescript';
3
+import { Effect } from 'effect';
4
+import { TaggedError } from 'effect/Data';
5
+
6
+export class GenerateTypeFromJsonSchemaError extends TaggedError('json-parsing-error')<{
7
+ cause?: unknown;
8
+ message?: string;
9
+}> {}
10
+
11
+export function generateTypeFromJsonSchema(
12
+ name: string,
13
+ schema: { readonly [x: string]: unknown }
14
+) {
15
+ const openApi3Definition = {
16
+ openapi: '3.1.0',
17
+ components: {
18
+ schemas: {
19
+ [name]: {
20
+ type: 'object',
21
+ properties: schema['properties'],
22
+ },
23
+ },
24
+ },
25
+ } as unknown as OpenAPI3;
26
+
27
+ return Effect.gen(function* () {
28
+ const astNodes = yield* Effect.tryPromise({
29
+ try: () => openapiTS(openApi3Definition),
30
+ catch: e =>
31
+ new GenerateTypeFromJsonSchemaError({
32
+ cause: e,
33
+ message: 'Failed to generate type from JSON schema',
34
+ }),
35
+ });
36
+
37
+ const components = astNodes.find(isInterfaceComponents);
38
+
39
+ if (components === undefined) {
40
+ return yield* Effect.fail(
41
+ new GenerateTypeFromJsonSchemaError({
42
+ message:
43
+ 'Failed to find `components` interface in types generated by `openapi-typescript`',
44
+ })
45
+ );
46
+ }
47
+
48
+ // This is the TypeScript definition obtained via `openapi-typescript`, which contains the types we want + some garbage we don't need.
49
+ // We thus have to extract the type we want using the TypeScript API.
50
+ const sourceCode = astToString(components);
51
+
52
+ const sourceFile = ts.createSourceFile('virtual.ts', sourceCode, ts.ScriptTarget.Latest, true);
53
+
54
+ // Navigate to components.schemas[name]
55
+ const schemasProp = components.members.find(
56
+ m => ts.isPropertySignature(m) && (m.name as ts.Identifier).text === 'schemas'
57
+ ) as ts.PropertySignature | undefined;
58
+
59
+ if (!schemasProp || !schemasProp.type || !ts.isTypeLiteralNode(schemasProp.type)) {
60
+ return yield* Effect.fail(
61
+ new GenerateTypeFromJsonSchemaError({
62
+ message: '`schemas` is not a type literal',
63
+ })
64
+ );
65
+ }
66
+
67
+ const schemasTypeLiteral = schemasProp.type;
68
+ const payloadProp = schemasTypeLiteral.members.find(
69
+ m => ts.isPropertySignature(m) && (m.name as ts.Identifier).text === name
70
+ ) as ts.PropertySignature | undefined;
71
+
72
+ if (!payloadProp || !payloadProp.type) {
73
+ return yield* Effect.fail(
74
+ new GenerateTypeFromJsonSchemaError({
75
+ message: `Failed to find type for ${name}`,
76
+ })
77
+ );
78
+ }
79
+
80
+ let typeNode: ts.TypeNode;
81
+
82
+ // Handle different type node cases
83
+ if (ts.isTypeLiteralNode(payloadProp.type)) {
84
+ // Case 1: Type literal with specific properties (e.g., { foo: string; bar: number; })
85
+ // BUT also handle empty type literals (which represent generic objects with no properties)
86
+ if (payloadProp.type.members.length === 0) {
87
+ // Empty type literal {} should be converted to 'object'
88
+ typeNode = ts.factory.createTypeReferenceNode('object');
89
+ } else {
90
+ // Type literal with specific properties
91
+ typeNode = payloadProp.type;
92
+ }
93
+ } else if (
94
+ ts.isTypeReferenceNode(payloadProp.type) &&
95
+ payloadProp.type.typeName &&
96
+ ts.isIdentifier(payloadProp.type.typeName)
97
+ ) {
98
+ const typeNameText = payloadProp.type.typeName.text;
99
+ if (typeNameText === 'object') {
100
+ // Case 2a: Generic 'object' type reference - output TypeScript 'object' type
101
+ typeNode = ts.factory.createTypeReferenceNode('object');
102
+ } else if (typeNameText === 'Record') {
103
+ // Case 2b: Record type (generated by openapi-typescript for generic objects) - convert to 'object'
104
+ typeNode = ts.factory.createTypeReferenceNode('object');
105
+ } else {
106
+ // Case 2c: Other type references - fall back to 'unknown'
107
+ typeNode = ts.factory.createTypeReferenceNode('unknown');
108
+ }
109
+ } else if (
110
+ ts.isToken(payloadProp.type) &&
111
+ payloadProp.type.kind === ts.SyntaxKind.ObjectKeyword
112
+ ) {
113
+ // Case 3: Direct 'object' keyword - output TypeScript 'object' type
114
+ typeNode = ts.factory.createTypeReferenceNode('object');
115
+ } else {
116
+ // Case 4: Other unexpected types - fall back to 'unknown'
117
+ typeNode = ts.factory.createTypeReferenceNode('unknown');
118
+ }
119
+
120
+ // Print the type as a string with JSDoc preserved
121
+ const printer = ts.createPrinter({ removeComments: false });
122
+
123
+ const printedType = ts.factory.createTypeAliasDeclaration(
124
+ [],
125
+ // [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
126
+ name,
127
+ undefined,
128
+ typeNode
129
+ );
130
+
131
+ const printedText = printer.printNode(ts.EmitHint.Unspecified, printedType, sourceFile);
132
+
133
+ // Formats the type so that it is indented by 2 spaces instead of 4
134
+ const adjustedText = printedText.replace(/^ {4}/gm, ' ');
135
+
136
+ return adjustedText;
137
+ });
138
+}
139
+
140
+function isInterfaceComponents(node: ts.Node): node is ts.InterfaceDeclaration {
141
+ return ts.isInterfaceDeclaration(node) && node.name.escapedText === 'components';
142
+}
ts/packages/cli/src/generation/typescript/generate.ts
+24
-19
@@ -3,6 +3,8 @@ import path from 'node:path';
3
import type { ToolkitIndex } from 'src/generation/create-toolkit-index';
4
import { generateTypeScriptToolkitSources } from './generate-toolkit-sources';
5
import { generateIndexSource } from './generate-index-source';
6
+import { Effect } from 'effect';
7
+import type { GenerateTypeFromJsonSchemaError } from './generate-type-from-json-schema';
8
9
type SourceFile = readonly [filename: string, content: string];
10
@@ -14,27 +16,30 @@ type GenerateTypeScriptSourcesParams = {
16
};
17
18
export function generateTypeScriptSources(params: GenerateTypeScriptSourcesParams) {
17
- return (index: ToolkitIndex): Array<SourceFile> => {
18
- const toolkiteSources = generateTypeScriptToolkitSources(params.banner)(index);
19
+ return (
20
+ index: ToolkitIndex
21
+ ): Effect.Effect<Array<SourceFile>, GenerateTypeFromJsonSchemaError, never> =>
22
+ Effect.gen(function* () {
23
+ const toolkiteSources = yield* generateTypeScriptToolkitSources(params.banner)(index);
24
20
- const indexSource = generateIndexSource(params)(index);
21
- const indexFilename = path.join(params.outputDir, 'index.ts');
25
+ const indexSource = generateIndexSource(params)(index);
26
+ const indexFilename = path.join(params.outputDir, 'index.ts');
27
23
- if (!params.emitSingleFile) {
24
- return [
25
- ...toolkiteSources.map(
26
- ([filename, content]) => [path.join(params.outputDir, filename), content] as const
27
- ),
28
- [indexFilename, indexSource] as const,
29
- ] as const;
30
- }
28
+ if (!params.emitSingleFile) {
29
+ return [
30
+ ...toolkiteSources.map(
31
+ ([filename, content]) => [path.join(params.outputDir, filename), content] as const
32
+ ),
33
+ [indexFilename, indexSource] as const,
34
+ ] as const;
35
+ }
36
32
- const localToolkitsSources = toolkiteSources.map(([_, content]) => content).join('\n');
37
+ const localToolkitsSources = toolkiteSources.map(([_, content]) => content).join('\n');
38
34
- const indexSourceSingleFile = `${ts.stringify(ts.docComment(params.banner))}
35
-${localToolkitsSources}
36
-${indexSource}
37
-`;
38
- return [[indexFilename, indexSourceSingleFile] as const];
39
- };
39
+ const indexSourceSingleFile = `${ts.stringify(ts.docComment(params.banner))}
40
+ ${localToolkitsSources}
41
+ ${indexSource}
42
+ `;
43
+ return [[indexFilename, indexSourceSingleFile] as const];
44
+ });
45
}
ts/packages/cli/test/__mocks__/tools_github.ts
new
+3
@@ -0,0 +1,3 @@
1
+import TOOLS from './tools.json' with { type: 'json' };
2
+
3
+export const TOOLS_GITHUB = TOOLS.filter(tool => tool.startsWith('GITHUB_'));
ts/packages/cli/test/__mocks__/tools_gmail.ts
new
+3
@@ -0,0 +1,3 @@
1
+import TOOLS from './tools.json' with { type: 'json' };
2
+
3
+export const TOOLS_GMAIL = TOOLS.filter(tool => tool.startsWith('GMAIL_'));
ts/packages/cli/test/__mocks__/tools_googledrive.ts
new
+3
@@ -0,0 +1,3 @@
1
+import TOOLS from './tools.json' with { type: 'json' };
2
+
3
+export const TOOLS_GOOGLEDRIVE = TOOLS.filter(tool => tool.startsWith('GOOGLEDRIVE_'));
ts/packages/cli/test/__mocks__/trigger-type-gmail.ts
deleted
-6
@@ -1,6 +0,0 @@
1
-import type { TriggerType } from 'src/models/trigger-types';
2
-import TRIGGER_TYPES from './trigger-types.json' with { type: 'json' };
3
-
4
-export const TRIGGER_TYPE_GMAIL = TRIGGER_TYPES.find(
5
- triggerType => triggerType.slug === 'GMAIL_NEW_GMAIL_MESSAGE'
6
-)! as TriggerType;
ts/packages/cli/test/__mocks__/trigger-types-github.ts
new
+6
@@ -0,0 +1,6 @@
1
+import TRIGGER_TYPES from './trigger-types.json' with { type: 'json' };
2
+import { TriggerType } from 'src/models/trigger-types';
3
+
4
+export const TRIGGER_TYPES_GITHUB = TRIGGER_TYPES.filter(triggerType =>
5
+ triggerType.slug.startsWith('GITHUB_')
6
+) as TriggerType[];
ts/packages/cli/test/__mocks__/trigger-types-gmail.ts
new
+6
@@ -0,0 +1,6 @@
1
+import TRIGGER_TYPES from './trigger-types.json' with { type: 'json' };
2
+import { TriggerType } from 'src/models/trigger-types';
3
+
4
+export const TRIGGER_TYPES_GMAIL = TRIGGER_TYPES.filter(triggerType =>
5
+ triggerType.slug.startsWith('GMAIL')
6
+) as TriggerType[];
ts/packages/cli/test/__mocks__/trigger-types-googledrive.ts
new
+6
@@ -0,0 +1,6 @@
1
+import TRIGGER_TYPES from './trigger-types.json' with { type: 'json' };
2
+import { TriggerType } from 'src/models/trigger-types';
3
+
4
+export const TRIGGER_TYPES_GOOGLEDRIVE = TRIGGER_TYPES.filter(triggerType =>
5
+ triggerType.slug.startsWith('GOOGLEDRIVE')
6
+) as TriggerType[];
ts/packages/cli/test/src/commands/py/py.generate.cmd.test.ts
+7
-6
@@ -5,9 +5,10 @@ import { FileSystem } from '@effect/platform';
5
import { cli, TestLive } from 'test/__utils__';
6
import { makeTestToolkits } from 'test/__utils__/models/toolkits';
7
import { NodeProcess } from 'src/services/node-process';
8
-import { TRIGGER_TYPE_GMAIL } from 'test/__mocks__/trigger-type-gmail';
8
+import { TRIGGER_TYPES_GMAIL } from 'test/__mocks__/trigger-types-gmail';
9
import { TestLiveInput } from 'test/__utils__/services/test-layer';
10
import { assertPythonIsValid } from 'test/__utils__/python-compiler';
11
+import { TOOLS_GMAIL } from 'test/__mocks__/tools_gmail';
12
13
describe('CLI: composio py generate', () => {
14
const appClientData = {
@@ -21,9 +22,9 @@ describe('CLI: composio py generate', () => {
22
slug: 'slack',
23
},
24
]),
24
- tools: ['GMAIL_CREATE_EMAIL_DRAFT', 'GMAIL_DELETE_MESSAGE', 'GMAIL_FETCH_EMAILS'],
25
- triggerTypesAsEnums: ['GMAIL_NEW_GMAIL_MESSAGE'],
26
- triggerTypes: [TRIGGER_TYPE_GMAIL],
25
+ tools: [...TOOLS_GMAIL.slice(0, 3)],
26
+ triggerTypesAsEnums: [...TRIGGER_TYPES_GMAIL.slice(0, 3).map(triggerType => triggerType.slug)],
27
+ triggerTypes: [...TRIGGER_TYPES_GMAIL.slice(0, 3)],
28
} satisfies TestLiveInput['toolkitsData'];
29
30
layer(
@@ -126,9 +127,9 @@ describe('CLI: composio py generate', () => {
127
slug: str = "gmail"
128
129
class tools:
130
+ ADD_LABEL_TO_EMAIL = "GMAIL_ADD_LABEL_TO_EMAIL"
131
CREATE_EMAIL_DRAFT = "GMAIL_CREATE_EMAIL_DRAFT"
130
- DELETE_MESSAGE = "GMAIL_DELETE_MESSAGE"
131
- FETCH_EMAILS = "GMAIL_FETCH_EMAILS"
132
+ CREATE_LABEL = "GMAIL_CREATE_LABEL"
133
134
class triggers:
135
NEW_GMAIL_MESSAGE = {
ts/packages/cli/test/src/commands/ts/ts.generate.cmd.test.ts
+197
-30
@@ -11,7 +11,8 @@ import {
11
} from 'test/__utils__/typescript-compiler';
12
import { ComposioCorePkgNotFound } from 'src/effects/find-composio-core-generated';
13
import type { TestLiveInput } from 'test/__utils__/services/test-layer';
14
-import { TRIGGER_TYPE_GMAIL } from 'test/__mocks__/trigger-type-gmail';
14
+import { TRIGGER_TYPES_GMAIL } from 'test/__mocks__/trigger-types-gmail';
15
+import { TOOLS_GMAIL } from 'test/__mocks__/tools_gmail';
16
17
describe('CLI: composio ts generate', () => {
18
const appClientData = {
@@ -25,9 +26,9 @@ describe('CLI: composio ts generate', () => {
26
slug: 'slack',
27
},
28
]),
28
- tools: ['GMAIL_CREATE_EMAIL_DRAFT', 'GMAIL_DELETE_MESSAGE', 'GMAIL_FETCH_EMAILS'],
29
- triggerTypesAsEnums: ['GMAIL_NEW_GMAIL_MESSAGE'],
30
- triggerTypes: [TRIGGER_TYPE_GMAIL],
29
+ tools: [...TOOLS_GMAIL.slice(0, 3)],
30
+ triggerTypes: [...TRIGGER_TYPES_GMAIL.slice(0, 3)],
31
+ triggerTypesAsEnums: [...TRIGGER_TYPES_GMAIL.slice(0, 3).map(triggerType => triggerType.slug)],
32
} satisfies TestLiveInput['toolkitsData'];
33
34
describe('[Given] valid fetched app data', () => {
@@ -61,15 +62,74 @@ describe('CLI: composio ts generate', () => {
62
const indexSourceCode = yield* fs.readFileString(path.join(outputDir, 'index.ts'));
63
64
expect(gmailSourceCode).toMatchInlineSnapshot(`
64
- "/**
65
+ "import { type TriggerEvent } from "@composio/core"
66
+
67
+ type GMAIL_NEW_GMAIL_MESSAGE_PAYLOAD = {
68
+ /**
69
+ * Attachment List
70
+ * @description The list of attachments in the message
71
+ * @default null
72
+ */
73
+ attachment_list: unknown[] | null;
74
+ /**
75
+ * Message ID
76
+ * @description The message ID of the message
77
+ * @default null
78
+ */
79
+ message_id: string | null;
80
+ /**
81
+ * Message Text
82
+ * @description The text of the message
83
+ * @default null
84
+ */
85
+ message_text: string | null;
86
+ /**
87
+ * Message Timestamp
88
+ * @description The timestamp of the message
89
+ * @default null
90
+ */
91
+ message_timestamp: string | null;
92
+ /**
93
+ * Payload
94
+ * @description The payload of the message
95
+ * @default null
96
+ */
97
+ payload: Record<string, never> | null;
98
+ /**
99
+ * Sender
100
+ * @description The sender of the message
101
+ * @default null
102
+ */
103
+ sender: string | null;
104
+ /**
105
+ * Subject
106
+ * @description The subject of the message
107
+ * @default null
108
+ */
109
+ subject: string | null;
110
+ /**
111
+ * Thread ID
112
+ * @description The thread ID of the message
113
+ * @default null
114
+ */
115
+ thread_id: string | null;
116
+ /**
117
+ * To
118
+ * @description The recipient of the message
119
+ * @default null
120
+ */
121
+ to: string | null;
122
+ };
123
+
124
+ /**
125
* Map of Composio's GMAIL toolkit.
126
*/
127
export const GMAIL = {
128
slug: "gmail",
129
tools: {
130
+ ADD_LABEL_TO_EMAIL: "GMAIL_ADD_LABEL_TO_EMAIL",
131
CREATE_EMAIL_DRAFT: "GMAIL_CREATE_EMAIL_DRAFT",
71
- DELETE_MESSAGE: "GMAIL_DELETE_MESSAGE",
72
- FETCH_EMAILS: "GMAIL_FETCH_EMAILS",
132
+ CREATE_LABEL: "GMAIL_CREATE_LABEL",
133
},
134
triggerTypes: {
135
NEW_GMAIL_MESSAGE: {
@@ -211,19 +271,43 @@ describe('CLI: composio ts generate', () => {
271
},
272
},
273
}
274
+
275
+ /**
276
+ * Type map of all available trigger payloads for toolkit "GMAIL".
277
+ */
278
+ export type GMAIL_TRIGGER_PAYLOADS = {
279
+ NEW_GMAIL_MESSAGE: GMAIL_NEW_GMAIL_MESSAGE_PAYLOAD
280
+ }
281
+
282
+ /**
283
+ * Type map of all available trigger events for toolkit "GMAIL".
284
+ */
285
+ export type GMAIL_TRIGGER_EVENTS = {
286
+ NEW_GMAIL_MESSAGE: TriggerEvent<GMAIL_NEW_GMAIL_MESSAGE_PAYLOAD>
287
+ }
288
"
289
`);
290
expect(slackSourceCode).toMatchInlineSnapshot(`
217
- "/**
218
- * Map of Composio's SLACK toolkit.
219
- */
220
- export const SLACK = {
221
- slug: "slack",
222
- tools: {},
223
- triggerTypes: {},
224
- }
225
- "
226
- `);
291
+ "/**
292
+ * Map of Composio's SLACK toolkit.
293
+ */
294
+ export const SLACK = {
295
+ slug: "slack",
296
+ tools: {},
297
+ triggerTypes: {},
298
+ }
299
+
300
+ /**
301
+ * Type map of all available trigger payloads for toolkit "SLACK".
302
+ */
303
+ export type SLACK_TRIGGER_PAYLOADS = {}
304
+
305
+ /**
306
+ * Type map of all available trigger events for toolkit "SLACK".
307
+ */
308
+ export type SLACK_TRIGGER_EVENTS = {}
309
+ "
310
+ `);
311
expect(indexSourceCode).toMatchInlineSnapshot(`
312
"/**
313
* Auto-generated by Composio CLI. Do not modify manually.
@@ -306,15 +390,74 @@ describe('CLI: composio ts generate', () => {
390
const indexSourceCode = yield* fs.readFileString(path.join(outputDir, 'index.ts'));
391
392
expect(gmailSourceCode).toMatchInlineSnapshot(`
309
- "/**
393
+ "import { type TriggerEvent } from "@composio/core"
394
+
395
+ type GMAIL_NEW_GMAIL_MESSAGE_PAYLOAD = {
396
+ /**
397
+ * Attachment List
398
+ * @description The list of attachments in the message
399
+ * @default null
400
+ */
401
+ attachment_list: unknown[] | null;
402
+ /**
403
+ * Message ID
404
+ * @description The message ID of the message
405
+ * @default null
406
+ */
407
+ message_id: string | null;
408
+ /**
409
+ * Message Text
410
+ * @description The text of the message
411
+ * @default null
412
+ */
413
+ message_text: string | null;
414
+ /**
415
+ * Message Timestamp
416
+ * @description The timestamp of the message
417
+ * @default null
418
+ */
419
+ message_timestamp: string | null;
420
+ /**
421
+ * Payload
422
+ * @description The payload of the message
423
+ * @default null
424
+ */
425
+ payload: Record<string, never> | null;
426
+ /**
427
+ * Sender
428
+ * @description The sender of the message
429
+ * @default null
430
+ */
431
+ sender: string | null;
432
+ /**
433
+ * Subject
434
+ * @description The subject of the message
435
+ * @default null
436
+ */
437
+ subject: string | null;
438
+ /**
439
+ * Thread ID
440
+ * @description The thread ID of the message
441
+ * @default null
442
+ */
443
+ thread_id: string | null;
444
+ /**
445
+ * To
446
+ * @description The recipient of the message
447
+ * @default null
448
+ */
449
+ to: string | null;
450
+ };
451
+
452
+ /**
453
* Map of Composio's GMAIL toolkit.
454
*/
455
export const GMAIL = {
456
slug: "gmail",
457
tools: {
458
+ ADD_LABEL_TO_EMAIL: "GMAIL_ADD_LABEL_TO_EMAIL",
459
CREATE_EMAIL_DRAFT: "GMAIL_CREATE_EMAIL_DRAFT",
316
- DELETE_MESSAGE: "GMAIL_DELETE_MESSAGE",
317
- FETCH_EMAILS: "GMAIL_FETCH_EMAILS",
460
+ CREATE_LABEL: "GMAIL_CREATE_LABEL",
461
},
462
triggerTypes: {
463
NEW_GMAIL_MESSAGE: {
@@ -456,19 +599,43 @@ describe('CLI: composio ts generate', () => {
599
},
600
},
601
}
602
+
603
+ /**
604
+ * Type map of all available trigger payloads for toolkit "GMAIL".
605
+ */
606
+ export type GMAIL_TRIGGER_PAYLOADS = {
607
+ NEW_GMAIL_MESSAGE: GMAIL_NEW_GMAIL_MESSAGE_PAYLOAD
608
+ }
609
+
610
+ /**
611
+ * Type map of all available trigger events for toolkit "GMAIL".
612
+ */
613
+ export type GMAIL_TRIGGER_EVENTS = {
614
+ NEW_GMAIL_MESSAGE: TriggerEvent<GMAIL_NEW_GMAIL_MESSAGE_PAYLOAD>
615
+ }
616
"
617
`);
618
expect(slackSourceCode).toMatchInlineSnapshot(`
462
- "/**
463
- * Map of Composio's SLACK toolkit.
464
- */
465
- export const SLACK = {
466
- slug: "slack",
467
- tools: {},
468
- triggerTypes: {},
469
- }
470
- "
471
- `);
619
+ "/**
620
+ * Map of Composio's SLACK toolkit.
621
+ */
622
+ export const SLACK = {
623
+ slug: "slack",
624
+ tools: {},
625
+ triggerTypes: {},
626
+ }
627
+
628
+ /**
629
+ * Type map of all available trigger payloads for toolkit "SLACK".
630
+ */
631
+ export type SLACK_TRIGGER_PAYLOADS = {}
632
+
633
+ /**
634
+ * Type map of all available trigger events for toolkit "SLACK".
635
+ */
636
+ export type SLACK_TRIGGER_EVENTS = {}
637
+ "
638
+ `);
639
expect(indexSourceCode).toMatchInlineSnapshot(`
640
"/**
641
* Auto-generated by Composio CLI. Do not modify manually.
ts/packages/cli/test/src/effects/detect-platform.test.ts
+10
-4
@@ -364,7 +364,7 @@ describe('detect-platform.ts', () => {
364
});
365
366
describe('Type Tests', () => {
367
- it('should return correct PlatformArch type for supported combinations', () => {
367
+ it('should return correct PlatformArch type for supported combinations', async () => {
368
// This test verifies TypeScript types at runtime
369
const testType = async (platform: string, arch: string): Promise<PlatformArch> => {
370
return await Effect.runPromise(
@@ -373,9 +373,15 @@ describe('detect-platform.ts', () => {
373
};
374
375
// These calls should compile without TypeScript errors
376
- expect(testType('darwin', 'x64')).resolves.toEqual({ platform: 'darwin', arch: 'x64' });
377
- expect(testType('darwin', 'arm64')).resolves.toEqual({ platform: 'darwin', arch: 'aarch64' });
378
- expect(testType('linux', 'aarch64')).resolves.toEqual({ platform: 'linux', arch: 'aarch64' });
376
+ await expect(testType('darwin', 'x64')).resolves.toEqual({ platform: 'darwin', arch: 'x64' });
377
+ await expect(testType('darwin', 'arm64')).resolves.toEqual({
378
+ platform: 'darwin',
379
+ arch: 'aarch64',
380
+ });
381
+ await expect(testType('linux', 'aarch64')).resolves.toEqual({
382
+ platform: 'linux',
383
+ arch: 'aarch64',
384
+ });
385
});
386
});
387
});
ts/packages/cli/test/src/generation/python/generate-toolkit-source.test.ts
+6
-5
@@ -4,7 +4,8 @@ import { createToolkitIndex } from 'src/generation/create-toolkit-index';
4
import { BANNER } from 'src/generation/constants';
5
import { makeTestToolkits } from 'test/__utils__/models/toolkits';
6
import { assertPythonIsValid } from 'test/__utils__/python-compiler';
7
-import { TRIGGER_TYPE_GMAIL } from 'test/__mocks__/trigger-type-gmail';
7
+import { TRIGGER_TYPES_GMAIL } from 'test/__mocks__/trigger-types-gmail';
8
+import { TOOLS_GMAIL } from 'test/__mocks__/tools_gmail';
9
10
describe('generatePythonToolkitSources', () => {
11
it('[Given] empty toolkits, tools, triggerTypes [Then] it returns an empty array', () => {
@@ -70,8 +71,8 @@ describe('generatePythonToolkitSources', () => {
71
72
const index = createToolkitIndex({
73
toolkits,
73
- tools: ['GMAIL_CREATE_EMAIL_DRAFT', 'GMAIL_DELETE_MESSAGE', 'GMAIL_FETCH_EMAILS'],
74
- triggerTypes: [TRIGGER_TYPE_GMAIL],
74
+ tools: [...TOOLS_GMAIL.slice(0, 3)],
75
+ triggerTypes: [...TRIGGER_TYPES_GMAIL],
76
});
77
78
const sources = generatePythonToolkitSources(BANNER)(index);
@@ -88,9 +89,9 @@ describe('generatePythonToolkitSources', () => {
89
slug: str = "gmail"
90
91
class tools:
92
+ ADD_LABEL_TO_EMAIL = "GMAIL_ADD_LABEL_TO_EMAIL"
93
CREATE_EMAIL_DRAFT = "GMAIL_CREATE_EMAIL_DRAFT"
92
- DELETE_MESSAGE = "GMAIL_DELETE_MESSAGE"
93
- FETCH_EMAILS = "GMAIL_FETCH_EMAILS"
94
+ CREATE_LABEL = "GMAIL_CREATE_LABEL"
95
96
class triggers:
97
NEW_GMAIL_MESSAGE = {
ts/packages/cli/test/src/generation/toolkit-index.test.ts
+7
-3
@@ -1,7 +1,7 @@
1
import { describe, expect, it } from 'vitest';
2
import { createToolkitIndex } from 'src/generation/create-toolkit-index';
3
import { makeTestToolkits } from 'test/__utils__/models/toolkits';
4
-import { TRIGGER_TYPE_GMAIL } from 'test/__mocks__/trigger-type-gmail';
4
+import { TRIGGER_TYPES_GMAIL } from 'test/__mocks__/trigger-types-gmail';
5
6
describe('createToolkitIndex', () => {
7
it('[Given] empty toolkits, tools, triggerTypes [Then] it returns an empty index', () => {
@@ -58,8 +58,12 @@ describe('createToolkitIndex', () => {
58
},
59
]);
60
61
+ const GMAIL_NEW_GMAIL_MESSAGE = TRIGGER_TYPES_GMAIL.find(
62
+ triggerType => triggerType.slug === 'GMAIL_NEW_GMAIL_MESSAGE'
63
+ )!;
64
+
65
const tools = ['GMAIL_CREATE_EMAIL_DRAFT', 'GMAIL_DELETE_MESSAGE', 'GMAIL_FETCH_EMAILS'];
62
- const triggerTypes = [TRIGGER_TYPE_GMAIL];
66
+ const triggerTypes = [GMAIL_NEW_GMAIL_MESSAGE];
67
68
const index = createToolkitIndex({
69
toolkits,
@@ -76,7 +80,7 @@ describe('createToolkitIndex', () => {
80
FETCH_EMAILS: 'GMAIL_FETCH_EMAILS',
81
},
82
triggerTypes: {
79
- NEW_GMAIL_MESSAGE: TRIGGER_TYPE_GMAIL,
83
+ NEW_GMAIL_MESSAGE: GMAIL_NEW_GMAIL_MESSAGE,
84
},
85
},
86
SLACK: {
ts/packages/cli/test/src/generation/typescript/generate-index-source.test.ts
+7
-4
@@ -6,7 +6,10 @@ import {
6
import { createToolkitIndex } from 'src/generation/create-toolkit-index';
7
import { makeTestToolkits } from 'test/__utils__/models/toolkits';
8
import { assertTypeScriptIsValid } from 'test/__utils__/typescript-compiler';
9
-import { TRIGGER_TYPE_GMAIL } from 'test/__mocks__/trigger-type-gmail';
9
+import { TOOLS_GITHUB } from 'test/__mocks__/tools_github';
10
+import { TRIGGER_TYPES_GITHUB } from 'test/__mocks__/trigger-types-github';
11
+import { TRIGGER_TYPES_GMAIL } from 'test/__mocks__/trigger-types-gmail';
12
+import { TOOLS_GMAIL } from 'test/__mocks__/tools_gmail';
13
14
describe('generateTypeScriptToolkitSources', () => {
15
describe('with a single emitted file', () => {
@@ -116,8 +119,8 @@ describe('generateTypeScriptToolkitSources', () => {
119
120
const index = createToolkitIndex({
121
toolkits,
119
- tools: ['GMAIL_CREATE_EMAIL_DRAFT', 'GMAIL_DELETE_MESSAGE', 'GMAIL_FETCH_EMAILS'],
120
- triggerTypes: [TRIGGER_TYPE_GMAIL],
122
+ tools: [...TOOLS_GMAIL.slice(0, 3), ...TOOLS_GITHUB.slice(0, 3)],
123
+ triggerTypes: [...TRIGGER_TYPES_GITHUB, ...TRIGGER_TYPES_GMAIL],
124
});
125
126
const source = generateIndexSource(params)(index);
@@ -272,7 +275,7 @@ describe('generateTypeScriptToolkitSources', () => {
275
const index = createToolkitIndex({
276
toolkits,
277
tools: ['GMAIL_CREATE_EMAIL_DRAFT', 'GMAIL_DELETE_MESSAGE', 'GMAIL_FETCH_EMAILS'],
275
- triggerTypes: [TRIGGER_TYPE_GMAIL],
278
+ triggerTypes: [...TRIGGER_TYPES_GMAIL],
279
});
280
281
const source = generateIndexSource(params)(index);
ts/packages/cli/test/src/generation/typescript/generate-toolkit-source.test.ts
+867
-66
@@ -1,45 +1,56 @@
1
-import { describe, expect, it } from 'vitest';
1
+import { describe, expect, it } from '@effect/vitest';
2
+import { Effect } from 'effect';
3
import { generateTypeScriptToolkitSources } from 'src/generation/typescript/generate-toolkit-sources';
4
import { createToolkitIndex } from 'src/generation/create-toolkit-index';
5
import { makeTestToolkits } from 'test/__utils__/models/toolkits';
5
-import { TRIGGER_TYPE_GMAIL } from 'test/__mocks__/trigger-type-gmail';
6
+import { TOOLS_GITHUB } from 'test/__mocks__/tools_github';
7
+import { TOOLS_GOOGLEDRIVE } from 'test/__mocks__/tools_googledrive';
8
+import { TOOLS_GMAIL } from 'test/__mocks__/tools_gmail';
9
+import { TRIGGER_TYPES_GITHUB } from 'test/__mocks__/trigger-types-github';
10
+import { TRIGGER_TYPES_GMAIL } from 'test/__mocks__/trigger-types-gmail';
11
+import { TRIGGER_TYPES_GOOGLEDRIVE } from 'test/__mocks__/trigger-types-googledrive';
12
13
describe('generateTypeScriptToolkitSources', () => {
14
describe('with a single emitted file', () => {
15
describe('with banner', () => {
16
const banner = 'Some banner that will appear in a comment';
17
12
- it('[Given] empty toolkits, tools, triggerTypes [Then] it returns an empty array', () => {
13
- const index = createToolkitIndex({
14
- toolkits: [],
15
- tools: [],
16
- triggerTypes: [],
17
- });
18
-
19
- const sources = generateTypeScriptToolkitSources(banner)(index);
20
-
21
- expect(sources).toEqual([]);
22
- });
23
-
24
- it('[Given] a single toolkit with no tools or triggerTypes [Then] it returns a single toolkit source file', () => {
25
- const toolkits = makeTestToolkits([
26
- {
27
- name: 'Slack Helper',
28
- slug: 'slack',
29
- },
30
- ]);
31
-
32
- const index = createToolkitIndex({
33
- toolkits,
34
- tools: [],
35
- triggerTypes: [],
36
- });
37
-
38
- const sources = generateTypeScriptToolkitSources(banner)(index);
39
- expect(sources).toHaveLength(1);
40
- expect(sources[0]).toHaveLength(2);
41
- expect(sources[0][0]).toBe('slack.ts');
42
- expect(sources[0][1]).toMatchInlineSnapshot(`
18
+ it.effect(
19
+ '[Given] empty toolkits, tools, triggerTypes [Then] it returns an empty array',
20
+ Effect.fn(function* () {
21
+ const index = createToolkitIndex({
22
+ toolkits: [],
23
+ tools: [],
24
+ triggerTypes: [],
25
+ });
26
+
27
+ const sources = yield* generateTypeScriptToolkitSources(banner)(index);
28
+
29
+ expect(sources).toEqual([]);
30
+ })
31
+ );
32
+
33
+ it.effect(
34
+ '[Given] a single toolkit with no tools or triggerTypes [Then] it returns a single toolkit source file',
35
+ Effect.fn(function* () {
36
+ const toolkits = makeTestToolkits([
37
+ {
38
+ name: 'Slack Helper',
39
+ slug: 'slack',
40
+ },
41
+ ]);
42
+
43
+ const index = createToolkitIndex({
44
+ toolkits,
45
+ tools: [],
46
+ triggerTypes: [],
47
+ });
48
+
49
+ const sources = yield* generateTypeScriptToolkitSources(banner)(index);
50
+ expect(sources).toHaveLength(1);
51
+ expect(sources[0]).toHaveLength(2);
52
+ expect(sources[0][0]).toBe('slack.ts');
53
+ expect(sources[0][1]).toMatchInlineSnapshot(`
54
"/**
55
* Map of Composio's SLACK toolkit.
56
*/
@@ -48,43 +59,131 @@ describe('generateTypeScriptToolkitSources', () => {
59
tools: {},
60
triggerTypes: {},
61
}
62
+
63
+ /**
64
+ * Type map of all available trigger payloads for toolkit "SLACK".
65
+ */
66
+ export type SLACK_TRIGGER_PAYLOADS = {}
67
+
68
+ /**
69
+ * Type map of all available trigger events for toolkit "SLACK".
70
+ */
71
+ export type SLACK_TRIGGER_EVENTS = {}
72
"
73
`);
53
- });
54
-
55
- it('[Given] toolkits with tools and triggerTypes [Then] it returns a TypeScript source file for each toolkit + the index map', () => {
56
- const toolkits = makeTestToolkits([
57
- {
58
- name: 'Gmail',
59
- slug: 'gmail',
60
- },
61
- {
62
- name: 'Slack Helper',
63
- slug: 'slack',
64
- },
65
- ]);
66
-
67
- const index = createToolkitIndex({
68
- toolkits,
69
- tools: ['GMAIL_CREATE_EMAIL_DRAFT', 'GMAIL_DELETE_MESSAGE', 'GMAIL_FETCH_EMAILS'],
70
- triggerTypes: [TRIGGER_TYPE_GMAIL],
71
- });
72
-
73
- const sources = generateTypeScriptToolkitSources(banner)(index);
74
- expect(sources).toHaveLength(2);
75
-
76
- expect(sources[0]).toHaveLength(2);
77
- expect(sources[0][0]).toBe('gmail.ts');
78
- expect(sources[0][1]).toMatchInlineSnapshot(`
79
- "/**
74
+ })
75
+ );
76
+
77
+ it.effect(
78
+ '[Given] toolkits with tools and triggerTypes [Then] it returns a TypeScript source file for each toolkit + the index map',
79
+ Effect.fn(function* () {
80
+ const toolkits = makeTestToolkits([
81
+ {
82
+ name: 'Gmail',
83
+ slug: 'gmail',
84
+ },
85
+ {
86
+ name: 'Github',
87
+ slug: 'github',
88
+ },
89
+ {
90
+ name: 'Slack Helper',
91
+ slug: 'slack',
92
+ },
93
+ {
94
+ name: 'Google Drive',
95
+ slug: 'googledrive',
96
+ },
97
+ ]);
98
+
99
+ const index = createToolkitIndex({
100
+ toolkits,
101
+ tools: [
102
+ ...TOOLS_GITHUB.slice(0, 3),
103
+ ...TOOLS_GMAIL.slice(0, 3),
104
+ ...TOOLS_GOOGLEDRIVE.slice(0, 3),
105
+ ],
106
+ triggerTypes: [
107
+ ...TRIGGER_TYPES_GITHUB,
108
+ ...TRIGGER_TYPES_GMAIL,
109
+ ...TRIGGER_TYPES_GOOGLEDRIVE,
110
+ ],
111
+ });
112
+
113
+ const sources = yield* generateTypeScriptToolkitSources(banner)(index);
114
+ expect(sources).toHaveLength(4);
115
+
116
+ expect(sources[0]).toHaveLength(2);
117
+ expect(sources[0][0]).toBe('gmail.ts');
118
+ expect(sources[0][1]).toMatchInlineSnapshot(`
119
+ "import { type TriggerEvent } from "@composio/core"
120
+
121
+ type GMAIL_NEW_GMAIL_MESSAGE_PAYLOAD = {
122
+ /**
123
+ * Attachment List
124
+ * @description The list of attachments in the message
125
+ * @default null
126
+ */
127
+ attachment_list: unknown[] | null;
128
+ /**
129
+ * Message ID
130
+ * @description The message ID of the message
131
+ * @default null
132
+ */
133
+ message_id: string | null;
134
+ /**
135
+ * Message Text
136
+ * @description The text of the message
137
+ * @default null
138
+ */
139
+ message_text: string | null;
140
+ /**
141
+ * Message Timestamp
142
+ * @description The timestamp of the message
143
+ * @default null
144
+ */
145
+ message_timestamp: string | null;
146
+ /**
147
+ * Payload
148
+ * @description The payload of the message
149
+ * @default null
150
+ */
151
+ payload: Record<string, never> | null;
152
+ /**
153
+ * Sender
154
+ * @description The sender of the message
155
+ * @default null
156
+ */
157
+ sender: string | null;
158
+ /**
159
+ * Subject
160
+ * @description The subject of the message
161
+ * @default null
162
+ */
163
+ subject: string | null;
164
+ /**
165
+ * Thread ID
166
+ * @description The thread ID of the message
167
+ * @default null
168
+ */
169
+ thread_id: string | null;
170
+ /**
171
+ * To
172
+ * @description The recipient of the message
173
+ * @default null
174
+ */
175
+ to: string | null;
176
+ };
177
+
178
+ /**
179
* Map of Composio's GMAIL toolkit.
180
*/
181
export const GMAIL = {
182
slug: "gmail",
183
tools: {
184
+ ADD_LABEL_TO_EMAIL: "GMAIL_ADD_LABEL_TO_EMAIL",
185
CREATE_EMAIL_DRAFT: "GMAIL_CREATE_EMAIL_DRAFT",
86
- DELETE_MESSAGE: "GMAIL_DELETE_MESSAGE",
87
- FETCH_EMAILS: "GMAIL_FETCH_EMAILS",
186
+ CREATE_LABEL: "GMAIL_CREATE_LABEL",
187
},
188
triggerTypes: {
189
NEW_GMAIL_MESSAGE: {
@@ -226,12 +325,647 @@ describe('generateTypeScriptToolkitSources', () => {
325
},
326
},
327
}
328
+
329
+ /**
330
+ * Type map of all available trigger payloads for toolkit "GMAIL".
331
+ */
332
+ export type GMAIL_TRIGGER_PAYLOADS = {
333
+ NEW_GMAIL_MESSAGE: GMAIL_NEW_GMAIL_MESSAGE_PAYLOAD
334
+ }
335
+
336
+ /**
337
+ * Type map of all available trigger events for toolkit "GMAIL".
338
+ */
339
+ export type GMAIL_TRIGGER_EVENTS = {
340
+ NEW_GMAIL_MESSAGE: TriggerEvent<GMAIL_NEW_GMAIL_MESSAGE_PAYLOAD>
341
+ }
342
"
343
`);
344
232
- expect(sources[1]).toHaveLength(2);
233
- expect(sources[1][0]).toBe('slack.ts');
234
- expect(sources[1][1]).toMatchInlineSnapshot(`
345
+ expect(sources[1]).toHaveLength(2);
346
+ expect(sources[1][0]).toBe('github.ts');
347
+ expect(sources[1][1]).toMatchInlineSnapshot(`
348
+ "import { type TriggerEvent } from "@composio/core"
349
+
350
+ type GITHUB_COMMIT_EVENT_PAYLOAD = {
351
+ /**
352
+ * Author
353
+ * @description The GitHub username of the commit author
354
+ */
355
+ author?: string;
356
+ /**
357
+ * Id
358
+ * @description The SHA of the commit
359
+ */
360
+ id?: string;
361
+ /**
362
+ * Message
363
+ * @description The commit message
364
+ */
365
+ message?: string;
366
+ /**
367
+ * Timestamp
368
+ * @description The timestamp of the commit
369
+ */
370
+ timestamp?: string;
371
+ /**
372
+ * Url
373
+ * @description The GitHub URL of the commit
374
+ */
375
+ url?: string;
376
+ };
377
+
378
+ type GITHUB_FOLLOWER_EVENT_PAYLOAD = {
379
+ /**
380
+ * Username
381
+ * @description Username of the github follower
382
+ */
383
+ username?: string;
384
+ };
385
+
386
+ type GITHUB_ISSUE_ADDED_EVENT_PAYLOAD = {
387
+ /**
388
+ * Action
389
+ * @description The action that was performed on the issue
390
+ */
391
+ action?: string;
392
+ /**
393
+ * Createdat
394
+ * @description The timestamp when the issue was created
395
+ */
396
+ createdAt?: string;
397
+ /**
398
+ * Createdby
399
+ * @description The GitHub username of the user who created the issue
400
+ */
401
+ createdBy?: string;
402
+ /**
403
+ * Description
404
+ * @description A detailed description of the issue
405
+ * @default
406
+ */
407
+ description: string;
408
+ /**
409
+ * Issue Id
410
+ * @description The unique ID assigned to the issue
411
+ */
412
+ issue_id?: number;
413
+ /**
414
+ * Number
415
+ * @description The unique number assigned to the issue
416
+ */
417
+ number?: number;
418
+ /**
419
+ * Title
420
+ * @description The title of the issue
421
+ */
422
+ title?: string;
423
+ /**
424
+ * Url
425
+ * @description The GitHub URL of the issue
426
+ */
427
+ url?: string;
428
+ };
429
+
430
+ type GITHUB_LABEL_ADDED_EVENT_PAYLOAD = {
431
+ /**
432
+ * Action
433
+ * @description The action that was performed on the label
434
+ */
435
+ action?: string;
436
+ /**
437
+ * Label
438
+ * @description The name of the label that was added
439
+ */
440
+ label?: string;
441
+ /**
442
+ * Labeled At
443
+ * @description The timestamp when the label was added
444
+ */
445
+ labeled_at?: string;
446
+ /**
447
+ * Labeled By
448
+ * @description The GitHub username of the user who added the label
449
+ */
450
+ labeled_by?: string;
451
+ /**
452
+ * Pull Request Number
453
+ * @description The unique number assigned to the pull request
454
+ */
455
+ pull_request_number?: number;
456
+ /**
457
+ * Pull Request Title
458
+ * @description The title of the pull request
459
+ */
460
+ pull_request_title?: string;
461
+ /**
462
+ * Pull Request Url
463
+ * @description The GitHub URL of the pull request
464
+ */
465
+ pull_request_url?: string;
466
+ };
467
+
468
+ type GITHUB_PULL_REQUEST_EVENT_PAYLOAD = {
469
+ /**
470
+ * Action
471
+ * @description The action that was performed on the pull request
472
+ */
473
+ action?: string;
474
+ /**
475
+ * Createdat
476
+ * @description The timestamp when the pull request was created
477
+ */
478
+ createdAt?: string;
479
+ /**
480
+ * Createdby
481
+ * @description The GitHub username of the user who created the pull request
482
+ */
483
+ createdBy?: string;
484
+ /**
485
+ * Description
486
+ * @description A detailed description of the pull request
487
+ * @default
488
+ */
489
+ description: string;
490
+ /**
491
+ * Number
492
+ * @description The unique number assigned to the pull request
493
+ */
494
+ number?: number;
495
+ /**
496
+ * Title
497
+ * @description The title of the pull request
498
+ */
499
+ title?: string;
500
+ /**
501
+ * Url
502
+ * @description The GitHub URL of the pull request
503
+ */
504
+ url?: string;
505
+ };
506
+
507
+ type GITHUB_STAR_ADDED_EVENT_PAYLOAD = {
508
+ /**
509
+ * Action
510
+ * @description The action that was performed on the star
511
+ */
512
+ action?: string;
513
+ /**
514
+ * Repository Id
515
+ * @description The unique ID assigned to the repository
516
+ */
517
+ repository_id?: number;
518
+ /**
519
+ * Repository Name
520
+ * @description The name of the repository
521
+ */
522
+ repository_name?: string;
523
+ /**
524
+ * Repository Url
525
+ * @description The GitHub URL of the repository
526
+ */
527
+ repository_url?: string;
528
+ /**
529
+ * Starred At
530
+ * @description The timestamp when the star was added
531
+ */
532
+ starred_at?: string;
533
+ /**
534
+ * Starred By
535
+ * @description The GitHub username of the user who added the star
536
+ */
537
+ starred_by?: string;
538
+ };
539
+
540
+ /**
541
+ * Map of Composio's GITHUB toolkit.
542
+ */
543
+ export const GITHUB = {
544
+ slug: "github",
545
+ tools: {
546
+ ACCEPT_A_REPOSITORY_INVITATION: "GITHUB_ACCEPT_A_REPOSITORY_INVITATION",
547
+ ACTIVITY_LIST_REPO_S_STARRED_BY_AUTHENTICATED_USER: "GITHUB_ACTIVITY_LIST_REPO_S_STARRED_BY_AUTHENTICATED_USER",
548
+ ACTIVITY_LIST_STARGAZERS_FOR_REPO: "GITHUB_ACTIVITY_LIST_STARGAZERS_FOR_REPO",
549
+ },
550
+ triggerTypes: {
551
+ COMMIT_EVENT: {
552
+ slug: "GITHUB_COMMIT_EVENT",
553
+ name: "Commit Event",
554
+ description: "Triggered when a new commit is pushed to a repository.",
555
+ instructions: "This trigger fires every time a new commit is pushed to the repository.",
556
+ config: {
557
+ properties: {
558
+ owner: {
559
+ description: "Owner of the repository",
560
+ title: "Owner",
561
+ type: "string",
562
+ },
563
+ repo: {
564
+ description: "Repository name",
565
+ title: "Repo",
566
+ type: "string",
567
+ },
568
+ },
569
+ required: ["owner", "repo"],
570
+ title: "WebhookConfigSchema",
571
+ type: "object",
572
+ },
573
+ payload: {
574
+ properties: {
575
+ author: {
576
+ description: "The GitHub username of the commit author",
577
+ examples: ["octocat"],
578
+ title: "Author",
579
+ type: "string",
580
+ },
581
+ id: {
582
+ description: "The SHA of the commit",
583
+ examples: ["7638417db6d59f3c431d3e1f261cc637155684cd"],
584
+ title: "Id",
585
+ type: "string",
586
+ },
587
+ message: {
588
+ description: "The commit message",
589
+ examples: ["Fix typo in README"],
590
+ title: "Message",
591
+ type: "string",
592
+ },
593
+ timestamp: {
594
+ description: "The timestamp of the commit",
595
+ examples: ["2021-04-14T02:15:15Z"],
596
+ title: "Timestamp",
597
+ type: "string",
598
+ },
599
+ url: {
600
+ description: "The GitHub URL of the commit",
601
+ examples: ["https://github.com/octocat/Hello-World/commit/7638417db6d59f3c431d3e1f261cc637155684cd"],
602
+ title: "Url",
603
+ type: "string",
604
+ },
605
+ },
606
+ required: ["id", "message", "timestamp", "author", "url"],
607
+ title: "CommitPayloadSchema",
608
+ type: "object",
609
+ },
610
+ type: "webhook",
611
+ },
612
+ FOLLOWER_EVENT: {
613
+ slug: "GITHUB_FOLLOWER_EVENT",
614
+ name: "Follower Changes",
615
+ description: "Triggers when there are changes in GitHub followers.",
616
+ instructions: "**Instructions for Setting Up the Trigger:**\\n\\n This trigger fires when there are changes in your GitHub followers.\\n It detects new followers and unfollowers.\\n ",
617
+ config: {
618
+ properties: {
619
+ interval: {
620
+ default: 1,
621
+ description: "Periodic Interval to Check for Updates & Send a Trigger in Minutes",
622
+ title: "Interval",
623
+ type: "number",
624
+ },
625
+ },
626
+ title: "GithubFollowerConfig",
627
+ type: "object",
628
+ },
629
+ payload: {
630
+ properties: {
631
+ username: {
632
+ description: "Username of the github follower",
633
+ title: "Username",
634
+ type: "string",
635
+ },
636
+ },
637
+ required: ["username"],
638
+ title: "GithubFollowerPayload",
639
+ type: "object",
640
+ },
641
+ type: "poll",
642
+ },
643
+ ISSUE_ADDED_EVENT: {
644
+ slug: "GITHUB_ISSUE_ADDED_EVENT",
645
+ name: "Issue Added Event",
646
+ description: "Triggered when a new issue is added to the repository.",
647
+ instructions: "This trigger fires every time a new issue is added to the repository.",
648
+ config: {
649
+ properties: {
650
+ owner: {
651
+ description: "Owner of the repository",
652
+ title: "Owner",
653
+ type: "string",
654
+ },
655
+ repo: {
656
+ description: "Repository name",
657
+ title: "Repo",
658
+ type: "string",
659
+ },
660
+ },
661
+ required: ["owner", "repo"],
662
+ title: "WebhookConfigSchema",
663
+ type: "object",
664
+ },
665
+ payload: {
666
+ properties: {
667
+ action: {
668
+ description: "The action that was performed on the issue",
669
+ examples: ["opened"],
670
+ title: "Action",
671
+ type: "string",
672
+ },
673
+ createdAt: {
674
+ description: "The timestamp when the issue was created",
675
+ examples: ["2021-04-14T02:15:15Z"],
676
+ title: "Createdat",
677
+ type: "string",
678
+ },
679
+ createdBy: {
680
+ description: "The GitHub username of the user who created the issue",
681
+ examples: ["octocat"],
682
+ title: "Createdby",
683
+ type: "string",
684
+ },
685
+ description: {
686
+ default: "",
687
+ description: "A detailed description of the issue",
688
+ examples: ["There is a bug in the code that needs to be fixed."],
689
+ title: "Description",
690
+ type: "string",
691
+ },
692
+ issue_id: {
693
+ description: "The unique ID assigned to the issue",
694
+ examples: [101],
695
+ title: "Issue Id",
696
+ type: "integer",
697
+ },
698
+ number: {
699
+ description: "The unique number assigned to the issue",
700
+ examples: [42],
701
+ title: "Number",
702
+ type: "integer",
703
+ },
704
+ title: {
705
+ description: "The title of the issue",
706
+ examples: ["Bug in code"],
707
+ title: "Title",
708
+ type: "string",
709
+ },
710
+ url: {
711
+ description: "The GitHub URL of the issue",
712
+ examples: ["https://github.com/octocat/Hello-World/issues/42"],
713
+ title: "Url",
714
+ type: "string",
715
+ },
716
+ },
717
+ required: ["action", "issue_id", "number", "title", "createdBy", "createdAt", "url"],
718
+ title: "IssueAddedPayloadSchema",
719
+ type: "object",
720
+ },
721
+ type: "webhook",
722
+ },
723
+ LABEL_ADDED_EVENT: {
724
+ slug: "GITHUB_LABEL_ADDED_EVENT",
725
+ name: "Label Added Event",
726
+ description: "Triggered when a new label is added to a pull request.",
727
+ instructions: "This trigger fires every time a new label is added to a pull request on the repository.",
728
+ config: {
729
+ properties: {
730
+ owner: {
731
+ description: "Owner of the repository",
732
+ title: "Owner",
733
+ type: "string",
734
+ },
735
+ repo: {
736
+ description: "Repository name",
737
+ title: "Repo",
738
+ type: "string",
739
+ },
740
+ },
741
+ required: ["owner", "repo"],
742
+ title: "WebhookConfigSchema",
743
+ type: "object",
744
+ },
745
+ payload: {
746
+ properties: {
747
+ action: {
748
+ description: "The action that was performed on the label",
749
+ examples: ["labeled"],
750
+ title: "Action",
751
+ type: "string",
752
+ },
753
+ label: {
754
+ description: "The name of the label that was added",
755
+ examples: ["bug", "enhancement"],
756
+ title: "Label",
757
+ type: "string",
758
+ },
759
+ labeled_at: {
760
+ description: "The timestamp when the label was added",
761
+ examples: ["2021-04-14T02:15:15Z"],
762
+ title: "Labeled At",
763
+ type: "string",
764
+ },
765
+ labeled_by: {
766
+ description: "The GitHub username of the user who added the label",
767
+ examples: ["octocat"],
768
+ title: "Labeled By",
769
+ type: "string",
770
+ },
771
+ pull_request_number: {
772
+ description: "The unique number assigned to the pull request",
773
+ examples: [42],
774
+ title: "Pull Request Number",
775
+ type: "integer",
776
+ },
777
+ pull_request_title: {
778
+ description: "The title of the pull request",
779
+ examples: ["Fix typo in README"],
780
+ title: "Pull Request Title",
781
+ type: "string",
782
+ },
783
+ pull_request_url: {
784
+ description: "The GitHub URL of the pull request",
785
+ examples: ["https://github.com/octocat/Hello-World/pull/42"],
786
+ title: "Pull Request Url",
787
+ type: "string",
788
+ },
789
+ },
790
+ required: ["action", "label", "pull_request_number", "pull_request_title", "pull_request_url", "labeled_by", "labeled_at"],
791
+ title: "LabelAddedPayloadSchema",
792
+ type: "object",
793
+ },
794
+ type: "webhook",
795
+ },
796
+ PULL_REQUEST_EVENT: {
797
+ slug: "GITHUB_PULL_REQUEST_EVENT",
798
+ name: "Pull Request Event",
799
+ description: "Triggered when a pull request is opened, closed, or synchronized.",
800
+ instructions: "This trigger fires every time a pull request is opened, closed, or synchronized on the repository.",
801
+ config: {
802
+ properties: {
803
+ owner: {
804
+ description: "Owner of the repository",
805
+ title: "Owner",
806
+ type: "string",
807
+ },
808
+ repo: {
809
+ description: "Repository name",
810
+ title: "Repo",
811
+ type: "string",
812
+ },
813
+ },
814
+ required: ["owner", "repo"],
815
+ title: "WebhookConfigSchema",
816
+ type: "object",
817
+ },
818
+ payload: {
819
+ properties: {
820
+ action: {
821
+ description: "The action that was performed on the pull request",
822
+ examples: ["opened", "closed", "synchronize"],
823
+ title: "Action",
824
+ type: "string",
825
+ },
826
+ createdAt: {
827
+ description: "The timestamp when the pull request was created",
828
+ examples: ["2021-04-14T02:15:15Z"],
829
+ title: "Createdat",
830
+ type: "string",
831
+ },
832
+ createdBy: {
833
+ description: "The GitHub username of the user who created the pull request",
834
+ examples: ["octocat"],
835
+ title: "Createdby",
836
+ type: "string",
837
+ },
838
+ description: {
839
+ default: "",
840
+ description: "A detailed description of the pull request",
841
+ examples: ["This pull request fixes a typo found in the README file under the 'Installation' section."],
842
+ title: "Description",
843
+ type: "string",
844
+ },
845
+ number: {
846
+ description: "The unique number assigned to the pull request",
847
+ examples: [42],
848
+ title: "Number",
849
+ type: "integer",
850
+ },
851
+ title: {
852
+ description: "The title of the pull request",
853
+ examples: ["Fix typo in README"],
854
+ title: "Title",
855
+ type: "string",
856
+ },
857
+ url: {
858
+ description: "The GitHub URL of the pull request",
859
+ examples: ["https://github.com/octocat/Hello-World/pull/42"],
860
+ title: "Url",
861
+ type: "string",
862
+ },
863
+ },
864
+ required: ["action", "number", "title", "createdBy", "createdAt", "url"],
865
+ title: "PullRequestPayloadSchema",
866
+ type: "object",
867
+ },
868
+ type: "webhook",
869
+ },
870
+ STAR_ADDED_EVENT: {
871
+ slug: "GITHUB_STAR_ADDED_EVENT",
872
+ name: "Star Added Event",
873
+ description: "Triggered when a new star is added to the repository.",
874
+ instructions: "This trigger fires every time a new star is added to the repository.",
875
+ config: {
876
+ properties: {
877
+ owner: {
878
+ description: "Owner of the repository",
879
+ title: "Owner",
880
+ type: "string",
881
+ },
882
+ repo: {
883
+ description: "Repository name",
884
+ title: "Repo",
885
+ type: "string",
886
+ },
887
+ },
888
+ required: ["owner", "repo"],
889
+ title: "WebhookConfigSchema",
890
+ type: "object",
891
+ },
892
+ payload: {
893
+ properties: {
894
+ action: {
895
+ description: "The action that was performed on the star",
896
+ examples: ["created"],
897
+ title: "Action",
898
+ type: "string",
899
+ },
900
+ repository_id: {
901
+ description: "The unique ID assigned to the repository",
902
+ examples: [101],
903
+ title: "Repository Id",
904
+ type: "integer",
905
+ },
906
+ repository_name: {
907
+ description: "The name of the repository",
908
+ examples: ["Hello-World"],
909
+ title: "Repository Name",
910
+ type: "string",
911
+ },
912
+ repository_url: {
913
+ description: "The GitHub URL of the repository",
914
+ examples: ["https://github.com/octocat/Hello-World"],
915
+ title: "Repository Url",
916
+ type: "string",
917
+ },
918
+ starred_at: {
919
+ description: "The timestamp when the star was added",
920
+ examples: ["2021-04-14T02:15:15Z"],
921
+ title: "Starred At",
922
+ type: "string",
923
+ },
924
+ starred_by: {
925
+ description: "The GitHub username of the user who added the star",
926
+ examples: ["octocat"],
927
+ title: "Starred By",
928
+ type: "string",
929
+ },
930
+ },
931
+ required: ["action", "starred_at", "repository_id", "repository_name", "repository_url", "starred_by"],
932
+ title: "StarAddedPayloadSchema",
933
+ type: "object",
934
+ },
935
+ type: "webhook",
936
+ },
937
+ },
938
+ }
939
+
940
+ /**
941
+ * Type map of all available trigger payloads for toolkit "GITHUB".
942
+ */
943
+ export type GITHUB_TRIGGER_PAYLOADS = {
944
+ COMMIT_EVENT: GITHUB_COMMIT_EVENT_PAYLOAD
945
+ FOLLOWER_EVENT: GITHUB_FOLLOWER_EVENT_PAYLOAD
946
+ ISSUE_ADDED_EVENT: GITHUB_ISSUE_ADDED_EVENT_PAYLOAD
947
+ LABEL_ADDED_EVENT: GITHUB_LABEL_ADDED_EVENT_PAYLOAD
948
+ PULL_REQUEST_EVENT: GITHUB_PULL_REQUEST_EVENT_PAYLOAD
949
+ STAR_ADDED_EVENT: GITHUB_STAR_ADDED_EVENT_PAYLOAD
950
+ }
951
+
952
+ /**
953
+ * Type map of all available trigger events for toolkit "GITHUB".
954
+ */
955
+ export type GITHUB_TRIGGER_EVENTS = {
956
+ COMMIT_EVENT: TriggerEvent<GITHUB_COMMIT_EVENT_PAYLOAD>
957
+ FOLLOWER_EVENT: TriggerEvent<GITHUB_FOLLOWER_EVENT_PAYLOAD>
958
+ ISSUE_ADDED_EVENT: TriggerEvent<GITHUB_ISSUE_ADDED_EVENT_PAYLOAD>
959
+ LABEL_ADDED_EVENT: TriggerEvent<GITHUB_LABEL_ADDED_EVENT_PAYLOAD>
960
+ PULL_REQUEST_EVENT: TriggerEvent<GITHUB_PULL_REQUEST_EVENT_PAYLOAD>
961
+ STAR_ADDED_EVENT: TriggerEvent<GITHUB_STAR_ADDED_EVENT_PAYLOAD>
962
+ }
963
+ "
964
+ `);
965
+
966
+ expect(sources[2]).toHaveLength(2);
967
+ expect(sources[2][0]).toBe('slack.ts');
968
+ expect(sources[2][1]).toMatchInlineSnapshot(`
969
"/**
970
* Map of Composio's SLACK toolkit.
971
*/
@@ -240,9 +974,76 @@ describe('generateTypeScriptToolkitSources', () => {
974
tools: {},
975
triggerTypes: {},
976
}
977
+
978
+ /**
979
+ * Type map of all available trigger payloads for toolkit "SLACK".
980
+ */
981
+ export type SLACK_TRIGGER_PAYLOADS = {}
982
+
983
+ /**
984
+ * Type map of all available trigger events for toolkit "SLACK".
985
+ */
986
+ export type SLACK_TRIGGER_EVENTS = {}
987
"
988
`);
245
- });
989
+
990
+ expect(sources[3]).toHaveLength(2);
991
+ expect(sources[3][0]).toBe('googledrive.ts');
992
+ expect(sources[3][1]).toMatchInlineSnapshot(`
993
+ "import { type TriggerEvent } from "@composio/core"
994
+
995
+ type GOOGLEDRIVE_GOOGLE_DRIVE_CHANGES_PAYLOAD = object;
996
+
997
+ /**
998
+ * Map of Composio's GOOGLEDRIVE toolkit.
999
+ */
1000
+ export const GOOGLEDRIVE = {
1001
+ slug: "googledrive",
1002
+ tools: {
1003
+ ADD_FILE_SHARING_PREFERENCE: "GOOGLEDRIVE_ADD_FILE_SHARING_PREFERENCE",
1004
+ COPY_FILE: "GOOGLEDRIVE_COPY_FILE",
1005
+ CREATE_COMMENT: "GOOGLEDRIVE_CREATE_COMMENT",
1006
+ },
1007
+ triggerTypes: {
1008
+ GOOGLE_DRIVE_CHANGES: {
1009
+ slug: "GOOGLEDRIVE_GOOGLE_DRIVE_CHANGES",
1010
+ name: "Google Drive Changes",
1011
+ description: "Triggers when changes are detected in a Google Drive.",
1012
+ instructions: "\\n **Instructions for Setting Up the Trigger:**\\n - Ensure you have set the necessary permissions to access Google Drive.\\n ",
1013
+ config: {
1014
+ description: "Configuration for Google Drive trigger",
1015
+ properties: {},
1016
+ title: "DriveConfig",
1017
+ type: "object",
1018
+ },
1019
+ payload: {
1020
+ description: "Schema for Google Drive trigger payload.\\nCurrently no specific fields are present, but may include\\nconfiguration options in the future.",
1021
+ properties: {},
1022
+ title: "DrivePayload",
1023
+ type: "object",
1024
+ },
1025
+ type: "poll",
1026
+ },
1027
+ },
1028
+ }
1029
+
1030
+ /**
1031
+ * Type map of all available trigger payloads for toolkit "GOOGLEDRIVE".
1032
+ */
1033
+ export type GOOGLEDRIVE_TRIGGER_PAYLOADS = {
1034
+ GOOGLE_DRIVE_CHANGES: GOOGLEDRIVE_GOOGLE_DRIVE_CHANGES_PAYLOAD
1035
+ }
1036
+
1037
+ /**
1038
+ * Type map of all available trigger events for toolkit "GOOGLEDRIVE".
1039
+ */
1040
+ export type GOOGLEDRIVE_TRIGGER_EVENTS = {
1041
+ GOOGLE_DRIVE_CHANGES: TriggerEvent<GOOGLEDRIVE_GOOGLE_DRIVE_CHANGES_PAYLOAD>
1042
+ }
1043
+ "
1044
+ `);
1045
+ })
1046
+ );
1047
});
1048
});
1049
});
ts/packages/cli/test/src/generation/typescript/generate.test.ts
+102
-69
@@ -1,10 +1,14 @@
1
-import { describe, expect, it } from 'vitest';
1
+import { describe, expect, it } from '@effect/vitest';
2
import { createToolkitIndex } from 'src/generation/create-toolkit-index';
3
import { generateTypeScriptSources } from 'src/generation/typescript/generate';
4
import { makeTestToolkits } from 'test/__utils__/models/toolkits';
5
import path from 'path';
6
import { assertTypeScriptIsValid } from 'test/__utils__/typescript-compiler';
7
-import { TRIGGER_TYPE_GMAIL } from 'test/__mocks__/trigger-type-gmail';
7
+import { TOOLS_GITHUB } from 'test/__mocks__/tools_github';
8
+import { TRIGGER_TYPES_GITHUB } from 'test/__mocks__/trigger-types-github';
9
+import { TRIGGER_TYPES_GMAIL } from 'test/__mocks__/trigger-types-gmail';
10
+import { TOOLS_GMAIL } from 'test/__mocks__/tools_gmail';
11
+import { Effect } from 'effect';
12
13
describe('generateTypeScriptSources', () => {
14
describe('with multiple emitted files', () => {
@@ -20,20 +24,22 @@ describe('generateTypeScriptSources', () => {
24
banner: 'Some banner that will appear in a comment',
25
};
26
23
- it('[Given] empty toolkits, tools, triggerTypes [Then] it returns just the index map', () => {
24
- const index = createToolkitIndex({
25
- toolkits: [],
26
- tools: [],
27
- triggerTypes: [],
28
- });
27
+ it.effect(
28
+ '[Given] empty toolkits, tools, triggerTypes [Then] it returns just the index map',
29
+ Effect.fn(function* () {
30
+ const index = createToolkitIndex({
31
+ toolkits: [],
32
+ tools: [],
33
+ triggerTypes: [],
34
+ });
35
30
- const sources = generateTypeScriptSources(params)(index);
36
+ const sources = yield* generateTypeScriptSources(params)(index);
37
32
- expect(sources).toHaveLength(1);
33
- const [[filename, source]] = sources;
38
+ expect(sources).toHaveLength(1);
39
+ const [[filename, source]] = sources;
40
35
- expect(filename).toBe(path.join(params.outputDir, 'index.ts'));
36
- expect(source).toMatchInlineSnapshot(`
41
+ expect(filename).toBe(path.join(params.outputDir, 'index.ts'));
42
+ expect(source).toMatchInlineSnapshot(`
43
"/**
44
* Some banner that will appear in a comment
45
*/
@@ -60,28 +66,31 @@ describe('generateTypeScriptSources', () => {
66
"
67
`);
68
63
- assertTypeScriptIsValid({ files: { './index.ts': source } });
64
- });
65
-
66
- it('[Given] a single toolkit with no tools or triggerTypes [Then] it returns a single toolkit source file + the index map', () => {
67
- const toolkits = makeTestToolkits([
68
- {
69
- name: 'Slack Helper',
70
- slug: 'slack',
71
- },
72
- ]);
73
-
74
- const index = createToolkitIndex({
75
- toolkits,
76
- tools: [],
77
- triggerTypes: [],
78
- });
79
-
80
- const sources = generateTypeScriptSources(params)(index);
81
- expect(sources).toHaveLength(2);
82
- expect(sources[0]).toHaveLength(2);
83
- expect(sources[0][0]).toBe(path.join(params.outputDir, 'slack.ts'));
84
- expect(sources[0][1]).toMatchInlineSnapshot(`
69
+ assertTypeScriptIsValid({ files: { './index.ts': source } });
70
+ })
71
+ );
72
+
73
+ it.effect(
74
+ '[Given] a single toolkit with no tools or triggerTypes [Then] it returns a single toolkit source file + the index map',
75
+ Effect.fn(function* () {
76
+ const toolkits = makeTestToolkits([
77
+ {
78
+ name: 'Slack Helper',
79
+ slug: 'slack',
80
+ },
81
+ ]);
82
+
83
+ const index = createToolkitIndex({
84
+ toolkits,
85
+ tools: [],
86
+ triggerTypes: [],
87
+ });
88
+
89
+ const sources = yield* generateTypeScriptSources(params)(index);
90
+ expect(sources).toHaveLength(2);
91
+ expect(sources[0]).toHaveLength(2);
92
+ expect(sources[0][0]).toBe(path.join(params.outputDir, 'slack.ts'));
93
+ expect(sources[0][1]).toMatchInlineSnapshot(`
94
"/**
95
* Map of Composio's SLACK toolkit.
96
*/
@@ -90,13 +99,23 @@ describe('generateTypeScriptSources', () => {
99
tools: {},
100
triggerTypes: {},
101
}
102
+
103
+ /**
104
+ * Type map of all available trigger payloads for toolkit "SLACK".
105
+ */
106
+ export type SLACK_TRIGGER_PAYLOADS = {}
107
+
108
+ /**
109
+ * Type map of all available trigger events for toolkit "SLACK".
110
+ */
111
+ export type SLACK_TRIGGER_EVENTS = {}
112
"
113
`);
95
- assertTypeScriptIsValid({ files: { './slack.ts': sources[0][1] } });
114
+ assertTypeScriptIsValid({ files: { './slack.ts': sources[0][1] } });
115
97
- expect(sources[1]).toHaveLength(2);
98
- expect(sources[1][0]).toBe(path.join(params.outputDir, 'index.ts'));
99
- expect(sources[1][1]).toMatchInlineSnapshot(`
116
+ expect(sources[1]).toHaveLength(2);
117
+ expect(sources[1][0]).toBe(path.join(params.outputDir, 'index.ts'));
118
+ expect(sources[1][1]).toMatchInlineSnapshot(`
119
"/**
120
* Some banner that will appear in a comment
121
*/
@@ -128,30 +147,33 @@ describe('generateTypeScriptSources', () => {
147
"
148
`);
149
131
- assertTypeScriptIsValid({
132
- files: { './index.ts': sources[1][1], './slack.ts': sources[0][1] },
133
- });
134
- });
135
-
136
- it('[Given] toolkits with tools and triggerTypes [Then] it returns a TypeScript source file for each toolkit + the index map', () => {
137
- const toolkits = makeTestToolkits([
138
- {
139
- name: 'Slack Helper',
140
- slug: 'slack',
141
- },
142
- ]);
143
-
144
- const index = createToolkitIndex({
145
- toolkits,
146
- tools: ['GMAIL_CREATE_EMAIL_DRAFT', 'GMAIL_DELETE_MESSAGE', 'GMAIL_FETCH_EMAILS'],
147
- triggerTypes: [TRIGGER_TYPE_GMAIL],
148
- });
149
-
150
- const sources = generateTypeScriptSources(params)(index);
151
- expect(sources).toHaveLength(2);
152
- expect(sources[0]).toHaveLength(2);
153
- expect(sources[0][0]).toBe(path.join(params.outputDir, './slack.ts'));
154
- expect(sources[0][1]).toMatchInlineSnapshot(`
150
+ assertTypeScriptIsValid({
151
+ files: { './index.ts': sources[1][1], './slack.ts': sources[0][1] },
152
+ });
153
+ })
154
+ );
155
+
156
+ it.effect(
157
+ '[Given] toolkits with tools and triggerTypes [Then] it returns a TypeScript source file for each toolkit + the index map',
158
+ Effect.fn(function* () {
159
+ const toolkits = makeTestToolkits([
160
+ {
161
+ name: 'Slack Helper',
162
+ slug: 'slack',
163
+ },
164
+ ]);
165
+
166
+ const index = createToolkitIndex({
167
+ toolkits,
168
+ tools: [...TOOLS_GMAIL.slice(0, 3), ...TOOLS_GITHUB.slice(0, 3)],
169
+ triggerTypes: [...TRIGGER_TYPES_GMAIL, ...TRIGGER_TYPES_GITHUB],
170
+ });
171
+
172
+ const sources = yield* generateTypeScriptSources(params)(index);
173
+ expect(sources).toHaveLength(2);
174
+ expect(sources[0]).toHaveLength(2);
175
+ expect(sources[0][0]).toBe(path.join(params.outputDir, './slack.ts'));
176
+ expect(sources[0][1]).toMatchInlineSnapshot(`
177
"/**
178
* Map of Composio's SLACK toolkit.
179
*/
@@ -160,13 +182,23 @@ describe('generateTypeScriptSources', () => {
182
tools: {},
183
triggerTypes: {},
184
}
185
+
186
+ /**
187
+ * Type map of all available trigger payloads for toolkit "SLACK".
188
+ */
189
+ export type SLACK_TRIGGER_PAYLOADS = {}
190
+
191
+ /**
192
+ * Type map of all available trigger events for toolkit "SLACK".
193
+ */
194
+ export type SLACK_TRIGGER_EVENTS = {}
195
"
196
`);
165
- assertTypeScriptIsValid({ files: { './slack.ts': sources[0][1] } });
197
+ assertTypeScriptIsValid({ files: { './slack.ts': sources[0][1] } });
198
167
- expect(sources[1]).toHaveLength(2);
168
- expect(sources[1][0]).toBe(path.join(params.outputDir, 'index.ts'));
169
- expect(sources[1][1]).toMatchInlineSnapshot(`
199
+ expect(sources[1]).toHaveLength(2);
200
+ expect(sources[1][0]).toBe(path.join(params.outputDir, 'index.ts'));
201
+ expect(sources[1][1]).toMatchInlineSnapshot(`
202
"/**
203
* Some banner that will appear in a comment
204
*/
@@ -197,8 +229,9 @@ describe('generateTypeScriptSources', () => {
229
230
"
231
`);
200
- assertTypeScriptIsValid({ files: { './index.ts': sources[1][1] } });
201
- });
232
+ assertTypeScriptIsValid({ files: { './index.ts': sources[1][1] } });
233
+ })
234
+ );
235
});
236
});
237
});
ts/packages/ts-builders/src/TypeDeclaration.ts
+12
-2
@@ -10,7 +10,7 @@ export class TypeDeclaration<InnerType extends TypeBuilder = TypeBuilder> implem
10
11
constructor(
12
public name: string,
13
- readonly type: InnerType
13
+ private type: InnerType | string
14
) {}
15
16
addGenericParameter(param: GenericParameter): this {
@@ -23,6 +23,10 @@ export class TypeDeclaration<InnerType extends TypeBuilder = TypeBuilder> implem
23
return this;
24
}
25
26
+ setValue(typeDecl: string) {
27
+ this.type = typeDecl;
28
+ }
29
+
30
setDocComment(docComment: DocComment): this {
31
this.docComment = docComment;
32
return this;
@@ -32,6 +36,12 @@ export class TypeDeclaration<InnerType extends TypeBuilder = TypeBuilder> implem
36
if (this.docComment) {
37
writer.write(this.docComment);
38
}
39
+
40
+ if (typeof this.type === 'string') {
41
+ writer.write(this.type);
42
+ return;
43
+ }
44
+
45
writer.write('type ').write(this.name);
46
if (this.genericParameters.length > 0) {
47
writer.write('<').writeJoined(', ', this.genericParameters).write('>');
@@ -42,7 +52,7 @@ export class TypeDeclaration<InnerType extends TypeBuilder = TypeBuilder> implem
52
53
export function typeDeclaration<InnerType extends TypeBuilder = TypeBuilder>(
54
name: string,
45
- type: InnerType
55
+ type: InnerType | string
56
) {
57
return new TypeDeclaration(name, type);
58
}