Script Context Members
Kubling injects bound objects into a script according to the contract of that script type. They provide controlled access to input values, result builders, logging, HTTP calls or Engine operations without exposing unrestricted host access.
This reference covers Script Data Sources, functions, authentication delegates, Endpoint Scripts, scheduled scripts and JavaScript routing resolvers. A script receives only the members listed for its execution context.
Script Data Source
For more information see here.
Common to all script types
contextVars
An object whose properties combine environment variables and application
properties.
In JavaScript, properties can be accessed with dot notation or computed property names. See Application variables for configuration and precedence.
global
A common, shared, thread-safe key-value store. The difference between this and contextVars is the scope: global has only one instance per Engine instance,
so it is Engine-scoped, whereas contextVars is Script-scoped, making global suitable for sharing information between script contexts.
| Function | Description |
|---|---|
put(key : string, value : object) | Associates the specified value object with the specified key. If the store previously contained a mapping for the key, the old value is replaced by the specified value. |
remove(key : string) | Removes the mapping for a key from the store if it is present. |
get(key : string) | Returns the value to which the specified key is mapped, or null if the store does not contain mapping for the key. |
containsKey(key : string) : boolean | Returns true if the store does not contain a mapping for the specified key. |
isEmpty() : boolean | Returns true if the store does not contain key-value mappings. |
keys() : <string> | Returns an iterable wrapper, containing the list of keys, that is resolved by the script context as a native feature. For example, in JavaScript it will allow you to use a for (variable of iterable) loop. |
values() : <object> | Returns an iterable wrapper, containing the list of values, that is resolved by the script context as a native feature. |
forEach(action) | Direct support for the standard forEach form when the particular script context or the language does not support it. For example, in JavaScript it is recommended the usage of forEach(callbackFn) instead. |
size() : integer | Returns the number of elements in the store. |
helper
Convenience class with some functionality not always included in a scripting language spec, like the ECMAScript.
| Function | Description |
|---|---|
toLong(object) : long | Transforms an object to its long representation. |
toInt(object) : integer | Transforms an object to its integer representation. |
base62(string) : string | Encodes a string to base62. |
base62Decode(string) : string | Decodes a string from base62. |
base64(string) : string | Encodes a string from base64. |
base64Decode(string) : string | Decodes a string from base64. |
compressString(string) : string | Compresses a string using the basic gzip deflater. |
decompressString(string) : string | Decompresses a string using the basic gzip inflater. |
encryptString(string) : string | Encrypts a string using a random key, which is created when the engine starts, and AES/CBC/PKCS5Padding cipher. |
decryptString(string) : string | Decrypts a string encrypted via encryptString. |
asJson(object) : string | Transforms an object to its json representation. |
asJsonPretty(object) : string | Transforms an object to its prettified json representation. |
unescapeJson(string) : string | Unescape a json document, which removed escape chars. |
isValidJson(string) : boolean | Returns whether an arbitrary text is a valid json document. |
asYaml(object) : string | Transforms an object to its yaml representation. |
dt() : DateTimeHelper | Returns a DateTimeHelper object. |
jsonPath() : JSONPath | Returns a JSONPath object. |
The helper functions list will grow in future versions as we identify more requirements/uses cases reported by users.
helper.DateTimeHelper
All values are expressed in EPOCH/Unix time .
| Function | Description |
|---|---|
nowMillis() : long | Returns the current time in milliseconds. |
nowSeconds() : long | Returns the current time in seconds. |
nowPlusSeconds(seconds : long) : long | Returns the current time in milliseconds after adding the specified amount of seconds. |
nowPlusMillis(millis : long) : long | Returns the current time in milliseconds after adding the specified amount of milliseconds. |
nowPlusMinutes(minutes : long) : long | Returns the current time in milliseconds after adding the specified amount of minutes. |
nowPlusHours(hours : long) : long | Returns the current time in milliseconds after adding the specified amount of hours. |
nowPlusDays(days : long) : long | Returns the current time in milliseconds after adding the specified amount of days. |
nowPlusMonths(months : long) : long | Returns the current time in milliseconds after adding the specified amount of months. |
nowPlusYears(years : long) : long | Returns the current time in milliseconds after adding the specified amount of years. |
fromMillisToSeconds(millis : long) : long | Transforms milliseconds to number of seconds. |
fromSecondsToMillis(seconds : long) : long | Transforms seconds to number of milliseconds. |
helper.JSONPath
Allows to perform basic operations using JSON Path .
| Function | Description |
|---|---|
read(document : string, path : string) : ListProxyObject<string> | Parses a JSON document and read the specified path. The result is a list of matches. |
excludeListedFields(document : object, fields : string[]) : string | Generates a new JSON document, based on the original, with the specified fields excluded. |
excludeNonListedFields(document : object, fields : string[]) : string | Generates a new JSON document, based on the original, keeping only the specified fields and excluding the rest. |
httpCli
httpCli executes HTTP and HTTPS requests from Script Data Sources, functions,
endpoints, authentication delegates and scheduled scripts. Requests reuse
process-owned outbound transports and release their responses after the body is
materialized.
const request = httpCli.request()
.url("https://inventory.example.com/v1/devices")
.method("POST")
.header("X-Tenant", contextVars.TENANT_ID)
.basicAuth(contextVars.API_USER, contextVars.API_PASSWORD)
.contentType("application/json")
.contentCharset("utf-8")
.body({ status: "active" })
.timeout(15000);
const response = httpCli.execRequest(request);
if (response.statusCode < 200 || response.statusCode >= 300) {
throw new Error(`Inventory request failed: ${response.statusCode}`);
}
return response.content;Non-success HTTP responses are returned as HTTPResponse objects; they do not
raise an exception solely because of their status code.
| Function | Description |
|---|---|
request() : HTTPRequest | Creates a fluent request object. |
execRequest(request : HTTPRequest) : HTTPResponse | Executes the request and returns its response. |
newFileWrapper(name : string) : FileWrapper | Creates a file part for a multipart form. |
exec(request : object) : HTTPResponse | Compatibility API based on a plain object. Deprecated since 26.2; use request() and execRequest(). |
HTTPRequest
Request methods return the same object, so they can be chained:
| Method | Default | Purpose |
|---|---|---|
url(value) | required | Sets the target URL. |
method(value) | GET | Sets the HTTP method. A GET request cannot contain a body. |
timeout(milliseconds) | 30000 | Sets the response read timeout. 0 means no timeout. |
followRedirects(enabled) | false | Controls automatic redirects. |
param(name, value) | — | Adds a query parameter. |
header(name, value) | — | Adds a request header. |
body(value) | — | Sets a raw string or serializable request body. |
form(name, value) | — | Adds a multipart or URL-encoded form field. |
formUrlEncoded(enabled) | false | Uses application/x-www-form-urlencoded instead of multipart form data. |
basicAuth(username, password) | — | Adds HTTP Basic credentials. |
contentType(value) | application/json | Sets the request body media type. |
contentCharset(value) | utf-8 | Sets the charset used to encode the request body. |
userAgent(value) | kubling | Sets the User-Agent header. |
accept(value) | — | Sets the Accept header. |
decodeUrl(enabled) | true | Controls decoding of an already encoded URL. |
doNotValidateCertificate(enabled) | false | Disables certificate and hostname validation for this request only. |
headers(), params() and form() expose their corresponding mutable maps
when a script needs direct map-style access.
HTTPResponse
| Property | Meaning |
|---|---|
statusCode | Numeric HTTP status. |
statusMessage | HTTP status text. |
contentType | Response media type, including its declared charset when present. |
headers | Read-only response headers. |
content | Complete response body decoded with the declared charset, or UTF-8 when none is declared. |
TLS and response limits v26.7+
HTTPS certificate and hostname validation is enabled by default. Configure a private trust store at application level when a service uses a private certificate authority:
keytool -importcert \
-alias internal-root \
-file internal-root.pem \
-keystore private-roots.p12 \
-storetype PKCS12keytool prompts for the store password and certificate confirmation. Mount
the resulting file into Kubling, then configure the shared outbound client:
outboundHttp:
maxResponseBytes: 16777216
trustStoreType: "PKCS12"
trustStoreFilePath: "/etc/kubling/certs/private-roots.p12"
trustStorePassword: "{{ OUTBOUND_HTTP_TRUST_STORE_PASSWORD }}"The private roots are added to the platform trust roots; they do not replace
them. trustStoreType defaults to PKCS12. Mount the store read-only and
provide its password through the deployment’s secret mechanism rather than
committing it with application configuration.
maxResponseBytes defaults to 16777216 bytes (16 MiB) and must be between
1 and 2147483647. It limits the complete response body materialized by an
outbound request. Increase it only when the script genuinely needs a larger
response and the process has sufficient memory.
doNotValidateCertificate(true) disables both certificate and hostname
validation for one request and emits a warning when insecure mode is first
used. Treat it only as a temporary migration aid. A private trust store does
not fix a hostname mismatch; the certificate must also identify the URL’s
host.
Scripts that previously depended on an untrusted certificate must add its CA
to the trust store or opt into insecure mode on the individual request.
Responses larger than 16 MiB must be reduced at the remote API or allowed by a
deliberately higher maxResponseBytes value.
| Failure | Check |
|---|---|
| TLS validation fails | Verify the certificate chain, trust-store path, password, type and hostname. |
| Basic authentication is rejected | Verify the credentials and use basicAuth() instead of constructing the header manually. |
| Response exceeds the configured limit | Request a smaller representation or review outboundHttp.maxResponseBytes. |
| Text is decoded incorrectly | Confirm the response charset and the request’s contentCharset. |
The generated application fields are available under Main Application Configuration.
Legacy exec() request
Existing scripts may continue passing a plain object to exec():
const response = httpCli.exec({
url: "https://inventory.example.com/v1/devices",
method: "GET",
timeout: 15000,
followRedirects: false,
doNotValidateCertificate: false,
headers: { "X-Tenant": contextVars.TENANT_ID },
credentials: {
username: contextVars.API_USER,
password: contextVars.API_PASSWORD
}
});The object also accepts params, body, form, formUrlEncoded,
contentType, contentCharset, userAgent and accept. New scripts should
use the fluent API shown above.
FileWrapper
A FileWrapper represents one file in a multipart form:
| Function | Description |
|---|---|
setContent(content: byte[]) | Replaces the file content. |
addContent(content: byte[]) | Appends bytes to the file content. |
getContent() : byte[] | Returns the current content. |
setType(type : string) | Sets the file media type. |
logger
| Function | Description |
|---|---|
debug(message: object) | Log a message at the DEBUG level. |
debug(context : string, message: object) | Log a message at the DEBUG level, with a context you can add to recognize it. |
info(message: object) | Log a message at the INFO level. |
info(context : string, message: object) | Log a message at the INFO level, with a context you can add to recognize it. |
warn(message: object) | Log a message at the WARN level. |
warn(context : string, message: object) | Log a message at the WARN level, with a context you can add to recognize it. |
error(message: object) | Log a message at the ERROR level. |
error(context : string, message: object) | Log a message at the ERROR level, with a context you can add to recognize it. |
logger will always attempt to transform the object into a printable string representation. If that transformation is not possible, it will print [object].
The logger cannot access the script’s call trace, making it impossible to print the exact file and line number that triggered the call.
We are investigating how to improve it.
DBEngine
Allows scripts to execute queries and update operations directly against the Engine.
Operations are executed within the current authentication context unless a privileged variant is explicitly used.
| Function | Description |
|---|---|
executeQuery(vdbName : string, query : string) : QueryResultProxyObject | Executes a SELECT statement and returns a QueryResultProxyObject. |
execute(vdbName : string, query : string) : boolean | Executes arbitrary SQL and reports whether it produced a result. |
executeUpdate(vdbName : string, query : string) : integer | Executes an update statement and returns affected rows. |
executeUpdateWithParams(vdbName : string, command : SqlCommand) : integer | Executes one parameterized update and returns affected rows. |
executeTransaction(vdbName : string, commands : string[]) : integer | Executes update statements as one transaction and returns total affected rows. |
executeTransactionWithParams(vdbName : string, commands : SqlCommand[]) : integer | Executes parameterized updates as one transaction and returns total affected rows. |
explain(vdbName : string, query : string) : string | Returns the engine execution plan for a query. |
getTableNamesByTags(vdbName : string, schemaName : string, tags : string[]) : string[] | Returns tables in one schema that match every supplied tag. |
All methods above use the current authentication context and preserve its authorization result. They never elevate privileges automatically.
The following explicit variants run with Kubling’s deployment-level privileged identity:
| Function | Description |
|---|---|
executeQueryPrivileged(vdbName : string, query : string) : QueryResultProxyObject | Privileged form of executeQuery. |
executePrivileged(vdbName : string, query : string) : boolean | Privileged form of execute. |
executeUpdatePrivileged(vdbName : string, query : string) : integer | Privileged form of executeUpdate. |
executeUpdateWithParamsPrivileged(vdbName : string, command : SqlCommand) : integer | Privileged parameterized update. |
executeTransactionPrivileged(vdbName : string, commands : string[]) : integer | Privileged transaction over SQL strings. |
executeTransactionWithParamsPrivileged(vdbName : string, commands : SqlCommand[]) : integer | Privileged transaction over parameterized commands. |
explainPrivileged(vdbName : string, query : string) : string | Privileged form of explain. |
Privileged methods bypass the caller’s identity by design. Treat any bundle that invokes them as trusted executable configuration: review it, restrict who can publish it and keep its effects observable.
resultSetScript
resultSet
A proxy object that contains the rows returned by the script.
| Function | Description |
|---|---|
addRow(row: string) | Adds a JSON or YAML document to the set. |
addRow(rows: string[]) | Adds array of rows to the set. |
dataFormat(df: string) | Specified the format of the documents contained by the set. Can be either JSON or YAML. |
queryFilter
Filter information. See QueryFilterProxyObject type.
insertScript
insertOperation
An object that contains only members (not functions), which describes the insert operation.
| Member | Description |
|---|---|
table : string | TABLE name. |
fieldValues : ListProxyObject<SetOperationProxyObject> | Returns the list of fields and values of the operation. Elements of the List are of SetOperationProxyObject type. |
jsonList : ListProxyObject<string> | Returns the list of final documents to be inserted. When the original insertion occurred in a synthetic TABLE, the document received is the final one, that is, the root document with a new nested document. For more information see here. |
yamlList : ListProxyObject<string> | Same as jsonList but in YAML format. |
originalJsonList : ListProxyObject<string> | It returns the list of original documents before the insertion. It is only valid when the TABLE is synthetic, otherwise list is always empty. |
originalYamlList : ListProxyObject<string> | Same as originalJsonList but in YAML format. |
differences : ListProxyObject<JsonDifferenceResultProxyObject> | Returns the list of differences detected when compared to the original document. Position matches jsonList and originalJsonList, therefore differences[index] uses jsonList[index] and originalJsonList[index] to make the comparison.Elements of the List are of JsonDifferenceResultProxyObject type. |
affectedRows
Must specify the number of documents effectively created/inserted during the operation.
updateScript
updateOperation
An object that contains only members (not functions), which describes the update operation.
| Member | Description |
|---|---|
table : string | TABLE name. |
updates : ListProxyObject<SetOperationProxyObject[]> | Returns the list of changes in documents, each entry is a list of fields and values updated of the operation. The reason why this returns a list of documents, is because an UPDATE may affect multiple documents, depending on the search result. |
queryFilter : QueryFilterProxyObject | Returns the WHERE clause of the update operation. See QueryFilterProxyObject type. |
jsonList : ListProxyObject<string> | Returns the list of final documents, with its values updated. When the TABLE is synthetic, the document received is the final one, that is, the root document with a new nested document. For more information see here. |
yamlList : ListProxyObject<string> | Same as jsonList but in YAML format. |
originalJsonList : ListProxyObject<string> | It returns the list of original documents before the update. |
originalYamlList : ListProxyObject<string> | Same as originalJsonList but in YAML format. |
differences : ListProxyObject<JsonDifferenceResultProxyObject> | Returns the list of differences detected when compared to the original document. Position matches jsonList and originalJsonList, therefore differences[index] uses jsonList[index] and originalJsonList[index] to make the comparison.Elements of the List are of JsonDifferenceResultProxyObject type. |
partialJsonList : ListProxyObject<string> | Returns a list of documents containing only the fields that were changed. Difference between this and updates, is that this member returns a valid JSON. |
partialYamlList : ListProxyObject<string> | Same as partialJsonList but in YAML format. |
affectedRows
Must specify the number of documents effectively updated during the operation.
deleteScript
deleteOperation
An object that contains only members (not functions), which describes the delete operation.
| Member | Description |
|---|---|
table : string | TABLE name. |
queryFilter : QueryFilterProxyObject | Returns the WHERE clause of the delete operation. See QueryFilterProxyObject type. |
jsonList : ListProxyObject<string> | Returns the list of documents to be deleted. |
yamlList : ListProxyObject<string> | Same as jsonList but in YAML format. |
affectedRows
Must specify the number of documents effectively deleted during the operation.
initScript
initResult
An object that indicates to the Engine the result of the initialization.
| Function | Description |
|---|---|
initialized() | Marks the initialization process as correctly initialized. |
error() | Marks the initialization process as erroneous. |
error(message : string) | Marks the initialization process as erroneous with a custom message. |
scheduledScript v26.5+
Scheduled scripts receive the common members and DBEngine. This applies to
scripts launched from a trusted descriptor or script bundle, where no
interactive caller may be present.
Use a normal DBEngine method when the schedule has an authenticated execution
context. If that context is absent, the method fails authorization rather than
elevating itself. Use a *Privileged method only when the scheduled operation
is intentionally owned by the deployment.
A scheduled script cannot select a separate configurable service identity. Privileged calls run with Kubling’s deployment-level identity. Until a dedicated identity is available, descriptor-bundle review and deployment controls are the security boundary.
JavaScript routing resolver v26.7+
A resolver configured on a ROUTING Data Source runs in an isolated
JavaScript context. The configured function receives request as its only
argument and can use these bound objects:
| Member | Purpose |
|---|---|
contextVars | Reads application and Data Source variables. |
Routing | Creates the routing decision returned by the function. |
DBEngine | Runs bounded, read-only SQL when the decision depends on current data. |
logger | Writes debug, info or warn messages. |
request
request is read-only and describes the command currently being routed:
| Member | Content |
|---|---|
operation | SELECT, INSERT, UPSERT, UPDATE or DELETE |
vdbName, vdbVersion | Active VDB identity |
schemaName, tableName | Routed schema and canonical table name |
values | Canonical column names mapped to literal, prepared or dependent values found in the predicate |
row | Values of an INSERT or UPSERT; empty for other operations |
changes | Values assigned by an UPDATE; empty for other operations |
predicate | Structured tree representing the complete command predicate |
session | Available requestId, sessionId, userName and transactional state |
candidateRoutes | Imported Data Source names for this table, in configuration order |
For ordinary routing policies, use values, row and changes. Inspect
predicate only when the logical structure of the complete WHERE condition
affects the decision.
Advanced: complete predicate tree
predicate is a structured representation of the SQL condition, not SQL text.
For example, tenant_id = 'acme' AND active = true is represented as an and
node whose left and right members are comparison nodes.
Boolean nodes use kind: "and", kind: "or" or kind: "not". Predicate
nodes use comparison, in, isNull or like. Their expressions are column
or literal nodes containing the canonical name, type and value. A condition
that cannot be represented safely uses kind: "unsupported".
When an advanced policy depends on this tree, reject or fan out on an
unsupported node instead of inferring a route.
contextVars v26.7.1+
contextVars combines the application variable set with the properties
declared on the ROUTING Data Source. A Data Source value takes precedence
when both scopes use the same name. A static routing table can therefore be
maintained outside the descriptor script:
propertiesFilePath: "/etc/kubling/routing.properties"ROUTE_ACME=clients_eu
ROUTE_GLOBEX=clients_usThe resolver can read a value with dot notation or a computed property name,
for example contextVars.ROUTE_ACME or contextVars[variableName]. Maps and
lists are exposed as a recursive read-only snapshot for the lifetime of the
resolver. See Application variables for inline properties,
environment variables, files and precedence.
Use contextVars when the mapping changes only with deployment configuration.
It avoids a SQL query for every routing decision. Use DBEngine when the
mapping is live data that must change without reconfiguring the application.
Routing
| Function | Decision |
|---|---|
routes(name) | Selects one exact candidate route. |
routes(names) | Selects an ordered array of exact candidate routes. |
fanOut() | Selects every candidate route for a read. |
reject(message) | Stops the command with an explicit diagnostic. |
The function must return one of these decision objects. A plain JavaScript object is not a routing decision.
DBEngine
DBEngine.query(sql, parameters) executes a bounded, read-only query against
authorized physical tables in the active VDB. It returns:
| Member | Content |
|---|---|
columns | Result column metadata |
rows | Result rows as positional arrays |
rowCount | Number of returned rows |
Tables must be qualified as schema.table. The API rejects writes, DDL,
procedures, functions, views, temporary and system objects, the routing schema
currently being resolved and direct or transitive routing cycles. Resolver
configuration bounds query count, rows, bytes and execution time.
logger
The routing logger exposes debug(message), info(message) and
warn(message). It does not expose the two-argument overloads available to
other script types.
The resolver context does not include global, helper or httpCli, and it
has no generic filesystem, process, thread, native, host-class or unrestricted
polyglot access.
Template function
Only common members.
SQL script function
Only common members.
Authentication/Authorization script
auth
An object used to exchange authentication and session-establishment information between the script and the session manager.
| Function | Description |
|---|---|
authenticationSource : string | Indicates which transport or entry point initiated the authentication request. Possible values include SOCKET_TRANSPORT and HTTP. |
userName : string | Contains the username provided by the remote client during session initialization. |
credentials : string | Contains the credentials (such as a password or token) provided by the remote client during session initialization. |
metadata : object | Contains metadata associated with the authentication request. For HTTP-based authentication, this object includes the request headers. |
httpAuthenticationType : string | Indicates the HTTP authentication mechanism detected by the engine. See below for details. |
trust() | Accepts the authentication request and allows the remote client to establish a persistent session. |
bad() | Rejects the authentication request due to invalid credentials or authentication failure. |
bad(message : string) | Same as bad(), but allows a custom reason message to be returned to the remote client. |
locked() | Rejects the authentication request because the user is locked or disabled. |
locked(message : string) | Same as locked(), but allows a custom reason message to be returned to the remote client. |
addPrincipal(name : string) | Associates a principal with the authenticated session. |
addRole(name : string) | Associates a role with the authenticated session. |
HTTP Authentication Type Detection
When authentication is initiated through the HTTP transport, Kubling attempts to infer the authentication mechanism used by the remote client and exposes the result through auth.httpAuthenticationType.
The detected type reflects how credentials or identity information were presented to the engine, independently of whether the authentication request is ultimately accepted or rejected.
Possible values are:
| Value | Description |
|---|---|
BEARER | The request contains an Authorization: Bearer header. |
BASIC | The request contains an HTTP Basic Authentication header. |
MTLS | Authentication information was derived from a mutually authenticated TLS session. |
API_KEY | The request contains an API key recognized by the configured authentication initiator. |
NONE | No recognizable HTTP authentication mechanism was detected. |
Endpoint Script
httpRequest
An object that provides full access to the incoming HTTP request made by a remote client.
It exposes standard request metadata, headers, query/form parameters, and the message body.
| Function | Description |
|---|---|
method() : string | Returns the HTTP method of the request (e.g., GET, POST, DELETE). |
contentType() : string | Returns the value of the Content-Type header, or null if not present. |
contentLength() : number | Returns the length of the request body in bytes, or -1 if unknown. |
headerNames() : string[] | Returns a list of all header names present in the request. |
header(name : string) : string | Returns the first header value for the given name, or null if not present. |
headers(name : string) : string[] | Returns all header values for the given name. |
parameterNames() : string[] | Returns a list of all query/form parameter names. |
param(name : string) : string | Returns the first value for the specified parameter, or null if not found. |
paramValues(name : string) : string[] | Returns all values for the specified parameter name. |
body() : string | Returns the full request body as a UTF-8 string. Cached after the first access. |
bodyAs(charset : string) : string | Returns the request body using the specified charset (e.g., "ISO-8859-1"). Defaults to UTF-8. |
httpResponse
An object used to build the HTTP response to be sent back to the client.
Supports text, JSON, HTML, and binary (base64) content, along with full control over headers, status codes, and cookies.
| Function | Description |
|---|---|
status() : number | Returns the current HTTP status code. |
status(code : number) : httpResponse | Sets the HTTP status code (e.g., 200, 404, 500). |
header(name : string, value : string) : httpResponse | Sets or replaces a header. |
addHeader(name : string, value : string) : httpResponse | Adds an additional value to a multi-valued header. |
removeHeader(name : string) : httpResponse | Removes the specified header. |
headerNames() : string[] | Returns all header names. |
headers(name : string) : string[] | Returns all values for the specified header. |
contentType() : string | Returns the current Content-Type value. |
contentType(type : string) : httpResponse | Sets the Content-Type (e.g., application/json, text/html). |
charset() : string | Returns the current character encoding. Default is UTF-8. |
charset(charset : string) : httpResponse | Sets the character encoding (e.g., ISO-8859-1). |
text(body : string) : httpResponse | Sets the response body as plain text. Sets Content-Type to text/plain; charset=UTF-8 unless already defined. |
html(body : string) : httpResponse | Sets the response body as HTML. Sets Content-Type to text/html; charset=UTF-8 unless already defined. |
json(value : object) : httpResponse | Serializes an object or JSON string and sets it as the response body. Sets Content-Type to application/json. |
base64(body : string, mimeType : string) : httpResponse | Sends a binary body encoded as Base64. Optionally sets the MIME type. |
noContent() : httpResponse | Clears the body and sets status to 204 if not already set. |
cookie(name : string, value : string) : httpResponse | Adds a basic cookie with default attributes. |
cookie(name : string, value : string, attributes : object) : httpResponse | Adds a cookie with attributes. See below. |
cookies() : object[] | Returns a list of cookies that will be sent in the response. |
General
ListProxyObject
A List of elements created in the engine and exposed to the script context.
Its functions are only proxies that point to the original, non-script-compatible array.
| Function | Description |
|---|---|
forEach(action) | Direct support for the standard forEach form when the particular script context or the language does not support it. For example, in JavaScript it is recommended the usage of array.forEach((element) => ...); instead. |
isEmpty() : boolean | Returns true if the array has no elements. |
array() : object[] | Returns all elements as an array of object. |
stringify() : string[] | Returns an array containing the string representation of the elements in the array. |
iterable() : <object> | Returns an iterable wrapper that is resolved by the script context as a native feature. For example, in JavaScript it will allow you to use a for (variable of iterable) loop. |
get(pos : integer) : object | Returns the object at the specified position in the array. |
getFirst() : object | Returns the first object of the array. |
getLast() : object | Returns the last object of the array. |
size() : integer | Returns the number of elements in the array. |
QueryFilterProxyObject
An object that contains only members (not functions), which describes the filter, or WHERE clause, of the query.
| Member | Description |
|---|---|
filters : ListProxyObject<FilterValue> | Returns the list of filters. Elements of the List are of FilterValue type. |
sort : ListProxyObject<QueryFilterSort> | Returns the requested sort (ORDER BY). Elements of the List are of QueryFilterSort type. |
pagination : QueryPageFilterProxyObject | Returns the requested pagination (LIMIT). See proxy information. |
table : string | Query table name. |
json : string | Self-representation in JSON format. |
yaml : string | Self-representation in YAML format. |
FilterValue full schema:
type: "object"
id: "schema:kubling:connectors:translation:scripting:base:member:filter:FilterValue"
properties:
field:
type: "string"
description: "Name of the field to be evaluated."
dataType:
type: "string"
description: "Engine data type of the field."
value:
type: "object"
id: "schema:kubling:InnerObject"
description: "Value used by the comparison operation."
operation:
type: "object"
id: "schema:kubling:connectors:translation:scripting:base:member:proxy:EnumObject<com:kubling:connectors:translation:scripting:base:member:filter:FilterValue:Operation>"
properties:
value:
type: "string"
enum:
- "EQUAL"
- "NOT_EQUAL"
- "GREATER_THAN"
- "GREATER_THAN_OR_EQUAL"
- "LESS_THAN"
- "LESS_THAN_OR_EQUAL"QueryFilterSort full schema:
type: "object"
id: "schema:kubling:connectors:translation:scripting:base:member:filter:QueryFilterSort"
properties:
field:
type: "string"
orderType:
type: "string"
enum:
- "ASC"
- "DESC"
- "FIRST"
- "LAST"QueryPageFilterProxyObject
An object that contains only members (not functions), which describes the filter, or LIMIT clause, of the query.
| Member | Description |
|---|---|
pageSize : integer | Number of rows returned by the query. |
page : integer | Page to start from, also known as offset. |
json : string | Self-representation in JSON format. |
yaml : string | Self-representation in YAML format. |
SetOperationProxyObject
An object that contains only members (not functions), with values passed to the operation.
| Member | Description |
|---|---|
fieldName : string | Field name. |
value : object | Field value. |
json : string | Self-representation in JSON format. |
yaml : string | Self-representation in YAML format. |
AffectedRows
A proxy object that contains the the number of rows affected by the operation.
| Member | Description |
|---|---|
increment() | Increments (1) the number of affected rows. |
increment(number : integer) | Increments a specified number of affected rows. |
get() : integer | Returns the current affected rows. |
addGeneratedKey(colName : string, value : object) : integer | Registers a generated key for the given column name and propagates it to the engine. This allows generated values (for example, auto-increment identifiers) to be returned by the operation when supported. The engine will attempt to transform the provided value from the script data type into the table column data type. Transformation failures result in execution errors. |
JsonDifferenceResultProxyObject
An object that contains only members (not functions), that describes the result of a document comparison operation.
| Member | Description |
|---|---|
added : ListProxyObject<string> | List of fully qualified field names added to the document. |
removed : ListProxyObject<string> | List of fully qualified field names removed from the original document. |
modified : ListProxyObject<string> | List of fully qualified field names modified. |
untouched : ListProxyObject<string> | List of fully qualified field names that have not been modified. |
QueryResultProxyObject
An object that contains the result set of query.
| Member | Description |
|---|---|
count : integer | Returns the number of rows contained in the result set. |
countFields : integer | Returns the number of columns (fields) contained in the result set. |
fieldNames : ListProxyObject<string> | List of field names returned by the query. |
rows : ListProxyObject<object> | Returns the actual rows of the result set. Each element is an native object, therefore fields can be accessed using dot-notation. |
inspect : string | Human-readable preview of the result set for debugging. v25.5+ |