Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ sequenceDiagram
participant Aquila as Aquila (Server)
participant Stream as Stream (gRPC)

Hercules->>Aquila: Register datatypes<br>because maybe they are needed in the config definitions
Aquila-->>Hercules: Validation result


Hercules->>Stream: Open bi-directional stream
Hercules->>Stream: ActionLogon request

Hercules->>Aquila: Register datatypes
Aquila-->>Hercules: Validation result


Hercules->>Aquila: Register function definitions
Aquila-->>Hercules: Validation result

Expand Down Expand Up @@ -59,4 +61,4 @@ To use a simple test server use the following command:
```bash
./bin/test_server.rb
```
This will start a test server on `localhost:50051` that you can connect to with the action sdk.
This will start a test server on `localhost:50051` that you can connect to with the action sdk.
5 changes: 3 additions & 2 deletions bin/Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# frozen_string_literal: true

source 'https://rubygems.org'

ruby '3.4.7'


gem 'tucana', '0.0.56'
gem 'grpc', '~> 1.67'
gem 'tucana', '0.0.57'
4 changes: 2 additions & 2 deletions bin/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ GEM
google-protobuf (>= 3.25, < 5.0)
googleapis-common-protos-types (~> 1.0)
rake (13.3.1)
tucana (0.0.56)
tucana (0.0.57)
grpc (~> 1.64)

PLATFORMS
Expand All @@ -26,7 +26,7 @@ PLATFORMS

DEPENDENCIES
grpc (~> 1.67)
tucana (= 0.0.56)
tucana (= 0.0.57)

RUBY VERSION
ruby 3.4.7p58
Expand Down
6 changes: 4 additions & 2 deletions bin/test_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ def construct_parameters(func)
end

def transfer(requests, call)
puts "Got Auth token: #{call.metadata['authorization']}"
token = call.metadata['authorization']
puts "Got Auth token: #{token}"
Enumerator.new do |yielder|
Thread.new do
loop do
Expand Down Expand Up @@ -133,6 +134,7 @@ def transfer(requests, call)
yielder << Tucana::Aquila::TransferResponse.new(
{
execution: Tucana::Aquila::ExecutionRequest.new(
project_id: Random.rand(1..1000),
execution_identifier: exec_identifier,
function_identifier: func.runtime_name,
parameters: construct_parameters(func)
Expand All @@ -156,12 +158,12 @@ def transfer(requests, call)
puts "Project id: #{req.event.project_id}"
next
end

next if req.logon.nil?

logon = req.logon

@state.add_action_config_definition({
auth_token: token,
action_identifier: logon.action_identifier,
version: logon.version,
config_definitions: logon.action_configurations,
Expand Down
4 changes: 2 additions & 2 deletions ts/bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

92 changes: 25 additions & 67 deletions ts/examples/simple_example.ts
Original file line number Diff line number Diff line change
@@ -1,101 +1,59 @@
import { createSdk } from "../src/action_sdk.js";
import { Struct, Value } from "@code0-tech/tucana/pb/shared.struct_pb.js";
import { constructValue } from "@code0-tech/tucana/helpers/shared.struct_helper.js";
import { ActionProjectConfiguration } from "@code0-tech/tucana/pb/shared.action_configuration_pb.js";
import {createSdk} from "../src/action_sdk.js";
import {constructValue} from "@code0-tech/tucana/helpers/shared.struct_helper.js";
import {ActionProjectConfiguration} from "@code0-tech/tucana/pb/shared.action_configuration_pb.js";
import {HerculesFunctionContext} from "../src/types.js";

const sdk = createSdk({
token: "your_token_here",
actionUrl: "127.0.0.1:50051",
authToken: "someToken",
aquilaUrl: "127.0.0.1:50051",
actionId: "action_123",
version: "0.0.0",
})

sdk.registerConfigDefinitions({
type: {
signature: "string",
identifier: "STRING",
version: "0.0.0",
rules: [],
name: [],
genericKeys: [],
alias: [],
displayMessage: [],
linkedDataTypeIdentifiers: [],
definitionSource: ""
},
name: [],
description: [],
identifier: "config_discord_bot_token",
})
}, [
{
type: "LIST<STRING>",
linkedDataTypeIdentifiers: ["STRING", "LIST"],
identifier: "config_discord_bot_token",
}
])

sdk.registerDataType({
identifier: "SOME_DATATYPE",
signature: "any",
name: [],
alias: [],
rules: [],
genericKeys: [],
displayMessage: [],
definitionSource: "",
linkedDataTypeIdentifiers: [],
version: "0.0.0",
type: "any",
})

sdk.registerFunctionDefinition(
{
signature: "(n: NUMBER) => NUMBER",
definitionSource: "",
linkedDataTypeIdentifiers: ["NUMBER"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should also be renamed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly?

runtimeParameterDefinitions: [
parameters: [
{
runtimeName: "n",
description: [],
name: [],
documentation: [],
defaultValue: constructValue(20),
defaultValue: 20,
}
],
alias: [],
deprecationMessage: [],
description: [],
displayIcon: "",
displayMessage: [],
documentation: [],
name: [],
throwsError: false,
version: "0.0.0",
runtimeName: "fib",
},
async (params: Struct): Promise<Value> => {
console.log("Received parameters:", params);
let n = params.fields["n"];
// This param is optional and can be omitted
(n: number, context: HerculesFunctionContext): number => {
console.log(context)
console.log("Project id:", context.projectId);
console.log("Execution id:", context.executionId);
console.log("Matched configs:", context.matchedConfigs); // matched configs for the current execution

function fibonacci(num: number): number {
if (num <= 1) return num;
return fibonacci(num - 1) + fibonacci(num - 2);
}

if (n && n.kind.oneofKind === "numberValue") {
return constructValue(fibonacci(n.kind.numberValue));
}

return constructValue(fibonacci(1));
return fibonacci(n)
}
)

sdk.registerFlowType(
{
documentation: [],
description: [],
displayIcon: "",
displayMessage: [],
editable: false,
inputTypeIdentifier: "STRING",
name: [],
alias: [],
inputType: "STRING",
identifier: "test_flow",
settings: [],
version: "0.0.0",
}
)

Expand All @@ -119,4 +77,4 @@ function connectToSdk() {
connectToSdk();
}, 5000)
})
}
}
8 changes: 4 additions & 4 deletions ts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"license": "ISC",
"type": "module",
"dependencies": {
"@code0-tech/tucana": "^0.0.56",
"@code0-tech/tucana": "^0.0.58",
"@grpc/grpc-js": "^1.14.3",
"@protobuf-ts/grpc-transport": "^2.11.1",
"@protobuf-ts/runtime": "^2.11.1",
Expand Down
Loading