Skip to content

Latest commit

 

History

History
2558 lines (1487 loc) · 49.8 KB

yudien_functions.md

File metadata and controls

2558 lines (1487 loc) · 49.8 KB

Yudien (UDN) Functions

  1. Data Access
    1. __get - Get Global Data
    2. __set - Set Global Data
    3. __get_index - Get data from input
    4. __set_index - Set data to output
    5. __get_first - Get First non-nil Data
    6. __get_temp - Get Temp Data
    7. __set_temp - Set Temp Data
    8. __increment - Increment Value
    9. __decrement - Decrement Value
  2. Database
    1. __data_get - Dataman Get
    2. __data_set - Dataman Set
    3. __data_filter - Dataman Filter
    4. __query - Stored SQL Querying
  3. Conditions and Looping
    1. __if - If
    2. __else_if - Debug Output
    3. __end_if - Debug Output
    4. __not - Not
    5. __not_nil - Not Nil
    6. __is_nil - Is Nil
    7. __iterate - Iterate
    8. __end_iterate - End Iterate
    9. __while - While
    10. __end_while - End While
    11. __compare_equal - Compare Equal
    12. __compare_not_equal - Compare Not Equal
  4. Execution Control
    1. __input - Input
    2. __input_get - Input Get
    3. __function - Call Function
    4. __execute - Execute UDN
  5. Text
    1. __template - String Template from Value
    2. __template_wrap - TBD
    3. __format - Format Strings from Map
    4. __template_short - String Template from Value
    5. __string_append - String Append
    6. __string_clear - String Clear
    7. __concat - String Concatenate
    8. __upper - String Uppercase
    9. __lower - String Lowercase
    10. __split - String Split
    11. __json_decode - JSON Decode
    12. __json_encode - JSON Encode
    13. __base64_decode - Base64 Decode
    14. __base64_encode - Base64 Encode
    15. __html_encode - HTML Encode
    16. __num_to_string - Number to String
  6. Maps
    1. __map_key_set - Map Key Set
    2. __map_key_delete - Map Key Delete
    3. __map_copy - Map Copy
    4. __map_update - Map Update
    5. __map_template_key - Map Template Key
    6. __group_by - Group By
  7. Array
    1. __array_append - Array Append
    2. __array_remove - Array Remove
    3. __array_index - Array Index
    4. __array_slice - Array Slice
    5. __array_contains - Array Contains
    6. __array_map_remap - Array Map Remap
    7. __array_map_find - Array Map Find
    8. __array_map_find_update - Array Map Find Update
    9. __array_map_template - Array Map Template
    10. __array_map_to_map - Array Map To Map
    11. __array_map_key_set - Array Map Key Set
    12. __array_divide - Array Divide
  8. Time
    1. __string_to_time - String to Time
    2. __get_current_time - Get Current Time
    3. __get_local_time - Get Local Time
    4. __time_to_epoch - Convert Time to Unix Time in Seconds
    5. __time_to_epoch_ms - Convert Time to Unix Time in Milliseconds
  9. Math
    1. __math - Math functions
  10. Rendering
    1. __widget - Render Widget
    2. __render_data - Render Data Widget
  11. Networking
    1. __set_http_response - Set http response code
    2. __http_request - Send http request
  12. User
    1. __login- LDAP Login
  13. Special
    1. __ddd_render - Render DDD Dialog Editor
  14. Debugging
    1. __debug_output - Debug Output
  15. Comments
    1. __comment - UDN Comment

Data Access

__get ::: Get Global Data

Go: UDN_Get

Input: Ignored

Args:

  1. string :: If quoted, this can contain dots, of each arg will become part of a "dotted string" to access the global data
  2. string (optional, variadic) :: Any number of args can be provided, all strings

Output: list of maps :: []map[string]interface

Example:

__input.Testing123.__set.temp.testing.__get.temp.testing

Result:

Testing123

Alternate Example, single dotted string uses the same Global Data:

__input.Testing123.__set.temp.testing.__get.'temp.testing'

Side Effect: None

Related Functions: __set

__set ::: Set Global Data

Go: UDN_Set

Input: Ignored

Args:

  1. string :: If quoted, this can contain dots, of each arg will become part of a "dotted string" to access the global data
  2. string (optional, variadic) :: Any number of args can be provided, all strings
  3. Any :: The final data can be any value, and is set into the location

Output: list of maps :: []map[string]interface

Example:

__input.Testing123.__set.temp.testing.__get.temp.testing

Result:

Testing123

Alternate Example, single dotted string uses the same Global Data:

__input.Testing123.__set.'temp.testing'.__get.temp.testing

Side Effect: None

Related Functions: __get

__get_index ::: Get Input Data

Go: UDN_GetIndex

Note: similar to __get, however the global udn_data is not used. Data comes directly from input

Input: Any

Args:

  1. string :: If quoted, this can contain dots, of each arg will become part of a "dotted string" to access the input data
  2. string (optional, variadic) :: Any number of args can be provided, all strings

Output: Any depending on what is specified

Example:

__input.{key1=value1}.__get_index.key1

Result:

value1

Alternate Example:

__input.[{key1=value1}, {key2=value2}].__get_index.1.key2

Result:

value2

Side Effect: None

Related Functions: __set_index

__set_index ::: Set Input Data

Go: UDN_SetIndex

Note: similar to __set, however data is not stored in the global udn_data. Output is directly piped out to result and not stored. Data comes directly from input and is modified and piped out.

Input: Any

Args:

  1. string :: If quoted, this can contain dots, of each arg will become part of a "dotted string" to access the input data
  2. string :: The last argument is the value that is set to the specified location in the input string

Output: The updated input string with the specified updated value

Example:

__input.{key1=value1}.__set_index.key1.value2

Result:

{key1: value2}

Alternate Example:

__input.[{key1=value1}, {key2=value2}].__set_index.1.key2.value3

Result:

[{key1=value1, key2=value3}]

Side Effect: None

Related Functions: __get_index

__get_first ::: Get first non-nil Global Data

Takes an array of N strings, which are dotted for udn_data accessing. The first value that isnt nil is returned. nil is returned if they all are.

Go: UDN_Get

Input: Ignored

Args:

  1. string :: Dotted string ('location.goes.here')
  2. string (optional, variadic) :: Any number of args can be provided, same as the first argument

Output: Any

Example:

__input.'Hello World'.__set.special.field.__get_first.'not.a.real.place'.'special.field'

Result:

Hello World

Side Effect: None

__get_temp ::: Get Temporary Data

Just like __get, except uses a portion of the Global Data space behind a UUID for this ProcessSchemaUDNSet() or __function call. It allows names to be re-used, which they cannot be in the normal Global Data space, as it is global.

Go: UDN_GetTemp

Input: Ignored

Args:

  1. string :: If quoted, this can contain dots, of each arg will become part of a "dotted string" to access the global data
  2. string (optional, variadic) :: Any number of args can be provided, all strings

Output: Any

Example:

__input.Testing123.__set_temp.temp.testing.__get_temp.temp.testing

Result:

Testing123

Alternate Example, single dotted string uses the same Global Data:

__input.Testing123.__set_temp.'temp.testing'.__get_temp.temp.testing

Side Effect: None

Related Functions: __set_temp

__set_temp ::: Set Global Data

Just like __set, except uses a portion of the Global Data space behind a UUID for this ProcessSchemaUDNSet() or __function call. It allows names to be re-used, which they cannot be in the normal Global Data space, as it is global.

Go: UDN_SetTemp

Input: Ignored

Args:

  1. string :: If quoted, this can contain dots, of each arg will become part of a "dotted string" to access the global data
  2. string (optional, variadic) :: Any number of args can be provided, all strings
  3. Any :: The final data can be any value, and is set into the location

Output: list of maps :: []map[string]interface

Example:

__input.Testing123.__set_temp.testing.__get_temp.testing

Result:

Testing123

Alternate Example, single dotted string uses the same Global Data:

__input.Testing123.__set_'temp.testing'.__get_temp.testing

Side Effect: None

Related Functions: __get_temp

__increment ::: Increment Value

Given arg[0], increment value by 1. Output incremented value (float64/int64)

Go: UDN_Increment

Input: int (starting value)

Args:

  1. int (value to be incremented by, default is 1 if not provided)

Output: int - incremented value

Example:

__input.99.__increment

Result:

100

Alternate Example,

__input.99.__increment.2

Result:

101

Side Effect: None

Related Functions: __decrement

__decrement ::: Decrement Value

Given arg[0], decrement value by 1. Output decremented value (float64/int64)

Go: UDN_Decrement

Input: int

Args:

  1. int - value to be incremented by (default is 0 if not provided)

Output: int - decremented value

Example:

__input.100.__decrement

Result:

99

Example:

__input.100.__decrement.2

Result:

98

Side Effect: None

Related Functions: __increment

Database

See docs on Dataman for more details: https://docs.google.com/document/d/1YDbwuQPpObAK06nnDd-v-rded3ma25AUToZ5iuewTiU/edit#

__data_get ::: Dataman Get

Just like __set, except uses a portion of the Global Data space behind a UUID for this ProcessSchemaUDNSet() or __function call. It allows names to be re-used, which they cannot be in the normal Global Data space, as it is global.

Go: UDN_DataGet

Input: Ignored

Args:

  1. string :: Table/Collection name
  2. int :: Record ID. Primary key.
  3. options :: Options. Example: {"db": "eventsum"}

Output: Map :: map[string]interface

Example:

__data_get.web_widget_type.1

Result:

{_id: 1, name: "Base Page"}

Side Effect: None

Related Functions: __data_set, __data_filter, __query

__data_set ::: Dataman Set

Just like __set, except uses a portion of the Global Data space behind a UUID for this ProcessSchemaUDNSet() or __function call. It allows names to be re-used, which they cannot be in the normal Global Data space, as it is global.

Go: UDN_DataSet

Input: Ignored

Args:

  1. string :: Table/Collection name
  2. map :: Record field data to put back in
  3. options :: Options. Example: {"db": "eventsum"}

Output: Map :: map[string]interface

Example:

__data_set.web_widget_type.{_id=1,name='Base Page'}

Result:

{_id: 1, name: "Base Page"}

Side Effect: None

Related Functions: __data_get, __data_filter

__data_filter ::: Dataman Filter

Just like __set, except uses a portion of the Global Data space behind a UUID for this ProcessSchemaUDNSet() or __function call. It allows names to be re-used, which they cannot be in the normal Global Data space, as it is global.

Go: UDN_DataFilter

Input: Ignored

Args:

  1. string :: If quoted, this can contain dots, of each arg will become part of a "dotted string" to access the global data
  2. string (optional, variadic) :: Any number of args can be provided, all strings
  3. Any :: The final data can be any value, and is set into the location
  4. options :: Options. Example: {"db": "eventsum"}

Output: list of maps :: []map[string]interface

Example:

__data_filter.web_widget_type.{name=(__input.['=', 'Base Page'])}
  • Note that it is necessary to create a list first to adhere to the dataman requirements

Result:

[{_id: 1, name: "Base Page"}]

Side Effect: None

Related Functions: __data_get, __data_set

__query ::: Stored SQL Querying

PARTIALLY DEPRICATED: Only use __query when __data_get and __data_filter absolutely wont work. Dataman makes working with data much more consistent and also takes care of integrite problems. Especially only use Dataman for writing data, as there are additional constraints.

Go: UDN_QueryById

Input: Ignored

Args:

  1. int :: datasource_query.id record primary key
  2. map (optional) :: data arguments for the query, are short templated into the stored SQL

Output: list of maps :: []map[string]interface

Example:

__query.25

Side Effect: None

Related Functions: __data_get, __data_filter

Conditions and Looping

__if :: Conditional If

Go: UDN_IfCondition

Input: Any

Args: None

Output: Last Output Function Result

Example:

__if.1.__debug_output.__end_if

Related Functions: __else_if

End Block: __end_if

Side Effect: Loops over all functions in the block (between __if and matching __end_if)

__else_if :: Conditional Else, If

Go: UDN_ElseCondition

Input: Any

Args: None

Output: Last Output Function Result

Example:

__if.0.__debug_output.__else_if.__debug_output.__end_if

Side Effect: Loops over all functions in the block (between __else_if and matching __end_if or next __else_if)

__end_if :: End If/ElseIf Block

Go: nil

Input: Any

Args: None

Output: Last Output Function Result

Example:

__if.1.__debug_output.__end_if

Side Effect: None

Related Functions: __if

__not :: Not - Reverses boolean test (1, "1", true)

Go: UDN_Not

Input: Boolean value: true, 1, "1", false, 0, "0"

Args:

  • Boolean, String, Integer: true, false, "1", "0", 1, 0

Output: Boolean: "1", "0"

Example:

__if.(__not.0).__debug_output.__end_if

Side Effect: None

Related Functions: __not_nil, __if

__not_nil :: Not Nil - Returns "1" (true) if not nil

Go: UDN_NotNil

Input: nil or Not

Args: None

Output: Boolean: "1", "0"

Example:

__if.(__get.thing.that.exists.__not_nil).__debug_output.__end_if

Side Effect: None

Related Functions: __not, __is_nil, __if

__is_nil :: Is Nil - Returns "1" (true) if is nil

Go: UDN_NotNil

Input: nil or Not

Args: None

Output: Boolean: "1", "0"

Example:

__if.(__get.thing.that.doesnt.exist.__is_nil).__debug_output.__end_if

Side Effect: None

Related Functions: __not, __not_nil, __if

__iterate :: Iterate

Go: UDN_Iterate

Input: Any

Args: None

Output: First Element of Array

Example:

__iterate.__debug_output.__end_iterate

End Block: __end_iterate

Side Effect: Loops over all functions in the block (between __iterate and matching __end_iterate)

__end_iterate :: End Iterate

Go: nil

Input: Any

Args: None

Output: Array of All iterate block runs

Example:

Side Effect: None

Related Functions: __iterate

__while :: While

Go: UDN_While

Input: None

Args: None

  1. String :: UDN code that is executed, and then checked like an __if result, which becomes boolean each while loop, breaking the while on a False result
  2. Int :: Maximum number of times the while should execute. Must be positive integer, 0/-1 will never execute. Ensures it does not infinitely loop.

Output: None

Example:

__input.10__set_temp_counter.__while.(__not.(__compare.(__get_temp.counter).0)).__math.input.(__get_temp.counter).__decrement.__set_temp.counter.__debug_output.__end_iterate

End Block: __end_while

Side Effect: Loops over all functions in the block (between __while and matching __end_while), as long as the condition is true, up to the maximum number of times (arg 1)

__end_while :: End While

Go: nil

Input: Any

Args: None

Output: Array of All while block runs

Side Effect: None

Related Functions: __while

__compare_equal :: Conditon to Check for Equality

Go: UDN_CompareEqual

Input: Ignored

Args:

  1. Any :: Converted to a string for comparison
  2. Any :: Converted to a string for comparison

Output: Boolean: "1", "0"

Example:

__if.(__compare_equal.Tom.Jerry).__input.1.__else.__input.0.__end_if

Returns:

0

Related Functions: __compare_not_equal, __if

Side Effect: None

__compare_not_equal :: Conditon to Check for Non-Equality

Go: UDN_CompareNotEqual

Input: Ignored

Args:

  1. Any :: Converted to a string for comparison
  2. Any :: Converted to a string for comparison

Output: Boolean: "1", "0"

Example:

__if.(__compare_not_equal.Tom.Jerry).__input.1.__else.__input.0.__end_if

Returns:

1

Related Functions: __compare_equal, __if

Side Effect: None

Execution Control

__input ::: Input

Go: UDN_Input

Input: Any

Args:

  1. Any (optional) :: This overrides the Input coming into this function

Output: Any. Passes through Input or Arg[0]

Example:

__input.Testing123.__set.temp.testing.__get.temp.testing

Result:

Testing123

Side Effect: None

__input_get ::: Retrieves field from current Input as Map

Go: UDN_InputGet

Input: Map ::: map[string]interface

Args:

  1. string :: Index of the field for the Input

Output: Any. Passes through Input or Arg[0]

Example:

__input.{name=Bob}.__input_get.name

Result:

Bob

Side Effect: None

__function ::: Calls a UDN Stored Function

This uses the udn_stored_function.name as the first argument, and then uses the current input to pass to the function, returning the final result of the function. Uses the web_site.udn_stored_function_domain_id to determine the stored function

Go: UDN_StoredFunction

Input: Any

Args:

  1. string :: Index of the field for the Input
  2. Any (options, variadic) :: Any arguments from this point are stored as an Array in the Global Data location "function_arg"

Output: Any

Example:

__function.test_function.arg0.arg1.arg2

Result:

Anything!!!

Side Effect: Any

Related Functions: __execute

__execute ::: Execute UDN from String

Execute a single UDN string. Combines the 2-tuple normally used to a single string. Also removes the concurrency blocks, making it a single string and not a next JSON array of 2-tuple strings.

Go: UDN_Execute

Input: Ignored

Args:

  1. string :: UDN code in a single string (Source/Target not separated)

Output: Any

Example:

__execute.'__input.Testing123'

Result:

Testing123

Side Effect: Any

Related Functions: __function

Text

__template :: String Template From Value

Go: UDN_StringTemplateFromValue

Input: Map :: map[string]interface{}

Args:

  1. string :: Text to be templated, using Go's text/template function
  2. Map (optional) :: Overrides the Input map value, if present

Output: string

Example:

__input.{name="Bob"}.__template.'Name: {{index .Map "name"}}'

Returns:

"Name: Bob"

Related Functions: __template_wrap, __template_short, __format, __template_map

Side Effect: None

__template_wrap :: String Template From Value

Takes N-2 tuple args, after 0th arg, which is the wrap_key, (also supports a single arg templating, like __template, but not the main purpose). For each N-Tuple, the new map data gets "value" set by the previous output of the last template, creating a rolling "wrap" function.

NOTE(g): I dont know how this function is used at this point. It was useful, but I dont see an example to explain it. It's extremely overloaded, but powerful.

Go: UDN_StringTemplateMultiWrap

Input: Map :: map[string]interface{}

Args:

  1. string :: Text to be templated, using Go's text/template function
  2. Map (optional) :: Overrides the Input map value, if present

Output: string

Example:

__input.{name=Bob,job=Programmer}.__template_wrap.'Name: {{index .Map "name"}}'.{name=Bob}.'Job: {{index .Map "job"}}'.{job=Programmer}

Returns:

"Name: Bob"

Related Functions: __template, __template_short, __format, __template_map

Side Effect: None

__template_map :: String Template From Value

Like format, for templating. Takes 3*N Args: (key,text,map), any number of times. Performs template and assigns key into the input map

Go: UDN_MapTemplate

Input: Ignored

Args:

  1. String :: Set key. This is where we will set the value once templated.
  2. String :: Template text. This is the text to be templated.
  3. Map :: This is the data to be templated into the 2nd arg.

Output: Passed Through Input

Example:

__template_map.'location.saved'.'Name: {{index .Map "name"}}'.{name=Bob}.__get.location.saved

Returns:

"Name: Bob"

Related Functions: __template_wrap, __template_short, __format, __template

Side Effect: None

__format :: Format Strings from Map

Updates a map with keys and string formats. Uses the map to format the strings. Takes N args, doing each arg in sequence, for order control

Go: UDN_MapStringFormat

Input: Map :: map[string]interface

Args:

  1. String :: Set key. This is where we will set the value once templated.
  2. String :: Format string. This is the data to be templated into the 0th arg location.

*** Optional and Repetable Args ***

  1. String (optional, variadic) :: Set key. Indefinite pairs of String/Map args
  2. Map (optional, variadic) :: Format string. Indefinite pairs of String/Map args

*** End Optional and Repetable Args ***

Output: Passed Through Input

Example:

__input.{name=Bob,job=Programmer}.__format.'location.saved.name'.'Name: {index .Map "name"}'.'location.saved.job'.'Job: {index .Map "job"}.__get.location.saved.name'

Returns:

"Name: Bob"

Related Functions: __template_wrap, __template_short, __format, __template

Side Effect: None

__template_short :: String Template From Value

Like __template, but uses {{{name}} instead of {index .Map "name"}

Go: UDN_StringTemplateFromValueShort

Input: Map :: map[string]interface

Args:

  1. String :: Set key. This is where we will set the value once templated.
  2. Map (optional) :: This overrides the Input, if present

Output: String

Example:

__input.{name=Bob,job=Programmer}.__template_short.'Name: {{{name}}}'

Returns:

"Name: Bob"

Related Functions: __template_wrap, __template_short, __format, __template

Side Effect: None

__string_append :: String Append

Appends to an existing string, or creates a string if nil (not present in Global Data). Args work like __get

Go: UDN_StringAppend

Input: String

Args:

  1. string :: If quoted, this can contain dots, of each arg will become part of a "dotted string" to access the global data
  2. string (optional, variadic) :: Any number of args can be provided, all strings

Output: String

Example:

__input.'The Quick '.__set.temp.test.__input.'Brown Fox'.__string_append.temp.test.__get.temp.test

Returns:

"The Quick Brown Fox"

Related Functions: __string_clear, __concat

Side Effect: None

__string_clear:: String Clear

This is only needed when re-using a Global Data label, you can start appending to an non-existent location and it will start it with an empty string.

Go: UDN_StringClear

Input: String

Args:

  1. string :: If quoted, this can contain dots, of each arg will become part of a "dotted string" to access the global data
  2. string (optional, variadic) :: Any number of args can be provided, all strings

Output: String

Example:

__string_clear.temp.test

Related Functions: __string_append

Side Effect: None

__concat :: String Concatenate

TODO(g): Not Yet Implemented

Go: UDN_StringConcat

Input: String

Args:

  1. string :: If quoted, this can contain dots, of each arg will become part of a "dotted string" to access the global data
  2. string (optional, variadic) :: Any number of args can be provided, all strings

Output: String

Example:

Returns:

Related Functions: __string_clear, __string_append

Side Effect: None

__upper :: String Uppercase

Go: UDN_StringUpper

Input: String

Args:

  1. string :: string that will be set to uppercase

Output: String (upper case)

Example:

"__upper.hElLo"

Returns:

HELLO

Related Functions: __lower

Side Effect: None

__lower :: String Lowercase

Go: UDN_StringLower

Input: String

Args:

  1. string :: string that will be set to lowercase

Output: String (lower case)

Example:

"__lower.hElLo"

Returns:

hello

Related Functions: __upper

Side Effect: None

__split :: String Split

Go: UDN_StringSplit

Input: String that will be split

Args:

  1. string :: string that is used as the separator

Output: List (of strings)

Example:

"__input.'hello.world.how.are.you'.__split.'.'"

Returns:

[hello, world, how, are, you]

Related Functions: __concat, __string_append

Side Effect: None

__json_decode :: JSON Decode

Decodes a string to Go data: map[string]interface is assumed if using Global Data

Go: UDN_JsonDecode

Input: String

Args: None

Output: Map :: map[string]interface

Example:

__input.'{"a": 1}'.__json_decode

Returns:

{a: 1}

Related Functions: __json_encode

Side Effect: None

__json_encode :: JSON Encode

Encodes Go data into a JSON string

Go: UDN_JsonDecode

Input: Any

Args: None

Output: String

Example:

__input.{a=1}.__json_encode

Returns:

{"a": "1"}

Related Functions: __json_decode

Side Effect: None

__base64_decode :: Base64 Decode

Decodes a string from base64 into a normal string

Go: UDN_JsonDecode

Input: String

Args: None

Output: Map :: map[string]interface

Example:

__input.'todo'.__base64_decode

Returns:

todo

Related Functions: __base64_encode

Side Effect: None

__base64_encode :: Base64 Encode

Encodes a string into base64, needed for passing around in web pages where quoting issues or spacing won't allow regular text, or binary transmission

Go: UDN_JsonDecode

Input: Any

Args: None

Output: String

Example:

__input.todo.__json_encode

Returns:

todo

Related Functions: __base64_decode

Side Effect: None

__html_encode :: HTML Encode

Escapes HTML characters

Go: UDN_HtmlEncode

Input: String

Args: None

Output: String

Example:

__input.'1 < 2'.__html_encode

Returns:

1 &lt; 2

Side Effect: None

__num_to_string ::: Number To String

Given input number (int/int64/float64) and optional precision (int), outputs string (with specified precision/ original number)

Go: UDN_NumberToString

Input: number (int/int64/float64)

Args:

  1. int (optional) :: arithmetic precision (number of decimal places)

Output: string (with specified precision/original number)

Example:

__math.input.'999.99'.__num_to_string.4

Returns:

"999.9900"

Alternate Example, no argument/precision specified:

__math.input.999.__num_to_string

Returns:

"999"

Side Effect: None

Map

__map_key_set ::: Map Key Set

Sets N keys, like __format, but with no formatting

Go: UDN_MapKeySet

Input: Map

Args:

  1. String (variadic) :: Key/field to set in the Map
  2. Any (variadic) :: Value to set in the Map key/field

Output: Map

Example:

__input.{name=Bob}.__map_key_set.job.Programmer

Result:

{name=Bob,job=Programmer}

Side Effect: None

Related Functions: __map_key_delete

__map_key_delete ::: Map Key Delete

Deletes N keys

Go: UDN_MapKeySet

Input: Map

Args:

  1. String (variadic) :: Key/field to delete in the Map

Output: Map

Example:

__input.{name=Bob,job=Programming}.__map_key_delete.job

Result:

{name=Bob}

Side Effect: None

Related Functions: __map_key_set

__map_copy ::: Map Copy

Creates a new Map which is a copy/clone of the current one, so you can modify it without changing the original

Go: UDN_MapCopy

Input: Map

Args:

  1. String (variadic) :: Key/field to delete in the Map

Output: Map

Example:

__input.{name=Bob,job=Programming}.__map_copy

Result:

{name=Bob,job=Programming}

Side Effect: None

__map_update ::: Map Update

Creates a new Map which is a copy/clone of the current one, so you can modify it without changing the original

Go: UDN_MapUpdate

Input: Map

Args:

  1. String (variadic) :: Key/field to delete in the Map

Output: Map

Example:

__input.{name=Bob}.__map_update.{job=Programming}

Result:

{name=Bob,job=Programming}

Side Effect: None

__map_template_key ::: Map Template Key

Creates a new Map which has keys that are templated versions of the previos map. The values remain the same.

This is useful for things such as prefixing a UUID in front of keys, so that they can be injected into HTML pages.

Go: UDN_MapTemplateKey

Input: Map

Args:

  1. String :: Template string (text/template)
  2. Map :: Map of values to use for templating. A "key" key will be added with each key's string, so that it can be used in the templating process.
  3. Map (optional) :: Map that overrides input Map.

Output: Map

Example:

__input.{name=Bob}.__map_template_key.'{{uuid}}_{{key}}'.{uuid=1234}

Result:

{1234_name=Bob}

Side Effect: None

__group_by ::: Group by on a list of Maps

Given a list of maps, group by an aggregate field

Go: UDN_GroupBy

Input: None

Args:

  1. string :: method to group on
  2. list of maps :: source of data to operate on
  3. string :: aggregated field
  4. string :: field to group on

Grouping methods:

  1. sum
  2. count

Output: Aggregated map

Example:

__input.[{order_id:101,category:monitor,cost:(__math.input.80)},{order_id:102,category:monitor,cost:(__math.input.82)},{order_id:103,category:laptop,cost:(__math.input.100)}].__set.data,
__group_by.sum.(__get.data).cost.category.__set.set_api_result

Result:

[{category:monitor,cost:162},{category:laptop,cost:100}]

Side Effect: None

Array

__array_append ::: Array Append

Appends the input into the specified target location (args)

Go: UDN_ArrayAppend

Input: Item to append into the array

Args:

  1. Any :: Target array name

Output: Array

Example:

__input.[1,2,3].__set.test
__input.4.__array_append.test

Result:

[1,2,3,4]

Side Effect: None

__array_remove ::: Array Remove

Removes first entry of the element (input)

Go: UDN_ArrayRemove

Input: Item to remove from the array

Args:

  1. Map :: Target array name

Output: Array

Example:

__input["Alice", "Bob"].__set.test.array.__input.["Alice"].__array_remove.test_array

Result:

["Bob"]

Side Effect: None

__array_index ::: Array Index

Returns the index (int) of the first entry in the array of the input element

Go: UDN_ArrayIndex

Input: Item to find the index of in the array

Args:

  1. Map :: Target array name

Output: Array

Example:

__input["Alice", "Bob"].__set.test.array.__input.["Bob"].__array_remove.test_array

Result:

0

Side Effect: None

__array_slice ::: Array Slice

Splits the array based on the start and end index (args)

Go: UDN_ArraySlice

Input: Array

Args:

  1. Int :: Start index (can be positive or negative)
  2. Int :: End index (can be positive or negative) - if end index not provided then end index is assumed to be end of array

Note: for positive indices the end index is non-inclusive. For negative indices the start index is non inclusive. Also, for positive indices the first element of the array is at 0. For negative indices the last element is at -1.

Output: Array Slice based on start & end index

Example:

__input.[1,2,3,4,5,6].__array_slice.0.6

Result:

[1,2,3,4,5,6]

Example 2:

__input.[1,2,3,4,5,6].__array_slice.-2.-1

Result:

[6]

Example 3:

__input.[1,2,3,4,5,6].__array_slice.-7.-1

Result:

[1,2,3,4,5,6]

Side Effect: None

__array_divide ::: Array Divide

Breaks an array up into a set of arrays, based on a divisor. Ex: divide=4, a 14 item array will be 4 arrays, of 4/4/4/2 items each.

Go: UDN_ArrayDivide

Input: Array

Args:

  1. Integer :: "Columns" to break up the "Row" of the Array, into many "Rows" of max "Column"

Output: Array

Example:

__input.[1,2,3,4].__array_divide.2

Result:

[[1,2],[3,4]]

Side Effect: None

__array_contains ::: Array Contains

Returns boolean, if the array specified by args contains all the elements in the input (single or array of elements)

Go: UDN_ArrayContains

Input: Item or Array of Items to see if they all exist in the specified array

Args:

  1. Map :: Target array name

Output: Bool

Example:

__input["Alice", "Bob"].__set.test.array.__input.["Bob"].__array_remove.test_array

Result:

0

Side Effect: None

__array_map_remap ::: Array Map Remap

Takes an array of maps, and makes a new array of maps, based on the arg[0] (map) mapping (key_new=key_old)

Go: UDN_ArrayMapRemap

Input: Array of Maps

Args:

  1. Map :: Keys of this map will be replaced in every Map in the Array with the value

Output: Array of Maps

Example:

__input.[{age=10},{age=20}].__array_map_remap.{age=8}

Result:

[{age=8},{age=8}]

Side Effect: None

__array_map_find ::: Array Map Find

Takes an array of maps, and returns the first entry that matches all key values of the arg0 map, or nil

Go: UDN_ArrayMapFind

Input: Array of Maps

Args:

  1. Map :: This is a key/value map to check against the array of maps, returning the first map which matches all keys/values.

Output: Map

Example:

__input.[{age=10,name=Joe},{age=20,name=Bob}].__array_map_find.{age=10}

Result:

{age=10,name=Joe}

Side Effect: None

__array_map_find_update ::: Array Map Find Update

Takes an array of maps, and matches it against all the arguments in the first map. For all elements that match, they are updated with the second map. The entire array is returned.

Go: UDN_ArrayMapFindUpdate

Input: Array of Maps

Args:

  1. Map :: This is a key/value map to check against the array of maps, returning the first map which matches all keys/values.
  2. Map :: This map is used to update all maps that match key/values in arg0

Output: Array of Maps

Example:

__input.[{age=10,name=Joe},{age=20,name=Bob}].__array_map_find_update.{age=10}.{selected=selected}

Result:

[{age=10,name=Joe,selected=selected},{age=20,name=Bob}]

Side Effect: None

__array_map_template ::: Array Map Template

Takes an array of maps, iterates over each map, and performs N templates updating keys with the map's contents (key/values)

Go: UDN_ArrayMapFindUpdate

Input: Array of Maps

Args:

  1. String :: This is the map key to update/set

  2. String :: This is the text/template data, uses the map's data

  3. String (optional) :: This is the map key to update/set

  4. String (optional) :: This is the text/template data, uses the map's data

Repeats in pairs forever.

Output: Array of Maps

Example:

__input.[{age=10,name=Joe},{age=20,name=Bob}].__array_map_template.label.'{{index .Map "name"}}: {{index .Map "age"}}'

Result:

[{age=10,name=Joe,label='Joe: 10',selected=selected},{age=20,name=Bob,label='Bob: 20'}]

Side Effect: None

__array_map_to_map ::: Array Map Find

Takes an array of maps, and returns a map where the key is the specified arg0 string key in all maps in the array

Go: UDN_ArrayMapToMap

Input: Array of Maps

Args:

  1. String :: Key to get from array maps, and key to set in result map
  2. List of Maps (optional) :: Can be passed in as arg1 instead of input

Output: Map

Example:

__input.[{age=10,name=Joe},{age=20,name=Bob}].__array_map_to_map.name

Result:

{Joe={age=10,name=Joe},Bob={age=20,name=Bob}}

Side Effect: None

__array_map_key_set ::: Array Map Key Set

Takes an array of maps, sets a variable number of key/value pairs

Go: UDN_ArrayMapToMap

Input: Array of Maps

Args:

  1. String :: Key to set in each map

  2. Any :: Value to be set into the key

  3. String (optional) :: Key to set in each map

  4. Any (optional) :: Value to be set into the key

Can repeat the pairs of key/values.

Output: Array of Maps

Example:

__input.[{age=10,name=Joe},{age=20,name=Bob}].__array_map_key_set.uuid.1234

Result:

[{age=10,name=Joe,uuid=1234},{age=20,name=Bob,uuid=1234}]

Side Effect: None

Time

__string_to_time ::: Convert String to Time

Given arg[0] string in the format 'YYYY-MM-DD hh:mm:ss' or 'YYYY-MM-DDThh:mm:ss.sssZ' (including milliseconds), return the go time.Time object.

Go: UDN_GetCurrentTime

Input: string :: This string must be of the format 'YYYY-MM-DD hh:mm:ss' or 'YYYY-MM-DDThh:mm:ss.sssZ' (including milliseconds). Otherwise, an empty result will be returned.

Args:

None

Output: time.time object

Example:

__input.'2018-01-01 00:00:00'.__string_to_time

Result:

time.Time object (Representing the first day of 2018 at midnight)

Side Effect: None

__get_current_time ::: Get Current Time

Given arg[0] string in the format 'YYYY-DD-MM hh:mm:ss'. If specific number given for YYYY, DD, MM, hh, mm, ss, use that number instead. Outputs go time.Time object of current time (UTC).

Go: UDN_GetCurrentTime

Input: Ignored

Args:

  1. string (optional) :: string format ‘YYYY-DD-MM hh:mm:ss’ - desired numbers can be specified to replace YYYY, DD, MM, hh, mm, ss

Output: time.time object

Example:

__get_current_time.'YYYY-MM-01 hh:mm:ss'

Result:

time.Time object (First day of the current month (UTC))

Alternate Example, no arguments specified:

__get_current_time

Result:

time.Time object (Current time (UTC))

Side Effect: None

__get_local_time ::: Get Local Time

If given arg[0] string, a specified timezone in the IANA Time Zone database, such as "America/Chicago". If given "" or "local" or no argument, outputs go time.Time object of current local time. Otherwise, outputs time.Time object, current time in the specified timezone.

Go: UDN_GetLocalTime

Input: Ignored

Args:

  1. string (optional) :: specified timezone in the IANA Time Zone database (https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)

Output: time.time object

Example:

__get_local_time.'America/Chicago'

Result:

time.Time object (current time in America/Chicago timezone)

Alternate Example, no arguments specified:

__get_local_time

Result:

time.Time object (Current local time)

Side Effect: None

__time_to_epoch ::: Convert time.Time to a int64 unix time in seconds

Given arg[0] time.Time object, convert to int64 unix time in seconds

Go: UDN_TimeToEpoch

Input: time.Time object

Args:

None

Output: int :: Unix time in seconds

Example:

__input.'2018-01-01 00:00:00'.__string_to_time.__time_to_epoch

Result:

1514764800

Side Effect: None

__time_to_epoch_ms ::: Convert time.Time to a int64 unix time in milliseconds

Given arg[0] time.Time object, convert to int64 unix time in milliseconds

Go: UDN_TimeToEpochMs

Input: time.Time object

Args:

None

Output: int :: Unix time in milliseconds

Example:

__input.'2018-01-01 00:00:00'.__string_to_time.__time_to_epoch

Result:

1514764800000

Side Effect: None

Math

__math ::: Math Functions

Performs a set of math functions

Go: UDN_Math

Input: None

Args:

  1. string :: specify the math function called
  2. int/float :: Arguments for the math function (variadic)

Output: int/float :: result of the math function

Functions:

__math.input.arg0 (returns a int/float)
__math.sum.arg0.arg1 or __math.+.arg0.arg1 (returns arg0 + arg1)
__math.subtract.arg0.arg1 or __math.-.arg0.arg1 (returns arg0 - arg1)
__math.multiply.arg0.arg1 or __math.*.arg0.arg1 (returns arg0 * arg1)
__math.divide.arg0.arg1 or __math./.arg0.arg1 (returns arg0 / arg1)

Example:

__math.input.8

Result:

8 (int, not string "8" - __input.8 would return string "8")

Example 2:

__math.add.8.9

Result:

17

Example 3:

__math.multiply.'1.1'.'5.5'

Result:

6.05

Side Effect: None

Rendering

__widget ::: Execute UDN from String

All widgets are cached in memory, this just accesses that cache and returns the Widget string.

Go: UDN_Widget

Input: Ignored

Args:

  1. string :: Name of widget

Output: String

Example:

__widget.button

Result:

<button type="button" class="btn btn-{{index .Map "color"}}" onclick="{{index .Map "onclick"}}"><i class="{{index .Map "icon"}} position-left"></i> {{index .Map "value"}}</button>

Side Effect: Any

__render_data ::: Render Data Widget

Renders a Data Widget Instance. Performs all the operations needed to render a Data Widget Instance to a web page via an API call, or other accessing method.

Go: UDN_RenderDataWidgetInstance

Input: Ignored

Args:

  1. Integer :: web_data_widget_instance.id
  2. Map :: A map to update the "widget_instance" Global Data, to include external data in the rendering process

Output: String

Example:

__render_data.dialog_target.34.{control=(__get.param.data.__json_decode)}

Result:

...HTML/CSS/JS...

Side Effect: Any

Networking

__set_http_response ::: Set http response code

Sets the returning http response code

Go: UDN_SetHttpResponseCode

Input: None

Args:

  1. string :: the http code (string) to be returned

Output: Nothing. The request's http return code will be set

Example:

__set_http_response.404

Result:

Nothing

Side Effect: The request's http return code will be set

__http_request ::: Send http request

Sends a http request with a given method (POST|PUT|DELETE|GET) to a url endpoint.

Go: UDN_HttpRequest

Input: map or array of maps to be encoded in the request body sends alone with the POST, PUT, DELETE

Args:

  1. string :: request method, should be one of "POST","GET","DELETE","PUT"
  2. endpoint url :: the url that the request goes to
  3. (Optional) timeout seconds :: the seconds after which the request will be timeout. By default, is 10 secs

Output: if error occurrs, returns nothing. If a "GET" request, returns the decoded json(application/json) or text string(other content-type), otherwise returns the response status code.

Example:

__http_request.'GET'.'http://eventsum.infra.prod.wish.com/detail?event_id=3002'.'10'

Result:

{ "event_name": "AttributeError", "event_type": "python", "raw_data": ...}

Side Effect: None

Example:

__input.[{name=group1,info=group1_info}].__http_request.'POST'.'http://eventsum.infra.prod.wish.com/group'

Result:

201

Side Effect: If POST/PUT/DELETE request, will change the state on the target url.

User

__login ::: LDAP User Login

Authenticates against LDAP server

Go: UDN_Login

Input: Ignored

Args:

  1. String :: User name
  2. String :: Password

Output: String

Example:

__login.bob.pass

Result:

0tE44fJhc8Ne81jsILc6TuUZCkX

Side Effect: None

Special

__ddd_render ::: Render DDD Widget Editor Dialog

Returns HTML/CSS/JS necessary to render a dialog editing window for DDD spec data.

Go: UDN_RenderDataWidgetInstance

Input: Ignored

Args:

  1. String :: DOM Target ID
  2. Int64 :: web_data_widget_instance.id
  3. Map :: Widget Instance Update Map
  4. Map (optional):: UDN Update Map

Output: String

Example:

__ddd_render.'0'.0.0.0.(__get.temp.item.ddd_id).'temp.item.static_data_json'.(__get.temp.item.static_data_json).0

Result:

...HTML/CSS/JS...

Side Effect: None

Debugging

____debug_output ::: Debug Output Printing

Go: UDN_QueryById

Input: Any

Args: None

Output: Pass Through Input

Example:

__debug_output

Side Effect: Prints input to the debug log

Comments

__comments ::: UDN Comments

Go: UDN_Comment

Input: Any

Args: Any

Output: Pass Through Input

Example:

__comment.hello.this is a comment

Side Effect: None