@nyaruka/temba-components 0.129.7 → 0.129.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (269) hide show
  1. package/.devcontainer/Dockerfile +11 -4
  2. package/.devcontainer/devcontainer.json +3 -2
  3. package/.github/workflows/build.yml +4 -14
  4. package/CHANGELOG.md +29 -0
  5. package/demo/components/flow/example.html +1 -1
  6. package/demo/components/message-editor/example.html +125 -0
  7. package/demo/components/textinput/completion.html +1 -0
  8. package/demo/data/flows/food-order.json +12 -21
  9. package/demo/data/flows/sample-flow.json +210 -104
  10. package/dist/temba-components.js +715 -364
  11. package/dist/temba-components.js.map +1 -1
  12. package/out-tsc/src/display/Thumbnail.js +2 -1
  13. package/out-tsc/src/display/Thumbnail.js.map +1 -1
  14. package/out-tsc/src/events.js.map +1 -1
  15. package/out-tsc/src/excellent/helpers.js +2 -2
  16. package/out-tsc/src/excellent/helpers.js.map +1 -1
  17. package/out-tsc/src/flow/CanvasNode.js +25 -7
  18. package/out-tsc/src/flow/CanvasNode.js.map +1 -1
  19. package/out-tsc/src/flow/Editor.js +11 -1
  20. package/out-tsc/src/flow/Editor.js.map +1 -1
  21. package/out-tsc/src/flow/NodeEditor.js +342 -276
  22. package/out-tsc/src/flow/NodeEditor.js.map +1 -1
  23. package/out-tsc/src/flow/actions/add_input_labels.js +40 -0
  24. package/out-tsc/src/flow/actions/add_input_labels.js.map +1 -1
  25. package/out-tsc/src/flow/actions/call_llm.js +56 -3
  26. package/out-tsc/src/flow/actions/call_llm.js.map +1 -1
  27. package/out-tsc/src/flow/actions/call_webhook.js +26 -17
  28. package/out-tsc/src/flow/actions/call_webhook.js.map +1 -1
  29. package/out-tsc/src/flow/actions/open_ticket.js +65 -3
  30. package/out-tsc/src/flow/actions/open_ticket.js.map +1 -1
  31. package/out-tsc/src/flow/actions/send_msg.js +147 -6
  32. package/out-tsc/src/flow/actions/send_msg.js.map +1 -1
  33. package/out-tsc/src/flow/actions/set_run_result.js +75 -0
  34. package/out-tsc/src/flow/actions/set_run_result.js.map +1 -1
  35. package/out-tsc/src/flow/config.js +4 -0
  36. package/out-tsc/src/flow/config.js.map +1 -1
  37. package/out-tsc/src/flow/nodes/split_by_llm_categorize.js +227 -0
  38. package/out-tsc/src/flow/nodes/split_by_llm_categorize.js.map +1 -0
  39. package/out-tsc/src/flow/nodes/split_by_ticket.js +18 -0
  40. package/out-tsc/src/flow/nodes/split_by_ticket.js.map +1 -0
  41. package/out-tsc/src/flow/nodes/wait_for_response.js +27 -1
  42. package/out-tsc/src/flow/nodes/wait_for_response.js.map +1 -1
  43. package/out-tsc/src/flow/types.js +0 -65
  44. package/out-tsc/src/flow/types.js.map +1 -1
  45. package/out-tsc/src/form/ArrayEditor.js +87 -57
  46. package/out-tsc/src/form/ArrayEditor.js.map +1 -1
  47. package/out-tsc/src/form/BaseListEditor.js +19 -4
  48. package/out-tsc/src/form/BaseListEditor.js.map +1 -1
  49. package/out-tsc/src/form/FieldRenderer.js +305 -0
  50. package/out-tsc/src/form/FieldRenderer.js.map +1 -0
  51. package/out-tsc/src/form/FormField.js +4 -4
  52. package/out-tsc/src/form/FormField.js.map +1 -1
  53. package/out-tsc/src/form/KeyValueEditor.js +1 -1
  54. package/out-tsc/src/form/KeyValueEditor.js.map +1 -1
  55. package/out-tsc/src/form/MediaPicker.js +13 -1
  56. package/out-tsc/src/form/MediaPicker.js.map +1 -1
  57. package/out-tsc/src/form/MessageEditor.js +422 -0
  58. package/out-tsc/src/form/MessageEditor.js.map +1 -0
  59. package/out-tsc/src/form/TextInput.js +13 -6
  60. package/out-tsc/src/form/TextInput.js.map +1 -1
  61. package/out-tsc/src/form/select/Select.js +52 -24
  62. package/out-tsc/src/form/select/Select.js.map +1 -1
  63. package/out-tsc/src/live/ContactChat.js +66 -15
  64. package/out-tsc/src/live/ContactChat.js.map +1 -1
  65. package/out-tsc/src/markdown.js +13 -11
  66. package/out-tsc/src/markdown.js.map +1 -1
  67. package/out-tsc/temba-modules.js +2 -0
  68. package/out-tsc/temba-modules.js.map +1 -1
  69. package/out-tsc/test/ActionHelper.js +2 -0
  70. package/out-tsc/test/ActionHelper.js.map +1 -1
  71. package/out-tsc/test/NodeHelper.js +148 -0
  72. package/out-tsc/test/NodeHelper.js.map +1 -0
  73. package/out-tsc/test/actions/call_llm.test.js +103 -0
  74. package/out-tsc/test/actions/call_llm.test.js.map +1 -0
  75. package/out-tsc/test/nodes/split_by_llm_categorize.test.js +532 -0
  76. package/out-tsc/test/nodes/split_by_llm_categorize.test.js.map +1 -0
  77. package/out-tsc/test/nodes/split_by_random.test.js +150 -0
  78. package/out-tsc/test/nodes/split_by_random.test.js.map +1 -0
  79. package/out-tsc/test/nodes/wait_for_digits.test.js +150 -0
  80. package/out-tsc/test/nodes/wait_for_digits.test.js.map +1 -0
  81. package/out-tsc/test/nodes/wait_for_response.test.js +171 -0
  82. package/out-tsc/test/nodes/wait_for_response.test.js.map +1 -0
  83. package/out-tsc/test/temba-add-input-labels.test.js +70 -0
  84. package/out-tsc/test/temba-add-input-labels.test.js.map +1 -0
  85. package/out-tsc/test/temba-field-config.test.js +4 -2
  86. package/out-tsc/test/temba-field-config.test.js.map +1 -1
  87. package/out-tsc/test/temba-field-renderer.test.js +296 -0
  88. package/out-tsc/test/temba-field-renderer.test.js.map +1 -0
  89. package/out-tsc/test/temba-markdown.test.js +1 -1
  90. package/out-tsc/test/temba-markdown.test.js.map +1 -1
  91. package/out-tsc/test/temba-message-editor.test.js +194 -0
  92. package/out-tsc/test/temba-message-editor.test.js.map +1 -0
  93. package/out-tsc/test/temba-node-editor.test.js +471 -0
  94. package/out-tsc/test/temba-node-editor.test.js.map +1 -1
  95. package/out-tsc/test/temba-select.test.js +7 -4
  96. package/out-tsc/test/temba-select.test.js.map +1 -1
  97. package/out-tsc/test/temba-textinput.test.js +16 -0
  98. package/out-tsc/test/temba-textinput.test.js.map +1 -1
  99. package/out-tsc/test/temba-webchat.test.js +5 -1
  100. package/out-tsc/test/temba-webchat.test.js.map +1 -1
  101. package/out-tsc/test/utils.test.js +2 -8
  102. package/out-tsc/test/utils.test.js.map +1 -1
  103. package/package.json +7 -4
  104. package/screenshots/truth/actions/add_contact_groups/editor/descriptive-group-names.png +0 -0
  105. package/screenshots/truth/actions/add_contact_groups/editor/long-group-names.png +0 -0
  106. package/screenshots/truth/actions/add_contact_groups/editor/many-groups.png +0 -0
  107. package/screenshots/truth/actions/add_contact_groups/editor/multiple-groups.png +0 -0
  108. package/screenshots/truth/actions/add_contact_groups/editor/single-group.png +0 -0
  109. package/screenshots/truth/actions/call_llm/editor/information-extraction.png +0 -0
  110. package/screenshots/truth/actions/call_llm/editor/sentiment-analysis.png +0 -0
  111. package/screenshots/truth/actions/call_llm/editor/summarization.png +0 -0
  112. package/screenshots/truth/actions/call_llm/editor/translation-task.png +0 -0
  113. package/screenshots/truth/actions/call_llm/render/information-extraction.png +0 -0
  114. package/screenshots/truth/actions/call_llm/render/sentiment-analysis.png +0 -0
  115. package/screenshots/truth/actions/call_llm/render/summarization.png +0 -0
  116. package/screenshots/truth/actions/call_llm/render/translation-task.png +0 -0
  117. package/screenshots/truth/actions/remove_contact_groups/editor/cleanup-groups.png +0 -0
  118. package/screenshots/truth/actions/remove_contact_groups/editor/long-descriptive-group-names.png +0 -0
  119. package/screenshots/truth/actions/remove_contact_groups/editor/many-groups.png +0 -0
  120. package/screenshots/truth/actions/remove_contact_groups/editor/multiple-groups.png +0 -0
  121. package/screenshots/truth/actions/remove_contact_groups/editor/remove-from-all-groups.png +0 -0
  122. package/screenshots/truth/actions/remove_contact_groups/editor/single-group.png +0 -0
  123. package/screenshots/truth/actions/send_email/editor/complex-business-email.png +0 -0
  124. package/screenshots/truth/actions/send_email/editor/empty-body.png +0 -0
  125. package/screenshots/truth/actions/send_email/editor/empty-subject.png +0 -0
  126. package/screenshots/truth/actions/send_email/editor/long-subject.png +0 -0
  127. package/screenshots/truth/actions/send_email/editor/multiline-body.png +0 -0
  128. package/screenshots/truth/actions/send_email/editor/multiple-recipients.png +0 -0
  129. package/screenshots/truth/actions/send_email/editor/simple-email.png +0 -0
  130. package/screenshots/truth/actions/send_email/editor/with-expressions.png +0 -0
  131. package/screenshots/truth/actions/send_msg/editor/long-quick-replies.png +0 -0
  132. package/screenshots/truth/actions/send_msg/editor/multiline-text-with-replies.png +0 -0
  133. package/screenshots/truth/actions/send_msg/editor/simple-text.png +0 -0
  134. package/screenshots/truth/actions/send_msg/editor/text-with-linebreaks.png +0 -0
  135. package/screenshots/truth/actions/send_msg/editor/text-with-many-quick-replies.png +0 -0
  136. package/screenshots/truth/actions/send_msg/editor/text-with-quick-replies.png +0 -0
  137. package/screenshots/truth/actions/send_msg/editor/text-without-quick-replies.png +0 -0
  138. package/screenshots/truth/editor/router.png +0 -0
  139. package/screenshots/truth/editor/send_msg.png +0 -0
  140. package/screenshots/truth/editor/set_contact_language.png +0 -0
  141. package/screenshots/truth/editor/set_contact_name.png +0 -0
  142. package/screenshots/truth/editor/set_run_result.png +0 -0
  143. package/screenshots/truth/editor/wait.png +0 -0
  144. package/screenshots/truth/field-renderer/checkbox-checked.png +0 -0
  145. package/screenshots/truth/field-renderer/checkbox-unchecked.png +0 -0
  146. package/screenshots/truth/field-renderer/checkbox-with-errors.png +0 -0
  147. package/screenshots/truth/field-renderer/context-comparison.png +0 -0
  148. package/screenshots/truth/field-renderer/key-value-with-label.png +0 -0
  149. package/screenshots/truth/field-renderer/message-editor-with-label.png +0 -0
  150. package/screenshots/truth/field-renderer/select-multi.png +0 -0
  151. package/screenshots/truth/field-renderer/select-no-label.png +0 -0
  152. package/screenshots/truth/field-renderer/select-with-label.png +0 -0
  153. package/screenshots/truth/field-renderer/text-evaluated.png +0 -0
  154. package/screenshots/truth/field-renderer/text-no-label.png +0 -0
  155. package/screenshots/truth/field-renderer/text-with-errors.png +0 -0
  156. package/screenshots/truth/field-renderer/text-with-label.png +0 -0
  157. package/screenshots/truth/field-renderer/textarea-evaluated.png +0 -0
  158. package/screenshots/truth/field-renderer/textarea-with-label.png +0 -0
  159. package/screenshots/truth/formfield/markdown-errors.png +0 -0
  160. package/screenshots/truth/formfield/no-errors.png +0 -0
  161. package/screenshots/truth/formfield/plain-text-errors.png +0 -0
  162. package/screenshots/truth/message-editor/autogrow-initial-content.png +0 -0
  163. package/screenshots/truth/message-editor/default.png +0 -0
  164. package/screenshots/truth/message-editor/drag-highlight.png +0 -0
  165. package/screenshots/truth/message-editor/filtered-attachments.png +0 -0
  166. package/screenshots/truth/message-editor/with-completion.png +0 -0
  167. package/screenshots/truth/message-editor/with-properties.png +0 -0
  168. package/screenshots/truth/nodes/split_by_llm_categorize/editor/basic-categorization.png +0 -0
  169. package/screenshots/truth/nodes/split_by_llm_categorize/editor/custom-input-and-result-name.png +0 -0
  170. package/screenshots/truth/nodes/split_by_llm_categorize/editor/feedback-categorization.png +0 -0
  171. package/screenshots/truth/nodes/split_by_llm_categorize/editor/many-categories.png +0 -0
  172. package/screenshots/truth/nodes/split_by_llm_categorize/editor/minimal-categories.png +0 -0
  173. package/screenshots/truth/nodes/split_by_llm_categorize/render/basic-categorization.png +0 -0
  174. package/screenshots/truth/nodes/split_by_llm_categorize/render/custom-input-and-result-name.png +0 -0
  175. package/screenshots/truth/nodes/split_by_llm_categorize/render/feedback-categorization.png +0 -0
  176. package/screenshots/truth/nodes/split_by_llm_categorize/render/many-categories.png +0 -0
  177. package/screenshots/truth/nodes/split_by_llm_categorize/render/minimal-categories.png +0 -0
  178. package/screenshots/truth/nodes/split_by_random/editor/ab-test-multiple-variants.png +0 -0
  179. package/screenshots/truth/nodes/split_by_random/editor/sampling-split.png +0 -0
  180. package/screenshots/truth/nodes/split_by_random/editor/three-way-split.png +0 -0
  181. package/screenshots/truth/nodes/split_by_random/editor/two-bucket-split.png +0 -0
  182. package/screenshots/truth/nodes/split_by_random/render/ab-test-multiple-variants.png +0 -0
  183. package/screenshots/truth/nodes/split_by_random/render/sampling-split.png +0 -0
  184. package/screenshots/truth/nodes/split_by_random/render/three-way-split.png +0 -0
  185. package/screenshots/truth/nodes/split_by_random/render/two-bucket-split.png +0 -0
  186. package/screenshots/truth/nodes/wait_for_digits/editor/basic-digits-wait.png +0 -0
  187. package/screenshots/truth/nodes/wait_for_digits/editor/phone-number-collection.png +0 -0
  188. package/screenshots/truth/nodes/wait_for_digits/editor/single-digit-with-timeout.png +0 -0
  189. package/screenshots/truth/nodes/wait_for_digits/editor/verification-code.png +0 -0
  190. package/screenshots/truth/nodes/wait_for_digits/render/basic-digits-wait.png +0 -0
  191. package/screenshots/truth/nodes/wait_for_digits/render/phone-number-collection.png +0 -0
  192. package/screenshots/truth/nodes/wait_for_digits/render/single-digit-with-timeout.png +0 -0
  193. package/screenshots/truth/nodes/wait_for_digits/render/verification-code.png +0 -0
  194. package/screenshots/truth/nodes/wait_for_response/editor/basic-wait.png +0 -0
  195. package/screenshots/truth/nodes/wait_for_response/editor/custom-result-name.png +0 -0
  196. package/screenshots/truth/nodes/wait_for_response/editor/no-timeout.png +0 -0
  197. package/screenshots/truth/nodes/wait_for_response/editor/short-timeout.png +0 -0
  198. package/screenshots/truth/nodes/wait_for_response/render/basic-wait.png +0 -0
  199. package/screenshots/truth/nodes/wait_for_response/render/custom-result-name.png +0 -0
  200. package/screenshots/truth/nodes/wait_for_response/render/no-timeout.png +0 -0
  201. package/screenshots/truth/nodes/wait_for_response/render/short-timeout.png +0 -0
  202. package/screenshots/truth/omnibox/selected.png +0 -0
  203. package/screenshots/truth/select/functions.png +0 -0
  204. package/screenshots/truth/select/multi-with-endpoint.png +0 -0
  205. package/screenshots/truth/select/search-enabled.png +0 -0
  206. package/screenshots/truth/textinput/autogrow-initial.png +0 -0
  207. package/screenshots/truth/textinput/input-form.png +0 -0
  208. package/src/display/Thumbnail.ts +2 -1
  209. package/src/events.ts +13 -1
  210. package/src/excellent/helpers.ts +2 -2
  211. package/src/flow/CanvasNode.ts +22 -1
  212. package/src/flow/Editor.ts +12 -1
  213. package/src/flow/NodeEditor.ts +412 -354
  214. package/src/flow/actions/add_input_labels.ts +45 -0
  215. package/src/flow/actions/call_llm.ts +57 -3
  216. package/src/flow/actions/call_webhook.ts +28 -18
  217. package/src/flow/actions/open_ticket.ts +74 -3
  218. package/src/flow/actions/send_msg.ts +170 -6
  219. package/src/flow/actions/set_run_result.ts +83 -0
  220. package/src/flow/config.ts +4 -0
  221. package/src/flow/nodes/split_by_llm_categorize.ts +277 -0
  222. package/src/flow/nodes/split_by_ticket.ts +19 -0
  223. package/src/flow/nodes/wait_for_response.ts +28 -1
  224. package/src/flow/types.ts +46 -128
  225. package/src/form/ArrayEditor.ts +96 -66
  226. package/src/form/BaseListEditor.ts +22 -6
  227. package/src/form/FieldRenderer.ts +465 -0
  228. package/src/form/FormField.ts +4 -4
  229. package/src/form/KeyValueEditor.ts +1 -1
  230. package/src/form/MediaPicker.ts +13 -1
  231. package/src/form/MessageEditor.ts +449 -0
  232. package/src/form/TextInput.ts +16 -8
  233. package/src/form/select/Select.ts +55 -24
  234. package/src/live/ContactChat.ts +69 -19
  235. package/src/markdown.ts +19 -11
  236. package/src/store/flow-definition.d.ts +5 -2
  237. package/static/api/labels.json +31 -0
  238. package/static/api/topics.json +24 -9
  239. package/static/api/users.json +35 -16
  240. package/static/css/temba-components.css +5 -3
  241. package/static/mr/docs/en-us/editor.json +2588 -0
  242. package/stress-test.js +143 -0
  243. package/temba-modules.ts +2 -0
  244. package/test/ActionHelper.ts +2 -0
  245. package/test/NodeHelper.ts +184 -0
  246. package/test/actions/call_llm.test.ts +137 -0
  247. package/test/nodes/README.md +78 -0
  248. package/test/nodes/split_by_llm_categorize.test.ts +698 -0
  249. package/test/nodes/split_by_random.test.ts +177 -0
  250. package/test/nodes/wait_for_digits.test.ts +176 -0
  251. package/test/nodes/wait_for_response.test.ts +206 -0
  252. package/test/temba-add-input-labels.test.ts +87 -0
  253. package/test/temba-field-config.test.ts +4 -2
  254. package/test/temba-field-renderer.test.ts +482 -0
  255. package/test/temba-markdown.test.ts +1 -1
  256. package/test/temba-message-editor.test.ts +300 -0
  257. package/test/temba-node-editor.test.ts +590 -0
  258. package/test/temba-select.test.ts +7 -7
  259. package/test/temba-textinput.test.ts +26 -0
  260. package/test/temba-webchat.test.ts +6 -1
  261. package/test/utils.test.ts +2 -13
  262. package/test-assets/contacts/history.json +19 -0
  263. package/test-assets/select/llms.json +18 -0
  264. package/test-assets/style.css +2 -0
  265. package/web-dev-mock.mjs +523 -0
  266. package/web-dev-server.config.mjs +74 -6
  267. package/web-test-runner.config.mjs +9 -4
  268. package/test/temba-flow-editor.test.ts.backup +0 -563
  269. package/test/temba-utils-index.test.ts.backup +0 -1737
@@ -0,0 +1,2588 @@
1
+ {
2
+ "context": {
3
+ "types": [
4
+ {
5
+ "name": "fields",
6
+ "key_source": "fields",
7
+ "property_template": {
8
+ "key": "{key}",
9
+ "help": "{key} for the contact",
10
+ "type": "any"
11
+ }
12
+ },
13
+ {
14
+ "name": "locals",
15
+ "key_source": "locals",
16
+ "property_template": {
17
+ "key": "{key}",
18
+ "help": "the local variable {key}",
19
+ "type": "any"
20
+ }
21
+ },
22
+ {
23
+ "name": "results",
24
+ "key_source": "results",
25
+ "property_template": {
26
+ "key": "{key}",
27
+ "help": "the result for {key}",
28
+ "type": "result"
29
+ }
30
+ },
31
+ {
32
+ "name": "globals",
33
+ "key_source": "globals",
34
+ "property_template": {
35
+ "key": "{key}",
36
+ "help": "the global value {key}",
37
+ "type": "text"
38
+ }
39
+ },
40
+ {
41
+ "name": "urns",
42
+ "properties": [
43
+ {
44
+ "key": "discord",
45
+ "help": "Discord URN for the contact",
46
+ "type": "text"
47
+ },
48
+ {
49
+ "key": "ext",
50
+ "help": "External URN for the contact",
51
+ "type": "text"
52
+ },
53
+ {
54
+ "key": "facebook",
55
+ "help": "Facebook URN for the contact",
56
+ "type": "text"
57
+ },
58
+ {
59
+ "key": "fcm",
60
+ "help": "Firebase URN for the contact",
61
+ "type": "text"
62
+ },
63
+ {
64
+ "key": "freshchat",
65
+ "help": "FreshChat URN for the contact",
66
+ "type": "text"
67
+ },
68
+ {
69
+ "key": "instagram",
70
+ "help": "Instagram URN for the contact",
71
+ "type": "text"
72
+ },
73
+ {
74
+ "key": "jiochat",
75
+ "help": "JioChat URN for the contact",
76
+ "type": "text"
77
+ },
78
+ {
79
+ "key": "line",
80
+ "help": "LINE URN for the contact",
81
+ "type": "text"
82
+ },
83
+ {
84
+ "key": "mailto",
85
+ "help": "Email URN for the contact",
86
+ "type": "text"
87
+ },
88
+ {
89
+ "key": "rocketchat",
90
+ "help": "Rocket.Chat URN for the contact",
91
+ "type": "text"
92
+ },
93
+ {
94
+ "key": "slack",
95
+ "help": "Slack URN for the contact",
96
+ "type": "text"
97
+ },
98
+ {
99
+ "key": "tel",
100
+ "help": "Phone URN for the contact",
101
+ "type": "text"
102
+ },
103
+ {
104
+ "key": "telegram",
105
+ "help": "Telegram URN for the contact",
106
+ "type": "text"
107
+ },
108
+ {
109
+ "key": "twitter",
110
+ "help": "Twitter Handle URN for the contact",
111
+ "type": "text"
112
+ },
113
+ {
114
+ "key": "twitterid",
115
+ "help": "Twitter URN for the contact",
116
+ "type": "text"
117
+ },
118
+ {
119
+ "key": "viber",
120
+ "help": "Viber URN for the contact",
121
+ "type": "text"
122
+ },
123
+ {
124
+ "key": "vk",
125
+ "help": "VK URN for the contact",
126
+ "type": "text"
127
+ },
128
+ {
129
+ "key": "webchat",
130
+ "help": "WebChat URN for the contact",
131
+ "type": "text"
132
+ },
133
+ {
134
+ "key": "wechat",
135
+ "help": "WeChat URN for the contact",
136
+ "type": "text"
137
+ },
138
+ {
139
+ "key": "whatsapp",
140
+ "help": "WhatsApp URN for the contact",
141
+ "type": "text"
142
+ }
143
+ ]
144
+ },
145
+ {
146
+ "name": "campaign",
147
+ "properties": [
148
+ {
149
+ "key": "uuid",
150
+ "help": "the UUID of the campaign",
151
+ "type": "text"
152
+ },
153
+ {
154
+ "key": "name",
155
+ "help": "the name of the campaign",
156
+ "type": "text"
157
+ }
158
+ ]
159
+ },
160
+ {
161
+ "name": "channel",
162
+ "properties": [
163
+ {
164
+ "key": "__default__",
165
+ "help": "the name",
166
+ "type": "text"
167
+ },
168
+ {
169
+ "key": "uuid",
170
+ "help": "the UUID of the channel",
171
+ "type": "text"
172
+ },
173
+ {
174
+ "key": "name",
175
+ "help": "the name of the channel",
176
+ "type": "text"
177
+ },
178
+ {
179
+ "key": "address",
180
+ "help": "the address of the channel",
181
+ "type": "text"
182
+ }
183
+ ]
184
+ },
185
+ {
186
+ "name": "contact",
187
+ "properties": [
188
+ {
189
+ "key": "__default__",
190
+ "help": "the name or URN",
191
+ "type": "text"
192
+ },
193
+ {
194
+ "key": "uuid",
195
+ "help": "the UUID of the contact",
196
+ "type": "text"
197
+ },
198
+ {
199
+ "key": "id",
200
+ "help": "the numeric ID of the contact",
201
+ "type": "text"
202
+ },
203
+ {
204
+ "key": "first_name",
205
+ "help": "the first name of the contact",
206
+ "type": "text"
207
+ },
208
+ {
209
+ "key": "name",
210
+ "help": "the name of the contact",
211
+ "type": "text"
212
+ },
213
+ {
214
+ "key": "language",
215
+ "help": "the language of the contact as 3-letter ISO code",
216
+ "type": "text"
217
+ },
218
+ {
219
+ "key": "status",
220
+ "help": "the status of the contact",
221
+ "type": "text"
222
+ },
223
+ {
224
+ "key": "created_on",
225
+ "help": "the creation date of the contact",
226
+ "type": "datetime"
227
+ },
228
+ {
229
+ "key": "last_seen_on",
230
+ "help": "the last seen date of the contact",
231
+ "type": "any"
232
+ },
233
+ {
234
+ "key": "urns",
235
+ "help": "the URNs belonging to the contact",
236
+ "type": "text",
237
+ "array": true
238
+ },
239
+ {
240
+ "key": "urn",
241
+ "help": "the preferred URN of the contact",
242
+ "type": "text"
243
+ },
244
+ {
245
+ "key": "groups",
246
+ "help": "the groups the contact belongs to",
247
+ "type": "group",
248
+ "array": true
249
+ },
250
+ {
251
+ "key": "fields",
252
+ "help": "the custom field values of the contact",
253
+ "type": "fields"
254
+ },
255
+ {
256
+ "key": "channel",
257
+ "help": "the preferred channel of the contact",
258
+ "type": "channel"
259
+ }
260
+ ]
261
+ },
262
+ {
263
+ "name": "flow",
264
+ "properties": [
265
+ {
266
+ "key": "__default__",
267
+ "help": "the name",
268
+ "type": "text"
269
+ },
270
+ {
271
+ "key": "uuid",
272
+ "help": "the UUID of the flow",
273
+ "type": "text"
274
+ },
275
+ {
276
+ "key": "name",
277
+ "help": "the name of the flow",
278
+ "type": "text"
279
+ },
280
+ {
281
+ "key": "revision",
282
+ "help": "the revision number of the flow",
283
+ "type": "text"
284
+ }
285
+ ]
286
+ },
287
+ {
288
+ "name": "group",
289
+ "properties": [
290
+ {
291
+ "key": "uuid",
292
+ "help": "the UUID of the group",
293
+ "type": "text"
294
+ },
295
+ {
296
+ "key": "name",
297
+ "help": "the name of the group",
298
+ "type": "text"
299
+ }
300
+ ]
301
+ },
302
+ {
303
+ "name": "input",
304
+ "properties": [
305
+ {
306
+ "key": "__default__",
307
+ "help": "the text and attachments",
308
+ "type": "text"
309
+ },
310
+ {
311
+ "key": "uuid",
312
+ "help": "the UUID of the input",
313
+ "type": "text"
314
+ },
315
+ {
316
+ "key": "created_on",
317
+ "help": "the creation date of the input",
318
+ "type": "datetime"
319
+ },
320
+ {
321
+ "key": "channel",
322
+ "help": "the channel that the input was received on",
323
+ "type": "channel"
324
+ },
325
+ {
326
+ "key": "urn",
327
+ "help": "the contact URN that the input was received on",
328
+ "type": "text"
329
+ },
330
+ {
331
+ "key": "text",
332
+ "help": "the text part of the input",
333
+ "type": "text"
334
+ },
335
+ {
336
+ "key": "attachments",
337
+ "help": "any attachments on the input",
338
+ "type": "text",
339
+ "array": true
340
+ },
341
+ {
342
+ "key": "external_id",
343
+ "help": "the external ID of the input",
344
+ "type": "text"
345
+ }
346
+ ]
347
+ },
348
+ {
349
+ "name": "node",
350
+ "properties": [
351
+ {
352
+ "key": "uuid",
353
+ "help": "the UUID of the node",
354
+ "type": "text"
355
+ },
356
+ {
357
+ "key": "categories",
358
+ "help": "the category names of the node",
359
+ "type": "text",
360
+ "array": true
361
+ },
362
+ {
363
+ "key": "visit_count",
364
+ "help": "the count of visits to the node in this run",
365
+ "type": "number"
366
+ }
367
+ ]
368
+ },
369
+ {
370
+ "name": "optin",
371
+ "properties": [
372
+ {
373
+ "key": "uuid",
374
+ "help": "the UUID of the optin",
375
+ "type": "text"
376
+ },
377
+ {
378
+ "key": "name",
379
+ "help": "the name of the optin",
380
+ "type": "text"
381
+ }
382
+ ]
383
+ },
384
+ {
385
+ "name": "related_run",
386
+ "properties": [
387
+ {
388
+ "key": "__default__",
389
+ "help": "the contact name and flow UUID",
390
+ "type": "text"
391
+ },
392
+ {
393
+ "key": "uuid",
394
+ "help": "the UUID of the run",
395
+ "type": "text"
396
+ },
397
+ {
398
+ "key": "contact",
399
+ "help": "the contact of the run",
400
+ "type": "contact"
401
+ },
402
+ {
403
+ "key": "flow",
404
+ "help": "the flow of the run",
405
+ "type": "flow"
406
+ },
407
+ {
408
+ "key": "fields",
409
+ "help": "the custom field values of the run",
410
+ "type": "fields"
411
+ },
412
+ {
413
+ "key": "urns",
414
+ "help": "the URN values of the run",
415
+ "type": "urns"
416
+ },
417
+ {
418
+ "key": "results",
419
+ "help": "the results saved by the run",
420
+ "type": "any"
421
+ },
422
+ {
423
+ "key": "status",
424
+ "help": "the current status of the run",
425
+ "type": "text"
426
+ }
427
+ ]
428
+ },
429
+ {
430
+ "name": "result",
431
+ "properties": [
432
+ {
433
+ "key": "__default__",
434
+ "help": "the value",
435
+ "type": "text"
436
+ },
437
+ {
438
+ "key": "name",
439
+ "help": "the name of the result",
440
+ "type": "text"
441
+ },
442
+ {
443
+ "key": "value",
444
+ "help": "the value of the result",
445
+ "type": "text"
446
+ },
447
+ {
448
+ "key": "category",
449
+ "help": "the category of the result",
450
+ "type": "text"
451
+ },
452
+ {
453
+ "key": "category_localized",
454
+ "help": "the localized category of the result",
455
+ "type": "text"
456
+ },
457
+ {
458
+ "key": "input",
459
+ "help": "the input of the result",
460
+ "type": "text"
461
+ },
462
+ {
463
+ "key": "node_uuid",
464
+ "help": "the UUID of the node in the flow that generated the result",
465
+ "type": "text"
466
+ },
467
+ {
468
+ "key": "created_on",
469
+ "help": "the creation date of the result",
470
+ "type": "datetime"
471
+ }
472
+ ]
473
+ },
474
+ {
475
+ "name": "resume",
476
+ "properties": [
477
+ {
478
+ "key": "type",
479
+ "help": "the type of resume that resumed this session",
480
+ "type": "text"
481
+ }
482
+ ]
483
+ },
484
+ {
485
+ "name": "run",
486
+ "properties": [
487
+ {
488
+ "key": "__default__",
489
+ "help": "the contact name and flow UUID",
490
+ "type": "text"
491
+ },
492
+ {
493
+ "key": "uuid",
494
+ "help": "the UUID of the run",
495
+ "type": "text"
496
+ },
497
+ {
498
+ "key": "contact",
499
+ "help": "the contact of the run",
500
+ "type": "contact"
501
+ },
502
+ {
503
+ "key": "flow",
504
+ "help": "the flow of the run",
505
+ "type": "flow"
506
+ },
507
+ {
508
+ "key": "status",
509
+ "help": "the status of the run",
510
+ "type": "text"
511
+ },
512
+ {
513
+ "key": "locals",
514
+ "help": "the local variables of the run",
515
+ "type": "locals"
516
+ },
517
+ {
518
+ "key": "results",
519
+ "help": "the results saved by the run",
520
+ "type": "results"
521
+ },
522
+ {
523
+ "key": "created_on",
524
+ "help": "the creation date of the run",
525
+ "type": "datetime"
526
+ },
527
+ {
528
+ "key": "exited_on",
529
+ "help": "the exit date of the run",
530
+ "type": "datetime"
531
+ }
532
+ ]
533
+ },
534
+ {
535
+ "name": "ticket",
536
+ "properties": [
537
+ {
538
+ "key": "uuid",
539
+ "help": "the UUID of the ticket",
540
+ "type": "text"
541
+ },
542
+ {
543
+ "key": "topic",
544
+ "help": "the topic of the ticket",
545
+ "type": "any"
546
+ },
547
+ {
548
+ "key": "assignee",
549
+ "help": "the assignee of the ticket",
550
+ "type": "any"
551
+ }
552
+ ]
553
+ },
554
+ {
555
+ "name": "topic",
556
+ "properties": [
557
+ {
558
+ "key": "__default__",
559
+ "help": "the name",
560
+ "type": "text"
561
+ },
562
+ {
563
+ "key": "uuid",
564
+ "help": "the UUID of the topic",
565
+ "type": "text"
566
+ },
567
+ {
568
+ "key": "name",
569
+ "help": "the name of the topic",
570
+ "type": "text"
571
+ }
572
+ ]
573
+ },
574
+ {
575
+ "name": "trigger",
576
+ "properties": [
577
+ {
578
+ "key": "type",
579
+ "help": "the type of trigger that started this session",
580
+ "type": "text"
581
+ },
582
+ {
583
+ "key": "params",
584
+ "help": "the parameters passed to the trigger",
585
+ "type": "any"
586
+ },
587
+ {
588
+ "key": "keyword",
589
+ "help": "the keyword match if this is a keyword trigger",
590
+ "type": "text"
591
+ },
592
+ {
593
+ "key": "user",
594
+ "help": "the user who started this session if this is a manual trigger",
595
+ "type": "user"
596
+ },
597
+ {
598
+ "key": "origin",
599
+ "help": "the origin of this session if this is a manual trigger",
600
+ "type": "text"
601
+ },
602
+ {
603
+ "key": "ticket",
604
+ "help": "the ticket if this is a ticket trigger",
605
+ "type": "ticket"
606
+ }
607
+ ]
608
+ },
609
+ {
610
+ "name": "user",
611
+ "properties": [
612
+ {
613
+ "key": "__default__",
614
+ "help": "the name or email",
615
+ "type": "text"
616
+ },
617
+ {
618
+ "key": "email",
619
+ "help": "the email address of the user",
620
+ "type": "text"
621
+ },
622
+ {
623
+ "key": "name",
624
+ "help": "the name of the user",
625
+ "type": "text"
626
+ },
627
+ {
628
+ "key": "first_name",
629
+ "help": "the first name of the user",
630
+ "type": "text"
631
+ }
632
+ ]
633
+ },
634
+ {
635
+ "name": "webhook",
636
+ "properties": [
637
+ {
638
+ "key": "__default__",
639
+ "help": "the method and URL",
640
+ "type": "text"
641
+ },
642
+ {
643
+ "key": "status",
644
+ "help": "the response status code",
645
+ "type": "number"
646
+ },
647
+ {
648
+ "key": "headers",
649
+ "help": "the response headers",
650
+ "type": "any"
651
+ },
652
+ {
653
+ "key": "json",
654
+ "help": "the response body if valid JSON",
655
+ "type": "any"
656
+ }
657
+ ]
658
+ }
659
+ ],
660
+ "root": [
661
+ {
662
+ "key": "contact",
663
+ "help": "the contact",
664
+ "type": "contact"
665
+ },
666
+ {
667
+ "key": "fields",
668
+ "help": "the custom field values of the contact",
669
+ "type": "fields"
670
+ },
671
+ {
672
+ "key": "urns",
673
+ "help": "the URN values of the contact",
674
+ "type": "urns"
675
+ },
676
+ {
677
+ "key": "locals",
678
+ "help": "the current run local variables",
679
+ "type": "locals"
680
+ },
681
+ {
682
+ "key": "results",
683
+ "help": "the current run results",
684
+ "type": "results"
685
+ },
686
+ {
687
+ "key": "input",
688
+ "help": "the current input from the contact",
689
+ "type": "input"
690
+ },
691
+ {
692
+ "key": "run",
693
+ "help": "the current run",
694
+ "type": "run"
695
+ },
696
+ {
697
+ "key": "child",
698
+ "help": "the last child run",
699
+ "type": "related_run"
700
+ },
701
+ {
702
+ "key": "parent",
703
+ "help": "the parent of the run",
704
+ "type": "related_run"
705
+ },
706
+ {
707
+ "key": "ticket",
708
+ "help": "the open ticket for the contact",
709
+ "type": "ticket"
710
+ },
711
+ {
712
+ "key": "webhook",
713
+ "help": "the last webhook call ",
714
+ "type": "webhook"
715
+ },
716
+ {
717
+ "key": "node",
718
+ "help": "the current node",
719
+ "type": "node"
720
+ },
721
+ {
722
+ "key": "globals",
723
+ "help": "the global values",
724
+ "type": "globals"
725
+ },
726
+ {
727
+ "key": "trigger",
728
+ "help": "the trigger that started this session",
729
+ "type": "trigger"
730
+ },
731
+ {
732
+ "key": "resume",
733
+ "help": "the current resume that continued this session",
734
+ "type": "resume"
735
+ }
736
+ ],
737
+ "root_no_session": [
738
+ {
739
+ "key": "contact",
740
+ "help": "the contact",
741
+ "type": "contact"
742
+ },
743
+ {
744
+ "key": "fields",
745
+ "help": "the custom field values of the contact",
746
+ "type": "fields"
747
+ },
748
+ {
749
+ "key": "urns",
750
+ "help": "the URN values of the contact",
751
+ "type": "urns"
752
+ },
753
+ {
754
+ "key": "globals",
755
+ "help": "the global values",
756
+ "type": "globals"
757
+ }
758
+ ]
759
+ },
760
+ "functions": [
761
+ {
762
+ "signature": "abs(number)",
763
+ "summary": "Returns the absolute value of `number`.",
764
+ "detail": "",
765
+ "examples": [
766
+ {
767
+ "template": "@(abs(-10))",
768
+ "output": "10"
769
+ },
770
+ {
771
+ "template": "@(abs(10.5))",
772
+ "output": "10.5"
773
+ },
774
+ {
775
+ "template": "@(abs(\"foo\"))",
776
+ "output": "ERROR"
777
+ }
778
+ ]
779
+ },
780
+ {
781
+ "signature": "and(values...)",
782
+ "summary": "Returns whether all the given `values` are truthy.",
783
+ "detail": "",
784
+ "examples": [
785
+ {
786
+ "template": "@(and(true))",
787
+ "output": "true"
788
+ },
789
+ {
790
+ "template": "@(and(true, false, true))",
791
+ "output": "false"
792
+ }
793
+ ]
794
+ },
795
+ {
796
+ "signature": "array(values...)",
797
+ "summary": "Takes multiple `values` and returns them as an array.",
798
+ "detail": "",
799
+ "examples": [
800
+ {
801
+ "template": "@(array(\"a\", \"b\", 356)[1])",
802
+ "output": "b"
803
+ },
804
+ {
805
+ "template": "@(join(array(\"a\", \"b\", \"c\"), \"|\"))",
806
+ "output": "a|b|c"
807
+ },
808
+ {
809
+ "template": "@(count(array()))",
810
+ "output": "0"
811
+ },
812
+ {
813
+ "template": "@(count(array(\"a\", \"b\")))",
814
+ "output": "2"
815
+ }
816
+ ]
817
+ },
818
+ {
819
+ "signature": "attachment_parts(attachment)",
820
+ "summary": "Parses an attachment into its different parts",
821
+ "detail": "",
822
+ "examples": [
823
+ {
824
+ "template": "@(attachment_parts(\"image/jpeg:https://example.com/test.jpg\"))",
825
+ "output": "{content_type: image/jpeg, url: https://example.com/test.jpg}"
826
+ }
827
+ ]
828
+ },
829
+ {
830
+ "signature": "boolean(value)",
831
+ "summary": "Tries to convert `value` to a boolean.",
832
+ "detail": "An error is returned if the value can't be converted.",
833
+ "examples": [
834
+ {
835
+ "template": "@(boolean(array(1, 2)))",
836
+ "output": "true"
837
+ },
838
+ {
839
+ "template": "@(boolean(\"FALSE\"))",
840
+ "output": "false"
841
+ },
842
+ {
843
+ "template": "@(boolean(1 / 0))",
844
+ "output": "ERROR"
845
+ }
846
+ ]
847
+ },
848
+ {
849
+ "signature": "char(code)",
850
+ "summary": "Returns the character for the given UNICODE `code`.",
851
+ "detail": "It is the inverse of [function:code].",
852
+ "examples": [
853
+ {
854
+ "template": "@(char(33))",
855
+ "output": "!"
856
+ },
857
+ {
858
+ "template": "@(char(128512))",
859
+ "output": "😀"
860
+ },
861
+ {
862
+ "template": "@(char(\"foo\"))",
863
+ "output": "ERROR"
864
+ }
865
+ ]
866
+ },
867
+ {
868
+ "signature": "clean(text)",
869
+ "summary": "Removes any non-printable characters from `text`.",
870
+ "detail": "",
871
+ "examples": [
872
+ {
873
+ "template": "@(clean(\"😃 Hello \\nwo\\tr\\rld\"))",
874
+ "output": "😃 Hello world"
875
+ },
876
+ {
877
+ "template": "@(clean(123))",
878
+ "output": "123"
879
+ }
880
+ ]
881
+ },
882
+ {
883
+ "signature": "code(text)",
884
+ "summary": "Returns the UNICODE code for the first character of `text`.",
885
+ "detail": "It is the inverse of [function:char].",
886
+ "examples": [
887
+ {
888
+ "template": "@(code(\"a\"))",
889
+ "output": "97"
890
+ },
891
+ {
892
+ "template": "@(code(\"abc\"))",
893
+ "output": "97"
894
+ },
895
+ {
896
+ "template": "@(code(\"😀\"))",
897
+ "output": "128512"
898
+ },
899
+ {
900
+ "template": "@(code(\"15\"))",
901
+ "output": "49"
902
+ },
903
+ {
904
+ "template": "@(code(15))",
905
+ "output": "49"
906
+ },
907
+ {
908
+ "template": "@(code(\"\"))",
909
+ "output": "ERROR"
910
+ }
911
+ ]
912
+ },
913
+ {
914
+ "signature": "concat(array1, array2)",
915
+ "summary": "Returns the result of concatenating two arrays.",
916
+ "detail": "",
917
+ "examples": [
918
+ {
919
+ "template": "@(concat(array(\"a\", \"b\"), array(\"c\", \"d\")))",
920
+ "output": "[a, b, c, d]"
921
+ },
922
+ {
923
+ "template": "@(unique(concat(array(1, 2, 3), array(3, 4))))",
924
+ "output": "[1, 2, 3, 4]"
925
+ }
926
+ ]
927
+ },
928
+ {
929
+ "signature": "contains(array, value)",
930
+ "summary": "Returns whether `array` contains `value`.",
931
+ "detail": "",
932
+ "examples": [
933
+ {
934
+ "template": "@(contains(array(\"a\", \"b\", \"c\"), \"a\"))",
935
+ "output": "true"
936
+ },
937
+ {
938
+ "template": "@(contains(array(1, 2, 3), 4))",
939
+ "output": "false"
940
+ }
941
+ ]
942
+ },
943
+ {
944
+ "signature": "count(value)",
945
+ "summary": "Returns the number of items in the given array or properties on an object.",
946
+ "detail": "It will return an error if it is passed an item which isn't countable.",
947
+ "examples": [
948
+ {
949
+ "template": "@(count(contact.fields))",
950
+ "output": "7"
951
+ },
952
+ {
953
+ "template": "@(count(array()))",
954
+ "output": "0"
955
+ },
956
+ {
957
+ "template": "@(count(array(\"a\", \"b\", \"c\")))",
958
+ "output": "3"
959
+ },
960
+ {
961
+ "template": "@(count(1234))",
962
+ "output": "ERROR"
963
+ }
964
+ ]
965
+ },
966
+ {
967
+ "signature": "date(value)",
968
+ "summary": "Tries to convert `value` to a date.",
969
+ "detail": "If it is text then it will be parsed into a date using the default date format.\nAn error is returned if the value can't be converted.",
970
+ "examples": [
971
+ {
972
+ "template": "@(date(\"1979-07-18\"))",
973
+ "output": "1979-07-18"
974
+ },
975
+ {
976
+ "template": "@(date(\"1979-07-18T10:30:45.123456Z\"))",
977
+ "output": "1979-07-18"
978
+ },
979
+ {
980
+ "template": "@(date(\"10/05/2010\"))",
981
+ "output": "2010-05-10"
982
+ },
983
+ {
984
+ "template": "@(date(\"NOT DATE\"))",
985
+ "output": "ERROR"
986
+ }
987
+ ]
988
+ },
989
+ {
990
+ "signature": "date_from_parts(year, month, day)",
991
+ "summary": "Creates a date from `year`, `month` and `day`.",
992
+ "detail": "",
993
+ "examples": [
994
+ {
995
+ "template": "@(date_from_parts(2017, 1, 15))",
996
+ "output": "2017-01-15"
997
+ },
998
+ {
999
+ "template": "@(date_from_parts(2017, 2, 31))",
1000
+ "output": "2017-03-03"
1001
+ },
1002
+ {
1003
+ "template": "@(date_from_parts(2017, 13, 15))",
1004
+ "output": "ERROR"
1005
+ }
1006
+ ]
1007
+ },
1008
+ {
1009
+ "signature": "datetime(value)",
1010
+ "summary": "Tries to convert `value` to a datetime.",
1011
+ "detail": "If it is text then it will be parsed into a datetime using the default date\nand time formats. An error is returned if the value can't be converted.",
1012
+ "examples": [
1013
+ {
1014
+ "template": "@(datetime(\"1979-07-18\"))",
1015
+ "output": "1979-07-18T00:00:00.000000-05:00"
1016
+ },
1017
+ {
1018
+ "template": "@(datetime(\"1979-07-18T10:30:45.123456Z\"))",
1019
+ "output": "1979-07-18T10:30:45.123456Z"
1020
+ },
1021
+ {
1022
+ "template": "@(datetime(\"10/05/2010\"))",
1023
+ "output": "2010-05-10T00:00:00.000000-05:00"
1024
+ },
1025
+ {
1026
+ "template": "@(datetime(\"NOT DATE\"))",
1027
+ "output": "ERROR"
1028
+ }
1029
+ ]
1030
+ },
1031
+ {
1032
+ "signature": "datetime_add(datetime, offset, unit)",
1033
+ "summary": "Calculates the date value arrived at by adding `offset` number of `unit` to the `datetime`",
1034
+ "detail": "Valid durations are \"Y\" for years, \"M\" for months, \"W\" for weeks, \"D\" for days, \"h\" for hour,\n\"m\" for minutes, \"s\" for seconds",
1035
+ "examples": [
1036
+ {
1037
+ "template": "@(datetime_add(\"2017-01-15\", 5, \"D\"))",
1038
+ "output": "2017-01-20T00:00:00.000000-05:00"
1039
+ },
1040
+ {
1041
+ "template": "@(datetime_add(\"2017-01-15 10:45\", 30, \"m\"))",
1042
+ "output": "2017-01-15T11:15:00.000000-05:00"
1043
+ }
1044
+ ]
1045
+ },
1046
+ {
1047
+ "signature": "datetime_diff(date1, date2, unit)",
1048
+ "summary": "Returns the duration between `date1` and `date2` in the `unit` specified.",
1049
+ "detail": "Valid durations are \"Y\" for years, \"M\" for months, \"W\" for weeks, \"D\" for days, \"h\" for hour,\n\"m\" for minutes, \"s\" for seconds.",
1050
+ "examples": [
1051
+ {
1052
+ "template": "@(datetime_diff(\"2017-01-15\", \"2017-01-17\", \"D\"))",
1053
+ "output": "2"
1054
+ },
1055
+ {
1056
+ "template": "@(datetime_diff(\"2017-01-15\", \"2017-05-15\", \"W\"))",
1057
+ "output": "17"
1058
+ },
1059
+ {
1060
+ "template": "@(datetime_diff(\"2017-01-15\", \"2017-05-15\", \"M\"))",
1061
+ "output": "4"
1062
+ },
1063
+ {
1064
+ "template": "@(datetime_diff(\"2017-01-17 10:50\", \"2017-01-17 12:30\", \"h\"))",
1065
+ "output": "1"
1066
+ },
1067
+ {
1068
+ "template": "@(datetime_diff(\"2017-01-17\", \"2015-12-17\", \"Y\"))",
1069
+ "output": "-2"
1070
+ }
1071
+ ]
1072
+ },
1073
+ {
1074
+ "signature": "datetime_from_epoch(seconds)",
1075
+ "summary": "Converts the UNIX epoch time `seconds` into a new date.",
1076
+ "detail": "",
1077
+ "examples": [
1078
+ {
1079
+ "template": "@(datetime_from_epoch(1497286619))",
1080
+ "output": "2017-06-12T11:56:59.000000-05:00"
1081
+ },
1082
+ {
1083
+ "template": "@(datetime_from_epoch(1497286619.123456))",
1084
+ "output": "2017-06-12T11:56:59.123456-05:00"
1085
+ }
1086
+ ]
1087
+ },
1088
+ {
1089
+ "signature": "default(value, default)",
1090
+ "summary": "Returns `value` if is not empty or an error, otherwise it returns `default`.",
1091
+ "detail": "",
1092
+ "examples": [
1093
+ {
1094
+ "template": "@(default(undeclared.var, \"default_value\"))",
1095
+ "output": "default_value"
1096
+ },
1097
+ {
1098
+ "template": "@(default(\"10\", \"20\"))",
1099
+ "output": "10"
1100
+ },
1101
+ {
1102
+ "template": "@(default(\"\", \"value\"))",
1103
+ "output": "value"
1104
+ },
1105
+ {
1106
+ "template": "@(default(\" \", \"value\"))",
1107
+ "output": "\\x20\\x20"
1108
+ },
1109
+ {
1110
+ "template": "@(default(datetime(\"invalid-date\"), \"today\"))",
1111
+ "output": "today"
1112
+ },
1113
+ {
1114
+ "template": "@(default(format_urn(\"invalid-urn\"), \"ok\"))",
1115
+ "output": "ok"
1116
+ }
1117
+ ]
1118
+ },
1119
+ {
1120
+ "signature": "epoch(date)",
1121
+ "summary": "Converts `date` to a UNIX epoch time.",
1122
+ "detail": "The returned number can contain fractional seconds.",
1123
+ "examples": [
1124
+ {
1125
+ "template": "@(epoch(\"2017-06-12T16:56:59.000000Z\"))",
1126
+ "output": "1497286619"
1127
+ },
1128
+ {
1129
+ "template": "@(epoch(\"2017-06-12T18:56:59.000000+02:00\"))",
1130
+ "output": "1497286619"
1131
+ },
1132
+ {
1133
+ "template": "@(epoch(\"2017-06-12T16:56:59.123456Z\"))",
1134
+ "output": "1497286619.123456"
1135
+ },
1136
+ {
1137
+ "template": "@(round_down(epoch(\"2017-06-12T16:56:59.123456Z\")))",
1138
+ "output": "1497286619"
1139
+ }
1140
+ ]
1141
+ },
1142
+ {
1143
+ "signature": "extract(object, properties)",
1144
+ "summary": "Takes an object and extracts the named property.",
1145
+ "detail": "",
1146
+ "examples": [
1147
+ {
1148
+ "template": "@(extract(contact, \"name\"))",
1149
+ "output": "Ryan Lewis"
1150
+ },
1151
+ {
1152
+ "template": "@(extract(contact.groups[0], \"name\"))",
1153
+ "output": "Testers"
1154
+ }
1155
+ ]
1156
+ },
1157
+ {
1158
+ "signature": "extract_object(object, properties...)",
1159
+ "summary": "Takes an object and returns a new object by extracting only the named properties.",
1160
+ "detail": "",
1161
+ "examples": [
1162
+ {
1163
+ "template": "@(extract_object(contact.groups[0], \"name\"))",
1164
+ "output": "{name: Testers}"
1165
+ }
1166
+ ]
1167
+ },
1168
+ {
1169
+ "signature": "field(text, index, delimiter)",
1170
+ "summary": "Splits `text` using the given `delimiter` and returns the field at `index`.",
1171
+ "detail": "The index starts at zero. When splitting with a space, the delimiter is considered to be all whitespace.",
1172
+ "examples": [
1173
+ {
1174
+ "template": "@(field(\"a,b,c\", 1, \",\"))",
1175
+ "output": "b"
1176
+ },
1177
+ {
1178
+ "template": "@(field(\"a,,b,c\", 1, \",\"))",
1179
+ "output": ""
1180
+ },
1181
+ {
1182
+ "template": "@(field(\"a b c\", 1, \" \"))",
1183
+ "output": "b"
1184
+ },
1185
+ {
1186
+ "template": "@(field(\"a\t\tb\tc\td\", 1, \"\t\"))",
1187
+ "output": ""
1188
+ },
1189
+ {
1190
+ "template": "@(field(\"a\\t\\tb\\tc\\td\", 1, \" \"))",
1191
+ "output": ""
1192
+ },
1193
+ {
1194
+ "template": "@(field(\"a,b,c\", \"foo\", \",\"))",
1195
+ "output": "ERROR"
1196
+ }
1197
+ ]
1198
+ },
1199
+ {
1200
+ "signature": "filter(array, func)",
1201
+ "summary": "Returns a new array with the items from `array` that when passed to `func` return true.",
1202
+ "detail": "",
1203
+ "examples": [
1204
+ {
1205
+ "template": "@(filter(array(1, 0, 2), boolean))",
1206
+ "output": "[1, 2]"
1207
+ },
1208
+ {
1209
+ "template": "@(filter(array(\"a\", \"b\", \"c\"), (x) => x != \"c\"))",
1210
+ "output": "[a, b]"
1211
+ }
1212
+ ]
1213
+ },
1214
+ {
1215
+ "signature": "foreach(values, func, [args...])",
1216
+ "summary": "Creates a new array by applying `func` to each value in `values`.",
1217
+ "detail": "If the given function takes more than one argument, you can pass additional arguments after the function.",
1218
+ "examples": [
1219
+ {
1220
+ "template": "@(foreach(array(\"a\", \"b\", \"c\"), upper))",
1221
+ "output": "[A, B, C]"
1222
+ },
1223
+ {
1224
+ "template": "@(foreach(array(\"a\", \"b\", \"c\"), (x) => x & \"1\"))",
1225
+ "output": "[a1, b1, c1]"
1226
+ },
1227
+ {
1228
+ "template": "@(foreach(array(\"a\", \"b\", \"c\"), (x) => object(\"v\", x)))",
1229
+ "output": "[{v: a}, {v: b}, {v: c}]"
1230
+ },
1231
+ {
1232
+ "template": "@(foreach(array(\"the man\", \"fox\", \"jumped up\"), word, 0))",
1233
+ "output": "[the, fox, jumped]"
1234
+ }
1235
+ ]
1236
+ },
1237
+ {
1238
+ "signature": "foreach_value(object, func, [args...])",
1239
+ "summary": "Creates a new object by applying `func` to each property value of `object`.",
1240
+ "detail": "If the given function takes more than one argument, you can pass additional arguments after the function.",
1241
+ "examples": [
1242
+ {
1243
+ "template": "@(foreach_value(object(\"a\", \"x\", \"b\", \"y\"), upper))",
1244
+ "output": "{a: X, b: Y}"
1245
+ },
1246
+ {
1247
+ "template": "@(foreach_value(object(\"a\", \"hi there\", \"b\", \"good bye\"), word, 1))",
1248
+ "output": "{a: there, b: bye}"
1249
+ }
1250
+ ]
1251
+ },
1252
+ {
1253
+ "signature": "format(value)",
1254
+ "summary": "Formats `value` according to its type.",
1255
+ "detail": "",
1256
+ "examples": [
1257
+ {
1258
+ "template": "@(format(1234.5670))",
1259
+ "output": "1,234.567"
1260
+ },
1261
+ {
1262
+ "template": "@(format(now()))",
1263
+ "output": "11-04-2018 13:24"
1264
+ },
1265
+ {
1266
+ "template": "@(format(today()))",
1267
+ "output": "11-04-2018"
1268
+ }
1269
+ ]
1270
+ },
1271
+ {
1272
+ "signature": "format_date(date, [,format])",
1273
+ "summary": "Formats `date` as text according to the given `format`.",
1274
+ "detail": "If `format` is not specified then the environment's default format is used. The format\nstring can consist of the following characters. The characters ' ', ':', ',', 'T', '-'\nand '_' are ignored. Any other character is an error.\n\n* `YY` - last two digits of year 0-99\n* `YYYY` - four digits of year 0000-9999\n* `M` - month 1-12\n* `MM` - month, zero padded 01-12\n* `MMM` - month Jan-Dec (localized)\n* `MMMM` - month January-December (localized)\n* `D` - day of month, 1-31\n* `DD` - day of month, zero padded 01-31\n* `EEE` - day of week Mon-Sun (localized)\n* `EEEE` - day of week Monday-Sunday (localized)",
1275
+ "examples": [
1276
+ {
1277
+ "template": "@(format_date(\"1979-07-18T15:00:00.000000Z\"))",
1278
+ "output": "18-07-1979"
1279
+ },
1280
+ {
1281
+ "template": "@(format_date(\"1979-07-18T15:00:00.000000Z\", \"YYYY-MM-DD\"))",
1282
+ "output": "1979-07-18"
1283
+ },
1284
+ {
1285
+ "template": "@(format_date(\"2010-05-10T19:50:00.000000Z\", \"YYYY M DD\"))",
1286
+ "output": "2010 5 10"
1287
+ },
1288
+ {
1289
+ "template": "@(format_date(\"1979-07-18T15:00:00.000000Z\", \"YYYY\"))",
1290
+ "output": "1979"
1291
+ },
1292
+ {
1293
+ "template": "@(format_date(\"1979-07-18T15:00:00.000000Z\", \"M\"))",
1294
+ "output": "7"
1295
+ },
1296
+ {
1297
+ "template": "@(format_date(\"NOT DATE\", \"YYYY-MM-DD\"))",
1298
+ "output": "ERROR"
1299
+ }
1300
+ ]
1301
+ },
1302
+ {
1303
+ "signature": "format_datetime(datetime [,format [,timezone]])",
1304
+ "summary": "Formats `datetime` as text according to the given `format`.",
1305
+ "detail": "If `format` is not specified then the environment's default format is used. The format\nstring can consist of the following characters. The characters ' ', ':', ',', 'T', '-'\nand '_' are ignored. Any other character is an error.\n\n* `YY` - last two digits of year 0-99\n* `YYYY` - four digits of year 0000-9999\n* `M` - month 1-12\n* `MM` - month, zero padded 01-12\n* `MMM` - month Jan-Dec (localized)\n* `MMMM` - month January-December (localized)\n* `D` - day of month, 1-31\n* `DD` - day of month, zero padded 01-31\n* `EEE` - day of week Mon-Sun (localized)\n* `EEEE` - day of week Monday-Sunday (localized)\n* `h` - hour of the day 1-12\n* `hh` - hour of the day, zero padded 01-12\n* `t` - twenty four hour of the day 0-23\n* `tt` - twenty four hour of the day, zero padded 00-23\n* `m` - minute 0-59\n* `mm` - minute, zero padded 00-59\n* `s` - second 0-59\n* `ss` - second, zero padded 00-59\n* `fff` - milliseconds\n* `ffffff` - microseconds\n* `fffffffff` - nanoseconds\n* `aa` - am or pm (localized)\n* `AA` - AM or PM (localized)\n* `Z` - hour and minute offset from UTC, or Z for UTC\n* `ZZZ` - hour and minute offset from UTC\n\nTimezone should be a location name as specified in the IANA Time Zone database, such\nas \"America/Guayaquil\" or \"America/Los_Angeles\". If not specified, the current timezone\nwill be used. An error will be returned if the timezone is not recognized.",
1306
+ "examples": [
1307
+ {
1308
+ "template": "@(format_datetime(\"1979-07-18T15:00:00.000000Z\"))",
1309
+ "output": "18-07-1979 10:00"
1310
+ },
1311
+ {
1312
+ "template": "@(format_datetime(\"1979-07-18T15:00:00.000000Z\", \"YYYY-MM-DD\"))",
1313
+ "output": "1979-07-18"
1314
+ },
1315
+ {
1316
+ "template": "@(format_datetime(\"2010-05-10T19:50:00.000000Z\", \"YYYY M DD tt:mm\"))",
1317
+ "output": "2010 5 10 14:50"
1318
+ },
1319
+ {
1320
+ "template": "@(format_datetime(\"2010-05-10T19:50:00.000000Z\", \"YYYY-MM-DD hh:mm AA\", \"America/Los_Angeles\"))",
1321
+ "output": "2010-05-10 12:50 PM"
1322
+ },
1323
+ {
1324
+ "template": "@(format_datetime(\"1979-07-18T15:00:00.000000Z\", \"YYYY\"))",
1325
+ "output": "1979"
1326
+ },
1327
+ {
1328
+ "template": "@(format_datetime(\"1979-07-18T15:00:00.000000Z\", \"M\"))",
1329
+ "output": "7"
1330
+ },
1331
+ {
1332
+ "template": "@(format_datetime(\"NOT DATE\", \"YYYY-MM-DD\"))",
1333
+ "output": "ERROR"
1334
+ }
1335
+ ]
1336
+ },
1337
+ {
1338
+ "signature": "format_location(location)",
1339
+ "summary": "Formats the given `location` as its name.",
1340
+ "detail": "",
1341
+ "examples": [
1342
+ {
1343
+ "template": "@(format_location(\"Rwanda\"))",
1344
+ "output": "Rwanda"
1345
+ },
1346
+ {
1347
+ "template": "@(format_location(\"Rwanda > Kigali\"))",
1348
+ "output": "Kigali"
1349
+ }
1350
+ ]
1351
+ },
1352
+ {
1353
+ "signature": "format_number(number, places [, humanize])",
1354
+ "summary": "Formats `number` to the given number of decimal `places`.",
1355
+ "detail": "An optional third argument `humanize` can be false to disable the use of thousand separators.",
1356
+ "examples": [
1357
+ {
1358
+ "template": "@(format_number(1234))",
1359
+ "output": "1,234"
1360
+ },
1361
+ {
1362
+ "template": "@(format_number(1234.5670))",
1363
+ "output": "1,234.567"
1364
+ },
1365
+ {
1366
+ "template": "@(format_number(1234.5670, 2, true))",
1367
+ "output": "1,234.57"
1368
+ },
1369
+ {
1370
+ "template": "@(format_number(1234.5678, 0, false))",
1371
+ "output": "1235"
1372
+ },
1373
+ {
1374
+ "template": "@(format_number(\"foo\", 2, false))",
1375
+ "output": "ERROR"
1376
+ }
1377
+ ]
1378
+ },
1379
+ {
1380
+ "signature": "format_time(time [,format])",
1381
+ "summary": "Formats `time` as text according to the given `format`.",
1382
+ "detail": "If `format` is not specified then the environment's default format is used. The format\nstring can consist of the following characters. The characters ' ', ':', ',', 'T', '-'\nand '_' are ignored. Any other character is an error.\n\n* `h` - hour of the day 1-12\n* `hh` - hour of the day, zero padded 01-12\n* `t` - twenty four hour of the day 0-23\n* `tt` - twenty four hour of the day, zero padded 00-23\n* `m` - minute 0-59\n* `mm` - minute, zero padded 00-59\n* `s` - second 0-59\n* `ss` - second, zero padded 00-59\n* `fff` - milliseconds\n* `ffffff` - microseconds\n* `fffffffff` - nanoseconds\n* `aa` - am or pm (localized)\n* `AA` - AM or PM (localized)",
1383
+ "examples": [
1384
+ {
1385
+ "template": "@(format_time(\"14:50:30.000000\"))",
1386
+ "output": "14:50"
1387
+ },
1388
+ {
1389
+ "template": "@(format_time(\"14:50:30.000000\", \"h:mm aa\"))",
1390
+ "output": "2:50 pm"
1391
+ },
1392
+ {
1393
+ "template": "@(format_time(\"15:00:27.000000\", \"s\"))",
1394
+ "output": "27"
1395
+ },
1396
+ {
1397
+ "template": "@(format_time(\"NOT TIME\", \"hh:mm\"))",
1398
+ "output": "ERROR"
1399
+ }
1400
+ ]
1401
+ },
1402
+ {
1403
+ "signature": "format_urn(urn)",
1404
+ "summary": "Formats `urn` into human friendly text.",
1405
+ "detail": "",
1406
+ "examples": [
1407
+ {
1408
+ "template": "@(format_urn(\"tel:+250781234567\"))",
1409
+ "output": "0781 234 567"
1410
+ },
1411
+ {
1412
+ "template": "@(format_urn(\"twitter:134252511151#billy_bob\"))",
1413
+ "output": "billy_bob"
1414
+ },
1415
+ {
1416
+ "template": "@(format_urn(contact.urn))",
1417
+ "output": "(202) 456-1111"
1418
+ },
1419
+ {
1420
+ "template": "@(format_urn(urns.tel))",
1421
+ "output": "(202) 456-1111"
1422
+ },
1423
+ {
1424
+ "template": "@(format_urn(urns.mailto))",
1425
+ "output": "foo@bar.com"
1426
+ },
1427
+ {
1428
+ "template": "@(format_urn(\"NOT URN\"))",
1429
+ "output": "ERROR"
1430
+ }
1431
+ ]
1432
+ },
1433
+ {
1434
+ "signature": "html_decode(text)",
1435
+ "summary": "HTML decodes `text`",
1436
+ "detail": "",
1437
+ "examples": [
1438
+ {
1439
+ "template": "@(html_decode(\"Red & Blue\"))",
1440
+ "output": "Red & Blue"
1441
+ },
1442
+ {
1443
+ "template": "@(html_decode(\"5 + 10\"))",
1444
+ "output": "5 + 10"
1445
+ }
1446
+ ]
1447
+ },
1448
+ {
1449
+ "signature": "if(test, value1, value2)",
1450
+ "summary": "Returns `value1` if `test` is truthy or `value2` if not.",
1451
+ "detail": "If the first argument is an error that error is returned.",
1452
+ "examples": [
1453
+ {
1454
+ "template": "@(if(1 = 1, \"foo\", \"bar\"))",
1455
+ "output": "foo"
1456
+ },
1457
+ {
1458
+ "template": "@(if(\"foo\" > \"bar\", \"foo\", \"bar\"))",
1459
+ "output": "ERROR"
1460
+ }
1461
+ ]
1462
+ },
1463
+ {
1464
+ "signature": "is_error(value)",
1465
+ "summary": "Returns whether `value` is an error",
1466
+ "detail": "",
1467
+ "examples": [
1468
+ {
1469
+ "template": "@(is_error(datetime(\"foo\")))",
1470
+ "output": "true"
1471
+ },
1472
+ {
1473
+ "template": "@(is_error(run.not.existing))",
1474
+ "output": "true"
1475
+ },
1476
+ {
1477
+ "template": "@(is_error(\"hello\"))",
1478
+ "output": "false"
1479
+ }
1480
+ ]
1481
+ },
1482
+ {
1483
+ "signature": "join(array, separator)",
1484
+ "summary": "Joins the given `array` of strings with `separator` to make text.",
1485
+ "detail": "",
1486
+ "examples": [
1487
+ {
1488
+ "template": "@(join(array(\"a\", \"b\", \"c\"), \"|\"))",
1489
+ "output": "a|b|c"
1490
+ },
1491
+ {
1492
+ "template": "@(join(split(\"a.b.c\", \".\"), \" \"))",
1493
+ "output": "a b c"
1494
+ }
1495
+ ]
1496
+ },
1497
+ {
1498
+ "signature": "json(value)",
1499
+ "summary": "Returns the JSON representation of `value`.",
1500
+ "detail": "",
1501
+ "examples": [
1502
+ {
1503
+ "template": "@(json(\"string\"))",
1504
+ "output": "\"string\""
1505
+ },
1506
+ {
1507
+ "template": "@(json(10))",
1508
+ "output": "10"
1509
+ },
1510
+ {
1511
+ "template": "@(json(null))",
1512
+ "output": "null"
1513
+ },
1514
+ {
1515
+ "template": "@(json(contact.uuid))",
1516
+ "output": "\"5d76d86b-3bb9-4d5a-b822-c9d86f5d8e4f\""
1517
+ }
1518
+ ]
1519
+ },
1520
+ {
1521
+ "signature": "keys(object)",
1522
+ "summary": "Returns an array containing the property keys of `object`.",
1523
+ "detail": "",
1524
+ "examples": [
1525
+ {
1526
+ "template": "@(keys(object(\"a\", 123, \"b\", \"hello\", \"c\", \"world\")))",
1527
+ "output": "[a, b, c]"
1528
+ },
1529
+ {
1530
+ "template": "@(keys(null))",
1531
+ "output": "[]"
1532
+ },
1533
+ {
1534
+ "template": "@(keys(\"string\"))",
1535
+ "output": "ERROR"
1536
+ },
1537
+ {
1538
+ "template": "@(keys(10))",
1539
+ "output": "ERROR"
1540
+ }
1541
+ ]
1542
+ },
1543
+ {
1544
+ "signature": "lower(text)",
1545
+ "summary": "Converts `text` to lowercase.",
1546
+ "detail": "",
1547
+ "examples": [
1548
+ {
1549
+ "template": "@(lower(\"HellO\"))",
1550
+ "output": "hello"
1551
+ },
1552
+ {
1553
+ "template": "@(lower(\"hello\"))",
1554
+ "output": "hello"
1555
+ },
1556
+ {
1557
+ "template": "@(lower(\"123\"))",
1558
+ "output": "123"
1559
+ },
1560
+ {
1561
+ "template": "@(lower(\"😀\"))",
1562
+ "output": "😀"
1563
+ }
1564
+ ]
1565
+ },
1566
+ {
1567
+ "signature": "max(numbers...)",
1568
+ "summary": "Returns the maximum value in `numbers`.",
1569
+ "detail": "",
1570
+ "examples": [
1571
+ {
1572
+ "template": "@(max(1, 2))",
1573
+ "output": "2"
1574
+ },
1575
+ {
1576
+ "template": "@(max(1, -1, 10))",
1577
+ "output": "10"
1578
+ },
1579
+ {
1580
+ "template": "@(max(1, 10, \"foo\"))",
1581
+ "output": "ERROR"
1582
+ }
1583
+ ]
1584
+ },
1585
+ {
1586
+ "signature": "mean(numbers...)",
1587
+ "summary": "Returns the arithmetic mean of `numbers`.",
1588
+ "detail": "",
1589
+ "examples": [
1590
+ {
1591
+ "template": "@(mean(1, 2))",
1592
+ "output": "1.5"
1593
+ },
1594
+ {
1595
+ "template": "@(mean(1, 2, 6))",
1596
+ "output": "3"
1597
+ },
1598
+ {
1599
+ "template": "@(mean(1, \"foo\"))",
1600
+ "output": "ERROR"
1601
+ }
1602
+ ]
1603
+ },
1604
+ {
1605
+ "signature": "min(numbers...)",
1606
+ "summary": "Returns the minimum value in `numbers`.",
1607
+ "detail": "",
1608
+ "examples": [
1609
+ {
1610
+ "template": "@(min(1, 2))",
1611
+ "output": "1"
1612
+ },
1613
+ {
1614
+ "template": "@(min(2, 2, -10))",
1615
+ "output": "-10"
1616
+ },
1617
+ {
1618
+ "template": "@(min(1, 2, \"foo\"))",
1619
+ "output": "ERROR"
1620
+ }
1621
+ ]
1622
+ },
1623
+ {
1624
+ "signature": "mod(dividend, divisor)",
1625
+ "summary": "Returns the remainder of the division of `dividend` by `divisor`.",
1626
+ "detail": "",
1627
+ "examples": [
1628
+ {
1629
+ "template": "@(mod(5, 2))",
1630
+ "output": "1"
1631
+ },
1632
+ {
1633
+ "template": "@(mod(4, 2))",
1634
+ "output": "0"
1635
+ },
1636
+ {
1637
+ "template": "@(mod(5, \"foo\"))",
1638
+ "output": "ERROR"
1639
+ }
1640
+ ]
1641
+ },
1642
+ {
1643
+ "signature": "now()",
1644
+ "summary": "Returns the current date and time in the current timezone.",
1645
+ "detail": "",
1646
+ "examples": [
1647
+ {
1648
+ "template": "@(now())",
1649
+ "output": "2018-04-11T13:24:30.123456-05:00"
1650
+ }
1651
+ ]
1652
+ },
1653
+ {
1654
+ "signature": "number(value)",
1655
+ "summary": "Tries to convert `value` to a number.",
1656
+ "detail": "An error is returned if the value can't be converted.",
1657
+ "examples": [
1658
+ {
1659
+ "template": "@(number(10))",
1660
+ "output": "10"
1661
+ },
1662
+ {
1663
+ "template": "@(number(\"123.45000\"))",
1664
+ "output": "123.45"
1665
+ },
1666
+ {
1667
+ "template": "@(number(\"what?\"))",
1668
+ "output": "ERROR"
1669
+ }
1670
+ ]
1671
+ },
1672
+ {
1673
+ "signature": "object(pairs...)",
1674
+ "summary": "Takes property name value pairs and returns them as a new object.",
1675
+ "detail": "",
1676
+ "examples": [
1677
+ {
1678
+ "template": "@(object())",
1679
+ "output": "{}"
1680
+ },
1681
+ {
1682
+ "template": "@(object(\"a\", 123, \"b\", \"hello\"))",
1683
+ "output": "{a: 123, b: hello}"
1684
+ },
1685
+ {
1686
+ "template": "@(object(\"a\"))",
1687
+ "output": "ERROR"
1688
+ }
1689
+ ]
1690
+ },
1691
+ {
1692
+ "signature": "or(values...)",
1693
+ "summary": "Returns whether if any of the given `values` are truthy.",
1694
+ "detail": "",
1695
+ "examples": [
1696
+ {
1697
+ "template": "@(or(true))",
1698
+ "output": "true"
1699
+ },
1700
+ {
1701
+ "template": "@(or(true, false, true))",
1702
+ "output": "true"
1703
+ }
1704
+ ]
1705
+ },
1706
+ {
1707
+ "signature": "parse_datetime(text, format [,timezone])",
1708
+ "summary": "Parses `text` into a date using the given `format`.",
1709
+ "detail": "The format string can consist of the following characters. The characters\n' ', ':', ',', 'T', '-' and '_' are ignored. Any other character is an error.\n\n* `YY` - last two digits of year 0-99\n* `YYYY` - four digits of year 0000-9999\n* `M` - month 1-12\n* `MM` - month, zero padded 01-12\n* `D` - day of month, 1-31\n* `DD` - day of month, zero padded 01-31\n* `h` - hour of the day 1-12\n* `hh` - hour of the day 01-12\n* `t` - twenty four hour of the day 1-23\n* `tt` - twenty four hour of the day, zero padded 01-23\n* `m` - minute 0-59\n* `mm` - minute, zero padded 00-59\n* `s` - second 0-59\n* `ss` - second, zero padded 00-59\n* `fff` - milliseconds\n* `ffffff` - microseconds\n* `fffffffff` - nanoseconds\n* `aa` - am or pm\n* `AA` - AM or PM\n* `Z` - hour and minute offset from UTC, or Z for UTC\n* `ZZZ` - hour and minute offset from UTC\n\nTimezone should be a location name as specified in the IANA Time Zone database, such\nas \"America/Guayaquil\" or \"America/Los_Angeles\". If not specified, the current timezone\nwill be used. An error will be returned if the timezone is not recognized.\n\nNote that fractional seconds will be parsed even without an explicit format identifier.\nYou should only specify fractional seconds when you want to assert the number of places\nin the input format.\n\nparse_datetime will return an error if it is unable to convert the text to a datetime.",
1710
+ "examples": [
1711
+ {
1712
+ "template": "@(parse_datetime(\"1979-07-18\", \"YYYY-MM-DD\"))",
1713
+ "output": "1979-07-18T00:00:00.000000-05:00"
1714
+ },
1715
+ {
1716
+ "template": "@(parse_datetime(\"2010 5 10\", \"YYYY M DD\"))",
1717
+ "output": "2010-05-10T00:00:00.000000-05:00"
1718
+ },
1719
+ {
1720
+ "template": "@(parse_datetime(\"2010 5 10 12:50\", \"YYYY M DD tt:mm\", \"America/Los_Angeles\"))",
1721
+ "output": "2010-05-10T12:50:00.000000-07:00"
1722
+ },
1723
+ {
1724
+ "template": "@(parse_datetime(\"NOT DATE\", \"YYYY-MM-DD\"))",
1725
+ "output": "ERROR"
1726
+ }
1727
+ ]
1728
+ },
1729
+ {
1730
+ "signature": "parse_json(text)",
1731
+ "summary": "Tries to parse `text` as JSON.",
1732
+ "detail": "If the given `text` is not valid JSON, then an error is returned",
1733
+ "examples": [
1734
+ {
1735
+ "template": "@(parse_json(\"{\\\"foo\\\": \\\"bar\\\"}\").foo)",
1736
+ "output": "bar"
1737
+ },
1738
+ {
1739
+ "template": "@(parse_json(\"[1,2,3,4]\")[2])",
1740
+ "output": "3"
1741
+ },
1742
+ {
1743
+ "template": "@(parse_json(\"invalid json\"))",
1744
+ "output": "ERROR"
1745
+ }
1746
+ ]
1747
+ },
1748
+ {
1749
+ "signature": "parse_time(text, format)",
1750
+ "summary": "Parses `text` into a time using the given `format`.",
1751
+ "detail": "The format string can consist of the following characters. The characters\n' ', ':', ',', 'T', '-' and '_' are ignored. Any other character is an error.\n\n* `h` - hour of the day 1-12\n* `hh` - hour of the day, zero padded 01-12\n* `t` - twenty four hour of the day 1-23\n* `tt` - twenty four hour of the day, zero padded 01-23\n* `m` - minute 0-59\n* `mm` - minute, zero padded 00-59\n* `s` - second 0-59\n* `ss` - second, zero padded 00-59\n* `fff` - milliseconds\n* `ffffff` - microseconds\n* `fffffffff` - nanoseconds\n* `aa` - am or pm\n* `AA` - AM or PM\n\nNote that fractional seconds will be parsed even without an explicit format identifier.\nYou should only specify fractional seconds when you want to assert the number of places\nin the input format.\n\nparse_time will return an error if it is unable to convert the text to a time.",
1752
+ "examples": [
1753
+ {
1754
+ "template": "@(parse_time(\"15:28\", \"tt:mm\"))",
1755
+ "output": "15:28:00.000000"
1756
+ },
1757
+ {
1758
+ "template": "@(parse_time(\"2:40 pm\", \"h:mm aa\"))",
1759
+ "output": "14:40:00.000000"
1760
+ },
1761
+ {
1762
+ "template": "@(parse_time(\"NOT TIME\", \"tt:mm\"))",
1763
+ "output": "ERROR"
1764
+ }
1765
+ ]
1766
+ },
1767
+ {
1768
+ "signature": "percent(number)",
1769
+ "summary": "Formats `number` as a percentage.",
1770
+ "detail": "",
1771
+ "examples": [
1772
+ {
1773
+ "template": "@(percent(0.54234))",
1774
+ "output": "54%"
1775
+ },
1776
+ {
1777
+ "template": "@(percent(1.2))",
1778
+ "output": "120%"
1779
+ },
1780
+ {
1781
+ "template": "@(percent(\"foo\"))",
1782
+ "output": "ERROR"
1783
+ }
1784
+ ]
1785
+ },
1786
+ {
1787
+ "signature": "prompt(name, args...)",
1788
+ "summary": "Returns a pre-defined LLM prompt.",
1789
+ "detail": "Note that the actual prompt text may differ from the examples below.",
1790
+ "examples": [
1791
+ {
1792
+ "template": "@(prompt(\"categorize\", array(\"Positive\", \"Negative\")))",
1793
+ "output": "Categorize the following text into one of the following: [Positive, Negative]"
1794
+ },
1795
+ {
1796
+ "template": "@(prompt(\"xx\"))",
1797
+ "output": "ERROR"
1798
+ }
1799
+ ]
1800
+ },
1801
+ {
1802
+ "signature": "rand()",
1803
+ "summary": "Returns a single random number between [0.0-1.0).",
1804
+ "detail": "",
1805
+ "examples": [
1806
+ {
1807
+ "template": "@(rand())",
1808
+ "output": "0.6075520156746239"
1809
+ },
1810
+ {
1811
+ "template": "@(rand())",
1812
+ "output": "0.48467757094734026"
1813
+ }
1814
+ ]
1815
+ },
1816
+ {
1817
+ "signature": "rand_between()",
1818
+ "summary": "A single random integer in the given inclusive range.",
1819
+ "detail": "",
1820
+ "examples": [
1821
+ {
1822
+ "template": "@(rand_between(1, 10))",
1823
+ "output": "10"
1824
+ },
1825
+ {
1826
+ "template": "@(rand_between(1, 10))",
1827
+ "output": "2"
1828
+ }
1829
+ ]
1830
+ },
1831
+ {
1832
+ "signature": "read_chars(text)",
1833
+ "summary": "Converts `text` into something that can be read by IVR systems.",
1834
+ "detail": "ReadChars will split the numbers such as they are easier to understand. This includes\nsplitting in 3s or 4s if appropriate.",
1835
+ "examples": [
1836
+ {
1837
+ "template": "@(read_chars(\"1234\"))",
1838
+ "output": "1 2 3 4"
1839
+ },
1840
+ {
1841
+ "template": "@(read_chars(\"abc\"))",
1842
+ "output": "a b c"
1843
+ },
1844
+ {
1845
+ "template": "@(read_chars(\"abcdef\"))",
1846
+ "output": "a b c , d e f"
1847
+ }
1848
+ ]
1849
+ },
1850
+ {
1851
+ "signature": "regex_match(text, pattern [,group])",
1852
+ "summary": "Returns the first match of the regular expression `pattern` in `text`.",
1853
+ "detail": "An optional third parameter `group` determines which matching group will be returned.",
1854
+ "examples": [
1855
+ {
1856
+ "template": "@(regex_match(\"sda34dfddg67\", \"\\d+\"))",
1857
+ "output": "34"
1858
+ },
1859
+ {
1860
+ "template": "@(regex_match(\"Bob Smith\", \"(\\w+) (\\w+)\", 1))",
1861
+ "output": "Bob"
1862
+ },
1863
+ {
1864
+ "template": "@(regex_match(\"Bob Smith\", \"(\\w+) (\\w+)\", 2))",
1865
+ "output": "Smith"
1866
+ },
1867
+ {
1868
+ "template": "@(regex_match(\"Bob Smith\", \"(\\w+) (\\w+)\", 5))",
1869
+ "output": "ERROR"
1870
+ },
1871
+ {
1872
+ "template": "@(regex_match(\"abc\", \"[\\.\"))",
1873
+ "output": "ERROR"
1874
+ }
1875
+ ]
1876
+ },
1877
+ {
1878
+ "signature": "remove_first_word(text)",
1879
+ "summary": "Removes the first word of `text`.",
1880
+ "detail": "",
1881
+ "examples": [
1882
+ {
1883
+ "template": "@(remove_first_word(\"foo bar\"))",
1884
+ "output": "bar"
1885
+ },
1886
+ {
1887
+ "template": "@(remove_first_word(\"Hi there. I'm a flow!\"))",
1888
+ "output": "there. I'm a flow!"
1889
+ }
1890
+ ]
1891
+ },
1892
+ {
1893
+ "signature": "repeat(text, count)",
1894
+ "summary": "Returns `text` repeated `count` number of times.",
1895
+ "detail": "",
1896
+ "examples": [
1897
+ {
1898
+ "template": "@(repeat(\"*\", 8))",
1899
+ "output": "********"
1900
+ },
1901
+ {
1902
+ "template": "@(repeat(\"*\", \"foo\"))",
1903
+ "output": "ERROR"
1904
+ }
1905
+ ]
1906
+ },
1907
+ {
1908
+ "signature": "replace(text, needle, replacement [, count])",
1909
+ "summary": "Replaces up to `count` occurrences of `needle` with `replacement` in `text`.",
1910
+ "detail": "If `count` is omitted or is less than 0 then all occurrences are replaced.",
1911
+ "examples": [
1912
+ {
1913
+ "template": "@(replace(\"foo bar foo\", \"foo\", \"zap\"))",
1914
+ "output": "zap bar zap"
1915
+ },
1916
+ {
1917
+ "template": "@(replace(\"foo bar foo\", \"foo\", \"zap\", 1))",
1918
+ "output": "zap bar foo"
1919
+ },
1920
+ {
1921
+ "template": "@(replace(\"foo bar\", \"baz\", \"zap\"))",
1922
+ "output": "foo bar"
1923
+ }
1924
+ ]
1925
+ },
1926
+ {
1927
+ "signature": "replace_time(datetime)",
1928
+ "summary": "Returns a new datetime with the time part replaced by the `time`.",
1929
+ "detail": "",
1930
+ "examples": [
1931
+ {
1932
+ "template": "@(replace_time(now(), \"10:30\"))",
1933
+ "output": "2018-04-11T10:30:00.000000-05:00"
1934
+ },
1935
+ {
1936
+ "template": "@(replace_time(\"2017-01-15\", \"10:30\"))",
1937
+ "output": "2017-01-15T10:30:00.000000-05:00"
1938
+ },
1939
+ {
1940
+ "template": "@(replace_time(\"foo\", \"10:30\"))",
1941
+ "output": "ERROR"
1942
+ }
1943
+ ]
1944
+ },
1945
+ {
1946
+ "signature": "reverse(array)",
1947
+ "summary": "Returns a new array with the values of `array` reversed.",
1948
+ "detail": "",
1949
+ "examples": [
1950
+ {
1951
+ "template": "@(reverse(array(3, 1, 2)))",
1952
+ "output": "[2, 1, 3]"
1953
+ },
1954
+ {
1955
+ "template": "@(reverse(array(\"C\", \"A\", \"B\")))",
1956
+ "output": "[B, A, C]"
1957
+ }
1958
+ ]
1959
+ },
1960
+ {
1961
+ "signature": "round(number [,places])",
1962
+ "summary": "Rounds `number` to the nearest value.",
1963
+ "detail": "You can optionally pass in the number of decimal places to round to as `places`. If `places` < 0,\nit will round the integer part to the nearest 10^(-places).",
1964
+ "examples": [
1965
+ {
1966
+ "template": "@(round(12))",
1967
+ "output": "12"
1968
+ },
1969
+ {
1970
+ "template": "@(round(12.141))",
1971
+ "output": "12"
1972
+ },
1973
+ {
1974
+ "template": "@(round(12.6))",
1975
+ "output": "13"
1976
+ },
1977
+ {
1978
+ "template": "@(round(12.141, 2))",
1979
+ "output": "12.14"
1980
+ },
1981
+ {
1982
+ "template": "@(round(12.146, 2))",
1983
+ "output": "12.15"
1984
+ },
1985
+ {
1986
+ "template": "@(round(12.146, -1))",
1987
+ "output": "10"
1988
+ },
1989
+ {
1990
+ "template": "@(round(\"notnum\", 2))",
1991
+ "output": "ERROR"
1992
+ }
1993
+ ]
1994
+ },
1995
+ {
1996
+ "signature": "round_down(number [,places])",
1997
+ "summary": "Rounds `number` down to the nearest integer value.",
1998
+ "detail": "You can optionally pass in the number of decimal places to round to as `places`.",
1999
+ "examples": [
2000
+ {
2001
+ "template": "@(round_down(12))",
2002
+ "output": "12"
2003
+ },
2004
+ {
2005
+ "template": "@(round_down(12.141))",
2006
+ "output": "12"
2007
+ },
2008
+ {
2009
+ "template": "@(round_down(12.6))",
2010
+ "output": "12"
2011
+ },
2012
+ {
2013
+ "template": "@(round_down(12.141, 2))",
2014
+ "output": "12.14"
2015
+ },
2016
+ {
2017
+ "template": "@(round_down(12.146, 2))",
2018
+ "output": "12.14"
2019
+ },
2020
+ {
2021
+ "template": "@(round_down(\"foo\"))",
2022
+ "output": "ERROR"
2023
+ }
2024
+ ]
2025
+ },
2026
+ {
2027
+ "signature": "round_up(number [,places])",
2028
+ "summary": "Rounds `number` up to the nearest integer value.",
2029
+ "detail": "You can optionally pass in the number of decimal places to round to as `places`.",
2030
+ "examples": [
2031
+ {
2032
+ "template": "@(round_up(12))",
2033
+ "output": "12"
2034
+ },
2035
+ {
2036
+ "template": "@(round_up(12.141))",
2037
+ "output": "13"
2038
+ },
2039
+ {
2040
+ "template": "@(round_up(12.6))",
2041
+ "output": "13"
2042
+ },
2043
+ {
2044
+ "template": "@(round_up(12.141, 2))",
2045
+ "output": "12.15"
2046
+ },
2047
+ {
2048
+ "template": "@(round_up(12.146, 2))",
2049
+ "output": "12.15"
2050
+ },
2051
+ {
2052
+ "template": "@(round_up(\"foo\"))",
2053
+ "output": "ERROR"
2054
+ }
2055
+ ]
2056
+ },
2057
+ {
2058
+ "signature": "slice(array, start, [,end])",
2059
+ "summary": "Returns the sub-sequence of `array` between `start` (inclusive) and `end` (exclusive).",
2060
+ "detail": "If `end` is not specified then the entire remainder of `array` will be included. Negative values\nfor `start` or `end` start at the end of `array`.",
2061
+ "examples": [
2062
+ {
2063
+ "template": "@(slice(array(\"a\", \"b\", \"c\"), 0, 2))",
2064
+ "output": "[a, b]"
2065
+ },
2066
+ {
2067
+ "template": "@(slice(array(\"a\", \"b\", \"c\"), 1, 3))",
2068
+ "output": "[b, c]"
2069
+ },
2070
+ {
2071
+ "template": "@(slice(array(\"a\", \"b\", \"c\"), 0, -1))",
2072
+ "output": "[a, b]"
2073
+ },
2074
+ {
2075
+ "template": "@(slice(array(\"a\", \"b\", \"c\"), 1))",
2076
+ "output": "[b, c]"
2077
+ },
2078
+ {
2079
+ "template": "@(slice(array(\"a\", \"b\", \"c\"), 10))",
2080
+ "output": "[]"
2081
+ }
2082
+ ]
2083
+ },
2084
+ {
2085
+ "signature": "sort(array)",
2086
+ "summary": "Returns a new array with the values of `array` sorted.",
2087
+ "detail": "Values in `array` must be a sortable type and be of the same type.",
2088
+ "examples": [
2089
+ {
2090
+ "template": "@(sort(array(3, 1, 2)))",
2091
+ "output": "[1, 2, 3]"
2092
+ },
2093
+ {
2094
+ "template": "@(sort(array(\"C\", \"A\", \"B\")))",
2095
+ "output": "[A, B, C]"
2096
+ }
2097
+ ]
2098
+ },
2099
+ {
2100
+ "signature": "split(text, [,delimiters])",
2101
+ "summary": "Splits `text` into an array of separated words.",
2102
+ "detail": "Empty values are removed from the returned list. There is an optional final parameter `delimiters` which\nis string of characters used to split the text into words.",
2103
+ "examples": [
2104
+ {
2105
+ "template": "@(split(\"a b c\"))",
2106
+ "output": "[a, b, c]"
2107
+ },
2108
+ {
2109
+ "template": "@(split(\"a\", \" \"))",
2110
+ "output": "[a]"
2111
+ },
2112
+ {
2113
+ "template": "@(split(\"abc..d\", \".\"))",
2114
+ "output": "[abc, d]"
2115
+ },
2116
+ {
2117
+ "template": "@(split(\"a.b.c.\", \".\"))",
2118
+ "output": "[a, b, c]"
2119
+ },
2120
+ {
2121
+ "template": "@(split(\"a|b,c d\", \" .|,\"))",
2122
+ "output": "[a, b, c, d]"
2123
+ }
2124
+ ]
2125
+ },
2126
+ {
2127
+ "signature": "sum(array)",
2128
+ "summary": "Sums the items in the given `array`.",
2129
+ "detail": "",
2130
+ "examples": [
2131
+ {
2132
+ "template": "@(sum(array(1, 2, \"3\")))",
2133
+ "output": "6"
2134
+ }
2135
+ ]
2136
+ },
2137
+ {
2138
+ "signature": "text(value)",
2139
+ "summary": "Tries to convert `value` to text.",
2140
+ "detail": "An error is returned if the value can't be converted.",
2141
+ "examples": [
2142
+ {
2143
+ "template": "@(text(3 = 3))",
2144
+ "output": "true"
2145
+ },
2146
+ {
2147
+ "template": "@(json(text(123.45)))",
2148
+ "output": "\"123.45\""
2149
+ },
2150
+ {
2151
+ "template": "@(text(1 / 0))",
2152
+ "output": "ERROR"
2153
+ }
2154
+ ]
2155
+ },
2156
+ {
2157
+ "signature": "text_compare(text1, text2)",
2158
+ "summary": "Returns the dictionary order of `text1` and `text2`.",
2159
+ "detail": "The return value will be -1 if `text1` comes before `text2`, 0 if they are equal\nand 1 if `text1` comes after `text2`.",
2160
+ "examples": [
2161
+ {
2162
+ "template": "@(text_compare(\"abc\", \"abc\"))",
2163
+ "output": "0"
2164
+ },
2165
+ {
2166
+ "template": "@(text_compare(\"abc\", \"def\"))",
2167
+ "output": "-1"
2168
+ },
2169
+ {
2170
+ "template": "@(text_compare(\"zzz\", \"aaa\"))",
2171
+ "output": "1"
2172
+ }
2173
+ ]
2174
+ },
2175
+ {
2176
+ "signature": "text_length(value)",
2177
+ "summary": "Returns the length (number of characters) of `value` when converted to text.",
2178
+ "detail": "",
2179
+ "examples": [
2180
+ {
2181
+ "template": "@(text_length(\"abc\"))",
2182
+ "output": "3"
2183
+ },
2184
+ {
2185
+ "template": "@(text_length(array(2, 3)))",
2186
+ "output": "6"
2187
+ }
2188
+ ]
2189
+ },
2190
+ {
2191
+ "signature": "text_slice(text, start [, end])",
2192
+ "summary": "Returns the portion of `text` between `start` (inclusive) and `end` (exclusive).",
2193
+ "detail": "If `end` is not specified then the entire remainder of `text` will be included. Negative values\nfor `start` or `end` start at the end of `text`.",
2194
+ "examples": [
2195
+ {
2196
+ "template": "@(text_slice(\"hello\", 2))",
2197
+ "output": "llo"
2198
+ },
2199
+ {
2200
+ "template": "@(text_slice(\"hello\", 1, 3))",
2201
+ "output": "el"
2202
+ },
2203
+ {
2204
+ "template": "@(text_slice(\"hello😁\", -3, -1))",
2205
+ "output": "lo"
2206
+ },
2207
+ {
2208
+ "template": "@(text_slice(\"hello\", 7))",
2209
+ "output": ""
2210
+ }
2211
+ ]
2212
+ },
2213
+ {
2214
+ "signature": "time(value)",
2215
+ "summary": "Tries to convert `value` to a time.",
2216
+ "detail": "If it is text then it will be parsed into a time using the default time format.\nAn error is returned if the value can't be converted.",
2217
+ "examples": [
2218
+ {
2219
+ "template": "@(time(\"10:30\"))",
2220
+ "output": "10:30:00.000000"
2221
+ },
2222
+ {
2223
+ "template": "@(time(\"10:30:45 PM\"))",
2224
+ "output": "22:30:45.000000"
2225
+ },
2226
+ {
2227
+ "template": "@(time(datetime(\"1979-07-18T10:30:45.123456Z\")))",
2228
+ "output": "10:30:45.123456"
2229
+ },
2230
+ {
2231
+ "template": "@(time(\"what?\"))",
2232
+ "output": "ERROR"
2233
+ }
2234
+ ]
2235
+ },
2236
+ {
2237
+ "signature": "time_from_parts(hour, minute, second)",
2238
+ "summary": "Creates a time from `hour`, `minute` and `second`",
2239
+ "detail": "",
2240
+ "examples": [
2241
+ {
2242
+ "template": "@(time_from_parts(14, 40, 15))",
2243
+ "output": "14:40:15.000000"
2244
+ },
2245
+ {
2246
+ "template": "@(time_from_parts(8, 10, 0))",
2247
+ "output": "08:10:00.000000"
2248
+ },
2249
+ {
2250
+ "template": "@(time_from_parts(25, 0, 0))",
2251
+ "output": "ERROR"
2252
+ }
2253
+ ]
2254
+ },
2255
+ {
2256
+ "signature": "title(text)",
2257
+ "summary": "Capitalizes each word in `text`.",
2258
+ "detail": "",
2259
+ "examples": [
2260
+ {
2261
+ "template": "@(title(\"foo\"))",
2262
+ "output": "Foo"
2263
+ },
2264
+ {
2265
+ "template": "@(title(\"ryan lewis\"))",
2266
+ "output": "Ryan Lewis"
2267
+ },
2268
+ {
2269
+ "template": "@(title(\"RYAN LEWIS\"))",
2270
+ "output": "Ryan Lewis"
2271
+ },
2272
+ {
2273
+ "template": "@(title(123))",
2274
+ "output": "123"
2275
+ }
2276
+ ]
2277
+ },
2278
+ {
2279
+ "signature": "today()",
2280
+ "summary": "Returns the current date in the environment timezone.",
2281
+ "detail": "",
2282
+ "examples": [
2283
+ {
2284
+ "template": "@(today())",
2285
+ "output": "2018-04-11"
2286
+ }
2287
+ ]
2288
+ },
2289
+ {
2290
+ "signature": "trim(text, [,chars])",
2291
+ "summary": "Removes whitespace from either end of `text`.",
2292
+ "detail": "There is an optional final parameter `chars` which is string of characters to be removed instead of whitespace.",
2293
+ "examples": [
2294
+ {
2295
+ "template": "@(trim(\" hello world \"))",
2296
+ "output": "hello world"
2297
+ },
2298
+ {
2299
+ "template": "@(trim(\"+123157568\", \"+\"))",
2300
+ "output": "123157568"
2301
+ }
2302
+ ]
2303
+ },
2304
+ {
2305
+ "signature": "trim_left(text, [,chars])",
2306
+ "summary": "Removes whitespace from the start of `text`.",
2307
+ "detail": "There is an optional final parameter `chars` which is string of characters to be removed instead of whitespace.",
2308
+ "examples": [
2309
+ {
2310
+ "template": "@(\"*\" & trim_left(\" hello world \") & \"*\")",
2311
+ "output": "*hello world *"
2312
+ },
2313
+ {
2314
+ "template": "@(trim_left(\"+12345+\", \"+\"))",
2315
+ "output": "12345+"
2316
+ }
2317
+ ]
2318
+ },
2319
+ {
2320
+ "signature": "trim_right(text, [,chars])",
2321
+ "summary": "Removes whitespace from the end of `text`.",
2322
+ "detail": "There is an optional final parameter `chars` which is string of characters to be removed instead of whitespace.",
2323
+ "examples": [
2324
+ {
2325
+ "template": "@(\"*\" & trim_right(\" hello world \") & \"*\")",
2326
+ "output": "* hello world*"
2327
+ },
2328
+ {
2329
+ "template": "@(trim_right(\"+12345+\", \"+\"))",
2330
+ "output": "+12345"
2331
+ }
2332
+ ]
2333
+ },
2334
+ {
2335
+ "signature": "tz(date)",
2336
+ "summary": "Returns the name of the timezone of `date`.",
2337
+ "detail": "If no timezone information is present in the date, then the current timezone will be returned.",
2338
+ "examples": [
2339
+ {
2340
+ "template": "@(tz(\"2017-01-15T02:15:18.123456Z\"))",
2341
+ "output": "UTC"
2342
+ },
2343
+ {
2344
+ "template": "@(tz(\"2017-01-15 02:15:18PM\"))",
2345
+ "output": "America/Guayaquil"
2346
+ },
2347
+ {
2348
+ "template": "@(tz(\"2017-01-15\"))",
2349
+ "output": "America/Guayaquil"
2350
+ },
2351
+ {
2352
+ "template": "@(tz(\"foo\"))",
2353
+ "output": "ERROR"
2354
+ }
2355
+ ]
2356
+ },
2357
+ {
2358
+ "signature": "tz_offset(date)",
2359
+ "summary": "Returns the offset of the timezone of `date`.",
2360
+ "detail": "The offset is returned in the format `[+/-]HH:MM`. If no timezone information is present in the date,\nthen the current timezone offset will be returned.",
2361
+ "examples": [
2362
+ {
2363
+ "template": "@(tz_offset(\"2017-01-15T02:15:18.123456Z\"))",
2364
+ "output": "+0000"
2365
+ },
2366
+ {
2367
+ "template": "@(tz_offset(\"2017-01-15 02:15:18PM\"))",
2368
+ "output": "-0500"
2369
+ },
2370
+ {
2371
+ "template": "@(tz_offset(\"2017-01-15\"))",
2372
+ "output": "-0500"
2373
+ },
2374
+ {
2375
+ "template": "@(tz_offset(\"foo\"))",
2376
+ "output": "ERROR"
2377
+ }
2378
+ ]
2379
+ },
2380
+ {
2381
+ "signature": "unique(array)",
2382
+ "summary": "Returns the unique values in `array`.",
2383
+ "detail": "",
2384
+ "examples": [
2385
+ {
2386
+ "template": "@(unique(array(1, 3, 2, 3)))",
2387
+ "output": "[1, 3, 2]"
2388
+ },
2389
+ {
2390
+ "template": "@(unique(array(\"hi\", \"there\", \"hi\")))",
2391
+ "output": "[hi, there]"
2392
+ }
2393
+ ]
2394
+ },
2395
+ {
2396
+ "signature": "upper(text)",
2397
+ "summary": "Converts `text` to uppercase.",
2398
+ "detail": "",
2399
+ "examples": [
2400
+ {
2401
+ "template": "@(upper(\"Asdf\"))",
2402
+ "output": "ASDF"
2403
+ },
2404
+ {
2405
+ "template": "@(upper(123))",
2406
+ "output": "123"
2407
+ }
2408
+ ]
2409
+ },
2410
+ {
2411
+ "signature": "url_encode(text)",
2412
+ "summary": "Encodes `text` for use as a URL parameter.",
2413
+ "detail": "",
2414
+ "examples": [
2415
+ {
2416
+ "template": "@(url_encode(\"two & words\"))",
2417
+ "output": "two%20%26%20words"
2418
+ },
2419
+ {
2420
+ "template": "@(url_encode(10))",
2421
+ "output": "10"
2422
+ }
2423
+ ]
2424
+ },
2425
+ {
2426
+ "signature": "urn_parts(urn)",
2427
+ "summary": "Parses a URN into its different parts",
2428
+ "detail": "",
2429
+ "examples": [
2430
+ {
2431
+ "template": "@(urn_parts(\"tel:+593979012345\"))",
2432
+ "output": "{display: , path: +593979012345, scheme: tel}"
2433
+ },
2434
+ {
2435
+ "template": "@(urn_parts(\"twitterid:3263621177#bobby\"))",
2436
+ "output": "{display: bobby, path: 3263621177, scheme: twitterid}"
2437
+ },
2438
+ {
2439
+ "template": "@(urn_parts(\"not a urn\"))",
2440
+ "output": "ERROR"
2441
+ }
2442
+ ]
2443
+ },
2444
+ {
2445
+ "signature": "week_number(date)",
2446
+ "summary": "Returns the week number (1-54) of `date`.",
2447
+ "detail": "The week is considered to start on Sunday and week containing Jan 1st is week number 1.",
2448
+ "examples": [
2449
+ {
2450
+ "template": "@(week_number(\"2019-01-01\"))",
2451
+ "output": "1"
2452
+ },
2453
+ {
2454
+ "template": "@(week_number(\"2019-07-23T16:56:59.000000Z\"))",
2455
+ "output": "30"
2456
+ },
2457
+ {
2458
+ "template": "@(week_number(\"xx\"))",
2459
+ "output": "ERROR"
2460
+ }
2461
+ ]
2462
+ },
2463
+ {
2464
+ "signature": "weekday(date)",
2465
+ "summary": "Returns the day of the week for `date`.",
2466
+ "detail": "The week is considered to start on Sunday so a Sunday returns 0, a Monday returns 1 etc.",
2467
+ "examples": [
2468
+ {
2469
+ "template": "@(weekday(\"2017-01-15\"))",
2470
+ "output": "0"
2471
+ },
2472
+ {
2473
+ "template": "@(weekday(\"foo\"))",
2474
+ "output": "ERROR"
2475
+ }
2476
+ ]
2477
+ },
2478
+ {
2479
+ "signature": "word(text, index [,delimiters])",
2480
+ "summary": "Returns the word at `index` in `text`.",
2481
+ "detail": "Indexes start at zero. There is an optional final parameter `delimiters` which\nis string of characters used to split the text into words.",
2482
+ "examples": [
2483
+ {
2484
+ "template": "@(word(\"bee cat dog\", 0))",
2485
+ "output": "bee"
2486
+ },
2487
+ {
2488
+ "template": "@(word(\"bee.cat,dog\", 0))",
2489
+ "output": "bee"
2490
+ },
2491
+ {
2492
+ "template": "@(word(\"bee.cat,dog\", 1))",
2493
+ "output": "cat"
2494
+ },
2495
+ {
2496
+ "template": "@(word(\"bee.cat,dog\", 2))",
2497
+ "output": "dog"
2498
+ },
2499
+ {
2500
+ "template": "@(word(\"bee.cat,dog\", -1))",
2501
+ "output": "dog"
2502
+ },
2503
+ {
2504
+ "template": "@(word(\"bee.cat,dog\", -2))",
2505
+ "output": "cat"
2506
+ },
2507
+ {
2508
+ "template": "@(word(\"bee.*cat,dog\", 1, \".*=|\"))",
2509
+ "output": "cat,dog"
2510
+ },
2511
+ {
2512
+ "template": "@(word(\"O'Grady O'Flaggerty\", 1, \" \"))",
2513
+ "output": "O'Flaggerty"
2514
+ }
2515
+ ]
2516
+ },
2517
+ {
2518
+ "signature": "word_count(text [,delimiters])",
2519
+ "summary": "Returns the number of words in `text`.",
2520
+ "detail": "There is an optional final parameter `delimiters` which is string of characters used\nto split the text into words.",
2521
+ "examples": [
2522
+ {
2523
+ "template": "@(word_count(\"foo bar\"))",
2524
+ "output": "2"
2525
+ },
2526
+ {
2527
+ "template": "@(word_count(10))",
2528
+ "output": "1"
2529
+ },
2530
+ {
2531
+ "template": "@(word_count(\"\"))",
2532
+ "output": "0"
2533
+ },
2534
+ {
2535
+ "template": "@(word_count(\"😀😃😄😁\"))",
2536
+ "output": "4"
2537
+ },
2538
+ {
2539
+ "template": "@(word_count(\"bee.*cat,dog\", \".*=|\"))",
2540
+ "output": "2"
2541
+ },
2542
+ {
2543
+ "template": "@(word_count(\"O'Grady O'Flaggerty\", \" \"))",
2544
+ "output": "2"
2545
+ }
2546
+ ]
2547
+ },
2548
+ {
2549
+ "signature": "word_slice(text, start, end [,delimiters])",
2550
+ "summary": "Extracts a sub-sequence of words from `text`.",
2551
+ "detail": "The returned words are those from `start` up to but not-including `end`. Indexes start at zero and a negative\nend value means that all words after the start should be returned. There is an optional final parameter `delimiters`\nwhich is string of characters used to split the text into words.",
2552
+ "examples": [
2553
+ {
2554
+ "template": "@(word_slice(\"bee cat dog\", 0, 1))",
2555
+ "output": "bee"
2556
+ },
2557
+ {
2558
+ "template": "@(word_slice(\"bee cat dog\", 0, 2))",
2559
+ "output": "bee cat"
2560
+ },
2561
+ {
2562
+ "template": "@(word_slice(\"bee cat dog\", 1, -1))",
2563
+ "output": "cat dog"
2564
+ },
2565
+ {
2566
+ "template": "@(word_slice(\"bee cat dog\", 1))",
2567
+ "output": "cat dog"
2568
+ },
2569
+ {
2570
+ "template": "@(word_slice(\"bee cat dog\", 2, 3))",
2571
+ "output": "dog"
2572
+ },
2573
+ {
2574
+ "template": "@(word_slice(\"bee cat dog\", 3, 10))",
2575
+ "output": ""
2576
+ },
2577
+ {
2578
+ "template": "@(word_slice(\"bee.*cat,dog\", 1, -1, \".*=|,\"))",
2579
+ "output": "cat dog"
2580
+ },
2581
+ {
2582
+ "template": "@(word_slice(\"O'Grady O'Flaggerty\", 1, 2, \" \"))",
2583
+ "output": "O'Flaggerty"
2584
+ }
2585
+ ]
2586
+ }
2587
+ ]
2588
+ }