1+ #!/usr/bin/env node
2+
3+ /**
4+ * Test specific trigger by ID to diagnose the missing trigger issue
5+ */
6+
7+ const path = require ( 'path' ) ;
8+
9+ // Set up proper paths for LibreChat
10+ process . chdir ( path . join ( __dirname , '..' , '..' ) ) ;
11+ require ( 'dotenv' ) . config ( ) ;
12+
13+ const { createBackendClient } = require ( '@pipedream/sdk/server' ) ;
14+
15+ // Initialize Pipedream client
16+ const client = createBackendClient ( {
17+ environment : process . env . NODE_ENV === 'production' ? 'production' : 'development' ,
18+ projectId : process . env . PIPEDREAM_PROJECT_ID ,
19+ credentials : {
20+ clientId : process . env . PIPEDREAM_CLIENT_ID ,
21+ clientSecret : process . env . PIPEDREAM_CLIENT_SECRET ,
22+ } ,
23+ } ) ;
24+
25+ async function testSpecificTrigger ( ) {
26+ console . log ( '🔍 TESTING SPECIFIC TRIGGER' ) ;
27+ console . log ( '============================' ) ;
28+
29+ const userId = '68627669a4d589b864fbaabc' ;
30+ const deploymentId = 'dc_Ajuvkm0' ; // New deployment ID from latest deploy
31+
32+ console . log ( `User ID: ${ userId } ` ) ;
33+ console . log ( `Deployment ID: ${ deploymentId } ` ) ;
34+
35+ // Test 1: Try to get the specific trigger by ID
36+ console . log ( '\n📋 Test 1: Get trigger by ID' ) ;
37+ try {
38+ const triggerResult = await client . getTrigger ( {
39+ id : deploymentId ,
40+ externalUserId : userId ,
41+ } ) ;
42+ console . log ( '✅ Trigger found:' , JSON . stringify ( triggerResult , null , 2 ) ) ;
43+ } catch ( error ) {
44+ console . log ( '❌ Error getting trigger by ID:' , error . message ) ;
45+ if ( error . response ) {
46+ console . log ( ' Response status:' , error . response . status ) ;
47+ console . log ( ' Response data:' , JSON . stringify ( error . response . data , null , 2 ) ) ;
48+ }
49+ }
50+
51+ // Test 2: Try to update the trigger
52+ console . log ( '\n⚙️ Test 2: Update trigger (test if it exists)' ) ;
53+ try {
54+ const updateResult = await client . updateTrigger ( {
55+ id : deploymentId ,
56+ externalUserId : userId ,
57+ active : true ,
58+ } ) ;
59+ console . log ( '✅ Update successful:' , JSON . stringify ( updateResult , null , 2 ) ) ;
60+ } catch ( error ) {
61+ console . log ( '❌ Error updating trigger:' , error . message ) ;
62+ if ( error . response ) {
63+ console . log ( ' Response status:' , error . response . status ) ;
64+ console . log ( ' Response data:' , JSON . stringify ( error . response . data , null , 2 ) ) ;
65+ }
66+ }
67+
68+ // Test 3: Try to delete the trigger (to clean up if it exists)
69+ console . log ( '\n🗑️ Test 3: Delete trigger (cleanup test)' ) ;
70+ try {
71+ const deleteResult = await client . deleteTrigger ( {
72+ id : deploymentId ,
73+ externalUserId : userId ,
74+ } ) ;
75+ console . log ( '✅ Delete successful:' , JSON . stringify ( deleteResult , null , 2 ) ) ;
76+ } catch ( error ) {
77+ console . log ( '❌ Error deleting trigger:' , error . message ) ;
78+ if ( error . response ) {
79+ console . log ( ' Response status:' , error . response . status ) ;
80+ console . log ( ' Response data:' , JSON . stringify ( error . response . data , null , 2 ) ) ;
81+ }
82+ }
83+
84+ // Test 4: List all triggers for user (different approach)
85+ console . log ( '\n📋 Test 4: List all triggers for user' ) ;
86+ try {
87+ const triggersResult = await client . getTriggers ( {
88+ externalUserId : userId ,
89+ limit : 50 ,
90+ } ) ;
91+ console . log ( '✅ Triggers list:' , JSON . stringify ( triggersResult , null , 2 ) ) ;
92+ } catch ( error ) {
93+ console . log ( '❌ Error listing triggers:' , error . message ) ;
94+ if ( error . response ) {
95+ console . log ( ' Response status:' , error . response . status ) ;
96+ console . log ( ' Response data:' , JSON . stringify ( error . response . data , null , 2 ) ) ;
97+ }
98+ }
99+ }
100+
101+ // Run the test
102+ if ( require . main === module ) {
103+ testSpecificTrigger ( ) . catch ( console . error ) ;
104+ }
105+
106+ module . exports = { testSpecificTrigger } ;
0 commit comments