Skip to content

Commit 2794c36

Browse files
committed
Make 0.0.66 work
1 parent b2a8bd7 commit 2794c36

6 files changed

Lines changed: 49 additions & 56 deletions

File tree

ts/examples/simple-example-ts/index.ts

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ import {
77

88
const 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

2625
sdk.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
},
3836
//This param is optional and can be omitted
39-
handler: (context: HerculesFunctionContext, n: number): number => {
37+
handler: (context: HerculesFunctionContext, number: bigint): bigint => {
4038
console.log(context)
4139
console.log("Project id:", context.projectId);
4240
console.log("Execution id:", context.executionId);
4341
console.log("Matched configs:", context.matchedConfig); // matched configs for the current execution
4442

45-
function fibonacci(num: number): number {
43+
function fibonacci(num: bigint): bigint {
4644
if (num <= 1) return num;
47-
return fibonacci(num - 1) + fibonacci(num - 2);
45+
return fibonacci(num - 1n) + fibonacci(num - 2n);
4846
}
4947

50-
throw new RuntimeErrorException("ERROR_CALCULATING_FIB", "An error occurred while calculating the Fibonacci number.");
51-
48+
return fibonacci(number)
5249
}
5350
}
5451
)
5552

5653
sdk.registerFlowTypes(
5754
{
58-
signature: "(): TEXT",
59-
linkedDataTypes: ["TEXT"],
55+
signature: "(): string",
6056
editable: false,
6157
identifier: "test_flow",
6258
}
@@ -71,8 +67,8 @@ function connectToSdk() {
7167
sdk.dispatchEvent("test_flow", configs[0].projectId, "Hello, World! Configs loaded: " + configs.length).then(() => {
7268
console.log("Event dispatched successfully");
7369
})
74-
}).catch((_error) => {
75-
console.error("Error connecting SDK:");
70+
}).catch((error) => {
71+
console.error("Error connecting SDK:", error);
7672
})
7773

7874
sdk.onError((error) => {

ts/examples/simple-example-ts/package-lock.json

Lines changed: 6 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ts/examples/simple-example-ts/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"dev": "cd ../.. && npm install && npm run build && npm pack && cd examples/simple-example-ts && npm install ../../code0-tech-hercules-0.0.0.tgz && npx tsx index.ts"
1212
},
1313
"dependencies": {
14-
"@code0-tech/hercules": "file:../../code0-tech-hercules-0.0.0.tgz",
15-
"@code0-tech/tucana": "^0.0.62"
14+
"@code0-tech/hercules": "file:../../code0-tech-hercules-0.0.0.tgz"
1615
}
1716
}

ts/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"license": "ISC",
3131
"type": "module",
3232
"dependencies": {
33-
"@code0-tech/tucana": "^0.0.67",
33+
"@code0-tech/tucana": "0.0.66",
3434
"@grpc/grpc-js": "^1.14.3",
3535
"@protobuf-ts/grpc-backend": "^2.11.1",
3636
"@protobuf-ts/grpc-transport": "^2.11.1",

ts/src/action_sdk.ts

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ const createSdk = (config: ActionSdk["config"], configDefinitions?: HerculesActi
7777
defaultValue: constructValue(param.defaultValue || null),
7878
hidden: param.hidden || false,
7979
optional: param.hidden || false,
80-
runtimeDefinitionName: param.runtimeDefinitionName || param.runtimeName
80+
// runtimeDefinitionName: param.runtimeDefinitionName || param.runtimeName
8181
})),
8282
signature: functionDefinition.signature,
8383
throwsError: functionDefinition.throwsError || false,
84-
runtimeDefinitionName: functionDefinition.runtimeDefinitionName
84+
// runtimeDefinitionName: functionDefinition.runtimeDefinitionName
8585
}
8686
});
8787
}
@@ -315,22 +315,22 @@ async function connect(state: SdkState, config: ActionSdk["config"], options?: R
315315
}
316316
})
317317

318-
const FunctionDefinitionClient = new FunctionDefinitionServiceClient(state.transport)
319-
await FunctionDefinitionClient.update(
320-
FunctionDefinitionUpdateRequest.create(
321-
{
322-
functions: [
323-
...state.functions.map(func => ({
324-
...func.definition,
325-
}))
326-
]
327-
}
328-
), builtOptions
329-
).then(value => {
330-
if (!value.response.success) {
331-
return Promise.reject(value.response);
332-
}
333-
})
318+
// const FunctionDefinitionClient = new FunctionDefinitionServiceClient(state.transport)
319+
// await FunctionDefinitionClient.update(
320+
// FunctionDefinitionUpdateRequest.create(
321+
// {
322+
// functions: [
323+
// ...state.functions.map(func => ({
324+
// ...func.definition,
325+
// }))
326+
// ]
327+
// }
328+
// ), builtOptions
329+
// ).then(value => {
330+
// if (!value.response.success) {
331+
// return Promise.reject(value.response);
332+
// }
333+
// })
334334

335335
const flowTypeClient = new FlowTypeServiceClient(state.transport)
336336
await flowTypeClient.update(FlowTypeUpdateRequest.create({
@@ -388,19 +388,23 @@ function handleExecutionRequest(state: SdkState, message: TransferResponse) {
388388
}
389389
const execution = message.data.execution as ExecutionRequest;
390390
const func = state.runtimeFunctions.find(value => value.identifier == execution.functionIdentifier);
391+
391392
if (func) {
392393
const params = Object.entries(execution.parameters!.fields!).map(([key, value]) => {
393394
const param = func.definition.runtimeParameterDefinitions
394395
.find(p => p.runtimeName === key);
395396

396397
return param ? toAllowedValue(value) : undefined;
397398
});
398-
const conf = state.projectConfigurations.find(config => {
399+
let conf = state.projectConfigurations.find(config => {
399400
return true
400401
})
401402
if (!conf) {
402403
console.error(`No configuration found for project ${execution.projectId}`)
403-
return;
404+
conf = {
405+
projectId: 0n,
406+
actionConfigurations: []
407+
}
404408
}
405409

406410
const context: HerculesFunctionContext = {
@@ -437,6 +441,7 @@ function handleExecutionRequest(state: SdkState, message: TransferResponse) {
437441
}
438442
})
439443
result.then((value: any) => {
444+
console.log(constructValue(value))
440445
state.stream!.requests.send(
441446
TransferRequest.create({
442447
data: {

0 commit comments

Comments
 (0)