Skip to content
This repository was archived by the owner on Jan 19, 2026. It is now read-only.
Closed
Changes from 1 commit
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
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,30 @@ Example:
}
```

### Special GDD Type: "Invoke Action"

Some templates support invoking custom functions during their life-time.
This GDD Type should be rendered as a Button in the GUI so that the user can click it to invoke the action.


Example:
```typescript
{
"title": string, // [Mandatory] A short title / label of the action
"description": "", // [Optional] A longer description of the action
"type": "null",
"gddType": "invoke-action",
"gddOptions": {
// [mandatory] The function to invoke in the template

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The description of the "invoke" field should clarify if this is "the name of the function to invoke" or "an invocation of the function", i.e. - for a function called myCustomHello should this be myCustomHello or myCustomHello("someArg0")? I was confused by what this is.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good point!
I've improved the description a tad now.
The invoke property is supposed to contain the script being executed in the target template, myCustomHello("someArg0")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The way the AMCP command CG INVOKE is documented, it does not allow to have arguments. Will that be changed?

@ianshade ianshade Sep 4, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, the AMCP documentation definitely needs updating because AFAIK it this been supported for years. It's essentially executing any JS that it gets, not necessarily just invoking a function. You can do CG 1-1 INVOKE 1 "var a = 1;a++;console.log(a)" and it'll work too, which might be a good or a bad thing, depending on where the invoked script comes from

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hmmm, but what you explain is just kind of an inline function, that sits in place of the function name, like CG 1-1 INVOKE 1 "function_name". That is no contradiction to the documentation. What @nytamin and @jstarpl are talking about is having a function name and an argument, like we have for the CG UPDATE command. And that is undocumented and should, in my opinion be avoided.

// Example: myCustomHello("world", $path)
"invoke": string
}
}
```

Note: `$path` is a special token which will be substituted at runtime with the path of the action. This is useful when having an action inside an array, since this would cause multiple actions to render (one per row in the data). An example of a path would be `people.2` for the action in the 3rd row of an array called `people`.
Comment thread
nytamin marked this conversation as resolved.
Outdated


## For GUI Developers

When implementing a GUI to support the GDD definitions, you don't have to implement support for all GDD Types - since the GDD Types are designed to degrade gracefully. The only types that are mandatory to implement are the basic types `"boolean"`, `"string"`, `"number"`, `"integer"`, `"array"`and `"object"`.
Expand All @@ -392,6 +416,7 @@ function determineComponent(prop) {
if (basicType === "integer") return componentInteger(prop);
if (basicType === "array") return componentArray(prop);
if (basicType === "object") return componentObject(prop);
if (basicType === "null") return null

return null;
}
Expand Down