Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
merge cli (#1649)
Co-authored-by: jkomyno <12381818+jkomyno@users.noreply.github.com>
Rahul Tarak committed
Jun 17, 2025 at 18:06 UTC
1d02d3e49591e6d73d7dd7d11d5b7c0d4276b53d
145 files changed
+8829
-42
.dockerignore
new
+28
@@ -0,0 +1,28 @@
1
+# Git
2
+.git
3
+.gitignore
4
+
5
+# Docker
6
+Dockerfile
7
+.dockerignore
8
+
9
+# Node.js
10
+node_modules
11
+/packages/*/node_modules
12
+/packages/*/dist
13
+/dist
14
+npm-debug.log*
15
+yarn-debug.log*
16
+yarn-error.log*
17
+
18
+# Editor directories and files
19
+.idea
20
+.vscode
21
+*.suo
22
+*.ntvs*
23
+*.njsproj
24
+*.sln
25
+
26
+# OS generated files
27
+.DS_Store
28
+Thumbs.db
Dockerfile
new
+45
@@ -0,0 +1,45 @@
1
+# Stage 1: Build the CLI binary
2
+FROM debian:bookworm-slim AS builder
3
+
4
+# Install dependencies
5
+RUN apt-get update && apt-get install -y \
6
+ git \
7
+ curl \
8
+ unzip \
9
+ && rm -rf /var/lib/apt/lists/*
10
+
11
+# Install Node.js, pnpm and bun
12
+RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
13
+ && apt-get install -y nodejs \
14
+ && npm install -g pnpm@10.8.0 \
15
+ && curl -fsSL https://bun.sh/install | bash
16
+
17
+# Add bun to PATH
18
+ENV PATH="/root/.bun/bin:${PATH}"
19
+
20
+# Clone the repository
21
+WORKDIR /app
22
+COPY . .
23
+
24
+# Build the monorepo
25
+RUN pnpm install
26
+RUN pnpm build
27
+
28
+# Build the CLI binary
29
+WORKDIR /app/packages/cli
30
+RUN pnpm build:bin
31
+
32
+# Stage 2: Create a minimal runtime image
33
+FROM debian:bookworm-slim
34
+
35
+# Copy the CLI binary from the builder stage
36
+COPY --from=builder /app/packages/cli/dist/composio /composio
37
+
38
+# Make the binary executable
39
+RUN chmod +x /composio
40
+
41
+# Create directory for user data
42
+WORKDIR /root/.composio
43
+
44
+# Set the entrypoint
45
+ENTRYPOINT ["/composio", "--version"]
pnpm-lock.yaml
+1157
-42
@@ -119,7 +119,7 @@ importers:
119
version: 5.8.3
120
vitest:
121
specifier: ^3.1.4
122
- version: 3.2.3(@types/node@20.19.1)(@vitest/ui@3.2.3)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0)
122
+ version: 3.2.3(@types/node@20.19.1)(@vitest/ui@3.2.3)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0)
123
yaml:
124
specifier: ^2.8.0
125
version: 2.8.0
@@ -282,7 +282,7 @@ importers:
282
version: link:../../packages/providers/mastra
283
'@mastra/core':
284
specifier: ^0.10.0
285
- version: 0.10.5(openapi-types@12.1.3)(react@18.3.1)(zod@3.25.62)
285
+ version: 0.10.5(effect@3.16.8)(openapi-types@12.1.3)(react@18.3.1)(zod@3.25.62)
286
dotenv:
287
specifier: ^16.4.1
288
version: 16.5.0
@@ -448,6 +448,76 @@ importers:
448
specifier: ^5.8.3
449
version: 5.8.3
450
451
+ ts/packages/cli:
452
+ dependencies:
453
+ '@composio/client':
454
+ specifier: 0.1.0-alpha.17
455
+ version: 0.1.0-alpha.17
456
+ '@composio/core':
457
+ specifier: workspace:*
458
+ version: link:../core
459
+ '@composio/ts-builders':
460
+ specifier: workspace:*
461
+ version: link:../ts-builders
462
+ '@effect/cli':
463
+ specifier: ^0.63.11
464
+ version: 0.63.11(@effect/platform@0.84.11(effect@3.16.8))(@effect/printer-ansi@0.44.8(@effect/typeclass@0.35.8(effect@3.16.8))(effect@3.16.8))(@effect/printer@0.44.8(@effect/typeclass@0.35.8(effect@3.16.8))(effect@3.16.8))(effect@3.16.8)
465
+ '@effect/platform-bun':
466
+ specifier: ^0.69.16
467
+ version: 0.69.16(@effect/cluster@0.39.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/sql@0.38.1(@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/workflow@0.2.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/sql@0.38.1(@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(effect@3.16.8)
468
+ '@effect/platform-node-shared':
469
+ specifier: ^0.40.2
470
+ version: 0.40.2(@effect/cluster@0.39.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/sql@0.38.1(@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/workflow@0.2.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/sql@0.38.1(@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(effect@3.16.8)
471
+ chalk:
472
+ specifier: ^5.4.1
473
+ version: 5.4.1
474
+ effect:
475
+ specifier: ^3.16.8
476
+ version: 3.16.8
477
+ effect-errors:
478
+ specifier: ^1.10.11
479
+ version: 1.10.11(ff5edfb43a1891ed491370151a2c33b9)
480
+ indent-string:
481
+ specifier: ^5.0.0
482
+ version: 5.0.0
483
+ semver:
484
+ specifier: ^7.7.2
485
+ version: 7.7.2
486
+ superjson:
487
+ specifier: ^2.2.2
488
+ version: 2.2.2
489
+ devDependencies:
490
+ '@effect/eslint-plugin':
491
+ specifier: ^0.3.2
492
+ version: 0.3.2
493
+ '@effect/platform':
494
+ specifier: ^0.84.11
495
+ version: 0.84.11(effect@3.16.8)
496
+ '@effect/vitest':
497
+ specifier: ^0.23.8
498
+ version: 0.23.8(effect@3.16.8)(vitest@3.2.4(@types/node@24.0.3)(@vitest/ui@3.2.3(vitest@3.2.3))(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0))
499
+ '@types/bun':
500
+ specifier: ^1.2.16
501
+ version: 1.2.16
502
+ '@types/semver':
503
+ specifier: ^7.7.0
504
+ version: 7.7.0
505
+ tempy:
506
+ specifier: ^3.1.0
507
+ version: 3.1.0
508
+ tsup:
509
+ specifier: ^8.5.0
510
+ version: 8.5.0(jiti@1.21.7)(postcss@8.5.5)(tsx@4.20.3)(typescript@5.8.3)(yaml@2.8.0)
511
+ tsx:
512
+ specifier: ^4.20.3
513
+ version: 4.20.3
514
+ typescript:
515
+ specifier: ^5.8.3
516
+ version: 5.8.3
517
+ vitest:
518
+ specifier: ^3.2.4
519
+ version: 3.2.4(@types/node@24.0.3)(@vitest/ui@3.2.3(vitest@3.2.3))(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0)
520
+
521
ts/packages/core:
522
dependencies:
523
'@composio/client':
@@ -508,13 +578,13 @@ importers:
578
version: 24.0.3
579
tsup:
580
specifier: ^8.4.0
511
- version: 8.5.0(jiti@1.21.7)(postcss@8.5.5)(tsx@4.20.1)(typescript@5.8.3)(yaml@2.8.0)
581
+ version: 8.5.0(jiti@1.21.7)(postcss@8.5.5)(tsx@4.20.3)(typescript@5.8.3)(yaml@2.8.0)
582
typescript:
583
specifier: ^5.8.3
584
version: 5.8.3
585
vitest:
586
specifier: ^3.1.4
517
- version: 3.2.3(@types/node@24.0.3)(@vitest/ui@3.2.3)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0)
587
+ version: 3.2.3(@types/node@24.0.3)(@vitest/ui@3.2.3)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0)
588
589
ts/packages/providers/anthropic:
590
dependencies:
@@ -527,13 +597,13 @@ importers:
597
version: link:../../core
598
tsup:
599
specifier: ^8.4.0
530
- version: 8.5.0(jiti@1.21.7)(postcss@8.5.5)(tsx@4.20.1)(typescript@5.8.3)(yaml@2.8.0)
600
+ version: 8.5.0(jiti@1.21.7)(postcss@8.5.5)(tsx@4.20.3)(typescript@5.8.3)(yaml@2.8.0)
601
typescript:
602
specifier: ^5.8.3
603
version: 5.8.3
604
vitest:
605
specifier: ^3.1.4
536
- version: 3.2.3(@types/node@24.0.3)(@vitest/ui@3.2.3)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0)
606
+ version: 3.2.3(@types/node@24.0.3)(@vitest/ui@3.2.3)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0)
607
608
ts/packages/providers/cloudflare:
609
dependencies:
@@ -546,13 +616,13 @@ importers:
616
version: link:../../core
617
tsup:
618
specifier: ^8.4.0
549
- version: 8.5.0(jiti@1.21.7)(postcss@8.5.5)(tsx@4.20.1)(typescript@5.8.3)(yaml@2.8.0)
619
+ version: 8.5.0(jiti@1.21.7)(postcss@8.5.5)(tsx@4.20.3)(typescript@5.8.3)(yaml@2.8.0)
620
typescript:
621
specifier: ^5.8.3
622
version: 5.8.3
623
vitest:
624
specifier: ^3.1.4
555
- version: 3.2.3(@types/node@24.0.3)(@vitest/ui@3.2.3)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0)
625
+ version: 3.2.3(@types/node@24.0.3)(@vitest/ui@3.2.3)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0)
626
627
ts/packages/providers/google:
628
dependencies:
@@ -565,7 +635,7 @@ importers:
635
version: link:../../core
636
tsup:
637
specifier: ^8.4.0
568
- version: 8.5.0(jiti@1.21.7)(postcss@8.5.5)(tsx@4.20.1)(typescript@5.8.3)(yaml@2.8.0)
638
+ version: 8.5.0(jiti@1.21.7)(postcss@8.5.5)(tsx@4.20.3)(typescript@5.8.3)(yaml@2.8.0)
639
typescript:
640
specifier: ^5.8.3
641
version: 5.8.3
@@ -581,32 +651,32 @@ importers:
651
version: link:../../core
652
tsup:
653
specifier: ^8.4.0
584
- version: 8.5.0(jiti@1.21.7)(postcss@8.5.5)(tsx@4.20.1)(typescript@5.8.3)(yaml@2.8.0)
654
+ version: 8.5.0(jiti@1.21.7)(postcss@8.5.5)(tsx@4.20.3)(typescript@5.8.3)(yaml@2.8.0)
655
typescript:
656
specifier: ^5.8.3
657
version: 5.8.3
658
vitest:
659
specifier: ^3.1.4
590
- version: 3.2.3(@types/node@24.0.3)(@vitest/ui@3.2.3)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0)
660
+ version: 3.2.3(@types/node@24.0.3)(@vitest/ui@3.2.3)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0)
661
662
ts/packages/providers/mastra:
663
dependencies:
664
'@mastra/core':
665
specifier: ^0.10.0
596
- version: 0.10.5(openapi-types@12.1.3)(react@18.3.1)(zod@3.25.62)
666
+ version: 0.10.5(effect@3.16.8)(openapi-types@12.1.3)(react@18.3.1)(zod@3.25.62)
667
devDependencies:
668
'@composio/core':
669
specifier: workspace:*
670
version: link:../../core
671
tsup:
672
specifier: ^8.4.0
603
- version: 8.5.0(jiti@1.21.7)(postcss@8.5.5)(tsx@4.20.1)(typescript@5.8.3)(yaml@2.8.0)
673
+ version: 8.5.0(jiti@1.21.7)(postcss@8.5.5)(tsx@4.20.3)(typescript@5.8.3)(yaml@2.8.0)
674
typescript:
675
specifier: ^5.8.3
676
version: 5.8.3
677
vitest:
678
specifier: ^3.1.4
609
- version: 3.2.3(@types/node@24.0.3)(@vitest/ui@3.2.3)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0)
679
+ version: 3.2.3(@types/node@24.0.3)(@vitest/ui@3.2.3)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0)
680
681
ts/packages/providers/openai:
682
dependencies:
@@ -619,13 +689,13 @@ importers:
689
version: link:../../core
690
tsup:
691
specifier: ^8.4.0
622
- version: 8.5.0(jiti@1.21.7)(postcss@8.5.5)(tsx@4.20.1)(typescript@5.8.3)(yaml@2.8.0)
692
+ version: 8.5.0(jiti@1.21.7)(postcss@8.5.5)(tsx@4.20.3)(typescript@5.8.3)(yaml@2.8.0)
693
typescript:
694
specifier: ^5.8.3
695
version: 5.8.3
696
vitest:
697
specifier: ^3.1.4
628
- version: 3.2.3(@types/node@24.0.3)(@vitest/ui@3.2.3)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0)
698
+ version: 3.2.3(@types/node@24.0.3)(@vitest/ui@3.2.3)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0)
699
700
ts/packages/providers/openai-agents:
701
dependencies:
@@ -638,13 +708,13 @@ importers:
708
version: link:../../core
709
tsup:
710
specifier: ^8.4.0
641
- version: 8.5.0(jiti@1.21.7)(postcss@8.5.5)(tsx@4.20.1)(typescript@5.8.3)(yaml@2.8.0)
711
+ version: 8.5.0(jiti@1.21.7)(postcss@8.5.5)(tsx@4.20.3)(typescript@5.8.3)(yaml@2.8.0)
712
typescript:
713
specifier: ^5.8.3
714
version: 5.8.3
715
vitest:
716
specifier: ^3.1.4
647
- version: 3.2.3(@types/node@24.0.3)(@vitest/ui@3.2.3)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0)
717
+ version: 3.2.3(@types/node@24.0.3)(@vitest/ui@3.2.3)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0)
718
719
ts/packages/providers/vercel:
720
dependencies:
@@ -657,13 +727,32 @@ importers:
727
version: link:../../core
728
tsup:
729
specifier: ^8.4.0
660
- version: 8.5.0(jiti@1.21.7)(postcss@8.5.5)(tsx@4.20.1)(typescript@5.8.3)(yaml@2.8.0)
730
+ version: 8.5.0(jiti@1.21.7)(postcss@8.5.5)(tsx@4.20.3)(typescript@5.8.3)(yaml@2.8.0)
731
typescript:
732
specifier: ^5.8.3
733
version: 5.8.3
734
vitest:
735
specifier: ^3.1.4
666
- version: 3.2.3(@types/node@24.0.3)(@vitest/ui@3.2.3)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0)
736
+ version: 3.2.3(@types/node@24.0.3)(@vitest/ui@3.2.3)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0)
737
+
738
+ ts/packages/ts-builders:
739
+ dependencies:
740
+ '@babel/helper-validator-identifier':
741
+ specifier: ^7.27.1
742
+ version: 7.27.1
743
+ devDependencies:
744
+ '@types/babel__helper-validator-identifier':
745
+ specifier: ^7.15.2
746
+ version: 7.15.2
747
+ helper-validator-identifier:
748
+ specifier: link:@types/@babel/helper-validator-identifier
749
+ version: link:@types/@babel/helper-validator-identifier
750
+ tsup:
751
+ specifier: ^8.4.0
752
+ version: 8.5.0(jiti@1.21.7)(postcss@8.5.5)(tsx@4.20.3)(typescript@5.8.3)(yaml@2.8.0)
753
+ vitest:
754
+ specifier: ^3.1.4
755
+ version: 3.2.4(@types/node@24.0.3)(@vitest/ui@3.2.3(vitest@3.2.3))(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0)
756
757
packages:
758
@@ -851,6 +940,10 @@ packages:
940
resolution: {integrity: sha512-DIIotRnefVL6DiaHtO6/21DhJ4JZnnIwdNbpwiAhdt/AVbttcE4yw925gsjur0OGv5BTYXQXU3YnANBYnZjuQA==}
941
engines: {node: '>=18.0.0'}
942
943
+ '@babel/helper-validator-identifier@7.27.1':
944
+ resolution: {integrity: sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==}
945
+ engines: {node: '>=6.9.0'}
946
+
947
'@babel/runtime@7.27.6':
948
resolution: {integrity: sha512-vbavdySgbTTrmFE+EsiqUTzlOr5bzlnJtUv9PynGCAKvfQqjIXbvFdumPM/GxMDfyuGMJaJAU6TO4zc1Jf1i8Q==}
949
engines: {node: '>=6.9.0'}
@@ -922,6 +1015,9 @@ packages:
1015
'@anthropic-ai/sdk': ^0.52.0
1016
'@composio/core': 0.1.22
1017
1018
+ '@composio/client@0.1.0-alpha.17':
1019
+ resolution: {integrity: sha512-iNCDSgdwfFVsjbbyZIMknMPy4uO8Xw5+MP2aI+yoQo34VXF17Fi6ZHYirrJPf8RbdoRROZTDJjC/rU18mMzC2Q==}
1020
+
1021
'@composio/client@0.1.0-alpha.22':
1022
resolution: {integrity: sha512-b9KCO5gy0EsCG+nXikOdm17PiZZ85rw3vwu9aNRIse9rEj2FA1SScpP+P9GN4G0lQHl+QPyDuVvGa6U9AATFeg==}
1023
@@ -944,6 +1040,129 @@ packages:
1040
'@composio/core': 0.1.22
1041
ai: ^4.3.8
1042
1043
+ '@dprint/formatter@0.4.1':
1044
+ resolution: {integrity: sha512-IB/GXdlMOvi0UhQQ9mcY15Fxcrc2JPadmo6tqefCNV0bptFq7YBpggzpqYXldBXDa04CbKJ+rDwO2eNRPE2+/g==}
1045
+
1046
+ '@dprint/typescript@0.91.8':
1047
+ resolution: {integrity: sha512-tuKn4leCPItox1O4uunHcQF0QllDCvPWklnNQIh2PiWWVtRAGltJJnM4Cwj5AciplosD1Hiz7vAY3ew3crLb3A==}
1048
+
1049
+ '@effect/cli@0.63.11':
1050
+ resolution: {integrity: sha512-e95XKrCLHFKQor1hRWD5a1nh34cMNWfhaZrRc5iqI2sWUTQumV8rUUDAPMNHFzPC0tIrdO42wrOUhIgJs7i2iA==}
1051
+ peerDependencies:
1052
+ '@effect/platform': ^0.84.11
1053
+ '@effect/printer': ^0.44.7
1054
+ '@effect/printer-ansi': ^0.44.7
1055
+ effect: ^3.16.7
1056
+
1057
+ '@effect/cluster@0.39.2':
1058
+ resolution: {integrity: sha512-oU/UDcKzQDPoEHW+1wMLxJRmdlA5n/Ek7AG0vrKFQ7AiBxUpJwlJlym8BVgpRBVs3VTI+Jwigmx5z8rp1dJA+g==}
1059
+ peerDependencies:
1060
+ '@effect/platform': ^0.85.1
1061
+ '@effect/rpc': ^0.62.2
1062
+ '@effect/sql': ^0.38.1
1063
+ '@effect/workflow': ^0.2.2
1064
+ effect: ^3.16.8
1065
+
1066
+ '@effect/eslint-plugin@0.3.2':
1067
+ resolution: {integrity: sha512-c4Vs9t3r54A4Zpl+wo8+PGzZz3JWYsip41H+UrebRLjQ2Hk/ap63IeCgN/HWcYtxtyhRopjp7gW9nOQ2Snbl+g==}
1068
+
1069
+ '@effect/experimental@0.49.1':
1070
+ resolution: {integrity: sha512-puU0tZR+vEQ8RwdBXkMXVGlV5WG4tyVQA6J5LCJJoDnHDzNmEKsEjcjrD6YKmt/MNr9Jdm0H5LkkEfRYTiCL2g==}
1071
+ peerDependencies:
1072
+ '@effect/platform': ^0.85.1
1073
+ effect: ^3.16.8
1074
+ ioredis: ^5
1075
+ lmdb: ^3
1076
+ peerDependenciesMeta:
1077
+ ioredis:
1078
+ optional: true
1079
+ lmdb:
1080
+ optional: true
1081
+
1082
+ '@effect/platform-bun@0.69.16':
1083
+ resolution: {integrity: sha512-5Mocp+ZfCZ4xw1kI5OmoTAzLKtHht8NisEwD66rc8wium+2elFxFsuiM2kGM3TYz9jC3vwkEXf1SXgecBLWz4A==}
1084
+ peerDependencies:
1085
+ '@effect/cluster': ^0.38.16
1086
+ '@effect/platform': ^0.84.11
1087
+ '@effect/rpc': ^0.61.15
1088
+ '@effect/sql': ^0.37.12
1089
+ effect: ^3.16.7
1090
+
1091
+ '@effect/platform-node-shared@0.39.16':
1092
+ resolution: {integrity: sha512-aJ7jVm9V+SEeNumRmHb+TxD0C38uv/1LLfBHB2Qg+xb5UjnZhak8SzwolAgSKkMNDFpAAdF2AlxZ1tO/HfhCiw==}
1093
+ peerDependencies:
1094
+ '@effect/cluster': ^0.38.16
1095
+ '@effect/platform': ^0.84.11
1096
+ '@effect/rpc': ^0.61.15
1097
+ '@effect/sql': ^0.37.12
1098
+ effect: ^3.16.7
1099
+
1100
+ '@effect/platform-node-shared@0.40.2':
1101
+ resolution: {integrity: sha512-f9FbZN1pTMlR4bTwlR/mER9Qqd1MwMdryn3cz5/lapmXvgrRxQ+vgGS15d286mZeoc6aHtXGEr0GgoPNDFscKw==}
1102
+ peerDependencies:
1103
+ '@effect/cluster': ^0.39.2
1104
+ '@effect/platform': ^0.85.1
1105
+ '@effect/rpc': ^0.62.2
1106
+ '@effect/sql': ^0.38.1
1107
+ effect: ^3.16.8
1108
+
1109
+ '@effect/platform-node@0.86.2':
1110
+ resolution: {integrity: sha512-EkmmRnH9m2ya+a4Yf7OTXNCkF1YO6w8yIfd6DwNfbFCsCBDHHcat5HgJpjPvsAWtbV9ZBaF0vfFXbbKfJx5Jfg==}
1111
+ peerDependencies:
1112
+ '@effect/cluster': ^0.39.2
1113
+ '@effect/platform': ^0.85.1
1114
+ '@effect/rpc': ^0.62.2
1115
+ '@effect/sql': ^0.38.1
1116
+ effect: ^3.16.8
1117
+
1118
+ '@effect/platform@0.84.11':
1119
+ resolution: {integrity: sha512-u3eURhaF38e8jqq/JC2NW9EDHUFVDETD/JLEFtFi7N6RnAUF90qaC8sRcoK5xe8UAo3/fJDQ+sEfDqYonUa30w==}
1120
+ peerDependencies:
1121
+ effect: ^3.16.7
1122
+
1123
+ '@effect/printer-ansi@0.44.8':
1124
+ resolution: {integrity: sha512-HFatTgDyPgXc0Kbw2BH0nUht0ViAPukggIHuxGDm1EN0G7uKX9qXHLkFaQ7HGhotNOuf2hC6AXaKkzWOhxWp1A==}
1125
+ peerDependencies:
1126
+ '@effect/typeclass': ^0.35.8
1127
+ effect: ^3.16.8
1128
+
1129
+ '@effect/printer@0.44.8':
1130
+ resolution: {integrity: sha512-dWJCAi/04W5VIfo0C9u9M6gPwH2Ki+NHDqcUi0qfghoGyG9wmA6bhoq7RAvzrVSL+59tuhsKTV9y4A5dYCVyLw==}
1131
+ peerDependencies:
1132
+ '@effect/typeclass': ^0.35.8
1133
+ effect: ^3.16.8
1134
+
1135
+ '@effect/rpc@0.62.2':
1136
+ resolution: {integrity: sha512-m9Vit6U0hZ/Yt/yKdz5fBoHI7cY4qFJdidYZTVqzAo5tctKQtfJFKjAn4Oq0TWVfbTC7JrCK0GM51j5iQuI33Q==}
1137
+ peerDependencies:
1138
+ '@effect/platform': ^0.85.1
1139
+ effect: ^3.16.8
1140
+
1141
+ '@effect/sql@0.38.1':
1142
+ resolution: {integrity: sha512-oS5s8j8C1W7rugZeDpwfRjrjfRaqUqhO+wtL1yRgXqE0px7fVI3y2Am5f6aq63cR9UMKOwFc5NzEl3Af9uYlSw==}
1143
+ peerDependencies:
1144
+ '@effect/experimental': ^0.49.1
1145
+ '@effect/platform': ^0.85.1
1146
+ effect: ^3.16.8
1147
+
1148
+ '@effect/typeclass@0.35.8':
1149
+ resolution: {integrity: sha512-hDrILuHlFEtiPSADMX9YKicAa7tSDMqJPEMfBdUoE27cUHLg7qnr5EykLQzvBKPhlHAs9DHb5w/fp9WMV6WUpQ==}
1150
+ peerDependencies:
1151
+ effect: ^3.16.8
1152
+
1153
+ '@effect/vitest@0.23.8':
1154
+ resolution: {integrity: sha512-yaAfl+qHb0jK38rl3HSd4cjmo4xcQQDKW/bCAhhi9zDlbIDzH+gsOHz094KoQ/kAlp0wOTgjquSI21FV4w9YXg==}
1155
+ peerDependencies:
1156
+ effect: ^3.16.8
1157
+ vitest: ^3.0.0
1158
+
1159
+ '@effect/workflow@0.2.2':
1160
+ resolution: {integrity: sha512-fAXH0S3roA1LUFItlXmHZPaL57ZWxySf4QveidOoZuB+1rXVKk79OX++Y1G+l7Omugb7JzsyL1JCt5qo+Detzg==}
1161
+ peerDependencies:
1162
+ '@effect/platform': ^0.85.1
1163
+ '@effect/rpc': ^0.62.2
1164
+ effect: ^3.16.8
1165
+
1166
'@emnapi/runtime@1.4.3':
1167
resolution: {integrity: sha512-pBPWdu6MLKROBX05wSNKcNb++m5Er+KQ9QkB+WVM+pW2Kx9hoSrVTnu3BdkI5eBLZoKu/J6mW/B6i6bJB2ytXQ==}
1168
@@ -1455,6 +1674,36 @@ packages:
1674
resolution: {integrity: sha512-KG1CZhZfWg+u8pxeM/mByJDScJSrjjxLc8fwQqbsS8xCjBmQfMNEBTotYdNanKekepnfRI85GtgQlctLFpcYPw==}
1675
engines: {node: '>=18'}
1676
1677
+ '@msgpackr-extract/msgpackr-extract-darwin-arm64@3.0.3':
1678
+ resolution: {integrity: sha512-QZHtlVgbAdy2zAqNA9Gu1UpIuI8Xvsd1v8ic6B2pZmeFnFcMWiPLfWXh7TVw4eGEZ/C9TH281KwhVoeQUKbyjw==}
1679
+ cpu: [arm64]
1680
+ os: [darwin]
1681
+
1682
+ '@msgpackr-extract/msgpackr-extract-darwin-x64@3.0.3':
1683
+ resolution: {integrity: sha512-mdzd3AVzYKuUmiWOQ8GNhl64/IoFGol569zNRdkLReh6LRLHOXxU4U8eq0JwaD8iFHdVGqSy4IjFL4reoWCDFw==}
1684
+ cpu: [x64]
1685
+ os: [darwin]
1686
+
1687
+ '@msgpackr-extract/msgpackr-extract-linux-arm64@3.0.3':
1688
+ resolution: {integrity: sha512-YxQL+ax0XqBJDZiKimS2XQaf+2wDGVa1enVRGzEvLLVFeqa5kx2bWbtcSXgsxjQB7nRqqIGFIcLteF/sHeVtQg==}
1689
+ cpu: [arm64]
1690
+ os: [linux]
1691
+
1692
+ '@msgpackr-extract/msgpackr-extract-linux-arm@3.0.3':
1693
+ resolution: {integrity: sha512-fg0uy/dG/nZEXfYilKoRe7yALaNmHoYeIoJuJ7KJ+YyU2bvY8vPv27f7UKhGRpY6euFYqEVhxCFZgAUNQBM3nw==}
1694
+ cpu: [arm]
1695
+ os: [linux]
1696
+
1697
+ '@msgpackr-extract/msgpackr-extract-linux-x64@3.0.3':
1698
+ resolution: {integrity: sha512-cvwNfbP07pKUfq1uH+S6KJ7dT9K8WOE4ZiAcsrSes+UY55E/0jLYc+vq+DO7jlmqRb5zAggExKm0H7O/CBaesg==}
1699
+ cpu: [x64]
1700
+ os: [linux]
1701
+
1702
+ '@msgpackr-extract/msgpackr-extract-win32-x64@3.0.3':
1703
+ resolution: {integrity: sha512-x0fWaQtYp4E6sktbsdAqnehxDgEc/VwM7uLsRCYWaiGu0ykYdZPiS8zCWdnjHwyiumousxfBm4SO31eXqwEZhQ==}
1704
+ cpu: [x64]
1705
+ os: [win32]
1706
+
1707
'@next/env@15.3.3':
1708
resolution: {integrity: sha512-OdiMrzCl2Xi0VTjiQQUK0Xh7bJHnOuET2s+3V+Y40WJBAXrJeGA3f+I8MZJ/YQ3mVGi5XGR1L66oFlgqXhQ4Vw==}
1709
@@ -1996,6 +2245,88 @@ packages:
2245
peerDependencies:
2246
'@opentelemetry/api': ^1.1.0
2247
2248
+ '@parcel/watcher-android-arm64@2.5.1':
2249
+ resolution: {integrity: sha512-KF8+j9nNbUN8vzOFDpRMsaKBHZ/mcjEjMToVMJOhTozkDonQFFrRcfdLWn6yWKCmJKmdVxSgHiYvTCef4/qcBA==}
2250
+ engines: {node: '>= 10.0.0'}
2251
+ cpu: [arm64]
2252
+ os: [android]
2253
+
2254
+ '@parcel/watcher-darwin-arm64@2.5.1':
2255
+ resolution: {integrity: sha512-eAzPv5osDmZyBhou8PoF4i6RQXAfeKL9tjb3QzYuccXFMQU0ruIc/POh30ePnaOyD1UXdlKguHBmsTs53tVoPw==}
2256
+ engines: {node: '>= 10.0.0'}
2257
+ cpu: [arm64]
2258
+ os: [darwin]
2259
+
2260
+ '@parcel/watcher-darwin-x64@2.5.1':
2261
+ resolution: {integrity: sha512-1ZXDthrnNmwv10A0/3AJNZ9JGlzrF82i3gNQcWOzd7nJ8aj+ILyW1MTxVk35Db0u91oD5Nlk9MBiujMlwmeXZg==}
2262
+ engines: {node: '>= 10.0.0'}
2263
+ cpu: [x64]
2264
+ os: [darwin]
2265
+
2266
+ '@parcel/watcher-freebsd-x64@2.5.1':
2267
+ resolution: {integrity: sha512-SI4eljM7Flp9yPuKi8W0ird8TI/JK6CSxju3NojVI6BjHsTyK7zxA9urjVjEKJ5MBYC+bLmMcbAWlZ+rFkLpJQ==}
2268
+ engines: {node: '>= 10.0.0'}
2269
+ cpu: [x64]
2270
+ os: [freebsd]
2271
+
2272
+ '@parcel/watcher-linux-arm-glibc@2.5.1':
2273
+ resolution: {integrity: sha512-RCdZlEyTs8geyBkkcnPWvtXLY44BCeZKmGYRtSgtwwnHR4dxfHRG3gR99XdMEdQ7KeiDdasJwwvNSF5jKtDwdA==}
2274
+ engines: {node: '>= 10.0.0'}
2275
+ cpu: [arm]
2276
+ os: [linux]
2277
+
2278
+ '@parcel/watcher-linux-arm-musl@2.5.1':
2279
+ resolution: {integrity: sha512-6E+m/Mm1t1yhB8X412stiKFG3XykmgdIOqhjWj+VL8oHkKABfu/gjFj8DvLrYVHSBNC+/u5PeNrujiSQ1zwd1Q==}
2280
+ engines: {node: '>= 10.0.0'}
2281
+ cpu: [arm]
2282
+ os: [linux]
2283
+
2284
+ '@parcel/watcher-linux-arm64-glibc@2.5.1':
2285
+ resolution: {integrity: sha512-LrGp+f02yU3BN9A+DGuY3v3bmnFUggAITBGriZHUREfNEzZh/GO06FF5u2kx8x+GBEUYfyTGamol4j3m9ANe8w==}
2286
+ engines: {node: '>= 10.0.0'}
2287
+ cpu: [arm64]
2288
+ os: [linux]
2289
+
2290
+ '@parcel/watcher-linux-arm64-musl@2.5.1':
2291
+ resolution: {integrity: sha512-cFOjABi92pMYRXS7AcQv9/M1YuKRw8SZniCDw0ssQb/noPkRzA+HBDkwmyOJYp5wXcsTrhxO0zq1U11cK9jsFg==}
2292
+ engines: {node: '>= 10.0.0'}
2293
+ cpu: [arm64]
2294
+ os: [linux]
2295
+
2296
+ '@parcel/watcher-linux-x64-glibc@2.5.1':
2297
+ resolution: {integrity: sha512-GcESn8NZySmfwlTsIur+49yDqSny2IhPeZfXunQi48DMugKeZ7uy1FX83pO0X22sHntJ4Ub+9k34XQCX+oHt2A==}
2298
+ engines: {node: '>= 10.0.0'}
2299
+ cpu: [x64]
2300
+ os: [linux]
2301
+
2302
+ '@parcel/watcher-linux-x64-musl@2.5.1':
2303
+ resolution: {integrity: sha512-n0E2EQbatQ3bXhcH2D1XIAANAcTZkQICBPVaxMeaCVBtOpBZpWJuf7LwyWPSBDITb7In8mqQgJ7gH8CILCURXg==}
2304
+ engines: {node: '>= 10.0.0'}
2305
+ cpu: [x64]
2306
+ os: [linux]
2307
+
2308
+ '@parcel/watcher-win32-arm64@2.5.1':
2309
+ resolution: {integrity: sha512-RFzklRvmc3PkjKjry3hLF9wD7ppR4AKcWNzH7kXR7GUe0Igb3Nz8fyPwtZCSquGrhU5HhUNDr/mKBqj7tqA2Vw==}
2310
+ engines: {node: '>= 10.0.0'}
2311
+ cpu: [arm64]
2312
+ os: [win32]
2313
+
2314
+ '@parcel/watcher-win32-ia32@2.5.1':
2315
+ resolution: {integrity: sha512-c2KkcVN+NJmuA7CGlaGD1qJh1cLfDnQsHjE89E60vUEMlqduHGCdCLJCID5geFVM0dOtA3ZiIO8BoEQmzQVfpQ==}
2316
+ engines: {node: '>= 10.0.0'}
2317
+ cpu: [ia32]
2318
+ os: [win32]
2319
+
2320
+ '@parcel/watcher-win32-x64@2.5.1':
2321
+ resolution: {integrity: sha512-9lHBdJITeNR++EvSQVUcaZoWupyHfXe1jZvGZ06O/5MflPcuPLtEphScIBL+AiCWBO46tDSHzWyD0uDmmZqsgA==}
2322
+ engines: {node: '>= 10.0.0'}
2323
+ cpu: [x64]
2324
+ os: [win32]
2325
+
2326
+ '@parcel/watcher@2.5.1':
2327
+ resolution: {integrity: sha512-dfUnCxiN9H4ap84DvD2ubjw+3vUNpstxa0TneY/Paat8a3R4uQZDLSvWjmznAY/DoahqTHl9V46HF/Zs3F29pg==}
2328
+ engines: {node: '>= 10.0.0'}
2329
+
2330
'@pkgjs/parseargs@0.11.0':
2331
resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==}
2332
engines: {node: '>=14'}
@@ -2367,6 +2698,9 @@ packages:
2698
resolution: {integrity: sha512-4QvC49HTteI1gfemu0I1syWovJgPvGn7CVUoN9ZFkdvr/cCFkrEL7qNCdx/2eICqDWEGnnr68oMdSIPCLAriSQ==}
2699
engines: {node: '>=18.0.0'}
2700
2701
+ '@standard-schema/spec@1.0.0':
2702
+ resolution: {integrity: sha512-m2bOd0f2RT9k8QJx1JN85cZYyH1RqFBdlwtkSlf4tBDYLCiiZnv1fIIwacK6cqwXavOydf0NPToMQgpKq+dVlA==}
2703
+
2704
'@swc/counter@0.1.3':
2705
resolution: {integrity: sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==}
2706
@@ -2376,6 +2710,9 @@ packages:
2710
'@types/aws-lambda@8.10.147':
2711
resolution: {integrity: sha512-nD0Z9fNIZcxYX5Mai2CTmFD7wX7UldCkW2ezCF8D1T5hdiLsnTWDGRpfRYntU6VjTdLQjOvyszru7I1c1oCQew==}
2712
2713
+ '@types/babel__helper-validator-identifier@7.15.2':
2714
+ resolution: {integrity: sha512-l3dkwCt890NFhMwPKXbxsWXC0Por0/+KaFIiQP1j38/vWSH2P3Tn6m+IuJHkx2SBI3VLFqincFe9JtBk2NFHOw==}
2715
+
2716
'@types/bun@1.2.16':
2717
resolution: {integrity: sha512-1aCZJ/6nSiViw339RsaNhkNoEloLaPzZhxMOYEa7OzRzO41IGg5n/7I43/ZIAW/c+Q6cT12Vf7fOZOoVIzb5BQ==}
2718
@@ -2550,6 +2887,9 @@ packages:
2887
'@vitest/expect@3.2.3':
2888
resolution: {integrity: sha512-W2RH2TPWVHA1o7UmaFKISPvdicFJH+mjykctJFoAkUw+SPTJTGjUNdKscFBrqM7IPnCVu6zihtKYa7TkZS1dkQ==}
2889
2890
+ '@vitest/expect@3.2.4':
2891
+ resolution: {integrity: sha512-Io0yyORnB6sikFlt8QW5K7slY4OjqNX9jmJQ02QDda8lyM6B5oNgVWoSoKPac8/kgnCUzuHQKrSLtu/uOqqrig==}
2892
+
2893
'@vitest/mocker@3.2.3':
2894
resolution: {integrity: sha512-cP6fIun+Zx8he4rbWvi+Oya6goKQDZK+Yq4hhlggwQBbrlOQ4qtZ+G4nxB6ZnzI9lyIb+JnvyiJnPC2AGbKSPA==}
2895
peerDependencies:
@@ -2561,18 +2901,41 @@ packages:
2901
vite:
2902
optional: true
2903
2904
+ '@vitest/mocker@3.2.4':
2905
+ resolution: {integrity: sha512-46ryTE9RZO/rfDd7pEqFl7etuyzekzEhUbTW3BvmeO/BcCMEgq59BKhek3dXDWgAj4oMK6OZi+vRr1wPW6qjEQ==}
2906
+ peerDependencies:
2907
+ msw: ^2.4.9
2908
+ vite: ^5.0.0 || ^6.0.0 || ^7.0.0-0
2909
+ peerDependenciesMeta:
2910
+ msw:
2911
+ optional: true
2912
+ vite:
2913
+ optional: true
2914
+
2915
'@vitest/pretty-format@3.2.3':
2916
resolution: {integrity: sha512-yFglXGkr9hW/yEXngO+IKMhP0jxyFw2/qys/CK4fFUZnSltD+MU7dVYGrH8rvPcK/O6feXQA+EU33gjaBBbAng==}
2917
2918
+ '@vitest/pretty-format@3.2.4':
2919
+ resolution: {integrity: sha512-IVNZik8IVRJRTr9fxlitMKeJeXFFFN0JaB9PHPGQ8NKQbGpfjlTx9zO4RefN8gp7eqjNy8nyK3NZmBzOPeIxtA==}
2920
+
2921
'@vitest/runner@3.2.3':
2922
resolution: {integrity: sha512-83HWYisT3IpMaU9LN+VN+/nLHVBCSIUKJzGxC5RWUOsK1h3USg7ojL+UXQR3b4o4UBIWCYdD2fxuzM7PQQ1u8w==}
2923
2924
+ '@vitest/runner@3.2.4':
2925
+ resolution: {integrity: sha512-oukfKT9Mk41LreEW09vt45f8wx7DordoWUZMYdY/cyAk7w5TWkTRCNZYF7sX7n2wB7jyGAl74OxgwhPgKaqDMQ==}
2926
+
2927
'@vitest/snapshot@3.2.3':
2928
resolution: {integrity: sha512-9gIVWx2+tysDqUmmM1L0hwadyumqssOL1r8KJipwLx5JVYyxvVRfxvMq7DaWbZZsCqZnu/dZedaZQh4iYTtneA==}
2929
2930
+ '@vitest/snapshot@3.2.4':
2931
+ resolution: {integrity: sha512-dEYtS7qQP2CjU27QBC5oUOxLE/v5eLkGqPE0ZKEIDGMs4vKWe7IjgLOeauHsR0D5YuuycGRO5oSRXnwnmA78fQ==}
2932
+
2933
'@vitest/spy@3.2.3':
2934
resolution: {integrity: sha512-JHu9Wl+7bf6FEejTCREy+DmgWe+rQKbK+y32C/k5f4TBIAlijhJbRBIRIOCEpVevgRsCQR2iHRUH2/qKVM/plw==}
2935
2936
+ '@vitest/spy@3.2.4':
2937
+ resolution: {integrity: sha512-vAfasCOe6AIK70iP5UD11Ac4siNUNJ9i/9PZ3NKx07sG6sUxeag1LWdNrMWeKKYBLlzuK+Gn65Yd5nyL6ds+nw==}
2938
+
2939
'@vitest/ui@3.2.3':
2940
resolution: {integrity: sha512-9aR2tY/WT7GRHGEH/9sSIipJqeA21Eh3C6xmiOVmfyBCFmezUSUFLalpaSmRHlRzWCKQU10yz3AHhKuYcdnZGQ==}
2941
peerDependencies:
@@ -2581,6 +2944,9 @@ packages:
2944
'@vitest/utils@3.2.3':
2945
resolution: {integrity: sha512-4zFBCU5Pf+4Z6v+rwnZ1HU1yzOKKvDkMXZrymE2PBlbjKJRlrOxbvpfPSvJTGRIwGoahaOGvp+kbCoxifhzJ1Q==}
2946
2947
+ '@vitest/utils@3.2.4':
2948
+ resolution: {integrity: sha512-fB2V0JFrQSMsCo9HiSq3Ezpdv4iYaXRG1Sx8edX3MwxfyNn83mKiGzOcH+Fkxt4MHxr3y42fQi1oeAInqgX2QA==}
2949
+
2950
abort-controller@3.0.0:
2951
resolution: {integrity: sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==}
2952
engines: {node: '>=6.5'}
@@ -2680,6 +3046,9 @@ packages:
3046
array-flatten@1.1.1:
3047
resolution: {integrity: sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==}
3048
3049
+ array-timsort@1.0.3:
3050
+ resolution: {integrity: sha512-/+3GRL7dDAGEfM6TseQk/U+mi18TU2Ms9I3UlLdUMhz2hbvGNTKdj9xniwXfUqgYhHxRx0+8UnKkvlNwVU+cWQ==}
3051
+
3052
array-union@2.1.0:
3053
resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==}
3054
engines: {node: '>=8'}
@@ -2883,6 +3252,10 @@ packages:
3252
resolution: {integrity: sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==}
3253
engines: {node: '>= 6'}
3254
3255
+ comment-json@4.2.5:
3256
+ resolution: {integrity: sha512-bKw/r35jR3HGt5PEPm1ljsQQGyCrR8sFGNiN5L+ykDHdpO8Smxkrkla9Yi6NkQyUrb8V54PGhfMs6NrIwtxtdw==}
3257
+ engines: {node: '>= 6'}
3258
+
3259
composio-core@0.5.39:
3260
resolution: {integrity: sha512-7BeSFlfRzr1cbIfGYJW4jQ3BHwaObOaFKiRJIFuWOmvOrTABl1hbxGkWPA3C+uFw9CFXbZhrLWNyD7lhYy2Scg==}
3261
hasBin: true
@@ -2939,6 +3312,13 @@ packages:
3312
resolution: {integrity: sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==}
3313
engines: {node: '>= 0.6'}
3314
3315
+ copy-anything@3.0.5:
3316
+ resolution: {integrity: sha512-yCEafptTtb4bk7GLEQoM8KVJpxAfdBJYaXyzQEgQQQgYrZiDp8SJmGKlYza6CYjEDNstAdNdKA3UuoULlEbS6w==}
3317
+ engines: {node: '>=12.13'}
3318
+
3319
+ core-util-is@1.0.3:
3320
+ resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==}
3321
+
3322
cors@2.8.5:
3323
resolution: {integrity: sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==}
3324
engines: {node: '>= 0.10'}
@@ -2947,6 +3327,10 @@ packages:
3327
resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==}
3328
engines: {node: '>= 8'}
3329
3330
+ crypto-random-string@4.0.0:
3331
+ resolution: {integrity: sha512-x8dy3RnvYdlUcPOjkEHqozhiwzKNSq7GcPuXFbnyMOCHxX8V3OgIg/pYuabl2sbUPfIJaeAQB7PMOK8DFIdoRA==}
3332
+ engines: {node: '>=12'}
3333
+
3334
cssesc@3.0.0:
3335
resolution: {integrity: sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==}
3336
engines: {node: '>=4'}
@@ -3013,6 +3397,11 @@ packages:
3397
resolution: {integrity: sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA==}
3398
engines: {node: '>=8'}
3399
3400
+ detect-libc@1.0.3:
3401
+ resolution: {integrity: sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg==}
3402
+ engines: {node: '>=0.10'}
3403
+ hasBin: true
3404
+
3405
detect-libc@2.0.4:
3406
resolution: {integrity: sha512-3UDv+G9CsCKO1WKMGw9fwq/SWJYbI0c5Y7LU1AXYoDdbhE2AHQ6N6Nb34sG8Fj7T5APy8qXDCKuuIHd1BR0tVA==}
3407
engines: {node: '>=8'}
@@ -3047,6 +3436,20 @@ packages:
3436
ee-first@1.1.1:
3437
resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==}
3438
3439
+ effect-errors@1.10.11:
3440
+ resolution: {integrity: sha512-lTktjnqeHfXSGQuhHm4jGWdZFfiWVZQP+szeEOuEmGEa2n4tNAu0FGO3LgS6Vp9nOatINYE3u65dFf28TtxxkQ==}
3441
+ engines: {node: '>=20.x'}
3442
+ peerDependencies:
3443
+ '@effect/cluster': 0.x
3444
+ '@effect/platform': 0.x
3445
+ '@effect/platform-node': 0.x
3446
+ '@effect/rpc': 0.x
3447
+ '@effect/sql': 0.x
3448
+ effect: 3.x
3449
+
3450
+ effect@3.16.8:
3451
+ resolution: {integrity: sha512-E4U0MZFBun99myxOogy9ZZ1c3IYR47L/A5GqCP9Lp+6ORag0YLmGHOrYxQ3agN1FOMTrElgtJmciicwnHdE+Ug==}
3452
+
3453
emoji-regex@10.4.0:
3454
resolution: {integrity: sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw==}
3455
@@ -3230,12 +3633,19 @@ packages:
3633
resolution: {integrity: sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==}
3634
engines: {node: '>=4'}
3635
3636
+ fast-check@3.23.2:
3637
+ resolution: {integrity: sha512-h5+1OzzfCC3Ef7VbtKdcv7zsstUQwUDlYpUTvjeUsJAssPgLn7QzbboPtL5ro04Mq0rPOsMzl7q5hIbRs2wD1A==}
3638
+ engines: {node: '>=8.0.0'}
3639
+
3640
fast-copy@3.0.2:
3641
resolution: {integrity: sha512-dl0O9Vhju8IrcLndv2eU4ldt1ftXMqqfgN4H1cpmGV7P6jeB9FwpN9a2c8DPGE1Ys88rNUJVYDHq73CGAGOPfQ==}
3642
3643
fast-deep-equal@3.1.3:
3644
resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==}
3645
3646
+ fast-diff@1.3.0:
3647
+ resolution: {integrity: sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==}
3648
+
3649
fast-glob@3.3.3:
3650
resolution: {integrity: sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==}
3651
engines: {node: '>=8.6.0'}
@@ -3291,6 +3701,9 @@ packages:
3701
resolution: {integrity: sha512-/t88Ty3d5JWQbWYgaOGCCYfXRwV1+be02WqYYlL6h0lEiUAMPM8o8qKGO01YIkOHzka2up08wvgYD0mDiI+q3Q==}
3702
engines: {node: '>= 0.8'}
3703
3704
+ find-my-way-ts@0.1.5:
3705
+ resolution: {integrity: sha512-4GOTMrpGQVzsCH2ruUn2vmwzV/02zF4q+ybhCIrw/Rkt3L8KWcycdC6aJMctJzwN4fXD4SD5F/4B9Sksh5rE0A==}
3706
+
3707
find-up@4.1.0:
3708
resolution: {integrity: sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==}
3709
engines: {node: '>=8'}
@@ -3457,6 +3870,10 @@ packages:
3870
resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==}
3871
engines: {node: '>=8'}
3872
3873
+ has-own-prop@2.0.0:
3874
+ resolution: {integrity: sha512-Pq0h+hvsVm6dDEa8x82GnLSYHOzNDt7f0ddFa3FqcQlgzEiptPqL+XrOJNavjOzSYiYWIrgeVYYgGlLmnxwilQ==}
3875
+ engines: {node: '>=8'}
3876
+
3877
has-symbols@1.1.0:
3878
resolution: {integrity: sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==}
3879
engines: {node: '>= 0.4'}
@@ -3575,9 +3992,17 @@ packages:
3992
resolution: {integrity: sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==}
3993
engines: {node: '>=0.8.19'}
3994
3995
+ indent-string@5.0.0:
3996
+ resolution: {integrity: sha512-m6FAo/spmsW2Ab2fU35JTYwtOKa2yAwXSwgjSv1TJzh4Mh7mC3lzAOVLBprb72XsTrgkEIsl7YrFNAiDiRhIGg==}
3997
+ engines: {node: '>=12'}
3998
+
3999
inherits@2.0.4:
4000
resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==}
4001
4002
+ ini@4.1.3:
4003
+ resolution: {integrity: sha512-X7rqawQBvfdjS10YU1y1YVreA3SsLrW9dX2CewP2EbBJM4ypVNLDkO5y04gejPwKIY9lR+7r9gn3rFPt/kmWFg==}
4004
+ engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0}
4005
+
4006
inquirer@10.2.2:
4007
resolution: {integrity: sha512-tyao/4Vo36XnUItZ7DnUXX4f1jVao2mSrleV/5IPtW/XAEA26hRVsbc68nuTEKWcr5vMP/1mVoT2O7u8H4v1Vg==}
4008
engines: {node: '>=18'}
@@ -3645,6 +4070,10 @@ packages:
4070
resolution: {integrity: sha512-2AT6j+gXe/1ueqbW6fLZJiIw3F8iXGJtt0yDrZaBhAZEG1raiTxKWU+IPqMCzQAXOUCKdA4UDMgacKH25XG2Cw==}
4071
engines: {node: '>=4'}
4072
4073
+ is-what@4.1.16:
4074
+ resolution: {integrity: sha512-ZhMwEosbFJkA0YhFnNDgTM4ZxDRsS6HqTo7qsZM08fehyRYIYa0yHu5R6mgo1n/8MgaPBXiPimPD77baVFYg+A==}
4075
+ engines: {node: '>=12.13'}
4076
+
4077
is-windows@1.0.2:
4078
resolution: {integrity: sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==}
4079
engines: {node: '>=0.10.0'}
@@ -3865,6 +4294,9 @@ packages:
4294
loupe@3.1.3:
4295
resolution: {integrity: sha512-kkIp7XSkP78ZxJEsSxW3712C6teJVoeHHwgo9zJ380de7IYyJ2ISlxojcH2pC5OFLewESmnRi/+XCDIEEVyoug==}
4296
4297
+ loupe@3.1.4:
4298
+ resolution: {integrity: sha512-wJzkKwJrheKtknCOKNEtDK4iqg/MxmZheEMtSTYvnzRdEYaZzmgH976nenp8WdJRdx5Vc1X/9MO0Oszl6ezeXg==}
4299
+
4300
lru-cache@10.4.3:
4301
resolution: {integrity: sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==}
4302
@@ -3936,6 +4368,11 @@ packages:
4368
engines: {node: '>=4'}
4369
hasBin: true
4370
4371
+ mime@3.0.0:
4372
+ resolution: {integrity: sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==}
4373
+ engines: {node: '>=10.0.0'}
4374
+ hasBin: true
4375
+
4376
mimic-fn@4.0.0:
4377
resolution: {integrity: sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==}
4378
engines: {node: '>=12'}
@@ -3978,6 +4415,16 @@ packages:
4415
ms@2.1.3:
4416
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
4417
4418
+ msgpackr-extract@3.0.3:
4419
+ resolution: {integrity: sha512-P0efT1C9jIdVRefqjzOQ9Xml57zpOXnIuS+csaB4MdZbTdmGDLo8XhzBG1N7aO11gKDDkJvBLULeFTo46wwreA==}
4420
+ hasBin: true
4421
+
4422
+ msgpackr@1.11.4:
4423
+ resolution: {integrity: sha512-uaff7RG9VIC4jacFW9xzL3jc0iM32DNHe4jYVycBcjUePT/Klnfj7pqtWJt9khvDFizmjN2TlYniYmSS2LIaZg==}
4424
+
4425
+ multipasta@0.2.5:
4426
+ resolution: {integrity: sha512-c8eMDb1WwZcE02WVjHoOmUVk7fnKU/RmUcosHACglrWAuPQsEJv+E8430sXj6jNc1jHw0zrS16aCjQh4BcEb4A==}
4427
+
4428
mustache@4.2.0:
4429
resolution: {integrity: sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==}
4430
hasBin: true
@@ -4026,6 +4473,9 @@ packages:
4473
sass:
4474
optional: true
4475
4476
+ node-addon-api@7.1.1:
4477
+ resolution: {integrity: sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==}
4478
+
4479
node-domexception@1.0.0:
4480
resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==}
4481
engines: {node: '>=10.5.0'}
@@ -4040,6 +4490,10 @@ packages:
4490
encoding:
4491
optional: true
4492
4493
+ node-gyp-build-optional-packages@5.2.2:
4494
+ resolution: {integrity: sha512-s+w+rBWnpTMwSFbaE0UXsRlg7hU4FjekKU4eyAih5T8nJuNZT1nNsskXpxmeqSK9UzkBl6UgRlnKc8hz8IEqOw==}
4495
+ hasBin: true
4496
+
4497
normalize-path@3.0.0:
4498
resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==}
4499
engines: {node: '>=0.10.0'}
@@ -4371,6 +4825,10 @@ packages:
4825
resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==}
4826
engines: {node: '>= 0.8.0'}
4827
4828
+ prettier-linter-helpers@1.0.0:
4829
+ resolution: {integrity: sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==}
4830
+ engines: {node: '>=6.0.0'}
4831
+
4832
prettier@2.8.8:
4833
resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==}
4834
engines: {node: '>=10.13.0'}
@@ -4410,6 +4868,9 @@ packages:
4868
resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==}
4869
engines: {node: '>=6'}
4870
4871
+ pure-rand@6.1.0:
4872
+ resolution: {integrity: sha512-bVWawvoZoBYpp6yIoQtQXHZjmz35RSVHnUOTefl8Vcjr8snTPY1wnpSPMWekcFwbxI6gtmT7rSYPFvz71ldiOA==}
4873
+
4874
pusher-js@8.4.0:
4875
resolution: {integrity: sha512-wp3HqIIUc1GRyu1XrP6m2dgyE9MoCsXVsWNlohj0rjSkLf+a0jLvEyVubdg58oMk7bhjBWnFClgp8jfAa6Ak4Q==}
4876
@@ -4485,6 +4946,10 @@ packages:
4946
resolution: {integrity: sha512-57frrGM/OCTLqLOAh0mhVA9VBMHd+9U7Zb2THMGdBUoZVOtGbJzjxsYGDJ3A9AYYCP4hn6y1TVbaOfzWtm5GFg==}
4947
engines: {node: '>= 12.13.0'}
4948
4949
+ repeat-string@1.6.1:
4950
+ resolution: {integrity: sha512-PV0dzCYDNfRi1jCDbJzpW7jNNDRuCOG/jI5ctQcGKt/clZD+YcPS3yIlWuTJMmESC8aevCFmWJy5wjAFgNqN6w==}
4951
+ engines: {node: '>=0.10'}
4952
+
4953
require-directory@2.1.1:
4954
resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==}
4955
engines: {node: '>=0.10.0'}
@@ -4764,6 +5229,10 @@ packages:
5229
resolution: {integrity: sha512-MJd5FeT32XBMElZuzOT7mMM9dZlBHMTVHadPV3QC/pNKfuCyMj1a9Ub30GH+LbsT8ows+cT/P/K7ks9yp6z3KA==}
5230
hasBin: true
5231
5232
+ superjson@2.2.2:
5233
+ resolution: {integrity: sha512-5JRxVqC8I8NuOUjzBbvVJAKNM8qoVuH0O77h4WInc/qC2q5IreqKxYwgkga3PfA22OayK2ikceb/B26dztPl+Q==}
5234
+ engines: {node: '>=16'}
5235
+
5236
supports-color@7.2.0:
5237
resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==}
5238
engines: {node: '>=8'}
@@ -4782,6 +5251,14 @@ packages:
5251
engines: {node: '>=14.0.0'}
5252
hasBin: true
5253
5254
+ temp-dir@3.0.0:
5255
+ resolution: {integrity: sha512-nHc6S/bwIilKHNRgK/3jlhDoIHcp45YgyiwcAk46Tr0LfEqGBVpmiAyuiuxeVE44m3mXnEeVhaipLOEWmH+Njw==}
5256
+ engines: {node: '>=14.16'}
5257
+
5258
+ tempy@3.1.0:
5259
+ resolution: {integrity: sha512-7jDLIdD2Zp0bDe5r3D2qtkd1QOCacylBuL7oa4udvN6v2pqr4+LcCr67C8DR1zkpaZ8XosF5m1yQSabKAW6f2g==}
5260
+ engines: {node: '>=14.16'}
5261
+
5262
term-size@2.2.1:
5263
resolution: {integrity: sha512-wK0Ri4fOGjv/XPy8SBHZChl8CM7uMc5VML7SqiQ0zG7+J5Vr+RMQDoHa2CNT6KHUnTGIXH34UDMkPzAUyapBZg==}
5264
engines: {node: '>=8'}
@@ -4814,6 +5291,10 @@ packages:
5291
resolution: {integrity: sha512-7CotroY9a8DKsKprEy/a14aCCm8jYVmR7aFy4fpkZM8sdpNJbKkixuNjgM50yCmip2ezc8z4N7k3oe2+rfRJCQ==}
5292
engines: {node: ^18.0.0 || >=20.0.0}
5293
5294
+ tinypool@1.1.1:
5295
+ resolution: {integrity: sha512-Zba82s87IFq9A9XmjiX5uZA/ARWDrB03OHlq+Vw1fSdt0I+4/Kutwy8BP4Y/y/aORMo61FQ0vIb5j44vSo5Pkg==}
5296
+ engines: {node: ^18.0.0 || >=20.0.0}
5297
+
5298
tinyrainbow@2.0.0:
5299
resolution: {integrity: sha512-op4nsTR47R6p0vMUUoYl/a+ljLFVtlfaXkLQmqfLR1qHma1h/ysYk4hEXZ880bf2CYgTskvTa/e196Vd5dDQXw==}
5300
engines: {node: '>=14.0.0'}
@@ -4834,6 +5315,9 @@ packages:
5315
resolution: {integrity: sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==}
5316
engines: {node: '>=0.6'}
5317
5318
+ toml@3.0.0:
5319
+ resolution: {integrity: sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==}
5320
+
5321
totalist@3.0.1:
5322
resolution: {integrity: sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==}
5323
engines: {node: '>=6'}
@@ -4887,6 +5371,11 @@ packages:
5371
engines: {node: '>=18.0.0'}
5372
hasBin: true
5373
5374
+ tsx@4.20.3:
5375
+ resolution: {integrity: sha512-qjbnuR9Tr+FJOMBqJCW5ehvIo/buZq7vH7qD7JziU98h6l3qGy0a/yPFjwO+y0/T7GFpNgNAvEcPPVfyT8rrPQ==}
5376
+ engines: {node: '>=18.0.0'}
5377
+ hasBin: true
5378
+
5379
turbo-darwin-64@2.5.4:
5380
resolution: {integrity: sha512-ah6YnH2dErojhFooxEzmvsoZQTMImaruZhFPfMKPBq8sb+hALRdvBNLqfc8NWlZq576FkfRZ/MSi4SHvVFT9PQ==}
5381
cpu: [x64]
@@ -4932,6 +5421,14 @@ packages:
5421
resolution: {integrity: sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==}
5422
engines: {node: '>=10'}
5423
5424
+ type-fest@1.4.0:
5425
+ resolution: {integrity: sha512-yGSza74xk0UG8k+pLh5oeoYirvIiWo5t0/o3zHHAO2tRDiZcxWP7fywNlXhqb6/r6sWvwi+RsyQMWhVLe4BVuA==}
5426
+ engines: {node: '>=10'}
5427
+
5428
+ type-fest@2.19.0:
5429
+ resolution: {integrity: sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==}
5430
+ engines: {node: '>=12.20'}
5431
+
5432
type-is@1.6.18:
5433
resolution: {integrity: sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==}
5434
engines: {node: '>= 0.6'}
@@ -4985,6 +5482,14 @@ packages:
5482
undici-types@7.8.0:
5483
resolution: {integrity: sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw==}
5484
5485
+ undici@7.10.0:
5486
+ resolution: {integrity: sha512-u5otvFBOBZvmdjWLVW+5DAc9Nkq8f24g0O9oY7qw2JVIF1VocIFoyz9JFkuVOS2j41AufeO0xnlweJ2RLT8nGw==}
5487
+ engines: {node: '>=20.18.1'}
5488
+
5489
+ unique-string@3.0.0:
5490
+ resolution: {integrity: sha512-VGXBUVwxKMBUznyffQweQABPRRW1vHZAbadFZud4pLFAqRGvv/96vafgjWFqzourzr8YonlQiPgH0YCJfawoGQ==}
5491
+ engines: {node: '>=12'}
5492
+
5493
universalify@0.1.2:
5494
resolution: {integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==}
5495
engines: {node: '>= 4.0.0'}
@@ -5032,6 +5537,11 @@ packages:
5537
engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0}
5538
hasBin: true
5539
5540
+ vite-node@3.2.4:
5541
+ resolution: {integrity: sha512-EbKSKh+bh1E1IFxeO0pg1n4dvoOTt0UDiXMd/qn++r98+jPO1xtJilvXldeuQ8giIB5IkpjCgMleHMNEsGH6pg==}
5542
+ engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0}
5543
+ hasBin: true
5544
+
5545
vite@6.3.5:
5546
resolution: {integrity: sha512-cZn6NDFE7wdTpINgs++ZJ4N49W2vRp8LCKrn3Ob1kYNtOo21vfDoaV5GzBfLU4MovSAB8uNRm4jgzVQZ+mBzPQ==}
5547
engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0}
@@ -5100,6 +5610,34 @@ packages:
5610
jsdom:
5611
optional: true
5612
5613
+ vitest@3.2.4:
5614
+ resolution: {integrity: sha512-LUCP5ev3GURDysTWiP47wRRUpLKMOfPh+yKTx3kVIEiu5KOMeqzpnYNsKyOoVrULivR8tLcks4+lga33Whn90A==}
5615
+ engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0}
5616
+ hasBin: true
5617
+ peerDependencies:
5618
+ '@edge-runtime/vm': '*'
5619
+ '@types/debug': ^4.1.12
5620
+ '@types/node': ^18.0.0 || ^20.0.0 || >=22.0.0
5621
+ '@vitest/browser': 3.2.4
5622
+ '@vitest/ui': 3.2.4
5623
+ happy-dom: '*'
5624
+ jsdom: '*'
5625
+ peerDependenciesMeta:
5626
+ '@edge-runtime/vm':
5627
+ optional: true
5628
+ '@types/debug':
5629
+ optional: true
5630
+ '@types/node':
5631
+ optional: true
5632
+ '@vitest/browser':
5633
+ optional: true
5634
+ '@vitest/ui':
5635
+ optional: true
5636
+ happy-dom:
5637
+ optional: true
5638
+ jsdom:
5639
+ optional: true
5640
+
5641
web-streams-polyfill@4.0.0-beta.3:
5642
resolution: {integrity: sha512-QW95TCTaHmsYfHDybGMwO5IJIM93I/6vTRk+daHTWFPhwh+C8Cg7j7XyKrwrj8Ib6vYXe0ocYNrmzY4xAAN6ug==}
5643
engines: {node: '>= 14'}
@@ -5718,6 +6256,8 @@ snapshots:
6256
'@smithy/types': 4.3.1
6257
tslib: 2.8.1
6258
6259
+ '@babel/helper-validator-identifier@7.27.1': {}
6260
+
6261
'@babel/runtime@7.27.6': {}
6262
6263
'@cfworker/json-schema@4.1.1': {}
@@ -5871,6 +6411,8 @@ snapshots:
6411
'@anthropic-ai/sdk': 0.52.0
6412
'@composio/core': 0.1.22(ws@8.18.2)
6413
6414
+ '@composio/client@0.1.0-alpha.17': {}
6415
+
6416
'@composio/client@0.1.0-alpha.22': {}
6417
6418
'@composio/client@0.1.0-alpha.23': {}
@@ -5902,16 +6444,152 @@ snapshots:
6444
'@composio/core': 0.1.22(ws@8.18.2)
6445
ai: 4.3.16(react@18.3.1)(zod@3.25.62)
6446
5905
- '@emnapi/runtime@1.4.3':
5906
- dependencies:
5907
- tslib: 2.8.1
5908
- optional: true
6447
+ '@dprint/formatter@0.4.1': {}
6448
5910
- '@esbuild/aix-ppc64@0.25.5':
5911
- optional: true
6449
+ '@dprint/typescript@0.91.8': {}
6450
5913
- '@esbuild/android-arm64@0.25.5':
5914
- optional: true
6451
+ '@effect/cli@0.63.11(@effect/platform@0.84.11(effect@3.16.8))(@effect/printer-ansi@0.44.8(@effect/typeclass@0.35.8(effect@3.16.8))(effect@3.16.8))(@effect/printer@0.44.8(@effect/typeclass@0.35.8(effect@3.16.8))(effect@3.16.8))(effect@3.16.8)':
6452
+ dependencies:
6453
+ '@effect/platform': 0.84.11(effect@3.16.8)
6454
+ '@effect/printer': 0.44.8(@effect/typeclass@0.35.8(effect@3.16.8))(effect@3.16.8)
6455
+ '@effect/printer-ansi': 0.44.8(@effect/typeclass@0.35.8(effect@3.16.8))(effect@3.16.8)
6456
+ effect: 3.16.8
6457
+ ini: 4.1.3
6458
+ toml: 3.0.0
6459
+ yaml: 2.8.0
6460
+
6461
+ '@effect/cluster@0.39.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/sql@0.38.1(@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/workflow@0.2.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(effect@3.16.8))(effect@3.16.8)':
6462
+ dependencies:
6463
+ '@effect/platform': 0.84.11(effect@3.16.8)
6464
+ '@effect/rpc': 0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8)
6465
+ '@effect/sql': 0.38.1(@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8)
6466
+ '@effect/workflow': 0.2.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(effect@3.16.8)
6467
+ effect: 3.16.8
6468
+
6469
+ '@effect/eslint-plugin@0.3.2':
6470
+ dependencies:
6471
+ '@dprint/formatter': 0.4.1
6472
+ '@dprint/typescript': 0.91.8
6473
+ prettier-linter-helpers: 1.0.0
6474
+
6475
+ '@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8)':
6476
+ dependencies:
6477
+ '@effect/platform': 0.84.11(effect@3.16.8)
6478
+ effect: 3.16.8
6479
+ uuid: 11.1.0
6480
+
6481
+ '@effect/platform-bun@0.69.16(@effect/cluster@0.39.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/sql@0.38.1(@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/workflow@0.2.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/sql@0.38.1(@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(effect@3.16.8)':
6482
+ dependencies:
6483
+ '@effect/cluster': 0.39.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/sql@0.38.1(@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/workflow@0.2.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(effect@3.16.8))(effect@3.16.8)
6484
+ '@effect/platform': 0.84.11(effect@3.16.8)
6485
+ '@effect/platform-node-shared': 0.39.16(@effect/cluster@0.39.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/sql@0.38.1(@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/workflow@0.2.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/sql@0.38.1(@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(effect@3.16.8)
6486
+ '@effect/rpc': 0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8)
6487
+ '@effect/sql': 0.38.1(@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8)
6488
+ effect: 3.16.8
6489
+ multipasta: 0.2.5
6490
+ transitivePeerDependencies:
6491
+ - bufferutil
6492
+ - utf-8-validate
6493
+
6494
+ '@effect/platform-node-shared@0.39.16(@effect/cluster@0.39.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/sql@0.38.1(@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/workflow@0.2.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/sql@0.38.1(@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(effect@3.16.8)':
6495
+ dependencies:
6496
+ '@effect/cluster': 0.39.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/sql@0.38.1(@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/workflow@0.2.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(effect@3.16.8))(effect@3.16.8)
6497
+ '@effect/platform': 0.84.11(effect@3.16.8)
6498
+ '@effect/rpc': 0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8)
6499
+ '@effect/sql': 0.38.1(@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8)
6500
+ '@parcel/watcher': 2.5.1
6501
+ effect: 3.16.8
6502
+ multipasta: 0.2.5
6503
+ ws: 8.18.2
6504
+ transitivePeerDependencies:
6505
+ - bufferutil
6506
+ - utf-8-validate
6507
+
6508
+ '@effect/platform-node-shared@0.40.2(@effect/cluster@0.39.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/sql@0.38.1(@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/workflow@0.2.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/sql@0.38.1(@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(effect@3.16.8)':
6509
+ dependencies:
6510
+ '@effect/cluster': 0.39.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/sql@0.38.1(@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/workflow@0.2.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(effect@3.16.8))(effect@3.16.8)
6511
+ '@effect/platform': 0.84.11(effect@3.16.8)
6512
+ '@effect/rpc': 0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8)
6513
+ '@effect/sql': 0.38.1(@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8)
6514
+ '@parcel/watcher': 2.5.1
6515
+ effect: 3.16.8
6516
+ multipasta: 0.2.5
6517
+ ws: 8.18.2
6518
+ transitivePeerDependencies:
6519
+ - bufferutil
6520
+ - utf-8-validate
6521
+
6522
+ '@effect/platform-node@0.86.2(@effect/cluster@0.39.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/sql@0.38.1(@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/workflow@0.2.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/sql@0.38.1(@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(effect@3.16.8)':
6523
+ dependencies:
6524
+ '@effect/cluster': 0.39.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/sql@0.38.1(@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/workflow@0.2.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(effect@3.16.8))(effect@3.16.8)
6525
+ '@effect/platform': 0.84.11(effect@3.16.8)
6526
+ '@effect/platform-node-shared': 0.40.2(@effect/cluster@0.39.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/sql@0.38.1(@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/workflow@0.2.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/sql@0.38.1(@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(effect@3.16.8)
6527
+ '@effect/rpc': 0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8)
6528
+ '@effect/sql': 0.38.1(@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8)
6529
+ effect: 3.16.8
6530
+ mime: 3.0.0
6531
+ undici: 7.10.0
6532
+ ws: 8.18.2
6533
+ transitivePeerDependencies:
6534
+ - bufferutil
6535
+ - utf-8-validate
6536
+
6537
+ '@effect/platform@0.84.11(effect@3.16.8)':
6538
+ dependencies:
6539
+ effect: 3.16.8
6540
+ find-my-way-ts: 0.1.5
6541
+ msgpackr: 1.11.4
6542
+ multipasta: 0.2.5
6543
+
6544
+ '@effect/printer-ansi@0.44.8(@effect/typeclass@0.35.8(effect@3.16.8))(effect@3.16.8)':
6545
+ dependencies:
6546
+ '@effect/printer': 0.44.8(@effect/typeclass@0.35.8(effect@3.16.8))(effect@3.16.8)
6547
+ '@effect/typeclass': 0.35.8(effect@3.16.8)
6548
+ effect: 3.16.8
6549
+
6550
+ '@effect/printer@0.44.8(@effect/typeclass@0.35.8(effect@3.16.8))(effect@3.16.8)':
6551
+ dependencies:
6552
+ '@effect/typeclass': 0.35.8(effect@3.16.8)
6553
+ effect: 3.16.8
6554
+
6555
+ '@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8)':
6556
+ dependencies:
6557
+ '@effect/platform': 0.84.11(effect@3.16.8)
6558
+ effect: 3.16.8
6559
+
6560
+ '@effect/sql@0.38.1(@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8)':
6561
+ dependencies:
6562
+ '@effect/experimental': 0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8)
6563
+ '@effect/platform': 0.84.11(effect@3.16.8)
6564
+ '@opentelemetry/semantic-conventions': 1.34.0
6565
+ effect: 3.16.8
6566
+ uuid: 11.1.0
6567
+
6568
+ '@effect/typeclass@0.35.8(effect@3.16.8)':
6569
+ dependencies:
6570
+ effect: 3.16.8
6571
+
6572
+ '@effect/vitest@0.23.8(effect@3.16.8)(vitest@3.2.4(@types/node@24.0.3)(@vitest/ui@3.2.3(vitest@3.2.3))(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0))':
6573
+ dependencies:
6574
+ effect: 3.16.8
6575
+ vitest: 3.2.4(@types/node@24.0.3)(@vitest/ui@3.2.3(vitest@3.2.3))(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0)
6576
+
6577
+ '@effect/workflow@0.2.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(effect@3.16.8)':
6578
+ dependencies:
6579
+ '@effect/platform': 0.84.11(effect@3.16.8)
6580
+ '@effect/rpc': 0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8)
6581
+ effect: 3.16.8
6582
+
6583
+ '@emnapi/runtime@1.4.3':
6584
+ dependencies:
6585
+ tslib: 2.8.1
6586
+ optional: true
6587
+
6588
+ '@esbuild/aix-ppc64@0.25.5':
6589
+ optional: true
6590
+
6591
+ '@esbuild/android-arm64@0.25.5':
6592
+ optional: true
6593
6594
'@esbuild/android-arm@0.25.5':
6595
optional: true
@@ -6394,7 +7072,7 @@ snapshots:
7072
globby: 11.1.0
7073
read-yaml-file: 1.1.0
7074
6397
- '@mastra/core@0.10.5(openapi-types@12.1.3)(react@18.3.1)(zod@3.25.62)':
7075
+ '@mastra/core@0.10.5(effect@3.16.8)(openapi-types@12.1.3)(react@18.3.1)(zod@3.25.62)':
7076
dependencies:
7077
'@ai-sdk/provider': 1.1.3
7078
'@ai-sdk/provider-utils': 2.2.8(zod@3.25.62)
@@ -6419,7 +7097,7 @@ snapshots:
7097
date-fns: 3.6.0
7098
dotenv: 16.5.0
7099
hono: 4.7.11
6422
- hono-openapi: 0.4.8(hono@4.7.11)(openapi-types@12.1.3)(zod@3.25.62)
7100
+ hono-openapi: 0.4.8(effect@3.16.8)(hono@4.7.11)(openapi-types@12.1.3)(zod@3.25.62)
7101
json-schema: 0.4.0
7102
json-schema-to-zod: 2.6.1
7103
pino: 9.7.0
@@ -6470,6 +7148,24 @@ snapshots:
7148
transitivePeerDependencies:
7149
- supports-color
7150
7151
+ '@msgpackr-extract/msgpackr-extract-darwin-arm64@3.0.3':
7152
+ optional: true
7153
+
7154
+ '@msgpackr-extract/msgpackr-extract-darwin-x64@3.0.3':
7155
+ optional: true
7156
+
7157
+ '@msgpackr-extract/msgpackr-extract-linux-arm64@3.0.3':
7158
+ optional: true
7159
+
7160
+ '@msgpackr-extract/msgpackr-extract-linux-arm@3.0.3':
7161
+ optional: true
7162
+
7163
+ '@msgpackr-extract/msgpackr-extract-linux-x64@3.0.3':
7164
+ optional: true
7165
+
7166
+ '@msgpackr-extract/msgpackr-extract-win32-x64@3.0.3':
7167
+ optional: true
7168
+
7169
'@next/env@15.3.3': {}
7170
7171
'@next/swc-darwin-arm64@15.3.3':
@@ -7244,6 +7940,66 @@ snapshots:
7940
'@opentelemetry/api': 1.9.0
7941
'@opentelemetry/core': 2.0.1(@opentelemetry/api@1.9.0)
7942
7943
+ '@parcel/watcher-android-arm64@2.5.1':
7944
+ optional: true
7945
+
7946
+ '@parcel/watcher-darwin-arm64@2.5.1':
7947
+ optional: true
7948
+
7949
+ '@parcel/watcher-darwin-x64@2.5.1':
7950
+ optional: true
7951
+
7952
+ '@parcel/watcher-freebsd-x64@2.5.1':
7953
+ optional: true
7954
+
7955
+ '@parcel/watcher-linux-arm-glibc@2.5.1':
7956
+ optional: true
7957
+
7958
+ '@parcel/watcher-linux-arm-musl@2.5.1':
7959
+ optional: true
7960
+
7961
+ '@parcel/watcher-linux-arm64-glibc@2.5.1':
7962
+ optional: true
7963
+
7964
+ '@parcel/watcher-linux-arm64-musl@2.5.1':
7965
+ optional: true
7966
+
7967
+ '@parcel/watcher-linux-x64-glibc@2.5.1':
7968
+ optional: true
7969
+
7970
+ '@parcel/watcher-linux-x64-musl@2.5.1':
7971
+ optional: true
7972
+
7973
+ '@parcel/watcher-win32-arm64@2.5.1':
7974
+ optional: true
7975
+
7976
+ '@parcel/watcher-win32-ia32@2.5.1':
7977
+ optional: true
7978
+
7979
+ '@parcel/watcher-win32-x64@2.5.1':
7980
+ optional: true
7981
+
7982
+ '@parcel/watcher@2.5.1':
7983
+ dependencies:
7984
+ detect-libc: 1.0.3
7985
+ is-glob: 4.0.3
7986
+ micromatch: 4.0.8
7987
+ node-addon-api: 7.1.1
7988
+ optionalDependencies:
7989
+ '@parcel/watcher-android-arm64': 2.5.1
7990
+ '@parcel/watcher-darwin-arm64': 2.5.1
7991
+ '@parcel/watcher-darwin-x64': 2.5.1
7992
+ '@parcel/watcher-freebsd-x64': 2.5.1
7993
+ '@parcel/watcher-linux-arm-glibc': 2.5.1
7994
+ '@parcel/watcher-linux-arm-musl': 2.5.1
7995
+ '@parcel/watcher-linux-arm64-glibc': 2.5.1
7996
+ '@parcel/watcher-linux-arm64-musl': 2.5.1
7997
+ '@parcel/watcher-linux-x64-glibc': 2.5.1
7998
+ '@parcel/watcher-linux-x64-musl': 2.5.1
7999
+ '@parcel/watcher-win32-arm64': 2.5.1
8000
+ '@parcel/watcher-win32-ia32': 2.5.1
8001
+ '@parcel/watcher-win32-x64': 2.5.1
8002
+
8003
'@pkgjs/parseargs@0.11.0':
8004
optional: true
8005
@@ -7689,6 +8445,8 @@ snapshots:
8445
'@smithy/types': 4.3.1
8446
tslib: 2.8.1
8447
8448
+ '@standard-schema/spec@1.0.0': {}
8449
+
8450
'@swc/counter@0.1.3': {}
8451
8452
'@swc/helpers@0.5.15':
@@ -7697,6 +8455,8 @@ snapshots:
8455
8456
'@types/aws-lambda@8.10.147': {}
8457
8458
+ '@types/babel__helper-validator-identifier@7.15.2': {}
8459
+
8460
'@types/bun@1.2.16':
8461
dependencies:
8462
bun-types: 1.2.16
@@ -7920,13 +8680,21 @@ snapshots:
8680
chai: 5.2.0
8681
tinyrainbow: 2.0.0
8682
7923
- '@vitest/mocker@3.2.3(vite@6.3.5(@types/node@20.19.1)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0))':
8683
+ '@vitest/expect@3.2.4':
8684
+ dependencies:
8685
+ '@types/chai': 5.2.2
8686
+ '@vitest/spy': 3.2.4
8687
+ '@vitest/utils': 3.2.4
8688
+ chai: 5.2.0
8689
+ tinyrainbow: 2.0.0
8690
+
8691
+ '@vitest/mocker@3.2.3(vite@6.3.5(@types/node@20.19.1)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0))':
8692
dependencies:
8693
'@vitest/spy': 3.2.3
8694
estree-walker: 3.0.3
8695
magic-string: 0.30.17
8696
optionalDependencies:
7929
- vite: 6.3.5(@types/node@20.19.1)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0)
8697
+ vite: 6.3.5(@types/node@20.19.1)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0)
8698
8699
'@vitest/mocker@3.2.3(vite@6.3.5(@types/node@22.15.31)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0))':
8700
dependencies:
@@ -7944,26 +8712,62 @@ snapshots:
8712
optionalDependencies:
8713
vite: 6.3.5(@types/node@24.0.3)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0)
8714
8715
+ '@vitest/mocker@3.2.3(vite@6.3.5(@types/node@24.0.3)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0))':
8716
+ dependencies:
8717
+ '@vitest/spy': 3.2.3
8718
+ estree-walker: 3.0.3
8719
+ magic-string: 0.30.17
8720
+ optionalDependencies:
8721
+ vite: 6.3.5(@types/node@24.0.3)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0)
8722
+
8723
+ '@vitest/mocker@3.2.4(vite@6.3.5(@types/node@24.0.3)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0))':
8724
+ dependencies:
8725
+ '@vitest/spy': 3.2.4
8726
+ estree-walker: 3.0.3
8727
+ magic-string: 0.30.17
8728
+ optionalDependencies:
8729
+ vite: 6.3.5(@types/node@24.0.3)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0)
8730
+
8731
'@vitest/pretty-format@3.2.3':
8732
dependencies:
8733
tinyrainbow: 2.0.0
8734
8735
+ '@vitest/pretty-format@3.2.4':
8736
+ dependencies:
8737
+ tinyrainbow: 2.0.0
8738
+
8739
'@vitest/runner@3.2.3':
8740
dependencies:
8741
'@vitest/utils': 3.2.3
8742
pathe: 2.0.3
8743
strip-literal: 3.0.0
8744
8745
+ '@vitest/runner@3.2.4':
8746
+ dependencies:
8747
+ '@vitest/utils': 3.2.4
8748
+ pathe: 2.0.3
8749
+ strip-literal: 3.0.0
8750
+
8751
'@vitest/snapshot@3.2.3':
8752
dependencies:
8753
'@vitest/pretty-format': 3.2.3
8754
magic-string: 0.30.17
8755
pathe: 2.0.3
8756
8757
+ '@vitest/snapshot@3.2.4':
8758
+ dependencies:
8759
+ '@vitest/pretty-format': 3.2.4
8760
+ magic-string: 0.30.17
8761
+ pathe: 2.0.3
8762
+
8763
'@vitest/spy@3.2.3':
8764
dependencies:
8765
tinyspy: 4.0.3
8766
8767
+ '@vitest/spy@3.2.4':
8768
+ dependencies:
8769
+ tinyspy: 4.0.3
8770
+
8771
'@vitest/ui@3.2.3(vitest@3.2.3)':
8772
dependencies:
8773
'@vitest/utils': 3.2.3
@@ -7973,7 +8777,7 @@ snapshots:
8777
sirv: 3.0.1
8778
tinyglobby: 0.2.14
8779
tinyrainbow: 2.0.0
7976
- vitest: 3.2.3(@types/node@24.0.3)(@vitest/ui@3.2.3)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0)
8780
+ vitest: 3.2.3(@types/node@20.19.1)(@vitest/ui@3.2.3)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0)
8781
8782
'@vitest/utils@3.2.3':
8783
dependencies:
@@ -7981,6 +8785,12 @@ snapshots:
8785
loupe: 3.1.3
8786
tinyrainbow: 2.0.0
8787
8788
+ '@vitest/utils@3.2.4':
8789
+ dependencies:
8790
+ '@vitest/pretty-format': 3.2.4
8791
+ loupe: 3.1.4
8792
+ tinyrainbow: 2.0.0
8793
+
8794
abort-controller@3.0.0:
8795
dependencies:
8796
event-target-shim: 5.0.1
@@ -8069,6 +8879,8 @@ snapshots:
8879
8880
array-flatten@1.1.1: {}
8881
8882
+ array-timsort@1.0.3: {}
8883
+
8884
array-union@2.1.0: {}
8885
8886
assertion-error@2.0.1: {}
@@ -8298,6 +9110,14 @@ snapshots:
9110
9111
commander@4.1.1: {}
9112
9113
+ comment-json@4.2.5:
9114
+ dependencies:
9115
+ array-timsort: 1.0.3
9116
+ core-util-is: 1.0.3
9117
+ esprima: 4.0.1
9118
+ has-own-prop: 2.0.0
9119
+ repeat-string: 1.6.1
9120
+
9121
composio-core@0.5.39(@ai-sdk/openai@1.3.22(zod@3.25.62))(@cloudflare/workers-types@4.20250612.0)(@langchain/core@0.3.58(openai@5.3.0(ws@8.18.2)(zod@3.25.62)))(@langchain/openai@0.5.13(@langchain/core@0.3.58(openai@5.3.0(ws@8.18.2)(zod@3.25.62)))(ws@8.18.2))(ai@4.3.16(react@18.3.1)(zod@3.25.62))(langchain@0.3.28(@langchain/core@0.3.58(openai@5.3.0(ws@8.18.2)(zod@3.25.62)))(axios@1.10.0)(openai@5.3.0(ws@8.18.2)(zod@3.25.62))(ws@8.18.2))(openai@5.3.0(ws@8.18.2)(zod@3.25.62)):
9122
dependencies:
9123
'@ai-sdk/openai': 1.3.22(zod@3.25.62)
@@ -8356,6 +9176,12 @@ snapshots:
9176
9177
cookie@0.7.2: {}
9178
9179
+ copy-anything@3.0.5:
9180
+ dependencies:
9181
+ is-what: 4.1.16
9182
+
9183
+ core-util-is@1.0.3: {}
9184
+
9185
cors@2.8.5:
9186
dependencies:
9187
object-assign: 4.1.1
@@ -8367,6 +9193,10 @@ snapshots:
9193
shebang-command: 2.0.0
9194
which: 2.0.2
9195
9196
+ crypto-random-string@4.0.0:
9197
+ dependencies:
9198
+ type-fest: 1.4.0
9199
+
9200
cssesc@3.0.0: {}
9201
9202
csstype@3.1.3: {}
@@ -8401,6 +9231,8 @@ snapshots:
9231
9232
detect-indent@6.1.0: {}
9233
9234
+ detect-libc@1.0.3: {}
9235
+
9236
detect-libc@2.0.4:
9237
optional: true
9238
@@ -8430,6 +9262,23 @@ snapshots:
9262
9263
ee-first@1.1.1: {}
9264
9265
+ effect-errors@1.10.11(ff5edfb43a1891ed491370151a2c33b9):
9266
+ dependencies:
9267
+ '@effect/cluster': 0.39.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/sql@0.38.1(@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/workflow@0.2.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(effect@3.16.8))(effect@3.16.8)
9268
+ '@effect/platform': 0.84.11(effect@3.16.8)
9269
+ '@effect/platform-node': 0.86.2(@effect/cluster@0.39.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/sql@0.38.1(@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/workflow@0.2.2(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(@effect/rpc@0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/sql@0.38.1(@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(effect@3.16.8)
9270
+ '@effect/rpc': 0.62.2(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8)
9271
+ '@effect/sql': 0.38.1(@effect/experimental@0.49.1(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8))(@effect/platform@0.84.11(effect@3.16.8))(effect@3.16.8)
9272
+ comment-json: 4.2.5
9273
+ effect: 3.16.8
9274
+ picocolors: 1.1.1
9275
+ source-map-js: 1.2.1
9276
+
9277
+ effect@3.16.8:
9278
+ dependencies:
9279
+ '@standard-schema/spec': 1.0.0
9280
+ fast-check: 3.23.2
9281
+
9282
emoji-regex@10.4.0: {}
9283
9284
emoji-regex@8.0.0: {}
@@ -8697,10 +9546,16 @@ snapshots:
9546
iconv-lite: 0.4.24
9547
tmp: 0.0.33
9548
9549
+ fast-check@3.23.2:
9550
+ dependencies:
9551
+ pure-rand: 6.1.0
9552
+
9553
fast-copy@3.0.2: {}
9554
9555
fast-deep-equal@3.1.3: {}
9556
9557
+ fast-diff@1.3.0: {}
9558
+
9559
fast-glob@3.3.3:
9560
dependencies:
9561
'@nodelib/fs.stat': 2.0.5
@@ -8764,6 +9619,8 @@ snapshots:
9619
transitivePeerDependencies:
9620
- supports-color
9621
9622
+ find-my-way-ts@0.1.5: {}
9623
+
9624
find-up@4.1.0:
9625
dependencies:
9626
locate-path: 5.0.0
@@ -8953,6 +9810,8 @@ snapshots:
9810
9811
has-flag@4.0.0: {}
9812
9813
+ has-own-prop@2.0.0: {}
9814
+
9815
has-symbols@1.1.0: {}
9816
9817
has-tostringtag@1.0.2:
@@ -8965,11 +9824,12 @@ snapshots:
9824
9825
help-me@5.0.0: {}
9826
8968
- hono-openapi@0.4.8(hono@4.7.11)(openapi-types@12.1.3)(zod@3.25.62):
9827
+ hono-openapi@0.4.8(effect@3.16.8)(hono@4.7.11)(openapi-types@12.1.3)(zod@3.25.62):
9828
dependencies:
9829
json-schema-walker: 2.0.0
9830
openapi-types: 12.1.3
9831
optionalDependencies:
9832
+ effect: 3.16.8
9833
hono: 4.7.11
9834
zod: 3.25.62
9835
@@ -9028,8 +9888,12 @@ snapshots:
9888
9889
imurmurhash@0.1.4: {}
9890
9891
+ indent-string@5.0.0: {}
9892
+
9893
inherits@2.0.4: {}
9894
9895
+ ini@4.1.3: {}
9896
+
9897
inquirer@10.2.2:
9898
dependencies:
9899
'@inquirer/core': 9.2.1
@@ -9084,6 +9948,8 @@ snapshots:
9948
dependencies:
9949
better-path-resolve: 1.0.0
9950
9951
+ is-what@4.1.16: {}
9952
+
9953
is-windows@1.0.2: {}
9954
9955
is-wsl@2.2.0:
@@ -9287,6 +10153,8 @@ snapshots:
10153
10154
loupe@3.1.3: {}
10155
10156
+ loupe@3.1.4: {}
10157
+
10158
lru-cache@10.4.3: {}
10159
10160
lunr@2.3.9: {}
@@ -9341,6 +10209,8 @@ snapshots:
10209
10210
mime@1.6.0: {}
10211
10212
+ mime@3.0.0: {}
10213
+
10214
mimic-fn@4.0.0: {}
10215
10216
mimic-function@5.0.1: {}
@@ -9374,6 +10244,24 @@ snapshots:
10244
10245
ms@2.1.3: {}
10246
10247
+ msgpackr-extract@3.0.3:
10248
+ dependencies:
10249
+ node-gyp-build-optional-packages: 5.2.2
10250
+ optionalDependencies:
10251
+ '@msgpackr-extract/msgpackr-extract-darwin-arm64': 3.0.3
10252
+ '@msgpackr-extract/msgpackr-extract-darwin-x64': 3.0.3
10253
+ '@msgpackr-extract/msgpackr-extract-linux-arm': 3.0.3
10254
+ '@msgpackr-extract/msgpackr-extract-linux-arm64': 3.0.3
10255
+ '@msgpackr-extract/msgpackr-extract-linux-x64': 3.0.3
10256
+ '@msgpackr-extract/msgpackr-extract-win32-x64': 3.0.3
10257
+ optional: true
10258
+
10259
+ msgpackr@1.11.4:
10260
+ optionalDependencies:
10261
+ msgpackr-extract: 3.0.3
10262
+
10263
+ multipasta@0.2.5: {}
10264
+
10265
mustache@4.2.0: {}
10266
10267
mute-stream@1.0.0: {}
@@ -9418,12 +10306,19 @@ snapshots:
10306
- '@babel/core'
10307
- babel-plugin-macros
10308
10309
+ node-addon-api@7.1.1: {}
10310
+
10311
node-domexception@1.0.0: {}
10312
10313
node-fetch@2.7.0:
10314
dependencies:
10315
whatwg-url: 5.0.0
10316
10317
+ node-gyp-build-optional-packages@5.2.2:
10318
+ dependencies:
10319
+ detect-libc: 2.0.4
10320
+ optional: true
10321
+
10322
normalize-path@3.0.0: {}
10323
10324
npm-run-path@5.3.0:
@@ -9693,6 +10588,15 @@ snapshots:
10588
tsx: 4.20.1
10589
yaml: 2.8.0
10590
10591
+ postcss-load-config@6.0.1(jiti@1.21.7)(postcss@8.5.5)(tsx@4.20.3)(yaml@2.8.0):
10592
+ dependencies:
10593
+ lilconfig: 3.1.3
10594
+ optionalDependencies:
10595
+ jiti: 1.21.7
10596
+ postcss: 8.5.5
10597
+ tsx: 4.20.3
10598
+ yaml: 2.8.0
10599
+
10600
postcss-nested@6.2.0(postcss@8.5.5):
10601
dependencies:
10602
postcss: 8.5.5
@@ -9729,6 +10633,10 @@ snapshots:
10633
10634
prelude-ls@1.2.1: {}
10635
10636
+ prettier-linter-helpers@1.0.0:
10637
+ dependencies:
10638
+ fast-diff: 1.3.0
10639
+
10640
prettier@2.8.8: {}
10641
10642
prettier@3.5.3: {}
@@ -9768,6 +10676,8 @@ snapshots:
10676
10677
punycode@2.3.1: {}
10678
10679
+ pure-rand@6.1.0: {}
10680
+
10681
pusher-js@8.4.0:
10682
dependencies:
10683
tweetnacl: 1.0.3
@@ -9848,6 +10758,8 @@ snapshots:
10758
10759
real-require@0.2.0: {}
10760
10761
+ repeat-string@1.6.1: {}
10762
+
10763
require-directory@2.1.1: {}
10764
10765
require-in-the-middle@7.5.2:
@@ -10203,6 +11115,10 @@ snapshots:
11115
- supports-color
11116
- utf-8-validate
11117
11118
+ superjson@2.2.2:
11119
+ dependencies:
11120
+ copy-anything: 3.0.5
11121
+
11122
supports-color@7.2.0:
11123
dependencies:
11124
has-flag: 4.0.0
@@ -10242,6 +11158,15 @@ snapshots:
11158
transitivePeerDependencies:
11159
- ts-node
11160
11161
+ temp-dir@3.0.0: {}
11162
+
11163
+ tempy@3.1.0:
11164
+ dependencies:
11165
+ is-stream: 3.0.0
11166
+ temp-dir: 3.0.0
11167
+ type-fest: 2.19.0
11168
+ unique-string: 3.0.0
11169
+
11170
term-size@2.2.1: {}
11171
11172
thenify-all@1.6.0:
@@ -10269,6 +11194,8 @@ snapshots:
11194
11195
tinypool@1.1.0: {}
11196
11197
+ tinypool@1.1.1: {}
11198
+
11199
tinyrainbow@2.0.0: {}
11200
11201
tinyspy@4.0.3: {}
@@ -10283,6 +11210,8 @@ snapshots:
11210
11211
toidentifier@1.0.1: {}
11212
11213
+ toml@3.0.0: {}
11214
+
11215
totalist@3.0.1: {}
11216
11217
tr46@0.0.3: {}
@@ -10331,6 +11260,34 @@ snapshots:
11260
- tsx
11261
- yaml
11262
11263
+ tsup@8.5.0(jiti@1.21.7)(postcss@8.5.5)(tsx@4.20.3)(typescript@5.8.3)(yaml@2.8.0):
11264
+ dependencies:
11265
+ bundle-require: 5.1.0(esbuild@0.25.5)
11266
+ cac: 6.7.14
11267
+ chokidar: 4.0.3
11268
+ consola: 3.4.2
11269
+ debug: 4.4.1
11270
+ esbuild: 0.25.5
11271
+ fix-dts-default-cjs-exports: 1.0.1
11272
+ joycon: 3.1.1
11273
+ picocolors: 1.1.1
11274
+ postcss-load-config: 6.0.1(jiti@1.21.7)(postcss@8.5.5)(tsx@4.20.3)(yaml@2.8.0)
11275
+ resolve-from: 5.0.0
11276
+ rollup: 4.43.0
11277
+ source-map: 0.8.0-beta.0
11278
+ sucrase: 3.35.0
11279
+ tinyexec: 0.3.2
11280
+ tinyglobby: 0.2.14
11281
+ tree-kill: 1.2.2
11282
+ optionalDependencies:
11283
+ postcss: 8.5.5
11284
+ typescript: 5.8.3
11285
+ transitivePeerDependencies:
11286
+ - jiti
11287
+ - supports-color
11288
+ - tsx
11289
+ - yaml
11290
+
11291
tsx@4.20.1:
11292
dependencies:
11293
esbuild: 0.25.5
@@ -10338,6 +11295,13 @@ snapshots:
11295
optionalDependencies:
11296
fsevents: 2.3.3
11297
11298
+ tsx@4.20.3:
11299
+ dependencies:
11300
+ esbuild: 0.25.5
11301
+ get-tsconfig: 4.10.1
11302
+ optionalDependencies:
11303
+ fsevents: 2.3.3
11304
+
11305
turbo-darwin-64@2.5.4:
11306
optional: true
11307
@@ -10373,6 +11337,10 @@ snapshots:
11337
11338
type-fest@0.21.3: {}
11339
11340
+ type-fest@1.4.0: {}
11341
+
11342
+ type-fest@2.19.0: {}
11343
+
11344
type-is@1.6.18:
11345
dependencies:
11346
media-typer: 0.3.0
@@ -10423,6 +11391,12 @@ snapshots:
11391
11392
undici-types@7.8.0: {}
11393
11394
+ undici@7.10.0: {}
11395
+
11396
+ unique-string@3.0.0:
11397
+ dependencies:
11398
+ crypto-random-string: 4.0.0
11399
+
11400
universalify@0.1.2: {}
11401
11402
unpipe@1.0.0: {}
@@ -10449,13 +11423,13 @@ snapshots:
11423
11424
vary@1.1.2: {}
11425
10452
- vite-node@3.2.3(@types/node@20.19.1)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0):
11426
+ vite-node@3.2.3(@types/node@20.19.1)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0):
11427
dependencies:
11428
cac: 6.7.14
11429
debug: 4.4.1
11430
es-module-lexer: 1.7.0
11431
pathe: 2.0.3
10458
- vite: 6.3.5(@types/node@20.19.1)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0)
11432
+ vite: 6.3.5(@types/node@20.19.1)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0)
11433
transitivePeerDependencies:
11434
- '@types/node'
11435
- jiti
@@ -10512,7 +11486,49 @@ snapshots:
11486
- tsx
11487
- yaml
11488
10515
- vite@6.3.5(@types/node@20.19.1)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0):
11489
+ vite-node@3.2.3(@types/node@24.0.3)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0):
11490
+ dependencies:
11491
+ cac: 6.7.14
11492
+ debug: 4.4.1
11493
+ es-module-lexer: 1.7.0
11494
+ pathe: 2.0.3
11495
+ vite: 6.3.5(@types/node@24.0.3)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0)
11496
+ transitivePeerDependencies:
11497
+ - '@types/node'
11498
+ - jiti
11499
+ - less
11500
+ - lightningcss
11501
+ - sass
11502
+ - sass-embedded
11503
+ - stylus
11504
+ - sugarss
11505
+ - supports-color
11506
+ - terser
11507
+ - tsx
11508
+ - yaml
11509
+
11510
+ vite-node@3.2.4(@types/node@24.0.3)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0):
11511
+ dependencies:
11512
+ cac: 6.7.14
11513
+ debug: 4.4.1
11514
+ es-module-lexer: 1.7.0
11515
+ pathe: 2.0.3
11516
+ vite: 6.3.5(@types/node@24.0.3)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0)
11517
+ transitivePeerDependencies:
11518
+ - '@types/node'
11519
+ - jiti
11520
+ - less
11521
+ - lightningcss
11522
+ - sass
11523
+ - sass-embedded
11524
+ - stylus
11525
+ - sugarss
11526
+ - supports-color
11527
+ - terser
11528
+ - tsx
11529
+ - yaml
11530
+
11531
+ vite@6.3.5(@types/node@20.19.1)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0):
11532
dependencies:
11533
esbuild: 0.25.5
11534
fdir: 6.4.6(picomatch@4.0.2)
@@ -10524,7 +11540,7 @@ snapshots:
11540
'@types/node': 20.19.1
11541
fsevents: 2.3.3
11542
jiti: 1.21.7
10527
- tsx: 4.20.1
11543
+ tsx: 4.20.3
11544
yaml: 2.8.0
11545
11546
vite@6.3.5(@types/node@22.15.31)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0):
@@ -10557,11 +11573,26 @@ snapshots:
11573
tsx: 4.20.1
11574
yaml: 2.8.0
11575
10560
- vitest@3.2.3(@types/node@20.19.1)(@vitest/ui@3.2.3)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0):
11576
+ vite@6.3.5(@types/node@24.0.3)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0):
11577
+ dependencies:
11578
+ esbuild: 0.25.5
11579
+ fdir: 6.4.6(picomatch@4.0.2)
11580
+ picomatch: 4.0.2
11581
+ postcss: 8.5.5
11582
+ rollup: 4.43.0
11583
+ tinyglobby: 0.2.14
11584
+ optionalDependencies:
11585
+ '@types/node': 24.0.3
11586
+ fsevents: 2.3.3
11587
+ jiti: 1.21.7
11588
+ tsx: 4.20.3
11589
+ yaml: 2.8.0
11590
+
11591
+ vitest@3.2.3(@types/node@20.19.1)(@vitest/ui@3.2.3)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0):
11592
dependencies:
11593
'@types/chai': 5.2.2
11594
'@vitest/expect': 3.2.3
10564
- '@vitest/mocker': 3.2.3(vite@6.3.5(@types/node@20.19.1)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0))
11595
+ '@vitest/mocker': 3.2.3(vite@6.3.5(@types/node@20.19.1)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0))
11596
'@vitest/pretty-format': 3.2.3
11597
'@vitest/runner': 3.2.3
11598
'@vitest/snapshot': 3.2.3
@@ -10579,8 +11610,8 @@ snapshots:
11610
tinyglobby: 0.2.14
11611
tinypool: 1.1.0
11612
tinyrainbow: 2.0.0
10582
- vite: 6.3.5(@types/node@20.19.1)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0)
10583
- vite-node: 3.2.3(@types/node@20.19.1)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0)
11613
+ vite: 6.3.5(@types/node@20.19.1)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0)
11614
+ vite-node: 3.2.3(@types/node@20.19.1)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0)
11615
why-is-node-running: 2.3.0
11616
optionalDependencies:
11617
'@types/node': 20.19.1
@@ -10683,6 +11714,90 @@ snapshots:
11714
- tsx
11715
- yaml
11716
11717
+ vitest@3.2.3(@types/node@24.0.3)(@vitest/ui@3.2.3)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0):
11718
+ dependencies:
11719
+ '@types/chai': 5.2.2
11720
+ '@vitest/expect': 3.2.3
11721
+ '@vitest/mocker': 3.2.3(vite@6.3.5(@types/node@24.0.3)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0))
11722
+ '@vitest/pretty-format': 3.2.3
11723
+ '@vitest/runner': 3.2.3
11724
+ '@vitest/snapshot': 3.2.3
11725
+ '@vitest/spy': 3.2.3
11726
+ '@vitest/utils': 3.2.3
11727
+ chai: 5.2.0
11728
+ debug: 4.4.1
11729
+ expect-type: 1.2.1
11730
+ magic-string: 0.30.17
11731
+ pathe: 2.0.3
11732
+ picomatch: 4.0.2
11733
+ std-env: 3.9.0
11734
+ tinybench: 2.9.0
11735
+ tinyexec: 0.3.2
11736
+ tinyglobby: 0.2.14
11737
+ tinypool: 1.1.0
11738
+ tinyrainbow: 2.0.0
11739
+ vite: 6.3.5(@types/node@24.0.3)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0)
11740
+ vite-node: 3.2.3(@types/node@24.0.3)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0)
11741
+ why-is-node-running: 2.3.0
11742
+ optionalDependencies:
11743
+ '@types/node': 24.0.3
11744
+ '@vitest/ui': 3.2.3(vitest@3.2.3)
11745
+ transitivePeerDependencies:
11746
+ - jiti
11747
+ - less
11748
+ - lightningcss
11749
+ - msw
11750
+ - sass
11751
+ - sass-embedded
11752
+ - stylus
11753
+ - sugarss
11754
+ - supports-color
11755
+ - terser
11756
+ - tsx
11757
+ - yaml
11758
+
11759
+ vitest@3.2.4(@types/node@24.0.3)(@vitest/ui@3.2.3(vitest@3.2.3))(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0):
11760
+ dependencies:
11761
+ '@types/chai': 5.2.2
11762
+ '@vitest/expect': 3.2.4
11763
+ '@vitest/mocker': 3.2.4(vite@6.3.5(@types/node@24.0.3)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0))
11764
+ '@vitest/pretty-format': 3.2.4
11765
+ '@vitest/runner': 3.2.4
11766
+ '@vitest/snapshot': 3.2.4
11767
+ '@vitest/spy': 3.2.4
11768
+ '@vitest/utils': 3.2.4
11769
+ chai: 5.2.0
11770
+ debug: 4.4.1
11771
+ expect-type: 1.2.1
11772
+ magic-string: 0.30.17
11773
+ pathe: 2.0.3
11774
+ picomatch: 4.0.2
11775
+ std-env: 3.9.0
11776
+ tinybench: 2.9.0
11777
+ tinyexec: 0.3.2
11778
+ tinyglobby: 0.2.14
11779
+ tinypool: 1.1.1
11780
+ tinyrainbow: 2.0.0
11781
+ vite: 6.3.5(@types/node@24.0.3)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0)
11782
+ vite-node: 3.2.4(@types/node@24.0.3)(jiti@1.21.7)(tsx@4.20.3)(yaml@2.8.0)
11783
+ why-is-node-running: 2.3.0
11784
+ optionalDependencies:
11785
+ '@types/node': 24.0.3
11786
+ '@vitest/ui': 3.2.3(vitest@3.2.3)
11787
+ transitivePeerDependencies:
11788
+ - jiti
11789
+ - less
11790
+ - lightningcss
11791
+ - msw
11792
+ - sass
11793
+ - sass-embedded
11794
+ - stylus
11795
+ - sugarss
11796
+ - supports-color
11797
+ - terser
11798
+ - tsx
11799
+ - yaml
11800
+
11801
web-streams-polyfill@4.0.0-beta.3: {}
11802
11803
webidl-conversions@3.0.1: {}
pnpm-workspace.yaml
+2
@@ -1,7 +1,9 @@
1
packages:
2
- "ts/packages/core"
3
+ - "ts/packages/cli"
4
- "ts/packages/json-schema-to-zod"
5
- "ts/packages/providers/*"
6
+ - "ts/packages/ts-builders"
7
- "ts/packages/wrappers/*"
8
- "ts/examples/*"
9
- "fern"
ts/packages/cli/.gitignore
new
+3
@@ -0,0 +1,3 @@
1
+.generated/
2
+.composio/
3
+composio
ts/packages/cli/README.md
new
+96
@@ -0,0 +1,96 @@
1
+# @composio/cli
2
+
3
+> A tool for managing Composio.dev projects in Python and TypeScript.
4
+
5
+This package defines the Composio CLI used to interact with the Composio Platform. It provides a powerful and flexible way to manage and execute tools, handle authentication, and integrate with various platforms and frameworks.
6
+
7
+## Overview
8
+
9
+The CLI is build using:
10
+
11
+- [TypeScript](https://www.typescriptlang.org/)
12
+- [The Effect ecosystem](https://effect.website/docs)
13
+- [Bun](https://bun.sh/)
14
+- [Vitest](https://vitest.dev/)
15
+
16
+## 🧑💻 Usage
17
+
18
+```
19
+composio [--log-level all|trace|debug|info|warning|error|fatal|none]
20
+```
21
+
22
+### Optional Flags
23
+
24
+- `--log-level`: Set the log verbosity level. Accepted values: all, trace, debug, info, warning, error, fatal, none
25
+
26
+## 🧭 Commands
27
+
28
+| Command | Description | Status |
29
+| --------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
30
+| `composio version` | Display the current CLI version. | ✅ |
31
+| `composio whoami` | Show the currently logged-in user/account. | ✅ It displays the local API_KEY, or shows a message if no API_KEY is found. |
32
+| `composio login` | Log in to the Composio SDK. | ⏰ The session client is defined, but the authentication workflow is currently incomplete |
33
+| `composio generate [-o, --output-dir <directory>]` | Auto-detect the project language (Python or TypeScript) and generate the latest app type stubs. | ✅ |
34
+| `composio py` | Python project-specific commands. |
35
+| `composio py generate [-o, --output-dir <directory>]` | Generate updated Python stubs with the latest app data. | ✅ |
36
+| `composio ts` | TypeScript project-specific commands. | ✅ |
37
+| `composio ts generate [-o, --output-dir <directory>] [--single-file]` | Generate updated TypeScript stubs, optionally as a single file. | ✅ |
38
+| `composio upgrade` | Self-update the Composio CLI if a new release is out. | 🛑 Not implemented yet |
39
+
40
+## Configuration
41
+
42
+The Composio CLI supports configuration via environment variables and a JSON configuration file.
43
+
44
+The Composio CLI also supports a JSON configuration file. The default location is `~/.composio/user_data.json`, but you can specify a custom location using the `COMPOSIO_CACHE_DIR` environment variable.
45
+
46
+| Environment Variable | User JSON config | Description | Default |
47
+| ---------------------- | ---------------- | ------------------------------------------------------------------ | ------- |
48
+| COMPOSIO_API_KEY | `api_key` | Your Composio API key | None |
49
+| COMPOSIO_BASE_URL | `base_url` | The base URL of the Composio backend API | None |
50
+| COMPOSIO_CACHE_DIR | `cache_dir` | The directory where the Composio CLI stores cache files | None |
51
+| COMPOSIO_LOG_LEVEL | `log_level` | The log level for the Composio CLI | None |
52
+| DEBUG_OVERRIDE_VERSION | `version` | The version to use when upgrading the Composio CLI (for debugging) | None |
53
+
54
+## Development
55
+
56
+### Installation
57
+
58
+```bash
59
+pnpm install
60
+```
61
+
62
+### Build TypeScript code
63
+
64
+```bash
65
+pnpm build
66
+```
67
+
68
+### Build self-contained executable
69
+
70
+```bash
71
+pnpm build:bin
72
+```
73
+
74
+or
75
+
76
+```bash
77
+bun run ./scripts/build-binary.ts
78
+```
79
+
80
+### Run interactively
81
+
82
+```bash
83
+pnpm cli
84
+```
85
+
86
+For instance, to generate type stubs for a TypeScript project, you can run:
87
+
88
+```bash
89
+pnpm cli ts generate
90
+```
91
+
92
+### Test
93
+
94
+```bash
95
+pnpm test
96
+```
ts/packages/cli/eslint.config.mjs
new
+6
@@ -0,0 +1,6 @@
1
+export default {
2
+ extends: ['../../eslint.config.mjs'],
3
+ rules: {
4
+ '@effect/eslint-plugin': 'error',
5
+ },
6
+};
ts/packages/cli/package.json
new
+67
@@ -0,0 +1,67 @@
1
+{
2
+ "name": "@composio/cli",
3
+ "version": "0.1.24",
4
+ "description": "Composio CLI",
5
+ "main": "dist/bin.js",
6
+ "bin": {
7
+ "composio": "./dist/composio"
8
+ },
9
+ "type": "module",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/ComposioHQ/composio.git",
13
+ "directory": "ts/packages/cli"
14
+ },
15
+ "publishConfig": {
16
+ "access": "public",
17
+ "main": "dist/bin.js",
18
+ "types": "dist/bin.d.ts"
19
+ },
20
+ "files": [
21
+ "README.md",
22
+ "dist"
23
+ ],
24
+ "scripts": {
25
+ "cli": "bun run src/bin.ts",
26
+ "build:bin": "bun run ./scripts/build-binary.ts",
27
+ "build": "tsup",
28
+ "bin": "./dist/composio",
29
+ "test": "vitest run",
30
+ "prepublishOnly": "pnpm build && pnpm build:bin"
31
+ },
32
+ "keywords": [
33
+ "composio",
34
+ "mcp",
35
+ "cli"
36
+ ],
37
+ "author": "Alberto Schiabel <alberto.schiabel@gmail.com> (https://github.com/jkomyno)",
38
+ "license": "ISC",
39
+ "packageManager": "pnpm@10.8.0",
40
+ "devDependencies": {
41
+ "@effect/eslint-plugin": "^0.3.2",
42
+ "@effect/platform": "^0.84.11",
43
+ "@effect/vitest": "^0.23.8",
44
+ "@types/bun": "^1.2.16",
45
+ "@types/semver": "^7.7.0",
46
+ "tempy": "^3.1.0",
47
+ "tsup": "^8.5.0",
48
+ "tsx": "^4.20.3",
49
+ "typescript": "^5.8.3",
50
+ "vitest": "^3.2.4"
51
+ },
52
+ "dependencies": {
53
+ "@composio/client": "0.1.0-alpha.17",
54
+ "@composio/core": "workspace:*",
55
+ "@composio/ts-builders": "workspace:*",
56
+ "@effect/cli": "^0.63.11",
57
+ "@effect/platform-bun": "^0.69.16",
58
+ "@effect/platform-node-shared": "^0.40.2",
59
+ "chalk": "^5.4.1",
60
+ "effect": "^3.16.8",
61
+ "effect-errors": "^1.10.11",
62
+ "indent-string": "^5.0.0",
63
+ "semver": "^7.7.2",
64
+ "superjson": "^2.2.2"
65
+ },
66
+ "gitHead": "4fae6e54d5c150fba955cc5fa314281da5a1e064"
67
+}
ts/packages/cli/scripts/build-binary.ts
new
+111
@@ -0,0 +1,111 @@
1
+import process from 'node:process';
2
+import {
3
+ Cause,
4
+ Config,
5
+ ConfigProvider,
6
+ Console,
7
+ Effect,
8
+ Exit,
9
+ Stream,
10
+ Logger,
11
+ Layer,
12
+ LogLevel,
13
+} from 'effect';
14
+import { Command } from '@effect/platform';
15
+import { BunContext, BunRuntime } from '@effect/platform-bun';
16
+import type { Teardown } from '@effect/platform/Runtime';
17
+
18
+export function buildBinary() {
19
+ return Effect.gen(function* () {
20
+ const cwd = process.cwd();
21
+ yield* Effect.logDebug(`Building binary in ${cwd}`);
22
+
23
+ const args = [
24
+ 'bun',
25
+ /**
26
+ * Transpile and bundle the CLI app.
27
+ */
28
+ 'build',
29
+ './src/bin.ts',
30
+
31
+ /**
32
+ * Statically inline any environment variable that matches `DEBUG_OVERRIDE_*`.
33
+ */
34
+ '--env',
35
+ 'DEBUG_OVERRIDE_*',
36
+
37
+ /**
38
+ * Generate a standalone Bun executable containing your bundled code.
39
+ */
40
+ '--compile',
41
+ '--production',
42
+
43
+ /**
44
+ * Output file destination.
45
+ */
46
+ '--outfile',
47
+ './dist/composio',
48
+ ] as const satisfies ReadonlyArray<string>;
49
+
50
+ const cmd = Command.make(...args);
51
+
52
+ yield* Effect.logDebug('Running build command with', args.join(' '), '');
53
+
54
+ const { exitCode } = yield* cmd.pipe(
55
+ Command.start,
56
+ Effect.flatMap(process =>
57
+ Effect.all(
58
+ {
59
+ exitCode: process.exitCode,
60
+ output: Stream.merge(
61
+ Stream.decodeText(process.stdout, 'utf-8'),
62
+ Stream.decodeText(process.stderr, 'utf-8'),
63
+ { haltStrategy: 'left' }
64
+ ).pipe(
65
+ Stream.tap(chunk => Console.log(chunk)),
66
+ Stream.runDrain
67
+ ),
68
+ },
69
+ {
70
+ concurrency: 'unbounded',
71
+ }
72
+ )
73
+ )
74
+ );
75
+
76
+ process.exitCode = exitCode;
77
+
78
+ if (exitCode !== 0) {
79
+ return yield* Effect.logInfo('Failed to build binary');
80
+ }
81
+
82
+ yield* Effect.logDebug('', 'Binary built successfully');
83
+ });
84
+}
85
+
86
+export const teardown: Teardown = <E, A>(exit: Exit.Exit<E, A>, onExit: (code: number) => void) => {
87
+ const shouldFail = Exit.isFailure(exit) && !Cause.isInterruptedOnly(exit.cause);
88
+ const errorCode = Number(process.exitCode ?? 1);
89
+ onExit(shouldFail ? errorCode : 0);
90
+};
91
+
92
+const ConfigLive = Effect.gen(function* () {
93
+ const logLevel = yield* Config.logLevel('COMPOSIO_LOG_LEVEL').pipe(
94
+ Config.withDefault(LogLevel.Info)
95
+ );
96
+
97
+ return Logger.minimumLogLevel(logLevel);
98
+}).pipe(Layer.unwrapEffect, Layer.merge(Layer.setConfigProvider(ConfigProvider.fromEnv())));
99
+
100
+if (require.main === module) {
101
+ buildBinary().pipe(
102
+ Effect.provide(ConfigLive),
103
+ Effect.provide(Logger.pretty),
104
+ Effect.provide(BunContext.layer),
105
+ Effect.scoped,
106
+ Effect.map(() => ({ message: 'Build process completed successfully.' })),
107
+ BunRuntime.runMain({
108
+ teardown,
109
+ })
110
+ );
111
+}
ts/packages/cli/src/bin.ts
new
+80
@@ -0,0 +1,80 @@
1
+import process from 'node:process';
2
+import { Cause, Effect, Exit, Layer } from 'effect';
3
+import { prettyPrint } from 'effect-errors';
4
+import { CliConfig } from '@effect/cli';
5
+import { BunContext, BunRuntime, BunFileSystem } from '@effect/platform-bun';
6
+import type { Teardown } from '@effect/platform/Runtime';
7
+import { runWithConfig } from 'src/commands';
8
+import * as constants from 'src/constants';
9
+import { ComposioCliConfig } from 'src/cli-config';
10
+import { UserConfigLive } from 'src/services/user-config';
11
+import {
12
+ ComposioSessionRepository,
13
+ ComposioToolkitsRepository,
14
+} from 'src/services/composio-clients';
15
+import { NodeProcess } from 'src/services/node-process';
16
+import { EnvLangDetector } from './services/env-lang-detector';
17
+
18
+/**
19
+ * Concrete Effect layer compositions for the Composio CLI runtime.
20
+ *
21
+ * ┌─── The service to be created
22
+ * │ ┌─── The possible error
23
+ * │ │ ┌─── The required dependencies
24
+ * ▼ ▼ ▼
25
+ * Layer<RequirementsOut, Error, RequirementsIn>
26
+ */
27
+
28
+/**
29
+ * Service layer that reads the user config.
30
+ */
31
+export const UserConfigProviderLiveFromFs = Layer.provide(UserConfigLive, BunFileSystem.layer);
32
+
33
+/**
34
+ * Service layer that configures the CLI appearance and default command options.
35
+ */
36
+export const CliConfigLive = CliConfig.layer(ComposioCliConfig);
37
+
38
+const layers = Layer.mergeAll(
39
+ UserConfigProviderLiveFromFs,
40
+ CliConfigLive.pipe(Layer.provide(UserConfigProviderLiveFromFs)),
41
+ NodeProcess.Default,
42
+ ComposioSessionRepository.Default.pipe(Layer.provide(UserConfigProviderLiveFromFs)),
43
+ ComposioToolkitsRepository.Default.pipe(Layer.provide(UserConfigProviderLiveFromFs)),
44
+ EnvLangDetector.Default,
45
+ BunContext.layer,
46
+ BunFileSystem.layer
47
+);
48
+
49
+export const teardown: Teardown = <E, A>(exit: Exit.Exit<E, A>, onExit: (code: number) => void) => {
50
+ const shouldFail = Exit.isFailure(exit) && !Cause.isInterruptedOnly(exit.cause);
51
+ const errorCode = Number(process.exitCode ?? 1);
52
+ onExit(shouldFail ? errorCode : 0);
53
+};
54
+
55
+/**
56
+ * CLI entrypoint, which:
57
+ * - runs the Effect runtime and sets up its runtime environment
58
+ * - collects and displays errors
59
+ */
60
+if (require.main === module) {
61
+ const runWithArgs = Effect.flatMap(runWithConfig, run =>
62
+ run(process.argv)
63
+ ) satisfies Effect.Effect<void, unknown, unknown>;
64
+
65
+ runWithArgs.pipe(
66
+ Effect.provide(layers),
67
+ Effect.provide(BunContext.layer),
68
+ Effect.withSpan('composio-cli', {
69
+ attributes: {
70
+ name: constants.APP_NAME,
71
+ filename: 'src/bin.ts',
72
+ },
73
+ }),
74
+ Effect.sandbox,
75
+ Effect.catchAll(e => Effect.fail(prettyPrint(e))),
76
+ BunRuntime.runMain({
77
+ teardown,
78
+ })
79
+ );
80
+}
ts/packages/cli/src/cli-config.ts
new
+7
@@ -0,0 +1,7 @@
1
+import type { CliConfig } from '@effect/cli/CliConfig';
2
+
3
+export const ComposioCliConfig = {
4
+ showBuiltIns: false,
5
+ autoCorrectLimit: 0,
6
+ isCaseSensitive: true,
7
+} satisfies Partial<CliConfig>;
ts/packages/cli/src/commands/$default.cmd.ts
new
+55
@@ -0,0 +1,55 @@
1
+import { Context, Schema, LogLevel, String, pipe, Layer, Effect } from 'effect';
2
+import { Command, Options } from '@effect/cli';
3
+import { setMinimumLogLevel } from 'src/effects/with-log-level';
4
+import type { ConfigError } from 'effect/ConfigError';
5
+import { versionCmd } from './version.cmd';
6
+
7
+const logLevelChoices = LogLevel.allLevels.map(level => String.toLowerCase(level._tag));
8
+
9
+const LogLevelLiteralSchema = Schema.Literal(...logLevelChoices)
10
+ .annotations({
11
+ identifier: 'LogLevelLiteral',
12
+ })
13
+ .pipe(
14
+ Schema.transform(
15
+ Schema.declare((input: unknown): input is LogLevel.LogLevel =>
16
+ LogLevel.allLevels.includes(input as LogLevel.LogLevel)
17
+ ).annotations({
18
+ identifier: 'LogLevel',
19
+ }),
20
+ {
21
+ decode: literal => pipe(literal, String.capitalize, LogLevel.fromLiteral),
22
+ encode: logLevel => String.toLowerCase(logLevel._tag),
23
+ strict: true,
24
+ }
25
+ )
26
+ );
27
+
28
+const logLevel = Options.choice('log-level', logLevelChoices).pipe(
29
+ Options.withSchema(LogLevelLiteralSchema),
30
+ Options.withDescription('Define log level'),
31
+ Options.optional
32
+);
33
+
34
+class $DefaultCmdContext extends Context.Tag('cli/$DefaultCmdContext')<
35
+ $DefaultCmdContext,
36
+ Layer.Layer<never, ConfigError, never>
37
+>() {}
38
+
39
+/**
40
+ * CLI entry point for the Composio CLI.
41
+ *
42
+ * @example
43
+ * ```bash
44
+ * composio <subcommand>
45
+ * ```
46
+ */
47
+export const $defaultCmd = Command.make('composio', { logLevel }).pipe(
48
+ Command.withSubcommands([versionCmd]),
49
+ Command.withDescription(
50
+ `Composio CLI - A tool for managing Python and TypeScript composio.dev projects.`
51
+ ),
52
+ Command.provideEffect($DefaultCmdContext, ({ logLevel }) =>
53
+ Effect.succeed(setMinimumLogLevel(logLevel))
54
+ )
55
+);
ts/packages/cli/src/commands/generate.cmd.ts
new
+44
@@ -0,0 +1,44 @@
1
+import { Command, Options } from '@effect/cli';
2
+import { Effect, Console, Match } from 'effect';
3
+import { EnvLangDetector } from 'src/services/env-lang-detector';
4
+import { NodeProcess } from 'src/services/node-process';
5
+import { generateTypescriptTypeStubs } from './ts/commands/ts.generate.cmd';
6
+import { generatePythonTypeStubs } from './py/commands/py.generate.cmd';
7
+
8
+export const outputOpt = Options.optional(
9
+ Options.directory('output-dir', {
10
+ exists: 'either',
11
+ })
12
+).pipe(Options.withAlias('o'), Options.withDescription('Output directory for type stubs'));
13
+
14
+/**
15
+ * @example
16
+ * ```bash
17
+ * composio generate <command>
18
+ * ```
19
+ */
20
+export const generateCmd = Command.make('generate', { outputOpt }).pipe(
21
+ Command.withDescription(
22
+ 'Updates the local type stubs with the latest app data, automatically detecting the language of the project in the current working directory (TypeScript | Python).'
23
+ ),
24
+ Command.withHandler(({ outputOpt }) =>
25
+ Effect.gen(function* () {
26
+ const process = yield* NodeProcess;
27
+ const cwd = process.cwd;
28
+
29
+ yield* Effect.logDebug('Identifying project type...');
30
+ const envLangDetector = yield* EnvLangDetector;
31
+ const envLang = yield* envLangDetector.detectEnvLanguage(cwd);
32
+ yield* Console.log(`Project type detected: ${envLang}`);
33
+
34
+ // Redirect to either `ts generate` or `py generate` commands
35
+ yield* Match.value(envLang).pipe(
36
+ Match.when('TypeScript', () =>
37
+ generateTypescriptTypeStubs({ outputOpt, singleFile: false })
38
+ ),
39
+ Match.when('Python', () => generatePythonTypeStubs({ outputOpt })),
40
+ Match.exhaustive
41
+ );
42
+ })
43
+ )
44
+);
ts/packages/cli/src/commands/index.ts
new
+31
@@ -0,0 +1,31 @@
1
+import { Effect } from 'effect';
2
+import { Command } from '@effect/cli';
3
+import * as constants from 'src/constants';
4
+import { $defaultCmd } from './$default.cmd';
5
+import { getVersion } from 'src/effects/version';
6
+import { versionCmd } from './version.cmd';
7
+import { whoamiCmd } from './whoami.cmd';
8
+import { loginCmd } from './login.cmd';
9
+import { pyCmd } from './py/py.cmd';
10
+import { tsCmd } from './ts/ts.cmd';
11
+import { generateCmd } from './generate.cmd';
12
+
13
+const $cmd = $defaultCmd.pipe(
14
+ Command.withSubcommands([versionCmd, whoamiCmd, loginCmd, generateCmd, pyCmd, tsCmd])
15
+);
16
+
17
+export const runWithConfig = Effect.gen(function* () {
18
+ const version = yield* getVersion;
19
+
20
+ return Command.run($cmd, {
21
+ name: 'composio',
22
+ executable: 'composio',
23
+ version,
24
+ });
25
+});
26
+
27
+export const run = Command.run($cmd, {
28
+ name: 'composio',
29
+ version: constants.APP_VERSION,
30
+ executable: 'composio',
31
+});
ts/packages/cli/src/commands/login.cmd.ts
new
+25
@@ -0,0 +1,25 @@
1
+import { Command } from '@effect/cli';
2
+import { Effect, Console } from 'effect';
3
+import { ComposioSessionRepository } from 'src/services/composio-clients';
4
+
5
+/**
6
+ * CLI command to login using Composio's CLI session APIs.
7
+ *
8
+ * @example
9
+ * ```bash
10
+ * composio login <command>
11
+ * ```
12
+ */
13
+export const loginCmd = Command.make('login', {}, () =>
14
+ Effect.gen(function* () {
15
+ const client = yield* ComposioSessionRepository;
16
+ const session = yield* client.createSession();
17
+ const linkedSession = yield* client.linkSession(session);
18
+
19
+ yield* Effect.logDebug(`Linked session: ${JSON.stringify(linkedSession)}`);
20
+
21
+ yield* Console.log(
22
+ `Linked session code ${session.code} to user account ${linkedSession.account.email}`
23
+ );
24
+ })
25
+).pipe(Command.withDescription('Log in to the Composio SDK.'));
ts/packages/cli/src/commands/py/commands/py.generate.cmd.ts
new
+65
@@ -0,0 +1,65 @@
1
+import path from 'node:path';
2
+import { Command, Options } from '@effect/cli';
3
+import { Console, Effect, Option } from 'effect';
4
+import { FileSystem } from '@effect/platform';
5
+import { ComposioToolkitsRepository } from 'src/services/composio-clients';
6
+import type { GetCmdParams } from 'src/type-utils';
7
+import { NodeProcess } from 'src/services/node-process';
8
+import { createToolkitIndex } from 'src/generation/create-toolkit-index';
9
+import { generatePythonToolkitSources } from 'src/generation/python/generate-toolkit-sources';
10
+
11
+export const outputOpt = Options.optional(
12
+ Options.directory('output-dir', {
13
+ exists: 'either',
14
+ })
15
+).pipe(
16
+ Options.withAlias('o'),
17
+ Options.withDescription(
18
+ 'Output directory for the generated Python type stubs (default: `./.generated/composio-py`)'
19
+ )
20
+);
21
+
22
+const _pyCmd$Generate = Command.make('generate', { outputOpt }).pipe(
23
+ Command.withDescription('Updates the local type stubs with the latest app data.')
24
+);
25
+
26
+export const pyCmd$Generate = _pyCmd$Generate.pipe(Command.withHandler(generatePythonTypeStubs));
27
+
28
+export function generatePythonTypeStubs({ outputOpt }: GetCmdParams<typeof _pyCmd$Generate>) {
29
+ return Effect.gen(function* () {
30
+ const process = yield* NodeProcess;
31
+ const cwd = process.cwd;
32
+
33
+ const fs = yield* FileSystem.FileSystem;
34
+
35
+ const output = outputOpt.pipe(
36
+ Option.getOrElse(() => path.join(cwd, '.generated', 'composio-py'))
37
+ );
38
+ yield* fs.makeDirectory(output, { recursive: true });
39
+
40
+ yield* Console.log('Fetching latest data from Composio API...');
41
+ const client = yield* ComposioToolkitsRepository;
42
+
43
+ yield* Effect.logDebug('Fetching toolkits...');
44
+ const toolkits = yield* client.getToolkits();
45
+
46
+ yield* Effect.logDebug('Fetching tools...');
47
+ const tools = yield* client.getTools();
48
+
49
+ yield* Effect.logDebug('Fetching trigger types...');
50
+ const triggerTypes = yield* client.getTriggerTypes();
51
+
52
+ const index = createToolkitIndex({ toolkits, tools, triggerTypes });
53
+ const sourceFiles = generatePythonToolkitSources(index).map(
54
+ ([filename, content]) => [path.join(output, filename), content] as const
55
+ );
56
+
57
+ yield* Console.log(`Writing type stubs to ${output}...`);
58
+
59
+ yield* Effect.all(
60
+ sourceFiles.map(([filePath, content]) => fs.writeFileString(filePath, content))
61
+ );
62
+
63
+ return yield* Console.log('✅ Type stubs generated successfully.');
64
+ });
65
+}
ts/packages/cli/src/commands/py/py.cmd.ts
new
+15
@@ -0,0 +1,15 @@
1
+import { Command } from '@effect/cli';
2
+import { pyCmd$Generate } from './commands/py.generate.cmd';
3
+
4
+/**
5
+ * CLI entry point for Python commands.
6
+ *
7
+ * @example
8
+ * ```bash
9
+ * composio py <command>
10
+ * ```
11
+ */
12
+export const pyCmd = Command.make('py').pipe(
13
+ Command.withDescription('Handle Python projects.'),
14
+ Command.withSubcommands([pyCmd$Generate])
15
+);
ts/packages/cli/src/commands/ts/commands/ts.generate.cmd.ts
new
+75
@@ -0,0 +1,75 @@
1
+import path from 'node:path';
2
+import { Command, Options } from '@effect/cli';
3
+import { Console, Effect, Option } from 'effect';
4
+import { FileSystem } from '@effect/platform';
5
+import { ComposioToolkitsRepository } from 'src/services/composio-clients';
6
+import { NodeProcess } from 'src/services/node-process';
7
+import { createToolkitIndex } from 'src/generation/create-toolkit-index';
8
+import type { GetCmdParams } from 'src/type-utils';
9
+import { generateTypeScriptSources } from 'src/generation/typescript/generate';
10
+
11
+export const outputOpt = Options.optional(
12
+ Options.directory('output-dir', {
13
+ exists: 'either',
14
+ })
15
+).pipe(
16
+ Options.withAlias('o'),
17
+ Options.withDescription(
18
+ 'Output directory for the generated Python type stubs (default: `./.generated/composio-py`)'
19
+ )
20
+);
21
+
22
+export const singleFile = Options.boolean('single-file').pipe(
23
+ Options.withDefault(false),
24
+ Options.withDescription('Emit a single TypeScript file')
25
+);
26
+
27
+const _tsCmd$Generate = Command.make('generate', { outputOpt, singleFile }).pipe(
28
+ Command.withDescription('Updates the local type stubs with the latest app data.')
29
+);
30
+
31
+export const tsCmd$Generate = _tsCmd$Generate.pipe(
32
+ Command.withHandler(generateTypescriptTypeStubs)
33
+);
34
+
35
+export function generateTypescriptTypeStubs({
36
+ outputOpt,
37
+ singleFile,
38
+}: GetCmdParams<typeof _tsCmd$Generate>) {
39
+ return Effect.gen(function* () {
40
+ const process = yield* NodeProcess;
41
+ const cwd = process.cwd;
42
+
43
+ const fs = yield* FileSystem.FileSystem;
44
+
45
+ const outputDir = outputOpt.pipe(
46
+ Option.getOrElse(() => path.join(cwd, '.generated', 'composio-ts'))
47
+ );
48
+ yield* fs.makeDirectory(outputDir, { recursive: true });
49
+
50
+ yield* Console.log('Fetching latest data from Composio API...');
51
+ const client = yield* ComposioToolkitsRepository;
52
+
53
+ yield* Effect.logDebug('Fetching toolkits...');
54
+ const toolkits = yield* client.getToolkits();
55
+
56
+ yield* Effect.logDebug('Fetching tools...');
57
+ const tools = yield* client.getTools();
58
+
59
+ yield* Effect.logDebug('Fetching trigger types...');
60
+ const triggerTypes = yield* client.getTriggerTypes();
61
+
62
+ const index = createToolkitIndex({ toolkits, tools, triggerTypes });
63
+ const sources = generateTypeScriptSources({
64
+ banner: 'Auto-generated by Composio CLI. Do not modify manually.',
65
+ emitSingleFile: singleFile,
66
+ outputDir,
67
+ })(index);
68
+
69
+ yield* Console.log(`Writing type stubs to ${outputDir}...`);
70
+
71
+ yield* Effect.all(sources.map(([filePath, content]) => fs.writeFileString(filePath, content)));
72
+
73
+ return yield* Console.log('✅ Type stubs generated successfully.');
74
+ });
75
+}
ts/packages/cli/src/commands/ts/ts.cmd.ts
new
+15
@@ -0,0 +1,15 @@
1
+import { Command } from '@effect/cli';
2
+import { tsCmd$Generate } from './commands/ts.generate.cmd';
3
+
4
+/**
5
+ * CLI entry point for TypeScript commands.
6
+ *
7
+ * @example
8
+ * ```bash
9
+ * composio ts <command>
10
+ * ```
11
+ */
12
+export const tsCmd = Command.make('ts').pipe(
13
+ Command.withDescription('Handle TypeScript projects.'),
14
+ Command.withSubcommands([tsCmd$Generate])
15
+);
ts/packages/cli/src/commands/version.cmd.ts
new
+23
@@ -0,0 +1,23 @@
1
+import { Command } from '@effect/cli';
2
+import { Effect, Console } from 'effect';
3
+import { getVersion } from 'src/effects/version';
4
+
5
+/**
6
+ * CLI command to display the version of the Composio CLI.
7
+ *
8
+ * @example
9
+ * ```bash
10
+ * composio version
11
+ * ```
12
+ */
13
+export const versionCmd = Command.make('version', {}).pipe(
14
+ Command.withDescription('Display your account information.'),
15
+ Command.withHandler(() =>
16
+ Effect.gen(function* () {
17
+ const version = yield* getVersion;
18
+ yield* Console.log(`${version}`);
19
+
20
+ yield* Effect.logDebug('Composio CLI version command executed successfully.');
21
+ })
22
+ )
23
+);
ts/packages/cli/src/commands/whoami.cmd.ts
new
+21
@@ -0,0 +1,21 @@
1
+import { Command } from '@effect/cli';
2
+import { Effect, Console } from 'effect';
3
+import { APP_CONFIG } from 'src/effects/app-config';
4
+
5
+/**
6
+ * CLI command to display your account information.
7
+ *
8
+ * @example
9
+ * ```bash
10
+ * composio whoami <command>
11
+ * ```
12
+ */
13
+export const whoamiCmd = Command.make('whoami', {}).pipe(
14
+ Command.withDescription('Display your account information.'),
15
+ Command.withHandler(() =>
16
+ Effect.gen(function* () {
17
+ const apiKey = yield* APP_CONFIG['API_KEY'];
18
+ yield* Console.log(`API KEY: ${apiKey}`);
19
+ })
20
+ )
21
+);
ts/packages/cli/src/constants.ts
new
+51
@@ -0,0 +1,51 @@
1
+import { constants } from '@composio/core';
2
+import pkg from '../package.json' with { type: 'json' };
3
+
4
+/**
5
+ * Prefix for user environment variable keys used by the Composio CLI.
6
+ */
7
+export const APP_ENV_CONFIG_KEY_PREFIX = 'COMPOSIO_';
8
+
9
+/**
10
+ * Prefix for environment variable keys used by the Composio CLI for debug overrides.
11
+ */
12
+export const DEBUG_OVERRIDE_ENV_CONFIG_KEY_PREFIX = 'DEBUG_OVERRIDE_';
13
+
14
+/**
15
+ * Name of the user config file used by the Composio CLI.
16
+ */
17
+export const USER_CONFIG_FILE_NAME = constants.USER_DATA_FILE_NAME;
18
+
19
+/**
20
+ * Name of the directory used to store the Composio CLI config.
21
+ */
22
+export const USER_COMPOSIO_DIR = constants.COMPOSIO_DIR;
23
+
24
+/**
25
+ * A map of cache filenames used by the Composio CLI.
26
+ */
27
+export const CACHE_FILENAMES = {
28
+ SESSION: 'session.json',
29
+ TOOLKITS: 'toolkits.json',
30
+ TOOLS: 'tools.json',
31
+ TRIGGER_TYPES: 'trigger-types.json',
32
+};
33
+
34
+/**
35
+ * Version of the Composio CLI, read from `package.json` at build time.
36
+ */
37
+export const APP_VERSION = pkg.version;
38
+
39
+/**
40
+ * Name of the Composio CLI application, read from `package.json` at build time.
41
+ */
42
+export const APP_NAME = pkg.name;
43
+
44
+/**
45
+ * GitHub repository information for release fetching
46
+ */
47
+export const GITHUB_REPO = {
48
+ OWNER: 'ComposioHQ',
49
+ REPO: 'composio',
50
+ API_BASE_URL: 'https://api.github.com',
51
+} as const;
ts/packages/cli/src/effects/app-config.ts
new
+27
@@ -0,0 +1,27 @@
1
+import { Config, LogLevel, Option } from 'effect';
2
+
3
+type APP_CONFIG = Config.Config.Wrap<{
4
+ API_KEY: string;
5
+ BASE_URL: Option.Option<string>;
6
+ CACHE_DIR: Option.Option<string>;
7
+ LOG_LEVEL: Option.Option<LogLevel.LogLevel>;
8
+}>;
9
+
10
+/**
11
+ * Describe every configuration key used at runtime.
12
+ * Keys are read from environment variables (with the `${APP_ENV_CONFIG_KEY_PREFIX}_<key>` format),
13
+ * or from the user config file (in JSON format).
14
+ */
15
+export const APP_CONFIG = {
16
+ // The API key for the Composio API
17
+ API_KEY: Config.string('API_KEY'),
18
+
19
+ // The base URL for the Composio API
20
+ BASE_URL: Config.option(Config.string('BASE_URL')),
21
+
22
+ // The cache directory for the Composio CLI
23
+ CACHE_DIR: Config.option(Config.string('CACHE_DIR')),
24
+
25
+ // The log level for the Composio CLI
26
+ LOG_LEVEL: Config.option(Config.logLevel('LOG_LEVEL')),
27
+} satisfies APP_CONFIG;
ts/packages/cli/src/effects/debug-config.ts
new
+20
@@ -0,0 +1,20 @@
1
+import { Config, Option } from 'effect';
2
+
3
+type DEBUG_CONFIG = Config.Config.Wrap<{
4
+ UPGRADE_TARGET: Option.Option<string>;
5
+ VERSION: Option.Option<string>;
6
+}>;
7
+
8
+/**
9
+ * Describe debug configuration keys used at runtime.
10
+ * Keys are read from environment variables (with the `DEBUG_OVERRIDE_<key>` format),
11
+ * or from the user config file (in JSON format).
12
+ */
13
+export const DEBUG_OVERRIDE_CONFIG = {
14
+ // The local binary used when upgrading the Composio CLI (for debugging).
15
+ // When set, the upgrade command will use this local file instead of downloading from GitHub.
16
+ UPGRADE_TARGET: Config.option(Config.string('DEBUG_OVERRIDE_UPGRADE_TARGET')),
17
+
18
+ // The version to use when upgrading the Composio CLI (for debugging).
19
+ VERSION: Config.option(Config.string('DEBUG_OVERRIDE_VERSION')),
20
+} satisfies DEBUG_CONFIG;
ts/packages/cli/src/effects/from-lazy-json.ts
new
+203
@@ -0,0 +1,203 @@
1
+import { FileSystem, Error as PlatformError } from '@effect/platform';
2
+import {
3
+ pipe,
4
+ Array,
5
+ Option,
6
+ Effect,
7
+ Cause,
8
+ RegExp as regexp,
9
+ Config,
10
+ ConfigError,
11
+ ConfigProvider,
12
+ ConfigProviderPathPatch,
13
+ HashSet,
14
+} from 'effect';
15
+import { JSONParse, JSONParseError } from 'src/effects/json';
16
+
17
+/**
18
+ * Lazy version of a `effect/ConfigProvider` that reads config values from a JSON file.
19
+ */
20
+export const configProviderFromLazyJson = (filePath: string) =>
21
+ Effect.gen(function* () {
22
+ const fs = yield* FileSystem.FileSystem;
23
+
24
+ const { pathDelim, seqDelim } = { seqDelim: ',', pathDelim: '.' };
25
+ const makePathString = (path: ReadonlyArray<string>): string =>
26
+ pipe(path, Array.join(pathDelim));
27
+ const unmakePathString = (pathString: string): ReadonlyArray<string> =>
28
+ pathString.split(pathDelim);
29
+
30
+ const STR_INDEX_REGEX = /(^.+)(\[(\d+)\])$/;
31
+
32
+ const parseInteger = (str: string): Option.Option<number> => {
33
+ const parsedIndex = Number.parseInt(str);
34
+ return Number.isNaN(parsedIndex) ? Option.none() : Option.some(parsedIndex);
35
+ };
36
+
37
+ const splitIndexFrom = (key: string): Option.Option<[string, number]> => {
38
+ const match = key.match(STR_INDEX_REGEX);
39
+ if (match !== null) {
40
+ const matchedString = match[1];
41
+ const matchedIndex = match[3];
42
+ const optionalString =
43
+ matchedString !== undefined && matchedString.length > 0
44
+ ? Option.some(matchedString)
45
+ : Option.none();
46
+ const optionalIndex = pipe(
47
+ matchedIndex !== undefined && matchedIndex.length > 0
48
+ ? Option.some(matchedIndex)
49
+ : Option.none(),
50
+ Option.flatMap(parseInteger)
51
+ );
52
+ return Option.all([optionalString, optionalIndex]);
53
+ }
54
+ return Option.none();
55
+ };
56
+
57
+ const splitIndexInKeys = (
58
+ map: Map<string, string>,
59
+ unmakePathString: (str: string) => ReadonlyArray<string>,
60
+ makePathString: (chunk: ReadonlyArray<string>) => string
61
+ ): Map<string, string> => {
62
+ const newMap: Map<string, string> = new Map();
63
+ for (const [pathString, value] of map) {
64
+ const keyWithIndex = pipe(
65
+ unmakePathString(pathString),
66
+ Array.flatMap(key =>
67
+ Option.match(splitIndexFrom(key), {
68
+ onNone: () => Array.of(key),
69
+ onSome: ([key, index]) => Array.make(key, `[${index}]`),
70
+ })
71
+ )
72
+ );
73
+ newMap.set(makePathString(keyWithIndex), value);
74
+ }
75
+ return newMap;
76
+ };
77
+
78
+ const parseConfig =
79
+ <A>(_config: Config.Config<A>) =>
80
+ (configContent: string) =>
81
+ Effect.gen(function* () {
82
+ const configContentAsJSON = yield* Effect.catchIf(
83
+ JSONParse(configContent),
84
+ (e): e is JSONParseError => e instanceof JSONParseError,
85
+ e => Effect.fail(ConfigError.SourceUnavailable([], e.message, Cause.fail(e)))
86
+ );
87
+
88
+ const map = new Map(
89
+ Object.entries(configContentAsJSON).map(([key, value]) => [key, String(value)] as const)
90
+ );
91
+
92
+ const mapWithIndexSplit = splitIndexInKeys(
93
+ map,
94
+ str => unmakePathString(str),
95
+ makePathString
96
+ );
97
+
98
+ return mapWithIndexSplit;
99
+ });
100
+
101
+ const readConfig = <A>(filePath: string, config: Config.Config<A>) =>
102
+ Effect.flatMap(fs.readFileString(filePath, 'utf-8'), parseConfig(config));
103
+
104
+ const sourceError = (error: PlatformError.PlatformError) =>
105
+ ConfigError.SourceUnavailable([], error.description ?? error.message, Cause.fail(error));
106
+
107
+ const pathNotFoundError = ConfigError.MissingData([], `Path ${filePath} not found`);
108
+ const handlePlatformError = (error: PlatformError.PlatformError) =>
109
+ error._tag === 'SystemError' && error.reason === 'NotFound'
110
+ ? Effect.fail(pathNotFoundError)
111
+ : Effect.fail(sourceError(error));
112
+
113
+ const splitPathString = (text: string, delim: string): Array<string> => {
114
+ const split = text.split(new RegExp(`\\s*${regexp.escape(delim)}\\s*`));
115
+ return split;
116
+ };
117
+
118
+ const parsePrimitive = <A>(
119
+ text: string,
120
+ path: ReadonlyArray<string>,
121
+ primitive: Config.Config.Primitive<A>,
122
+ delimiter: string,
123
+ split: boolean
124
+ ): Effect.Effect<Array<A>, ConfigError.ConfigError> => {
125
+ if (!split) {
126
+ return pipe(
127
+ primitive.parse(text),
128
+ Effect.mapBoth({
129
+ onFailure: ConfigError.prefixed(Array.fromIterable(path)),
130
+ onSuccess: Array.of,
131
+ })
132
+ );
133
+ }
134
+ return pipe(
135
+ splitPathString(text, delimiter),
136
+ Effect.forEach(char => primitive.parse(char.trim())),
137
+ Effect.mapError(ConfigError.prefixed(Array.fromIterable(path)))
138
+ );
139
+ };
140
+
141
+ const load = <A>(
142
+ path: ReadonlyArray<string>,
143
+ primitive: Config.Config.Primitive<A>,
144
+ split = true
145
+ ): Effect.Effect<Array<A>, ConfigError.ConfigError> =>
146
+ Effect.gen(function* () {
147
+ const mapWithIndexSplit = yield* Effect.catchIf(
148
+ readConfig(filePath, primitive),
149
+ PlatformError.isPlatformError,
150
+ handlePlatformError
151
+ );
152
+
153
+ const pathString = makePathString(path);
154
+ const valueOpt = mapWithIndexSplit.has(pathString)
155
+ ? Option.some(mapWithIndexSplit.get(pathString)!)
156
+ : Option.none();
157
+ const value = yield* pipe(
158
+ valueOpt,
159
+ Effect.mapError(() =>
160
+ ConfigError.MissingData(
161
+ Array.fromIterable(path),
162
+ `Expected ${pathString} to exist in the provided map`
163
+ )
164
+ )
165
+ );
166
+
167
+ return yield* parsePrimitive(value, path, primitive, seqDelim, split);
168
+ });
169
+
170
+ const enumerateChildren = (
171
+ path: ReadonlyArray<string>
172
+ ): Effect.Effect<HashSet.HashSet<string>, ConfigError.ConfigError> =>
173
+ Effect.gen(function* () {
174
+ const mapWithIndexSplit = yield* Effect.catchIf(
175
+ readConfig(filePath, Config.string()),
176
+ PlatformError.isPlatformError,
177
+ handlePlatformError
178
+ );
179
+
180
+ const keyPaths = Array.fromIterable(mapWithIndexSplit.keys()).map(unmakePathString);
181
+ const filteredKeyPaths = keyPaths
182
+ .filter(keyPath => {
183
+ for (let i = 0; i < path.length; i++) {
184
+ const pathComponent = pipe(path, Array.unsafeGet(i));
185
+ const currentElement = keyPath[i];
186
+ if (currentElement === undefined || pathComponent !== currentElement) {
187
+ return false;
188
+ }
189
+ }
190
+ return true;
191
+ })
192
+ .flatMap(keyPath => keyPath.slice(path.length, path.length + 1));
193
+ return HashSet.fromIterable(filteredKeyPaths);
194
+ });
195
+
196
+ return ConfigProvider.fromFlat(
197
+ ConfigProvider.makeFlat({
198
+ load,
199
+ enumerateChildren,
200
+ patch: ConfigProviderPathPatch.empty,
201
+ })
202
+ );
203
+ });
ts/packages/cli/src/effects/json.ts
new
+12
@@ -0,0 +1,12 @@
1
+import { Data, Effect } from 'effect';
2
+
3
+export class JSONParseError extends Data.TaggedError('effects/JSONParseError')<{
4
+ readonly cause: Error;
5
+ readonly message: string;
6
+}> {}
7
+
8
+export const JSONParse = (s: string) =>
9
+ Effect.try({
10
+ try: () => JSON.parse(s) as Record<string, unknown>,
11
+ catch: e => new JSONParseError({ cause: e as Error, message: 'Failed to parse JSON' }),
12
+ });
ts/packages/cli/src/effects/setup-cache-dir.ts
new
+20
@@ -0,0 +1,20 @@
1
+import path from 'node:path';
2
+import os from 'node:os';
3
+import { Effect, pipe, Option } from 'effect';
4
+import { FileSystem } from '@effect/platform';
5
+import * as constants from 'src/constants';
6
+import { APP_CONFIG } from 'src/effects/app-config';
7
+
8
+// Helper to create cache directory
9
+export const setupCacheDir = Effect.gen(function* () {
10
+ const fs = yield* FileSystem.FileSystem;
11
+
12
+ const cacheDir = yield* pipe(
13
+ APP_CONFIG.CACHE_DIR,
14
+ Effect.map(Option.getOrElse(() => path.join(os.homedir(), constants.USER_COMPOSIO_DIR)))
15
+ );
16
+
17
+ yield* fs.makeDirectory(cacheDir, { recursive: true });
18
+
19
+ return cacheDir;
20
+});
ts/packages/cli/src/effects/version.ts
new
+8
@@ -0,0 +1,8 @@
1
+import { Effect, Option } from 'effect';
2
+import { DEBUG_OVERRIDE_CONFIG } from 'src/effects/debug-config';
3
+import * as constants from 'src/constants';
4
+
5
+export const getVersion = Effect.map(
6
+ DEBUG_OVERRIDE_CONFIG.VERSION,
7
+ Option.getOrElse(() => constants.APP_VERSION)
8
+);
ts/packages/cli/src/effects/with-log-level.ts
new
+16
@@ -0,0 +1,16 @@
1
+import { Effect, Option, Logger, LogLevel, Layer } from 'effect';
2
+import { APP_CONFIG } from 'src/effects/app-config';
3
+
4
+/**
5
+ * Sets the minimum log level for subsequent logging operation, preferring the given log level,
6
+ * and falling back to the one read from the config.
7
+ */
8
+export const setMinimumLogLevel = (logLevelFromCLI: Option.Option<LogLevel.LogLevel>) =>
9
+ APP_CONFIG['LOG_LEVEL'].pipe(
10
+ Effect.map(logLevelFromEnv => {
11
+ return Option.zipLeft(logLevelFromCLI, logLevelFromEnv);
12
+ }),
13
+ Effect.map(Option.getOrElse(() => LogLevel.Info)),
14
+ Effect.map(logLevel => Logger.minimumLogLevel(logLevel)),
15
+ Layer.unwrapEffect
16
+ );
ts/packages/cli/src/generation/create-toolkit-index.ts
new
+87
@@ -0,0 +1,87 @@
1
+import { pipe, String, Record } from 'effect';
2
+import type { Simplify } from 'effect/Types';
3
+import { Toolkit, Toolkits, ToolkitName } from 'src/models/toolkits';
4
+import { Tools } from 'src/models/tools';
5
+import { TriggerTypes } from 'src/models/trigger-types';
6
+
7
+const startsWith =
8
+ <const P extends string>(prefix: P) =>
9
+ (str: string): str is `${P}${string}` =>
10
+ str.startsWith(prefix);
11
+
12
+interface CreateToolkitIndexInput {
13
+ toolkits: Toolkits; // e.g., [ { slug: 'gmail', }]
14
+ tools: Tools; // e.g., [ 'GMAIL_SEND_EMAIL' ]
15
+ triggerTypes: TriggerTypes; // e.g., [ 'GMAIL_NEW_EMAIL' ]
16
+}
17
+
18
+export type ToolkitIndexData = Simplify<{
19
+ slug: string;
20
+ tools: Record<`${ToolkitName}_${string}`, string>;
21
+ triggerTypes: Record<`${ToolkitName}_${string}`, string>;
22
+}>;
23
+
24
+export type ToolkitIndex = Record<ToolkitName, ToolkitIndexData>;
25
+
26
+/**
27
+ * Creates a toolkit index from the given input.
28
+ * Tools and triggerTypes are grouped by their corresponding toolkit name,
29
+ * which is found by looking at the prefix of the tool or trigger type.
30
+ */
31
+export function createToolkitIndex(input: CreateToolkitIndexInput): Simplify<ToolkitIndex> {
32
+ return pipe(
33
+ input,
34
+ groupByToolkits,
35
+ Record.fromEntries,
36
+ Record.mapEntries((value, key) => {
37
+ const stripPrefix = String.slice(key.length + 1);
38
+
39
+ const { slug } = value.toolkit;
40
+ const tools = value.tools.map(tool => [stripPrefix(tool), tool] as const);
41
+ const triggerTypes = value.triggerTypes.map(
42
+ triggerType => [stripPrefix(triggerType), triggerType] as const
43
+ );
44
+
45
+ return [
46
+ key,
47
+ { slug, tools: Record.fromEntries(tools), triggerTypes: Record.fromEntries(triggerTypes) },
48
+ ] as const;
49
+ })
50
+ );
51
+}
52
+
53
+type GroupByToolkitOutput<T extends ToolkitName> = [
54
+ Uppercase<T>,
55
+ {
56
+ toolkit: Toolkit;
57
+ tools: Array<`${Uppercase<T>}_${string}`>;
58
+ triggerTypes: Array<`${Uppercase<T>}_${string}`>;
59
+ },
60
+];
61
+
62
+const groupByToolkit =
63
+ <const T extends string>(toolkit: Omit<Toolkit, 'name'> & { name: T }) =>
64
+ ({
65
+ tools,
66
+ triggerTypes,
67
+ }: Omit<CreateToolkitIndexInput, 'toolkits'>): GroupByToolkitOutput<T & ToolkitName> => {
68
+ const toolkitName = pipe(toolkit.slug, String.toUpperCase, ToolkitName) as Uppercase<
69
+ T & ToolkitName
70
+ >;
71
+
72
+ return [
73
+ toolkitName,
74
+ {
75
+ toolkit,
76
+ tools: tools.filter(startsWith(`${toolkitName}_`)),
77
+ triggerTypes: triggerTypes.filter(startsWith(`${toolkitName}_`)),
78
+ },
79
+ ];
80
+ };
81
+
82
+function groupByToolkits({
83
+ toolkits,
84
+ ...rest
85
+}: CreateToolkitIndexInput): GroupByToolkitOutput<ToolkitName>[] {
86
+ return toolkits.map(toolkit => groupByToolkit(toolkit)(rest));
87
+}
ts/packages/cli/src/generation/python/generate-toolkit-sources.ts
new
+80
@@ -0,0 +1,80 @@
1
+/**
2
+ * @example
3
+ *
4
+ * ```python
5
+ * class ABLY:
6
+ * """Map of Composio's ABLY toolkit."""
7
+ *
8
+ * slug: str = "ably"
9
+ *
10
+ * class tools:
11
+ * BATCH_PRESENCE = "ABLY_BATCH_PRESENCE"
12
+ * BATCH_PRESENCE_HISTORY = "ABLY_BATCH_PRESENCE_HISTORY"
13
+ * CREATE_CHANNEL = "ABLY_CREATE_CHANNEL"
14
+ * DELETE_CHANNEL_SUBSCRIPTION = "ABLY_DELETE_CHANNEL_SUBSCRIPTION"
15
+ *
16
+ * class triggers:
17
+ * pass
18
+ * ```
19
+ */
20
+
21
+import { pipe, Record } from 'effect';
22
+import type { ToolkitName } from 'src/models/toolkits';
23
+import type { ToolkitIndex, ToolkitIndexData } from '../create-toolkit-index';
24
+
25
+type SourceFile = [filename: string, content: string];
26
+
27
+/**
28
+ * Generates a list of Python source files that should be written to disk by the caller.
29
+ */
30
+export function generatePythonToolkitSources(index: ToolkitIndex): Array<SourceFile> {
31
+ return pipe(index, Record.mapEntries(generatePythonToolkitSource), Record.toEntries);
32
+}
33
+
34
+function generatePythonToolkitSource(
35
+ toolkit: ToolkitIndexData,
36
+ toolkitName: ToolkitName
37
+): SourceFile {
38
+ const filename = `${toolkit.slug}.py`;
39
+
40
+ const toolsEntries = (spacing: number) => {
41
+ const spacePad = ' '.repeat(spacing);
42
+
43
+ if (Record.size(toolkit.tools) > 0) {
44
+ return Object.entries(toolkit.tools)
45
+ .map(([toolName, toolValue]) => `${spacePad}${toolName} = "${toolValue}"`)
46
+ .join('\n');
47
+ }
48
+
49
+ return `${spacePad}pass`;
50
+ };
51
+
52
+ const triggerTypesEntries = (spacing: number) => {
53
+ const spacePad = ' '.repeat(spacing);
54
+
55
+ if (Record.size(toolkit.triggerTypes) > 0) {
56
+ return Object.entries(toolkit.triggerTypes)
57
+ .map(([triggerName, triggerValue]) => `${spacePad}${triggerName} = "${triggerValue}"`)
58
+ .join('\n');
59
+ }
60
+
61
+ return `${spacePad}pass`;
62
+ };
63
+
64
+ const filesource = `# Auto-generated by Composio CLI via \`composio py generate\`.
65
+# Do not modify manually.
66
+
67
+class ${toolkitName}:
68
+ """Map of Composio's ${toolkitName} toolkit."""
69
+
70
+ slug: str = "${toolkit.slug}"
71
+
72
+ class tools:
73
+${toolsEntries(8)}
74
+
75
+ class triggers:
76
+${triggerTypesEntries(8)}
77
+`;
78
+
79
+ return [filename, filesource];
80
+}
ts/packages/cli/src/generation/typescript/generate-index-source.ts
new
+142
@@ -0,0 +1,142 @@
1
+/**
2
+ * @example
3
+ *
4
+ * ```typescript
5
+ * // Map of Composio's ABLY toolkit.
6
+ * export const ABLY = {
7
+ * slug: "ably",
8
+ * tools: {
9
+ * BATCH_PRESENCE: "ABLY_BATCH_PRESENCE",
10
+ * BATCH_PRESENCE_HISTORY: "ABLY_BATCH_PRESENCE_HISTORY",
11
+ * CREATE_CHANNEL: "ABLY_CREATE_CHANNEL",
12
+ * DELETE_CHANNEL_SUBSCRIPTION: "ABLY_DELETE_CHANNEL_SUBSCRIPTION",
13
+ * GET_CHANNEL_DETAILS: "ABLY_GET_CHANNEL_DETAILS",
14
+ * GET_CHANNEL_HISTORY: "ABLY_GET_CHANNEL_HISTORY",
15
+ * GET_PRESENCE_HISTORY: "ABLY_GET_PRESENCE_HISTORY",
16
+ * GET_SERVICE_TIME: "ABLY_GET_SERVICE_TIME",
17
+ * GET_STATS: "ABLY_GET_STATS",
18
+ * LIST_PUSH_CHANNEL_SUBSCRIPTIONS: "ABLY_LIST_PUSH_CHANNEL_SUBSCRIPTIONS",
19
+ * PUBLISH_MESSAGE_TO_CHANNEL: "ABLY_PUBLISH_MESSAGE_TO_CHANNEL",
20
+ * },
21
+ * triggerTypes: {},
22
+ * }
23
+ * ```
24
+ */
25
+
26
+import * as ts from '@composio/ts-builders';
27
+import { pipe, Record, Array as Arr } from 'effect';
28
+import type { ToolkitIndex } from '../create-toolkit-index';
29
+
30
+type generateTypeScriptIndexMapSourceParams = {
31
+ banner: string;
32
+ emitSingleFile: boolean;
33
+};
34
+
35
+export function generateIndexSource(params: generateTypeScriptIndexMapSourceParams) {
36
+ return (index: ToolkitIndex) => {
37
+ const indexMap = generateTypeScriptIndexMapSource(params)(index);
38
+ const toolkitUnionType = generateToolkitUnionType(index);
39
+ const toolsByToolkitType = generateToolsByToolkitType();
40
+
41
+ const indexMapWithBanner = params.emitSingleFile
42
+ ? indexMap
43
+ : `${ts.stringify(ts.docComment(params.banner))}
44
+${indexMap}`;
45
+
46
+ // Add the Toolkit type to the generated code
47
+ const code = `${indexMapWithBanner}
48
+${ts.stringify(ts.docComment('Type declarations'))}
49
+${toolkitUnionType}
50
+${toolsByToolkitType}
51
+`;
52
+
53
+ return code;
54
+ };
55
+}
56
+
57
+/**
58
+ * Generates a list of Python source files that should be written to disk by the caller.
59
+ */
60
+export function generateTypeScriptIndexMapSource(params: generateTypeScriptIndexMapSourceParams) {
61
+ return (index: ToolkitIndex): string => {
62
+ const indexMapEntries = pipe(
63
+ index,
64
+ Record.map((_, key) => ts.propertyValue(key, ts.namedValue(key as string))),
65
+ Record.toEntries,
66
+ Arr.map(([_, value]) => value)
67
+ );
68
+
69
+ const indexMapFile = ts.file();
70
+
71
+ for (const [toolkitName, value] of Record.toEntries(index)) {
72
+ // Note: imports needd to be skipped when generating a single file
73
+ if (params.emitSingleFile) {
74
+ break;
75
+ }
76
+
77
+ indexMapFile.addImport(ts.moduleImport(`./${value.slug}.ts`).named(toolkitName));
78
+ }
79
+
80
+ indexMapFile.add(
81
+ ts
82
+ .moduleExport(
83
+ ts.constDeclaration('composio').setValue(ts.objectValue().addMultiple(indexMapEntries))
84
+ )
85
+ .setDocComment(ts.docComment('Map of Composio toolkits to actions.'))
86
+ );
87
+
88
+ const indexMapFileSource = ts.stringify(indexMapFile);
89
+
90
+ return indexMapFileSource;
91
+ };
92
+}
93
+
94
+export function generateToolkitUnionType(index: ToolkitIndex): string {
95
+ const toolkitModules = pipe(
96
+ index,
97
+ Record.toEntries,
98
+ Arr.map(([key, _]) => key)
99
+ );
100
+
101
+ const file = ts.file();
102
+ const doc = ts.docComment('Union of all available toolkits.');
103
+
104
+ file.add(
105
+ ts
106
+ .moduleExport(
107
+ ts.typeDeclaration(
108
+ 'Toolkit',
109
+ toolkitModules.length === 0
110
+ ? ts.neverType
111
+ : ts.unionType(toolkitModules.map(slug => ts.stringLiteral(slug))).formatMultiline()
112
+ )
113
+ )
114
+ .setDocComment(doc)
115
+ );
116
+
117
+ return ts.stringify(file);
118
+}
119
+
120
+export function generateToolsByToolkitType(): string {
121
+ const file = ts.file();
122
+ const doc = ts.docComment('Given a toolkit, returns the tools available for that toolkit.');
123
+
124
+ file.add(
125
+ ts
126
+ .moduleExport(
127
+ ts
128
+ .typeDeclaration(
129
+ 'ToolsByToolkit',
130
+ ts.typeOfType(ts.keyType(ts.namedType('composio'), ts.namedType('Toolkit')))
131
+ )
132
+ .addGenericParameter(
133
+ ts
134
+ .genericParameter('Toolkit')
135
+ .extends(ts.keyOfType(ts.typeOfType(ts.namedType('composio'))))
136
+ )
137
+ )
138
+ .setDocComment(doc)
139
+ );
140
+
141
+ return ts.stringify(file);
142
+}
ts/packages/cli/src/generation/typescript/generate-toolkit-sources.ts
new
+104
@@ -0,0 +1,104 @@
1
+/**
2
+ * @example
3
+ *
4
+ * ```typescript
5
+ * // Map of Composio's ABLY toolkit.
6
+ * export const ABLY = {
7
+ * slug: "ably",
8
+ * tools: {
9
+ * BATCH_PRESENCE: "ABLY_BATCH_PRESENCE",
10
+ * BATCH_PRESENCE_HISTORY: "ABLY_BATCH_PRESENCE_HISTORY",
11
+ * CREATE_CHANNEL: "ABLY_CREATE_CHANNEL",
12
+ * DELETE_CHANNEL_SUBSCRIPTION: "ABLY_DELETE_CHANNEL_SUBSCRIPTION",
13
+ * GET_CHANNEL_DETAILS: "ABLY_GET_CHANNEL_DETAILS",
14
+ * GET_CHANNEL_HISTORY: "ABLY_GET_CHANNEL_HISTORY",
15
+ * GET_PRESENCE_HISTORY: "ABLY_GET_PRESENCE_HISTORY",
16
+ * GET_SERVICE_TIME: "ABLY_GET_SERVICE_TIME",
17
+ * GET_STATS: "ABLY_GET_STATS",
18
+ * LIST_PUSH_CHANNEL_SUBSCRIPTIONS: "ABLY_LIST_PUSH_CHANNEL_SUBSCRIPTIONS",
19
+ * PUBLISH_MESSAGE_TO_CHANNEL: "ABLY_PUBLISH_MESSAGE_TO_CHANNEL",
20
+ * },
21
+ * triggerTypes: {},
22
+ * }
23
+ * ```
24
+ */
25
+
26
+import * as ts from '@composio/ts-builders';
27
+import { pipe, Record } from 'effect';
28
+import type { ToolkitName } from 'src/models/toolkits';
29
+import type { ToolkitIndex, ToolkitIndexData } from '../create-toolkit-index';
30
+
31
+type SourceFile = [filename: string, content: string];
32
+
33
+type GenerateTypeScriptToolkitSourcesInput = {
34
+ banner: string;
35
+ emitSingleFile: boolean;
36
+ outputDir: string;
37
+};
38
+
39
+/**
40
+ * Generates a list of Python source files that should be written to disk by the caller.
41
+ */
42
+export function generateTypeScriptToolkitSources(params: GenerateTypeScriptToolkitSourcesInput) {
43
+ return (index: ToolkitIndex): Array<SourceFile> => {
44
+ const toolkitSources = pipe(
45
+ index,
46
+ Record.mapEntries(generateTypeScriptToolkitSource(params)),
47
+ Record.toEntries
48
+ );
49
+
50
+ return toolkitSources;
51
+ };
52
+}
53
+
54
+function generateTypeScriptToolkitSource(_params: GenerateTypeScriptToolkitSourcesInput) {
55
+ return (
56
+ { slug, tools, triggerTypes }: ToolkitIndexData,
57
+ toolkitName: ToolkitName
58
+ ): SourceFile => {
59
+ const filename = `${slug}.ts`;
60
+
61
+ const file = ts.file();
62
+
63
+ const entry = ts.propertyValue(
64
+ toolkitName,
65
+ ts
66
+ .objectValue()
67
+ .add(ts.propertyValue('slug', ts.stringLiteral(slug).asValue()))
68
+ .add(
69
+ ts.propertyValue(
70
+ 'tools',
71
+ ts
72
+ .objectValue()
73
+ .addMultiple(
74
+ Object.entries(tools).map(([toolName, tool]) =>
75
+ ts.propertyValue(toolName, ts.stringLiteral(tool).asValue())
76
+ )
77
+ )
78
+ )
79
+ )
80
+ .add(
81
+ ts.propertyValue(
82
+ 'triggerTypes',
83
+ ts
84
+ .objectValue()
85
+ .addMultiple(
86
+ Object.entries(triggerTypes).map(([triggerTypeSlug, triggerType]) =>
87
+ ts.propertyValue(triggerTypeSlug, ts.stringLiteral(triggerType).asValue())
88
+ )
89
+ )
90
+ )
91
+ )
92
+ );
93
+
94
+ file.add(
95
+ ts
96
+ .moduleExport(ts.constDeclaration(entry.name as string).setValue(entry.value))
97
+ .setDocComment(ts.docComment(`Map of Composio's ${entry.name} toolkit.`))
98
+ );
99
+
100
+ const filesource = ts.stringify(file);
101
+
102
+ return [filename, filesource];
103
+ };
104
+}
ts/packages/cli/src/generation/typescript/generate.ts
new
+37
@@ -0,0 +1,37 @@
1
+import * as ts from '@composio/ts-builders';
2
+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
+
7
+type GenerateTypeScriptSourcesParams = {
8
+ banner: string;
9
+ emitSingleFile: boolean;
10
+ outputDir: string;
11
+};
12
+
13
+export function generateTypeScriptSources(params: GenerateTypeScriptSourcesParams) {
14
+ return (index: ToolkitIndex): Array<readonly [string, string]> => {
15
+ const toolkiteSources = generateTypeScriptToolkitSources(params)(index);
16
+
17
+ const indexSource = generateIndexSource(params)(index);
18
+ const indexFilename = path.join(params.outputDir, 'index.ts');
19
+
20
+ if (!params.emitSingleFile) {
21
+ return [
22
+ ...toolkiteSources.map(
23
+ ([filename, content]) => [path.join(params.outputDir, filename), content] as const
24
+ ),
25
+ [indexFilename, indexSource] as const,
26
+ ] as const;
27
+ }
28
+
29
+ const localToolkitsSources = toolkiteSources.map(([_, content]) => content).join('\n');
30
+
31
+ const indexSourceSingleFile = `${ts.stringify(ts.docComment(params.banner))}
32
+${localToolkitsSources}
33
+${indexSource}
34
+`;
35
+ return [[indexFilename, indexSourceSingleFile] as const];
36
+ };
37
+}
ts/packages/cli/src/models/session.ts
new
+51
@@ -0,0 +1,51 @@
1
+import { Schema } from 'effect';
2
+import { JSONTransformSchema } from './utils/json-transform-schema';
3
+
4
+export const Session = Schema.Struct({
5
+ id: Schema.String,
6
+ code: Schema.String,
7
+ expiresAt: Schema.DateTimeUtc,
8
+ status: Schema.Literal('pending', 'linked'),
9
+}).annotations({ identifier: 'Session' });
10
+export type Session = Schema.Schema.Type<typeof Session>;
11
+
12
+export const SessionJSON = JSONTransformSchema(Session);
13
+export const sessionFromJSON = Schema.decode(SessionJSON);
14
+export const sessionToJSON = Schema.encode(SessionJSON);
15
+
16
+const SessionAccount = Schema.Struct({
17
+ id: Schema.String,
18
+ email: Schema.String,
19
+ name: Schema.String,
20
+}).annotations({ identifier: 'SessionAccount' });
21
+export type SessionAccount = Schema.Schema.Type<typeof SessionAccount>;
22
+
23
+export const LinkedSession = Session.omit('status')
24
+ .pipe(
25
+ Schema.extend(
26
+ Schema.Struct({
27
+ status: Schema.Literal('linked'),
28
+ account: SessionAccount.annotations({ identifier: 'LinkedSession.Account' }),
29
+ })
30
+ )
31
+ )
32
+ .annotations({ identifier: 'LinkedSession' });
33
+export type LinkedSession = Schema.Schema.Type<typeof LinkedSession>;
34
+
35
+export const LinkedSessionJSON = JSONTransformSchema(LinkedSession);
36
+export const LinkedSessionFromJSON = Schema.decode(LinkedSessionJSON);
37
+export const LinkedSessionToJSON = Schema.encode(LinkedSessionJSON);
38
+
39
+export const RetrievedSession = Schema.Union(
40
+ Schema.Struct({ ...Session.fields, status: Schema.Literal('pending') }),
41
+ Schema.Struct({
42
+ ...Session.fields,
43
+ account: SessionAccount.annotations({ identifier: 'RetrievedSession.Account' }),
44
+ status: Schema.Literal('linked'),
45
+ })
46
+).annotations({ identifier: 'RetrievedSession' });
47
+export type RetrievedSession = Schema.Schema.Type<typeof RetrievedSession>;
48
+
49
+export const RetrievedSessionJSON = JSONTransformSchema(RetrievedSession);
50
+export const retrievedSessionFromJSON = Schema.decode(RetrievedSessionJSON);
51
+export const retrievedSessionToJSON = Schema.encode(RetrievedSessionJSON);
ts/packages/cli/src/models/toolkits.ts
new
+28
@@ -0,0 +1,28 @@
1
+import { Brand, Schema } from 'effect';
2
+import { JSONTransformSchema } from './utils/json-transform-schema';
3
+
4
+export const Toolkit = Schema.Struct({
5
+ name: Schema.String, // "Gmail"
6
+ slug: Schema.String, // "gmail"
7
+ auth_schemes: Schema.Array(Schema.String), // [ "OAUTH2", "BEARER_TOKEN" ]
8
+ composio_managed_auth_schemes: Schema.Array(Schema.String), // [ "OAUTH2" ]
9
+ is_local_toolkit: Schema.Boolean,
10
+ meta: Schema.Struct({
11
+ description: Schema.String,
12
+ categories: Schema.Array(Schema.Unknown),
13
+ created_at: Schema.DateTimeUtc, // "2024-05-03T11:44:32.061Z"
14
+ updated_at: Schema.DateTimeUtc, // "2024-05-03T11:44:32.061Z"
15
+ }),
16
+ no_auth: Schema.Boolean,
17
+}).annotations({ identifier: 'Toolkit' });
18
+export type Toolkit = Schema.Schema.Type<typeof Toolkit>;
19
+
20
+export const Toolkits = Schema.Array(Toolkit);
21
+export type Toolkits = Schema.Schema.Type<typeof Toolkits>;
22
+
23
+export const ToolkitsJSON = JSONTransformSchema(Toolkits);
24
+export const toolkitsFromJSON = Schema.decode(ToolkitsJSON);
25
+export const toolkitsToJSON = Schema.encode(ToolkitsJSON);
26
+
27
+export type ToolkitName = string & Brand.Brand<'ToolkitName'>;
28
+export const ToolkitName = Brand.nominal<ToolkitName>();
ts/packages/cli/src/models/tools.ts
new
+20
@@ -0,0 +1,20 @@
1
+import { Brand, Schema } from 'effect';
2
+import { JSONTransformSchema } from './utils/json-transform-schema';
3
+
4
+export const Tool = Schema.String;
5
+export type Tool = Schema.Schema.Type<typeof Tool>;
6
+
7
+export const Tools = Schema.Array(Tool);
8
+export type Tools = Schema.Schema.Type<typeof Tools>;
9
+
10
+export const ToolsJSON = JSONTransformSchema(Tools);
11
+export const toolsFromJSON = Schema.decode(ToolsJSON);
12
+export const toolsToJSON = Schema.encode(ToolsJSON);
13
+
14
+// E.g., `SEND_EMAIL`
15
+export type ToolName = string & Brand.Brand<'ToolName'>;
16
+export const ToolName = Brand.nominal<ToolName>();
17
+
18
+// E.g., `GMAIL_SEND_EMAIL`
19
+export type ToolNameWithToolkitPrefix = string & Brand.Brand<'ToolNameWithToolkitPrefix'>;
20
+export const ToolNameWithToolkitPrefix = Brand.nominal<ToolNameWithToolkitPrefix>();
ts/packages/cli/src/models/trigger-types.ts
new
+21
@@ -0,0 +1,21 @@
1
+import { Brand, Schema } from 'effect';
2
+import { JSONTransformSchema } from './utils/json-transform-schema';
3
+
4
+export const TriggerType = Schema.String;
5
+export type TriggerType = Schema.Schema.Type<typeof TriggerType>;
6
+
7
+export const TriggerTypes = Schema.Array(TriggerType);
8
+export type TriggerTypes = Schema.Schema.Type<typeof TriggerTypes>;
9
+
10
+export const TriggerTypesJSON = JSONTransformSchema(TriggerTypes);
11
+export const triggerTypesFromJSON = Schema.decode(TriggerTypesJSON);
12
+export const triggerTypesToJSON = Schema.encode(TriggerTypesJSON);
13
+
14
+// E.g., `NEW_EMAIL`
15
+export type TriggerTypeName = string & Brand.Brand<'TriggerTypeName'>;
16
+export const TriggerTypeName = Brand.nominal<TriggerTypeName>();
17
+
18
+// E.g., `GMAIL_NEW_EMAIL`
19
+export type TriggerTypeNameWithToolkitPrefix = string &
20
+ Brand.Brand<'TriggerTypeNameWithToolkitPrefix'>;
21
+export const TriggerTypeNameWithToolkitPrefix = Brand.nominal<TriggerTypeNameWithToolkitPrefix>();
ts/packages/cli/src/models/utils/json-transform-schema.ts
new
+18
@@ -0,0 +1,18 @@
1
+import { Schema, ParseResult } from 'effect';
2
+import superjson from 'superjson';
3
+
4
+export function JSONTransformSchema<To extends Schema.Schema.Any>(to: To) {
5
+ return Schema.transformOrFail(Schema.String, to, {
6
+ strict: true,
7
+ encode: (obj, _options, ast) =>
8
+ ParseResult.try({
9
+ try: () => superjson.stringify(obj),
10
+ catch: e => new ParseResult.Type(ast, obj, (e as Error).message),
11
+ }),
12
+ decode: (str, _options, ast) =>
13
+ ParseResult.try({
14
+ try: () => superjson.parse(str),
15
+ catch: e => new ParseResult.Type(ast, str, (e as Error).message),
16
+ }),
17
+ });
18
+}
ts/packages/cli/src/services/composio-clients.ts
new
+191
@@ -0,0 +1,191 @@
1
+import { pipe, Data, Effect, Option, Schema, Array, Order } from 'effect';
2
+import { APP_CONFIG } from 'src/effects/app-config';
3
+import { Composio as _RawComposioClient } from '@composio/client';
4
+import { Toolkit, Toolkits } from 'src/models/toolkits';
5
+import { Tools } from 'src/models/tools';
6
+import { LinkedSession, Session, RetrievedSession } from 'src/models/session';
7
+import { TriggerType } from 'src/models/trigger-types';
8
+
9
+/**
10
+ * Error types
11
+ */
12
+
13
+/**
14
+ * Error thrown when a HTTP request fails.
15
+ */
16
+export class HttpServerError extends Data.TaggedError('services/HttpServerError')<{
17
+ readonly cause: Error;
18
+ readonly message: string;
19
+}> {}
20
+
21
+/**
22
+ * Error thrown when a HTTP response doesn't match the expected response schema.
23
+ */
24
+export class HttpDecodingError extends Data.TaggedError('services/HttpDecodingError')<{
25
+ readonly cause: Error;
26
+ readonly message: string;
27
+}> {}
28
+
29
+export type HttpError = HttpServerError | HttpDecodingError;
30
+
31
+/**
32
+ * Response schemas
33
+ */
34
+
35
+export const CliCreateSessionResponse = Session;
36
+export type CliCreateSessionResponse = Schema.Schema.Type<typeof CliCreateSessionResponse>;
37
+
38
+export const CliLinkSessionResponse = LinkedSession;
39
+export type CliLinkSessionResponse = Schema.Schema.Type<typeof CliLinkSessionResponse>;
40
+
41
+export const CliRetrieveSessionResponse = RetrievedSession;
42
+export type CliRetrieveSessionResponse = Schema.Schema.Type<typeof CliRetrieveSessionResponse>;
43
+
44
+export const ToolkitsResponse = Schema.Struct({
45
+ items: Toolkits,
46
+ total_pages: Schema.Int,
47
+ next_cursor: Schema.NullOr(Schema.Int),
48
+}).annotations({ identifier: 'ToolkitsResponse' });
49
+export type ToolkitsResponse = Schema.Schema.Type<typeof ToolkitsResponse>;
50
+
51
+export const ToolsResponse = Tools;
52
+export type ToolsResponse = Schema.Schema.Type<typeof ToolsResponse>;
53
+
54
+export const TriggerTypesResponse = Schema.Array(TriggerType);
55
+export type TriggerResponse = Schema.Schema.Type<typeof TriggerTypesResponse>;
56
+
57
+/**
58
+ * Utilities
59
+ */
60
+
61
+// Utility function for calling the Composio API and decoding its response.
62
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
63
+const callClient = <T, S extends Schema.Schema<any, any>>(
64
+ apiCall: () => Promise<T>,
65
+ responseSchema: S
66
+): Effect.Effect<Schema.Schema.Type<S>, HttpError> =>
67
+ pipe(
68
+ Effect.tryPromise({
69
+ try: apiCall,
70
+ catch: error => {
71
+ const e = error as Error;
72
+ return new HttpServerError({
73
+ cause: e,
74
+ message: e.message,
75
+ });
76
+ },
77
+ }),
78
+ Effect.flatMap(json => Schema.decodeUnknown(responseSchema)(json)),
79
+ Effect.catchTag('ParseError', e => {
80
+ return new HttpDecodingError({
81
+ cause: e,
82
+ message: e.message,
83
+ });
84
+ })
85
+ );
86
+
87
+/**
88
+ * Services
89
+ */
90
+
91
+// Service that wraps the raw Composio client, which is shared by all client services.
92
+class ComposioClientLive extends Effect.Service<ComposioClientLive>()(
93
+ 'services/ComposioClientLive',
94
+ {
95
+ effect: Effect.gen(function* () {
96
+ const apiKey = yield* APP_CONFIG['API_KEY'];
97
+ const baseURLOpt = yield* APP_CONFIG['BASE_URL'];
98
+ const baseURL = Option.getOrUndefined(baseURLOpt);
99
+
100
+ yield* Effect.logDebug('Creating raw Composio client...');
101
+ const client = new _RawComposioClient({ apiKey, baseURL });
102
+
103
+ return {
104
+ toolkits: {
105
+ /**
106
+ * Retrieves a comprehensive list of toolkits that are available to the authenticated project.
107
+ */
108
+ list: () => callClient(() => client.toolkits.list(), ToolkitsResponse),
109
+ },
110
+ tools: {
111
+ /**
112
+ * Retrieve a list of all available tool enumeration values (tool slugs) for the project.
113
+ */
114
+ retrieveEnum: () => callClient(() => client.tools.retrieveEnum(), ToolsResponse),
115
+ },
116
+ triggersTypes: {
117
+ /**
118
+ * Retrieves a list of all available trigger type enum values that can be used across the API.
119
+ */
120
+ retrieveEnum: () =>
121
+ callClient(() => client.triggersTypes.retrieveEnum(), TriggerTypesResponse),
122
+ },
123
+ v3: {
124
+ cli: {
125
+ /**
126
+ * Generates a new CLI session with a random 6-character code.
127
+ */
128
+ createSession: () =>
129
+ callClient(() => client.v3.cli.createSession(), CliCreateSessionResponse),
130
+
131
+ /**
132
+ * Retrieves the current state of a CLI session using either the session ID (UUID) or the 6-character code.
133
+ */
134
+ retrieveSession: (session: { id: string }) =>
135
+ callClient(() => client.v3.cli.retrieveSession(session), CliRetrieveSessionResponse),
136
+
137
+ /**
138
+ * Links a pending CLI session to the currently authenticated user.
139
+ */
140
+ linkSession: (session: { id: string }) =>
141
+ callClient(() => client.v3.cli.linkSession(session), CliLinkSessionResponse),
142
+ },
143
+ },
144
+ };
145
+ }),
146
+ dependencies: [],
147
+ }
148
+) {}
149
+
150
+export class ComposioToolkitsRepository extends Effect.Service<ComposioToolkitsRepository>()(
151
+ 'services/ComposioToolkitsRepository',
152
+ {
153
+ effect: Effect.gen(function* () {
154
+ const client = yield* ComposioClientLive;
155
+
156
+ return {
157
+ getToolkits: () =>
158
+ client.toolkits.list().pipe(
159
+ Effect.map(response => response.items),
160
+ Effect.flatMap(toolkits =>
161
+ Effect.gen(function* () {
162
+ // Sort apps by slug
163
+ const orderBySlug = Order.mapInput(Order.string, (app: Toolkit) => app.slug);
164
+ return Array.sort(toolkits, orderBySlug);
165
+ })
166
+ )
167
+ ),
168
+ getTools: () => client.tools.retrieveEnum(),
169
+ getTriggerTypes: () => client.triggersTypes.retrieveEnum(),
170
+ };
171
+ }),
172
+ dependencies: [ComposioClientLive.Default],
173
+ }
174
+) {}
175
+
176
+export class ComposioSessionRepository extends Effect.Service<ComposioSessionRepository>()(
177
+ 'services/ComposioSessionRepository',
178
+ {
179
+ effect: Effect.gen(function* () {
180
+ const client = yield* ComposioClientLive;
181
+
182
+ return {
183
+ createSession: () => client.v3.cli.createSession(),
184
+ retrieveSession: (session: { id: string }) =>
185
+ client.v3.cli.retrieveSession({ id: session.id }),
186
+ linkSession: (session: { id: string }) => client.v3.cli.linkSession({ id: session.id }),
187
+ };
188
+ }),
189
+ dependencies: [ComposioClientLive.Default],
190
+ }
191
+) {}
ts/packages/cli/src/services/env-lang-detector.ts
new
+219
@@ -0,0 +1,219 @@
1
+import { BunFileSystem } from '@effect/platform-bun';
2
+import { pipe, Data, Effect } from 'effect';
3
+import { FileSystem } from '@effect/platform';
4
+
5
+export class EnvLangDetectorError extends Data.TaggedError('services/DetectEnvLangError')<{
6
+ readonly cause: Error;
7
+ readonly message: string;
8
+}> {}
9
+
10
+// Service that attempts to detect the language of the project in the current working directory.
11
+export class EnvLangDetector extends Effect.Service<EnvLangDetector>()('services/EnvLangDetector', {
12
+ effect: Effect.gen(function* () {
13
+ const fs = yield* FileSystem.FileSystem;
14
+
15
+ return {
16
+ detectEnvLanguage: (cwd: string) =>
17
+ Effect.gen(function* () {
18
+ const files = yield* pipe(
19
+ fs.readDirectory(cwd),
20
+ Effect.catchAll(e =>
21
+ Effect.fail(
22
+ new EnvLangDetectorError({ cause: e, message: `Failed to read directory ${cwd}` })
23
+ )
24
+ )
25
+ );
26
+
27
+ // Convert to lowercase for case-insensitive comparison
28
+ const fileNames = files.map(f => f.toLowerCase());
29
+ yield* Effect.logDebug(`Files in directory ${cwd}:\n${fileNames.join('\n')}`);
30
+
31
+ // TypeScript project indicators (in order of precedence)
32
+ const typescriptIndicators = [
33
+ 'tsconfig.json',
34
+ 'package.json',
35
+ 'yarn.lock',
36
+ 'package-lock.json',
37
+ 'pnpm-lock.yaml',
38
+ 'bun.lockb',
39
+ 'deno.json',
40
+ 'deno.jsonc',
41
+ ];
42
+
43
+ // Python project indicators (in order of precedence)
44
+ const pythonIndicators = [
45
+ 'pyproject.toml',
46
+ 'setup.py',
47
+ 'requirements.txt',
48
+ 'pipfile',
49
+ 'pipfile.lock',
50
+ 'poetry.lock',
51
+ 'conda.yaml',
52
+ 'environment.yml',
53
+ 'setup.cfg',
54
+ 'tox.ini',
55
+ 'pytest.ini',
56
+ '__pycache__',
57
+ ];
58
+
59
+ // Check for TypeScript indicators first
60
+ const hasTypescriptIndicator = typescriptIndicators.some(indicator =>
61
+ fileNames.includes(indicator)
62
+ );
63
+
64
+ // Check for Python indicators
65
+ const hasPythonIndicator = pythonIndicators.some(indicator =>
66
+ fileNames.includes(indicator)
67
+ );
68
+
69
+ yield* Effect.logDebug(`TypeScript indicators found: ${hasTypescriptIndicator}`);
70
+ yield* Effect.logDebug(`Python indicators found: ${hasPythonIndicator}`);
71
+
72
+ // Additional checks for file extensions if no clear indicators found
73
+ if (!hasTypescriptIndicator && !hasPythonIndicator) {
74
+ // Get actual file names (not lowercase) for extension checking
75
+ const hasTypeScriptFiles = files.some(
76
+ file =>
77
+ file.endsWith('.ts') ||
78
+ file.endsWith('.tsx') ||
79
+ file.endsWith('.mts') ||
80
+ file.endsWith('.cts')
81
+ );
82
+
83
+ const hasPythonFiles = files.some(
84
+ file =>
85
+ file.endsWith('.py') ||
86
+ file.endsWith('.pyw') ||
87
+ file.endsWith('.pyi') ||
88
+ file.endsWith('.pyx')
89
+ );
90
+
91
+ if (hasTypeScriptFiles && !hasPythonFiles) {
92
+ return 'TypeScript' as const;
93
+ }
94
+
95
+ if (hasPythonFiles && !hasTypeScriptFiles) {
96
+ return 'Python' as const;
97
+ }
98
+
99
+ // If both or neither are found, check for more files by reading subdirectories
100
+ // This is a more exhaustive check
101
+ const allFiles: string[] = [];
102
+
103
+ // Don't recurse into common directories that might contain false positives
104
+ const skipDirs = [
105
+ '.composio',
106
+ 'node_modules',
107
+ '.git',
108
+ '__pycache__',
109
+ '.venv',
110
+ 'venv',
111
+ 'env',
112
+ 'dist',
113
+ 'build',
114
+ ];
115
+
116
+ // Recursively collect files from immediate subdirectories
117
+ yield* Effect.logInfo('Checking subdirectories for more files...');
118
+
119
+ for (const item of files) {
120
+ const itemPath = `${cwd}/${item}`;
121
+ const stat = yield* pipe(
122
+ fs.stat(cwd),
123
+ Effect.catchAll(e =>
124
+ Effect.fail(
125
+ new EnvLangDetectorError({
126
+ cause: e,
127
+ message: `Failed to read file ${itemPath}`,
128
+ })
129
+ )
130
+ )
131
+ );
132
+
133
+ if (stat.type === 'Directory') {
134
+ if (!skipDirs.includes(item.toLowerCase())) {
135
+ const subFiles = yield* pipe(
136
+ fs.readDirectory(item),
137
+ Effect.catchAll(e =>
138
+ Effect.fail(
139
+ new EnvLangDetectorError({
140
+ cause: e,
141
+ message: `Failed to read directory ${item}`,
142
+ })
143
+ )
144
+ )
145
+ );
146
+ allFiles.push(...subFiles);
147
+ }
148
+ }
149
+ }
150
+
151
+ const allFileNames = [...files, ...allFiles];
152
+
153
+ const deepTsFiles = allFileNames.filter(
154
+ file =>
155
+ file.endsWith('.ts') ||
156
+ file.endsWith('.tsx') ||
157
+ file.endsWith('.mts') ||
158
+ file.endsWith('.cts')
159
+ ).length;
160
+
161
+ const deepPyFiles = allFileNames.filter(
162
+ file =>
163
+ file.endsWith('.py') ||
164
+ file.endsWith('.pyw') ||
165
+ file.endsWith('.pyi') ||
166
+ file.endsWith('.pyx')
167
+ ).length;
168
+
169
+ // Decide based on which has more files
170
+ if (deepTsFiles > deepPyFiles && deepTsFiles > 0) {
171
+ return 'TypeScript' as const;
172
+ }
173
+
174
+ if (deepPyFiles > deepTsFiles && deepPyFiles > 0) {
175
+ return 'Python' as const;
176
+ }
177
+ }
178
+
179
+ // Prioritize based on strength of indicators
180
+ if (hasTypescriptIndicator && hasPythonIndicator) {
181
+ // Both present - prioritize based on most definitive files
182
+ const strongTsIndicators = ['tsconfig.json', 'package.json'];
183
+ const strongPyIndicators = ['pyproject.toml', 'setup.py'];
184
+
185
+ const hasStrongTs = strongTsIndicators.some(indicator => fileNames.includes(indicator));
186
+ const hasStrongPy = strongPyIndicators.some(indicator => fileNames.includes(indicator));
187
+
188
+ if (hasStrongTs && !hasStrongPy) {
189
+ return 'TypeScript' as const;
190
+ }
191
+ if (hasStrongPy && !hasStrongTs) {
192
+ return 'Python' as const;
193
+ }
194
+
195
+ // If both have strong indicators, default to TypeScript
196
+ // (this is arbitrary but package.json is very common)
197
+ return 'TypeScript' as const;
198
+ }
199
+
200
+ if (hasTypescriptIndicator) {
201
+ return 'TypeScript' as const;
202
+ }
203
+
204
+ if (hasPythonIndicator) {
205
+ return 'Python' as const;
206
+ }
207
+
208
+ // No clear indicators found
209
+ return yield* Effect.fail(
210
+ new EnvLangDetectorError({
211
+ cause: new Error('Unable to detect project language'),
212
+ message: `Could not determine if directory '${cwd}' contains a Python or TypeScript project. No recognizable project files or patterns found.`,
213
+ })
214
+ );
215
+ }),
216
+ };
217
+ }),
218
+ dependencies: [BunFileSystem.layer],
219
+}) {}
ts/packages/cli/src/services/node-process.ts
new
+12
@@ -0,0 +1,12 @@
1
+import process from 'node:process';
2
+import { Effect } from 'effect';
3
+
4
+// Service to that wraps `node:process`, for testing purposes.
5
+export class NodeProcess extends Effect.Service<NodeProcess>()('services/NodeProcess', {
6
+ sync: () => ({
7
+ cwd: process.cwd(),
8
+ platform: process.platform,
9
+ arch: process.arch,
10
+ }),
11
+ dependencies: [],
12
+}) {}
ts/packages/cli/src/services/user-config.ts
new
+95
@@ -0,0 +1,95 @@
1
+import path from 'node:path';
2
+import { Option, Effect, ConfigProvider, Layer, Logger } from 'effect';
3
+import * as constants from 'src/constants';
4
+import { DEBUG_OVERRIDE_CONFIG } from 'src/effects/debug-config';
5
+import { configProviderFromLazyJson } from 'src/effects/from-lazy-json';
6
+import { APP_CONFIG } from 'src/effects/app-config';
7
+import { setupCacheDir } from 'src/effects/setup-cache-dir';
8
+
9
+/**
10
+ * Define where `effect/Config` reads config values from.
11
+ * Lookup priority:
12
+ * 1. Environment variables
13
+ * 2. JSON user file (lazily loaded only when absolutely needed)
14
+ *
15
+ * Environment variables' keys are in upper snake case.
16
+ * They are prefixed with `COMPOSIO_`, with the only exception of `DEBUG_*` variables.
17
+ * The prefix is stripped when reading the environment variables from `effect/Config`.
18
+ *
19
+ * @example
20
+ * ```sh
21
+ * # Environment variable
22
+ * COMPOSIO_API_KEY=your_api_key
23
+ * ```
24
+ *
25
+ * ```jsonc
26
+ * // JSON User config file
27
+ * {
28
+ * "api_key": "your_api_key"
29
+ * }
30
+ * ```
31
+ *
32
+ * Read via `yield* Config.string('API_KEY')`.
33
+ */
34
+const ConfigProviderLive = Effect.gen(function* () {
35
+ // TODO: fix this to avoid `API_KEY` errors when using commands that don't need it.
36
+ const cacheDir = yield* setupCacheDir;
37
+ const jsonUserConfigPath = path.join(cacheDir, constants.USER_CONFIG_FILE_NAME);
38
+ const configProviderFromUserFile = yield* configProviderFromLazyJson(jsonUserConfigPath);
39
+ // const configProviderFromUserFile = yield* configProviderFromLazyJson('/tmp');
40
+
41
+ // start by reading from env vars
42
+ const configProvider = ConfigProvider.fromEnv()
43
+ // prefix env var keys
44
+ .pipe(
45
+ ConfigProvider.mapInputPath(key => {
46
+ if (key.startsWith('DEBUG_OVERRIDE_') || key.startsWith('FORCE_')) {
47
+ return key;
48
+ }
49
+
50
+ return `${constants.APP_ENV_CONFIG_KEY_PREFIX}${key}`;
51
+ })
52
+ )
53
+ // fall back to user config file, which is lazily loaded
54
+ .pipe(
55
+ ConfigProvider.orElse(() => {
56
+ // e.g., read `json['api_key']` as `Config.string('COMPOSIO_API_KEY')`
57
+ return configProviderFromUserFile.pipe(ConfigProvider.snakeCase);
58
+ })
59
+ );
60
+
61
+ return Layer.setConfigProvider(configProvider);
62
+}).pipe(Layer.unwrapEffect);
63
+
64
+/**
65
+ * Tentatively set the minimum log level if found in the config.
66
+ */
67
+const LoggerFromConfigLive = Effect.map(
68
+ APP_CONFIG['LOG_LEVEL'],
69
+ Option.match({
70
+ onNone: () => Layer.empty,
71
+ onSome: logLevel => Logger.minimumLogLevel(logLevel),
72
+ })
73
+).pipe(Layer.unwrapEffect);
74
+
75
+/**
76
+ * Print a debug message for each debug environment variable that overrides dynamic configuration values.
77
+ */
78
+const logDebugOverride = Effect.gen(function* () {
79
+ const debugOverrideEntries = Object.keys(DEBUG_OVERRIDE_CONFIG) as [
80
+ keyof typeof DEBUG_OVERRIDE_CONFIG,
81
+ ];
82
+
83
+ for (const key of debugOverrideEntries) {
84
+ const configEntry = yield* DEBUG_OVERRIDE_CONFIG[key];
85
+ if (Option.isSome(configEntry)) {
86
+ yield* Effect.logDebug(
87
+ `Using \`${constants.DEBUG_OVERRIDE_ENV_CONFIG_KEY_PREFIX}${key}\` debug override`
88
+ );
89
+ }
90
+ }
91
+});
92
+
93
+export const UserConfigLive = Layer.provide(LoggerFromConfigLive, ConfigProviderLive).pipe(
94
+ Layer.tap(() => logDebugOverride)
95
+);
ts/packages/cli/src/type-utils.ts
new
+4
@@ -0,0 +1,4 @@
1
+import type { Command } from '@effect/cli';
2
+
3
+export type GetCmdParams<T> =
4
+ T extends Command.Command<infer _Name extends string, unknown, unknown, infer P> ? P : never;
ts/packages/cli/test/__fixtures__/python-project/requirements.txt
new
+1
@@ -0,0 +1 @@
1
+click=8.1.2
ts/packages/cli/test/__fixtures__/python-project/setup.py
ts/packages/cli/test/__fixtures__/typescript-project/package.json
new
+5
@@ -0,0 +1,5 @@
1
+{
2
+ "devDependencies": {
3
+ "typescript": "^5.8.3"
4
+ }
5
+}
ts/packages/cli/test/__fixtures__/typescript-project/tsconfig.json
new
+20
@@ -0,0 +1,20 @@
1
+{
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "declaration": true,
6
+ "outDir": "./dist",
7
+ "rootDir": "./src",
8
+ "paths": {
9
+ "src/*": ["./src/*"],
10
+ "test/*": ["./test/*"]
11
+ },
12
+ "strict": true,
13
+ "esModuleInterop": true,
14
+ "moduleResolution": "node",
15
+ "skipLibCheck": true,
16
+ "resolveJsonModule": true
17
+ },
18
+ "include": ["src"],
19
+ "exclude": ["**/dist", "**/node_modules", "test/__fixtures__/**"]
20
+}
ts/packages/cli/test/__utils__/cli.ts
new
+10
@@ -0,0 +1,10 @@
1
+import { Effect } from 'effect';
2
+import * as Cli from 'src/commands';
3
+
4
+// Run CLI in test environment
5
+export const cli = (args: ReadonlyArray<string>) =>
6
+ Effect.flatMap(Cli.runWithConfig, run => run(['node', '<CMD>', ...args])) satisfies Effect.Effect<
7
+ void,
8
+ any,
9
+ any
10
+ >;
ts/packages/cli/test/__utils__/index.ts
new
+7
@@ -0,0 +1,7 @@
1
+import pkg from '../../package.json' with { type: 'json' };
2
+
3
+export * as MockConsole from './services/mock-console';
4
+export * as MockTerminal from './services/mock-terminal';
5
+export { TestLayer as TestLive, runEffect } from './services/test-layer';
6
+export { cli } from './cli';
7
+export { pkg };
ts/packages/cli/test/__utils__/models/toolkits.ts
new
+17
@@ -0,0 +1,17 @@
1
+import { Arbitrary, FastCheck } from 'effect';
2
+import { Toolkit } from 'src/models/toolkits';
3
+
4
+const ToolkitArbitary = Arbitrary.make(Toolkit);
5
+
6
+/**
7
+ * Creates test toolkit instances by merging arbitrary generated toolkit data with provided subset values.
8
+ * Useful for generating test data that maintains consistent identifiers while having realistic randomized properties.
9
+ */
10
+export function makeTestToolkits(inputs: Array<Pick<Toolkit, 'name' | 'slug'>>) {
11
+ const samples = FastCheck.sample(ToolkitArbitary, {
12
+ numRuns: inputs.length,
13
+ });
14
+
15
+ const testToolkits = samples.map((sample, i) => ({ ...sample, ...inputs[i] }));
16
+ return testToolkits;
17
+}
ts/packages/cli/test/__utils__/sanitize.ts
new
+9
@@ -0,0 +1,9 @@
1
+import { pipe, Effect, String } from 'effect';
2
+import { getVersion } from 'src/effects/version';
3
+
4
+export const sanitize = (str: string) =>
5
+ Effect.gen(function* () {
6
+ const version = yield* getVersion;
7
+
8
+ return pipe(str, String.replaceAll(version, '<VERSION>'));
9
+ });
ts/packages/cli/test/__utils__/services/mock-console.ts
new
+82
@@ -0,0 +1,82 @@
1
+// Inspired from https://github.com/Effect-TS/effect/blob/a2d57c9ac596445009ca12859b78e00e5d89b936/packages/cli/test/services/MockConsole.ts.
2
+
3
+import * as Array from 'effect/Array';
4
+import * as Console from 'effect/Console';
5
+import * as Context from 'effect/Context';
6
+import * as Effect from 'effect/Effect';
7
+import * as Ref from 'effect/Ref';
8
+
9
+export interface MockConsole extends Console.Console {
10
+ readonly getLines: (
11
+ params?: Partial<{
12
+ readonly stripAnsi: boolean;
13
+ }>
14
+ ) => Effect.Effect<ReadonlyArray<string>>;
15
+}
16
+
17
+export const MockConsole = Context.GenericTag<Console.Console, MockConsole>('effect/Console');
18
+const pattern = new RegExp(
19
+ [
20
+ '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
21
+ '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))',
22
+ ].join('|'),
23
+ 'g'
24
+);
25
+
26
+const stripAnsi = (str: string) => str.replace(pattern, '');
27
+
28
+export const make = Effect.gen(function* () {
29
+ const lines = yield* Ref.make(Array.empty<string>());
30
+
31
+ const getLines: MockConsole['getLines'] = (params = {}) =>
32
+ Ref.get(lines).pipe(
33
+ Effect.map(lines => (params.stripAnsi || false ? Array.map(lines, stripAnsi) : lines))
34
+ );
35
+
36
+ const log: MockConsole['log'] = (...args) => {
37
+ return Ref.update(lines, Array.appendAll(args));
38
+ };
39
+
40
+ const info: MockConsole['info'] = (...args) => {
41
+ return Ref.update(lines, Array.appendAll(args));
42
+ };
43
+
44
+ const warn: MockConsole['warn'] = (...args) => {
45
+ return Ref.update(lines, Array.appendAll(args));
46
+ };
47
+
48
+ const error: MockConsole['error'] = (...args) => {
49
+ return Ref.update(lines, Array.appendAll(args));
50
+ };
51
+
52
+ return MockConsole.of({
53
+ [Console.TypeId]: Console.TypeId,
54
+ getLines,
55
+ log,
56
+ info,
57
+ warn,
58
+ error,
59
+ unsafe: globalThis.console,
60
+ assert: () => Effect.void,
61
+ clear: Effect.void,
62
+ count: () => Effect.void,
63
+ countReset: () => Effect.void,
64
+ debug: () => Effect.void,
65
+ dir: () => Effect.void,
66
+ dirxml: () => Effect.void,
67
+ group: () => Effect.void,
68
+ groupEnd: Effect.void,
69
+ table: () => Effect.void,
70
+ time: () => Effect.void,
71
+ timeEnd: () => Effect.void,
72
+ timeLog: () => Effect.void,
73
+ trace: () => Effect.void,
74
+ });
75
+});
76
+
77
+export const getLines = (
78
+ params?: Partial<{
79
+ readonly stripAnsi?: boolean;
80
+ }>
81
+): Effect.Effect<ReadonlyArray<string>> =>
82
+ Effect.consoleWith(_console => (_console as MockConsole).getLines(params));
ts/packages/cli/test/__utils__/services/mock-terminal.ts
new
+114
@@ -0,0 +1,114 @@
1
+// Copied from https://github.com/Effect-TS/effect/blob/a2d57c9ac596445009ca12859b78e00e5d89b936/packages/cli/test/services/MockTerminal.ts
2
+
3
+import * as Terminal from '@effect/platform/Terminal';
4
+import * as Array from 'effect/Array';
5
+import * as Console from 'effect/Console';
6
+import * as Context from 'effect/Context';
7
+import * as Effect from 'effect/Effect';
8
+import * as Layer from 'effect/Layer';
9
+import * as Option from 'effect/Option';
10
+import * as Queue from 'effect/Queue';
11
+
12
+// =============================================================================
13
+// Models
14
+// =============================================================================
15
+
16
+export interface MockTerminal extends Terminal.Terminal {
17
+ readonly inputText: (text: string) => Effect.Effect<void>;
18
+ readonly inputKey: (
19
+ key: string,
20
+ modifiers?: Partial<MockTerminal.Modifiers>
21
+ ) => Effect.Effect<void>;
22
+}
23
+
24
+export declare namespace MockTerminal {
25
+ export interface Modifiers {
26
+ readonly ctrl: boolean;
27
+ readonly meta: boolean;
28
+ readonly shift: boolean;
29
+ }
30
+}
31
+
32
+// =============================================================================
33
+// Context
34
+// =============================================================================
35
+
36
+export const MockTerminal = Context.GenericTag<Terminal.Terminal, MockTerminal>(
37
+ '@effect/platform/Terminal'
38
+);
39
+
40
+// =============================================================================
41
+// Constructors
42
+// =============================================================================
43
+
44
+export const make = Effect.gen(function* (_) {
45
+ const queue = yield* _(
46
+ Effect.acquireRelease(Queue.unbounded<Terminal.UserInput>(), Queue.shutdown)
47
+ );
48
+
49
+ const inputText: MockTerminal['inputText'] = (text: string) => {
50
+ const inputs = Array.map(text.split(''), key => toUserInput(key));
51
+ return Queue.offerAll(queue, inputs).pipe(Effect.asVoid);
52
+ };
53
+
54
+ const inputKey: MockTerminal['inputKey'] = (
55
+ key: string,
56
+ modifiers?: Partial<MockTerminal.Modifiers>
57
+ ) => {
58
+ const input = toUserInput(key, modifiers);
59
+ return Queue.offer(queue, input).pipe(Effect.asVoid);
60
+ };
61
+
62
+ const display: MockTerminal['display'] = input => Console.log(input);
63
+
64
+ const readInput: MockTerminal['readInput'] = Queue.take(queue).pipe(
65
+ Effect.filterOrFail(
66
+ input => !shouldQuit(input),
67
+ () => new Terminal.QuitException()
68
+ ),
69
+ Effect.timeoutFail({
70
+ duration: '2 seconds',
71
+ onTimeout: () => new Terminal.QuitException(),
72
+ })
73
+ );
74
+
75
+ return MockTerminal.of({
76
+ columns: Effect.succeed(80),
77
+ display,
78
+ readInput,
79
+ readLine: Effect.succeed(''),
80
+ inputKey,
81
+ inputText,
82
+ });
83
+});
84
+
85
+// =============================================================================
86
+// Layer
87
+// =============================================================================
88
+
89
+export const layer = Layer.scoped(MockTerminal, make);
90
+
91
+// =============================================================================
92
+// Accessors
93
+// =============================================================================
94
+
95
+export const { columns, readInput, readLine } = Effect.serviceConstants(MockTerminal);
96
+export const { inputKey, inputText } = Effect.serviceFunctions(MockTerminal);
97
+
98
+// =============================================================================
99
+// Utilities
100
+// =============================================================================
101
+
102
+const shouldQuit = (input: Terminal.UserInput): boolean =>
103
+ input.key.ctrl && (input.key.name === 'c' || input.key.name === 'd');
104
+
105
+const toUserInput = (
106
+ key: string,
107
+ modifiers: Partial<MockTerminal.Modifiers> = {}
108
+): Terminal.UserInput => {
109
+ const { ctrl = false, meta = false, shift = false } = modifiers;
110
+ return {
111
+ input: Option.some(key),
112
+ key: { name: key, ctrl, meta, shift },
113
+ };
114
+};
ts/packages/cli/test/__utils__/services/test-layer.ts
new
+187
@@ -0,0 +1,187 @@
1
+import path from 'node:path';
2
+import * as tempy from 'tempy';
3
+import { CliApp } from '@effect/cli';
4
+import { FileSystem } from '@effect/platform';
5
+import { BunFileSystem, BunContext, BunPath } from '@effect/platform-bun';
6
+import { Console, DateTime, Effect, Layer, Logger, LogLevel, Schedule } from 'effect';
7
+import { CliConfigLive } from 'src/bin';
8
+import * as MockConsole from './mock-console';
9
+import * as MockTerminal from './mock-terminal';
10
+import type { Toolkits } from 'src/models/toolkits';
11
+import { NodeProcess } from 'src/services/node-process';
12
+import {
13
+ ComposioSessionRepository,
14
+ ComposioToolkitsRepository,
15
+} from 'src/services/composio-clients';
16
+import { EnvLangDetector } from 'src/services/env-lang-detector';
17
+import type { Tools } from 'src/models/tools';
18
+import type { TriggerTypes } from 'src/models/trigger-types';
19
+
20
+interface TestLiveInput {
21
+ /**
22
+ * Fixture to use in test.
23
+ */
24
+ fixture?: string;
25
+
26
+ /**
27
+ * Mock toolkit-related data to use in test.
28
+ */
29
+ toolkitsData?: {
30
+ toolkits?: Toolkits;
31
+ tools?: Tools;
32
+ triggerTypes?: TriggerTypes;
33
+ };
34
+}
35
+
36
+/**
37
+ * Effect layer that injects all the services needed for tests, using mocks to avoid
38
+ * side-effects like unwanted HTTP requests to remote services.
39
+ */
40
+export const TestLayer = (input?: TestLiveInput) =>
41
+ Effect.gen(function* () {
42
+ const defaultAppClientData = {
43
+ toolkits: [],
44
+ tools: [],
45
+ triggerTypes: [],
46
+ } satisfies TestLiveInput['toolkitsData'];
47
+ const { fixture, toolkitsData } = Object.assign(
48
+ { fixture: undefined, toolkitsData: defaultAppClientData },
49
+ input
50
+ );
51
+
52
+ const tempDir = tempy.temporaryDirectory({ prefix: 'test' });
53
+ const cwd = (yield* setupFixtureFolder({ fixture, tempDir })) ?? tempDir;
54
+
55
+ const composioToolkitsRepositoryTest = new ComposioToolkitsRepository({
56
+ getToolkits: () => Effect.succeed(toolkitsData.toolkits),
57
+ getTools: () => Effect.succeed(toolkitsData.tools),
58
+ getTriggerTypes: () => Effect.succeed(toolkitsData.triggerTypes),
59
+ });
60
+ const ComposioToolkitsRepositoryTest = Layer.succeed(
61
+ ComposioToolkitsRepository,
62
+ composioToolkitsRepositoryTest
63
+ );
64
+
65
+ const ComposioSessionRepositoryTest = yield* setupComposioSessionRepository();
66
+
67
+ // Mock `node:process`
68
+ const nodeProcessTest = new NodeProcess({
69
+ cwd,
70
+ platform: 'darwin',
71
+ arch: 'arm64',
72
+ });
73
+ const NodeProcessTest = Layer.succeed(NodeProcess, nodeProcessTest);
74
+
75
+ const MockConsoleTestLive = yield* MockConsole.make;
76
+
77
+ const layers = Layer.mergeAll(
78
+ Console.setConsole(MockConsoleTestLive),
79
+ NodeProcessTest,
80
+ CliConfigLive,
81
+ ComposioSessionRepositoryTest,
82
+ ComposioToolkitsRepositoryTest,
83
+ EnvLangDetector.Default,
84
+ BunFileSystem.layer,
85
+ BunContext.layer,
86
+ MockTerminal.layer,
87
+ BunPath.layer
88
+ );
89
+
90
+ return layers;
91
+ }).pipe(Logger.withMinimumLogLevel(LogLevel.Info), Layer.unwrapEffect);
92
+
93
+// Run @effect/vitest suite with TestLive layer
94
+export const runEffect =
95
+ (input?: TestLiveInput) =>
96
+ <E, A>(self: Effect.Effect<A, E, CliApp.CliApp.Environment>): Promise<A> =>
97
+ Effect.provide(self, TestLayer(input)).pipe(Effect.runPromise);
98
+
99
+function setupFixtureFolder({ fixture, tempDir }: { fixture?: string; tempDir: string }) {
100
+ return Effect.gen(function* () {
101
+ if (fixture === undefined) {
102
+ return;
103
+ }
104
+
105
+ const fs = yield* FileSystem.FileSystem;
106
+
107
+ const realFixturePath = path.resolve(
108
+ new URL('.', import.meta.url).pathname,
109
+ '..',
110
+ '..',
111
+ '__fixtures__',
112
+ fixture
113
+ );
114
+ const tmpFixturesPath = path.join(tempDir, 'test', '__fixtures__', fixture);
115
+
116
+ yield* Effect.logDebug(`Using fixture at: ${tmpFixturesPath}`);
117
+
118
+ // Retry the task with a delay between retries and a maximum of 3 retries
119
+ const policy = Schedule.addDelay(Schedule.recurs(3), () => '100 millis');
120
+
121
+ // If all retries fail, run the fallback effect
122
+ const task = Effect.gen(function* () {
123
+ yield* fs.makeDirectory(tmpFixturesPath, { recursive: true });
124
+ yield* fs.copy(realFixturePath, tmpFixturesPath);
125
+ });
126
+
127
+ const repeated = Effect.retryOrElse(policy, () =>
128
+ Effect.die(`Failed to copy fixture to: ${tmpFixturesPath}`)
129
+ );
130
+
131
+ yield* repeated(task);
132
+
133
+ yield* Effect.logDebug(`Copied fixture to: ${tmpFixturesPath}`);
134
+
135
+ return tmpFixturesPath;
136
+ }).pipe(Effect.provide(BunFileSystem.layer));
137
+}
138
+
139
+function setupComposioSessionRepository() {
140
+ return Effect.gen(function* () {
141
+ const now = yield* DateTime.now;
142
+ const sessionId = 'te00st11-d0c4-4efa-8117-c638886063e0';
143
+ const sessionCode = '001122';
144
+ const expiresAt = DateTime.add(now, { minutes: 10 });
145
+
146
+ const accountName = 'test-name';
147
+ const accountId = 'test-id';
148
+ const accountEmail = 'test.name@gmail.com';
149
+
150
+ const account = {
151
+ name: accountName,
152
+ id: accountId,
153
+ email: accountEmail,
154
+ };
155
+
156
+ const composioSessionRepositoryTest = new ComposioSessionRepository({
157
+ createSession: () =>
158
+ Effect.succeed({
159
+ id: sessionId,
160
+ code: sessionCode,
161
+ expiresAt,
162
+ status: 'pending',
163
+ }),
164
+ retrieveSession: () =>
165
+ Effect.succeed({
166
+ id: sessionId,
167
+ code: sessionCode,
168
+ expiresAt,
169
+ status: 'pending',
170
+ }),
171
+ linkSession: () =>
172
+ Effect.succeed({
173
+ id: sessionId,
174
+ code: sessionCode,
175
+ expiresAt,
176
+ status: 'linked',
177
+ account,
178
+ }),
179
+ });
180
+ const ComposioSessionRepositoryTest = Layer.succeed(
181
+ ComposioSessionRepository,
182
+ composioSessionRepositoryTest
183
+ );
184
+
185
+ return ComposioSessionRepositoryTest;
186
+ });
187
+}
ts/packages/cli/test/__utils__/typescript-compiler.ts
new
+95
@@ -0,0 +1,95 @@
1
+import { describe, it, expect } from 'vitest';
2
+import ts from 'typescript';
3
+
4
+interface AssertTypeScriptIsValidInput {
5
+ files: {
6
+ [filename: string]: string;
7
+ };
8
+}
9
+
10
+/**
11
+ * Asserts that the provided TypeScript code is syntactically and semantically valid.
12
+ */
13
+export function assertTypeScriptIsValid({ files }: AssertTypeScriptIsValidInput) {
14
+ const compilerOptions = {
15
+ noEmit: true,
16
+ strict: true,
17
+ target: ts.ScriptTarget.ES2022,
18
+ module: ts.ModuleKind.ES2022,
19
+ skipLibCheck: false,
20
+ types: [],
21
+ lib: [],
22
+ jsx: ts.JsxEmit.None,
23
+ isolatedModules: true,
24
+ allowJs: false,
25
+ moduleResolution: ts.ModuleResolutionKind.Bundler,
26
+ allowImportingTsExtensions: true,
27
+ } satisfies ts.CompilerOptions;
28
+
29
+ const virtualFileMap = new Map(
30
+ Object.entries(files).map(
31
+ ([filename, code]) =>
32
+ [
33
+ filename,
34
+ ts.createSourceFile(filename, code, compilerOptions.target, true, ts.ScriptKind.TS),
35
+ ] as const
36
+ )
37
+ );
38
+ const virtualFileNames = Array.from(virtualFileMap.keys());
39
+
40
+ const tsHost = ts.createCompilerHost(compilerOptions);
41
+ tsHost.getSourceFile = (filename, _languageVersion) => {
42
+ if (virtualFileMap.has(filename)) {
43
+ return virtualFileMap.get(filename);
44
+ }
45
+
46
+ if (virtualFileMap.has(`./${filename}`)) {
47
+ return virtualFileMap.get(filename);
48
+ }
49
+
50
+ throw new Error(`Unexpected filename ${filename}`);
51
+ };
52
+
53
+ const program = ts.createProgram(virtualFileNames, compilerOptions, tsHost);
54
+
55
+ // Check for syntax or semantic errors
56
+ const diagnostics = [...program.getSyntacticDiagnostics(), ...program.getSemanticDiagnostics()];
57
+
58
+ // Assert that there are no TypeScript errors
59
+ expect(diagnostics).toEqual([]);
60
+}
61
+
62
+if (import.meta.vitest) {
63
+ describe('assertTypeScriptIsValid', () => {
64
+ it('[Given] valid TypeScript code [Then] no errors are found', () => {
65
+ const code = /* typescript */ `
66
+ export const id = <T>(x: T): T => x;
67
+ `;
68
+ assertTypeScriptIsValid({ files: { 'index.ts': code } });
69
+ });
70
+
71
+ it('[Given] valid TypeScript code with resolvable imports [Then] no errors are found', () => {
72
+ const doubleSource = /* typescript */ `
73
+ import { multiply } from './multiply.ts';
74
+
75
+ export const double = (x: number) => multiply(x, 2);
76
+ `;
77
+ const multiplySource = /* typescript */ `
78
+ export const multiply = (x: number, y: number) => x * y;
79
+ `;
80
+
81
+ assertTypeScriptIsValid({
82
+ files: { './index.ts': doubleSource, './multiply.ts': multiplySource },
83
+ });
84
+ });
85
+
86
+ it('[Given] invalid TypeScript code [Then] errors are found', () => {
87
+ const code = /* typescript */ `
88
+ export const id<T> = (x: T) => T: x;
89
+ `;
90
+ expect(() => {
91
+ assertTypeScriptIsValid({ files: { 'index.ts': code } });
92
+ }).toThrowError();
93
+ });
94
+ });
95
+}
ts/packages/cli/test/src/commands/$default.cmd.test.ts
new
+102
@@ -0,0 +1,102 @@
1
+import { describe, expect, layer } from '@effect/vitest';
2
+import { Effect, Fiber } from 'effect';
3
+import { ValidationError, HelpDoc } from '@effect/cli';
4
+import { cli, pkg, TestLive, MockConsole } from 'test/__utils__';
5
+import { sanitize } from 'test/__utils__/sanitize';
6
+
7
+describe('CLI: composio', () => {
8
+ layer(TestLive())(it => {
9
+ it.effect.skip('[Given] unknown argument [Then] print error message', () =>
10
+ Effect.gen(function* () {
11
+ const args = ['--bar'];
12
+ const fiber = yield* Effect.fork(cli(args));
13
+ yield* Fiber.join(fiber);
14
+
15
+ const result = yield* Effect.flip(fiber);
16
+ expect(result).toEqual(
17
+ ValidationError.invalidValue(HelpDoc.p("Received unknown argument: '--bar'"))
18
+ );
19
+ })
20
+ );
21
+
22
+ it.effect('[Given] --help flag [Then] prints help message', () =>
23
+ Effect.gen(function* () {
24
+ const args = ['--help'];
25
+ yield* cli(args);
26
+ const lines = yield* MockConsole.getLines();
27
+ const output = lines.join('\n');
28
+
29
+ expect(yield* sanitize(output)).toMatchInlineSnapshot(`
30
+ "[0;1m[0;37;1mcomposio[0;1m[0m
31
+
32
+ composio <VERSION>
33
+
34
+ [0;1mUSAGE[0m
35
+
36
+ $ composio [--log-level all | trace | debug | info | warning | error | fatal | none]
37
+
38
+ [0;1mDESCRIPTION[0m
39
+
40
+ Composio CLI - A tool for managing Python and TypeScript composio.dev projects.
41
+
42
+ [0;1mOPTIONS[0m
43
+
44
+ [0;1m--log-level all | trace | debug | info | warning | error | fatal | none[0m
45
+
46
+ One of the following: all, trace, debug, info, warning, error, fatal, none
47
+
48
+ Define log level
49
+
50
+ This setting is optional.
51
+
52
+ [0;1mCOMMANDS[0m
53
+
54
+ - version Display your account information.
55
+
56
+ [0;1mCOMMANDS[0m
57
+
58
+ - version Display your account information.
59
+
60
+ - whoami Display your account information.
61
+
62
+ - login Log in to the Composio SDK.
63
+
64
+ - generate [(-o, --output-dir directory)] Updates the local type stubs with the latest app data, automatically detecting the language of the project in the current working directory (TypeScript | Python).
65
+
66
+ - py Handle Python projects.
67
+
68
+ - py generate [(-o, --output-dir directory)] Updates the local type stubs with the latest app data.
69
+
70
+ - ts Handle TypeScript projects.
71
+
72
+ - ts generate [(-o, --output-dir directory)] [--single-file] Updates the local type stubs with the latest app data.
73
+ "
74
+ `);
75
+ })
76
+ );
77
+
78
+ it.effect("[Given] --version flag [Then] prints composio's version from package.json", () =>
79
+ Effect.gen(function* () {
80
+ const args = ['--version'];
81
+ yield* cli(args);
82
+ const lines = yield* MockConsole.getLines();
83
+ const output = lines.join('\n');
84
+ expect(output).toContain(pkg.version);
85
+ })
86
+ );
87
+
88
+ // it.effect('[Pressing] CTRL+C [Then] quit wizard mode', () =>
89
+ // Effect.gen(function* () {
90
+ // const args = ['--wizard'];
91
+
92
+ // const fiber = yield* Effect.fork(cli(args));
93
+ // yield* MockTerminal.inputKey('c', { ctrl: true });
94
+ // yield* Fiber.join(fiber);
95
+
96
+ // const lines = yield* MockConsole.getLines();
97
+ // const output = lines.join('\n');
98
+ // expect(output).toContain('Quitting wizard mode...');
99
+ // })
100
+ // );
101
+ });
102
+});
ts/packages/cli/test/src/commands/generate.cmd.test.ts
new
+37
@@ -0,0 +1,37 @@
1
+import { describe, expect, layer } from '@effect/vitest';
2
+import { Effect } from 'effect';
3
+import { cli, TestLive, MockConsole } from 'test/__utils__';
4
+
5
+describe('CLI: composio generate', () => {
6
+ layer(
7
+ TestLive({
8
+ fixture: 'python-project',
9
+ })
10
+ )(it => {
11
+ it.effect('[Given] a valid Python project in cwd [Then] it detects its language', () =>
12
+ Effect.gen(function* () {
13
+ const args = ['generate'];
14
+ yield* cli(args);
15
+ const lines = yield* MockConsole.getLines();
16
+ const output = lines.join('\n');
17
+ expect(output).toContain('Project type detected: Python');
18
+ })
19
+ );
20
+ });
21
+
22
+ layer(
23
+ TestLive({
24
+ fixture: 'typescript-project',
25
+ })
26
+ )(it => {
27
+ it.effect('[Given] a valid TypeScript project in cwd [Then] it detects its language', () =>
28
+ Effect.gen(function* () {
29
+ const args = ['generate'];
30
+ yield* cli(args);
31
+ const lines = yield* MockConsole.getLines();
32
+ const output = lines.join('\n');
33
+ expect(output).toContain('Project type detected: TypeScript');
34
+ })
35
+ );
36
+ });
37
+});
ts/packages/cli/test/src/commands/py/py.generate.cmd.test.ts
new
+219
@@ -0,0 +1,219 @@
1
+import path from 'node:path';
2
+import { describe, expect, layer, vi } from '@effect/vitest';
3
+import { Effect } from 'effect';
4
+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
+
9
+describe('CLI: composio py generate', () => {
10
+ const appClientData = {
11
+ toolkits: makeTestToolkits([
12
+ {
13
+ name: 'Gmail',
14
+ slug: 'gmail',
15
+ },
16
+ {
17
+ name: 'Slack',
18
+ slug: 'slack',
19
+ },
20
+ ]),
21
+ tools: ['GMAIL_CREATE_EMAIL_DRAFT', 'GMAIL_DELETE_MESSAGE', 'GMAIL_FETCH_EMAILS'],
22
+ triggerTypes: ['GMAIL_NEW_GMAIL_MESSAGE'],
23
+ };
24
+
25
+ layer(
26
+ TestLive({
27
+ fixture: 'python-project',
28
+ toolkitsData: appClientData,
29
+ })
30
+ )(it => {
31
+ describe('[Given] valid fetched app data', () => {
32
+ it.effect(
33
+ '[Given] no arguments [Then] it generates type stubs relative to the cache directory',
34
+ () =>
35
+ Effect.gen(function* () {
36
+ const process = yield* NodeProcess;
37
+ const cwd = process.cwd;
38
+ const fs = yield* FileSystem.FileSystem;
39
+
40
+ vi.stubEnv('COMPOSIO_CACHE_DIR', cwd);
41
+
42
+ const args = ['py', 'generate'];
43
+ yield* cli(args);
44
+
45
+ const outputDir = path.join(cwd, '.generated', 'composio-py');
46
+
47
+ const gmailSourceCode = yield* fs.readFileString(path.join(outputDir, 'gmail.py'));
48
+ const slackSourceCode = yield* fs.readFileString(path.join(outputDir, 'slack.py'));
49
+
50
+ expect(gmailSourceCode).toMatchInlineSnapshot(`
51
+ "# Auto-generated by Composio CLI via \`composio py generate\`.
52
+ # Do not modify manually.
53
+
54
+ class GMAIL:
55
+ """Map of Composio's GMAIL toolkit."""
56
+
57
+ slug: str = "gmail"
58
+
59
+ class tools:
60
+ CREATE_EMAIL_DRAFT = "GMAIL_CREATE_EMAIL_DRAFT"
61
+ DELETE_MESSAGE = "GMAIL_DELETE_MESSAGE"
62
+ FETCH_EMAILS = "GMAIL_FETCH_EMAILS"
63
+
64
+ class triggers:
65
+ NEW_GMAIL_MESSAGE = "GMAIL_NEW_GMAIL_MESSAGE"
66
+ "
67
+ `);
68
+ expect(slackSourceCode).toMatchInlineSnapshot(`
69
+ "# Auto-generated by Composio CLI via \`composio py generate\`.
70
+ # Do not modify manually.
71
+
72
+ class SLACK:
73
+ """Map of Composio's SLACK toolkit."""
74
+
75
+ slug: str = "slack"
76
+
77
+ class tools:
78
+ pass
79
+
80
+ class triggers:
81
+ pass
82
+ "
83
+ `);
84
+ })
85
+ );
86
+
87
+ it.effect(
88
+ '[Given] --output-dir [Then] it generates type stubs relative to the given output directory',
89
+ () =>
90
+ Effect.gen(function* () {
91
+ const process = yield* NodeProcess;
92
+ const cwd = process.cwd;
93
+ const fs = yield* FileSystem.FileSystem;
94
+
95
+ const outputDirArg = path.join('.generated', 'composio-py');
96
+
97
+ const args = ['py', 'generate', '--output-dir', outputDirArg];
98
+ yield* cli(args);
99
+
100
+ const outputDir = path.join(cwd, outputDirArg);
101
+
102
+ const gmailSourceCode = yield* fs.readFileString(path.join(outputDir, 'gmail.py'));
103
+ const slackSourceCode = yield* fs.readFileString(path.join(outputDir, 'slack.py'));
104
+
105
+ expect(gmailSourceCode).toMatchInlineSnapshot(`
106
+ "# Auto-generated by Composio CLI via \`composio py generate\`.
107
+ # Do not modify manually.
108
+
109
+ class GMAIL:
110
+ """Map of Composio's GMAIL toolkit."""
111
+
112
+ slug: str = "gmail"
113
+
114
+ class tools:
115
+ CREATE_EMAIL_DRAFT = "GMAIL_CREATE_EMAIL_DRAFT"
116
+ DELETE_MESSAGE = "GMAIL_DELETE_MESSAGE"
117
+ FETCH_EMAILS = "GMAIL_FETCH_EMAILS"
118
+
119
+ class triggers:
120
+ NEW_GMAIL_MESSAGE = "GMAIL_NEW_GMAIL_MESSAGE"
121
+ "
122
+ `);
123
+ expect(slackSourceCode).toMatchInlineSnapshot(`
124
+ "# Auto-generated by Composio CLI via \`composio py generate\`.
125
+ # Do not modify manually.
126
+
127
+ class SLACK:
128
+ """Map of Composio's SLACK toolkit."""
129
+
130
+ slug: str = "slack"
131
+
132
+ class tools:
133
+ pass
134
+
135
+ class triggers:
136
+ pass
137
+ "
138
+ `);
139
+ })
140
+ );
141
+
142
+ it.effect('[Given] --single-file [Then] it generates type stubs in a single file', () =>
143
+ Effect.gen(function* () {
144
+ const process = yield* NodeProcess;
145
+ const cwd = process.cwd;
146
+ const fs = yield* FileSystem.FileSystem;
147
+
148
+ vi.stubEnv('COMPOSIO_CACHE_DIR', cwd);
149
+
150
+ const args = ['ts', 'generate', '--single-file'];
151
+ yield* cli(args);
152
+
153
+ const outputDir = path.join(cwd, '.generated', 'composio-ts');
154
+
155
+ expect(yield* fs.exists(path.join(outputDir, 'index.ts'))).toBe(true);
156
+
157
+ const indexSourceCode = yield* fs.readFileString(path.join(outputDir, 'index.ts'));
158
+
159
+ expect(indexSourceCode).toMatchInlineSnapshot(`
160
+ "/**
161
+ * Auto-generated by Composio CLI. Do not modify manually.
162
+ */
163
+
164
+ /**
165
+ * Map of Composio's GMAIL toolkit.
166
+ */
167
+ export const GMAIL = {
168
+ slug: "gmail",
169
+ tools: {
170
+ CREATE_EMAIL_DRAFT: "GMAIL_CREATE_EMAIL_DRAFT",
171
+ DELETE_MESSAGE: "GMAIL_DELETE_MESSAGE",
172
+ FETCH_EMAILS: "GMAIL_FETCH_EMAILS",
173
+ },
174
+ triggerTypes: {
175
+ NEW_GMAIL_MESSAGE: "GMAIL_NEW_GMAIL_MESSAGE",
176
+ },
177
+ }
178
+
179
+ /**
180
+ * Map of Composio's SLACK toolkit.
181
+ */
182
+ export const SLACK = {
183
+ slug: "slack",
184
+ tools: {},
185
+ triggerTypes: {},
186
+ }
187
+
188
+ /**
189
+ * Map of Composio toolkits to actions.
190
+ */
191
+ export const composio = {
192
+ GMAIL: GMAIL,
193
+ SLACK: SLACK,
194
+ }
195
+
196
+ /**
197
+ * Type declarations
198
+ */
199
+
200
+ /**
201
+ * Union of all available toolkits.
202
+ */
203
+ export type Toolkit =
204
+ | "GMAIL"
205
+ | "SLACK"
206
+
207
+ /**
208
+ * Given a toolkit, returns the tools available for that toolkit.
209
+ */
210
+ export type ToolsByToolkit<Toolkit extends keyof (typeof composio)> = typeof composio[Toolkit]
211
+
212
+
213
+ "
214
+ `);
215
+ })
216
+ );
217
+ });
218
+ });
219
+});
ts/packages/cli/test/src/commands/ts/ts.generate.cmd.test.ts
new
+300
@@ -0,0 +1,300 @@
1
+import path from 'node:path';
2
+import { describe, expect, layer, vi } from '@effect/vitest';
3
+import { Effect } from 'effect';
4
+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 { assertTypeScriptIsValid } from 'test/__utils__/typescript-compiler';
9
+
10
+describe('CLI: composio ts generate', () => {
11
+ const appClientData = {
12
+ toolkits: makeTestToolkits([
13
+ {
14
+ name: 'Gmail',
15
+ slug: 'gmail',
16
+ },
17
+ {
18
+ name: 'Slack',
19
+ slug: 'slack',
20
+ },
21
+ ]),
22
+ tools: ['GMAIL_CREATE_EMAIL_DRAFT', 'GMAIL_DELETE_MESSAGE', 'GMAIL_FETCH_EMAILS'],
23
+ triggerTypes: ['GMAIL_NEW_GMAIL_MESSAGE'],
24
+ };
25
+
26
+ layer(
27
+ TestLive({
28
+ fixture: 'typescript-project',
29
+ toolkitsData: appClientData,
30
+ })
31
+ )(it => {
32
+ describe('[Given] valid fetched app data', () => {
33
+ it.effect(
34
+ '[Given] no arguments [Then] it generates type stubs relative to the cache directory',
35
+ () =>
36
+ Effect.gen(function* () {
37
+ const process = yield* NodeProcess;
38
+ const cwd = process.cwd;
39
+ const fs = yield* FileSystem.FileSystem;
40
+
41
+ vi.stubEnv('COMPOSIO_CACHE_DIR', cwd);
42
+
43
+ const args = ['ts', 'generate'];
44
+ yield* cli(args);
45
+
46
+ const outputDir = path.join(cwd, '.generated', 'composio-ts');
47
+
48
+ const gmailSourceCode = yield* fs.readFileString(path.join(outputDir, 'gmail.ts'));
49
+ const slackSourceCode = yield* fs.readFileString(path.join(outputDir, 'slack.ts'));
50
+ const indexSourceCode = yield* fs.readFileString(path.join(outputDir, 'index.ts'));
51
+
52
+ expect(gmailSourceCode).toMatchInlineSnapshot(`
53
+ "/**
54
+ * Map of Composio's GMAIL toolkit.
55
+ */
56
+ export const GMAIL = {
57
+ slug: "gmail",
58
+ tools: {
59
+ CREATE_EMAIL_DRAFT: "GMAIL_CREATE_EMAIL_DRAFT",
60
+ DELETE_MESSAGE: "GMAIL_DELETE_MESSAGE",
61
+ FETCH_EMAILS: "GMAIL_FETCH_EMAILS",
62
+ },
63
+ triggerTypes: {
64
+ NEW_GMAIL_MESSAGE: "GMAIL_NEW_GMAIL_MESSAGE",
65
+ },
66
+ }
67
+ "
68
+ `);
69
+ expect(slackSourceCode).toMatchInlineSnapshot(`
70
+ "/**
71
+ * Map of Composio's SLACK toolkit.
72
+ */
73
+ export const SLACK = {
74
+ slug: "slack",
75
+ tools: {},
76
+ triggerTypes: {},
77
+ }
78
+ "
79
+ `);
80
+ expect(indexSourceCode).toMatchInlineSnapshot(`
81
+ "/**
82
+ * Auto-generated by Composio CLI. Do not modify manually.
83
+ */
84
+
85
+ import { GMAIL } from "./gmail.ts"
86
+ import { SLACK } from "./slack.ts"
87
+
88
+ /**
89
+ * Map of Composio toolkits to actions.
90
+ */
91
+ export const composio = {
92
+ GMAIL: GMAIL,
93
+ SLACK: SLACK,
94
+ }
95
+
96
+ /**
97
+ * Type declarations
98
+ */
99
+
100
+ /**
101
+ * Union of all available toolkits.
102
+ */
103
+ export type Toolkit =
104
+ | "GMAIL"
105
+ | "SLACK"
106
+
107
+ /**
108
+ * Given a toolkit, returns the tools available for that toolkit.
109
+ */
110
+ export type ToolsByToolkit<Toolkit extends keyof (typeof composio)> = typeof composio[Toolkit]
111
+
112
+ "
113
+ `);
114
+
115
+ assertTypeScriptIsValid({ files: { './gmail.ts': gmailSourceCode } });
116
+ assertTypeScriptIsValid({ files: { './slack.ts': slackSourceCode } });
117
+ assertTypeScriptIsValid({
118
+ files: {
119
+ './index.ts': indexSourceCode,
120
+ './gmail.ts': gmailSourceCode,
121
+ './slack.ts': slackSourceCode,
122
+ },
123
+ });
124
+ })
125
+ );
126
+
127
+ it.effect(
128
+ '[Given] --output-dir [Then] it generates type stubs relative to the given output directory',
129
+ () =>
130
+ Effect.gen(function* () {
131
+ const process = yield* NodeProcess;
132
+ const cwd = process.cwd;
133
+ const fs = yield* FileSystem.FileSystem;
134
+
135
+ const outputDirArg = path.join('.generated', 'composio-ts');
136
+
137
+ const args = ['ts', 'generate', '--output-dir', outputDirArg];
138
+ yield* cli(args);
139
+
140
+ const outputDir = path.join(cwd, outputDirArg);
141
+
142
+ const gmailSourceCode = yield* fs.readFileString(path.join(outputDir, 'gmail.ts'));
143
+ const slackSourceCode = yield* fs.readFileString(path.join(outputDir, 'slack.ts'));
144
+ const indexSourceCode = yield* fs.readFileString(path.join(outputDir, 'index.ts'));
145
+
146
+ expect(gmailSourceCode).toMatchInlineSnapshot(`
147
+ "/**
148
+ * Map of Composio's GMAIL toolkit.
149
+ */
150
+ export const GMAIL = {
151
+ slug: "gmail",
152
+ tools: {
153
+ CREATE_EMAIL_DRAFT: "GMAIL_CREATE_EMAIL_DRAFT",
154
+ DELETE_MESSAGE: "GMAIL_DELETE_MESSAGE",
155
+ FETCH_EMAILS: "GMAIL_FETCH_EMAILS",
156
+ },
157
+ triggerTypes: {
158
+ NEW_GMAIL_MESSAGE: "GMAIL_NEW_GMAIL_MESSAGE",
159
+ },
160
+ }
161
+ "
162
+ `);
163
+ expect(slackSourceCode).toMatchInlineSnapshot(`
164
+ "/**
165
+ * Map of Composio's SLACK toolkit.
166
+ */
167
+ export const SLACK = {
168
+ slug: "slack",
169
+ tools: {},
170
+ triggerTypes: {},
171
+ }
172
+ "
173
+ `);
174
+ expect(indexSourceCode).toMatchInlineSnapshot(`
175
+ "/**
176
+ * Auto-generated by Composio CLI. Do not modify manually.
177
+ */
178
+
179
+ import { GMAIL } from "./gmail.ts"
180
+ import { SLACK } from "./slack.ts"
181
+
182
+ /**
183
+ * Map of Composio toolkits to actions.
184
+ */
185
+ export const composio = {
186
+ GMAIL: GMAIL,
187
+ SLACK: SLACK,
188
+ }
189
+
190
+ /**
191
+ * Type declarations
192
+ */
193
+
194
+ /**
195
+ * Union of all available toolkits.
196
+ */
197
+ export type Toolkit =
198
+ | "GMAIL"
199
+ | "SLACK"
200
+
201
+ /**
202
+ * Given a toolkit, returns the tools available for that toolkit.
203
+ */
204
+ export type ToolsByToolkit<Toolkit extends keyof (typeof composio)> = typeof composio[Toolkit]
205
+
206
+ "
207
+ `);
208
+
209
+ assertTypeScriptIsValid({ files: { './gmail.ts': gmailSourceCode } });
210
+ assertTypeScriptIsValid({ files: { './slack.ts': slackSourceCode } });
211
+ assertTypeScriptIsValid({
212
+ files: {
213
+ './index.ts': indexSourceCode,
214
+ './gmail.ts': gmailSourceCode,
215
+ './slack.ts': slackSourceCode,
216
+ },
217
+ });
218
+ })
219
+ );
220
+
221
+ it.effect('[Given] --single-file [Then] it generates type stubs in a single file', () =>
222
+ Effect.gen(function* () {
223
+ const process = yield* NodeProcess;
224
+ const cwd = process.cwd;
225
+ const fs = yield* FileSystem.FileSystem;
226
+
227
+ vi.stubEnv('COMPOSIO_CACHE_DIR', cwd);
228
+
229
+ const args = ['ts', 'generate', '--single-file'];
230
+ yield* cli(args);
231
+
232
+ const outputDir = path.join(cwd, '.generated', 'composio-ts');
233
+
234
+ expect(yield* fs.exists(path.join(outputDir, 'index.ts'))).toBe(true);
235
+
236
+ const indexSourceCode = yield* fs.readFileString(path.join(outputDir, 'index.ts'));
237
+
238
+ expect(indexSourceCode).toMatchInlineSnapshot(`
239
+ "/**
240
+ * Auto-generated by Composio CLI. Do not modify manually.
241
+ */
242
+
243
+ /**
244
+ * Map of Composio's GMAIL toolkit.
245
+ */
246
+ export const GMAIL = {
247
+ slug: "gmail",
248
+ tools: {
249
+ CREATE_EMAIL_DRAFT: "GMAIL_CREATE_EMAIL_DRAFT",
250
+ DELETE_MESSAGE: "GMAIL_DELETE_MESSAGE",
251
+ FETCH_EMAILS: "GMAIL_FETCH_EMAILS",
252
+ },
253
+ triggerTypes: {
254
+ NEW_GMAIL_MESSAGE: "GMAIL_NEW_GMAIL_MESSAGE",
255
+ },
256
+ }
257
+
258
+ /**
259
+ * Map of Composio's SLACK toolkit.
260
+ */
261
+ export const SLACK = {
262
+ slug: "slack",
263
+ tools: {},
264
+ triggerTypes: {},
265
+ }
266
+
267
+ /**
268
+ * Map of Composio toolkits to actions.
269
+ */
270
+ export const composio = {
271
+ GMAIL: GMAIL,
272
+ SLACK: SLACK,
273
+ }
274
+
275
+ /**
276
+ * Type declarations
277
+ */
278
+
279
+ /**
280
+ * Union of all available toolkits.
281
+ */
282
+ export type Toolkit =
283
+ | "GMAIL"
284
+ | "SLACK"
285
+
286
+ /**
287
+ * Given a toolkit, returns the tools available for that toolkit.
288
+ */
289
+ export type ToolsByToolkit<Toolkit extends keyof (typeof composio)> = typeof composio[Toolkit]
290
+
291
+
292
+ "
293
+ `);
294
+
295
+ assertTypeScriptIsValid({ files: { './index.ts': indexSourceCode } });
296
+ })
297
+ );
298
+ });
299
+ });
300
+});
ts/packages/cli/test/src/commands/version.test.ts
new
+30
@@ -0,0 +1,30 @@
1
+import { vi, describe, expect, layer } from '@effect/vitest';
2
+import { Effect } from 'effect';
3
+import { cli, pkg, TestLive, MockConsole } from 'test/__utils__';
4
+
5
+describe('CLI: composio', () => {
6
+ layer(TestLive())(it => {
7
+ it.effect("[Given] no arguments [Then] prints composio's version from package.json", () =>
8
+ Effect.gen(function* () {
9
+ const args = ['version'];
10
+ yield* cli(args);
11
+ const lines = yield* MockConsole.getLines();
12
+ const output = lines.join('\n');
13
+ expect(output).toContain(pkg.version);
14
+ })
15
+ );
16
+
17
+ it.effect('[Given] DEBUG_OVERRIDE_VERSION env var [Then] prints overridden version', () =>
18
+ Effect.gen(function* () {
19
+ const expectedVersion = '1.2.3-test';
20
+ vi.stubEnv('DEBUG_OVERRIDE_VERSION', expectedVersion);
21
+
22
+ const args = ['version'];
23
+ yield* cli(args);
24
+ const lines = yield* MockConsole.getLines();
25
+ const output = lines.join('\n');
26
+ expect(output).toContain(expectedVersion);
27
+ })
28
+ );
29
+ });
30
+});
ts/packages/cli/test/src/commands/whoami.cmd.test.ts
new
+25
@@ -0,0 +1,25 @@
1
+import { describe, expect, layer } from '@effect/vitest';
2
+import { ConfigProvider, Effect, Layer } from 'effect';
3
+import { cli, TestLive, MockConsole } from 'test/__utils__';
4
+
5
+describe('CLI: composio whoami', () => {
6
+ // Create a mock config provider using a map with test data.
7
+ // Note: `process.env.COMPOSIO_API_KEY` is interpreted as Config.string('API_KEY')
8
+ // after prefix stripping
9
+ const mockConfigProvider = ConfigProvider.fromMap(
10
+ new Map([['API_KEY', 'api_key_from_test_env']])
11
+ );
12
+
13
+ layer(TestLive().pipe(Layer.provide(Layer.setConfigProvider(mockConfigProvider))))(it => {
14
+ it.effect('[Given] `COMPOSIO_API_KEY` env var [Then] prints it in stdout', () =>
15
+ Effect.gen(function* () {
16
+ const args = ['whoami'];
17
+ yield* cli(args);
18
+
19
+ const lines = yield* MockConsole.getLines();
20
+ const output = lines.join('\n');
21
+ expect(output).toContain(`API KEY: api_key_from_test_env`);
22
+ })
23
+ );
24
+ });
25
+});
ts/packages/cli/test/src/generation/python/generate-toolkit-source.test.ts
new
+116
@@ -0,0 +1,116 @@
1
+import { describe, expect, it } from 'vitest';
2
+import { generatePythonToolkitSources } from 'src/generation/python/generate-toolkit-sources';
3
+import { createToolkitIndex } from 'src/generation/create-toolkit-index';
4
+import { makeTestToolkits } from 'test/__utils__/models/toolkits';
5
+
6
+describe('generatePythonToolkitSources', () => {
7
+ it('[Given] empty toolkits, tools, triggerTypes [Then] it returns an empty array', () => {
8
+ const index = createToolkitIndex({
9
+ toolkits: [],
10
+ tools: [],
11
+ triggerTypes: [],
12
+ });
13
+
14
+ const sources = generatePythonToolkitSources(index);
15
+
16
+ expect(sources).toEqual([]);
17
+ });
18
+
19
+ it('[Given] a single toolkit with no tools or triggerTypes [Then] it returns a single Python source file', () => {
20
+ const toolkits = makeTestToolkits([
21
+ {
22
+ name: 'Slack Helper',
23
+ slug: 'slack',
24
+ },
25
+ ]);
26
+
27
+ const index = createToolkitIndex({
28
+ toolkits,
29
+ tools: [],
30
+ triggerTypes: [],
31
+ });
32
+
33
+ const sources = generatePythonToolkitSources(index);
34
+ expect(sources).toHaveLength(1);
35
+ expect(sources[0]).toHaveLength(2);
36
+ expect(sources[0][0]).toBe('slack.py');
37
+ expect(sources[0][1]).toMatchInlineSnapshot(`
38
+ "# Auto-generated by Composio CLI via \`composio py generate\`.
39
+ # Do not modify manually.
40
+
41
+ class SLACK:
42
+ """Map of Composio's SLACK toolkit."""
43
+
44
+ slug: str = "slack"
45
+
46
+ class tools:
47
+ pass
48
+
49
+ class triggers:
50
+ pass
51
+ "
52
+ `);
53
+ });
54
+
55
+ it('[Given] toolkits with tools and triggerTypes [Then] it returns a Python source file for each toolkit', () => {
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: ['GMAIL_NEW_GMAIL_MESSAGE'],
71
+ });
72
+
73
+ const sources = generatePythonToolkitSources(index);
74
+ expect(sources).toHaveLength(2);
75
+
76
+ expect(sources[0]).toHaveLength(2);
77
+ expect(sources[0][0]).toBe('gmail.py');
78
+ expect(sources[0][1]).toMatchInlineSnapshot(`
79
+ "# Auto-generated by Composio CLI via \`composio py generate\`.
80
+ # Do not modify manually.
81
+
82
+ class GMAIL:
83
+ """Map of Composio's GMAIL toolkit."""
84
+
85
+ slug: str = "gmail"
86
+
87
+ class tools:
88
+ CREATE_EMAIL_DRAFT = "GMAIL_CREATE_EMAIL_DRAFT"
89
+ DELETE_MESSAGE = "GMAIL_DELETE_MESSAGE"
90
+ FETCH_EMAILS = "GMAIL_FETCH_EMAILS"
91
+
92
+ class triggers:
93
+ NEW_GMAIL_MESSAGE = "GMAIL_NEW_GMAIL_MESSAGE"
94
+ "
95
+ `);
96
+
97
+ expect(sources[1]).toHaveLength(2);
98
+ expect(sources[1][0]).toBe('slack.py');
99
+ expect(sources[1][1]).toMatchInlineSnapshot(`
100
+ "# Auto-generated by Composio CLI via \`composio py generate\`.
101
+ # Do not modify manually.
102
+
103
+ class SLACK:
104
+ """Map of Composio's SLACK toolkit."""
105
+
106
+ slug: str = "slack"
107
+
108
+ class tools:
109
+ pass
110
+
111
+ class triggers:
112
+ pass
113
+ "
114
+ `);
115
+ });
116
+});
ts/packages/cli/test/src/generation/toolkit-index.test.ts
new
+88
@@ -0,0 +1,88 @@
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
+
5
+describe('createToolkitIndex', () => {
6
+ it('[Given] empty toolkits, tools, triggerTypes [Then] it returns an empty index', () => {
7
+ const index = createToolkitIndex({
8
+ toolkits: [],
9
+ tools: [],
10
+ triggerTypes: [],
11
+ });
12
+
13
+ expect(index).toEqual({});
14
+ });
15
+
16
+ it('[Given] only toolkits and no tools or triggerTypes [Then] it returns an index with empty tools and triggerTypes', () => {
17
+ const toolkits = makeTestToolkits([
18
+ {
19
+ name: 'Gmail',
20
+ slug: 'gmail',
21
+ },
22
+ {
23
+ name: 'Slack Helper',
24
+ slug: 'slack',
25
+ },
26
+ ]);
27
+
28
+ const index = createToolkitIndex({
29
+ toolkits,
30
+ tools: [],
31
+ triggerTypes: [],
32
+ });
33
+
34
+ expect(index).toEqual({
35
+ GMAIL: {
36
+ slug: 'gmail',
37
+ tools: {},
38
+ triggerTypes: {},
39
+ },
40
+ SLACK: {
41
+ slug: 'slack',
42
+ tools: {},
43
+ triggerTypes: {},
44
+ },
45
+ });
46
+ });
47
+
48
+ it('[Given] valid toolkits, tools, triggerTypes [Then] it builds an index based on toolkits', () => {
49
+ const toolkits = makeTestToolkits([
50
+ {
51
+ name: 'Gmail',
52
+ slug: 'gmail',
53
+ },
54
+ {
55
+ name: 'Slack Helper',
56
+ slug: 'slack',
57
+ },
58
+ ]);
59
+
60
+ const tools = ['GMAIL_CREATE_EMAIL_DRAFT', 'GMAIL_DELETE_MESSAGE', 'GMAIL_FETCH_EMAILS'];
61
+ const triggerTypes = ['GMAIL_NEW_GMAIL_MESSAGE'];
62
+
63
+ const index = createToolkitIndex({
64
+ toolkits,
65
+ tools,
66
+ triggerTypes,
67
+ });
68
+
69
+ expect(index).toEqual({
70
+ GMAIL: {
71
+ slug: 'gmail',
72
+ tools: {
73
+ CREATE_EMAIL_DRAFT: 'GMAIL_CREATE_EMAIL_DRAFT',
74
+ DELETE_MESSAGE: 'GMAIL_DELETE_MESSAGE',
75
+ FETCH_EMAILS: 'GMAIL_FETCH_EMAILS',
76
+ },
77
+ triggerTypes: {
78
+ NEW_GMAIL_MESSAGE: 'GMAIL_NEW_GMAIL_MESSAGE',
79
+ },
80
+ },
81
+ SLACK: {
82
+ slug: 'slack',
83
+ tools: {},
84
+ triggerTypes: {},
85
+ },
86
+ });
87
+ });
88
+});
ts/packages/cli/test/src/generation/typescript/generate-index-source.test.ts
new
+312
@@ -0,0 +1,312 @@
1
+import { describe, expect, it } from 'vitest';
2
+import { generateIndexSource } from 'src/generation/typescript/generate-index-source';
3
+import { createToolkitIndex } from 'src/generation/create-toolkit-index';
4
+import { makeTestToolkits } from 'test/__utils__/models/toolkits';
5
+import { assertTypeScriptIsValid } from 'test/__utils__/typescript-compiler';
6
+
7
+describe('generateTypeScriptToolkitSources', () => {
8
+ describe('with a single emitted file', () => {
9
+ const _params = {
10
+ outputDir: '<cwd>',
11
+ emitSingleFile: true,
12
+ };
13
+
14
+ describe('with banner', () => {
15
+ const params = {
16
+ ..._params,
17
+ banner: '<<< Some banner that will appear in a comment >>>',
18
+ };
19
+
20
+ it('[Given] empty toolkits, tools, triggerTypes [Then] it creates a valid but empty index map', () => {
21
+ const index = createToolkitIndex({
22
+ toolkits: [],
23
+ tools: [],
24
+ triggerTypes: [],
25
+ });
26
+
27
+ const source = generateIndexSource(params)(index);
28
+
29
+ expect(source).not.includes(params.banner);
30
+ expect(source).toMatchInlineSnapshot(`
31
+ "/**
32
+ * Map of Composio toolkits to actions.
33
+ */
34
+ export const composio = {}
35
+
36
+ /**
37
+ * Type declarations
38
+ */
39
+
40
+ /**
41
+ * Union of all available toolkits.
42
+ */
43
+ export type Toolkit = never
44
+
45
+ /**
46
+ * Given a toolkit, returns the tools available for that toolkit.
47
+ */
48
+ export type ToolsByToolkit<Toolkit extends keyof (typeof composio)> = typeof composio[Toolkit]
49
+
50
+ "
51
+ `);
52
+
53
+ assertTypeScriptIsValid({ files: { 'index.ts': source } });
54
+ });
55
+
56
+ it('[Given] a single toolkit with no tools or triggerTypes [Then] it creates an index map with no imports, with unrelesolved references, and with no banner', () => {
57
+ const toolkits = makeTestToolkits([
58
+ {
59
+ name: 'Slack Helper',
60
+ slug: 'slack',
61
+ },
62
+ ]);
63
+
64
+ const index = createToolkitIndex({
65
+ toolkits,
66
+ tools: [],
67
+ triggerTypes: [],
68
+ });
69
+
70
+ const source = generateIndexSource(params)(index);
71
+
72
+ expect(source).not.includes(params.banner);
73
+ expect(source).toMatchInlineSnapshot(`
74
+ "/**
75
+ * Map of Composio toolkits to actions.
76
+ */
77
+ export const composio = {
78
+ SLACK: SLACK,
79
+ }
80
+
81
+ /**
82
+ * Type declarations
83
+ */
84
+
85
+ /**
86
+ * Union of all available toolkits.
87
+ */
88
+ export type Toolkit =
89
+ | "SLACK"
90
+
91
+ /**
92
+ * Given a toolkit, returns the tools available for that toolkit.
93
+ */
94
+ export type ToolsByToolkit<Toolkit extends keyof (typeof composio)> = typeof composio[Toolkit]
95
+
96
+ "
97
+ `);
98
+ });
99
+
100
+ it('[Given] multiple toolkits with tools and triggerTypes [Then] it creates an index map with no imports, with unrelesolved references, and with no banner', () => {
101
+ const toolkits = makeTestToolkits([
102
+ {
103
+ name: 'Gmail',
104
+ slug: 'gmail',
105
+ },
106
+ {
107
+ name: 'Slack Helper',
108
+ slug: 'slack',
109
+ },
110
+ ]);
111
+
112
+ const index = createToolkitIndex({
113
+ toolkits,
114
+ tools: ['GMAIL_CREATE_EMAIL_DRAFT', 'GMAIL_DELETE_MESSAGE', 'GMAIL_FETCH_EMAILS'],
115
+ triggerTypes: ['GMAIL_NEW_GMAIL_MESSAGE'],
116
+ });
117
+
118
+ const source = generateIndexSource(params)(index);
119
+
120
+ expect(source).not.includes(params.banner);
121
+ expect(source).toMatchInlineSnapshot(`
122
+ "/**
123
+ * Map of Composio toolkits to actions.
124
+ */
125
+ export const composio = {
126
+ GMAIL: GMAIL,
127
+ SLACK: SLACK,
128
+ }
129
+
130
+ /**
131
+ * Type declarations
132
+ */
133
+
134
+ /**
135
+ * Union of all available toolkits.
136
+ */
137
+ export type Toolkit =
138
+ | "GMAIL"
139
+ | "SLACK"
140
+
141
+ /**
142
+ * Given a toolkit, returns the tools available for that toolkit.
143
+ */
144
+ export type ToolsByToolkit<Toolkit extends keyof (typeof composio)> = typeof composio[Toolkit]
145
+
146
+ "
147
+ `);
148
+ });
149
+ });
150
+ });
151
+
152
+ describe('with multiple emitted files', () => {
153
+ const _params = {
154
+ outputDir: '<cwd>',
155
+ emitSingleFile: false,
156
+ };
157
+
158
+ describe('with banner', () => {
159
+ const params = {
160
+ ..._params,
161
+ banner: 'Some banner that will appear in a comment',
162
+ };
163
+
164
+ it('[Given] empty toolkits, tools, triggerTypes [Then] it creates a valid but empty index map', () => {
165
+ const index = createToolkitIndex({
166
+ toolkits: [],
167
+ tools: [],
168
+ triggerTypes: [],
169
+ });
170
+
171
+ const source = generateIndexSource(params)(index);
172
+
173
+ expect(source).includes(params.banner);
174
+ expect(source).toMatchInlineSnapshot(`
175
+ "/**
176
+ * Some banner that will appear in a comment
177
+ */
178
+
179
+ /**
180
+ * Map of Composio toolkits to actions.
181
+ */
182
+ export const composio = {}
183
+
184
+ /**
185
+ * Type declarations
186
+ */
187
+
188
+ /**
189
+ * Union of all available toolkits.
190
+ */
191
+ export type Toolkit = never
192
+
193
+ /**
194
+ * Given a toolkit, returns the tools available for that toolkit.
195
+ */
196
+ export type ToolsByToolkit<Toolkit extends keyof (typeof composio)> = typeof composio[Toolkit]
197
+
198
+ "
199
+ `);
200
+
201
+ assertTypeScriptIsValid({ files: { 'index.ts': source } });
202
+ });
203
+
204
+ it('[Given] a single toolkit with no tools or triggerTypes [Then] it creates the index map with imports', () => {
205
+ const toolkits = makeTestToolkits([
206
+ {
207
+ name: 'Slack Helper',
208
+ slug: 'slack',
209
+ },
210
+ ]);
211
+
212
+ const index = createToolkitIndex({
213
+ toolkits,
214
+ tools: [],
215
+ triggerTypes: [],
216
+ });
217
+
218
+ const source = generateIndexSource(params)(index);
219
+
220
+ expect(source).includes(params.banner);
221
+ expect(source).toMatchInlineSnapshot(`
222
+ "/**
223
+ * Some banner that will appear in a comment
224
+ */
225
+
226
+ import { SLACK } from "./slack.ts"
227
+
228
+ /**
229
+ * Map of Composio toolkits to actions.
230
+ */
231
+ export const composio = {
232
+ SLACK: SLACK,
233
+ }
234
+
235
+ /**
236
+ * Type declarations
237
+ */
238
+
239
+ /**
240
+ * Union of all available toolkits.
241
+ */
242
+ export type Toolkit =
243
+ | "SLACK"
244
+
245
+ /**
246
+ * Given a toolkit, returns the tools available for that toolkit.
247
+ */
248
+ export type ToolsByToolkit<Toolkit extends keyof (typeof composio)> = typeof composio[Toolkit]
249
+
250
+ "
251
+ `);
252
+ });
253
+
254
+ it('[Given] multiple toolkits with tools and triggerTypes [Then] it creates the index map with imports', () => {
255
+ const toolkits = makeTestToolkits([
256
+ {
257
+ name: 'Gmail',
258
+ slug: 'gmail',
259
+ },
260
+ {
261
+ name: 'Slack Helper',
262
+ slug: 'slack',
263
+ },
264
+ ]);
265
+
266
+ const index = createToolkitIndex({
267
+ toolkits,
268
+ tools: ['GMAIL_CREATE_EMAIL_DRAFT', 'GMAIL_DELETE_MESSAGE', 'GMAIL_FETCH_EMAILS'],
269
+ triggerTypes: ['GMAIL_NEW_GMAIL_MESSAGE'],
270
+ });
271
+
272
+ const source = generateIndexSource(params)(index);
273
+
274
+ expect(source).includes(params.banner);
275
+ expect(source).toMatchInlineSnapshot(`
276
+ "/**
277
+ * Some banner that will appear in a comment
278
+ */
279
+
280
+ import { GMAIL } from "./gmail.ts"
281
+ import { SLACK } from "./slack.ts"
282
+
283
+ /**
284
+ * Map of Composio toolkits to actions.
285
+ */
286
+ export const composio = {
287
+ GMAIL: GMAIL,
288
+ SLACK: SLACK,
289
+ }
290
+
291
+ /**
292
+ * Type declarations
293
+ */
294
+
295
+ /**
296
+ * Union of all available toolkits.
297
+ */
298
+ export type Toolkit =
299
+ | "GMAIL"
300
+ | "SLACK"
301
+
302
+ /**
303
+ * Given a toolkit, returns the tools available for that toolkit.
304
+ */
305
+ export type ToolsByToolkit<Toolkit extends keyof (typeof composio)> = typeof composio[Toolkit]
306
+
307
+ "
308
+ `);
309
+ });
310
+ });
311
+ });
312
+});
ts/packages/cli/test/src/generation/typescript/generate-toolkit-source.test.ts
new
+232
@@ -0,0 +1,232 @@
1
+import { describe, expect, it } from 'vitest';
2
+import { generateTypeScriptToolkitSources } from 'src/generation/typescript/generate-toolkit-sources';
3
+import { createToolkitIndex } from 'src/generation/create-toolkit-index';
4
+import { makeTestToolkits } from 'test/__utils__/models/toolkits';
5
+
6
+describe('generateTypeScriptToolkitSources', () => {
7
+ describe('with a single emitted file', () => {
8
+ const _params = {
9
+ outputDir: '<cwd>',
10
+ emitSingleFile: true,
11
+ };
12
+
13
+ describe('with banner', () => {
14
+ const params = {
15
+ ..._params,
16
+ banner: 'Some banner that will appear in a comment',
17
+ };
18
+
19
+ it('[Given] empty toolkits, tools, triggerTypes [Then] it returns an empty array', () => {
20
+ const index = createToolkitIndex({
21
+ toolkits: [],
22
+ tools: [],
23
+ triggerTypes: [],
24
+ });
25
+
26
+ const sources = generateTypeScriptToolkitSources(params)(index);
27
+
28
+ expect(sources).toEqual([]);
29
+ });
30
+
31
+ it('[Given] a single toolkit with no tools or triggerTypes [Then] it returns a single toolkit source file', () => {
32
+ const toolkits = makeTestToolkits([
33
+ {
34
+ name: 'Slack Helper',
35
+ slug: 'slack',
36
+ },
37
+ ]);
38
+
39
+ const index = createToolkitIndex({
40
+ toolkits,
41
+ tools: [],
42
+ triggerTypes: [],
43
+ });
44
+
45
+ const sources = generateTypeScriptToolkitSources(params)(index);
46
+ expect(sources).toHaveLength(1);
47
+ expect(sources[0]).toHaveLength(2);
48
+ expect(sources[0][0]).toBe('slack.ts');
49
+ expect(sources[0][1]).toMatchInlineSnapshot(`
50
+ "/**
51
+ * Map of Composio's SLACK toolkit.
52
+ */
53
+ export const SLACK = {
54
+ slug: "slack",
55
+ tools: {},
56
+ triggerTypes: {},
57
+ }
58
+ "
59
+ `);
60
+ });
61
+
62
+ it('[Given] toolkits with tools and triggerTypes [Then] it returns a TypeScript source file for each toolkit + the index map', () => {
63
+ const toolkits = makeTestToolkits([
64
+ {
65
+ name: 'Gmail',
66
+ slug: 'gmail',
67
+ },
68
+ {
69
+ name: 'Slack Helper',
70
+ slug: 'slack',
71
+ },
72
+ ]);
73
+
74
+ const index = createToolkitIndex({
75
+ toolkits,
76
+ tools: ['GMAIL_CREATE_EMAIL_DRAFT', 'GMAIL_DELETE_MESSAGE', 'GMAIL_FETCH_EMAILS'],
77
+ triggerTypes: ['GMAIL_NEW_GMAIL_MESSAGE'],
78
+ });
79
+
80
+ const sources = generateTypeScriptToolkitSources(params)(index);
81
+ expect(sources).toHaveLength(2);
82
+
83
+ expect(sources[0]).toHaveLength(2);
84
+ expect(sources[0][0]).toBe('gmail.ts');
85
+ expect(sources[0][1]).toMatchInlineSnapshot(`
86
+ "/**
87
+ * Map of Composio's GMAIL toolkit.
88
+ */
89
+ export const GMAIL = {
90
+ slug: "gmail",
91
+ tools: {
92
+ CREATE_EMAIL_DRAFT: "GMAIL_CREATE_EMAIL_DRAFT",
93
+ DELETE_MESSAGE: "GMAIL_DELETE_MESSAGE",
94
+ FETCH_EMAILS: "GMAIL_FETCH_EMAILS",
95
+ },
96
+ triggerTypes: {
97
+ NEW_GMAIL_MESSAGE: "GMAIL_NEW_GMAIL_MESSAGE",
98
+ },
99
+ }
100
+ "
101
+ `);
102
+
103
+ expect(sources[1]).toHaveLength(2);
104
+ expect(sources[1][0]).toBe('slack.ts');
105
+ expect(sources[1][1]).toMatchInlineSnapshot(`
106
+ "/**
107
+ * Map of Composio's SLACK toolkit.
108
+ */
109
+ export const SLACK = {
110
+ slug: "slack",
111
+ tools: {},
112
+ triggerTypes: {},
113
+ }
114
+ "
115
+ `);
116
+ });
117
+ });
118
+ });
119
+
120
+ describe('with multiple emitted files', () => {
121
+ const _params = {
122
+ outputDir: '<cwd>',
123
+ emitSingleFile: false,
124
+ };
125
+
126
+ describe('with banner', () => {
127
+ const params = {
128
+ ..._params,
129
+ banner: 'Some banner that will appear in a comment',
130
+ };
131
+
132
+ it('[Given] empty toolkits, tools, triggerTypes [Then] it returns an empty array', () => {
133
+ const index = createToolkitIndex({
134
+ toolkits: [],
135
+ tools: [],
136
+ triggerTypes: [],
137
+ });
138
+
139
+ const sources = generateTypeScriptToolkitSources(params)(index);
140
+
141
+ expect(sources).toEqual([]);
142
+ });
143
+
144
+ it('[Given] a single toolkit with no tools or triggerTypes [Then] it returns a single toolkit source file', () => {
145
+ const toolkits = makeTestToolkits([
146
+ {
147
+ name: 'Slack Helper',
148
+ slug: 'slack',
149
+ },
150
+ ]);
151
+
152
+ const index = createToolkitIndex({
153
+ toolkits,
154
+ tools: [],
155
+ triggerTypes: [],
156
+ });
157
+
158
+ const sources = generateTypeScriptToolkitSources(params)(index);
159
+ expect(sources).toHaveLength(1);
160
+ expect(sources[0]).toHaveLength(2);
161
+ expect(sources[0][0]).toBe('slack.ts');
162
+ expect(sources[0][1]).toMatchInlineSnapshot(`
163
+ "/**
164
+ * Map of Composio's SLACK toolkit.
165
+ */
166
+ export const SLACK = {
167
+ slug: "slack",
168
+ tools: {},
169
+ triggerTypes: {},
170
+ }
171
+ "
172
+ `);
173
+ });
174
+
175
+ it('[Given] toolkits with tools and triggerTypes [Then] it returns a TypeScript source file for each toolkit + the index map', () => {
176
+ const toolkits = makeTestToolkits([
177
+ {
178
+ name: 'Gmail',
179
+ slug: 'gmail',
180
+ },
181
+ {
182
+ name: 'Slack Helper',
183
+ slug: 'slack',
184
+ },
185
+ ]);
186
+
187
+ const index = createToolkitIndex({
188
+ toolkits,
189
+ tools: ['GMAIL_CREATE_EMAIL_DRAFT', 'GMAIL_DELETE_MESSAGE', 'GMAIL_FETCH_EMAILS'],
190
+ triggerTypes: ['GMAIL_NEW_GMAIL_MESSAGE'],
191
+ });
192
+
193
+ const sources = generateTypeScriptToolkitSources(params)(index);
194
+ expect(sources).toHaveLength(2);
195
+
196
+ expect(sources[0]).toHaveLength(2);
197
+ expect(sources[0][0]).toBe('gmail.ts');
198
+ expect(sources[0][1]).toMatchInlineSnapshot(`
199
+ "/**
200
+ * Map of Composio's GMAIL toolkit.
201
+ */
202
+ export const GMAIL = {
203
+ slug: "gmail",
204
+ tools: {
205
+ CREATE_EMAIL_DRAFT: "GMAIL_CREATE_EMAIL_DRAFT",
206
+ DELETE_MESSAGE: "GMAIL_DELETE_MESSAGE",
207
+ FETCH_EMAILS: "GMAIL_FETCH_EMAILS",
208
+ },
209
+ triggerTypes: {
210
+ NEW_GMAIL_MESSAGE: "GMAIL_NEW_GMAIL_MESSAGE",
211
+ },
212
+ }
213
+ "
214
+ `);
215
+
216
+ expect(sources[1]).toHaveLength(2);
217
+ expect(sources[1][0]).toBe('slack.ts');
218
+ expect(sources[1][1]).toMatchInlineSnapshot(`
219
+ "/**
220
+ * Map of Composio's SLACK toolkit.
221
+ */
222
+ export const SLACK = {
223
+ slug: "slack",
224
+ tools: {},
225
+ triggerTypes: {},
226
+ }
227
+ "
228
+ `);
229
+ });
230
+ });
231
+ });
232
+});
ts/packages/cli/test/src/generation/typescript/generate.test.ts
new
+202
@@ -0,0 +1,202 @@
1
+import { describe, expect, it } from '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
+
8
+describe('generateTypeScriptSources', () => {
9
+ describe('with multiple emitted files', () => {
10
+ const _params = {
11
+ outputDir: '<cwd>',
12
+ emitSingleFile: false,
13
+ };
14
+
15
+ describe('with banner', () => {
16
+ const params = {
17
+ ..._params,
18
+ banner: 'Some banner that will appear in a comment',
19
+ };
20
+
21
+ it('[Given] empty toolkits, tools, triggerTypes [Then] it returns just the index map', () => {
22
+ const index = createToolkitIndex({
23
+ toolkits: [],
24
+ tools: [],
25
+ triggerTypes: [],
26
+ });
27
+
28
+ const sources = generateTypeScriptSources(params)(index);
29
+
30
+ expect(sources).toHaveLength(1);
31
+ const [[filename, source]] = sources;
32
+
33
+ expect(filename).toBe(path.join(params.outputDir, 'index.ts'));
34
+ expect(source).toMatchInlineSnapshot(`
35
+ "/**
36
+ * Some banner that will appear in a comment
37
+ */
38
+
39
+ /**
40
+ * Map of Composio toolkits to actions.
41
+ */
42
+ export const composio = {}
43
+
44
+ /**
45
+ * Type declarations
46
+ */
47
+
48
+ /**
49
+ * Union of all available toolkits.
50
+ */
51
+ export type Toolkit = never
52
+
53
+ /**
54
+ * Given a toolkit, returns the tools available for that toolkit.
55
+ */
56
+ export type ToolsByToolkit<Toolkit extends keyof (typeof composio)> = typeof composio[Toolkit]
57
+
58
+ "
59
+ `);
60
+
61
+ assertTypeScriptIsValid({ files: { './index.ts': source } });
62
+ });
63
+
64
+ it('[Given] a single toolkit with no tools or triggerTypes [Then] it returns a single toolkit source file + the index map', () => {
65
+ const toolkits = makeTestToolkits([
66
+ {
67
+ name: 'Slack Helper',
68
+ slug: 'slack',
69
+ },
70
+ ]);
71
+
72
+ const index = createToolkitIndex({
73
+ toolkits,
74
+ tools: [],
75
+ triggerTypes: [],
76
+ });
77
+
78
+ const sources = generateTypeScriptSources(params)(index);
79
+ expect(sources).toHaveLength(2);
80
+ expect(sources[0]).toHaveLength(2);
81
+ expect(sources[0][0]).toBe(path.join(params.outputDir, 'slack.ts'));
82
+ expect(sources[0][1]).toMatchInlineSnapshot(`
83
+ "/**
84
+ * Map of Composio's SLACK toolkit.
85
+ */
86
+ export const SLACK = {
87
+ slug: "slack",
88
+ tools: {},
89
+ triggerTypes: {},
90
+ }
91
+ "
92
+ `);
93
+ assertTypeScriptIsValid({ files: { './slack.ts': sources[0][1] } });
94
+
95
+ expect(sources[1]).toHaveLength(2);
96
+ expect(sources[1][0]).toBe(path.join(params.outputDir, 'index.ts'));
97
+ expect(sources[1][1]).toMatchInlineSnapshot(`
98
+ "/**
99
+ * Some banner that will appear in a comment
100
+ */
101
+
102
+ import { SLACK } from "./slack.ts"
103
+
104
+ /**
105
+ * Map of Composio toolkits to actions.
106
+ */
107
+ export const composio = {
108
+ SLACK: SLACK,
109
+ }
110
+
111
+ /**
112
+ * Type declarations
113
+ */
114
+
115
+ /**
116
+ * Union of all available toolkits.
117
+ */
118
+ export type Toolkit =
119
+ | "SLACK"
120
+
121
+ /**
122
+ * Given a toolkit, returns the tools available for that toolkit.
123
+ */
124
+ export type ToolsByToolkit<Toolkit extends keyof (typeof composio)> = typeof composio[Toolkit]
125
+
126
+ "
127
+ `);
128
+
129
+ assertTypeScriptIsValid({
130
+ files: { './index.ts': sources[1][1], './slack.ts': sources[0][1] },
131
+ });
132
+ });
133
+
134
+ it('[Given] toolkits with tools and triggerTypes [Then] it returns a TypeScript source file for each toolkit + the index map', () => {
135
+ const toolkits = makeTestToolkits([
136
+ {
137
+ name: 'Slack Helper',
138
+ slug: 'slack',
139
+ },
140
+ ]);
141
+
142
+ const index = createToolkitIndex({
143
+ toolkits,
144
+ tools: ['GMAIL_CREATE_EMAIL_DRAFT', 'GMAIL_DELETE_MESSAGE', 'GMAIL_FETCH_EMAILS'],
145
+ triggerTypes: ['GMAIL_NEW_GMAIL_MESSAGE'],
146
+ });
147
+
148
+ const sources = generateTypeScriptSources(params)(index);
149
+ expect(sources).toHaveLength(2);
150
+ expect(sources[0]).toHaveLength(2);
151
+ expect(sources[0][0]).toBe(path.join(params.outputDir, './slack.ts'));
152
+ expect(sources[0][1]).toMatchInlineSnapshot(`
153
+ "/**
154
+ * Map of Composio's SLACK toolkit.
155
+ */
156
+ export const SLACK = {
157
+ slug: "slack",
158
+ tools: {},
159
+ triggerTypes: {},
160
+ }
161
+ "
162
+ `);
163
+ assertTypeScriptIsValid({ files: { './slack.ts': sources[0][1] } });
164
+
165
+ expect(sources[1]).toHaveLength(2);
166
+ expect(sources[1][0]).toBe(path.join(params.outputDir, 'index.ts'));
167
+ expect(sources[1][1]).toMatchInlineSnapshot(`
168
+ "/**
169
+ * Some banner that will appear in a comment
170
+ */
171
+
172
+ import { SLACK } from "./slack.ts"
173
+
174
+ /**
175
+ * Map of Composio toolkits to actions.
176
+ */
177
+ export const composio = {
178
+ SLACK: SLACK,
179
+ }
180
+
181
+ /**
182
+ * Type declarations
183
+ */
184
+
185
+ /**
186
+ * Union of all available toolkits.
187
+ */
188
+ export type Toolkit =
189
+ | "SLACK"
190
+
191
+ /**
192
+ * Given a toolkit, returns the tools available for that toolkit.
193
+ */
194
+ export type ToolsByToolkit<Toolkit extends keyof (typeof composio)> = typeof composio[Toolkit]
195
+
196
+ "
197
+ `);
198
+ assertTypeScriptIsValid({ files: { './index.ts': sources[1][1] } });
199
+ });
200
+ });
201
+ });
202
+});
ts/packages/cli/tsconfig.json
new
+14
@@ -0,0 +1,14 @@
1
+{
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": "./tsconfig.options.json",
4
+ "compilerOptions": {
5
+ "rootDir": ".",
6
+ "paths": {
7
+ "src/*": ["./src/*"],
8
+ "test/*": ["./test/*"],
9
+ "~/*": ["./*"]
10
+ },
11
+ "types": ["@types/bun", "vitest/importMeta"]
12
+ },
13
+ "include": ["src", "test", "scripts"]
14
+}
ts/packages/cli/tsconfig.options.json
new
+28
@@ -0,0 +1,28 @@
1
+{
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "compilerOptions": {
4
+ "target": "ESNext",
5
+ "module": "ESNext",
6
+ "declaration": true,
7
+ "outDir": "./dist",
8
+ "rootDir": ".",
9
+ "strict": true,
10
+ "esModuleInterop": true,
11
+ "moduleResolution": "node",
12
+ "skipLibCheck": true,
13
+ "resolveJsonModule": true,
14
+ "verbatimModuleSyntax": true,
15
+ "pretty": true,
16
+ "noImplicitReturns": true,
17
+ "noFallthroughCasesInSwitch": true,
18
+ "noUnusedLocals": false,
19
+ "noUnusedParameters": false,
20
+ "plugins": [
21
+ {
22
+ "name": "@effect/language-service"
23
+ }
24
+ ]
25
+ },
26
+ "include": ["src"],
27
+ "exclude": ["**/dist", "test/__fixtures__/**"]
28
+}
ts/packages/cli/tsconfig.src.json
new
+13
@@ -0,0 +1,13 @@
1
+{
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": "./tsconfig.options.json",
4
+ "compilerOptions": {
5
+ "outDir": "./dist",
6
+ "rootDir": ".",
7
+ "paths": {
8
+ "src/*": ["./src/*"]
9
+ },
10
+ "types": ["@types/bun"]
11
+ },
12
+ "include": ["src"]
13
+}
ts/packages/cli/tsconfig.test.json
new
+12
@@ -0,0 +1,12 @@
1
+{
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": "./tsconfig.options.json",
4
+ "compilerOptions": {
5
+ "rootDir": ".",
6
+ "paths": {
7
+ "src/*": ["./src/*"],
8
+ "test/*": ["./test/*"]
9
+ }
10
+ },
11
+ "include": ["test"]
12
+}
ts/packages/cli/tsup.config.ts
new
+14
@@ -0,0 +1,14 @@
1
+import { defineConfig } from 'tsup';
2
+
3
+export default defineConfig({
4
+ entry: ['src/bin.ts'],
5
+ format: ['esm'],
6
+ dts: true,
7
+ clean: true,
8
+ minify: false,
9
+ outDir: 'dist',
10
+ tsconfig: './tsconfig.src.json',
11
+ banner: {
12
+ js: '#!/usr/bin/env bun',
13
+ },
14
+});
ts/packages/cli/vitest.config.ts
new
+20
@@ -0,0 +1,20 @@
1
+import { defineConfig } from 'vitest/config';
2
+import path from 'node:path';
3
+
4
+const __dirname = path.resolve(path.dirname(new URL(import.meta.url).pathname));
5
+
6
+export default defineConfig({
7
+ resolve: {
8
+ alias: {
9
+ '~': path.resolve(__dirname, './'),
10
+ src: path.resolve(__dirname, './src'),
11
+ test: path.resolve(__dirname, './test'),
12
+ },
13
+ },
14
+ test: {
15
+ typecheck: {
16
+ tsconfig: './tsconfig.test.json',
17
+ },
18
+ includeSource: ['src/**/*.ts', 'test/**/*.ts'],
19
+ },
20
+});
ts/packages/core/src/index.ts
+1
@@ -14,6 +14,7 @@ export * from './types/modifiers.types';
14
export * from './types/connectedAccountAuthStates.types';
15
export * from './types/toolkit.types';
16
export * from './types/triggers.types';
17
+export * as constants from './utils/constants';
18
19
export { default as logger } from './utils/logger';
20
// Error handling exports
ts/packages/ts-builders/README.md
new
+23
@@ -0,0 +1,23 @@
1
+# @composio/ts-builders
2
+
3
+This package provides a set of utilities for programmatically generating TypeScript Abstract Syntax Trees. It is used to generate type stubs for TypeScript projects in the Composio CLI ([@composio/cli](./../cli/README.md)).
4
+
5
+## Development
6
+
7
+### Installation
8
+
9
+```bash
10
+pnpm install
11
+```
12
+
13
+### Build
14
+
15
+```bash
16
+pnpm build
17
+```
18
+
19
+### Test
20
+
21
+```bash
22
+pnpm test
23
+```
ts/packages/ts-builders/package.json
new
+40
@@ -0,0 +1,40 @@
1
+{
2
+ "name": "@composio/ts-builders",
3
+ "version": "0.1.24",
4
+ "description": "Fork of @prisma/ts-builders",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "module": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ }
15
+ }
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/ComposioHQ/composio.git",
20
+ "directory": "ts/packages/ts-builders"
21
+ },
22
+ "license": "Apache-2.0",
23
+ "devDependencies": {
24
+ "@types/babel__helper-validator-identifier": "^7.15.2",
25
+ "helper-validator-identifier": "link:@types/@babel/helper-validator-identifier",
26
+ "tsup": "^8.4.0",
27
+ "vitest": "^3.1.4"
28
+ },
29
+ "scripts": {
30
+ "build": "tsup",
31
+ "test": "vitest run"
32
+ },
33
+ "files": [
34
+ "dist"
35
+ ],
36
+ "sideEffects": false,
37
+ "dependencies": {
38
+ "@babel/helper-validator-identifier": "^7.27.1"
39
+ }
40
+}
ts/packages/ts-builders/src/AnyDeclarationBuilder.ts
new
+12
@@ -0,0 +1,12 @@
1
+import { ClassDeclaration } from './Class';
2
+import { ConstDeclaration } from './ConstDeclaration';
3
+import { InterfaceDeclaration } from './Interface';
4
+import { NamespaceDeclaration } from './NamespaceDeclaration';
5
+import { TypeDeclaration } from './TypeDeclaration';
6
+
7
+export type AnyDeclarationBuilder =
8
+ | TypeDeclaration
9
+ | ConstDeclaration
10
+ | InterfaceDeclaration
11
+ | ClassDeclaration
12
+ | NamespaceDeclaration;
ts/packages/ts-builders/src/ArraySpread.ts
new
+18
@@ -0,0 +1,18 @@
1
+import { TypeBuilder } from './TypeBuilder';
2
+import { Writer } from './Writer';
3
+import { OperatorPrecedence } from './OperatorPrecedence';
4
+
5
+export class ArraySpread extends TypeBuilder {
6
+ readonly precedence = OperatorPrecedence.ArrayType;
7
+
8
+ constructor(private innerType: TypeBuilder) {
9
+ super();
10
+ }
11
+ write(writer: Writer): void {
12
+ writer.write('[...').write(this.innerType).write(']');
13
+ }
14
+}
15
+
16
+export function arraySpread(innerType: TypeBuilder) {
17
+ return new ArraySpread(innerType);
18
+}
ts/packages/ts-builders/src/ArrayType.test.ts
new
+29
@@ -0,0 +1,29 @@
1
+import { expect, test } from 'vitest';
2
+
3
+import { array } from './ArrayType';
4
+import { functionType } from './FunctionType';
5
+import { namedType } from './NamedType';
6
+import { objectType } from './ObjectType';
7
+import { stringify } from './stringify';
8
+import { unionType } from './UnionType';
9
+
10
+const A = namedType('A');
11
+const B = namedType('B');
12
+const C = namedType('C');
13
+
14
+test('simple only', () => {
15
+ expect(stringify(array(A))).toMatchInlineSnapshot(`"A[]"`);
16
+});
17
+
18
+test('with object type', () => {
19
+ expect(stringify(array(objectType()))).toMatchInlineSnapshot(`"({})[]"`);
20
+});
21
+
22
+test('with function type', () => {
23
+ expect(stringify(array(functionType()))).toMatchInlineSnapshot(`"(() => void)[]"`);
24
+});
25
+
26
+test('with union type', () => {
27
+ const union = unionType(A).addVariant(B).addVariant(C);
28
+ expect(stringify(array(union))).toMatchInlineSnapshot(`"(A | B | C)[]"`);
29
+});
ts/packages/ts-builders/src/ArrayType.ts
new
+20
@@ -0,0 +1,20 @@
1
+import { TypeBuilder } from './TypeBuilder';
2
+import { Writer } from './Writer';
3
+import { OperatorPrecedence, TypeContext } from './OperatorPrecedence';
4
+
5
+export class ArrayType extends TypeBuilder {
6
+ readonly precedence = OperatorPrecedence.ArrayType;
7
+
8
+ constructor(private elementType: TypeBuilder) {
9
+ super();
10
+ }
11
+
12
+ write(writer: Writer): void {
13
+ this.elementType.writeInContext(writer, TypeContext.ArrayElement);
14
+ writer.write('[]');
15
+ }
16
+}
17
+
18
+export function array(elementType: TypeBuilder): ArrayType {
19
+ return new ArrayType(elementType);
20
+}
ts/packages/ts-builders/src/BasicBuilder.ts
new
+5
@@ -0,0 +1,5 @@
1
+import { Writer } from './Writer';
2
+
3
+export interface BasicBuilder<ContextType = undefined> {
4
+ write(writer: Writer<ContextType>): void;
5
+}
ts/packages/ts-builders/src/Class.test.ts
new
+68
@@ -0,0 +1,68 @@
1
+import { expect, test } from 'vitest';
2
+
3
+import { classDeclaration } from './Class';
4
+import { genericParameter } from './GenericParameter';
5
+import { method } from './Method';
6
+import { namedType } from './NamedType';
7
+import { property } from './Property';
8
+import { stringify } from './stringify';
9
+
10
+const A = namedType('A');
11
+
12
+test('empty', () => {
13
+ const obj = classDeclaration('MyClass');
14
+ expect(stringify(obj)).toMatchInlineSnapshot(`
15
+ "class MyClass {}
16
+ "
17
+ `);
18
+});
19
+
20
+test('with property', () => {
21
+ const obj = classDeclaration('SomeClass').add(property('foo', A));
22
+ expect(stringify(obj)).toMatchInlineSnapshot(`
23
+ "class SomeClass {
24
+ foo: A
25
+ }"
26
+ `);
27
+});
28
+
29
+test('with method', () => {
30
+ const obj = classDeclaration('MyClass').add(method('doThing'));
31
+ expect(stringify(obj)).toMatchInlineSnapshot(`
32
+ "class MyClass {
33
+ doThing(): void
34
+ }"
35
+ `);
36
+});
37
+
38
+test('with generic parameter', () => {
39
+ const obj = classDeclaration('SomeClass')
40
+ .addGenericParameter(genericParameter('T').extends(namedType('U')))
41
+ .add(property('foo', A));
42
+ expect(stringify(obj)).toMatchInlineSnapshot(`
43
+ "class SomeClass<T extends U> {
44
+ foo: A
45
+ }"
46
+ `);
47
+});
48
+
49
+test('extending the type', () => {
50
+ const obj = classDeclaration('SomeClass').extends(namedType('Foo')).add(property('foo', A));
51
+ expect(stringify(obj)).toMatchInlineSnapshot(`
52
+ "class SomeClass extends Foo {
53
+ foo: A
54
+ }"
55
+ `);
56
+});
57
+
58
+test('extending multiple types', () => {
59
+ const obj = classDeclaration('SomeClass')
60
+ .extends(namedType('Foo'))
61
+ .extends(namedType('Bar'))
62
+ .add(property('foo', A));
63
+ expect(stringify(obj)).toMatchInlineSnapshot(`
64
+ "class SomeClass extends Foo, Bar {
65
+ foo: A
66
+ }"
67
+ `);
68
+});
ts/packages/ts-builders/src/Class.ts
new
+72
@@ -0,0 +1,72 @@
1
+import { GenericParameter } from './GenericParameter';
2
+import { Method } from './Method';
3
+import { NamedType } from './NamedType';
4
+import { Property } from './Property';
5
+import { TypeBuilder } from './TypeBuilder';
6
+import { Writer } from './Writer';
7
+import { OperatorPrecedence } from './OperatorPrecedence';
8
+
9
+type ClassItem = Method | Property;
10
+
11
+export class ClassDeclaration extends TypeBuilder {
12
+ readonly precedence = OperatorPrecedence.Atomic;
13
+ needsParenthesisWhenIndexed = true;
14
+
15
+ private items: ClassItem[] = [];
16
+ private genericParameters: GenericParameter[] = [];
17
+ private extendedTypes: NamedType[] = [];
18
+
19
+ constructor(readonly name: string) {
20
+ super();
21
+ }
22
+
23
+ add(item: ClassItem): this {
24
+ this.items.push(item);
25
+ return this;
26
+ }
27
+
28
+ addMultiple(items: ClassItem[]): this {
29
+ for (const item of items) {
30
+ this.add(item);
31
+ }
32
+ return this;
33
+ }
34
+
35
+ addGenericParameter(param: GenericParameter) {
36
+ this.genericParameters.push(param);
37
+ return this;
38
+ }
39
+
40
+ extends(type: NamedType) {
41
+ this.extendedTypes.push(type);
42
+ return this;
43
+ }
44
+
45
+ write(writer: Writer): void {
46
+ writer.write('class ').write(this.name);
47
+ if (this.genericParameters.length > 0) {
48
+ writer.write('<').writeJoined(', ', this.genericParameters).write('>');
49
+ }
50
+
51
+ if (this.extendedTypes.length > 0) {
52
+ writer.write(' extends ').writeJoined(', ', this.extendedTypes);
53
+ }
54
+ if (this.items.length === 0) {
55
+ writer.writeLine(' {}');
56
+ return;
57
+ }
58
+
59
+ writer
60
+ .writeLine(' {')
61
+ .withIndent(() => {
62
+ for (const item of this.items) {
63
+ writer.writeLine(item);
64
+ }
65
+ })
66
+ .write('}');
67
+ }
68
+}
69
+
70
+export function classDeclaration(name: string) {
71
+ return new ClassDeclaration(name);
72
+}
ts/packages/ts-builders/src/ConstDeclaration.test.ts
new
+22
@@ -0,0 +1,22 @@
1
+import { expect, test } from 'vitest';
2
+
3
+import { constDeclaration } from './ConstDeclaration';
4
+import { docComment } from './DocComment';
5
+import { namedType } from './NamedType';
6
+import { stringify } from './stringify';
7
+
8
+const A = namedType('A');
9
+
10
+test('basic', () => {
11
+ expect(stringify(constDeclaration('B', A))).toMatchInlineSnapshot(`"const B: A"`);
12
+});
13
+
14
+test('with doc comment', () => {
15
+ const decl = constDeclaration('B', A).setDocComment(docComment('Some important value'));
16
+ expect(stringify(decl)).toMatchInlineSnapshot(`
17
+ "/**
18
+ * Some important value
19
+ */
20
+ const B: A"
21
+ `);
22
+});
ts/packages/ts-builders/src/ConstDeclaration.ts
new
+42
@@ -0,0 +1,42 @@
1
+import type { BasicBuilder } from './BasicBuilder';
2
+import { DocComment } from './DocComment';
3
+import { TypeBuilder } from './TypeBuilder';
4
+import { ValueBuilder } from './ValueBuilder';
5
+import { Writer } from './Writer';
6
+
7
+export class ConstDeclaration implements BasicBuilder {
8
+ private docComment?: DocComment;
9
+ private value?: ValueBuilder;
10
+
11
+ constructor(
12
+ readonly name: string,
13
+ readonly type?: TypeBuilder
14
+ ) {}
15
+
16
+ setDocComment(docComment: DocComment): this {
17
+ this.docComment = docComment;
18
+ return this;
19
+ }
20
+
21
+ setValue(value: ValueBuilder): this {
22
+ this.value = value;
23
+ return this;
24
+ }
25
+
26
+ write(writer: Writer): void {
27
+ if (this.docComment) {
28
+ writer.write(this.docComment);
29
+ }
30
+ writer.write('const ').write(this.name);
31
+ if (this.type) {
32
+ writer.write(': ').write(this.type);
33
+ }
34
+ if (this.value) {
35
+ writer.write(' = ').write(this.value);
36
+ }
37
+ }
38
+}
39
+
40
+export function constDeclaration(name: string, type?: TypeBuilder) {
41
+ return new ConstDeclaration(name, type);
42
+}
ts/packages/ts-builders/src/DocComment.test.ts
new
+90
@@ -0,0 +1,90 @@
1
+import { expect, test } from 'vitest';
2
+
3
+import { docComment } from './DocComment';
4
+import { stringify } from './stringify';
5
+
6
+test('empty', () => {
7
+ expect(stringify(docComment())).toMatchInlineSnapshot(`
8
+ "/**
9
+ */
10
+ "
11
+ `);
12
+});
13
+
14
+test('one line', () => {
15
+ expect(stringify(docComment('I am comment'))).toMatchInlineSnapshot(`
16
+ "/**
17
+ * I am comment
18
+ */
19
+ "
20
+ `);
21
+});
22
+
23
+test('multiline', () => {
24
+ expect(stringify(docComment('first\nsecond'))).toMatchInlineSnapshot(`
25
+ "/**
26
+ * first
27
+ * second
28
+ */
29
+ "
30
+ `);
31
+});
32
+
33
+test('multiple addText calls', () => {
34
+ const comment = docComment('Line 1').addText('Line 2').addText('Line 3');
35
+ expect(stringify(comment)).toMatchInlineSnapshot(`
36
+ "/**
37
+ * Line 1
38
+ * Line 2
39
+ * Line 3
40
+ */
41
+ "
42
+ `);
43
+});
44
+
45
+test('tagged template - empty', () => {
46
+ expect(stringify(docComment``)).toMatchInlineSnapshot(`
47
+ "/**
48
+ */
49
+ "
50
+ `);
51
+});
52
+
53
+test('tagged template - spaces only', () => {
54
+ expect(stringify(docComment` `)).toMatchInlineSnapshot(`
55
+ "/**
56
+ */
57
+ "
58
+ `);
59
+});
60
+
61
+test('tagged template - with content', () => {
62
+ const comment = docComment`
63
+ This is a multiline comment
64
+ - this line should be indented
65
+ And this should be not
66
+ `;
67
+
68
+ expect(stringify(comment)).toMatchInlineSnapshot(`
69
+ "/**
70
+ * This is a multiline comment
71
+ * - this line should be indented
72
+ * And this should be not
73
+ */
74
+ "
75
+ `);
76
+});
77
+
78
+test('tagged template - with substitutions', () => {
79
+ const name = 'World';
80
+ const comment = docComment`
81
+ Hello, ${name}!
82
+ `;
83
+
84
+ expect(stringify(comment)).toMatchInlineSnapshot(`
85
+ "/**
86
+ * Hello, World!
87
+ */
88
+ "
89
+ `);
90
+});
ts/packages/ts-builders/src/DocComment.ts
new
+95
@@ -0,0 +1,95 @@
1
+import type { BasicBuilder } from './BasicBuilder';
2
+import { Writer } from './Writer';
3
+
4
+export class DocComment implements BasicBuilder {
5
+ readonly lines: string[] = [];
6
+
7
+ constructor(startingText?: string) {
8
+ if (startingText) {
9
+ this.addText(startingText);
10
+ }
11
+ }
12
+
13
+ addText(text: string): this {
14
+ this.lines.push(...text.split('\n'));
15
+ return this;
16
+ }
17
+
18
+ write(writer: Writer) {
19
+ writer.writeLine('/**');
20
+ for (const line of this.lines) {
21
+ writer.writeLine(` * ${line}`);
22
+ }
23
+ writer.writeLine(' */');
24
+ return writer;
25
+ }
26
+}
27
+
28
+function docComment(strings: TemplateStringsArray, ...args: string[]): DocComment;
29
+function docComment(startingText?: string): DocComment;
30
+function docComment(
31
+ firstParameter: string | TemplateStringsArray | undefined,
32
+ ...args: string[]
33
+): DocComment {
34
+ if (typeof firstParameter === 'string' || typeof firstParameter === 'undefined') {
35
+ return new DocComment(firstParameter);
36
+ }
37
+ return docCommentTag(firstParameter, args);
38
+}
39
+
40
+function docCommentTag(strings: TemplateStringsArray, args: string[]) {
41
+ const docComment = new DocComment();
42
+ const fullText = strings
43
+ .flatMap((str, i) => {
44
+ if (i < args.length) {
45
+ return [str, args[i]];
46
+ }
47
+ return [str];
48
+ })
49
+ .join('');
50
+ const lines = trimEmptyLines(fullText.split('\n'));
51
+ if (lines.length === 0) {
52
+ return docComment;
53
+ }
54
+ const indent = getIndent(lines[0]);
55
+ for (const line of lines) {
56
+ docComment.addText(line.slice(indent));
57
+ }
58
+ return docComment;
59
+}
60
+
61
+function trimEmptyLines(lines: string[]): string[] {
62
+ const firstLine = findFirstNonEmptyLine(lines);
63
+ const lastLine = findLastNonEmptyLine(lines);
64
+ if (firstLine === -1 || lastLine === -1) {
65
+ // all lines are empty
66
+ return [];
67
+ }
68
+ return lines.slice(firstLine, lastLine + 1);
69
+}
70
+
71
+function findFirstNonEmptyLine(lines: string[]) {
72
+ return lines.findIndex(line => !isEmptyLine(line));
73
+}
74
+
75
+function findLastNonEmptyLine(lines: string[]) {
76
+ let i = lines.length - 1;
77
+ while (i > 0 && isEmptyLine(lines[i])) {
78
+ i--;
79
+ }
80
+ return i;
81
+}
82
+
83
+function isEmptyLine(line: string) {
84
+ return line.trim().length === 0;
85
+}
86
+
87
+function getIndent(line: string): number {
88
+ let indent = 0;
89
+ while (line[indent] === ' ') {
90
+ indent++;
91
+ }
92
+ return indent;
93
+}
94
+
95
+export { docComment };
ts/packages/ts-builders/src/Export.ts
new
+25
@@ -0,0 +1,25 @@
1
+import type { AnyDeclarationBuilder } from './AnyDeclarationBuilder';
2
+import type { BasicBuilder } from './BasicBuilder';
3
+import { DocComment } from './DocComment';
4
+import { Writer } from './Writer';
5
+
6
+export class Export<Decl extends AnyDeclarationBuilder> implements BasicBuilder {
7
+ private docComment?: DocComment;
8
+ constructor(public readonly declaration: Decl) {}
9
+
10
+ setDocComment(docComment: DocComment): this {
11
+ this.docComment = docComment;
12
+ return this;
13
+ }
14
+
15
+ write(writer: Writer): void {
16
+ if (this.docComment) {
17
+ writer.write(this.docComment);
18
+ }
19
+ writer.write('export ').write(this.declaration);
20
+ }
21
+}
22
+
23
+export function moduleExport<Decl extends AnyDeclarationBuilder>(declaration: Decl): Export<Decl> {
24
+ return new Export(declaration);
25
+}
ts/packages/ts-builders/src/ExportFrom.test.ts
new
+37
@@ -0,0 +1,37 @@
1
+import { expect, test } from 'vitest';
2
+
3
+import { moduleExportFrom, namedExport } from './ExportFrom';
4
+import { stringify } from './stringify';
5
+
6
+test('module name only', () => {
7
+ expect(stringify(moduleExportFrom('someModule'))).toMatchInlineSnapshot(
8
+ `"export * from "someModule""`
9
+ );
10
+});
11
+
12
+test('namespace', () => {
13
+ const exportDecl = moduleExportFrom('myModule').asNamespace('ns');
14
+ expect(stringify(exportDecl)).toMatchInlineSnapshot(`"export * as ns from 'myModule'"`);
15
+});
16
+
17
+test('named', () => {
18
+ const exportDecl = moduleExportFrom('myModule').named('func');
19
+ expect(stringify(exportDecl)).toMatchInlineSnapshot(`"export { func } from "myModule""`);
20
+});
21
+
22
+test('named with alias', () => {
23
+ const exportDecl = moduleExportFrom('myModule').named(namedExport('func').as('myFunc'));
24
+ expect(stringify(exportDecl)).toMatchInlineSnapshot(
25
+ `"export { func as myFunc } from "myModule""`
26
+ );
27
+});
28
+
29
+test('multiple named', () => {
30
+ const exportDecl = moduleExportFrom('myModule')
31
+ .named('func1')
32
+ .named('func2')
33
+ .named(namedExport('func3').as('aliasedFunc3'));
34
+ expect(stringify(exportDecl)).toMatchInlineSnapshot(
35
+ `"export { func1, func2, func3 as aliasedFunc3 } from "myModule""`
36
+ );
37
+});
ts/packages/ts-builders/src/ExportFrom.ts
new
+89
@@ -0,0 +1,89 @@
1
+import type { BasicBuilder } from './BasicBuilder';
2
+import { Writer } from './Writer';
3
+
4
+export type ExportFrom = NamespaceExport | BindingsExport | ExportAllFrom;
5
+
6
+export class NamespaceExport implements BasicBuilder {
7
+ constructor(
8
+ private from: string,
9
+ private namespace: string
10
+ ) {}
11
+
12
+ write(writer: Writer<undefined>): void {
13
+ writer.write(`export * as ${this.namespace} from '${this.from}'`);
14
+ }
15
+}
16
+
17
+export class BindingsExport implements BasicBuilder {
18
+ private namedExports: NamedExport[] = [];
19
+ constructor(private from: string) {}
20
+
21
+ named(namedExport: string | NamedExport) {
22
+ if (typeof namedExport === 'string') {
23
+ namedExport = new NamedExport(namedExport);
24
+ }
25
+ this.namedExports.push(namedExport);
26
+ return this;
27
+ }
28
+
29
+ write(writer: Writer<undefined>): void {
30
+ writer
31
+ .write('export ')
32
+ .write('{ ')
33
+ .writeJoined(', ', this.namedExports)
34
+ .write(' }')
35
+
36
+ .write(` from "${this.from}"`);
37
+ }
38
+}
39
+
40
+export class NamedExport implements BasicBuilder {
41
+ private alias: string | undefined;
42
+ private type = false;
43
+
44
+ constructor(readonly name: string) {}
45
+
46
+ as(alias: string) {
47
+ this.alias = alias;
48
+ return this;
49
+ }
50
+
51
+ typeOnly(): this {
52
+ this.type = true;
53
+ return this;
54
+ }
55
+
56
+ write(writer: Writer): void {
57
+ if (this.type) {
58
+ writer.write('type ');
59
+ }
60
+ writer.write(this.name);
61
+ if (this.alias) {
62
+ writer.write(' as ').write(this.alias);
63
+ }
64
+ }
65
+}
66
+
67
+export class ExportAllFrom implements BasicBuilder {
68
+ constructor(private from: string) {}
69
+
70
+ asNamespace(namespace: string) {
71
+ return new NamespaceExport(this.from, namespace);
72
+ }
73
+
74
+ named(binding: string | NamedExport) {
75
+ return new BindingsExport(this.from).named(binding);
76
+ }
77
+
78
+ write(writer: Writer): void {
79
+ writer.write(`export * from "${this.from}"`);
80
+ }
81
+}
82
+
83
+export function moduleExportFrom(from: string) {
84
+ return new ExportAllFrom(from);
85
+}
86
+
87
+export function namedExport(name: string) {
88
+ return new NamedExport(name);
89
+}
ts/packages/ts-builders/src/File.ts
new
+40
@@ -0,0 +1,40 @@
1
+import type { AnyDeclarationBuilder } from './AnyDeclarationBuilder';
2
+import type { BasicBuilder } from './BasicBuilder';
3
+import { Export } from './Export';
4
+import type { ExportFrom } from './ExportFrom';
5
+import type { Import } from './Import';
6
+import { Writer } from './Writer';
7
+
8
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
9
+export type FileItem = AnyDeclarationBuilder | Export<any> | ExportFrom;
10
+export class File implements BasicBuilder {
11
+ private imports: Import[] = [];
12
+ private declarations: FileItem[] = [];
13
+
14
+ addImport(moduleImport: Import) {
15
+ this.imports.push(moduleImport);
16
+ return this;
17
+ }
18
+ add(declaration: FileItem) {
19
+ this.declarations.push(declaration);
20
+ }
21
+
22
+ write(writer: Writer<undefined>): void {
23
+ for (const moduleImport of this.imports) {
24
+ writer.writeLine(moduleImport);
25
+ }
26
+ if (this.imports.length > 0) {
27
+ writer.newLine();
28
+ }
29
+ for (const [i, declaration] of this.declarations.entries()) {
30
+ writer.writeLine(declaration);
31
+ if (i < this.declarations.length - 1) {
32
+ writer.newLine();
33
+ }
34
+ }
35
+ }
36
+}
37
+
38
+export function file(): File {
39
+ return new File();
40
+}
ts/packages/ts-builders/src/FunctionCall.ts
new
+26
@@ -0,0 +1,26 @@
1
+import { ValueBuilder } from './ValueBuilder';
2
+import { Writer } from './Writer';
3
+
4
+export class FunctionCall extends ValueBuilder {
5
+ #name: string;
6
+ #args: ValueBuilder[];
7
+
8
+ constructor(name: string, args: ValueBuilder[]) {
9
+ super();
10
+ this.#name = name;
11
+ this.#args = args;
12
+ }
13
+
14
+ addArgument(arg: ValueBuilder): this {
15
+ this.#args.push(arg);
16
+ return this;
17
+ }
18
+
19
+ override write(writer: Writer): void {
20
+ writer.write(this.#name).write('(').writeJoined(', ', this.#args).write(')');
21
+ }
22
+}
23
+
24
+export function functionCall(name: string, args: ValueBuilder[] = []): FunctionCall {
25
+ return new FunctionCall(name, args);
26
+}
ts/packages/ts-builders/src/FunctionType.test.ts
new
+43
@@ -0,0 +1,43 @@
1
+import { expect, test } from 'vitest';
2
+
3
+import { functionType } from './FunctionType';
4
+import { genericParameter } from './GenericParameter';
5
+import { namedType } from './NamedType';
6
+import { parameter } from './Parameter';
7
+import { stringify } from './stringify';
8
+
9
+const A = namedType('A');
10
+const B = namedType('B');
11
+
12
+test('basic', () => {
13
+ expect(stringify(functionType())).toMatchInlineSnapshot(`"() => void"`);
14
+});
15
+
16
+test('with return type', () => {
17
+ const func = functionType().setReturnType(A);
18
+ expect(stringify(func)).toMatchInlineSnapshot(`"() => A"`);
19
+});
20
+
21
+test('with parameter', () => {
22
+ const func = functionType().addParameter(parameter('param', A));
23
+ expect(stringify(func)).toMatchInlineSnapshot(`"(param: A) => void"`);
24
+});
25
+
26
+test('with multiple parameters', () => {
27
+ const func = functionType()
28
+ .addParameter(parameter('param1', A))
29
+ .addParameter(parameter('param2', B));
30
+ expect(stringify(func)).toMatchInlineSnapshot(`"(param1: A, param2: B) => void"`);
31
+});
32
+
33
+test('with generic parameter', () => {
34
+ const func = functionType().addGenericParameter(genericParameter('T'));
35
+ expect(stringify(func)).toMatchInlineSnapshot(`"<T>() => void"`);
36
+});
37
+
38
+test('with multiple generic parameters', () => {
39
+ const func = functionType()
40
+ .addGenericParameter(genericParameter('T'))
41
+ .addGenericParameter(genericParameter('U'));
42
+ expect(stringify(func)).toMatchInlineSnapshot(`"<T, U>() => void"`);
43
+});
ts/packages/ts-builders/src/FunctionType.ts
new
+40
@@ -0,0 +1,40 @@
1
+import { GenericParameter } from './GenericParameter';
2
+import { Parameter } from './Parameter';
3
+import { voidType } from './PrimitiveType';
4
+import { TypeBuilder } from './TypeBuilder';
5
+import { Writer } from './Writer';
6
+import { OperatorPrecedence, TypeContext } from './OperatorPrecedence';
7
+
8
+export class FunctionType extends TypeBuilder {
9
+ readonly precedence = OperatorPrecedence.FunctionType;
10
+ private returnType: TypeBuilder = voidType;
11
+ private parameters: Parameter[] = [];
12
+ private genericParameters: GenericParameter[] = [];
13
+
14
+ setReturnType(returnType: TypeBuilder): this {
15
+ this.returnType = returnType;
16
+ return this;
17
+ }
18
+
19
+ addParameter(param: Parameter): this {
20
+ this.parameters.push(param);
21
+ return this;
22
+ }
23
+
24
+ addGenericParameter(param: GenericParameter): this {
25
+ this.genericParameters.push(param);
26
+ return this;
27
+ }
28
+
29
+ write(writer: Writer): void {
30
+ if (this.genericParameters.length > 0) {
31
+ writer.write('<').writeJoined(', ', this.genericParameters).write('>');
32
+ }
33
+ writer.write('(').writeJoined(', ', this.parameters).write(') => ');
34
+ this.returnType.writeInContext(writer, TypeContext.FunctionReturn);
35
+ }
36
+}
37
+
38
+export function functionType(): FunctionType {
39
+ return new FunctionType();
40
+}
ts/packages/ts-builders/src/GenericParameter.test.ts
new
+26
@@ -0,0 +1,26 @@
1
+import { expect, test } from 'vitest';
2
+
3
+import { genericParameter } from './GenericParameter';
4
+import { namedType } from './NamedType';
5
+import { stringify } from './stringify';
6
+
7
+const A = namedType('A');
8
+const B = namedType('B');
9
+
10
+test('name only', () => {
11
+ expect(stringify(genericParameter('T'))).toMatchInlineSnapshot(`"T"`);
12
+});
13
+
14
+test('with extends', () => {
15
+ expect(stringify(genericParameter('T').extends(A))).toMatchInlineSnapshot(`"T extends A"`);
16
+});
17
+
18
+test('with default', () => {
19
+ expect(stringify(genericParameter('T').default(B))).toMatchInlineSnapshot(`"T = B"`);
20
+});
21
+
22
+test('with extends + default', () => {
23
+ expect(stringify(genericParameter('T').extends(A).default(B))).toMatchInlineSnapshot(
24
+ `"T extends A = B"`
25
+ );
26
+});
ts/packages/ts-builders/src/GenericParameter.ts
new
+39
@@ -0,0 +1,39 @@
1
+import type { BasicBuilder } from './BasicBuilder';
2
+import { NamedType } from './NamedType';
3
+import { TypeBuilder } from './TypeBuilder';
4
+import { Writer } from './Writer';
5
+
6
+export class GenericParameter implements BasicBuilder {
7
+ private extendedType?: TypeBuilder;
8
+ private defaultType?: TypeBuilder;
9
+
10
+ constructor(private name: string) {}
11
+
12
+ extends(type: TypeBuilder): this {
13
+ this.extendedType = type;
14
+ return this;
15
+ }
16
+
17
+ default(type: TypeBuilder): this {
18
+ this.defaultType = type;
19
+ return this;
20
+ }
21
+
22
+ toArgument(): NamedType {
23
+ return new NamedType(this.name);
24
+ }
25
+
26
+ write(writer: Writer): void {
27
+ writer.write(this.name);
28
+ if (this.extendedType) {
29
+ writer.write(' extends ').write(this.extendedType);
30
+ }
31
+ if (this.defaultType) {
32
+ writer.write(' = ').write(this.defaultType);
33
+ }
34
+ }
35
+}
36
+
37
+export function genericParameter(name: string): GenericParameter {
38
+ return new GenericParameter(name);
39
+}
ts/packages/ts-builders/src/Import.test.ts
new
+47
@@ -0,0 +1,47 @@
1
+import { expect, test } from 'vitest';
2
+
3
+import { moduleImport, namedImport } from './Import';
4
+import { stringify } from './stringify';
5
+
6
+test('module name only', () => {
7
+ expect(stringify(moduleImport('someModule'))).toMatchInlineSnapshot(`"import "someModule""`);
8
+});
9
+
10
+test('default', () => {
11
+ const importDecl = moduleImport('myModule').default('mod');
12
+ expect(stringify(importDecl)).toMatchInlineSnapshot(`"import mod from "myModule""`);
13
+});
14
+
15
+test('namespace', () => {
16
+ const importDecl = moduleImport('myModule').asNamespace('ns');
17
+ expect(stringify(importDecl)).toMatchInlineSnapshot(`"import * as ns from "myModule""`);
18
+});
19
+
20
+test('named', () => {
21
+ const importDecl = moduleImport('myModule').named('func');
22
+ expect(stringify(importDecl)).toMatchInlineSnapshot(`"import { func } from "myModule""`);
23
+});
24
+
25
+test('named with alias', () => {
26
+ const importDecl = moduleImport('myModule').named(namedImport('func').as('myFunc'));
27
+ expect(stringify(importDecl)).toMatchInlineSnapshot(
28
+ `"import { func as myFunc } from "myModule""`
29
+ );
30
+});
31
+
32
+test('multiple named', () => {
33
+ const importDecl = moduleImport('myModule')
34
+ .named('func1')
35
+ .named('func2')
36
+ .named(namedImport('func3').as('aliasedFunc3'));
37
+ expect(stringify(importDecl)).toMatchInlineSnapshot(
38
+ `"import { func1, func2, func3 as aliasedFunc3 } from "myModule""`
39
+ );
40
+});
41
+
42
+test('default and named', () => {
43
+ const importDecl = moduleImport('myModule').default('mod').named('func1').named('func2');
44
+ expect(stringify(importDecl)).toMatchInlineSnapshot(
45
+ `"import mod, { func1, func2 } from "myModule""`
46
+ );
47
+});
ts/packages/ts-builders/src/Import.ts
new
+120
@@ -0,0 +1,120 @@
1
+import type { BasicBuilder } from './BasicBuilder';
2
+import { Writer } from './Writer';
3
+
4
+export type Import = NamespaceImport | BindingsImport | ModuleImport;
5
+
6
+export class NamespaceImport implements BasicBuilder {
7
+ private type = false;
8
+
9
+ constructor(
10
+ readonly alias: string,
11
+ readonly from: string
12
+ ) {}
13
+
14
+ typeOnly() {
15
+ this.type = true;
16
+ return this;
17
+ }
18
+
19
+ write(writer: Writer<undefined>): void {
20
+ writer.write('import ');
21
+ if (this.type) {
22
+ writer.write('type ');
23
+ }
24
+ writer.write('* as ').write(this.alias).write(` from "${this.from}"`);
25
+ }
26
+}
27
+
28
+export class BindingsImport implements BasicBuilder {
29
+ private defaultImport: string | undefined;
30
+ private namedImports: NamedImport[] = [];
31
+ constructor(readonly from: string) {}
32
+
33
+ default(name: string) {
34
+ this.defaultImport = name;
35
+ return this;
36
+ }
37
+
38
+ named(namedImport: string | NamedImport) {
39
+ if (typeof namedImport === 'string') {
40
+ namedImport = new NamedImport(namedImport);
41
+ }
42
+ this.namedImports.push(namedImport);
43
+ return this;
44
+ }
45
+
46
+ write(writer: Writer): void {
47
+ writer.write('import ');
48
+ if (this.defaultImport) {
49
+ writer.write(this.defaultImport);
50
+ if (this.hasNamedImports()) {
51
+ writer.write(', ');
52
+ }
53
+ }
54
+
55
+ if (this.hasNamedImports()) {
56
+ writer.write('{ ').writeJoined(', ', this.namedImports).write(' }');
57
+ }
58
+
59
+ writer.write(` from "${this.from}"`);
60
+ }
61
+
62
+ private hasNamedImports() {
63
+ return this.namedImports.length > 0;
64
+ }
65
+}
66
+
67
+export class NamedImport implements BasicBuilder {
68
+ private alias: string | undefined;
69
+ private type = false;
70
+
71
+ constructor(readonly name: string) {}
72
+
73
+ as(alias: string) {
74
+ this.alias = alias;
75
+ return this;
76
+ }
77
+
78
+ typeOnly() {
79
+ this.type = true;
80
+ return this;
81
+ }
82
+
83
+ write(writer: Writer): void {
84
+ if (this.type) {
85
+ writer.write('type ');
86
+ }
87
+ writer.write(this.name);
88
+ if (this.alias) {
89
+ writer.write(' as ').write(this.alias);
90
+ }
91
+ }
92
+}
93
+
94
+export class ModuleImport implements BasicBuilder {
95
+ constructor(readonly from: string) {}
96
+
97
+ asNamespace(alias: string): NamespaceImport {
98
+ return new NamespaceImport(alias, this.from);
99
+ }
100
+
101
+ default(alias: string): BindingsImport {
102
+ return new BindingsImport(this.from).default(alias);
103
+ }
104
+
105
+ named(namedImport: string | NamedImport) {
106
+ return new BindingsImport(this.from).named(namedImport);
107
+ }
108
+
109
+ write(writer: Writer): void {
110
+ writer.write('import ').write(`"${this.from}"`);
111
+ }
112
+}
113
+
114
+export function moduleImport(from: string) {
115
+ return new ModuleImport(from);
116
+}
117
+
118
+export function namedImport(name: string) {
119
+ return new NamedImport(name);
120
+}
ts/packages/ts-builders/src/Interface.test.ts
new
+70
@@ -0,0 +1,70 @@
1
+import { expect, test } from 'vitest';
2
+
3
+import { genericParameter } from './GenericParameter';
4
+import { interfaceDeclaration } from './Interface';
5
+import { method } from './Method';
6
+import { namedType } from './NamedType';
7
+import { property } from './Property';
8
+import { stringify } from './stringify';
9
+
10
+const A = namedType('A');
11
+
12
+test('empty', () => {
13
+ const obj = interfaceDeclaration('MyInterface');
14
+ expect(stringify(obj)).toMatchInlineSnapshot(`
15
+ "interface MyInterface {}
16
+ "
17
+ `);
18
+});
19
+
20
+test('with property', () => {
21
+ const obj = interfaceDeclaration('SomeInterface').add(property('foo', A));
22
+ expect(stringify(obj)).toMatchInlineSnapshot(`
23
+ "interface SomeInterface {
24
+ foo: A
25
+ }"
26
+ `);
27
+});
28
+
29
+test('with method', () => {
30
+ const obj = interfaceDeclaration('MyInterface').add(method('doThing'));
31
+ expect(stringify(obj)).toMatchInlineSnapshot(`
32
+ "interface MyInterface {
33
+ doThing(): void
34
+ }"
35
+ `);
36
+});
37
+
38
+test('with generic parameter', () => {
39
+ const obj = interfaceDeclaration('SomeInterface')
40
+ .addGenericParameter(genericParameter('T').extends(namedType('U')))
41
+ .add(property('foo', A));
42
+ expect(stringify(obj)).toMatchInlineSnapshot(`
43
+ "interface SomeInterface<T extends U> {
44
+ foo: A
45
+ }"
46
+ `);
47
+});
48
+
49
+test('extending the type', () => {
50
+ const obj = interfaceDeclaration('SomeInterface')
51
+ .extends(namedType('Foo'))
52
+ .add(property('foo', A));
53
+ expect(stringify(obj)).toMatchInlineSnapshot(`
54
+ "interface SomeInterface extends Foo {
55
+ foo: A
56
+ }"
57
+ `);
58
+});
59
+
60
+test('extending multiple types', () => {
61
+ const obj = interfaceDeclaration('SomeInterface')
62
+ .extends(namedType('Foo'))
63
+ .extends(namedType('Bar'))
64
+ .add(property('foo', A));
65
+ expect(stringify(obj)).toMatchInlineSnapshot(`
66
+ "interface SomeInterface extends Foo, Bar {
67
+ foo: A
68
+ }"
69
+ `);
70
+});
ts/packages/ts-builders/src/Interface.ts
new
+72
@@ -0,0 +1,72 @@
1
+import { GenericParameter } from './GenericParameter';
2
+import { Method } from './Method';
3
+import { NamedType } from './NamedType';
4
+import { Property } from './Property';
5
+import { TypeBuilder } from './TypeBuilder';
6
+import { Writer } from './Writer';
7
+import { OperatorPrecedence } from './OperatorPrecedence';
8
+
9
+type InterfaceItem = Method | Property;
10
+
11
+export class InterfaceDeclaration extends TypeBuilder {
12
+ needsParenthesisWhenIndexed = true;
13
+ readonly precedence = OperatorPrecedence.ObjectType;
14
+
15
+ private items: InterfaceItem[] = [];
16
+ private genericParameters: GenericParameter[] = [];
17
+ private extendedTypes: NamedType[] = [];
18
+
19
+ constructor(readonly name: string) {
20
+ super();
21
+ }
22
+
23
+ add(item: InterfaceItem): this {
24
+ this.items.push(item);
25
+ return this;
26
+ }
27
+
28
+ addMultiple(items: InterfaceItem[]): this {
29
+ for (const item of items) {
30
+ this.add(item);
31
+ }
32
+ return this;
33
+ }
34
+
35
+ addGenericParameter(param: GenericParameter) {
36
+ this.genericParameters.push(param);
37
+ return this;
38
+ }
39
+
40
+ extends(type: NamedType) {
41
+ this.extendedTypes.push(type);
42
+ return this;
43
+ }
44
+
45
+ write(writer: Writer): void {
46
+ writer.write('interface ').write(this.name);
47
+ if (this.genericParameters.length > 0) {
48
+ writer.write('<').writeJoined(', ', this.genericParameters).write('>');
49
+ }
50
+
51
+ if (this.extendedTypes.length > 0) {
52
+ writer.write(' extends ').writeJoined(', ', this.extendedTypes);
53
+ }
54
+ if (this.items.length === 0) {
55
+ writer.writeLine(' {}');
56
+ return;
57
+ }
58
+
59
+ writer
60
+ .writeLine(' {')
61
+ .withIndent(() => {
62
+ for (const item of this.items) {
63
+ writer.writeLine(item);
64
+ }
65
+ })
66
+ .write('}');
67
+ }
68
+}
69
+
70
+export function interfaceDeclaration(name: string) {
71
+ return new InterfaceDeclaration(name);
72
+}
ts/packages/ts-builders/src/KeyType.test.ts
new
+36
@@ -0,0 +1,36 @@
1
+import { expect, test } from 'vitest';
2
+
3
+import { array } from './ArrayType';
4
+import { functionType } from './FunctionType';
5
+import { keyType } from './KeyType';
6
+import { namedType } from './NamedType';
7
+import { objectType } from './ObjectType';
8
+import { stringify } from './stringify';
9
+import { unionType } from './UnionType';
10
+
11
+const A = namedType('A');
12
+const B = namedType('B');
13
+const C = namedType('C');
14
+
15
+test('simple only', () => {
16
+ expect(stringify(keyType(A, 'foo'))).toMatchInlineSnapshot(`"A["foo"]"`);
17
+});
18
+
19
+test('with object type', () => {
20
+ expect(stringify(keyType(objectType(), 'toString'))).toMatchInlineSnapshot(`"({})["toString"]"`);
21
+});
22
+
23
+test('with array type', () => {
24
+ expect(stringify(keyType(array(A), 'length'))).toMatchInlineSnapshot(`"A[]["length"]"`);
25
+});
26
+
27
+test('with function type', () => {
28
+ expect(stringify(keyType(functionType(), 'length'))).toMatchInlineSnapshot(
29
+ `"(() => void)["length"]"`
30
+ );
31
+});
32
+
33
+test('with union type', () => {
34
+ const union = unionType(A).addVariant(B).addVariant(C);
35
+ expect(stringify(keyType(union, 'foo'))).toMatchInlineSnapshot(`"(A | B | C)["foo"]"`);
36
+});
ts/packages/ts-builders/src/KeyType.ts
new
+27
@@ -0,0 +1,27 @@
1
+import { TypeBuilder } from './TypeBuilder';
2
+import { NamedType } from './NamedType';
3
+import type { Writer } from './Writer';
4
+import { OperatorPrecedence, TypeContext } from './OperatorPrecedence';
5
+
6
+export class KeyType extends TypeBuilder {
7
+ readonly precedence = OperatorPrecedence.IndexAccess;
8
+
9
+ constructor(
10
+ public baseType: TypeBuilder,
11
+ public key: string | NamedType
12
+ ) {
13
+ super();
14
+ }
15
+
16
+ write(writer: Writer): void {
17
+ this.baseType.writeInContext(writer, TypeContext.IndexAccess);
18
+
19
+ const keyIndexed = this.key instanceof NamedType ? `${this.key.name}` : `"${this.key}"`;
20
+
21
+ writer.write('[').write(keyIndexed).write(']');
22
+ }
23
+}
24
+
25
+export function keyType(baseType: TypeBuilder, key: string | NamedType) {
26
+ return new KeyType(baseType, key);
27
+}
ts/packages/ts-builders/src/KeyofType.test.ts
new
+34
@@ -0,0 +1,34 @@
1
+import { expect, test } from 'vitest';
2
+
3
+import { array } from './ArrayType';
4
+import { functionType } from './FunctionType';
5
+import { keyOfType } from './KeyofType';
6
+import { namedType } from './NamedType';
7
+import { objectType } from './ObjectType';
8
+import { stringify } from './stringify';
9
+import { unionType } from './UnionType';
10
+
11
+const A = namedType('A');
12
+const B = namedType('B');
13
+const C = namedType('C');
14
+
15
+test('simple only', () => {
16
+ expect(stringify(keyOfType(A))).toMatchInlineSnapshot(`"keyof A"`);
17
+});
18
+
19
+test('with object type', () => {
20
+ expect(stringify(keyOfType(objectType()))).toMatchInlineSnapshot(`"keyof {}"`);
21
+});
22
+
23
+test('with array type', () => {
24
+ expect(stringify(keyOfType(array(A)))).toMatchInlineSnapshot(`"keyof A[]"`);
25
+});
26
+
27
+test('with function type', () => {
28
+ expect(stringify(keyOfType(functionType()))).toMatchInlineSnapshot(`"keyof (() => void)"`);
29
+});
30
+
31
+test('with union type', () => {
32
+ const union = unionType(A).addVariant(B).addVariant(C);
33
+ expect(stringify(keyOfType(union))).toMatchInlineSnapshot(`"keyof (A | B | C)"`);
34
+});
ts/packages/ts-builders/src/KeyofType.ts
new
+20
@@ -0,0 +1,20 @@
1
+import { TypeBuilder } from './TypeBuilder';
2
+import { Writer } from './Writer';
3
+import { OperatorPrecedence, TypeContext } from './OperatorPrecedence';
4
+
5
+export class KeyofType extends TypeBuilder {
6
+ readonly precedence = OperatorPrecedence.KeyofType;
7
+
8
+ constructor(public baseType: TypeBuilder) {
9
+ super();
10
+ }
11
+
12
+ write(writer: Writer): void {
13
+ writer.write(`keyof `);
14
+ this.baseType.writeInContext(writer, TypeContext.KeyofOperand);
15
+ }
16
+}
17
+
18
+export function keyOfType(baseType: TypeBuilder): KeyofType {
19
+ return new KeyofType(baseType);
20
+}
ts/packages/ts-builders/src/Method.test.ts
new
+53
@@ -0,0 +1,53 @@
1
+import { expect, test } from 'vitest';
2
+
3
+import { docComment } from './DocComment';
4
+import { genericParameter } from './GenericParameter';
5
+import { method } from './Method';
6
+import { namedType } from './NamedType';
7
+import { parameter } from './Parameter';
8
+import { stringify } from './stringify';
9
+
10
+const A = namedType('A');
11
+const B = namedType('B');
12
+
13
+test('name only', () => {
14
+ const m = method('doThings');
15
+ expect(stringify(m)).toMatchInlineSnapshot(`"doThings(): void"`);
16
+});
17
+
18
+test('with return type', () => {
19
+ const m = method('doThings').setReturnType(A);
20
+ expect(stringify(m)).toMatchInlineSnapshot(`"doThings(): A"`);
21
+});
22
+
23
+test('with doc comment', () => {
24
+ const m = method('doThings').setDocComment(docComment('Does things'));
25
+ expect(stringify(m)).toMatchInlineSnapshot(`
26
+ "/**
27
+ * Does things
28
+ */
29
+ doThings(): void"
30
+ `);
31
+});
32
+
33
+test('with parameter', () => {
34
+ const m = method('doThings').addParameter(parameter('foo', A));
35
+ expect(stringify(m)).toMatchInlineSnapshot(`"doThings(foo: A): void"`);
36
+});
37
+
38
+test('with multiple parameters', () => {
39
+ const m = method('doThings').addParameter(parameter('foo', A)).addParameter(parameter('foo', B));
40
+ expect(stringify(m)).toMatchInlineSnapshot(`"doThings(foo: A, foo: B): void"`);
41
+});
42
+
43
+test('with generic parameter', () => {
44
+ const m = method('doThings').addGenericParameter(genericParameter('T'));
45
+ expect(stringify(m)).toMatchInlineSnapshot(`"doThings<T>(): void"`);
46
+});
47
+
48
+test('with multiple generic parameters', () => {
49
+ const m = method('doThings')
50
+ .addGenericParameter(genericParameter('T'))
51
+ .addGenericParameter(genericParameter('U'));
52
+ expect(stringify(m)).toMatchInlineSnapshot(`"doThings<T, U>(): void"`);
53
+});
ts/packages/ts-builders/src/Method.ts
new
+60
@@ -0,0 +1,60 @@
1
+import type { BasicBuilder } from './BasicBuilder';
2
+import { DocComment } from './DocComment';
3
+import { GenericParameter } from './GenericParameter';
4
+import { Parameter } from './Parameter';
5
+import { voidType } from './PrimitiveType';
6
+import { TypeBuilder } from './TypeBuilder';
7
+import { Writer } from './Writer';
8
+
9
+export class Method implements BasicBuilder {
10
+ private docComment?: DocComment;
11
+ private returnType: TypeBuilder = voidType;
12
+ private parameters: Parameter[] = [];
13
+ private genericParameters: GenericParameter[] = [];
14
+ constructor(private name: string) {}
15
+
16
+ setDocComment(docComment: DocComment): this {
17
+ this.docComment = docComment;
18
+ return this;
19
+ }
20
+
21
+ setReturnType(returnType: TypeBuilder): this {
22
+ this.returnType = returnType;
23
+ return this;
24
+ }
25
+
26
+ addParameter(param: Parameter): this {
27
+ this.parameters.push(param);
28
+ return this;
29
+ }
30
+
31
+ addGenericParameter(param: GenericParameter): this {
32
+ this.genericParameters.push(param);
33
+ return this;
34
+ }
35
+
36
+ write(writer: Writer): void {
37
+ if (this.docComment) {
38
+ writer.write(this.docComment);
39
+ }
40
+
41
+ writer.write(this.name);
42
+ if (this.genericParameters.length > 0) {
43
+ writer.write('<').writeJoined(', ', this.genericParameters).write('>');
44
+ }
45
+
46
+ writer.write('(');
47
+ if (this.parameters.length > 0) {
48
+ writer.writeJoined(', ', this.parameters);
49
+ }
50
+ writer.write(')');
51
+
52
+ if (this.name !== 'constructor') {
53
+ writer.write(': ').write(this.returnType);
54
+ }
55
+ }
56
+}
57
+
58
+export function method(name: string): Method {
59
+ return new Method(name);
60
+}
ts/packages/ts-builders/src/NamedType.test.ts
new
+22
@@ -0,0 +1,22 @@
1
+import { expect, test } from 'vitest';
2
+
3
+import { namedType } from './NamedType';
4
+import { stringify } from './stringify';
5
+
6
+test('name only', () => {
7
+ expect(stringify(namedType('MyType'))).toMatchInlineSnapshot(`"MyType"`);
8
+});
9
+
10
+test('with generic argument', () => {
11
+ expect(stringify(namedType('MyType').addGenericArgument(namedType('Foo')))).toMatchInlineSnapshot(
12
+ `"MyType<Foo>"`
13
+ );
14
+});
15
+
16
+test('with multiple generic arguments', () => {
17
+ expect(
18
+ stringify(
19
+ namedType('MyType').addGenericArgument(namedType('Foo')).addGenericArgument(namedType('Bar'))
20
+ )
21
+ ).toMatchInlineSnapshot(`"MyType<Foo, Bar>"`);
22
+});
ts/packages/ts-builders/src/NamedType.ts
new
+28
@@ -0,0 +1,28 @@
1
+import { TypeBuilder } from './TypeBuilder';
2
+import { Writer } from './Writer';
3
+import { OperatorPrecedence } from './OperatorPrecedence';
4
+
5
+export class NamedType extends TypeBuilder {
6
+ readonly precedence = OperatorPrecedence.Atomic;
7
+ readonly genericArguments: TypeBuilder[] = [];
8
+
9
+ constructor(readonly name: string) {
10
+ super();
11
+ }
12
+
13
+ addGenericArgument(type: TypeBuilder): this {
14
+ this.genericArguments.push(type);
15
+ return this;
16
+ }
17
+
18
+ write(writer: Writer): void {
19
+ writer.write(this.name);
20
+ if (this.genericArguments.length > 0) {
21
+ writer.write('<').writeJoined(', ', this.genericArguments).write('>');
22
+ }
23
+ }
24
+}
25
+
26
+export function namedType(name: string): NamedType {
27
+ return new NamedType(name);
28
+}
ts/packages/ts-builders/src/NamedValue.ts
new
+19
@@ -0,0 +1,19 @@
1
+import { ValueBuilder } from './ValueBuilder';
2
+import { Writer } from './Writer';
3
+
4
+export class NamedValue extends ValueBuilder {
5
+ #name: string;
6
+
7
+ constructor(name: string) {
8
+ super();
9
+ this.#name = name;
10
+ }
11
+
12
+ override write(writer: Writer): void {
13
+ writer.write(this.#name);
14
+ }
15
+}
16
+
17
+export function namedValue(name: string): NamedValue {
18
+ return new NamedValue(name);
19
+}
ts/packages/ts-builders/src/NamespaceDeclaration.ts
new
+29
@@ -0,0 +1,29 @@
1
+import type { AnyDeclarationBuilder } from './AnyDeclarationBuilder';
2
+import type { BasicBuilder } from './BasicBuilder';
3
+import { Export } from './Export';
4
+import { Writer } from './Writer';
5
+
6
+export type NamespaceItem = AnyDeclarationBuilder | Export<AnyDeclarationBuilder>;
7
+export class NamespaceDeclaration implements BasicBuilder {
8
+ private items: NamespaceItem[] = [];
9
+ constructor(readonly name: string) {}
10
+
11
+ add(declaration: NamespaceItem) {
12
+ this.items.push(declaration);
13
+ }
14
+
15
+ write(writer: Writer<undefined>): void {
16
+ writer
17
+ .writeLine(`namespace ${this.name} {`)
18
+ .withIndent(() => {
19
+ for (const item of this.items) {
20
+ writer.writeLine(item);
21
+ }
22
+ })
23
+ .write('}');
24
+ }
25
+}
26
+
27
+export function namespace(name: string): NamespaceDeclaration {
28
+ return new NamespaceDeclaration(name);
29
+}
ts/packages/ts-builders/src/ObjectType.test.ts
new
+37
@@ -0,0 +1,37 @@
1
+import { expect, test } from 'vitest';
2
+
3
+import { method } from './Method';
4
+import { namedType } from './NamedType';
5
+import { objectType } from './ObjectType';
6
+import { property } from './Property';
7
+import { stringify } from './stringify';
8
+
9
+const A = namedType('A');
10
+
11
+test('empty', () => {
12
+ const obj = objectType();
13
+ expect(stringify(obj)).toMatchInlineSnapshot(`"{}"`);
14
+});
15
+
16
+test('with property', () => {
17
+ const obj = objectType().add(property('foo', A));
18
+ expect(stringify(obj)).toMatchInlineSnapshot(`
19
+ "{
20
+ foo: A
21
+ }"
22
+ `);
23
+});
24
+
25
+test('with method', () => {
26
+ const obj = objectType().add(method('doThing'));
27
+ expect(stringify(obj)).toMatchInlineSnapshot(`
28
+ "{
29
+ doThing(): void
30
+ }"
31
+ `);
32
+});
33
+
34
+test('inline formatting', () => {
35
+ const obj = objectType().add(property('foo', A)).formatInline();
36
+ expect(stringify(obj)).toMatchInlineSnapshot(`"{ foo: A }"`);
37
+});
ts/packages/ts-builders/src/ObjectType.ts
new
+60
@@ -0,0 +1,60 @@
1
+import { Method } from './Method';
2
+import { Property } from './Property';
3
+import { TypeBuilder } from './TypeBuilder';
4
+import { Writer } from './Writer';
5
+import { OperatorPrecedence } from './OperatorPrecedence';
6
+
7
+type ObjectTypeItem = Method | Property;
8
+
9
+export class ObjectType extends TypeBuilder {
10
+ readonly precedence = OperatorPrecedence.ObjectType;
11
+
12
+ private items: ObjectTypeItem[] = [];
13
+ private inline = false;
14
+
15
+ add(item: ObjectTypeItem): this {
16
+ this.items.push(item);
17
+ return this;
18
+ }
19
+
20
+ addMultiple(items: ObjectTypeItem[]): this {
21
+ for (const item of items) {
22
+ this.add(item);
23
+ }
24
+ return this;
25
+ }
26
+
27
+ formatInline() {
28
+ this.inline = true;
29
+ return this;
30
+ }
31
+
32
+ write(writer: Writer): void {
33
+ if (this.items.length === 0) {
34
+ writer.write('{}');
35
+ } else if (this.inline) {
36
+ this.writeInline(writer);
37
+ } else {
38
+ this.writeMultiline(writer);
39
+ }
40
+ }
41
+
42
+ private writeMultiline(writer: Writer) {
43
+ writer
44
+ .writeLine('{')
45
+ .withIndent(() => {
46
+ for (const item of this.items) {
47
+ writer.writeLine(item);
48
+ }
49
+ })
50
+ .write('}');
51
+ }
52
+
53
+ private writeInline(writer: Writer) {
54
+ writer.write('{ ').writeJoined(', ', this.items).write(' }');
55
+ }
56
+}
57
+
58
+export function objectType() {
59
+ return new ObjectType();
60
+}
ts/packages/ts-builders/src/ObjectValue.ts
new
+60
@@ -0,0 +1,60 @@
1
+import { ValueBuilder } from './ValueBuilder';
2
+import { PropertyValue } from './PropertyValue';
3
+import type { Writer } from './Writer';
4
+
5
+type ObjectTypeItem = PropertyValue;
6
+
7
+export class ObjectValue extends ValueBuilder {
8
+ needsParenthesisWhenIndexed = true;
9
+
10
+ private items: ObjectTypeItem[] = [];
11
+ private inline = false;
12
+
13
+ add(item: ObjectTypeItem): this {
14
+ this.items.push(item);
15
+ return this;
16
+ }
17
+
18
+ addMultiple(items: ObjectTypeItem[]): this {
19
+ for (const item of items) {
20
+ this.add(item);
21
+ }
22
+ return this;
23
+ }
24
+
25
+ formatInline() {
26
+ this.inline = true;
27
+ return this;
28
+ }
29
+
30
+ write(writer: Writer): void {
31
+ if (this.items.length === 0) {
32
+ writer.write('{}');
33
+ } else if (this.inline) {
34
+ this.writeInline(writer);
35
+ } else {
36
+ this.writeMultiline(writer);
37
+ }
38
+ }
39
+
40
+ private writeMultiline(writer: Writer) {
41
+ writer
42
+ .writeLine('{')
43
+ .withIndent(() => {
44
+ for (const item of this.items) {
45
+ writer.write(item);
46
+ writer.write(',');
47
+ writer.newLine();
48
+ }
49
+ })
50
+ .write('}');
51
+ }
52
+
53
+ private writeInline(writer: Writer) {
54
+ writer.write('{ ').writeJoined(', ', this.items).write(' }');
55
+ }
56
+}
57
+
58
+export function objectValue() {
59
+ return new ObjectValue();
60
+}
ts/packages/ts-builders/src/OperatorPrecedence.ts
new
+89
@@ -0,0 +1,89 @@
1
+/* eslint-disable @typescript-eslint/no-duplicate-enum-values */
2
+
3
+/**
4
+ * TypeScript operator precedence levels for automatic parentheses placement.
5
+ * Higher numbers indicate higher precedence (bind more tightly).
6
+ *
7
+ * Based on TypeScript/JavaScript operator precedence:
8
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
9
+ */
10
+export enum OperatorPrecedence {
11
+ // Lowest precedence
12
+ Union = 1, // A | B
13
+ Intersection = 2, // A & B
14
+ Conditional = 3, // A extends B ? C : D
15
+
16
+ // Typeof types are special cases, see:
17
+ // https://stackoverflow.com/questions/70102722/whats-the-precedence-of-typescript-operators#comment123924051_70102722
18
+ TypeofType = 4, // typeof T
19
+
20
+ // Function types
21
+ FunctionType = 4, // () => void
22
+
23
+ // Object types (lower precedence than arrays so they need parentheses in more contexts)
24
+ ObjectType = 5, // { a: string }
25
+
26
+ // Array and tuple types
27
+ ArrayType = 6, // T[]
28
+ TupleType = 6, // [A, B, C]
29
+
30
+ // Indexing and property access
31
+ IndexAccess = 7, // T[K]
32
+
33
+ // Unary operators
34
+ KeyofType = 8, // keyof T
35
+
36
+ // Highest precedence (atomic types, least likely to need parentheses)
37
+ Atomic = 10, // string, number, boolean, literal types, named types
38
+}
39
+
40
+/**
41
+ * Context in which a type is being written, used to determine if parentheses are needed
42
+ */
43
+export enum TypeContext {
44
+ Root = 'root', // Top-level, no context
45
+ UnionMember = 'union_member', // Inside a union type
46
+ IntersectionMember = 'intersection_member', // Inside an intersection type
47
+ ArrayElement = 'array_element', // T in T[]
48
+ TupleElement = 'tuple_element', // T in [T, ...]
49
+ IndexAccess = 'index_access', // T in T[K] or K in T[K]
50
+ KeyofOperand = 'keyof_operand', // T in keyof T
51
+ TypeofOperand = 'typeof_operand', // T in typeof T
52
+ FunctionReturn = 'function_return', // T in () => T
53
+ FunctionParameter = 'function_parameter', // T in (x: T) => void
54
+ ObjectProperty = 'object_property', // T in { prop: T }
55
+ ConditionalCheck = 'conditional_check', // T in T extends U ? V : W
56
+ ConditionalTrue = 'conditional_true', // V in T extends U ? V : W
57
+ ConditionalFalse = 'conditional_false', // W in T extends U ? V : W
58
+}
59
+
60
+/**
61
+ * Maps contexts to the minimum precedence level that doesn't require parentheses
62
+ */
63
+export const CONTEXT_PRECEDENCE: Record<TypeContext, OperatorPrecedence> = {
64
+ [TypeContext.Root]: OperatorPrecedence.Union,
65
+ [TypeContext.UnionMember]: OperatorPrecedence.ArrayType, // Functions (4) < ArrayType (6) = true, parentheses added
66
+ [TypeContext.IntersectionMember]: OperatorPrecedence.Conditional,
67
+ [TypeContext.ArrayElement]: OperatorPrecedence.Atomic, // Objects (5) < Atomic (10) = true, parentheses added
68
+ [TypeContext.TupleElement]: OperatorPrecedence.ArrayType,
69
+ [TypeContext.IndexAccess]: OperatorPrecedence.ArrayType, // Objects (5) < ArrayType (6) = true, Arrays (6) < ArrayType (6) = false
70
+ [TypeContext.KeyofOperand]: OperatorPrecedence.ObjectType, // Functions (4) < ObjectType (5) = true, Unions (1) < ObjectType (5) = true, Objects (5) < ObjectType (5) = false, Arrays (6) < ObjectType (5) = false
71
+ [TypeContext.FunctionReturn]: OperatorPrecedence.FunctionType,
72
+ [TypeContext.TypeofOperand]: OperatorPrecedence.TypeofType,
73
+ [TypeContext.FunctionParameter]: OperatorPrecedence.FunctionType,
74
+ [TypeContext.ObjectProperty]: OperatorPrecedence.ObjectType,
75
+ [TypeContext.ConditionalCheck]: OperatorPrecedence.Conditional,
76
+ [TypeContext.ConditionalTrue]: OperatorPrecedence.Conditional,
77
+ [TypeContext.ConditionalFalse]: OperatorPrecedence.Conditional,
78
+};
79
+
80
+/**
81
+ * Determines if parentheses are needed when writing a type in a given context
82
+ */
83
+export function needsParentheses(
84
+ typePrecedence: OperatorPrecedence,
85
+ context: TypeContext
86
+): boolean {
87
+ const contextPrecedence = CONTEXT_PRECEDENCE[context];
88
+ return typePrecedence < contextPrecedence;
89
+}
ts/packages/ts-builders/src/Parameter.test.ts
new
+19
@@ -0,0 +1,19 @@
1
+import { expect, test } from 'vitest';
2
+
3
+import { namedType } from './NamedType';
4
+import { parameter } from './Parameter';
5
+import { stringify } from './stringify';
6
+
7
+const A = namedType('A');
8
+
9
+test('name and type', () => {
10
+ const param = parameter('foo', A);
11
+
12
+ expect(stringify(param)).toMatchInlineSnapshot(`"foo: A"`);
13
+});
14
+
15
+test('optional', () => {
16
+ const param = parameter('foo', A).optional();
17
+
18
+ expect(stringify(param)).toMatchInlineSnapshot(`"foo?: A"`);
19
+});
ts/packages/ts-builders/src/Parameter.ts
new
+28
@@ -0,0 +1,28 @@
1
+import type { BasicBuilder } from './BasicBuilder';
2
+import { TypeBuilder } from './TypeBuilder';
3
+import { Writer } from './Writer';
4
+
5
+export class Parameter implements BasicBuilder {
6
+ private isOptional = false;
7
+ constructor(
8
+ private name: string,
9
+ private type: TypeBuilder
10
+ ) {}
11
+
12
+ optional(): this {
13
+ this.isOptional = true;
14
+ return this;
15
+ }
16
+
17
+ write(writer: Writer): void {
18
+ writer.write(this.name);
19
+ if (this.isOptional) {
20
+ writer.write('?');
21
+ }
22
+ writer.write(': ').write(this.type);
23
+ }
24
+}
25
+
26
+export function parameter(name: string, type: TypeBuilder) {
27
+ return new Parameter(name, type);
28
+}
ts/packages/ts-builders/src/PrimitiveType.ts
new
+27
@@ -0,0 +1,27 @@
1
+import { TypeBuilder } from './TypeBuilder';
2
+import { Writer } from './Writer';
3
+import { OperatorPrecedence } from './OperatorPrecedence';
4
+
5
+export class PrimitiveType extends TypeBuilder {
6
+ readonly precedence = OperatorPrecedence.Atomic;
7
+
8
+ constructor(private name: string) {
9
+ super();
10
+ }
11
+
12
+ write(writer: Writer): void {
13
+ writer.write(this.name);
14
+ }
15
+}
16
+
17
+export const stringType = new PrimitiveType('string');
18
+export const numberType = new PrimitiveType('number');
19
+export const booleanType = new PrimitiveType('boolean');
20
+export const nullType = new PrimitiveType('null');
21
+export const undefinedType = new PrimitiveType('undefined');
22
+export const bigintType = new PrimitiveType('bigint');
23
+export const unknownType = new PrimitiveType('unknown');
24
+export const anyType = new PrimitiveType('any');
25
+export const voidType = new PrimitiveType('void');
26
+export const thisType = new PrimitiveType('this');
27
+export const neverType = new PrimitiveType('never');
ts/packages/ts-builders/src/Property.test.ts
new
+50
@@ -0,0 +1,50 @@
1
+import { expect, test } from 'vitest';
2
+
3
+import { docComment } from './DocComment';
4
+import { namedType } from './NamedType';
5
+import { property } from './Property';
6
+import { stringify } from './stringify';
7
+import { toStringTag } from './WellKnownSymbol';
8
+
9
+const A = namedType('A');
10
+
11
+test('name and type', () => {
12
+ const prop = property('foo', A);
13
+
14
+ expect(stringify(prop)).toMatchInlineSnapshot(`"foo: A"`);
15
+});
16
+
17
+test('invalid identifier', () => {
18
+ const prop = property('this is not a valid JS identifier', A);
19
+
20
+ expect(stringify(prop)).toMatchInlineSnapshot(`"["this is not a valid JS identifier"]: A"`);
21
+});
22
+
23
+test('well-known symbol', () => {
24
+ const prop = property(toStringTag, A);
25
+
26
+ expect(stringify(prop)).toMatchInlineSnapshot(`"[Symbol.toStringTag]: A"`);
27
+});
28
+
29
+test('optional', () => {
30
+ const prop = property('foo', A).optional();
31
+
32
+ expect(stringify(prop)).toMatchInlineSnapshot(`"foo?: A"`);
33
+});
34
+
35
+test('readonly', () => {
36
+ const prop = property('foo', A).readonly();
37
+
38
+ expect(stringify(prop)).toMatchInlineSnapshot(`"readonly foo: A"`);
39
+});
40
+
41
+test('with doc comment', () => {
42
+ const prop = property('foo', A).setDocComment(docComment('This is foo'));
43
+
44
+ expect(stringify(prop)).toMatchInlineSnapshot(`
45
+ "/**
46
+ * This is foo
47
+ */
48
+ foo: A"
49
+ `);
50
+});
ts/packages/ts-builders/src/Property.ts
new
+60
@@ -0,0 +1,60 @@
1
+import type { BasicBuilder } from './BasicBuilder';
2
+import { DocComment } from './DocComment';
3
+import { isValidJsIdentifier } from './isValidJsIdentifier';
4
+import { TypeBuilder } from './TypeBuilder';
5
+import { WellKnownSymbol } from './WellKnownSymbol';
6
+import { Writer } from './Writer';
7
+
8
+export class Property implements BasicBuilder {
9
+ private isOptional = false;
10
+ private isReadonly = false;
11
+ private docComment?: DocComment;
12
+
13
+ constructor(
14
+ private name: string | WellKnownSymbol,
15
+ private type: TypeBuilder
16
+ ) {}
17
+
18
+ optional(): this {
19
+ this.isOptional = true;
20
+ return this;
21
+ }
22
+
23
+ readonly(): this {
24
+ this.isReadonly = true;
25
+ return this;
26
+ }
27
+
28
+ setDocComment(docComment: DocComment): this {
29
+ this.docComment = docComment;
30
+ return this;
31
+ }
32
+
33
+ write(writer: Writer): void {
34
+ if (this.docComment) {
35
+ writer.write(this.docComment);
36
+ }
37
+ if (this.isReadonly) {
38
+ writer.write('readonly ');
39
+ }
40
+
41
+ if (typeof this.name === 'string') {
42
+ if (isValidJsIdentifier(this.name)) {
43
+ writer.write(this.name);
44
+ } else {
45
+ writer.write('[').write(JSON.stringify(this.name)).write(']');
46
+ }
47
+ } else {
48
+ writer.write('[').write(this.name).write(']');
49
+ }
50
+
51
+ if (this.isOptional) {
52
+ writer.write('?');
53
+ }
54
+ writer.write(': ').write(this.type);
55
+ }
56
+}
57
+
58
+export function property(name: string | WellKnownSymbol, type: TypeBuilder) {
59
+ return new Property(name, type);
60
+}
ts/packages/ts-builders/src/PropertyValue.ts
new
+46
@@ -0,0 +1,46 @@
1
+import { DocComment } from './DocComment';
2
+import { WellKnownSymbol } from './WellKnownSymbol';
3
+import { ValueBuilder } from './ValueBuilder';
4
+import { Writer } from './Writer';
5
+import type { BasicBuilder } from './BasicBuilder';
6
+
7
+export class PropertyValue implements BasicBuilder {
8
+ private isOptional = false;
9
+ private docComment?: DocComment;
10
+
11
+ constructor(
12
+ public name: string | WellKnownSymbol,
13
+ public value: ValueBuilder
14
+ ) {}
15
+
16
+ optional(): this {
17
+ this.isOptional = true;
18
+ return this;
19
+ }
20
+
21
+ setDocComment(docComment: DocComment): this {
22
+ this.docComment = docComment;
23
+ return this;
24
+ }
25
+
26
+ write(writer: Writer): void {
27
+ if (this.docComment) {
28
+ writer.write(this.docComment);
29
+ }
30
+
31
+ if (typeof this.name === 'string') {
32
+ writer.write(this.name);
33
+ } else {
34
+ writer.write('[').write(this.name).write(']');
35
+ }
36
+
37
+ if (this.isOptional) {
38
+ writer.write('?');
39
+ }
40
+ writer.write(': ').write(this.value);
41
+ }
42
+}
43
+
44
+export function propertyValue(name: string | WellKnownSymbol, value: ValueBuilder) {
45
+ return new PropertyValue(name, value);
46
+}
ts/packages/ts-builders/src/QuoteStyle.test.ts
new
+90
@@ -0,0 +1,90 @@
1
+import { describe, it, expect } from 'vitest';
2
+import { QuoteStyle, escapeStringContent } from './QuoteStyle';
3
+import { stringLiteral } from './StringLiteralType';
4
+import { Writer } from './Writer';
5
+
6
+describe('QuoteStyle', () => {
7
+ describe('escapeStringContent', () => {
8
+ it('should format with double quotes', () => {
9
+ expect(escapeStringContent('hello', QuoteStyle.Double)).toBe('"hello"');
10
+ expect(escapeStringContent('hello "world"', QuoteStyle.Double)).toBe('"hello \\"world\\""');
11
+ expect(escapeStringContent("hello 'world'", QuoteStyle.Double)).toBe('"hello \'world\'"');
12
+ });
13
+
14
+ it('should format with single quotes', () => {
15
+ expect(escapeStringContent('hello', QuoteStyle.Single)).toBe("'hello'");
16
+ expect(escapeStringContent("hello 'world'", QuoteStyle.Single)).toBe("'hello \\'world\\''");
17
+ expect(escapeStringContent('hello "world"', QuoteStyle.Single)).toBe('\'hello "world"\'');
18
+ });
19
+
20
+ it('should format with backticks', () => {
21
+ expect(escapeStringContent('hello', QuoteStyle.Backtick)).toBe('`hello`');
22
+ expect(escapeStringContent('hello `world`', QuoteStyle.Backtick)).toBe('`hello \\`world\\``');
23
+ expect(escapeStringContent('hello $world', QuoteStyle.Backtick)).toBe('`hello \\$world`');
24
+ });
25
+
26
+ it('should handle backslashes correctly', () => {
27
+ expect(escapeStringContent('hello\\world', QuoteStyle.Double)).toBe('"hello\\\\world"');
28
+ expect(escapeStringContent('hello\\world', QuoteStyle.Single)).toBe("'hello\\\\world'");
29
+ expect(escapeStringContent('hello\\world', QuoteStyle.Backtick)).toBe('`hello\\\\world`');
30
+ });
31
+ });
32
+
33
+ describe('StringLiteralType with different quote styles', () => {
34
+ it('should use double quotes by default', () => {
35
+ const literal = stringLiteral('hello world');
36
+ const writer = new Writer(0, undefined);
37
+ literal.write(writer);
38
+ expect(writer.toString()).toBe('"hello world"');
39
+ });
40
+
41
+ it('should use single quotes when configured', () => {
42
+ const literal = stringLiteral('hello world');
43
+ const writer = new Writer(0, undefined, { quoteStyle: QuoteStyle.Single });
44
+ literal.write(writer);
45
+ expect(writer.toString()).toBe("'hello world'");
46
+ });
47
+
48
+ it('should use backticks when configured', () => {
49
+ const literal = stringLiteral('hello world');
50
+ const writer = new Writer(0, undefined, { quoteStyle: QuoteStyle.Backtick });
51
+ literal.write(writer);
52
+ expect(writer.toString()).toBe('`hello world`');
53
+ });
54
+
55
+ it('should handle quotes in content correctly', () => {
56
+ const literal = stringLiteral('hello "world"');
57
+
58
+ // Double quotes - content quotes are escaped
59
+ const doubleWriter = new Writer(0, undefined, { quoteStyle: QuoteStyle.Double });
60
+ literal.write(doubleWriter);
61
+ expect(doubleWriter.toString()).toBe('"hello \\"world\\""');
62
+
63
+ // Single quotes - content quotes are not escaped
64
+ const singleWriter = new Writer(0, undefined, { quoteStyle: QuoteStyle.Single });
65
+ literal.write(singleWriter);
66
+ expect(singleWriter.toString()).toBe('\'hello "world"\'');
67
+ });
68
+
69
+ it('should handle single quotes in content correctly', () => {
70
+ const literal = stringLiteral("hello 'world'");
71
+
72
+ // Double quotes - content quotes are not escaped
73
+ const doubleWriter = new Writer(0, undefined, { quoteStyle: QuoteStyle.Double });
74
+ literal.write(doubleWriter);
75
+ expect(doubleWriter.toString()).toBe('"hello \'world\'"');
76
+
77
+ // Single quotes - content quotes are escaped
78
+ const singleWriter = new Writer(0, undefined, { quoteStyle: QuoteStyle.Single });
79
+ literal.write(singleWriter);
80
+ expect(singleWriter.toString()).toBe("'hello \\'world\\''");
81
+ });
82
+
83
+ it('should handle special characters in backticks', () => {
84
+ const literal = stringLiteral('hello `$world`');
85
+ const writer = new Writer(0, undefined, { quoteStyle: QuoteStyle.Backtick });
86
+ literal.write(writer);
87
+ expect(writer.toString()).toBe('`hello \\`\\$world\\``');
88
+ });
89
+ });
90
+});
ts/packages/ts-builders/src/QuoteStyle.ts
new
+46
@@ -0,0 +1,46 @@
1
+/**
2
+ * Configuration for quote styles in string literals
3
+ */
4
+
5
+export enum QuoteStyle {
6
+ /** Use double quotes: "hello" */
7
+ Double = 'double',
8
+ /** Use single quotes: 'hello' */
9
+ Single = 'single',
10
+ /** Use backticks for template literals: `hello` */
11
+ Backtick = 'backtick',
12
+}
13
+
14
+/**
15
+ * Configuration options for code generation
16
+ */
17
+export interface FormattingOptions {
18
+ /** Quote style for string literals */
19
+ quoteStyle: QuoteStyle;
20
+}
21
+
22
+/**
23
+ * Default formatting options
24
+ */
25
+export const DEFAULT_FORMATTING_OPTIONS: FormattingOptions = {
26
+ quoteStyle: QuoteStyle.Double,
27
+};
28
+
29
+/**
30
+ * Escapes a string content for the specified quote style
31
+ */
32
+export function escapeStringContent(content: string, quoteStyle: QuoteStyle): string {
33
+ switch (quoteStyle) {
34
+ case QuoteStyle.Double:
35
+ return JSON.stringify(content);
36
+
37
+ case QuoteStyle.Single:
38
+ return "'" + content.replace(/\\/g, '\\\\').replace(/'/g, "\\'") + "'";
39
+
40
+ case QuoteStyle.Backtick:
41
+ return '`' + content.replace(/\\/g, '\\\\').replace(/`/g, '\\`').replace(/\$/g, '\\$') + '`';
42
+
43
+ default:
44
+ throw new Error(`Unsupported quote style: ${quoteStyle}`);
45
+ }
46
+}
ts/packages/ts-builders/src/StringLiteralType.ts
new
+39
@@ -0,0 +1,39 @@
1
+import { TypeBuilder } from './TypeBuilder';
2
+import { ValueBuilder } from './ValueBuilder';
3
+import { Writer } from './Writer';
4
+import { OperatorPrecedence } from './OperatorPrecedence';
5
+import { escapeStringContent } from './QuoteStyle';
6
+
7
+export class StringLiteralType extends TypeBuilder {
8
+ readonly precedence = OperatorPrecedence.Atomic;
9
+
10
+ constructor(readonly content: string) {
11
+ super();
12
+ }
13
+
14
+ write(writer: Writer): void {
15
+ const escaped = escapeStringContent(this.content, writer.formattingOptions.quoteStyle);
16
+ writer.write(escaped);
17
+ }
18
+
19
+ asValue(): StringLiteralValue {
20
+ return new StringLiteralValue(this);
21
+ }
22
+}
23
+
24
+export class StringLiteralValue extends ValueBuilder {
25
+ #type: StringLiteralType;
26
+
27
+ constructor(type: StringLiteralType) {
28
+ super();
29
+ this.#type = type;
30
+ }
31
+
32
+ override write(writer: Writer): void {
33
+ writer.write(this.#type);
34
+ }
35
+}
36
+
37
+export function stringLiteral(content: string) {
38
+ return new StringLiteralType(content);
39
+}
ts/packages/ts-builders/src/TupleType.test.ts
new
+25
@@ -0,0 +1,25 @@
1
+import { expect, test } from 'vitest';
2
+
3
+import { namedType } from './NamedType';
4
+import { stringify } from './stringify';
5
+import { tupleItem, tupleType } from './TupleType';
6
+
7
+test('empty', () => {
8
+ const tuple = tupleType();
9
+ expect(stringify(tuple)).toMatchInlineSnapshot(`"[]"`);
10
+});
11
+
12
+test('one item', () => {
13
+ const tuple = tupleType().add(namedType('A'));
14
+ expect(stringify(tuple)).toMatchInlineSnapshot(`"[A]"`);
15
+});
16
+
17
+test('with named item', () => {
18
+ const tuple = tupleType().add(tupleItem(namedType('A')).setName('foo'));
19
+ expect(stringify(tuple)).toMatchInlineSnapshot(`"[foo: A]"`);
20
+});
21
+
22
+test('multiple items', () => {
23
+ const tuple = tupleType().add(namedType('A')).add(namedType('B')).add(namedType('C'));
24
+ expect(stringify(tuple)).toMatchInlineSnapshot(`"[A, B, C]"`);
25
+});
ts/packages/ts-builders/src/TupleType.ts
new
+46
@@ -0,0 +1,46 @@
1
+import type { BasicBuilder } from './BasicBuilder';
2
+import { TypeBuilder } from './TypeBuilder';
3
+import { Writer } from './Writer';
4
+import { OperatorPrecedence } from './OperatorPrecedence';
5
+
6
+export class TupleItem implements BasicBuilder {
7
+ private name: string | undefined;
8
+ constructor(readonly type: TypeBuilder) {}
9
+
10
+ setName(name: string) {
11
+ this.name = name;
12
+ return this;
13
+ }
14
+
15
+ write(writer: Writer<undefined>): void {
16
+ if (this.name) {
17
+ writer.write(this.name).write(': ');
18
+ }
19
+ writer.write(this.type);
20
+ }
21
+}
22
+
23
+export class TupleType extends TypeBuilder {
24
+ readonly precedence = OperatorPrecedence.TupleType;
25
+ readonly items: TupleItem[] = [];
26
+
27
+ add(item: TypeBuilder | TupleItem) {
28
+ if (item instanceof TypeBuilder) {
29
+ item = new TupleItem(item);
30
+ }
31
+ this.items.push(item);
32
+ return this;
33
+ }
34
+
35
+ override write(writer: Writer): void {
36
+ writer.write('[').writeJoined(', ', this.items).write(']');
37
+ }
38
+}
39
+
40
+export function tupleType() {
41
+ return new TupleType();
42
+}
43
+
44
+export function tupleItem(type: TypeBuilder) {
45
+ return new TupleItem(type);
46
+}
ts/packages/ts-builders/src/TypeBuilder.ts
new
+33
@@ -0,0 +1,33 @@
1
+import type { BasicBuilder } from './BasicBuilder';
2
+import { Writer } from './Writer';
3
+import { OperatorPrecedence, TypeContext, needsParentheses } from './OperatorPrecedence';
4
+
5
+export abstract class TypeBuilder implements BasicBuilder {
6
+ /**
7
+ * The precedence level of this type builder.
8
+ * Used to determine when parentheses are needed automatically.
9
+ */
10
+ abstract readonly precedence: OperatorPrecedence;
11
+
12
+ abstract write(writer: Writer): void;
13
+
14
+ /**
15
+ * Writes this type with parentheses if needed in the given context
16
+ */
17
+ writeInContext(writer: Writer, context: TypeContext): void {
18
+ if (needsParentheses(this.precedence, context)) {
19
+ writer.write('(');
20
+ this.write(writer);
21
+ writer.write(')');
22
+ } else {
23
+ this.write(writer);
24
+ }
25
+ }
26
+
27
+ /**
28
+ * @deprecated Use writeInContext with TypeContext.IndexAccess instead
29
+ */
30
+ writeIndexed(writer: Writer) {
31
+ this.writeInContext(writer, TypeContext.IndexAccess);
32
+ }
33
+}
ts/packages/ts-builders/src/TypeDeclaration.test.ts
new
+35
@@ -0,0 +1,35 @@
1
+import { expect, test } from 'vitest';
2
+
3
+import { docComment } from './DocComment';
4
+import { genericParameter } from './GenericParameter';
5
+import { namedType } from './NamedType';
6
+import { stringify } from './stringify';
7
+import { typeDeclaration } from './TypeDeclaration';
8
+
9
+const A = namedType('A');
10
+
11
+test('basic', () => {
12
+ expect(stringify(typeDeclaration('B', A))).toMatchInlineSnapshot(`"type B = A"`);
13
+});
14
+
15
+test('with doc comment', () => {
16
+ const decl = typeDeclaration('B', A).setDocComment(docComment('Type for stuff'));
17
+ expect(stringify(decl)).toMatchInlineSnapshot(`
18
+ "/**
19
+ * Type for stuff
20
+ */
21
+ type B = A"
22
+ `);
23
+});
24
+
25
+test('with generic parameters', () => {
26
+ const decl = typeDeclaration('B', A).addGenericParameter(genericParameter('T'));
27
+ expect(stringify(decl)).toMatchInlineSnapshot(`"type B<T> = A"`);
28
+});
29
+
30
+test('with multiple generic parameters', () => {
31
+ const decl = typeDeclaration('B', A)
32
+ .addGenericParameter(genericParameter('T'))
33
+ .addGenericParameter(genericParameter('U'));
34
+ expect(stringify(decl)).toMatchInlineSnapshot(`"type B<T, U> = A"`);
35
+});
ts/packages/ts-builders/src/TypeDeclaration.ts
new
+48
@@ -0,0 +1,48 @@
1
+import type { BasicBuilder } from './BasicBuilder';
2
+import { DocComment } from './DocComment';
3
+import { GenericParameter } from './GenericParameter';
4
+import { TypeBuilder } from './TypeBuilder';
5
+import { Writer } from './Writer';
6
+
7
+export class TypeDeclaration<InnerType extends TypeBuilder = TypeBuilder> implements BasicBuilder {
8
+ private genericParameters: GenericParameter[] = [];
9
+ private docComment?: DocComment;
10
+
11
+ constructor(
12
+ public name: string,
13
+ readonly type: InnerType
14
+ ) {}
15
+
16
+ addGenericParameter(param: GenericParameter): this {
17
+ this.genericParameters.push(param);
18
+ return this;
19
+ }
20
+
21
+ setName(name: string) {
22
+ this.name = name;
23
+ return this;
24
+ }
25
+
26
+ setDocComment(docComment: DocComment): this {
27
+ this.docComment = docComment;
28
+ return this;
29
+ }
30
+
31
+ write(writer: Writer): void {
32
+ if (this.docComment) {
33
+ writer.write(this.docComment);
34
+ }
35
+ writer.write('type ').write(this.name);
36
+ if (this.genericParameters.length > 0) {
37
+ writer.write('<').writeJoined(', ', this.genericParameters).write('>');
38
+ }
39
+ writer.write(' = ').write(this.type);
40
+ }
41
+}
42
+
43
+export function typeDeclaration<InnerType extends TypeBuilder = TypeBuilder>(
44
+ name: string,
45
+ type: InnerType
46
+) {
47
+ return new TypeDeclaration(name, type);
48
+}
ts/packages/ts-builders/src/TypeOf.ts
new
+20
@@ -0,0 +1,20 @@
1
+import { TypeBuilder } from './TypeBuilder';
2
+import type { Writer } from './Writer';
3
+import { OperatorPrecedence, TypeContext } from './OperatorPrecedence';
4
+
5
+export class TypeofType extends TypeBuilder {
6
+ readonly precedence = OperatorPrecedence.TypeofType;
7
+
8
+ constructor(public baseType: TypeBuilder) {
9
+ super();
10
+ }
11
+
12
+ write(writer: Writer): void {
13
+ writer.write(`typeof `);
14
+ this.baseType.writeInContext(writer, TypeContext.TypeofOperand);
15
+ }
16
+}
17
+
18
+export function typeOfType(baseType: TypeBuilder): TypeofType {
19
+ return new TypeofType(baseType);
20
+}
ts/packages/ts-builders/src/UnionType.multiline.test.ts
new
+59
@@ -0,0 +1,59 @@
1
+import { describe, it, expect } from 'vitest';
2
+import { unionType } from './UnionType';
3
+import { namedType } from './NamedType';
4
+import { stringLiteral } from './StringLiteralType';
5
+import { Writer } from './Writer';
6
+
7
+describe('UnionType multiline formatting', () => {
8
+ it('should format simple union types in multiline style', () => {
9
+ const union = unionType([namedType('string'), namedType('number'), namedType('boolean')]);
10
+
11
+ const writer = new Writer(0, undefined);
12
+ union.formatMultiline().write(writer);
13
+
14
+ expect(writer.toString()).toBe(['', ' | string', ' | number', ' | boolean'].join('\n'));
15
+ });
16
+
17
+ it('should format string literal union types in multiline style', () => {
18
+ const union = unionType([
19
+ stringLiteral('success'),
20
+ stringLiteral('error'),
21
+ stringLiteral('pending'),
22
+ ]);
23
+
24
+ const writer = new Writer(0, undefined);
25
+ union.formatMultiline().write(writer);
26
+
27
+ expect(writer.toString()).toBe(
28
+ ['', ' | "success"', ' | "error"', ' | "pending"'].join('\n')
29
+ );
30
+ });
31
+
32
+ it('should still format inline when multiline is not enabled', () => {
33
+ const union = unionType([namedType('string'), namedType('number'), namedType('boolean')]);
34
+
35
+ const writer = new Writer(0, undefined);
36
+ union.write(writer);
37
+
38
+ expect(writer.toString()).toBe('string | number | boolean');
39
+ });
40
+
41
+ it('should handle single variant union in multiline', () => {
42
+ const union = unionType(namedType('string'));
43
+
44
+ const writer = new Writer(0, undefined);
45
+ union.formatMultiline().write(writer);
46
+
47
+ expect(writer.toString()).toBe(['', ' | string'].join('\n'));
48
+ });
49
+
50
+ it('should handle empty variants gracefully', () => {
51
+ const union = unionType([namedType('string')]);
52
+ union.variants.length = 0; // Force empty for edge case test
53
+
54
+ const writer = new Writer(0, undefined);
55
+ union.formatMultiline().write(writer);
56
+
57
+ expect(writer.toString()).toBe('');
58
+ });
59
+});
ts/packages/ts-builders/src/UnionType.test.ts
new
+39
@@ -0,0 +1,39 @@
1
+import { expect, test } from 'vitest';
2
+
3
+import { array } from './ArrayType';
4
+import { functionType } from './FunctionType';
5
+import { namedType } from './NamedType';
6
+import { stringify } from './stringify';
7
+import { unionType } from './UnionType';
8
+
9
+const A = namedType('A');
10
+const B = namedType('B');
11
+
12
+test('one type', () => {
13
+ expect(stringify(unionType(A))).toMatchInlineSnapshot(`"A"`);
14
+});
15
+
16
+test('multiple types', () => {
17
+ expect(stringify(unionType(A).addVariant(B))).toMatchInlineSnapshot(`"A | B"`);
18
+});
19
+
20
+test('from array', () => {
21
+ expect(stringify(unionType([A, B]))).toMatchInlineSnapshot(`"A | B"`);
22
+});
23
+
24
+test('with function type', () => {
25
+ expect(stringify(unionType([A, B, functionType()]))).toMatchInlineSnapshot(
26
+ `"A | B | (() => void)"`
27
+ );
28
+});
29
+
30
+test('fails with empty array', () => {
31
+ expect(() => unionType([])).toThrowErrorMatchingInlineSnapshot(
32
+ `[TypeError: Union types array can not be empty]`
33
+ );
34
+});
35
+
36
+test('mapVariants', () => {
37
+ const union = unionType([A, B]).mapVariants(array);
38
+ expect(stringify(union)).toMatchInlineSnapshot(`"A[] | B[]"`);
39
+});
ts/packages/ts-builders/src/UnionType.ts
new
+92
@@ -0,0 +1,92 @@
1
+import { TypeBuilder } from './TypeBuilder';
2
+import { Writer } from './Writer';
3
+import { OperatorPrecedence, TypeContext } from './OperatorPrecedence';
4
+
5
+export class UnionType<VariantType extends TypeBuilder = TypeBuilder> extends TypeBuilder {
6
+ readonly precedence = OperatorPrecedence.Union;
7
+ readonly variants: VariantType[];
8
+ private multiline = false;
9
+
10
+ constructor(firstType: VariantType) {
11
+ super();
12
+ this.variants = [firstType];
13
+ }
14
+
15
+ addVariant(variant: VariantType) {
16
+ this.variants.push(variant);
17
+ return this;
18
+ }
19
+
20
+ addVariants(variants: VariantType[]) {
21
+ for (const variant of variants) {
22
+ this.addVariant(variant);
23
+ }
24
+ return this;
25
+ }
26
+
27
+ /**
28
+ * Format this union type in multi-line style:
29
+ * type SomeUnion =
30
+ * | UnionVariantA
31
+ * | UnionVariantB
32
+ * | UnionVariantC;
33
+ */
34
+ formatMultiline() {
35
+ this.multiline = true;
36
+ return this;
37
+ }
38
+
39
+ write(writer: Writer): void {
40
+ if (this.multiline) {
41
+ this.writeMultiline(writer);
42
+ } else {
43
+ this.writeInline(writer);
44
+ }
45
+ }
46
+
47
+ private writeInline(writer: Writer): void {
48
+ writer.writeJoined(' | ', this.variants, (variant, writer) => {
49
+ variant.writeInContext(writer, TypeContext.UnionMember);
50
+ });
51
+ }
52
+
53
+ private writeMultiline(writer: Writer): void {
54
+ if (this.variants.length === 0) {
55
+ return;
56
+ }
57
+
58
+ const nestedWriter = writer.writeLine('').indent();
59
+
60
+ // All variants with pipe symbol and indentation
61
+ for (let i = 0; i < this.variants.length; i++) {
62
+ if (i > 0) {
63
+ nestedWriter.writeLine('');
64
+ }
65
+
66
+ nestedWriter.write('| ');
67
+ this.variants[i].writeInContext(nestedWriter, TypeContext.UnionMember);
68
+ }
69
+ }
70
+
71
+ mapVariants<NewVariantType extends TypeBuilder>(
72
+ callback: (type: VariantType) => NewVariantType
73
+ ): UnionType<NewVariantType> {
74
+ return unionType(this.variants.map(v => callback(v)));
75
+ }
76
+}
77
+
78
+export function unionType<VariantType extends TypeBuilder = TypeBuilder>(
79
+ types: VariantType[] | VariantType
80
+) {
81
+ if (Array.isArray(types)) {
82
+ if (types.length === 0) {
83
+ throw new TypeError('Union types array can not be empty');
84
+ }
85
+ const union = new UnionType(types[0]);
86
+ for (let i = 1; i < types.length; i++) {
87
+ union.addVariant(types[i]);
88
+ }
89
+ return union;
90
+ }
91
+ return new UnionType(types);
92
+}
ts/packages/ts-builders/src/ValueBuilder.ts
new
+27
@@ -0,0 +1,27 @@
1
+import type { BasicBuilder } from './BasicBuilder';
2
+import { TypeBuilder } from './TypeBuilder';
3
+import { Writer } from './Writer';
4
+
5
+export abstract class ValueBuilder implements BasicBuilder {
6
+ as(type: TypeBuilder): TypeAssertion {
7
+ return new TypeAssertion(this, type);
8
+ }
9
+
10
+ abstract write(writer: Writer<undefined>): void;
11
+}
12
+
13
+// Must be in the same file due to a circular dependency
14
+export class TypeAssertion extends ValueBuilder {
15
+ #value: ValueBuilder;
16
+ #type: TypeBuilder;
17
+
18
+ constructor(value: ValueBuilder, type: TypeBuilder) {
19
+ super();
20
+ this.#value = value;
21
+ this.#type = type;
22
+ }
23
+
24
+ override write(writer: Writer): void {
25
+ writer.write(this.#value).write(' as ').write(this.#type);
26
+ }
27
+}
ts/packages/ts-builders/src/WellKnownSymbol.ts
new
+15
@@ -0,0 +1,15 @@
1
+import type { BasicBuilder } from './BasicBuilder';
2
+import { Writer } from './Writer';
3
+
4
+export class WellKnownSymbol implements BasicBuilder {
5
+ constructor(readonly name: string) {}
6
+ write(writer: Writer<undefined>): void {
7
+ writer.write('Symbol.').write(this.name);
8
+ }
9
+}
10
+
11
+export function wellKnownSymbol(name: string) {
12
+ return new WellKnownSymbol(name);
13
+}
14
+
15
+export const toStringTag = wellKnownSymbol('toStringTag');
ts/packages/ts-builders/src/Writer.test.ts
new
+123
@@ -0,0 +1,123 @@
1
+import { expect, test } from 'vitest';
2
+
3
+import { Writer } from './Writer';
4
+
5
+test('write string', () => {
6
+ const writer = new Writer(0, undefined);
7
+ writer.write('A').write('B').write('C');
8
+ expect(writer.toString()).toBe('ABC');
9
+});
10
+
11
+test('write builder', () => {
12
+ const builder = {
13
+ write(writer: Writer) {
14
+ writer.write('hello from builder');
15
+ },
16
+ };
17
+ const writer = new Writer(0, undefined);
18
+ writer.write(builder);
19
+ expect(writer.toString()).toBe('hello from builder');
20
+});
21
+
22
+test('newLine', () => {
23
+ const writer = new Writer(0, undefined);
24
+ writer.newLine();
25
+ expect(writer.toString()).toBe('\n');
26
+});
27
+
28
+test('writeLine', () => {
29
+ const writer = new Writer(0, undefined);
30
+ writer.writeLine('A').writeLine('B').writeLine('C');
31
+ expect(writer.toString()).toBe('A\nB\nC\n');
32
+});
33
+
34
+test('writeJoined with strings', () => {
35
+ const writer = new Writer(0, undefined);
36
+ writer.writeJoined(', ', ['A', 'B', 'C']);
37
+ expect(writer.toString()).toBe('A, B, C');
38
+});
39
+
40
+test('writeJoined with builder values', () => {
41
+ const writer = new Writer(0, undefined);
42
+
43
+ const builder = {
44
+ write(writer: Writer) {
45
+ writer.write('builder');
46
+ },
47
+ };
48
+ writer.writeJoined(', ', [builder, builder, builder]);
49
+ expect(writer.toString()).toBe('builder, builder, builder');
50
+});
51
+
52
+test('writeJoined with builder separator', () => {
53
+ const writer = new Writer(0, undefined);
54
+
55
+ const separator = {
56
+ write(writer: Writer) {
57
+ writer.write('|');
58
+ },
59
+ };
60
+ writer.writeJoined(separator, ['A', 'B', 'C']);
61
+ expect(writer.toString()).toBe('A|B|C');
62
+});
63
+
64
+test('writeJoined empty', () => {
65
+ const writer = new Writer(0, undefined);
66
+ writer.writeJoined(', ', []);
67
+ expect(writer.toString()).toBe('');
68
+});
69
+
70
+test('indent', () => {
71
+ const writer = new Writer(0, undefined);
72
+ writer.indent().write('A');
73
+ expect(writer.toString()).toBe(' A');
74
+});
75
+
76
+test('indent + unindent', () => {
77
+ const writer = new Writer(0, undefined);
78
+ writer.writeLine('A').indent().writeLine('B').unindent().writeLine('C');
79
+ expect(writer.toString()).toBe('A\n B\nC\n');
80
+});
81
+
82
+test('unindent beyond 0', () => {
83
+ const writer = new Writer(0, undefined);
84
+ writer.unindent().unindent().write('A');
85
+ expect(writer.toString()).toBe('A');
86
+});
87
+
88
+test('withIndent', () => {
89
+ const writer = new Writer(0, undefined);
90
+ writer
91
+ .writeLine('A')
92
+ .withIndent(() => writer.writeLine('B'))
93
+ .writeLine('C');
94
+ expect(writer.toString()).toBe('A\n B\nC\n');
95
+});
96
+
97
+test('after next newline callback', () => {
98
+ const writer = new Writer(0, undefined);
99
+ writer.afterNextNewline(() => {
100
+ writer.writeLine('---');
101
+ });
102
+ writer.writeLine('foo');
103
+ writer.writeLine('bar');
104
+ expect(writer.toString()).toBe('foo\n---\nbar\n');
105
+});
106
+
107
+test('margin symbol', () => {
108
+ const writer = new Writer(0, undefined);
109
+ writer
110
+ .writeLine('{')
111
+ .withIndent(() => {
112
+ writer.addMarginSymbol('+').writeLine('foo').writeLine('bar');
113
+ })
114
+ .writeLine('}');
115
+
116
+ expect(writer.toString()).toMatchInlineSnapshot(`
117
+ "{
118
+ + foo
119
+ bar
120
+ }
121
+ "
122
+ `);
123
+});
ts/packages/ts-builders/src/Writer.ts
new
+179
@@ -0,0 +1,179 @@
1
+import type { BasicBuilder } from './BasicBuilder';
2
+import type { FormattingOptions } from './QuoteStyle';
3
+import { DEFAULT_FORMATTING_OPTIONS } from './QuoteStyle';
4
+
5
+export const INDENT_SIZE = 2;
6
+/**
7
+ * Helper class for building long multi-line formatted strings from building blocks.
8
+ * Can use either plain strings or `Builder` objects, that would encapsulate formatting logic.
9
+ */
10
+export class Writer<ContextType = undefined> {
11
+ private lines: string[] = [];
12
+ private currentLine = '';
13
+ private currentIndent = 0;
14
+ private marginSymbol?: string;
15
+ private afterNextNewLineCallback?: () => void;
16
+ readonly formattingOptions: FormattingOptions;
17
+
18
+ constructor(
19
+ startingIndent = 0,
20
+ readonly context: ContextType,
21
+ formattingOptions: Partial<FormattingOptions> = {}
22
+ ) {
23
+ this.currentIndent = startingIndent;
24
+ this.formattingOptions = { ...DEFAULT_FORMATTING_OPTIONS, ...formattingOptions };
25
+ }
26
+
27
+ /**
28
+ * Adds provided value to the current line. Does not end the line.
29
+ *
30
+ * @param value
31
+ * @returns
32
+ */
33
+ write(value: string | BasicBuilder<ContextType>): this {
34
+ if (typeof value === 'string') {
35
+ this.currentLine += value;
36
+ } else {
37
+ value.write(this);
38
+ }
39
+ return this;
40
+ }
41
+
42
+ /**
43
+ * Adds several `values` to the current line, separated by `separator`. Both values and separator
44
+ * can also be `Builder` instances for more advanced formatting.
45
+ *
46
+ * @param separator
47
+ * @param values
48
+ * @param writeItem allow to customize how individual item is written
49
+ * @returns
50
+ */
51
+ writeJoined<T extends string | BasicBuilder<ContextType>>(
52
+ separator: string | BasicBuilder<ContextType>,
53
+ values: T[],
54
+ writeItem: (item: T, writer: this) => void = (item, w) => w.write(item)
55
+ ): this {
56
+ const last = values.length - 1;
57
+ for (let i = 0; i < values.length; i++) {
58
+ writeItem(values[i], this);
59
+ if (i !== last) {
60
+ this.write(separator);
61
+ }
62
+ }
63
+ return this;
64
+ }
65
+
66
+ /**
67
+ * Adds a string to current line, flushes current line and starts a new line.
68
+ * @param line
69
+ * @returns
70
+ */
71
+ writeLine(line: string | BasicBuilder<ContextType>): this {
72
+ return this.write(line).newLine();
73
+ }
74
+
75
+ /**
76
+ * Flushes current line and starts a new line. New line starts at previously configured indentation level
77
+ * @returns
78
+ */
79
+ newLine(): this {
80
+ this.lines.push(this.indentedCurrentLine());
81
+ this.currentLine = '';
82
+ this.marginSymbol = undefined;
83
+
84
+ const afterNextNewLineCallback = this.afterNextNewLineCallback;
85
+ this.afterNextNewLineCallback = undefined;
86
+ afterNextNewLineCallback?.();
87
+ return this;
88
+ }
89
+
90
+ /**
91
+ * Increases indentation level by 1, calls provided callback and then decreases indentation again.
92
+ * Could be used for writing indented blocks of text:
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * writer
97
+ * .writeLine('{')
98
+ * .withIndent(() => {
99
+ * writer.writeLine('foo: 123');
100
+ * writer.writeLine('bar: 456');
101
+ * })
102
+ * .writeLine('}')
103
+ * ```
104
+ * @param callback
105
+ * @returns
106
+ */
107
+ withIndent(callback: (writer: this) => void): this {
108
+ this.indent();
109
+ callback(this);
110
+ this.unindent();
111
+ return this;
112
+ }
113
+
114
+ /**
115
+ * Calls provided callback next time when new line is started.
116
+ * Callback is called after old line have already been flushed and a new
117
+ * line have been started. Can be used for adding "between the lines" decorations,
118
+ * such as underlines.
119
+ *
120
+ * @param callback
121
+ * @returns
122
+ */
123
+ afterNextNewline(callback: () => void) {
124
+ this.afterNextNewLineCallback = callback;
125
+ return this;
126
+ }
127
+
128
+ /**
129
+ * Increases indentation level of the current line by 1
130
+ * @returns
131
+ */
132
+ indent(): this {
133
+ this.currentIndent++;
134
+ return this;
135
+ }
136
+
137
+ /**
138
+ * Decreases indentation level of the current line by 1, if it is possible
139
+ * @returns
140
+ */
141
+ unindent(): this {
142
+ if (this.currentIndent > 0) {
143
+ this.currentIndent--;
144
+ }
145
+ return this;
146
+ }
147
+
148
+ /**
149
+ * Adds a symbol, that will replace the first character of the current line (including indentation)
150
+ * when it is flushed. Can be used for adding markers to the line.
151
+ *
152
+ * Note: if indentation level of the line is 0, it will replace the first actually printed character
153
+ * of the line. Use with caution.
154
+ * @param symbol
155
+ * @returns
156
+ */
157
+ addMarginSymbol(symbol: string): this {
158
+ this.marginSymbol = symbol;
159
+ return this;
160
+ }
161
+
162
+ toString() {
163
+ return this.lines.concat(this.indentedCurrentLine()).join('\n');
164
+ }
165
+
166
+ getCurrentLineLength() {
167
+ return this.currentLine.length;
168
+ }
169
+
170
+ private indentedCurrentLine(): string {
171
+ const line = this.currentLine.padStart(
172
+ this.currentLine.length + INDENT_SIZE * this.currentIndent
173
+ );
174
+ if (this.marginSymbol) {
175
+ return this.marginSymbol + line.slice(1);
176
+ }
177
+ return line;
178
+ }
179
+}
ts/packages/ts-builders/src/helpers.ts
new
+6
@@ -0,0 +1,6 @@
1
+import { NamedType, namedType } from './NamedType';
2
+import { TypeBuilder } from './TypeBuilder';
3
+
4
+export function omit(type: TypeBuilder, keyType: TypeBuilder): NamedType {
5
+ return namedType('Omit').addGenericArgument(type).addGenericArgument(keyType);
6
+}
ts/packages/ts-builders/src/index.ts
new
+42
@@ -0,0 +1,42 @@
1
+export * from './AnyDeclarationBuilder';
2
+export * from './ArraySpread';
3
+export * from './ArrayType';
4
+export * from './BasicBuilder';
5
+export * from './Class';
6
+export * from './ConstDeclaration';
7
+export * from './DocComment';
8
+export * from './Export';
9
+export * from './ExportFrom';
10
+export * from './File';
11
+export * from './FunctionCall';
12
+export * from './FunctionType';
13
+export * from './GenericParameter';
14
+export * from './helpers';
15
+export * from './Import';
16
+export * from './Interface';
17
+export * from './KeyofType';
18
+export * from './KeyType';
19
+export * from './Method';
20
+export * from './NamedType';
21
+export * from './NamedValue';
22
+export * from './NamespaceDeclaration';
23
+export * from './ObjectType';
24
+export * from './ObjectValue';
25
+export * from './OperatorPrecedence';
26
+export * from './Parameter';
27
+export * from './PrimitiveType';
28
+export * from './Property';
29
+export * from './PropertyValue';
30
+export * from './QuoteStyle';
31
+export * from './stringify';
32
+export * from './StringLiteralType';
33
+export * from './TupleType';
34
+export * from './TypeBuilder';
35
+export * from './TypeDeclaration';
36
+export * from './TypeOf';
37
+export * from './UnionType';
38
+export * from './ValueBuilder';
39
+export * from './WellKnownSymbol';
40
+export * from './Writer';
41
+
42
+export { isValidJsIdentifier } from './isValidJsIdentifier';
ts/packages/ts-builders/src/isValidJsIdentifier.ts
new
+5
@@ -0,0 +1,5 @@
1
+import { isIdentifierName } from '@babel/helper-validator-identifier';
2
+
3
+export function isValidJsIdentifier(name: string): boolean {
4
+ return isIdentifierName(name);
5
+}
ts/packages/ts-builders/src/stringify.ts
new
+30
@@ -0,0 +1,30 @@
1
+import type { BasicBuilder } from './BasicBuilder';
2
+import { Writer } from './Writer';
3
+
4
+export function assertNever(_arg: never, errorMessage: string): never {
5
+ throw new Error(errorMessage);
6
+}
7
+
8
+type StringifyOptions = {
9
+ indentLevel?: number;
10
+ newLine?: 'none' | 'leading' | 'trailing' | 'both';
11
+};
12
+
13
+export function stringify(
14
+ builder: BasicBuilder,
15
+ { indentLevel = 0, newLine = 'none' }: StringifyOptions = {}
16
+) {
17
+ const str = new Writer(indentLevel, undefined).write(builder).toString();
18
+ switch (newLine) {
19
+ case 'none':
20
+ return str;
21
+ case 'leading':
22
+ return '\n' + str;
23
+ case 'trailing':
24
+ return str + '\n';
25
+ case 'both':
26
+ return '\n' + str + '\n';
27
+ default:
28
+ assertNever(newLine, 'Unexpected value');
29
+ }
30
+}
ts/packages/ts-builders/tsconfig.json
new
+8
@@ -0,0 +1,8 @@
1
+{
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": "./tsconfig.options.json",
4
+ "compilerOptions": {
5
+ "rootDir": "."
6
+ },
7
+ "include": ["src"]
8
+}
ts/packages/ts-builders/tsconfig.options.json
new
+23
@@ -0,0 +1,23 @@
1
+{
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "compilerOptions": {
4
+ "target": "ESNext",
5
+ "module": "ESNext",
6
+ "declaration": true,
7
+ "outDir": "./dist",
8
+ "rootDir": ".",
9
+ "strict": true,
10
+ "esModuleInterop": true,
11
+ "moduleResolution": "node",
12
+ "skipLibCheck": true,
13
+ "resolveJsonModule": true,
14
+ "verbatimModuleSyntax": true,
15
+ "pretty": true,
16
+ "noImplicitReturns": true,
17
+ "noFallthroughCasesInSwitch": true,
18
+ "noUnusedLocals": false,
19
+ "noUnusedParameters": false
20
+ },
21
+ "include": ["src"],
22
+ "exclude": ["**/dist", "test/__fixtures__/**"]
23
+}
ts/packages/ts-builders/tsconfig.src.json
new
+13
@@ -0,0 +1,13 @@
1
+{
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": "./tsconfig.options.json",
4
+ "compilerOptions": {
5
+ "outDir": "./dist",
6
+ "rootDir": ".",
7
+ "paths": {
8
+ "src/*": ["./src/*"]
9
+ }
10
+ },
11
+ "include": ["src"],
12
+ "exclude": ["src/**/*.test.ts"]
13
+}
ts/packages/ts-builders/tsconfig.test.json
new
+12
@@ -0,0 +1,12 @@
1
+{
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": "./tsconfig.options.json",
4
+ "compilerOptions": {
5
+ "rootDir": ".",
6
+ "paths": {
7
+ "src/*": ["./src/*"],
8
+ "test/*": ["./test/*"]
9
+ }
10
+ },
11
+ "include": ["test"]
12
+}
ts/packages/ts-builders/tsup.config.ts
new
+11
@@ -0,0 +1,11 @@
1
+import { defineConfig } from 'tsup';
2
+
3
+export default defineConfig({
4
+ entry: ['src/index.ts'],
5
+ format: ['esm'],
6
+ dts: true,
7
+ clean: true,
8
+ minify: false,
9
+ outDir: 'dist',
10
+ tsconfig: './tsconfig.src.json',
11
+});