You have been redirected from an outdated version of the article.
Below is the content available on this topic. To view the old article click here.
Call
The Call element allows a flow to be called from a flow. It is a flow based alternative to calling the scripting function flow().
Name |
Description |
Prev |
Accepts another element’s Next socket |
Next |
Connects to another element’s Prev socket |
Parameters |
Accepts multiple ParameterInput element connections |
DataTarget |
Connects to another element’s DataSource |
Flow |
Allows the selection of a Flow to call with this element |
Search results for "Call"
call()
Calls the SchemaMethod
with the given name and returns the result. This method is used to execute global schema methods (methods that are not associated with a type).
call(name [, key1, value1 [, ... ]] )
$.call(name [, map])
call_privileged()
Calls the SchemaMethod
with the given name and returns the result. This method is used to execute global schema methods (methods that are not associated with a type).
call_privileged(name [, key1, value1 [, ... ]] )
$.call_privileged(name [, map])
Relationship Details Dialog
The Cascading Delete
settings allow configuration of what happens when either end of the relationship is deleted. The possible values are explained in-depth in the help popup in the dialog.
Automatic Creation of Related Nodes
configures if it is allowed to include nested nodes in a REST POST request for this relationship. A node with the given property set is automatically created and linked to the node. If the nested node contains an id
attribute (or another property marked as unique) a node is searched for that property and linked if found.
Permission Resolution
allows configuration of rights propagation in the graph. If NONE
is selected, no rights propagation is applied for this relationship. If SOURCE_TO_TARGET
is selected the rights are propagated along the relationship direction to the next node. For TARGET_TO_SOURCE
the rights propagation is works against the relationship direction. For ALWAYS
the direction of the relationship does not matter and rights propagation is always applied.
Specific rights (Read
, Write
, Delete
, AccessControl
) can be added, kept or removed according to the propagation configuration. If a user has read rights to the previous node and Read
is configured to Keep
, the user also has read rights for the next node. (Specific User/Group rights are applied before using permission propagation - i.e. if a user has specific rights configured for a node, permission resolution is not evaluated as user rights are more specific).
Along the way of permission propagation, properties can be hidden in order to hide sensitive information from users who get rights from permission propagation. The property names can be separated by comma ,
or space
character.
There are 3 tabs where the functionality of the type can be configured:
Local Attributes
A Custom Type can be extended with dynamic properties to provide the data model for the intended use-case. This list contains all local properties (meaning they are defined on this type directly).
Views
The properties of a type can be combined into named Views, which are accessible under an individual REST URL. Access to these URLs can be configured independently for each HTTP method using Resource Access Grants, which makes them an ideal tool to create specialised endpoints for different client applications (e.g. mobile clients etc.).
Methods
There are different kinds of methods - callback methods and entity methods. Callback methods are automatically executed by the framework upon certain lifecycle events and have a strict naming convention. Entity methods are called by the user/programmer.
Entity methods are not automatically run by the framework and must be called manually. This either means making a POST request to /structr/rest/(Type)/(<a data-id="7c9c8218bced42bab66868373e64d885" class="mention">UUID</a>)/(methodName)
or in serverside JavaScript as node.methodName();
Type Details Dialog
There are 5 tabs where the functionality of the type can be configured:
-
Local Attributes
A Custom Type can be extended with dynamic properties to provide the data model for the intended use-case. This list contains all local properties (meaning they are defined on this type directly).
-
Views
The properties of a type can be combined into named Views, which are accessible under an individual REST URL. Access to these URLs can be configured independently for each HTTP method using Resource Access Grants, which makes them an ideal tool to create specialised endpoints for different client applications (e.g. mobile clients etc.).
-
Methods
There are different kinds of methods - callback methods and entity methods. Callback methods are automatically executed by the framework upon certain lifecycle events and have a strict naming convention. Entity methods are called by the user/programmer.
Entity methods are not automatically run by the framework and must be called manually. This either means making a POST request to /structr/rest/<Type>/<UUID>/<methodName>
or in serverside JavaScript as <node>.<methodName>();
-
Remote Attributes
Custom types can be linked to other types, including base types. Structr will automatically create Remote Attributes on either side of the link, which can then be used to create, update or remove the relationships between instances of the two types. In this tab the configuration of the remote attributes can be viewed and edited. The names configured here are used throughout the application to refer to the other side of the relationship(s).
-
Inherited Attributes
The content of this tab is of informative character. All inherited attributes are shown with an information from where it was inherited.
Business Logic
The third option to implement logic is to use a global schema method, especially when the logic is not bound to a specific type. Global schema methods can be called via REST using a special maintenance endpoint, scheduled for execution with a cron-like syntax or called from any scripting envrionment using the call() or call_privileged() functions.
User Configuration
There are three main properties you can change to control the two factor authentication behaviour for a specific user node.
User.twoFactorConfirmed | This is automatically set to true after a user authenticates via two-factor authentication. If this is set to false the user will always be shown the QR code for him to scan. |
User.isTwoFactorUser | Controls if the user wants to authenticate via two factor authentication. This only works if the setting TwoFactor.level is set to 1. If the setting is set to 2, the flag will automatically be set to true after a user logs in. |
User.twoFactorSecret | This is the secret which is used to generate tokens. It is automatically generated for every user. |
onAcmeChallenge
This method is called when an ACME challenge of type dns
is triggered, typically by using the maintenance method letsencrypt
like this:
$.maintenance('letsencrypt', { server: 'production', challenge: 'dns', wait: '60', reload: true });
The primary use case of this method is creating a DNS TXT record via an external API call to a DNS provider.
The following parameters are passed to this method and can be retrieved with $.retrieve(key)
:
Parameter name | Description | Examples |
type | The type of the ACME authorisation challenge | dns |
domain | The domain the ACME challenge is created for | subdomain.example.com |
record | The name of the DNS record including prefix _acme-challenge. and suffix . | _acme-challenge.subdomain.example.com. |
digest | The token string that is probed by the ACME server to validate the challenge | X6Rea0DdZ-5XGotp1geAxfsdDR0x1T9d_kAseA4YMCA |
Calling Flows within Flows
Besides calling flows from a scripting context, it’s also possible to reuse flows from within flows by using the FlowCall element. This allows the user to select a flow from all existing flows and optionally supply parameters to the call as well. In the following example a very basic use is illustrated.
Call
The Call element allows a flow to be called from a flow. It is a flow based alternative to calling the scripting function flow().
JavaScript
JavaScript scripting contexts are explicitely defined by enclosing dollar sign and double curly brackets (${{}}
) or single curly brackets ({}
) within auto-scripting contexts. In an R context, access to Structr’s built-in functionality is provided via the Structr
keyword or dollar sign $
as a global variable.
The JavaScript engine provides special bindings allowing built-in functions to be called directly on the binding object. Built-in functions can be called using Structr.call([Function Name], [Parameters])
and Structr constants can be retrieved using Structr.get('[Constant Name]')
.
This allows expressions like:
Methods
To implement the business logic of an application or to provide reusable blocks of functionality, you can add named methods to any type. Structr distinguishes between methods that are automatically executed at certain events (so-called lifecycle methods) and instance methods that can be called from a scripting context or via a URL.
afterCreate
- Is called after an object has been created (onCreate has already been executed), all checks have passed successfully and the transaction has been committed
- Multiple afterCreate methods can exist per type - every method prefixed with afterCreate is called after an object has been created successfully (e.g.
afterCreate01
, afterCreate02
)
- can not roll back the transaction
- is useful for actions that should only happen if the node is sure to have been created. For example sending a mail: Calling
send_html_mail()
in onCreate would send the email even if the transaction would be rolled back due to an error.
- All regular keywords can be used - no special keywords are introduced for this method
Example:
Edit File
The other two parameters, Replace <a data-id="c535223d2c1e409ebdcbbfcf1479c15f" class="mention">template</a> expressions
and Show preview
, are used to configure so-called dynamic files. Additionally to storing static content, as in the case of the text file above, Structr also allows you to open a scripting context within a file and thus inject dynamically generated content. Such files, containing dynamically generated content, are referred to as dynamic files.
Proxy
application.proxy.http.url | Specifies the proxy url for built-in HTTP function calls. |
application.proxy.http.username | Specifies the proxy username for built-in HTTP function calls. |
application.proxy.http.password | Specifies the proxy password for built-in HTTP function calls. |
Triggering the Authentication
Key | Description |
oauth.auth0.client_id | ClientId at provider. |
oauth.auth0.client_secret | Client Secret at provider. |
oauth.auth0.authorization_location | Redirect URI for the authentication process. |
oauth.auth0.token_location | Token URI of provider, called by Structr to optain access_token. |
oauth.auth0.redirect_uri | Called by provider on Structr application after successfull authentication. Triggers Structr to load userdata. |
oauth.auth0.user_details_resource_uri | URI of Oauth provider for user details e.g. username, eMail etc. |
oauth.auth0.error_uri | Error URI within Structr app. |
oauth.auth0.return_uri | Success URI called after successfull login. The resource of this URI usally is a landing page within your Structr application. |
jsonrestservlet.user.autocreate | Has to be set to enabled, so Structr can create usernode if they doesn’t exist yet. |
MessageSubscriber
MessageSubscriber is a generic abstraction of a subscriber included in the Messaging-Engine Module module.
It can attach to any kind of MessageClient and will subscribe on that client with the specified topic.
If the client receives a message on given topic, a callback will be made to the subscriber and the message will be evaluated in a scripting context that is specified in the subscribers callback
attribute.
The following properties can be configured for the subscriber:
Name | Type | Description |
clients | Array of MessageClient | A list of all related clients that will be subscribed on. |
topic | String | The topic that will be subscribed |
callback | String | Specifies a script that is evaluated upon the reception of a relevant message. |
Note: Instead of using a specific topic, it is also possible to use *
as a wildcard subscription.
The default scripting context is StructrScript and the message’s content is injected as well and available via retrieve() under the following attributes.
Key | Description |
topic | The topic the message was sent in. |
message | The message’s content. |
onOAuthLogin
Available in structr v4.2+
- Is called after a user successfully logs into the system via a configured OAuth provider
- can not prevent the login of a user
- Is called with the two parameters
provider
containing the OAuth provider name that was used for login and userinfo
containing the information pulled from the userinfo endpoint of the OAuth provider.
Create and use Let's Encrypt certificates
If the type is set to dns
, Structr will automatically trigger the onAcmeChallenge
method with the parameters type
, domain
and digest
. This can be used to create a DNS TXT record via an external API call to the domain’s DNS provider.
Rendering Engine
The HTML5 standard defines different types of elements: the so-called “block elements”, e.g. <div>
, <p>
or <table>
that form the structure of a document, and “inline” elements like <a>
and <span>
, etc. The content of an element can be other elements, or so-called #text
nodes as defined in the DOM specification.