@@ -7,13 +7,12 @@ import {
77
88const sdk = createSdk ( {
99 authToken : "token" ,
10- aquilaUrl : "127.0.0.1:50051 " ,
11- actionId : "service " ,
10+ aquilaUrl : "127.0.0.1:8081 " ,
11+ actionId : "example " ,
1212 version : "0.0.0" ,
1313} , [
1414 {
15- type : "LIST<STRING>" ,
16- linkedDataTypes : [ "STRING" , "LIST" ] ,
15+ type : "string[]" ,
1716 identifier : "config_discord_bot_token" ,
1817 }
1918] )
@@ -25,38 +24,35 @@ sdk.registerDataTypes({
2524
2625sdk . registerRuntimeFunctionDefinitionsAndFunctionDefinitions ( {
2726 definition : {
28- signature : "(n: NUMBER) => NUMBER" ,
29- linkedDataTypes : [ "NUMBER" ] ,
27+ signature : "(number: number) => number" ,
3028 parameters : [
3129 {
32- runtimeName : "n " ,
30+ runtimeName : "number " ,
3331 defaultValue : 20 ,
3432 }
3533 ] ,
3634 runtimeName : "fib" ,
3735 } ,
38- //This param is optional and can be omitted
39- handler : ( context : HerculesFunctionContext , n : number ) : number => {
40- console . log ( context )
41- console . log ( "Project id:" , context . projectId ) ;
42- console . log ( "Execution id:" , context . executionId ) ;
43- console . log ( "Matched configs:" , context . matchedConfig ) ; // matched configs for the current execution
44-
45- function fibonacci ( num : number ) : number {
46- if ( num <= 1 ) return num ;
47- return fibonacci ( num - 1 ) + fibonacci ( num - 2 ) ;
48- }
49-
50- throw new RuntimeErrorException ( "ERROR_CALCULATING_FIB" , "An error occurred while calculating the Fibonacci number." ) ;
36+ //This param is optional and can be omitted
37+ handler : ( context : HerculesFunctionContext , number : bigint ) : bigint => {
38+ console . log ( context )
39+ console . log ( "Project id:" , context . projectId ) ;
40+ console . log ( "Execution id:" , context . executionId ) ;
41+ console . log ( "Matched configs:" , context . matchedConfig ) ; // matched configs for the current execution
5142
43+ function fibonacci ( num : bigint ) : bigint {
44+ if ( num <= 1 ) return num ;
45+ return fibonacci ( num - 1n ) + fibonacci ( num - 2n ) ;
5246 }
47+
48+ return fibonacci ( number )
49+ }
5350 }
5451)
5552
5653sdk . registerFlowTypes (
5754 {
58- signature : "(): TEXT" ,
59- linkedDataTypes : [ "TEXT" ] ,
55+ signature : "(): string" ,
6056 editable : false ,
6157 identifier : "test_flow" ,
6258 }
@@ -68,11 +64,13 @@ connectToSdk();
6864function connectToSdk ( ) {
6965 sdk . connect ( ) . then ( ( configs : HerculesActionProjectConfiguration [ ] ) => {
7066 console . log ( "SDK connected successfully" ) ;
67+
7168 sdk . dispatchEvent ( "test_flow" , configs [ 0 ] . projectId , "Hello, World! Configs loaded: " + configs . length ) . then ( ( ) => {
7269 console . log ( "Event dispatched successfully" ) ;
7370 } )
74- } ) . catch ( ( _error ) => {
75- console . error ( "Error connecting SDK:" ) ;
71+ } ) . catch ( ( ) => {
72+ // will be handled by logger internally
73+ process . exit ( 1 )
7674 } )
7775
7876 sdk . onError ( ( error ) => {
0 commit comments