@devries-cameron20 / composio Mirror · read-only / commits / b414316ce
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 23, 01:45 UTC

Fix tests

haxzie committed May 28, 2025 at 17:35 UTC b414316cea94d5af040ef9689238710da7b3061e
4 files changed +78 -58
packages/core/src/models/Triggers.ts
+8 -7
@@ -385,7 +385,7 @@ export class Triggers {
385 id: data.metadata.id,
386 triggerSlug: data.metadata.triggerName,
387 toolkitSlug: data.appName,
388 - userId: data.metadata.connection.clientUniqueUserId,
388 + userId: data.metadata.connection?.clientUniqueUserId,
389 payload: data.payload,
390 originalPayload: data.originalPayload,
391 metadata: {
@@ -393,13 +393,14 @@ export class Triggers {
393 triggerConfig: data.metadata.triggerConfig,
394 triggerSlug: data.metadata.triggerName,
395 toolkitSlug: data.appName,
396 + triggerData: data.metadata.triggerData,
397 connectedAccount: {
397 - id: data.metadata.connection.connectedAccountNanoId,
398 - uuid: data.metadata.connection.id,
399 - authConfigId: data.metadata.connection.authConfigNanoId,
400 - authConfigUUID: data.metadata.connection.integrationId,
401 - userId: data.metadata.connection.clientUniqueUserId,
402 - status: data.metadata.connection.status,
398 + id: data.metadata.connection?.connectedAccountNanoId,
399 + uuid: data.metadata.connection?.id,
400 + authConfigId: data.metadata.connection?.authConfigNanoId,
401 + authConfigUUID: data.metadata.connection?.integrationId,
402 + userId: data.metadata.connection?.clientUniqueUserId,
403 + status: data.metadata.connection?.status,
404 },
405 },
406 } as IncomingTriggerPayload);
packages/core/src/types/triggers.types.ts
+2 -2
@@ -97,8 +97,8 @@ export const IncomingTriggerPayloadSchema = z.object({
97 triggerSlug: z.string().describe('The slug of the trigger that triggered the event'),
98 toolkitSlug: z.string().describe('The slug of the toolkit that triggered the event'),
99 userId: z.string().describe('The ID of the user that triggered the event'),
100 - payload: z.record(z.unknown()).describe('The payload of the trigger'),
101 - originalPayload: z.record(z.unknown()).describe('The original payload of the trigger'),
100 + payload: z.record(z.unknown()).describe('The payload of the trigger').optional(),
101 + originalPayload: z.record(z.unknown()).describe('The original payload of the trigger').optional(),
102 metadata: z.object({
103 id: z.string(),
104 toolkitSlug: z.string(),
packages/core/test/models/triggers.test.ts
+63 -45
@@ -139,7 +139,7 @@ const mockTriggerData: TriggerData = {
139 integrationId: 'github',
140 authConfigNanoId: 'auth-123',
141 clientUniqueUserId: 'user-456',
142 - status: 'enable',
142 + status: 'ACTIVE',
143 },
144 },
145 };
@@ -607,14 +607,15 @@ describe('Triggers', () => {
607 originalPayload: { action: 'push', repository: 'test-repo' },
608 metadata: {
609 id: 'trigger-123',
610 - connectionId: 'conn-123',
610 triggerName: 'github_webhook',
611 triggerConfig: { webhook_url: 'https://example.com/webhook' },
612 connection: {
613 id: 'conn-123',
614 + connectedAccountNanoId: 'conn-123',
615 integrationId: 'github',
616 + authConfigNanoId: 'auth-123',
617 clientUniqueUserId: 'user-456',
617 - status: 'enable',
618 + status: 'ACTIVE',
619 },
620 },
621 };
@@ -630,8 +631,19 @@ describe('Triggers', () => {
631 expect(mockCallback).toHaveBeenCalledWith(
632 expect.objectContaining({
633 id: 'trigger-123',
634 + triggerSlug: 'github_webhook',
635 + toolkitSlug: 'github',
636 + payload: { action: 'push', repository: 'test-repo' },
637 metadata: expect.objectContaining({
634 - triggerData: undefined,
638 + id: 'trigger-123',
639 + triggerSlug: 'github_webhook',
640 + toolkitSlug: 'github',
641 + connectedAccount: expect.objectContaining({
642 + id: 'conn-123',
643 + uuid: 'conn-123',
644 + authConfigId: 'auth-123',
645 + status: 'ACTIVE',
646 + }),
647 }),
648 })
649 );
@@ -673,6 +685,40 @@ describe('Triggers', () => {
685 expect(callback1).not.toHaveBeenCalled();
686 expect(callback2).toHaveBeenCalledTimes(1);
687 });
688 +
689 + it('should pass the parsed trigger data to callback when filters match', async () => {
690 + await triggers.subscribe(mockCallback);
691 +
692 + const subscribeCall = vi.mocked(mockPusherService.subscribe).mock.calls[0];
693 + const filterCallback = subscribeCall[0];
694 +
695 + filterCallback(mockTriggerData);
696 +
697 + expect(mockCallback).toHaveBeenCalledTimes(1);
698 + expect(mockCallback).toHaveBeenCalledWith(
699 + expect.objectContaining({
700 + id: 'trigger-123',
701 + triggerSlug: 'github_webhook',
702 + toolkitSlug: 'github',
703 + userId: 'user-456',
704 + payload: { action: 'push', repository: 'test-repo' },
705 + metadata: expect.objectContaining({
706 + id: 'trigger-123',
707 + triggerSlug: 'github_webhook',
708 + toolkitSlug: 'github',
709 + triggerConfig: { webhook_url: 'https://example.com/webhook' },
710 + connectedAccount: expect.objectContaining({
711 + id: 'conn-123',
712 + uuid: 'conn-123',
713 + authConfigId: 'auth-123',
714 + authConfigUUID: 'github',
715 + userId: 'user-456',
716 + status: 'ACTIVE',
717 + }),
718 + }),
719 + })
720 + );
721 + });
722 });
723
724 describe('unsubscribe', () => {
@@ -728,13 +774,23 @@ describe('Triggers', () => {
774 expect(mockCallback).toHaveBeenCalledWith(
775 expect.objectContaining({
776 id: 'trigger-123',
731 - clientId: '123',
777 triggerSlug: 'github_webhook',
778 toolkitSlug: 'github',
779 + userId: 'user-456',
780 payload: { action: 'push', repository: 'test-repo' },
781 metadata: expect.objectContaining({
736 - connectedAccountId: 'conn-123',
737 - triggerName: 'github_webhook',
782 + id: 'trigger-123',
783 + triggerSlug: 'github_webhook',
784 + toolkitSlug: 'github',
785 + triggerConfig: { webhook_url: 'https://example.com/webhook' },
786 + connectedAccount: expect.objectContaining({
787 + id: 'conn-123',
788 + uuid: 'conn-123',
789 + authConfigId: 'auth-123',
790 + authConfigUUID: 'github',
791 + userId: 'user-456',
792 + status: 'ACTIVE',
793 + }),
794 }),
795 })
796 );
@@ -795,44 +851,6 @@ describe('Triggers', () => {
851 expect(mockCallback).not.toHaveBeenCalled();
852 });
853
798 - it('should handle partial trigger data with missing optional fields', async () => {
799 - const partialTriggerData = {
800 - appName: 'github',
801 - clientId: 123,
802 - payload: { action: 'push', repository: 'test-repo' },
803 - originalPayload: { action: 'push', repository: 'test-repo' },
804 - metadata: {
805 - id: 'trigger-123',
806 - connectionId: 'conn-123',
807 - triggerName: 'github_webhook',
808 - triggerConfig: { webhook_url: 'https://example.com/webhook' },
809 - connection: {
810 - id: 'conn-123',
811 - integrationId: 'github',
812 - clientUniqueUserId: 'user-456',
813 - status: 'enable',
814 - },
815 - },
816 - };
817 -
818 - await triggers.subscribe(mockCallback);
819 -
820 - const subscribeCall = vi.mocked(mockPusherService.subscribe).mock.calls[0];
821 - const filterCallback = subscribeCall[0];
822 -
823 - // Should not throw for missing optional fields
824 - expect(() => filterCallback(partialTriggerData)).not.toThrow();
825 - expect(mockCallback).toHaveBeenCalledTimes(1);
826 - expect(mockCallback).toHaveBeenCalledWith(
827 - expect.objectContaining({
828 - id: 'trigger-123',
829 - metadata: expect.objectContaining({
830 - triggerData: undefined,
831 - }),
832 - })
833 - );
834 - });
835 -
854 it('should handle multiple callbacks with different filters', async () => {
855 const callback1 = vi.fn();
856 const callback2 = vi.fn();
packages/providers/google/src/index.ts
+5 -4
@@ -52,11 +52,12 @@ export class GoogleProvider extends BaseNonAgenticProvider<GoogleGenAIToolCollec
52 return {
53 name: tool.slug,
54 description: tool.description || '',
55 - parameters: (tool.inputParameters ?? {
55 + parameters: {
56 type: 'object',
57 - properties: {},
58 - required: [],
59 - }) as unknown as Schema,
57 + description: tool.description || '',
58 + properties: tool.inputParameters?.properties || {},
59 + required: tool.inputParameters?.required || [],
60 + } as unknown as Schema,
61 };
62 }
63