@xano/xanoscript-language-server 11.0.3

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 (716) hide show
  1. package/.claude/settings.local.json +27 -0
  2. package/.github/copilot-instructions.md +190 -0
  3. package/.github/workflows/ci.yml +31 -0
  4. package/.husky/pre-commit +1 -0
  5. package/CLAUDE.md +121 -0
  6. package/LICENSE +21 -0
  7. package/README.md +55 -0
  8. package/connection.js +7 -0
  9. package/documents.js +5 -0
  10. package/embedded/README.md +102 -0
  11. package/embedded/embeddedContent.js +74 -0
  12. package/embedded/embeddedDocuments.js +57 -0
  13. package/embedded/jsLanguageService.js +74 -0
  14. package/eslint.config.js +24 -0
  15. package/language-server-worker.js +52 -0
  16. package/lexer/action.js +31 -0
  17. package/lexer/addon.js +31 -0
  18. package/lexer/agent.js +37 -0
  19. package/lexer/agent_trigger.js +42 -0
  20. package/lexer/ai.js +82 -0
  21. package/lexer/api.js +81 -0
  22. package/lexer/api_group.js +58 -0
  23. package/lexer/arrays.js +161 -0
  24. package/lexer/branch.js +31 -0
  25. package/lexer/cast.js +105 -0
  26. package/lexer/cloud.js +159 -0
  27. package/lexer/columns.js +234 -0
  28. package/lexer/comment.js +61 -0
  29. package/lexer/comment.spec.js +77 -0
  30. package/lexer/control.js +634 -0
  31. package/lexer/db.js +190 -0
  32. package/lexer/debug.js +37 -0
  33. package/lexer/expect.js +157 -0
  34. package/lexer/function.js +36 -0
  35. package/lexer/identifier.js +6 -0
  36. package/lexer/lexer.js +26 -0
  37. package/lexer/literal.js +77 -0
  38. package/lexer/math.js +97 -0
  39. package/lexer/mcp_server.js +51 -0
  40. package/lexer/mcp_server_trigger.js +42 -0
  41. package/lexer/middleware.js +42 -0
  42. package/lexer/multiline.js +24 -0
  43. package/lexer/multiline.spec.js +179 -0
  44. package/lexer/object.js +44 -0
  45. package/lexer/query.js +99 -0
  46. package/lexer/realtime_trigger.js +50 -0
  47. package/lexer/redis.js +145 -0
  48. package/lexer/security.js +161 -0
  49. package/lexer/storage.js +99 -0
  50. package/lexer/stream.js +49 -0
  51. package/lexer/table.js +38 -0
  52. package/lexer/table_trigger.js +50 -0
  53. package/lexer/task.js +83 -0
  54. package/lexer/tests/query/query_lexer.spec.js +36 -0
  55. package/lexer/tests/query/valid_sources/basic_query.xs +44 -0
  56. package/lexer/tests/query/valid_sources/db_query.xs +77 -0
  57. package/lexer/tests/query/valid_sources/empty_query.xs +5 -0
  58. package/lexer/tests/query/valid_sources/header_query.xs +15 -0
  59. package/lexer/tests/table/basic_table.xs +17 -0
  60. package/lexer/tests/table/empty_table.xs +3 -0
  61. package/lexer/tests/table/table_lexer.spec.js +324 -0
  62. package/lexer/text.js +114 -0
  63. package/lexer/tokens.js +526 -0
  64. package/lexer/tool.js +39 -0
  65. package/lexer/util.js +113 -0
  66. package/lexer/utils.js +56 -0
  67. package/lexer/utils.spec.js +61 -0
  68. package/lexer/var.js +30 -0
  69. package/lexer/variables.js +217 -0
  70. package/lexer/workflow_test.js +42 -0
  71. package/lexer/workspace.js +23 -0
  72. package/lexer/workspace_trigger.js +42 -0
  73. package/lexer/zip.js +63 -0
  74. package/logic-assistant-script.js +8 -0
  75. package/onCheckError/onCheckError.js +43 -0
  76. package/onCompletion/contentAssist.js +183 -0
  77. package/onCompletion/contentAssist.spec.js +275 -0
  78. package/onCompletion/onCompletion.js +38 -0
  79. package/onDidChangeContent/onDidChangeContent.js +128 -0
  80. package/onHover/FilterMessageProvider.js +102 -0
  81. package/onHover/FilterMessageProvider.spec.js +85 -0
  82. package/onHover/FunctionMessageProvider.js +122 -0
  83. package/onHover/FunctionMessageProvider.spec.js +128 -0
  84. package/onHover/HoverMessageProvider.js +31 -0
  85. package/onHover/InputFilterMessageProvider.js +140 -0
  86. package/onHover/InputFilterMessageProvider.spec.js +329 -0
  87. package/onHover/InputVariableMessageProvider.js +55 -0
  88. package/onHover/QueryFilterMessageProvider.spec.js +164 -0
  89. package/onHover/filters.md +2852 -0
  90. package/onHover/functions.md +2617 -0
  91. package/onHover/inputFilters.md +271 -0
  92. package/onHover/onHover.js +40 -0
  93. package/onHover/onHoverDocument.js +64 -0
  94. package/onHover/onHoverDocument.spec.js +486 -0
  95. package/onHover/queryFilterMessageProvider.js +122 -0
  96. package/onHover/queryFilters.md +489 -0
  97. package/onSemanticCheck/highlight.js +45 -0
  98. package/onSemanticCheck/onSemanticCheck.js +25 -0
  99. package/onSemanticCheck/tokens.js +40 -0
  100. package/package.json +48 -0
  101. package/parser/addon_parser.js +90 -0
  102. package/parser/addon_parser.spec.js +88 -0
  103. package/parser/agent_parser.js +281 -0
  104. package/parser/agent_parser.spec.js +599 -0
  105. package/parser/agent_trigger_parser.js +138 -0
  106. package/parser/agent_trigger_parser.spec.js +525 -0
  107. package/parser/api_group_parser.js +143 -0
  108. package/parser/api_group_parser.spec.js +127 -0
  109. package/parser/attributes/columnDefaultValueAttribute.js +33 -0
  110. package/parser/attributes/columnDefaultValueAttribute.spec.js +49 -0
  111. package/parser/attributes/descriptionFieldAttribute.js +24 -0
  112. package/parser/attributes/descriptionFieldAttribute.spec.js +39 -0
  113. package/parser/attributes/disabledFieldAttribute.js +19 -0
  114. package/parser/attributes/disabledFieldAttribute.spec.js +34 -0
  115. package/parser/attributes/docsFieldAttribute.js +24 -0
  116. package/parser/attributes/docsFieldAttribute.spec.js +39 -0
  117. package/parser/attributes/inputFilterFn.js +71 -0
  118. package/parser/attributes/inputFilterFn.spec.js +39 -0
  119. package/parser/attributes/register.js +41 -0
  120. package/parser/attributes/sensitiveFieldAttribute.js +17 -0
  121. package/parser/attributes/sensitiveFieldAttribute.spec.js +39 -0
  122. package/parser/attributes/valueFieldAttribute.js +17 -0
  123. package/parser/attributes/valueFieldAttribute.spec.js +54 -0
  124. package/parser/attributes/valuesFieldAttribute.js +18 -0
  125. package/parser/attributes/valuesFieldAttribute.spec.js +44 -0
  126. package/parser/base_parser.js +249 -0
  127. package/parser/branch_parser.js +49 -0
  128. package/parser/branch_parser.spec.js +34 -0
  129. package/parser/clauses/agentClause.js +23 -0
  130. package/parser/clauses/agentClause.spec.js +34 -0
  131. package/parser/clauses/authClause.js +17 -0
  132. package/parser/clauses/authClause.spec.js +39 -0
  133. package/parser/clauses/cacheClause.js +32 -0
  134. package/parser/clauses/cacheClause.spec.js +103 -0
  135. package/parser/clauses/canonicalClause.js +23 -0
  136. package/parser/clauses/canonicalClause.spec.js +34 -0
  137. package/parser/clauses/channelClause.js +23 -0
  138. package/parser/clauses/channelClause.spec.js +34 -0
  139. package/parser/clauses/dbTableClause.js +23 -0
  140. package/parser/clauses/dbTableClause.spec.js +34 -0
  141. package/parser/clauses/flexibleStringClause.js +43 -0
  142. package/parser/clauses/historyClause.js +19 -0
  143. package/parser/clauses/historyClause.spec.js +53 -0
  144. package/parser/clauses/indexClause.js +36 -0
  145. package/parser/clauses/indexClause.spec.js +47 -0
  146. package/parser/clauses/inputClause.js +35 -0
  147. package/parser/clauses/inputClause.spec.js +79 -0
  148. package/parser/clauses/mcpServerClause.js +23 -0
  149. package/parser/clauses/mcpServerClause.spec.js +34 -0
  150. package/parser/clauses/middlewareClause.js +39 -0
  151. package/parser/clauses/middlewareClause.spec.js +161 -0
  152. package/parser/clauses/nakedStackFn.js +69 -0
  153. package/parser/clauses/nakedStackFn.spec.js +63 -0
  154. package/parser/clauses/outputClause.js +33 -0
  155. package/parser/clauses/register.js +50 -0
  156. package/parser/clauses/responseClause.js +17 -0
  157. package/parser/clauses/responseClause.spec.js +42 -0
  158. package/parser/clauses/scheduleClause.js +37 -0
  159. package/parser/clauses/scheduleClause.spec.js +71 -0
  160. package/parser/clauses/schemaClause.js +66 -0
  161. package/parser/clauses/schemaClause.spec.js +66 -0
  162. package/parser/clauses/stackClause.js +16 -0
  163. package/parser/clauses/testClause.js +73 -0
  164. package/parser/clauses/testClause.spec.js +78 -0
  165. package/parser/clauses/viewClause.js +49 -0
  166. package/parser/clauses/viewClause.spec.js +154 -0
  167. package/parser/definitions/arraySlice.js +70 -0
  168. package/parser/definitions/arraySlice.spec.js +49 -0
  169. package/parser/definitions/columnDefinition.js +139 -0
  170. package/parser/definitions/columnDefinition.spec.js +199 -0
  171. package/parser/definitions/dbLinkColumnDefinition.js +24 -0
  172. package/parser/definitions/dbLinkColumnDefinition.spec.js +45 -0
  173. package/parser/definitions/enumColumnDefinition.js +55 -0
  174. package/parser/definitions/enumColumnDefinition.spec.js +108 -0
  175. package/parser/definitions/filterDefinition.js +23 -0
  176. package/parser/definitions/filterDefinition.spec.js +43 -0
  177. package/parser/definitions/objectColumnDefinition.js +52 -0
  178. package/parser/definitions/objectColumnDefinition.spec.js +118 -0
  179. package/parser/definitions/register.js +28 -0
  180. package/parser/function_parser.js +123 -0
  181. package/parser/function_parser.spec.js +83 -0
  182. package/parser/functions/actionCallFn.js +41 -0
  183. package/parser/functions/actionCallFn.spec.js +51 -0
  184. package/parser/functions/addonCallFn.js +39 -0
  185. package/parser/functions/addonCallFn.spec.js +41 -0
  186. package/parser/functions/ai/aiAgentRunFn.js +40 -0
  187. package/parser/functions/ai/aiAgentRunFn.spec.js +94 -0
  188. package/parser/functions/ai/aiExternalMcpServerDetailsFn.js +28 -0
  189. package/parser/functions/ai/aiExternalMcpServerDetailsFn.spec.js +85 -0
  190. package/parser/functions/ai/aiExternalMcpToolListFn.js +28 -0
  191. package/parser/functions/ai/aiExternalMcpToolListFn.spec.js +85 -0
  192. package/parser/functions/ai/aiExternalMcpToolRunFn.js +30 -0
  193. package/parser/functions/ai/aiExternalMcpToolRunFn.spec.js +101 -0
  194. package/parser/functions/ai/register.js +24 -0
  195. package/parser/functions/aiFn.js +61 -0
  196. package/parser/functions/aiFn.spec.js +51 -0
  197. package/parser/functions/api/apiCallFn.js +49 -0
  198. package/parser/functions/api/apiCallFn.spec.js +60 -0
  199. package/parser/functions/api/apiLambdaFn.js +19 -0
  200. package/parser/functions/api/apiLambdaFn.spec.js +63 -0
  201. package/parser/functions/api/apiRealtimeEventFn.js +25 -0
  202. package/parser/functions/api/apiRealtimeEventFn.spec.js +82 -0
  203. package/parser/functions/api/apiRequestFn.js +47 -0
  204. package/parser/functions/api/apiRequestFn.spec.js +113 -0
  205. package/parser/functions/api/apiStreamFn.js +22 -0
  206. package/parser/functions/api/apiStreamFn.spec.js +44 -0
  207. package/parser/functions/api/register.js +19 -0
  208. package/parser/functions/api/webflowRequestFn.js +47 -0
  209. package/parser/functions/api/webflowRequestFn.spec.js +114 -0
  210. package/parser/functions/apiFn.js +24 -0
  211. package/parser/functions/array/arrayDifferenceFn.js +37 -0
  212. package/parser/functions/array/arrayDifferenceFn.spec.js +34 -0
  213. package/parser/functions/array/arrayEveryFn.js +13 -0
  214. package/parser/functions/array/arrayFilterCountFn.js +14 -0
  215. package/parser/functions/array/arrayFilterFn.js +14 -0
  216. package/parser/functions/array/arrayFindFn.js +14 -0
  217. package/parser/functions/array/arrayFindFn.spec.js +44 -0
  218. package/parser/functions/array/arrayFindIndexFn.js +14 -0
  219. package/parser/functions/array/arrayGroupByFn.js +36 -0
  220. package/parser/functions/array/arrayGroupByFn.spec.js +41 -0
  221. package/parser/functions/array/arrayHasFn.js +14 -0
  222. package/parser/functions/array/arrayIntersectionFn.js +37 -0
  223. package/parser/functions/array/arrayIntersectionFn.spec.js +22 -0
  224. package/parser/functions/array/arrayMapFn.js +36 -0
  225. package/parser/functions/array/arrayMapFn.spec.js +37 -0
  226. package/parser/functions/array/arrayMergeFn.js +17 -0
  227. package/parser/functions/array/arrayNoValueAs.js +31 -0
  228. package/parser/functions/array/arrayNoValueAs.spec.js +56 -0
  229. package/parser/functions/array/arrayPartitionFn.js +19 -0
  230. package/parser/functions/array/arrayPartitionFn.spec.js +29 -0
  231. package/parser/functions/array/arrayPopFn.js +17 -0
  232. package/parser/functions/array/arrayPushFn.js +14 -0
  233. package/parser/functions/array/arrayShiftFn.js +15 -0
  234. package/parser/functions/array/arrayUnionFn.js +37 -0
  235. package/parser/functions/array/arrayUnionFn.spec.js +22 -0
  236. package/parser/functions/array/arrayUnshiftFn.js +14 -0
  237. package/parser/functions/array/arrayValueIfAs.js +51 -0
  238. package/parser/functions/array/arrayValueIfAs.spec.js +54 -0
  239. package/parser/functions/array/arrayValueOnly.js +40 -0
  240. package/parser/functions/array/arrayValueOnly.spec.js +61 -0
  241. package/parser/functions/array/register.js +49 -0
  242. package/parser/functions/array/valueAttrOnly.js +47 -0
  243. package/parser/functions/array/valueAttrOnly.spec.js +61 -0
  244. package/parser/functions/arrayFn.js +33 -0
  245. package/parser/functions/cloud/cloudAlgoliaFn.js +18 -0
  246. package/parser/functions/cloud/cloudAlgoliaRequestFn.js +26 -0
  247. package/parser/functions/cloud/cloudAlgoliaRequestFn.spec.js +30 -0
  248. package/parser/functions/cloud/cloudAwsFn.js +19 -0
  249. package/parser/functions/cloud/cloudAwsOpenSearchFn.js +19 -0
  250. package/parser/functions/cloud/cloudAwsS3Fn.js +22 -0
  251. package/parser/functions/cloud/cloudAwsS3Fn.spec.js +21 -0
  252. package/parser/functions/cloud/cloudAzureFn.js +18 -0
  253. package/parser/functions/cloud/cloudDeleteFileFn.js +23 -0
  254. package/parser/functions/cloud/cloudDeleteFileFn.spec.js +25 -0
  255. package/parser/functions/cloud/cloudElasticSearchFn.js +19 -0
  256. package/parser/functions/cloud/cloudGetFileInfoFn.js +24 -0
  257. package/parser/functions/cloud/cloudGetFileInfoFn.spec.js +25 -0
  258. package/parser/functions/cloud/cloudGoogleFn.js +18 -0
  259. package/parser/functions/cloud/cloudListDirectoryFn.js +24 -0
  260. package/parser/functions/cloud/cloudListDirectoryFn.spec.js +26 -0
  261. package/parser/functions/cloud/cloudReadFileFn.js +24 -0
  262. package/parser/functions/cloud/cloudReadFileFn.spec.js +25 -0
  263. package/parser/functions/cloud/cloudSearchDocumentFn.js +24 -0
  264. package/parser/functions/cloud/cloudSearchDocumentFn.spec.js +28 -0
  265. package/parser/functions/cloud/cloudSearchQueryFn.js +24 -0
  266. package/parser/functions/cloud/cloudSearchQueryFn.spec.js +32 -0
  267. package/parser/functions/cloud/cloudSearchRequestFn.js +24 -0
  268. package/parser/functions/cloud/cloudSearchRequestFn.spec.js +32 -0
  269. package/parser/functions/cloud/cloudSignUrlFn.js +24 -0
  270. package/parser/functions/cloud/cloudSignUrlFn.spec.js +26 -0
  271. package/parser/functions/cloud/cloudStorageFn.js +23 -0
  272. package/parser/functions/cloud/cloudStorageFn.spec.js +21 -0
  273. package/parser/functions/cloud/cloudUploadFileFn.js +24 -0
  274. package/parser/functions/cloud/cloudUploadFileFn.spec.js +29 -0
  275. package/parser/functions/cloud/register.js +61 -0
  276. package/parser/functions/cloudFn.js +21 -0
  277. package/parser/functions/controlFn.js +34 -0
  278. package/parser/functions/controls/awaitFn.js +21 -0
  279. package/parser/functions/controls/awaitFn.spec.js +48 -0
  280. package/parser/functions/controls/conditionalElifFn.js +19 -0
  281. package/parser/functions/controls/conditionalElseFn.js +13 -0
  282. package/parser/functions/controls/conditionalFn.js +62 -0
  283. package/parser/functions/controls/conditionalFn.spec.js +167 -0
  284. package/parser/functions/controls/conditionalIfFn.js +19 -0
  285. package/parser/functions/controls/forEachFn.js +70 -0
  286. package/parser/functions/controls/forEachFn.spec.js +101 -0
  287. package/parser/functions/controls/forFn.js +55 -0
  288. package/parser/functions/controls/forFn.spec.js +85 -0
  289. package/parser/functions/controls/functionCallFn.js +38 -0
  290. package/parser/functions/controls/functionRunFn.js +40 -0
  291. package/parser/functions/controls/functionRunFn.spec.js +77 -0
  292. package/parser/functions/controls/groupFn.js +42 -0
  293. package/parser/functions/controls/groupFn.spec.js +63 -0
  294. package/parser/functions/controls/preconditionFn.js +40 -0
  295. package/parser/functions/controls/preconditionFn.spec.js +97 -0
  296. package/parser/functions/controls/register.js +45 -0
  297. package/parser/functions/controls/returnFn.js +21 -0
  298. package/parser/functions/controls/returnFn.spec.js +44 -0
  299. package/parser/functions/controls/switchCaseFn.js +22 -0
  300. package/parser/functions/controls/switchDefaultFn.js +13 -0
  301. package/parser/functions/controls/switchFn.js +50 -0
  302. package/parser/functions/controls/switchFn.spec.js +104 -0
  303. package/parser/functions/controls/taskCallFn.js +31 -0
  304. package/parser/functions/controls/throwFn.js +21 -0
  305. package/parser/functions/controls/throwFn.spec.js +56 -0
  306. package/parser/functions/controls/tryCatchFn.js +67 -0
  307. package/parser/functions/controls/tryCatchFn.spec.js +180 -0
  308. package/parser/functions/controls/whileFn.js +52 -0
  309. package/parser/functions/controls/whileFn.spec.js +94 -0
  310. package/parser/functions/db/dbAddFn.js +38 -0
  311. package/parser/functions/db/dbAddFn.spec.js +72 -0
  312. package/parser/functions/db/dbAddOrEditFn.js +39 -0
  313. package/parser/functions/db/dbAddOrEditFn.spec.js +97 -0
  314. package/parser/functions/db/dbAddonAttr.js +17 -0
  315. package/parser/functions/db/dbBulkAddFn.js +54 -0
  316. package/parser/functions/db/dbBulkAddFn.spec.js +94 -0
  317. package/parser/functions/db/dbBulkDeleteFn.js +35 -0
  318. package/parser/functions/db/dbBulkDeleteFn.spec.js +28 -0
  319. package/parser/functions/db/dbBulkFn.js +20 -0
  320. package/parser/functions/db/dbBulkPatchFn.js +35 -0
  321. package/parser/functions/db/dbBulkPatchFn.spec.js +42 -0
  322. package/parser/functions/db/dbBulkUpdateFn.js +35 -0
  323. package/parser/functions/db/dbBulkUpdateFn.spec.js +42 -0
  324. package/parser/functions/db/dbDelFn.js +34 -0
  325. package/parser/functions/db/dbDelFn.spec.js +62 -0
  326. package/parser/functions/db/dbDirectQueryFn.js +37 -0
  327. package/parser/functions/db/dbDirectQueryFn.spec.js +104 -0
  328. package/parser/functions/db/dbEditFn.js +40 -0
  329. package/parser/functions/db/dbEditFn.spec.js +122 -0
  330. package/parser/functions/db/dbExternalDirectQueryFn.js +29 -0
  331. package/parser/functions/db/dbExternalDirectQueryFn.spec.js +103 -0
  332. package/parser/functions/db/dbExternalFn.js +29 -0
  333. package/parser/functions/db/dbGetFn.js +40 -0
  334. package/parser/functions/db/dbGetFn.spec.js +117 -0
  335. package/parser/functions/db/dbHasFn.js +34 -0
  336. package/parser/functions/db/dbHasFn.spec.js +62 -0
  337. package/parser/functions/db/dbPatchFn.js +39 -0
  338. package/parser/functions/db/dbPatchFn.spec.js +88 -0
  339. package/parser/functions/db/dbQueryFn.js +73 -0
  340. package/parser/functions/db/dbQueryFn.spec.js +333 -0
  341. package/parser/functions/db/dbSchemaFn.js +25 -0
  342. package/parser/functions/db/dbSchemaFn.spec.js +42 -0
  343. package/parser/functions/db/dbSetDatasourceFn.js +18 -0
  344. package/parser/functions/db/dbSetDatasourceFn.spec.js +44 -0
  345. package/parser/functions/db/dbTransactionFn.js +43 -0
  346. package/parser/functions/db/dbTransactionFn.spec.js +63 -0
  347. package/parser/functions/db/dbTruncateFn.js +33 -0
  348. package/parser/functions/db/dbTruncateFn.spec.js +42 -0
  349. package/parser/functions/db/register.js +52 -0
  350. package/parser/functions/db/schema.js +8 -0
  351. package/parser/functions/dbFn.js +31 -0
  352. package/parser/functions/debug/debugLogFn.js +21 -0
  353. package/parser/functions/debug/debugLogFn.spec.js +44 -0
  354. package/parser/functions/debug/debugStopFn.js +21 -0
  355. package/parser/functions/debug/debugStopFn.spec.js +44 -0
  356. package/parser/functions/debug/register.js +11 -0
  357. package/parser/functions/debugFn.js +18 -0
  358. package/parser/functions/expect/register.js +44 -0
  359. package/parser/functions/expect/unitExpectToBeWithinFn.js +28 -0
  360. package/parser/functions/expect/unitExpectToBeWithinFn.spec.js +61 -0
  361. package/parser/functions/expect/unitExpectToThrowFn.js +15 -0
  362. package/parser/functions/expect/unitExpectToThrowFn.spec.js +40 -0
  363. package/parser/functions/expect/unitExpectWithArgumentsFn.js +49 -0
  364. package/parser/functions/expect/unitExpectWithArgumentsFn.spec.js +341 -0
  365. package/parser/functions/expect/unitExpectWithoutArgumentsFn.js +42 -0
  366. package/parser/functions/expect/unitExpectWithoutArgumentsFn.spec.js +69 -0
  367. package/parser/functions/expect/workflowExpectToBeWithinFn.js +22 -0
  368. package/parser/functions/expect/workflowExpectToBeWithinFn.spec.js +70 -0
  369. package/parser/functions/expect/workflowExpectToThrowFn.js +21 -0
  370. package/parser/functions/expect/workflowExpectToThrowFn.spec.js +56 -0
  371. package/parser/functions/expect/workflowExpectWithArgumentsFn.js +40 -0
  372. package/parser/functions/expect/workflowExpectWithArgumentsFn.spec.js +301 -0
  373. package/parser/functions/expect/workflowExpectWithoutArgumentsFn.js +39 -0
  374. package/parser/functions/expect/workflowExpectWithoutArgumentsFn.spec.js +87 -0
  375. package/parser/functions/math/allMathFn.js +64 -0
  376. package/parser/functions/math/allMathFn.spec.js +100 -0
  377. package/parser/functions/math/register.js +9 -0
  378. package/parser/functions/mathFn.js +15 -0
  379. package/parser/functions/middlewareCallFn.js +43 -0
  380. package/parser/functions/middlewareCallFn.spec.js +44 -0
  381. package/parser/functions/object/objectEntriesFn.js +22 -0
  382. package/parser/functions/object/objectEntriesFn.spec.js +44 -0
  383. package/parser/functions/object/objectKeysFn.js +22 -0
  384. package/parser/functions/object/objectKeysFn.spec.js +44 -0
  385. package/parser/functions/object/objectValuesFn.js +22 -0
  386. package/parser/functions/object/objectValuesFn.spec.js +44 -0
  387. package/parser/functions/object/register.js +13 -0
  388. package/parser/functions/objectFn.js +22 -0
  389. package/parser/functions/redis/redisCountFn.js +26 -0
  390. package/parser/functions/redis/redisCountFn.spec.js +58 -0
  391. package/parser/functions/redis/redisDecrFn.js +28 -0
  392. package/parser/functions/redis/redisDecrFn.spec.js +47 -0
  393. package/parser/functions/redis/redisDelFn.js +25 -0
  394. package/parser/functions/redis/redisDelFn.spec.js +58 -0
  395. package/parser/functions/redis/redisGetFn.js +26 -0
  396. package/parser/functions/redis/redisGetFn.spec.js +67 -0
  397. package/parser/functions/redis/redisHasFn.js +26 -0
  398. package/parser/functions/redis/redisHasFn.spec.js +58 -0
  399. package/parser/functions/redis/redisIncrFn.js +28 -0
  400. package/parser/functions/redis/redisIncrFn.spec.js +74 -0
  401. package/parser/functions/redis/redisKeysFn.js +26 -0
  402. package/parser/functions/redis/redisKeysFn.spec.js +67 -0
  403. package/parser/functions/redis/redisPopFn.js +26 -0
  404. package/parser/functions/redis/redisPopFn.spec.js +67 -0
  405. package/parser/functions/redis/redisPushFn.js +28 -0
  406. package/parser/functions/redis/redisPushFn.spec.js +71 -0
  407. package/parser/functions/redis/redisRangeFn.js +30 -0
  408. package/parser/functions/redis/redisRangeFn.spec.js +80 -0
  409. package/parser/functions/redis/redisRateLimitFn.js +32 -0
  410. package/parser/functions/redis/redisRateLimitFn.spec.js +87 -0
  411. package/parser/functions/redis/redisRemoveFn.js +29 -0
  412. package/parser/functions/redis/redisRemoveFn.spec.js +65 -0
  413. package/parser/functions/redis/redisSetFn.js +29 -0
  414. package/parser/functions/redis/redisSetFn.spec.js +89 -0
  415. package/parser/functions/redis/redisShiftFn.js +26 -0
  416. package/parser/functions/redis/redisShiftFn.spec.js +67 -0
  417. package/parser/functions/redis/redisUnshiftFn.js +28 -0
  418. package/parser/functions/redis/redisUnshiftFn.spec.js +73 -0
  419. package/parser/functions/redis/register.js +37 -0
  420. package/parser/functions/redisFn.js +31 -0
  421. package/parser/functions/register.js +91 -0
  422. package/parser/functions/schema/register.js +30 -0
  423. package/parser/functions/schema/schemaFn.js +173 -0
  424. package/parser/functions/schema/schemaFn.spec.js +92 -0
  425. package/parser/functions/schema/schemaParseArrayFn.js +47 -0
  426. package/parser/functions/schema/schemaParseArrayFn.spec.js +134 -0
  427. package/parser/functions/schema/schemaParseAttributeFn.js +194 -0
  428. package/parser/functions/schema/schemaParseAttributeFn.spec.js +281 -0
  429. package/parser/functions/schema/schemaParseConstantFn.js +136 -0
  430. package/parser/functions/schema/schemaParseConstantFn.spec.js +122 -0
  431. package/parser/functions/schema/schemaParseEnum.js +52 -0
  432. package/parser/functions/schema/schemaParseEnum.spec.js +47 -0
  433. package/parser/functions/schema/schemaParseImmutableFn.js +134 -0
  434. package/parser/functions/schema/schemaParseImmutableFn.spec.js +99 -0
  435. package/parser/functions/schema/schemaParseObjectFn.js +171 -0
  436. package/parser/functions/schema/schemaParseObjectFn.spec.js +223 -0
  437. package/parser/functions/schema/utils.js +136 -0
  438. package/parser/functions/schema/utils.spec.js +27 -0
  439. package/parser/functions/security/register.js +64 -0
  440. package/parser/functions/security/securityCheckPasswordFn.js +24 -0
  441. package/parser/functions/security/securityCheckPasswordFn.spec.js +22 -0
  442. package/parser/functions/security/securityCreateAuthTokenFn.js +24 -0
  443. package/parser/functions/security/securityCreateAuthTokenFn.spec.js +24 -0
  444. package/parser/functions/security/securityCreateCurveKeyFn.js +19 -0
  445. package/parser/functions/security/securityCreateCurveKeyFn.spec.js +22 -0
  446. package/parser/functions/security/securityCreatePasswordFn.js +26 -0
  447. package/parser/functions/security/securityCreatePasswordFn.spec.js +26 -0
  448. package/parser/functions/security/securityCreateRsaKeyFn.js +19 -0
  449. package/parser/functions/security/securityCreateRsaKeyFn.spec.js +22 -0
  450. package/parser/functions/security/securityCreateSecretKeyFn.js +24 -0
  451. package/parser/functions/security/securityCreateSecretKeyFn.spec.js +22 -0
  452. package/parser/functions/security/securityCreateUuidFn.js +26 -0
  453. package/parser/functions/security/securityCreateUuidFn.spec.js +27 -0
  454. package/parser/functions/security/securityDecryptFn.js +24 -0
  455. package/parser/functions/security/securityDecryptFn.spec.js +24 -0
  456. package/parser/functions/security/securityEncryptFn.js +24 -0
  457. package/parser/functions/security/securityEncryptFn.spec.js +24 -0
  458. package/parser/functions/security/securityJweDecodeFn.js +24 -0
  459. package/parser/functions/security/securityJweDecodeFn.spec.js +26 -0
  460. package/parser/functions/security/securityJweEncodeFn.js +24 -0
  461. package/parser/functions/security/securityJweEncodeFn.spec.js +26 -0
  462. package/parser/functions/security/securityJwsDecodeFn.js +24 -0
  463. package/parser/functions/security/securityJwsDecodeFn.spec.js +25 -0
  464. package/parser/functions/security/securityJwsEncodeFn.js +24 -0
  465. package/parser/functions/security/securityJwsEncodeFn.spec.js +25 -0
  466. package/parser/functions/security/securityRandomBytesFn.js +24 -0
  467. package/parser/functions/security/securityRandomBytesFn.spec.js +21 -0
  468. package/parser/functions/security/securityRandomNumberFn.js +24 -0
  469. package/parser/functions/security/securityRandomNumberFn.spec.js +22 -0
  470. package/parser/functions/securityFn.js +30 -0
  471. package/parser/functions/storage/register.js +44 -0
  472. package/parser/functions/storage/storageCreateAttachmentFn.js +25 -0
  473. package/parser/functions/storage/storageCreateAttachmentFn.spec.js +87 -0
  474. package/parser/functions/storage/storageCreateAudioFn.js +29 -0
  475. package/parser/functions/storage/storageCreateAudioFn.spec.js +98 -0
  476. package/parser/functions/storage/storageCreateFileResourceFn.js +19 -0
  477. package/parser/functions/storage/storageCreateFileResourceFn.spec.js +72 -0
  478. package/parser/functions/storage/storageCreateImageFn.js +25 -0
  479. package/parser/functions/storage/storageCreateImageFn.spec.js +98 -0
  480. package/parser/functions/storage/storageCreateVideoFn.js +29 -0
  481. package/parser/functions/storage/storageCreateVideoFn.spec.js +99 -0
  482. package/parser/functions/storage/storageDeleteFileFn.js +17 -0
  483. package/parser/functions/storage/storageDeleteFileFn.spec.js +67 -0
  484. package/parser/functions/storage/storageReadFileResourceFn.js +19 -0
  485. package/parser/functions/storage/storageReadFileResourceFn.spec.js +60 -0
  486. package/parser/functions/storage/storageSignPrivateUrlFn.js +19 -0
  487. package/parser/functions/storage/storageSignPrivateUrlFn.spec.js +72 -0
  488. package/parser/functions/storageFn.js +24 -0
  489. package/parser/functions/stream/register.js +13 -0
  490. package/parser/functions/stream/streamFromCsvFn.js +20 -0
  491. package/parser/functions/stream/streamFromCsvFn.spec.js +69 -0
  492. package/parser/functions/stream/streamFromJsonlFn.js +21 -0
  493. package/parser/functions/stream/streamFromJsonlFn.spec.js +47 -0
  494. package/parser/functions/stream/streamFromRequestFn.js +50 -0
  495. package/parser/functions/stream/streamFromRequestFn.spec.js +103 -0
  496. package/parser/functions/streamFn.js +19 -0
  497. package/parser/functions/text/allTextWithReturnValueFn.js +36 -0
  498. package/parser/functions/text/allTextWithReturnValueFn.spec.js +100 -0
  499. package/parser/functions/text/allTextWithoutReturnValueFn.js +34 -0
  500. package/parser/functions/text/allTextWithoutReturnValueFn.spec.js +122 -0
  501. package/parser/functions/text/register.js +17 -0
  502. package/parser/functions/textFn.js +33 -0
  503. package/parser/functions/toolCallFn.js +40 -0
  504. package/parser/functions/toolCallFn.spec.js +28 -0
  505. package/parser/functions/unitExpectFn.js +20 -0
  506. package/parser/functions/unitExpectFn.spec.js +21 -0
  507. package/parser/functions/util/register.js +29 -0
  508. package/parser/functions/util/utilGeoDistanceFn.js +30 -0
  509. package/parser/functions/util/utilGeoDistanceFn.spec.js +79 -0
  510. package/parser/functions/util/utilGetAllInputFn.js +20 -0
  511. package/parser/functions/util/utilGetAllInputFn.spec.js +33 -0
  512. package/parser/functions/util/utilGetEnvFn.js +20 -0
  513. package/parser/functions/util/utilGetEnvFn.spec.js +33 -0
  514. package/parser/functions/util/utilGetRawInputFn.js +25 -0
  515. package/parser/functions/util/utilGetRawInputFn.spec.js +55 -0
  516. package/parser/functions/util/utilGetVarsFn.js +20 -0
  517. package/parser/functions/util/utilGetVarsFn.spec.js +33 -0
  518. package/parser/functions/util/utilIpLookupFn.js +22 -0
  519. package/parser/functions/util/utilIpLookupFn.spec.js +37 -0
  520. package/parser/functions/util/utilPostProcessFn.js +43 -0
  521. package/parser/functions/util/utilPostProcessFn.spec.js +63 -0
  522. package/parser/functions/util/utilSendEmailFn.js +108 -0
  523. package/parser/functions/util/utilSendEmailFn.spec.js +62 -0
  524. package/parser/functions/util/utilSetHeaderFn.js +22 -0
  525. package/parser/functions/util/utilSetHeaderFn.spec.js +48 -0
  526. package/parser/functions/util/utilSleepFn.js +19 -0
  527. package/parser/functions/util/utilSleepFn.spec.js +44 -0
  528. package/parser/functions/util/utilTemplateFn.js +19 -0
  529. package/parser/functions/util/utilTemplateFn.spec.js +78 -0
  530. package/parser/functions/utilFn.js +39 -0
  531. package/parser/functions/varFn.js +51 -0
  532. package/parser/functions/varFn.spec.js +173 -0
  533. package/parser/functions/webflowFn.js +19 -0
  534. package/parser/functions/workflowExpectFn.js +20 -0
  535. package/parser/functions/zip/register.js +20 -0
  536. package/parser/functions/zip/zipAddToArchiveFn.js +31 -0
  537. package/parser/functions/zip/zipAddToArchiveFn.spec.js +78 -0
  538. package/parser/functions/zip/zipCreateArchiveFn.js +29 -0
  539. package/parser/functions/zip/zipCreateArchiveFn.spec.js +53 -0
  540. package/parser/functions/zip/zipDeleteFromArchiveFn.js +23 -0
  541. package/parser/functions/zip/zipDeleteFromArchiveFn.spec.js +69 -0
  542. package/parser/functions/zip/zipExtractFn.js +23 -0
  543. package/parser/functions/zip/zipExtractFn.spec.js +52 -0
  544. package/parser/functions/zip/zipViewContentsFn.js +24 -0
  545. package/parser/functions/zip/zipViewContentsFn.spec.js +52 -0
  546. package/parser/functions/zipFn.js +21 -0
  547. package/parser/generic/arrayOfObjectAttrReq.js +47 -0
  548. package/parser/generic/arrayOfObjectAttrReq.spec.js +254 -0
  549. package/parser/generic/arrayOfStringLiterals.js +45 -0
  550. package/parser/generic/arrayOfStringLiterals.spec.js +56 -0
  551. package/parser/generic/arrayWithValues.js +35 -0
  552. package/parser/generic/arrayWithValues.spec.js +72 -0
  553. package/parser/generic/asVariable.js +23 -0
  554. package/parser/generic/asVariable.spec.js +37 -0
  555. package/parser/generic/assignableVariableAs.js +27 -0
  556. package/parser/generic/assignableVariableAs.spec.js +52 -0
  557. package/parser/generic/assignableVariableProperty.js +52 -0
  558. package/parser/generic/assignableVariableProperty.spec.js +52 -0
  559. package/parser/generic/booleanValue.js +22 -0
  560. package/parser/generic/bracketAccessor.js +53 -0
  561. package/parser/generic/castedValue.js +14 -0
  562. package/parser/generic/castedValue.spec.js +29 -0
  563. package/parser/generic/chainedIdentifier.js +48 -0
  564. package/parser/generic/chainedIdentifier.spec.js +89 -0
  565. package/parser/generic/completeAuthVariable.js +13 -0
  566. package/parser/generic/completeAuthVariable.spec.js +23 -0
  567. package/parser/generic/completeEnvVariable.js +79 -0
  568. package/parser/generic/completeEnvVariable.spec.js +94 -0
  569. package/parser/generic/completeErrorVariable.js +39 -0
  570. package/parser/generic/completeErrorVariable.spec.js +17 -0
  571. package/parser/generic/completeInputVariable.js +42 -0
  572. package/parser/generic/completeInputVariable.spec.js +53 -0
  573. package/parser/generic/enumValue.js +23 -0
  574. package/parser/generic/expressionFn.js +415 -0
  575. package/parser/generic/expressionFn.spec.js +588 -0
  576. package/parser/generic/filterFn.js +48 -0
  577. package/parser/generic/filterFn.spec.js +47 -0
  578. package/parser/generic/filterNames.js +381 -0
  579. package/parser/generic/functionAttrReq.js +279 -0
  580. package/parser/generic/functionAttrReq.spec.js +353 -0
  581. package/parser/generic/longFormVariable.js +46 -0
  582. package/parser/generic/longFormVariable.spec.js +25 -0
  583. package/parser/generic/minimalFnBody.js +24 -0
  584. package/parser/generic/minimalFnBody.spec.js +47 -0
  585. package/parser/generic/mockAttribute.js +21 -0
  586. package/parser/generic/mockAttribute.spec.js +57 -0
  587. package/parser/generic/multilineFilterFn.js +27 -0
  588. package/parser/generic/multilineFilterFn.spec.js +51 -0
  589. package/parser/generic/numberValue.js +27 -0
  590. package/parser/generic/objectAttrReq.js +243 -0
  591. package/parser/generic/objectAttrReq.spec.js +412 -0
  592. package/parser/generic/objectWithAttributes.js +74 -0
  593. package/parser/generic/objectWithAttributes.spec.js +147 -0
  594. package/parser/generic/optionalCommentBlock.js +32 -0
  595. package/parser/generic/pipedFilter.js +20 -0
  596. package/parser/generic/register.js +124 -0
  597. package/parser/generic/requiredValueFnBody.js +40 -0
  598. package/parser/generic/requiredValueFnBody.spec.js +56 -0
  599. package/parser/generic/shortFormVariable.js +17 -0
  600. package/parser/generic/shortFormVariable.spec.js +27 -0
  601. package/parser/generic/stringArray.js +33 -0
  602. package/parser/generic/stringArray.spec.js +55 -0
  603. package/parser/generic/tagsAttribute.js +14 -0
  604. package/parser/generic/tagsAttribute.spec.js +47 -0
  605. package/parser/generic/utils.js +14 -0
  606. package/parser/generic/valueExpressionForResponse.js +51 -0
  607. package/parser/generic/variableOnly.js +13 -0
  608. package/parser/generic/variableOnly.spec.js +47 -0
  609. package/parser/mcp_server_parser.js +130 -0
  610. package/parser/mcp_server_parser.spec.js +478 -0
  611. package/parser/mcp_server_trigger_parser.js +142 -0
  612. package/parser/mcp_server_trigger_parser.spec.js +396 -0
  613. package/parser/metadata/columnMetadataDefinition.js +32 -0
  614. package/parser/metadata/columnMetadataDefinition.spec.js +47 -0
  615. package/parser/metadata/enumColumnMetadataDefinition.js +46 -0
  616. package/parser/metadata/enumColumnMetadataDefinition.spec.js +59 -0
  617. package/parser/metadata/objectColumnMetadataDefinition.js +26 -0
  618. package/parser/metadata/register.js +22 -0
  619. package/parser/middleware_parser.js +137 -0
  620. package/parser/middleware_parser.spec.js +203 -0
  621. package/parser/parser.js +87 -0
  622. package/parser/query_parser.js +183 -0
  623. package/parser/query_parser.spec.js +141 -0
  624. package/parser/realtime_channel_parser.js +45 -0
  625. package/parser/realtime_channel_parser.spec.js +20 -0
  626. package/parser/realtime_trigger_parser.js +141 -0
  627. package/parser/realtime_trigger_parser.spec.js +469 -0
  628. package/parser/register.js +88 -0
  629. package/parser/table_parser.js +126 -0
  630. package/parser/table_parser.spec.js +138 -0
  631. package/parser/table_trigger_parser.js +144 -0
  632. package/parser/table_trigger_parser.spec.js +449 -0
  633. package/parser/task_parser.js +116 -0
  634. package/parser/task_parser.spec.js +83 -0
  635. package/parser/test_parser.js +39 -0
  636. package/parser/tests/agent/agent_parser.spec.js +52 -0
  637. package/parser/tests/agent/valid_sources/customer_servier_agent.xs +45 -0
  638. package/parser/tests/api_group/api_group_parser.spec.js +52 -0
  639. package/parser/tests/api_group/valid_sources/api_group_history.xs +4 -0
  640. package/parser/tests/api_group/valid_sources/basic_api_group.xs +3 -0
  641. package/parser/tests/api_group/valid_sources/complete_api_group.xs +7 -0
  642. package/parser/tests/api_group/valid_sources/protected_api_group.xs +7 -0
  643. package/parser/tests/function/function_parser.spec.js +52 -0
  644. package/parser/tests/function/valid_sources/all_controls.xs +68 -0
  645. package/parser/tests/function/valid_sources/all_query_return_types.xs +227 -0
  646. package/parser/tests/function/valid_sources/all_storage.xs +45 -0
  647. package/parser/tests/function/valid_sources/discord_poll_send_to_slack.xs +133 -0
  648. package/parser/tests/function/valid_sources/expression_in_response.xs +22 -0
  649. package/parser/tests/function/valid_sources/filter_by_value.xs +55 -0
  650. package/parser/tests/function/valid_sources/filter_query.xs +82 -0
  651. package/parser/tests/function/valid_sources/large_regex.xs +13 -0
  652. package/parser/tests/function/valid_sources/ledash_ends_with.xs +90 -0
  653. package/parser/tests/function/valid_sources/multiline_description.xs +28 -0
  654. package/parser/tests/function/valid_sources/multiline_expr.xs +41 -0
  655. package/parser/tests/function/valid_sources/set_theory_fn.xs +129 -0
  656. package/parser/tests/function/valid_sources/simple_unit_test.xs +33 -0
  657. package/parser/tests/function/valid_sources/valid_officer.xs +57 -0
  658. package/parser/tests/function/valid_sources/webflow.xs +18 -0
  659. package/parser/tests/query/query_parser.spec.js +54 -0
  660. package/parser/tests/query/valid_sources/all_basics.xs +51 -0
  661. package/parser/tests/query/valid_sources/all_cloud.xs +141 -0
  662. package/parser/tests/query/valid_sources/all_db.xs +102 -0
  663. package/parser/tests/query/valid_sources/all_external_db.xs +43 -0
  664. package/parser/tests/query/valid_sources/all_keywords.xs +65 -0
  665. package/parser/tests/query/valid_sources/all_math.xs +53 -0
  666. package/parser/tests/query/valid_sources/all_object.xs +25 -0
  667. package/parser/tests/query/valid_sources/all_redis.xs +106 -0
  668. package/parser/tests/query/valid_sources/all_security.xs +105 -0
  669. package/parser/tests/query/valid_sources/all_stream.xs +69 -0
  670. package/parser/tests/query/valid_sources/all_text.xs +54 -0
  671. package/parser/tests/query/valid_sources/all_util.xs +66 -0
  672. package/parser/tests/query/valid_sources/all_zip.xs +39 -0
  673. package/parser/tests/query/valid_sources/arrays.xs +33 -0
  674. package/parser/tests/query/valid_sources/disabled_response.xs +27 -0
  675. package/parser/tests/query/valid_sources/multiline_lambda_GET.xs +50 -0
  676. package/parser/tests/query/valid_sources/mutliline_query.xs +140 -0
  677. package/parser/tests/query/valid_sources/patch_expression_multiline.xs +27 -0
  678. package/parser/tests/query/valid_sources/query_cache.xs +34 -0
  679. package/parser/tests/query/valid_sources/query_example.xs +43 -0
  680. package/parser/tests/query/valid_sources/query_mini.xs +11 -0
  681. package/parser/tests/query/valid_sources/query_rich_inputs.xs +32 -0
  682. package/parser/tests/query/valid_sources/simple_unit_test.xs +33 -0
  683. package/parser/tests/query/valid_sources/test_with_slashes.xs +22 -0
  684. package/parser/tests/query/valid_sources/with_unit_test.xs +97 -0
  685. package/parser/tests/table/table_parser.spec.js +52 -0
  686. package/parser/tests/table/valid_sources/account.xs +31 -0
  687. package/parser/tests/table/valid_sources/all_basic_columns.xs +44 -0
  688. package/parser/tests/table/valid_sources/basic_table.xs +15 -0
  689. package/parser/tests/table/valid_sources/empty_object.xs +17 -0
  690. package/parser/tests/table/valid_sources/empty_table.xs +3 -0
  691. package/parser/tests/table/valid_sources/multiline_index.xs +33 -0
  692. package/parser/tests/table/valid_sources/relation.xs +44 -0
  693. package/parser/tests/table/valid_sources/rich_columns.xs +28 -0
  694. package/parser/tests/table/valid_sources/table_with_comments.xs +17 -0
  695. package/parser/tests/table/valid_sources/table_with_search_index.xs +31 -0
  696. package/parser/tests/table/valid_sources/view_table.xs +62 -0
  697. package/parser/tests/task/task_parser.spec.js +53 -0
  698. package/parser/tests/task/valid_sources/active_event.xs +11 -0
  699. package/parser/tests/task/valid_sources/all_events.xs +17 -0
  700. package/parser/tests/task/valid_sources/daily_sales_report.xs +56 -0
  701. package/parser/tests/task/valid_sources/inactive_event.xs +11 -0
  702. package/parser/tests/workflow_test/valid_sources/basic_workflow_test.xs +13 -0
  703. package/parser/tests/workflow_test/workflow_test_parser.spec.js +52 -0
  704. package/parser/tool_parser.js +121 -0
  705. package/parser/tool_parser.spec.js +102 -0
  706. package/parser/workflow_test_parser.js +73 -0
  707. package/parser/workflow_test_parser.spec.js +71 -0
  708. package/parser/workspace_parser.js +38 -0
  709. package/parser/workspace_parser.spec.js +142 -0
  710. package/parser/workspace_trigger_parser.js +118 -0
  711. package/parser/workspace_trigger_parser.spec.js +332 -0
  712. package/profile-parser.js +214 -0
  713. package/server.js +59 -0
  714. package/toTmLanguage.js +75 -0
  715. package/utils.js +55 -0
  716. package/utils.spec.js +277 -0
@@ -0,0 +1,2617 @@
1
+ # stack
2
+
3
+ ```xs
4
+ stack {
5
+ var $counter {
6
+ value = 0
7
+ }
8
+ for (3) {
9
+ each as $index {
10
+ math.add $counter {
11
+ value = 1
12
+ }
13
+ }
14
+ }
15
+ debug.log {
16
+ value = $counter
17
+ }
18
+ }
19
+ ```
20
+
21
+ A `stack` block defines a sequence of actions to be executed in a specific context, such as within a `query`, `function`, `task`, or other block (e.g., `group`, `transaction`). It acts as a container for operations like:
22
+
23
+ - Variable declarations (e.g., `var`),
24
+ - Control flow (e.g., `for`, `conditional`),
25
+ - Function calls (e.g., `math.add`, `debug.log`),
26
+ - Database operations (e.g., `db.query`).
27
+
28
+ Stacks are used to organize and execute a series of steps in a structured manner, often as part of a larger workflow.
29
+
30
+ # input
31
+
32
+ ```xs
33
+ input {
34
+ text username filters=trim {
35
+ description = "User's login name"
36
+ sensitive = false
37
+ }
38
+ int age? {
39
+ description = "User's age (optional)"
40
+ }
41
+ }
42
+ ```
43
+
44
+ An `input` block defines the parameters expected by a `query` or `function`. It includes:
45
+
46
+ - Fields with their data types (e.g., `text`, `int`),
47
+ - Optional status (marked with `?`),
48
+ - Filters (e.g., `trim`) to process the input,
49
+ - Metadata like `description` for clarity or `sensitive` to mark private data.
50
+
51
+ Inputs specify the data that a query or function can receive and work with, such as user-provided values in an API request.
52
+
53
+ # schema
54
+
55
+ ```xs
56
+ schema {
57
+ int customer_id
58
+ text full_name filters=trim {
59
+ description = "Customer's full name"
60
+ }
61
+ email contact_email filters=trim|lower {
62
+ description = "Customer's email address"
63
+ sensitive = true
64
+ }
65
+ timestamp registered_at?=now
66
+ }
67
+ ```
68
+
69
+ A `schema` block, used within a `table` file, defines the structure of a database table. It includes:
70
+
71
+ - Fields with their data types (e.g., `int`, `text`, `email`),
72
+ - Optional status (marked with `?`),
73
+ - Default values (e.g., `?=now`),
74
+ - Filters (e.g., `trim|lower`) to process field values,
75
+ - Metadata like `description` for clarity or `sensitive` to mark private fields.
76
+
77
+ Schemas outline the columns and their properties for storing data in a table.
78
+
79
+ # response
80
+
81
+ ```xs
82
+ response = $user_data
83
+ ```
84
+
85
+ A `response` block, used within a `query` or `function`, specifies the data to return as the result of the operation. The value defines the output, which can be a variable (e.g., `$user_data`), a literal, or an expression. Responses determine what data is sent back to the caller, such as API response data or a function’s return value.
86
+
87
+ # schedule
88
+
89
+ ```xs
90
+ schedule {
91
+ events = [
92
+ {starts_on: 2025-01-01 09:00:00+0000, freq: 86400},
93
+ {starts_on: 2025-01-02 09:00:00+0000, freq: 604800, ends_on: 2025-12-31 09:00:00+0000}
94
+ ]
95
+ }
96
+ ```
97
+
98
+ A `schedule` block, used within a `task` file, defines when the task should run. It includes an `events` array with:
99
+
100
+ - `starts_on`: The start date and time (e.g., `2025-01-01 09:00:00+0000`),
101
+ - `freq`: The frequency in seconds for recurring tasks (e.g., `86400` for daily, `604800` for weekly),
102
+ - `ends_on`: An optional end date for recurring tasks (e.g., `2025-12-31 09:00:00+0000`).
103
+
104
+ Schedules automate task execution at specified intervals or times.
105
+
106
+ # table
107
+
108
+ ```xs
109
+ table customer {
110
+ auth = true
111
+ security {
112
+ guid = "a1b2c3d4e5f6"
113
+ }
114
+ schema {
115
+ int id
116
+ text name filters=trim {
117
+ description = "Customer's full name"
118
+ }
119
+ email email filters=trim|lower {
120
+ description = "Customer's email address"
121
+ sensitive = true
122
+ }
123
+ timestamp signup_date?=now
124
+ bool is_active?=true
125
+ }
126
+ index = [
127
+ {type: "primary", field: [{name: "id"}]}
128
+ {type: "gin", field: [{name: "xdo", op: "jsonb_path_op"}]}
129
+ {type: "btree", field: [{name: "email", op: "desc"}]}
130
+ ]
131
+ }
132
+ ```
133
+
134
+ A `table` file defines the schema for a database table (e.g., `customer`). It includes:
135
+
136
+ - An `auth` flag to enable/disable authentication for the table,
137
+ - A `security` block with a `guid` for access control,
138
+ - A `schema` block listing fields with their data types (e.g., `int`, `text`, `email`), optional status (marked with `?`), default values (e.g., `?=now`), filters (e.g., `trim|lower`), and metadata like `description` or `sensitive`,
139
+ - An `index` block defining indexes for efficient querying (e.g., `primary` for the `id` field, `unique` for the `email` field).
140
+
141
+ Tables are used to structure and store data in a database, such as customer information.
142
+
143
+ # query
144
+
145
+ ```xs
146
+ query products verb=GET {
147
+ input {
148
+ text category filters=trim {
149
+ description = "Product category to filter by"
150
+ sensitive = false
151
+ }
152
+ }
153
+ stack {
154
+ var $category_filter {
155
+ value = $input.category
156
+ }
157
+ conditional {
158
+ if ($category_filter|strlen > 0) {
159
+ db.query product {
160
+ where = ($db.product.category|to_lower) == ($category_filter|to_lower)
161
+ } as $filtered_products
162
+ }
163
+ else {
164
+ db.query product {
165
+ } as $filtered_products
166
+ }
167
+ }
168
+ }
169
+ response = $filtered_products
170
+ }
171
+ ```
172
+
173
+ A `query` file defines an API endpoint to handle HTTP requests (e.g., GET, POST). It includes:
174
+
175
+ - A path (e.g., `/products`) and HTTP method (`verb`),
176
+ - An `input` block to define request parameters (e.g., `category`), which can have filters (e.g., `trim`) and metadata like `description` or `sensitive`,
177
+ - A `stack` block containing the logic to process the request (e.g., querying a database, applying conditions),
178
+ - A `response` block specifying the data to return (e.g., `$filtered_products`).
179
+
180
+ Queries are essential for creating API endpoints to retrieve or manipulate data, such as fetching products by category.
181
+
182
+ # workflow_test
183
+
184
+ ```xs
185
+ workflow_test test_sum_api {
186
+ description = "Test the sum API"
187
+
188
+ stack {
189
+ api.call sum verb=GET {
190
+ api_group = "new api"
191
+ headers = ""
192
+ input = {a: 22, b: 33}
193
+ } as $sum
194
+ }
195
+ }
196
+ ```
197
+
198
+ A workflow_test is a way to check if different parts of your Xano project (like APIs, functions, or tasks) work together correctly. It lets you run these parts with specific inputs and compare the results to what you expect, ensuring everything functions as intended.
199
+
200
+ # api_group
201
+
202
+ ```xs
203
+ api_group "another api" {
204
+ description = "Some description"
205
+ active = false
206
+ canonical = "HZ4jLtdc"
207
+ swagger = true
208
+ tags = ["foo", "bar"]
209
+ }
210
+ ```
211
+
212
+ An `api_group` file defines the rules applied to the API endpoint (`query`) it contains.
213
+
214
+ - `description`: A brief explanation of the API group.
215
+ - `active`: A flag indicating whether the API endpoints inside this API group are active or not.
216
+ - `canonical`: A unique identifier for the API group, will be used in as part of the URL of each endpoint.
217
+ - `swagger`: A flag indicating whether the API group is documented in Swagger.
218
+ - `tags`: An array of tags associated with the API group.
219
+
220
+ # function
221
+
222
+ ```xs
223
+ function maths/calculate_total {
224
+ input {
225
+ int quantity?
226
+ int price_per_item?
227
+ }
228
+ stack {
229
+ var $total {
230
+ value = 0
231
+ }
232
+ conditional {
233
+ if ($input.quantity == null || $input.price_per_item == null) {
234
+ throw {
235
+ name = "InvalidInputError"
236
+ value = "Quantity and price must be provided"
237
+ }
238
+ }
239
+ else {
240
+ math.mul $total {
241
+ value = $input.quantity
242
+ }
243
+ math.mul $total {
244
+ value = $input.price_per_item
245
+ }
246
+ }
247
+ }
248
+ }
249
+ response = $total
250
+ }
251
+ ```
252
+
253
+ A `function` file defines a reusable custom function that can be called elsewhere in your script. It includes:
254
+
255
+ - A name (e.g., `"calculate_total"`) to identify the function,
256
+ - An `input` block to define parameters (e.g., `quantity` and `price_per_item`), which can be optional (marked with `?`),
257
+ - A `stack` block containing the logic to execute (e.g., calculations, conditionals),
258
+ - A `response` block specifying the return value (e.g., `$total`).
259
+
260
+ Functions are ideal for encapsulating logic, such as calculating a total cost, that can be reused across scripts.
261
+
262
+ # task
263
+
264
+ ```xs
265
+ task "daily_report" {
266
+ stack {
267
+ db.query sales {
268
+ description = "Fetch daily sales data"
269
+ } as $daily_sales
270
+ }
271
+ schedule {
272
+ events = [
273
+ {starts_on: 2025-01-01 08:00:00+0000, freq: 86400}
274
+ ]
275
+ }
276
+ }
277
+ ```
278
+
279
+ A `task` file defines a scheduled job that runs automatically at specified times. It includes:
280
+
281
+ - A name (e.g., `"daily_report"`) to identify the task,
282
+ - A `stack` block containing the actions to execute (e.g., querying a database),
283
+ - A `schedule` block with `events` to define when the task runs, including:
284
+ - `starts_on`: The start date and time (e.g., `2025-01-01 08:00:00+0000`),
285
+ - `freq`: The frequency in seconds for recurring tasks (e.g., `86400` for daily),
286
+ - `ends_on`: An optional end date for recurring tasks (not used here).
287
+
288
+ Tasks are ideal for automating recurring operations like generating reports or syncing data.
289
+
290
+ # action.call
291
+
292
+ ```xs
293
+ action.call "send_email" {
294
+ input = {
295
+ to: "user@example.com",
296
+ subject: "Hello",
297
+ body: "This is a test email."
298
+ }
299
+ } as $send_email_response
300
+ ```
301
+
302
+ Calls an external Xano action, it allows you to invoke actions from third-party services imported within your workspace.
303
+
304
+ # task.call
305
+
306
+ ```xs
307
+ task.call "daily_report" {
308
+ description = "Call the daily report task"
309
+ }
310
+ ```
311
+
312
+ Calls an internal Xano task, it allows you to invoke internal tasks within your end-to-end workflows tests.
313
+
314
+ - `task.call` takes the name of the task as an argument.
315
+ - `description`: A brief explanation of the task being called (optional)
316
+
317
+ # function.call
318
+
319
+ ```xs
320
+ function.call "maths/calculate_total" {
321
+ input = {
322
+ quantity: 2,
323
+ price_per_item: 5
324
+ }
325
+ } as $calculate_total_response
326
+ ```
327
+
328
+ Calls an internal function, it allows you to invoke internal functions within your end-to-end workflows tests.
329
+
330
+ - `function.call` takes the name of the function as an argument.
331
+ - `input`: The input parameters for the function.
332
+
333
+ # api.call
334
+
335
+ ```xs
336
+ api.call "account/{account_id}" verb=POST {
337
+ api_group = "account"
338
+ headers = []|push:"Authorization: Bearer token123"
339
+ input = {
340
+ name: "New Name"
341
+ }
342
+ } as $account_update_response
343
+ ```
344
+
345
+ Calls an internal Xano API endpoint, it allows you to invoke internal APIs within your end-to-end workflows tests.
346
+
347
+ - `api.call` signature is similar to the `query` definition it's invoking (e.g., `query <URL> verb=<METHOD> {...}`).
348
+ - `api_group`: The API group to which the endpoint belongs.
349
+ - `headers`: Custom headers to include in the request.
350
+ - `input`: The request payload.
351
+
352
+ # tool.call
353
+
354
+ ```xs
355
+ tool.call "my_tool" {
356
+ input = {
357
+ key: "value"
358
+ }
359
+ } as $tool_response
360
+ ```
361
+
362
+ Calls an internal Xano AI tool, it allows you to invoke internal tools within your end-to-end workflows tests.
363
+
364
+ - `tool.call` takes the name of the tool as an argument.
365
+ - `input`: The input parameters for the tool.
366
+
367
+ # api.lambda
368
+
369
+ ```xs
370
+ api.lambda {
371
+ code = """
372
+ // Javascript or Typescript code here
373
+ return $input.value > 10 ? true : false;
374
+ """
375
+ timeout = 10
376
+ } as $result
377
+ ```
378
+
379
+ allows you to run provided `code` in Javascript or Typescript in a sandboxed environment. Maximum execution time is `timeout` seconds.
380
+
381
+ The lambda function has access to your function stack context like `$input`, `$var`, `$auth` and `$env`.
382
+
383
+ The result of the execution is stored in `as $result` variable and is the returned value of the code.
384
+
385
+ # api.request
386
+
387
+ ```xs
388
+ api.request {
389
+ url = "https://api.example.com/users"
390
+ method = "GET"
391
+ params = {}|set:"user_id":"123"
392
+ headers = []|push:"Authorization: Bearer token123"
393
+ timeout = 30
394
+ } as $user_response
395
+ ```
396
+
397
+ Sends an HTTP request to a specified URL and retrieves the response. It supports various HTTP methods, query parameters, custom headers, and a timeout to limit execution time. The response is stored in the variable specified by `as`.
398
+
399
+ # api.stream
400
+
401
+ ```xs
402
+ api.stream {
403
+ value = $processed_results
404
+ }
405
+ ```
406
+
407
+ Streams data back to the client when the API response type is set to `'Stream'`. This is useful for real-time data delivery, such as in live updates or large data transfers.
408
+
409
+ # api.realtime_event
410
+
411
+ ```xs
412
+ api.realtime_event {
413
+ channel = "notifications_channel"
414
+ data = $alert_message
415
+ auth_table = "users"
416
+ auth_id = "user_789"
417
+ }
418
+ ```
419
+
420
+ Sends a real-time event over a specified channel, enabling live updates in applications. It includes a data payload and optional authentication details to control access.
421
+
422
+ # ai.agent.run
423
+
424
+ ```xs
425
+ ai.agent.run my_first_agent {
426
+ args = {
427
+ customer_message: $input.question,
428
+ messages: []
429
+ |push:{
430
+ role: "user",
431
+ content: []
432
+ |push:{
433
+ type: "text",
434
+ text: $input.question
435
+ }
436
+ }
437
+ }
438
+ allow_tool_execution = true
439
+ } as $agent_response
440
+ ```
441
+
442
+ Executes an AI agent with the specified configuration. It takes the agent name (e.g., `my_first_agent`) and optional parameters:
443
+
444
+ - `args`: Input arguments for the agent (can be an object, string, or expression)
445
+ - `allow_tool_execution`: Boolean flag to enable or disable tool execution by the agent (optional)
446
+ - `description`: A brief explanation of the agent run (optional)
447
+ - `disabled`: Flag to skip execution (optional)
448
+
449
+ The agent's response is stored in the variable specified by `as`, here `$agent_response`.
450
+
451
+ # ai.external.mcp.tool.list
452
+
453
+ ```xs
454
+ ai.external.mcp.tool.list {
455
+ url = "https://mcp-server.example.com/sse"
456
+ bearer_token = $env.mcp_secret_key
457
+ connection_type = "sse"
458
+ } as $available_tools
459
+ ```
460
+
461
+ Retrieves a list of available tools from an external Model Context Protocol (MCP) server. Required parameters:
462
+
463
+ - `url`: The endpoint URL of the MCP server
464
+ - `bearer_token`: Authentication token for the MCP server (can be a variable like `$env.token`)
465
+ - `connection_type`: The connection type (e.g., `"sse"` for Server-Sent Events)
466
+ - `description`: A brief explanation of the operation (optional)
467
+ - `disabled`: Flag to skip execution (optional)
468
+
469
+ The list of available tools is stored in the variable specified by `as`, here `$available_tools`.
470
+
471
+ # ai.external.mcp.tool.run
472
+
473
+ ```xs
474
+ ai.external.mcp.tool.run {
475
+ url = "https://mcp-server.example.com/sse"
476
+ bearer_token = $env.mcp_secret_key
477
+ connection_type = "sse"
478
+ tool = "search_documents"
479
+ args = {user_id: $auth.user_id, query: $input.search_term}
480
+ } as $tool_result
481
+ ```
482
+
483
+ Executes a specific tool on an external Model Context Protocol (MCP) server. Required parameters:
484
+
485
+ - `url`: The endpoint URL of the MCP server
486
+ - `bearer_token`: Authentication token for the MCP server
487
+ - `connection_type`: The connection type (e.g., `"sse"` for Server-Sent Events)
488
+ - `tool`: The name of the tool to execute
489
+ - `args`: Arguments to pass to the tool (can be an object, string, or expression)
490
+ - `description`: A brief explanation of the tool execution (optional)
491
+ - `disabled`: Flag to skip execution (optional)
492
+
493
+ The tool's execution result is stored in the variable specified by `as`, here `$tool_result`.
494
+
495
+ # ai.external.mcp.server_details
496
+
497
+ ```xs
498
+ ai.external.mcp.server_details {
499
+ url = "https://mcp-server.example.com/sse"
500
+ bearer_token = $env.mcp_secret_key
501
+ connection_type = "sse"
502
+ } as $server_info
503
+ ```
504
+
505
+ Retrieves detailed information about an external Model Context Protocol (MCP) server, such as capabilities, version, and configuration. Required parameters:
506
+
507
+ - `url`: The endpoint URL of the MCP server
508
+ - `bearer_token`: Authentication token for the MCP server
509
+ - `connection_type`: The connection type (e.g., `"sse"` for Server-Sent Events)
510
+ - `description`: A brief explanation of the operation (optional)
511
+ - `disabled`: Flag to skip execution (optional)
512
+
513
+ The server details are stored in the variable specified by `as`, here `$server_info`.
514
+
515
+ # var
516
+
517
+ ```xs
518
+ var $name {
519
+ value = "value"
520
+ }
521
+ ```
522
+
523
+ defines a variable with the name `$name` and the value `"value"`. The value can be a string, number, boolean, or an object followed by filters.
524
+
525
+ # var.update
526
+
527
+ ```xs
528
+ var.update $name {
529
+ value = "value"
530
+ }
531
+ ```
532
+
533
+ updates the value of the variable with the name `$name` to `"value"`. The value can be a string, number, boolean, or an object followed by filters.
534
+
535
+ # array.find
536
+
537
+ ```xs
538
+ array.find $customer_ages if ($this > 18) as $first_adult_age
539
+ ```
540
+
541
+ Searches an array and returns the first element that meets the specified condition. If no element satisfies it, `null` is returned. The result is stored in the variable defined by `as`.
542
+
543
+ # array.push
544
+
545
+ ```xs
546
+ array.push $shopping_cart {
547
+ value = "oranges"
548
+ disabled = false
549
+ description = "Add oranges to cart"
550
+ }
551
+ ```
552
+
553
+ Appends a new element to the end of an array. It accepts a `value` to add, with optional `disabled` (to skip execution) and `description` (for context or logging).
554
+
555
+ # array.unshift
556
+
557
+ ```xs
558
+ array.unshift $priority_tasks {
559
+ value = "urgent meeting"
560
+ }
561
+ ```
562
+
563
+ Inserts a new element at the beginning of an array, shifting existing elements to higher indexes.
564
+
565
+ # array.shift
566
+
567
+ ```xs
568
+ array.shift $waiting_list as $next_customer
569
+ ```
570
+
571
+ Removes and returns the first element of an array, shortening the array by one. The removed element is stored in the variable specified by `as`.
572
+
573
+ # array.pop
574
+
575
+ ```xs
576
+ array.pop $completed_tasks as $last_finished_task
577
+ ```
578
+
579
+ Removes and returns the last element of an array, reducing its length by one. The removed element is stored in the variable defined by `as`.
580
+
581
+ # array.merge
582
+
583
+ ```xs
584
+ array.merge $active_users {
585
+ value = $new_users
586
+ }
587
+ ```
588
+
589
+ Combines another array or a single value into the target array, appending all elements from the provided `value`.
590
+
591
+ # array.find_index
592
+
593
+ ```xs
594
+ array.find_index $sale_prices if ($this < 20) as $first_discount_index
595
+ ```
596
+
597
+ Returns the index of the first element that satisfies the condition. If no match is found, it returns `-1`. The result is stored in the variable specified by `as`.
598
+
599
+ # array.has
600
+
601
+ ```xs
602
+ array.has $team_roles if ($this == "manager") {
603
+ disabled = false
604
+ description = "Verify manager role"
605
+ } as $has_manager
606
+ ```
607
+
608
+ Checks if at least one element in the array meets the condition, returning `true` if so, `false` otherwise. The result is stored in the `as` variable. Optional `disabled` and `description` parameters control execution and add context.
609
+
610
+ # array.every
611
+
612
+ ```xs
613
+ array.every $exam_scores if ($this >= 70) as $all_passed
614
+ ```
615
+
616
+ Tests whether every element in the array satisfies the condition, returning `true` if they all do, `false` if any fail. The result is stored in the `as` variable.
617
+
618
+ # array.filter
619
+
620
+ ```xs
621
+ array.filter $temperatures if ($this > 32) as $above_freezing
622
+ ```
623
+
624
+ Creates a new array containing only the elements that meet the condition. The filtered result is stored in the variable specified by `as`.
625
+
626
+ # array.filter_count
627
+
628
+ ```xs
629
+ array.filter_count $survey_responses if ($this == "yes") as $yes_count
630
+ ```
631
+
632
+ Counts how many elements in the array satisfy the condition. The total is stored in the variable defined by `as`.
633
+
634
+ Below is the documentation for the XanoScript functions related to database operations and control flow, as requested in your query. Each entry follows the style of the existing documentation, providing a code snippet example and a brief explanation of what the function does. The examples use meaningful variable names to illustrate practical use cases.
635
+
636
+ # array.map
637
+
638
+ ```xs
639
+ array.map ($json) {
640
+ by = $this.email
641
+ } as $emails
642
+
643
+ array.map ($json) {
644
+ by = {name: $this.name, gender: $this.gender}
645
+ } as $people
646
+ ```
647
+
648
+ Transforms each element in an array based on a specified mapping function. The `by` parameter defines how each element should be transformed, and the resulting array is stored in the variable specified by `as`.
649
+
650
+ # array.partition
651
+
652
+ ```xs
653
+ array.partition ($json) if ($this.gender == "male") as $is_male
654
+ ```
655
+
656
+ Divides an array into two separate arrays based on a condition and stores the results in an object with a `true` and `false` key. The `true` key contains elements that meet the condition, while the `false` key contains those that do not. The resulting object is stored in the variable specified by `as`.
657
+
658
+ # array.group_by
659
+
660
+ ```xs
661
+ array.group_by ($users) {
662
+ by = $this.gender
663
+ } as $user_by_gender
664
+ ```
665
+
666
+ Groups elements in an array based on a specified key or function. The `by` parameter defines the grouping criterion, and the resulting object, where each key corresponds to a group, is stored in the variable specified by `as`.
667
+
668
+ # array.union
669
+
670
+ ```xs
671
+ // expects the result to be [1,2,3,4,5,6,7,8,9]
672
+ array.union ([1,3,5,7,9]) {
673
+ value = [2,4,6,8]
674
+ by = $this
675
+ } as $union
676
+ ```
677
+
678
+ Combines two arrays into one, ensuring that all elements are unique based on a specified key or function. The `value` parameter provides the array to merge, and the `by` parameter defines how to determine uniqueness. The resulting array is stored in the variable specified by `as`.
679
+
680
+ # array.difference
681
+
682
+ ```xs
683
+ // expects the result to be [1,3,5,7,9]
684
+ array.difference ([1,2,3,4,5,6,7,8,9]) {
685
+ value = [2,4,6,8]
686
+ by = $this
687
+ } as $difference
688
+ ```
689
+
690
+ Computes the difference between two arrays, returning elements that are present in the first array but not in the second, based on a specified key or function. The `value` parameter provides the array to compare against, and the `by` parameter defines how to determine uniqueness. The resulting array is stored in the variable specified by `as`.
691
+
692
+ # array.intersection
693
+
694
+ ```xs
695
+ // expects the result to be [2,4,6,8]
696
+ array.intersection ([1,2,3,4,5,6,7,8,9]) {
697
+ value = [2,4,6,8]
698
+ by = $this
699
+ } as $intersection
700
+ ```
701
+
702
+ Computes the intersection of two arrays, returning elements that are present in both arrays based on a specified key or function. The `value` parameter provides the array to compare against, and the `by` parameter defines how to determine uniqueness. The resulting array is stored in the variable specified by `as`.
703
+
704
+ # conditional
705
+
706
+ ```xs
707
+ conditional {
708
+ if ($user_age > 18) {
709
+ debug.log {
710
+ value = "Adult user"
711
+ }
712
+ }
713
+ elseif ($user_age < 18) {
714
+ debug.log {
715
+ value = "Minor user"
716
+ }
717
+ }
718
+ else {
719
+ debug.log {
720
+ value = "User age not specified"
721
+ }
722
+ }
723
+ }
724
+ ```
725
+
726
+ Controls the flow of the script based on specified conditions, allowing different code blocks to execute depending on whether the conditions are true or false. It functions like an if-else statement, checking each condition in sequence and running the corresponding block.
727
+
728
+ # continue
729
+
730
+ ```xs
731
+ foreach $users as $user {
732
+ if ($user.age < 18) {
733
+ continue
734
+ }
735
+ debug.log {
736
+ value = $user.name ~ " is an adult"
737
+ }
738
+ }
739
+ ```
740
+
741
+ Skips the current iteration of a loop and moves to the next one. This is useful for bypassing specific items in a loop based on a condition, such as skipping users under 18 in this example.
742
+
743
+ # db.add
744
+
745
+ ```xs
746
+ db.add user {
747
+ data = {
748
+ name: $input.name,
749
+ email: $input.email
750
+ }
751
+ } as $new_user
752
+ ```
753
+
754
+ Inserts a new record into a specified database table (e.g., `user`) with the provided data fields. The new record is stored in the variable specified by `as`, here `$new_user`, for further use.
755
+
756
+ # db.add_or_edit
757
+
758
+ ```xs
759
+ db.add_or_edit user {
760
+ field_name = "email"
761
+ field_value = $input.email
762
+ data = {
763
+ name: $input.name,
764
+ category: $input.category
765
+ }
766
+ } as $user_record
767
+ ```
768
+
769
+ Inserts a new record into a database table (e.g., `user`) or updates an existing one based on a specified field (e.g., `email`) and its value (e.g., `$input.email`). The data block specifies the fields to add or update, and the resulting record is stored in `$user_record`.
770
+
771
+ # db.del
772
+
773
+ ```xs
774
+ db.del comment {
775
+ field_name = "id"
776
+ field_value = $input.commentId
777
+ }
778
+ ```
779
+
780
+ Removes a record from a database table (e.g., `comment`) based on a specified field (e.g., `id`) and its value (e.g., `$input.commentId`). This deletes the matching record.
781
+
782
+ # db.direct_query
783
+
784
+ ```xs
785
+ db.direct_query {
786
+ sql = "SELECT * FROM users WHERE users.email = ?"
787
+ response_type = "list"
788
+ arg = $input.email
789
+ } as $query_results
790
+ ```
791
+
792
+ Executes a raw SQL query directly on the database, using placeholders (`?`) for parameters provided via `arg`. The `response_type` specifies whether to return a `list` or `single` result. The output is stored in the variable defined by `as`, here `$query_results`.
793
+
794
+ # db.edit
795
+
796
+ ```xs
797
+ db.edit user {
798
+ field_name = "email"
799
+ field_value = $input.email
800
+ data = {
801
+ category: $input.category
802
+ }
803
+ } as $updated_user
804
+ ```
805
+
806
+ Updates an existing record in a database table (e.g., `user`) identified by a field (e.g., `email`) and its value (e.g., `$input.email`). The `data` block specifies the fields to update, and the revised record is stored in `$updated_user`.
807
+
808
+ # db.patch
809
+
810
+ ```xs
811
+ db.patch user {
812
+ field_name = "email"
813
+ field_value = $input.email
814
+ data = {
815
+ category: $input.category
816
+ }
817
+ } as $updated_user
818
+ ```
819
+
820
+ Updates specific fields of an existing record in a database table (e.g., `user`) identified by a field (e.g., `email`) and its value (e.g., `$input.email`). The `data` block specifies the fields to update, and the modified record is stored in `$updated_user`.
821
+
822
+ # db.get
823
+
824
+ ```xs
825
+ db.get user {
826
+ field_name = "email"
827
+ field_value = $input.email
828
+ } as $user
829
+ ```
830
+
831
+ Retrieves a single record from a database table (e.g., `user`) based on a specified field (e.g., `email`) and its value (e.g., `$input.email`). The fetched record is stored in the variable specified by `as`, here `$user`.
832
+
833
+ # db.has
834
+
835
+ ```xs
836
+ db.has user {
837
+ field_name = "email"
838
+ field_value = $input.email
839
+ } as $user_exists
840
+ ```
841
+
842
+ Checks if a record exists in a database table (e.g., `user`) based on a specified field (e.g., `email`) and its value (e.g., `$input.email`). Returns `true` if found, `false` otherwise, stored in `$user_exists`.
843
+
844
+ # db.query
845
+
846
+ ```xs
847
+ db.query client {
848
+ description = "Fetch client details by name"
849
+ where = $db.client.name ilike $input.search
850
+ return = {
851
+ type: "list"
852
+ paging : {
853
+ page : $input.page
854
+ per_page: 25
855
+ totals : true
856
+ offset : 0
857
+ metadata: true
858
+ }
859
+ }
860
+ sort: {"client.name": "asc"}
861
+
862
+ } as $matched_client
863
+ ```
864
+
865
+ Retrieves multiple records from a database table (e.g., `user`) based on a search condition. Here, it matches records where the lowercase email equals the lowercase input email. The results are stored in `$users`.
866
+
867
+ # db.schema
868
+
869
+ ```xs
870
+ db.schema user {
871
+ path = "email"
872
+ } as $email_schema
873
+ ```
874
+
875
+ Returns the schema of a database table (e.g., `user`) or a specific field within it (e.g., `email` via `path`). The schema information is stored in the variable specified by `as`, here `$email_schema`.
876
+
877
+ # db.set_datasource
878
+
879
+ ```xs
880
+ db.set_datasource {
881
+ value = "test"
882
+ }
883
+ ```
884
+
885
+ Changes the datasource for all subsequent database queries in the current script execution to the specified value (e.g., `"test"`). This affects all database operations that follow.
886
+
887
+ # db.transaction
888
+
889
+ ```xs
890
+ db.transaction {
891
+ description = "Update user and log action"
892
+ stack {
893
+ db.update user { /* ... */ }
894
+ db.add log { /* ... */ }
895
+ }
896
+ }
897
+ ```
898
+
899
+ Executes a series of database operations (e.g., updating a user and adding a log entry) within a single transaction. Ensures atomicity—either all operations succeed, or none are applied. The `description` provides context.
900
+
901
+ # db.truncate
902
+
903
+ ```xs
904
+ db.truncate user {
905
+ reset = true
906
+ }
907
+ ```
908
+
909
+ Deletes all records from a specified database table (e.g., `user`). If `reset = true`, it also resets any auto-incrementing IDs, effectively clearing the table and starting fresh.
910
+
911
+ # db.external.mssql.direct_query
912
+
913
+ ```xs
914
+ db.external.mssql.direct_query {
915
+ sql = "SELECT * FROM orders WHERE orders.total > ?"
916
+ response_type = "list"
917
+ connection_string = "mssql://db_user:db_password@server.com:1433/sales_db?sslmode=disabled"
918
+ arg = $input.min_total
919
+ } as $large_orders
920
+ ```
921
+
922
+ Executes a SQL query directly on an external Microsoft SQL Server database. The `code` parameter contains the SQL statement, and `response_type` specifies whether it returns a `list` of records or a `single` record. The `connection_string` provides access to the database, and `arg` supplies values for placeholders (e.g., `?`) in the query. Results are stored in the variable defined by `as`, here `$large_orders`.
923
+
924
+ # db.external.mysql.direct_query
925
+
926
+ ```xs
927
+ db.external.mysql.direct_query {
928
+ sql = "SELECT * FROM products WHERE products.category = ?"
929
+ response_type = "list"
930
+ connection_string = "mysql://db_user:db_password@host.com:3306/inventory_db?sslmode=disabled"
931
+ arg = $input.category
932
+ } as $category_products
933
+ ```
934
+
935
+ Runs a SQL query directly on an external MySQL database. The `response_type` determines if the result is a `list` or a `single` record. The `connection_string` specifies the database connection, and `arg` provides values for query placeholders. The output is stored in the `as` variable, here `$category_products`.
936
+
937
+ # db.external.oracle.direct_query
938
+
939
+ ```xs
940
+ db.external.oracle.direct_query {
941
+ sql = "SELECT * FROM employees WHERE employees.department = ?"
942
+ response_type = "list"
943
+ connection_string = "oracle://db_user:db_password@server.com:1521/hr_db"
944
+ arg = $input.department
945
+ } as $department_employees
946
+ ```
947
+
948
+ Directly executes a SQL query on an external Oracle database. The `response_type` sets whether the query returns a `list` or a `single` record. The `connection_string` defines the database connection, and `arg` supplies placeholder values. Results are stored in the variable specified by `as`, here `$department_employees`.
949
+
950
+ # db.external.postgres.direct_query
951
+
952
+ ```xs
953
+ db.external.postgres.direct_query {
954
+ sql = "SELECT * FROM customers WHERE customers.last_purchase > ?"
955
+ response_type = "list"
956
+ connection_string = "postgres://db_user:db_password@host.com:5432/shop_db?sslmode=prefer"
957
+ arg = $input.date_threshold
958
+ } as $recent_customers
959
+ ```
960
+
961
+ Performs a SQL query directly on an external PostgreSQL database. The `response_type` indicates if the result is a `list` or a `single` record. The `connection_string` establishes the database connection, and `arg` provides values for placeholders. The results are stored in the `as` variable, here `$recent_customers`.
962
+
963
+ # debug.stop
964
+
965
+ ```xs
966
+ debug.stop {
967
+ value = $some_var
968
+ }
969
+ ```
970
+
971
+ This function stops the script’s execution at the point where it’s called and sends the specified `value` to the debugger. It’s a handy tool for troubleshooting, allowing you to inspect the contents of a variable (like `$some_var`) during development to ensure your script is working as expected.
972
+
973
+ # foreach
974
+
975
+ ```xs
976
+ foreach ($numbers_list) {
977
+ each as $item {
978
+ var.update $sum {
979
+ value = $sum + $item
980
+ }
981
+ }
982
+ }
983
+ ```
984
+
985
+ **Example with a predefined list**:
986
+
987
+ ```xs
988
+ foreach ([1, 2, 3, 4]) {
989
+ each as $item {
990
+ var.update $sum {
991
+ value = $sum + $item
992
+ }
993
+ }
994
+ }
995
+ ```
996
+
997
+ The `foreach` function loops through every item in a list (e.g., an array like `$numbers_list` or `[1, 2, 3, 4]`). The `each as` clause assigns the current item to a variable (e.g., `$item`), which you can use inside the loop to perform actions on each element.
998
+
999
+ # for
1000
+
1001
+ ```xs
1002
+ for (10) {
1003
+ description = "Repeat this 10 times, with $index counting from 0 to 9"
1004
+ each as $index {
1005
+ debug.log {
1006
+ value = $index + 1
1007
+ }
1008
+ }
1009
+ }
1010
+ ```
1011
+
1012
+ This function creates a loop that runs a set number of times (e.g., 10). The `each as` clause provides a counter variable (e.g., `$index`), which starts at 0 and increases by 1 each iteration, up to one less than the specified number (e.g., 0 through 9 for a count of 10).
1013
+
1014
+ # function.run
1015
+
1016
+ ```xs
1017
+ function.run add_fn {
1018
+ input = { a: $input.a, b: $input.b }
1019
+ } as $func_result
1020
+ ```
1021
+
1022
+ The `function.run` function calls a custom function (e.g., `add_fn`) and passes it the data specified in the `input` parameter (e.g., an object with `a` and `b` values). The result of the function is stored in the variable named after `as` (e.g., `$func_result`), making it available for further use in your script.
1023
+
1024
+ # group
1025
+
1026
+ ```xs
1027
+ group {
1028
+ description = "your group description"
1029
+ stack {
1030
+ debug.log {
1031
+ value = "Action 1"
1032
+ }
1033
+ }
1034
+ }
1035
+ ```
1036
+
1037
+ The `group` function organizes a set of actions into a logical block that can be collapsed in the user interface for better readability. The `description` field labels the group (e.g., "group description"), and the `stack` contains the actions you want to group together.
1038
+
1039
+ # math.sub
1040
+
1041
+ ```xs
1042
+ math.sub $total_cost {
1043
+ value = $discount_amount
1044
+ }
1045
+ ```
1046
+
1047
+ Subtracts the specified `value` (e.g., `$discount_amount`) from the variable (e.g., `$total_cost`) and updates the variable with the result. This is ideal for scenarios like reducing a total by a discount.
1048
+
1049
+ **NOTE**: math.sub does not return a value; it mutates the variable directly.
1050
+
1051
+ # math.mul
1052
+
1053
+ ```xs
1054
+ math.mul $base_price {
1055
+ value = $tax_rate
1056
+ }
1057
+ ```
1058
+
1059
+ Multiplies the variable (e.g., `$base_price`) by the specified `value` (e.g., `$tax_rate`) and stores the product back into the variable. Use this to calculate values like a price with tax applied.
1060
+
1061
+ **NOTE**: math.mul does not return a value; it mutates the variable directly.
1062
+
1063
+ # math.div
1064
+
1065
+ ```xs
1066
+ math.div $total_time {
1067
+ value = $num_tasks
1068
+ }
1069
+ ```
1070
+
1071
+ Divides the variable (e.g., `$total_time`) by the specified `value` (e.g., `$num_tasks`), updating the variable with the quotient. This is useful for finding averages, such as time per task.
1072
+
1073
+ **NOTE**: math.div mutates the value, it doesn't have a return value.
1074
+
1075
+ # math.bitwise.xor
1076
+
1077
+ ```xs
1078
+ math.bitwise.xor $flags {
1079
+ value = $toggle_bit
1080
+ }
1081
+ ```
1082
+
1083
+ Performs a bitwise XOR operation between the variable (e.g., `$flags`) and the specified `value` (e.g., `$toggle_bit`), storing the result in the variable. This is handy for toggling specific bits in a binary flag.
1084
+
1085
+ **NOTE**: math.bitwise.xor mutates the value, it doesn't have a return value.
1086
+
1087
+ # math.bitwise.or
1088
+
1089
+ ```xs
1090
+ math.bitwise.or $permissions {
1091
+ value = $new_permission
1092
+ }
1093
+ ```
1094
+
1095
+ Applies a bitwise OR operation between the variable (e.g., `$permissions`) and the specified `value` (e.g., `$new_permission`), updating the variable with the result. Commonly used to add permissions to an existing set.
1096
+
1097
+ **NOTE**: math.bitwise.or mutates the value, it doesn't have a return value.
1098
+
1099
+ # math.bitwise.and
1100
+
1101
+ ```xs
1102
+ math.bitwise.and $status_flags {
1103
+ value = $check_bit
1104
+ }
1105
+ ```
1106
+
1107
+ Executes a bitwise AND operation between the variable (e.g., `$status_flags`) and the specified `value` (e.g., `$check_bit`), saving the result in the variable. This is useful for checking if a particular bit is set.
1108
+
1109
+ **NOTE**: math.bitwise.and mutates the value, it doesn't have a return value.
1110
+
1111
+ # math.add
1112
+
1113
+ ```xs
1114
+ math.add $cart_total {
1115
+ value = $item_price
1116
+ }
1117
+ ```
1118
+
1119
+ Adds the specified `value` (e.g., `$item_price`) to the variable (e.g., `$cart_total`) and updates the variable with the sum. Perfect for accumulating values, like adding an item’s cost to a cart total.
1120
+
1121
+ **NOTE**: math.add mutates the value, it doesn't have a return value.
1122
+
1123
+ # redis.unshift
1124
+
1125
+ ```xs
1126
+ redis.unshift {
1127
+ key = "task_list"
1128
+ value = "urgent_task"
1129
+ } as $new_list_length
1130
+ ```
1131
+
1132
+ Adds an element to the beginning of a Redis list specified by `key`. The `value` is the element to add, and the new length of the list is stored in the variable defined by `as`, here `$new_list_length`.
1133
+
1134
+ # redis.incr
1135
+
1136
+ ```xs
1137
+ redis.incr {
1138
+ key = "visit_counter"
1139
+ by = 1
1140
+ } as $new_count
1141
+ ```
1142
+
1143
+ Increments a numeric value in Redis at the specified `key` by the amount given in `by`. The updated value is stored in the variable specified by `as`, here `$new_count`.
1144
+
1145
+ # redis.remove
1146
+
1147
+ ```xs
1148
+ redis.remove {
1149
+ key = "user_list"
1150
+ value = "inactive_user"
1151
+ count = 1
1152
+ }
1153
+ ```
1154
+
1155
+ Removes a specified number (`count`) of occurrences of `value` from a Redis list identified by `key`. This is useful for cleaning up lists by removing specific elements.
1156
+
1157
+ # redis.del
1158
+
1159
+ ```xs
1160
+ redis.del {
1161
+ key = "session_data"
1162
+ }
1163
+ ```
1164
+
1165
+ Deletes a key and its associated value from Redis, specified by `key`. This clears the cache entry, freeing up space.
1166
+
1167
+ # redis.push
1168
+
1169
+ ```xs
1170
+ redis.push {
1171
+ key = "message_queue"
1172
+ value = "new_message"
1173
+ } as $queue_length
1174
+ ```
1175
+
1176
+ Adds an element to the end of a Redis list identified by `key`. The `value` is the element to add, and the new list length is stored in the variable defined by `as`, here `$queue_length`.
1177
+
1178
+ # redis.ratelimit
1179
+
1180
+ ```xs
1181
+ redis.ratelimit {
1182
+ key = "api_requests"
1183
+ max = 100
1184
+ ttl = 60
1185
+ error = "Rate limit exceeded"
1186
+ } as $rate_limit_status
1187
+ ```
1188
+
1189
+ Enforces rate limiting on requests using Redis, tracking usage with `key`. It allows up to `max` requests within a `ttl` time window (in seconds). If exceeded, the `error` message is used, and the result (e.g., success or failure) is stored in `$rate_limit_status`.
1190
+
1191
+ # redis.range
1192
+
1193
+ ```xs
1194
+ redis.range {
1195
+ key = "event_log"
1196
+ start = 0
1197
+ stop = 5
1198
+ } as $recent_events
1199
+ ```
1200
+
1201
+ Retrieves a range of elements from a Redis list specified by `key`, from the `start` index to the `stop` index (inclusive). The result is stored in the variable defined by `as`, here `$recent_events`.
1202
+
1203
+ # redis.decr
1204
+
1205
+ ```xs
1206
+ redis.decr {
1207
+ key = "stock_count"
1208
+ by = 1
1209
+ } as $new_stock
1210
+ ```
1211
+
1212
+ Decrements a numeric value in Redis at the specified `key` by the amount given in `by`. The updated value is stored in the variable specified by `as`, here `$new_stock`.
1213
+
1214
+ # redis.pop
1215
+
1216
+ ```xs
1217
+ redis.pop {
1218
+ key = "task_queue"
1219
+ } as $last_task
1220
+ ```
1221
+
1222
+ Removes and returns the last element from a Redis list specified by `key`. The removed element is stored in the variable defined by `as`, here `$last_task`.
1223
+
1224
+ # redis.get
1225
+
1226
+ ```xs
1227
+ redis.get {
1228
+ key = "user_session"
1229
+ } as $session_data
1230
+ ```
1231
+
1232
+ Retrieves the value associated with a `key` from Redis. The result is stored in the variable specified by `as`, here `$session_data`.
1233
+
1234
+ # redis.set
1235
+
1236
+ ```xs
1237
+ redis.set {
1238
+ key = "user_token"
1239
+ data = "token123"
1240
+ ttl = 3600
1241
+ }
1242
+ ```
1243
+
1244
+ Sets a `key` in Redis to the specified `data` value, with an optional `ttl` (time-to-live in seconds) to control how long the key persists before expiring.
1245
+
1246
+ # redis.has
1247
+
1248
+ ```xs
1249
+ redis.has {
1250
+ key = "user_token"
1251
+ } as $token_exists
1252
+ ```
1253
+
1254
+ Checks if a `key` exists in Redis, returning `true` if it does, `false` otherwise. The result is stored in the variable specified by `as`, here `$token_exists`.
1255
+
1256
+ # redis.shift
1257
+
1258
+ ```xs
1259
+ redis.shift {
1260
+ key = "message_queue"
1261
+ } as $first_message
1262
+ ```
1263
+
1264
+ Removes and returns the first element from a Redis list specified by `key`. The removed element is stored in the variable defined by `as`, here `$first_message`.
1265
+
1266
+ # redis.count
1267
+
1268
+ ```xs
1269
+ redis.count {
1270
+ key = "message_queue"
1271
+ } as $queue_size
1272
+ ```
1273
+
1274
+ Returns the number of elements in a Redis list specified by `key`. The count is stored in the variable defined by `as`, here `$queue_size`.
1275
+
1276
+ # redis.keys
1277
+
1278
+ ```xs
1279
+ redis.keys {
1280
+ search = "user_*"
1281
+ } as $user_keys
1282
+ ```
1283
+
1284
+ Retrieves a list of Redis keys that match the specified `search` pattern (e.g., `user_*` for all keys starting with "user\_"). The matching keys are stored in the variable specified by `as`, here `$user_keys`.
1285
+
1286
+ # object.keys
1287
+
1288
+ ```xs
1289
+ object.keys {
1290
+ value = $user_data
1291
+ } as $user_data_keys
1292
+ ```
1293
+
1294
+ Retrieves the property keys of an object (e.g., `$user_data`) as an array. The resulting array of keys is stored in the variable specified by `as`, here `$user_data_keys`.
1295
+
1296
+ # object.values
1297
+
1298
+ ```xs
1299
+ object.values {
1300
+ value = $product_info
1301
+ } as $product_values
1302
+ ```
1303
+
1304
+ Extracts the values of an object’s properties (e.g., `$product_info`) into an array. The array of values is stored in the variable defined by `as`, here `$product_values`.
1305
+
1306
+ # object.entries
1307
+
1308
+ ```xs
1309
+ object.entries {
1310
+ value = $settings
1311
+ } as $settings_pairs
1312
+ ```
1313
+
1314
+ Returns an array of key-value pairs from an object (e.g., `$settings`), where each pair is an array containing the key and its corresponding value. The result is stored in the variable specified by `as`, here `$settings_pairs`.
1315
+
1316
+ # precondition
1317
+
1318
+ ```xs
1319
+ precondition ($user_age >= 18) {
1320
+ error_type = "standard"
1321
+ error = "User must be 18 or older"
1322
+ }
1323
+ ```
1324
+
1325
+ Throws an exception if the specified condition (e.g., `$user_age >= 18`) evaluates to `false`. The `error_type` defines the type of error, and `error` provides a custom message to describe the failure.
1326
+
1327
+ # return
1328
+
1329
+ ```xs
1330
+ return {
1331
+ value = $calculation_result
1332
+ }
1333
+ ```
1334
+
1335
+ Halts the execution of the current function and returns the specified `value` (e.g., `$calculation_result`) as the function’s output. This allows early termination with a result.
1336
+
1337
+ # security.create_auth_token
1338
+
1339
+ ```xs
1340
+ security.create_auth_token {
1341
+ table = "users"
1342
+ extras = { "role": "admin" }
1343
+ expiration = 86400
1344
+ id = $user_id
1345
+ } as $auth_token
1346
+ ```
1347
+
1348
+ Generates an encrypted authentication token linked to a database table (e.g., `users`). The `extras` parameter adds optional data, `expiration` sets validity in seconds (e.g., 86400 for 24 hours), and `id` identifies the user. The token is stored in the variable defined by `as`, here `$auth_token`.
1349
+
1350
+ # security.create_uuid
1351
+
1352
+ ```xs
1353
+ security.create_uuid as $unique_id
1354
+ ```
1355
+
1356
+ Generates a Universally Unique Identifier (UUID), a random 128-bit value, stored in the variable defined by `as`, here `$unique_id`.
1357
+
1358
+ # security.encrypt
1359
+
1360
+ ```xs
1361
+ security.encrypt {
1362
+ data = $sensitive_data
1363
+ algorithm = "aes-256-cbc"
1364
+ key = "encryption_key"
1365
+ iv = "init_vector"
1366
+ } as $encrypted_data
1367
+ ```
1368
+
1369
+ Encrypts a payload into binary data using a specified `algorithm` (e.g., `aes-256-cbc`), `key`, and initialization vector (`iv`). The encrypted result is stored in the variable defined by `as`, here `$encrypted_data`.
1370
+
1371
+ # security.create_curve_key
1372
+
1373
+ ```xs
1374
+ security.create_curve_key {
1375
+ curve = "P-256"
1376
+ format = "object"
1377
+ } as $crypto_key
1378
+ ```
1379
+
1380
+ Generates a cryptographic key using an elliptic curve type (`P-256`, `P-384`, or `P-521`). The `format` parameter sets the output type (e.g., `object`), and the key is stored in the variable defined by `as`, here `$crypto_key`.
1381
+
1382
+ # security.random_bytes
1383
+
1384
+ ```xs
1385
+ security.random_bytes {
1386
+ length = 16
1387
+ } as $random_bytes
1388
+ ```
1389
+
1390
+ Generates a string of random bytes with the specified `length` (e.g., 16), stored in the variable defined by `as`, here `$random_bytes`.
1391
+
1392
+ # security.create_password
1393
+
1394
+ ```xs
1395
+ security.create_password {
1396
+ character_count = 12
1397
+ require_lowercase = true
1398
+ require_uppercase = true
1399
+ require_digit = true
1400
+ require_symbol = false
1401
+ symbol_whitelist = ""
1402
+ } as $generated_password
1403
+ ```
1404
+
1405
+ Generates a random password based on rules like `character_count` (e.g., 12) and requirements for lowercase, uppercase, digits, and symbols. The `symbol_whitelist` limits allowed symbols. The password is stored in the variable defined by `as`, here `$generated_password`.
1406
+
1407
+ # security.decrypt
1408
+
1409
+ ```xs
1410
+ security.decrypt {
1411
+ data = $encrypted_data
1412
+ algorithm = "aes-256-cbc"
1413
+ key = "encryption_key"
1414
+ iv = "init_vector"
1415
+ } as $decrypted_data
1416
+ ```
1417
+
1418
+ Decrypts a payload back to its original form using the specified `algorithm` (e.g., `aes-256-cbc`), `key`, and initialization vector (`iv`). The decrypted result is stored in the variable defined by `as`, here `$decrypted_data`.
1419
+
1420
+ # security.jwe_decode
1421
+
1422
+ ```xs
1423
+ security.jwe_decode {
1424
+ token = $jwe_token
1425
+ key = "decryption_key"
1426
+ check_claims = { "iss": "my_app" }
1427
+ key_algorithm = "A256KW"
1428
+ content_algorithm = "A256GCM"
1429
+ timeDrift = 0
1430
+ } as $decoded_payload
1431
+ ```
1432
+
1433
+ Decodes a JSON Web Encryption (JWE) token using the `key`, specified `key_algorithm` (e.g., `A256KW`), and `content_algorithm` (e.g., `A256GCM`). Optional `check_claims` validates token claims, and `timeDrift` adjusts time validation. The result is stored in the variable defined by `as`, here `$decoded_payload`.
1434
+
1435
+ # security.jws_encode
1436
+
1437
+ ```xs
1438
+ security.jws_encode {
1439
+ headers = { "alg": "HS256" }
1440
+ claims = { "user_id": "123" }
1441
+ key = "signing_key"
1442
+ signature_algorithm = "HS256"
1443
+ ttl = 3600
1444
+ } as $signed_token
1445
+ ```
1446
+
1447
+ Encodes a payload as a JSON Web Signature (JWS) token with `headers`, `claims`, and a `key`. The `signature_algorithm` (e.g., `HS256`) signs the token, and `ttl` sets its validity in seconds (e.g., 3600). The token is stored in the variable defined by `as`, here `$signed_token`.
1448
+
1449
+ # security.jws_decode
1450
+
1451
+ ```xs
1452
+ security.jws_decode {
1453
+ token = $jws_token
1454
+ key = "signing_key"
1455
+ check_claims = { "user_id": "123" }
1456
+ signature_algorithm = "HS256"
1457
+ timeDrift = 0
1458
+ } as $verified_payload
1459
+ ```
1460
+
1461
+ Decodes a JSON Web Signature (JWS) token using the `key` and `signature_algorithm` (e.g., `HS256`). Optional `check_claims` verifies token claims, and `timeDrift` adjusts time validation. The payload is stored in the variable defined by `as`, here `$verified_payload`.
1462
+
1463
+ # security.jwe_encode
1464
+
1465
+ ```xs
1466
+ security.jwe_encode {
1467
+ headers = { "alg": "A256KW" }
1468
+ claims = { "data": "secret" }
1469
+ key = "encryption_key"
1470
+ key_algorithm = "A256KW"
1471
+ content_algorithm = "A256GCM"
1472
+ ttl = 0
1473
+ } as $encrypted_token
1474
+ ```
1475
+
1476
+ Encodes a payload as a JSON Web Encryption (JWE) token with `headers`, `claims`, and a `key`. The `key_algorithm` (e.g., `A256KW`) and `content_algorithm` (e.g., `A256GCM`) secure the token, and `ttl` sets its validity (0 for no expiration). The token is stored in the variable defined by `as`, here `$encrypted_token`.
1477
+
1478
+ # security.create_secret_key
1479
+
1480
+ ```xs
1481
+ security.create_secret_key {
1482
+ bits = 2048
1483
+ format = "object"
1484
+ } as $secret_key
1485
+ ```
1486
+
1487
+ Generates a secret key for digital signatures or symmetric encryption with the specified `bits` (e.g., 2048) and `format` (e.g., `object`). The key is stored in the variable defined by `as`, here `$secret_key`.
1488
+
1489
+ # security.random_number
1490
+
1491
+ ```xs
1492
+ security.random_number {
1493
+ min = 1
1494
+ max = 100
1495
+ } as $random_value
1496
+ ```
1497
+
1498
+ Generates a random number between `min` and `max` (e.g., 1 to 100), stored in the variable defined by `as`, here `$random_value`.
1499
+
1500
+ # security.check_password
1501
+
1502
+ ```xs
1503
+ security.check_password {
1504
+ text_password = $user_input_password
1505
+ hash_password = $stored_password_hash
1506
+ } as $is_valid
1507
+ ```
1508
+
1509
+ Verifies if a plain-text password (e.g., `$user_input_password`) matches a hashed password (e.g., `$stored_password_hash`). Returns `true` if they match, `false` otherwise, stored in the variable defined by `as`, here `$is_valid`.
1510
+
1511
+ # stream.from_jsonl
1512
+
1513
+ ```xs
1514
+ stream.from_jsonl {
1515
+ value = $jsonl_file
1516
+ } as $jsonl_stream
1517
+ ```
1518
+
1519
+ Parses a JSONL (JSON Lines) file resource and streams its row data. The `value` parameter specifies the JSONL file to process, and the resulting stream is stored in the variable defined by `as`, here `$jsonl_stream`.
1520
+
1521
+ # storage.create_file_resource
1522
+
1523
+ ```xs
1524
+ storage.create_file_resource {
1525
+ filename = "report.txt"
1526
+ filedata = $report_content
1527
+ } as $new_file
1528
+ ```
1529
+
1530
+ Creates a new file with the specified `filename` and `filedata` content. The created file resource is stored in the variable specified by `as`, here `$new_file`, for further use.
1531
+
1532
+ # storage.sign_private_url
1533
+
1534
+ ```xs
1535
+ storage.sign_private_url {
1536
+ pathname = "documents/secret.pdf"
1537
+ ttl = 60
1538
+ } as $signed_url
1539
+ ```
1540
+
1541
+ Generates a signed URL for a private file at the specified `pathname`, allowing temporary access for a duration defined by `ttl` (in seconds). The signed URL is stored in the variable defined by `as`, here `$signed_url`.
1542
+
1543
+ # storage.create_attachment
1544
+
1545
+ ```xs
1546
+ storage.create_attachment access=public {
1547
+ value = $input.attachment
1548
+ filename = "attachment.pdf"
1549
+ } as $attachment_metadata
1550
+ ```
1551
+
1552
+ Creates attachment metadata from a file resource specified by `value`, with the given `filename`. The `access` parameter determines if the attachment is `public` or `private`. The metadata is stored in the variable specified by `as`, here `$attachment_metadata`.
1553
+
1554
+ # storage.delete_file
1555
+
1556
+ ```xs
1557
+ storage.delete_file {
1558
+ pathname = "temp/data.csv"
1559
+ }
1560
+ ```
1561
+
1562
+ Deletes a file from storage at the specified `pathname`. This removes the file permanently from the storage system.
1563
+
1564
+ # storage.read_file_resource
1565
+
1566
+ ```xs
1567
+ storage.read_file_resource {
1568
+ value = $input.file
1569
+ } as $file_content
1570
+ ```
1571
+
1572
+ Retrieves the raw data from a file resource specified by `value`. The content of the file is stored in the variable defined by `as`, here `$file_content`.
1573
+
1574
+ # storage.create_image
1575
+
1576
+ ```xs
1577
+ storage.create_image access=public {
1578
+ value = $input.image
1579
+ filename = "profile.jpg"
1580
+ } as $image_metadata
1581
+ ```
1582
+
1583
+ Creates image metadata from a file resource specified by `value`, with the given `filename`. The `access` parameter sets the image as `public` or `private`. The metadata is stored in the variable specified by `as`, here `$image_metadata`.
1584
+
1585
+ # stream.from_csv
1586
+
1587
+ ```xs
1588
+ stream.from_csv {
1589
+ value = $csv_file
1590
+ separator = ","
1591
+ enclosure = "'"
1592
+ escape_char = "'"
1593
+ } as $csv_stream
1594
+ ```
1595
+
1596
+ Parses a CSV file resource and streams its row data. The `value` parameter specifies the CSV file, while `separator`, `enclosure`, and `escape_char` define the CSV format. The resulting stream is stored in the variable defined by `as`, here `$csv_stream`.
1597
+
1598
+ # stream.from_request
1599
+
1600
+ ```xs
1601
+ stream.from_request {
1602
+ url = "http://example.com/api/v1"
1603
+ method = "GET"
1604
+ params = {}|set:"filter":"active"
1605
+ headers = []|push:"Authorization: Bearer token123"
1606
+ timeout = 15
1607
+ follow_location = true
1608
+ } as $api_stream
1609
+ ```
1610
+
1611
+ Converts an external HTTP request into a streaming API response, returning the data as an array. It supports various HTTP methods, query parameters, headers, a `timeout` (in seconds), and an option to `follow_location` for redirects. The stream is stored in the variable specified by `as`, here `$api_stream`.
1612
+
1613
+ # switch
1614
+
1615
+ ```xs
1616
+ switch ($user_status) {
1617
+ case ("active") {
1618
+ return {
1619
+ value = "User is active"
1620
+ }
1621
+ } break
1622
+ case ("inactive") {
1623
+ return {
1624
+ value = "User is inactive"
1625
+ }
1626
+ } break
1627
+ default {
1628
+ return {
1629
+ value = "User status unknown"
1630
+ }
1631
+ }
1632
+ }
1633
+ ```
1634
+
1635
+ Implements switch-case logic to control script flow based on the value of a variable (e.g., `$user_status`). It evaluates the variable against each `case`, executing the corresponding block if a match is found, or the `default` block if no matches occur.
1636
+
1637
+ # text.starts_with
1638
+
1639
+ ```xs
1640
+ text.starts_with $message {
1641
+ value = "Hello"
1642
+ } as $starts_with_hello
1643
+ ```
1644
+
1645
+ Checks if a text string (e.g., `$message`) begins with the specified `value` (e.g., `"Hello"`). Returns `true` if it does, `false` otherwise, and stores the result in the variable defined by `as`, here `$starts_with_hello`.
1646
+
1647
+ # text.icontains
1648
+
1649
+ ```xs
1650
+ text.icontains $description {
1651
+ value = "error"
1652
+ } as $has_error
1653
+ ```
1654
+
1655
+ Performs a case-insensitive check to see if a text string (e.g., `$description`) contains the specified `value` (e.g., `"error"`). Returns `true` if found, `false` otherwise, and stores the result in `$has_error`.
1656
+
1657
+ # text.ltrim
1658
+
1659
+ ```xs
1660
+ text.ltrim $user_input {
1661
+ value = " "
1662
+ }
1663
+ ```
1664
+
1665
+ Removes leading characters (default is whitespace, or as specified by `value`) from a text string (e.g., `$user_input`). Updates the variable with the trimmed result, useful for cleaning up user input.
1666
+
1667
+ # text.rtrim
1668
+
1669
+ ```xs
1670
+ text.rtrim $user_input {
1671
+ value = " "
1672
+ }
1673
+ ```
1674
+
1675
+ Removes trailing characters (default is whitespace, or as specified by `value`) from a text string (e.g., `$user_input`). Updates the variable with the trimmed result, ensuring no unwanted trailing characters remain.
1676
+
1677
+ # text.append
1678
+
1679
+ ```xs
1680
+ text.append $greeting {
1681
+ value = ", welcome!"
1682
+ }
1683
+ ```
1684
+
1685
+ Adds the specified `value` (e.g., `", welcome!"`) to the end of a text string (e.g., `$greeting`). Updates the variable with the new concatenated string, useful for building messages.
1686
+
1687
+ # text.istarts_with
1688
+
1689
+ ```xs
1690
+ text.istarts_with $title {
1691
+ value = "intro"
1692
+ } as $starts_with_intro
1693
+ ```
1694
+
1695
+ Performs a case-insensitive check to see if a text string (e.g., `$title`) starts with the specified `value` (e.g., `"intro"`). Returns `true` if it does, `false` otherwise, and stores the result in `$starts_with_intro`.
1696
+
1697
+ # text.iends_with
1698
+
1699
+ ```xs
1700
+ text.iends_with $filename {
1701
+ value = "pdf"
1702
+ } as $ends_with_pdf
1703
+ ```
1704
+
1705
+ Performs a case-insensitive check to see if a text string (e.g., `$filename`) ends with the specified `value` (e.g., `"pdf"`). Returns `true` if it does, `false` otherwise, and stores the result in `$ends_with_pdf`.
1706
+
1707
+ # text.ends_with
1708
+
1709
+ ```xs
1710
+ text.ends_with $url {
1711
+ value = ".com"
1712
+ } as $is_com_domain
1713
+ ```
1714
+
1715
+ Checks if a text string (e.g., `$url`) ends with the specified `value` (e.g., `".com"`). Returns `true` if it does, `false` otherwise, and stores the result in `$is_com_domain`.
1716
+
1717
+ # text.prepend
1718
+
1719
+ ```xs
1720
+ text.prepend $message {
1721
+ value = "Alert: "
1722
+ }
1723
+ ```
1724
+
1725
+ Adds the specified `value` (e.g., `"Alert: "`) to the beginning of a text string (e.g., `$message`). Updates the variable with the new concatenated string, useful for adding prefixes.
1726
+
1727
+ # text.contains
1728
+
1729
+ ```xs
1730
+ text.contains $log_entry {
1731
+ value = "error"
1732
+ } as $has_error
1733
+ ```
1734
+
1735
+ Checks if a text string (e.g., `$log_entry`) contains the specified `value` (e.g., `"error"`). Returns `true` if found, `false` otherwise, and stores the result in `$has_error`.
1736
+
1737
+ # text.trim
1738
+
1739
+ ```xs
1740
+ text.trim $user_input {
1741
+ value = " "
1742
+ }
1743
+ ```
1744
+
1745
+ Removes characters (default is whitespace, or as specified by `value`) from both the beginning and end of a text string (e.g., `$user_input`). Updates the variable with the trimmed result, ensuring clean text.
1746
+
1747
+ # throw
1748
+
1749
+ ```xs
1750
+ throw {
1751
+ name = "ValidationError"
1752
+ value = "Invalid user input provided"
1753
+ }
1754
+ ```
1755
+
1756
+ Throws an error and halts the script’s execution immediately. The `name` parameter specifies the error type (e.g., `"ValidationError"`), and `value` provides a custom error message to describe the issue.
1757
+
1758
+ # try_catch
1759
+
1760
+ ```xs
1761
+ try_catch {
1762
+ try {
1763
+ function.run divide_fn {
1764
+ input = { a: 10, b: 0 }
1765
+ }
1766
+ }
1767
+ catch {
1768
+ debug.log {
1769
+ value = "Error occurred: division by zero"
1770
+ }
1771
+ }
1772
+ finally {
1773
+ debug.log {
1774
+ value = "Operation completed"
1775
+ }
1776
+ }
1777
+ }
1778
+ ```
1779
+
1780
+ Executes a block of code in the `try` section, catching any errors in the `catch` block for error handling (e.g., logging the error). The optional `finally` block runs regardless of success or failure, useful for cleanup tasks.
1781
+
1782
+ # util.send_email
1783
+
1784
+ ```xs
1785
+ util.send_email {
1786
+ service_provider = "resend"
1787
+ api_key = $env.RESEND_API_KEY
1788
+ from = $env.EMAIL_SENDER
1789
+ to = "user@example.com"
1790
+ subject = "Hello " ~ $user.name
1791
+ message = """
1792
+ Hello {{ $user.name }},
1793
+ {{ $message }}
1794
+ """
1795
+ } as $email_status
1796
+ ```
1797
+
1798
+ Sends an email using the specified `service_provider` (e.g., `"resend"` or `"xano"`). The `api_key` authenticates the request, while `from`, `to`, `subject`, and `message` define the email details. The result of the email operation is stored in the variable defined by `as`, here `$email_status`.
1799
+
1800
+ Service provider can be one of: `"xano"`, `"resend"`. When using `"xano"`, you are limited to sending emails only to your account admin email address.
1801
+
1802
+ # util.template_engine
1803
+
1804
+ ```xs
1805
+ util.template_engine {
1806
+ value = """
1807
+ Hello {{$name}},
1808
+ {{ $message }}
1809
+
1810
+ ---
1811
+ Best,
1812
+ {{ $sender }}
1813
+ """|trim
1814
+ } as $greeting_message
1815
+ ```
1816
+
1817
+ Parses a template string (e.g., `"Hello, {{name}}!"`) and replaces placeholders (e.g., `{{name}}`) with actual values. The result is stored in the variable defined by `as`, here `$greeting_message`.
1818
+
1819
+ # util.set_header
1820
+
1821
+ ```xs
1822
+ util.set_header {
1823
+ value = "Set-Cookie: sessionId=e8bb43229de9; HttpOnly; Secure; Domain=foo.example.com"
1824
+ duplicates = "replace"
1825
+ }
1826
+ ```
1827
+
1828
+ Adds a header to the response, specified by `value` (e.g., a cookie header). The `duplicates` parameter determines how to handle duplicate headers, such as `"replace"` to overwrite existing ones.
1829
+
1830
+ # util.get_env
1831
+
1832
+ ```xs
1833
+ util.get_env as $environment_vars
1834
+ ```
1835
+
1836
+ Retrieves all environment variables available in the script’s context and stores them in the variable specified by `as`, here `$environment_vars`. Useful for accessing system-wide settings.
1837
+
1838
+ # util.get_all_input
1839
+
1840
+ ```xs
1841
+ util.get_all_input as $input_data
1842
+ ```
1843
+
1844
+ Captures all parsed input data sent to the script’s context and stores it in the variable specified by `as`, here `$input_data`. This provides a structured view of input parameters.
1845
+
1846
+ # util.get_input
1847
+
1848
+ ```xs
1849
+ util.get_input as $raw_input
1850
+ ```
1851
+
1852
+ Retrieves the raw, unparsed input data for the request and stores it in the variable specified by `as`, here `$raw_input`. This is useful for accessing the original request data before processing.
1853
+
1854
+ # util.sleep
1855
+
1856
+ ```xs
1857
+ util.sleep {
1858
+ value = 5
1859
+ }
1860
+ ```
1861
+
1862
+ Pauses script execution for the specified number of seconds in `value` (e.g., 5 seconds). This can be used to introduce delays between operations.
1863
+
1864
+ # util.ip_lookup
1865
+
1866
+ ```xs
1867
+ util.ip_lookup {
1868
+ value = "123.234.99.22"
1869
+ } as $location
1870
+ ```
1871
+
1872
+ Retrieves the geographic location of an IP address specified in `value`. The location data (e.g., city, country) is stored in the variable defined by `as`, here `$location`.
1873
+
1874
+ # util.geo_distance
1875
+
1876
+ ```xs
1877
+ util.geo_distance {
1878
+ latitude_1 = 40.71
1879
+ longitude_1 = 74
1880
+ latitude_2 = 48.86
1881
+ longitude_2 = 2.35
1882
+ } as $distance
1883
+ ```
1884
+
1885
+ Calculates the distance between two geographic points, specified by their `latitude_1`, `longitude_1` (first point) and `latitude_2`, `longitude_2` (second point). The computed distance is stored in the variable defined by `as`, here `$distance`.
1886
+
1887
+ # while
1888
+
1889
+ ```xs
1890
+ while ($retry_count < 5) {
1891
+ each {
1892
+ var.update $retry_count {
1893
+ value = $retry_count + 1
1894
+ }
1895
+ }
1896
+ }
1897
+ ```
1898
+
1899
+ Continuously loops through a block of code as long as the specified condition (e.g., `$retry_count < 5`) evaluates to `true`. The `each` block contains the actions to repeat until the condition becomes `false`.
1900
+
1901
+ # zip.create_archive
1902
+
1903
+ ```xs
1904
+ zip.create_archive {
1905
+ filename = "backup.zip"
1906
+ } as $zip_archive
1907
+ ```
1908
+
1909
+ Creates a new compressed zip archive with the specified `filename`. The created zip file resource is stored in the variable defined by `as`, here `$zip_archive`, for further use.
1910
+
1911
+ # zip.add_to_archive
1912
+
1913
+ ```xs
1914
+ zip.add_to_archive {
1915
+ file = $input.file
1916
+ zip = $zip_archive
1917
+ }
1918
+ ```
1919
+
1920
+ Adds a file (specified by `file`) to an existing zip archive (specified by `zip`). This updates the zip archive with the new file content.
1921
+
1922
+ # zip.delete_from_archive
1923
+
1924
+ ```xs
1925
+ zip.delete_from_archive {
1926
+ filename = $input.file
1927
+ zip = $input.file
1928
+ }
1929
+ ```
1930
+
1931
+ Removes a file (specified by `filename`) from an existing zip archive (specified by `zip`). This deletes the file from the archive without affecting other contents.
1932
+
1933
+ # zip.extract
1934
+
1935
+ ```xs
1936
+ zip.extract {
1937
+ zip = $zip_archive
1938
+ } as $extracted_files
1939
+ ```
1940
+
1941
+ Extracts the contents of a zip archive (specified by `zip`) into individual files. The extracted files are stored in the variable defined by `as`, here `$extracted_files`.
1942
+
1943
+ # zip.view_contents
1944
+
1945
+ ```xs
1946
+ zip.view_contents {
1947
+ zip = $input.file
1948
+ } as $archive_contents
1949
+ ```
1950
+
1951
+ Lists the contents of a zip archive (specified by `zip`), providing details such as file names within the archive. The list is stored in the variable defined by `as`, here `$archive_contents`.
1952
+
1953
+ # cloud.azure.storage.sign_url
1954
+
1955
+ ```xs
1956
+ cloud.azure.storage.sign_url {
1957
+ account_name = "my_storage_account"
1958
+ account_key = "my_secret_key"
1959
+ container_name = "documents"
1960
+ path = "reports/annual.pdf"
1961
+ ttl = 300
1962
+ } as $document_access_url
1963
+ ```
1964
+
1965
+ Generates a signed URL for securely accessing a blob in Azure Blob Storage. The URL remains valid for the duration specified by `ttl` (in seconds), allowing temporary access to the file, and is stored in a variable for later use.
1966
+
1967
+ # cloud.aws.s3.sign_url
1968
+
1969
+ ```xs
1970
+ cloud.aws.s3.sign_url {
1971
+ bucket = "company_assets"
1972
+ region = "us-east-1"
1973
+ key = "my_aws_key"
1974
+ secret = "my_aws_secret"
1975
+ file_key = "images/logo.png"
1976
+ ttl = 300
1977
+ } as $logo_access_url
1978
+ ```
1979
+
1980
+ Creates a signed URL for accessing an object in an AWS S3 bucket, providing temporary access for the time set by `ttl` (in seconds). The URL is stored in the specified variable.
1981
+
1982
+ # cloud.aws.s3.list_directory
1983
+
1984
+ ```xs
1985
+ cloud.aws.s3.list_directory {
1986
+ bucket = "media_library"
1987
+ region = "us-west-2"
1988
+ key = "my_aws_key"
1989
+ secret = "my_aws_secret"
1990
+ prefix = "videos/"
1991
+ next_page_token = $previous_page_token
1992
+ } as $video_list
1993
+ ```
1994
+
1995
+ Lists the contents of an AWS S3 bucket, optionally filtered by a `prefix`, with support for pagination via `next_page_token`. The resulting list is stored in the specified variable.
1996
+
1997
+ # cloud.google.storage.upload_file
1998
+
1999
+ ```xs
2000
+ cloud.google.storage.upload_file {
2001
+ service_account = "my_service_account_json"
2002
+ bucket = "user_uploads"
2003
+ filePath = "photos/vacation.jpg"
2004
+ file = $uploaded_image
2005
+ metadata = { "description": "Beach vacation photo" }
2006
+ }
2007
+ ```
2008
+
2009
+ Uploads a file to Google Cloud Storage at the specified `filePath` in a bucket, with optional `metadata` for additional details.
2010
+
2011
+ # cloud.elasticsearch.request
2012
+
2013
+ ```xs
2014
+ cloud.elasticsearch.request {
2015
+ auth_type = "API Key"
2016
+ key_id = "my_key_id"
2017
+ access_key = "my_access_key"
2018
+ method = "GET"
2019
+ url = "https://my-elastic-cluster.com/posts/_search"
2020
+ payload = { "query": { "match": { "category": "tech" } } }
2021
+ } as $search_results
2022
+ ```
2023
+
2024
+ Sends an HTTP request to an Elastic Search cluster, executing the specified `method` with an optional `payload`. The response is stored in the given variable.
2025
+
2026
+ # cloud.azure.storage.list_directory
2027
+
2028
+ ```xs
2029
+ cloud.azure.storage.list_directory {
2030
+ account_name = "my_storage_account"
2031
+ account_key = "my_secret_key"
2032
+ container_name = "archives"
2033
+ path = "2023/"
2034
+ } as $yearly_archives
2035
+ ```
2036
+
2037
+ Lists the contents of an Azure Blob Storage container, optionally filtered by a `path`. The list is stored in the specified variable.
2038
+
2039
+ # cloud.aws.opensearch.document
2040
+
2041
+ ```xs
2042
+ cloud.aws.opensearch.document {
2043
+ auth_type = "IAM"
2044
+ key_id = "my_aws_key"
2045
+ access_key = "my_aws_secret"
2046
+ region = "us-east-1"
2047
+ base_url = "https://my-opensearch-domain.com"
2048
+ index = "articles"
2049
+ method = "POST"
2050
+ doc_id = "article_123"
2051
+ } as $article_response
2052
+ ```
2053
+
2054
+ Manages records (e.g., create, read, update, delete) in an AWS OpenSearch index using the specified `method`. The response is stored in the given variable.
2055
+
2056
+ # cloud.elasticsearch.document
2057
+
2058
+ ```xs
2059
+ cloud.elasticsearch.document {
2060
+ auth_type = "API Key"
2061
+ key_id = "my_key_id"
2062
+ access_key = "my_access_key"
2063
+ base_url = "https://my-elastic-cluster.com"
2064
+ index = "users"
2065
+ method = "GET"
2066
+ doc_id = "user_456"
2067
+ } as $user_profile
2068
+ ```
2069
+
2070
+ Manages records in an Elastic Search index (e.g., create, read, update, delete) with the specified `method`. The response is stored in the given variable.
2071
+
2072
+ # cloud.aws.s3.read_file
2073
+
2074
+ ```xs
2075
+ cloud.aws.s3.read_file {
2076
+ bucket = "app_resources"
2077
+ region = "us-west-2"
2078
+ key = "my_aws_key"
2079
+ secret = "my_aws_secret"
2080
+ file_key = "configs/settings.json"
2081
+ } as $app_settings_file
2082
+ ```
2083
+
2084
+ Reads a file from an AWS S3 bucket and stores its contents in a variable as a file resource.
2085
+
2086
+ # cloud.azure.storage.delete_file
2087
+
2088
+ ```xs
2089
+ cloud.azure.storage.delete_file {
2090
+ account_name = "my_storage_account"
2091
+ account_key = "my_secret_key"
2092
+ container_name = "temp_files"
2093
+ filePath = "drafts/old_draft.docx"
2094
+ }
2095
+ ```
2096
+
2097
+ Deletes a blob from an Azure Blob Storage container at the specified `filePath`.
2098
+
2099
+ # cloud.aws.s3.delete_file
2100
+
2101
+ ```xs
2102
+ cloud.aws.s3.delete_file {
2103
+ bucket = "user_backups"
2104
+ region = "us-east-1"
2105
+ key = "my_aws_key"
2106
+ secret = "my_aws_secret"
2107
+ file_key = "backups/2023-01.zip"
2108
+ }
2109
+ ```
2110
+
2111
+ Deletes an object from an AWS S3 bucket at the specified `file_key`.
2112
+
2113
+ # cloud.google.storage.read_file
2114
+
2115
+ ```xs
2116
+ cloud.google.storage.read_file {
2117
+ service_account = "my_service_account_json"
2118
+ bucket = "app_data"
2119
+ filePath = "logs/error_log.txt"
2120
+ } as $error_log_file
2121
+ ```
2122
+
2123
+ Reads a file from Google Cloud Storage and stores its contents in a variable as a file resource.
2124
+
2125
+ # cloud.aws.s3.get_file_info
2126
+
2127
+ ```xs
2128
+ cloud.aws.s3.get_file_info {
2129
+ bucket = "product_images"
2130
+ region = "us-east-1"
2131
+ key = "my_aws_key"
2132
+ secret = "my_aws_secret"
2133
+ file_key = "items/shirt.jpg"
2134
+ } as $image_metadata
2135
+ ```
2136
+
2137
+ Retrieves metadata (e.g., size, last modified) about an object in an AWS S3 bucket, storing it in a variable.
2138
+
2139
+ # cloud.aws.opensearch.request
2140
+
2141
+ ```xs
2142
+ cloud.aws.opensearch.request {
2143
+ auth_type = "IAM"
2144
+ key_id = "my_aws_key"
2145
+ access_key = "my_aws_secret"
2146
+ region = "us-west-2"
2147
+ method = "POST"
2148
+ url = "https://my-opensearch-domain.com/_search"
2149
+ query = { "query": { "term": { "status": "active" } } }
2150
+ } as $active_items
2151
+ ```
2152
+
2153
+ Sends a request to AWS OpenSearch with the specified `method` and `query`, storing the response in a variable.
2154
+
2155
+ # cloud.google.storage.list_directory
2156
+
2157
+ ```xs
2158
+ cloud.google.storage.list_directory {
2159
+ service_account = "my_service_account_json"
2160
+ bucket = "project_files"
2161
+ path = "designs/"
2162
+ } as $design_files
2163
+ ```
2164
+
2165
+ Lists the contents of a Google Cloud Storage bucket, optionally filtered by `path`, storing the result in a variable.
2166
+
2167
+ # cloud.google.storage.sign_url
2168
+
2169
+ ```xs
2170
+ cloud.google.storage.sign_url {
2171
+ service_account = "my_service_account_json"
2172
+ bucket = "public_assets"
2173
+ filePath = "downloads/guide.pdf"
2174
+ method = "GET"
2175
+ ttl = 300
2176
+ } as $guide_download_url
2177
+ ```
2178
+
2179
+ Generates a signed URL for accessing a file in Google Cloud Storage, valid for `ttl` seconds, with the specified `method`.
2180
+
2181
+ # cloud.google.storage.get_file_info
2182
+
2183
+ ```xs
2184
+ cloud.google.storage.get_file_info {
2185
+ service_account = "my_service_account_json"
2186
+ bucket = "app_assets"
2187
+ filePath = "icons/app_icon.png"
2188
+ } as $icon_details
2189
+ ```
2190
+
2191
+ Retrieves metadata about a file in Google Cloud Storage, storing it in a variable.
2192
+
2193
+ # cloud.azure.storage.get_file_info
2194
+
2195
+ ```xs
2196
+ cloud.azure.storage.get_file_info {
2197
+ account_name = "my_storage_account"
2198
+ account_key = "my_secret_key"
2199
+ container_name = "media"
2200
+ filePath = "videos/intro.mp4"
2201
+ } as $video_metadata
2202
+ ```
2203
+
2204
+ Retrieves metadata about a blob in Azure Blob Storage, storing it in a variable.
2205
+
2206
+ # cloud.aws.opensearch.query
2207
+
2208
+ ```xs
2209
+ cloud.aws.opensearch.query {
2210
+ auth_type = "IAM"
2211
+ key_id = "my_aws_key"
2212
+ access_key = "my_aws_secret"
2213
+ region = "us-east-1"
2214
+ base_url = "https://my-opensearch-domain.com"
2215
+ index = "products"
2216
+ return_type = "search"
2217
+ expression = [{ "field": "price", "value": "100", "op": "lt" }]
2218
+ size = 10
2219
+ from = 0
2220
+ included_fields = ["name", "price"]
2221
+ sort = [{ "field": "price", "order": "asc" }]
2222
+ payload = {}
2223
+ } as $cheap_products
2224
+ ```
2225
+
2226
+ Performs a search query on AWS OpenSearch with customizable filters, pagination, and sorting, storing results in a variable.
2227
+
2228
+ # cloud.aws.s3.upload_file
2229
+
2230
+ ```xs
2231
+ cloud.aws.s3.upload_file {
2232
+ bucket = "user_content"
2233
+ region = "us-west-2"
2234
+ key = "my_aws_key"
2235
+ secret = "my_aws_secret"
2236
+ file_key = "uploads/profile.jpg"
2237
+ file = $user_photo
2238
+ metadata = { "user_id": "123" }
2239
+ object_lock_mode = "governance"
2240
+ object_lock_retain_until = "2025-12-31"
2241
+ } as $upload_result
2242
+ ```
2243
+
2244
+ Uploads a file to an AWS S3 bucket with optional metadata and object lock settings, storing the response in a variable.
2245
+
2246
+ # cloud.algolia.request
2247
+
2248
+ ```xs
2249
+ cloud.algolia.request {
2250
+ application_id = "my_algolia_app_id"
2251
+ api_key = "my_algolia_api_key"
2252
+ url = "https://my-algolia-app.algolia.net/1/indexes/posts/query"
2253
+ method = "POST"
2254
+ payload = { "query": "tech" }
2255
+ } as $tech_posts
2256
+ ```
2257
+
2258
+ Sends a request to Algolia with the specified `method` and `payload`, storing the response in a variable.
2259
+
2260
+ # cloud.azure.storage.upload_file
2261
+
2262
+ ```xs
2263
+ cloud.azure.storage.upload_file {
2264
+ account_name = "my_storage_account"
2265
+ account_key = "my_secret_key"
2266
+ container_name = "user_files"
2267
+ filePath = "docs/resume.pdf"
2268
+ file = $user_resume
2269
+ metadata = { "owner": "Jane" }
2270
+ } as $upload_confirmation
2271
+ ```
2272
+
2273
+ Uploads a file to Azure Blob Storage with optional metadata, storing the response in a variable.
2274
+
2275
+ # cloud.google.storage.delete_file
2276
+
2277
+ ```xs
2278
+ cloud.google.storage.delete_file {
2279
+ service_account = "my_service_account_json"
2280
+ bucket = "temp_storage"
2281
+ filePath = "old/temp_data.csv"
2282
+ }
2283
+ ```
2284
+
2285
+ Deletes a file from Google Cloud Storage at the specified `filePath`.
2286
+
2287
+ # cloud.elasticsearch.query
2288
+
2289
+ ```xs
2290
+ cloud.elasticsearch.query {
2291
+ auth_type = "API Key"
2292
+ key_id = "my_key_id"
2293
+ access_key = "my_access_key"
2294
+ base_url = "https://my-elastic-cluster.com"
2295
+ index = "orders"
2296
+ return_type = "search"
2297
+ expression = [{ "field": "total", "value": "50", "op": "gt" }]
2298
+ size = 5
2299
+ from = 0
2300
+ included_fields = ["id", "total"]
2301
+ sort = [{ "field": "total", "order": "desc" }]
2302
+ payload = {}
2303
+ } as $large_orders
2304
+ ```
2305
+
2306
+ Executes a search query on Elastic Search with filters, pagination, and sorting, storing results in a variable.
2307
+
2308
+ # cloud.azure.storage.read_file
2309
+
2310
+ ```xs
2311
+ cloud.azure.storage.read_file {
2312
+ account_name = "my_storage_account"
2313
+ account_key = "my_secret_key"
2314
+ container_name = "logs"
2315
+ filePath = "daily/2023-10-01.log"
2316
+ } as $daily_log_file
2317
+ ```
2318
+
2319
+ Reads a blob from Azure Blob Storage and stores its contents in a variable as a file resource.
2320
+
2321
+ # test
2322
+
2323
+ ```xs
2324
+ test "value should always be greater than 0" {
2325
+ input = { name: "value" }
2326
+ expect.to_be_greater_than ($response.value) {
2327
+ value = 0
2328
+ }
2329
+ }
2330
+ ```
2331
+
2332
+ Defines a unit-test with a descriptive name (e.g., `"value should always be greater than 0"`). Each test can contain many `expect` blocks asserting conditions on the `$response` variable. The test will pass if all expectations are met. An optional `input` parameter can be passed to the stack being tested as its calling `input`.
2333
+
2334
+ # expect.to_equal
2335
+
2336
+ ```xs
2337
+ expect.to_equal ($response.some_property) {
2338
+ value = "expected_value"
2339
+ }
2340
+ ```
2341
+
2342
+ Checks if the value of `$response.some_property` equals the specified `value`. Useful for basic equality checks in test assertions.
2343
+
2344
+ # expect.to_start_with
2345
+
2346
+ ```xs
2347
+ expect.to_start_with ($response.some_property) {
2348
+ value = "expected_value"
2349
+ }
2350
+ ```
2351
+
2352
+ Checks if the value of `$response.some_property` starts with the specified `value`. Useful for verifying string prefixes in test assertions.
2353
+
2354
+ # expect.to_end_with
2355
+
2356
+ ```xs
2357
+ expect.to_end_with ($response.some_property) {
2358
+ value = "expected_value"
2359
+ }
2360
+ ```
2361
+
2362
+ Checks if the value of `$response.some_property` ends with the specified `value`. Useful for verifying string suffixes in test assertions.
2363
+
2364
+ # expect.to_be_greater_than
2365
+
2366
+ ```xs
2367
+ expect.to_be_greater_than ($response.some_number) {
2368
+ value = "expected_value"
2369
+ }
2370
+ ```
2371
+
2372
+ Checks if the value of `$response.some_number` is greater than the specified `value`. Useful for numeric comparisons in tests.
2373
+
2374
+ # expect.to_be_less_than
2375
+
2376
+ ```xs
2377
+ expect.to_be_less_than ($response.some_number) {
2378
+ value = "expected_value"
2379
+ }
2380
+ ```
2381
+
2382
+ Checks if the value of `$response.some_number` is less than the specified `value`. Useful for numeric comparisons in tests.
2383
+
2384
+ # expect.to_match
2385
+
2386
+ ```xs
2387
+ expect.to_match ($response) {
2388
+ value = "expected_value"
2389
+ }
2390
+ ```
2391
+
2392
+ Checks if the value of `$response` matches the specified pattern or regular expression in `value`. Useful for pattern matching in test assertions.
2393
+
2394
+ # expect.to_not_equal
2395
+
2396
+ ```xs
2397
+ expect.to_not_equal ($response) {
2398
+ value = "expected_value"
2399
+ }
2400
+ ```
2401
+
2402
+ Checks if the value of `$response` does not equal the specified `value`. Useful for negative equality assertions in tests.
2403
+
2404
+ # expect.to_contain
2405
+
2406
+ ```xs
2407
+ expect.to_contain ($response) {
2408
+ value = "expected_value"
2409
+ }
2410
+ ```
2411
+
2412
+ Checks if the value of `$response` contains the specified `value`. Useful for substring or array membership assertions in tests.
2413
+
2414
+ # expect.to_throw
2415
+
2416
+ ```xs
2417
+ expect.to_throw {
2418
+ exception = "expected_value"
2419
+ stack {
2420
+ function.run some_function {
2421
+ input = { key: "value" }
2422
+ }
2423
+ }
2424
+ }
2425
+ ```
2426
+
2427
+ Checks if the specified code block throws an exception with the expected name (e.g., `"expected_value"`). Useful for testing error handling in functions.
2428
+
2429
+ # expect.to_be_within
2430
+
2431
+ ```xs
2432
+ expect.to_be_within ($response.some_number) {
2433
+ min = 10
2434
+ max = 100
2435
+ }
2436
+ ```
2437
+
2438
+ Checks if the value of `$response.some_number` is within the specified `min` and `max` range (inclusive). Useful for range checks in tests.
2439
+
2440
+ # expect.to_be_true
2441
+
2442
+ ```xs
2443
+ expect.to_be_true ($response)
2444
+ ```
2445
+
2446
+ Checks if the value of `$response` is `true`. Useful for boolean assertions in tests.
2447
+
2448
+ # expect.to_be_false
2449
+
2450
+ ```xs
2451
+ expect.to_be_false ($response.some_boolean)
2452
+ ```
2453
+
2454
+ Checks if the value of `$response.some_boolean` is `false`. Useful for boolean assertions in tests.
2455
+
2456
+ # expect.to_be_in_the_past
2457
+
2458
+ ```xs
2459
+ expect.to_be_in_the_past ($response.some_date)
2460
+ ```
2461
+
2462
+ Checks if the value of `$response.some_date` is a date/time in the past. Useful for validating timestamps.
2463
+
2464
+ # expect.to_be_in_the_future
2465
+
2466
+ ```xs
2467
+ expect.to_be_in_the_future ($response.some_date)
2468
+ ```
2469
+
2470
+ Checks if the value of `$response.some_date` is a date/time in the future. Useful for validating timestamps.
2471
+
2472
+ # expect.to_be_defined
2473
+
2474
+ ```xs
2475
+ expect.to_be_defined ($response.some_property)
2476
+ ```
2477
+
2478
+ Checks if the value of `$response.some_property` is defined (not `null` or `undefined`). Useful for ensuring variables are set.
2479
+
2480
+ # expect.to_not_be_defined
2481
+
2482
+ ```xs
2483
+ expect.to_not_be_defined ($response.some_property)
2484
+ ```
2485
+
2486
+ Checks if the value of `$response.some_property` is not defined (is `null` or `undefined`). Useful for ensuring variables are unset.
2487
+
2488
+ # expect.to_be_null
2489
+
2490
+ ```xs
2491
+ expect.to_be_null ($response)
2492
+ ```
2493
+
2494
+ Checks if the value of `$response` is `null`. Useful for asserting null values.
2495
+
2496
+ # expect.to_not_be_null
2497
+
2498
+ ```xs
2499
+ expect.to_not_be_null ($response)
2500
+ ```
2501
+
2502
+ Checks if the value of `$response` is not `null`. Useful for asserting non-null values.
2503
+
2504
+ # expect.to_be_empty
2505
+
2506
+ ```xs
2507
+ expect.to_be_empty ($response.my_array)
2508
+ ```
2509
+
2510
+ Checks if the value of `$response.my_array` is empty (e.g., an empty string, array, or object). Useful for asserting emptiness.
2511
+
2512
+ # mock
2513
+
2514
+ ```xs
2515
+ var $email {
2516
+ value = $input.email|trim|lower
2517
+ mock = {
2518
+ "get user test": "email@example.com"
2519
+ }
2520
+ }
2521
+
2522
+ db.get user {
2523
+ field_name = "email"
2524
+ field_value = $input.email
2525
+ mock = {
2526
+ "get user test": { id: 1, name: "Test User", email: "email@example.com" }
2527
+ }
2528
+ } as $user
2529
+ ```
2530
+
2531
+ Creates a mock for a database query, API endpoint or any other statement returning a `value`. The mock's name must match the test's name. When the test runs, it applies this mock to the statement with the same name, simulating data (e.g., API responses) without real external calls.
2532
+
2533
+ # swagger
2534
+
2535
+ ```xs
2536
+ api_group "products" {
2537
+ description = "Operations related to products"
2538
+ swagger = false
2539
+ }
2540
+ ```
2541
+
2542
+ Activate or deactivate Swagger documentation for this API group.
2543
+
2544
+ # canonical
2545
+
2546
+ ```xs
2547
+ api_group "products" {
2548
+ description = "Operations related to products"
2549
+ canonical = "HZ4jLtdc"
2550
+ }
2551
+ ```
2552
+
2553
+ Defines a unique identifier for the API group or other resources. In the case of an API group, this identifier will be used as part of the URL of each endpoint it contains.
2554
+
2555
+ # $input
2556
+
2557
+ ```xs
2558
+ $input.user_id
2559
+ ```
2560
+
2561
+ The `$input` variable provides access to all input parameters sent to the script’s context. It is an object containing key-value pairs representing the input data, which can be accessed and manipulated within the script.
2562
+
2563
+ # $env
2564
+
2565
+ The `$env` variable allows access to environment variables defined within your workspace. These variables can store sensitive information like API keys or configuration settings, which can be referenced securely within your script.
2566
+
2567
+ Xano also defines a series of default environment variables for you to use within your functions:
2568
+
2569
+ - `$env.$remote_ip`: resolves to the IP address of the individual accessing the API endpoint.
2570
+ - `$env.$http_headers`: this is a text array of headers that are sent to the API endpoint.
2571
+ - `$env.$api_baseurl`: contains the base URL of the active endpoint.
2572
+ - `$env.$request_uri`: contains the URI that is being accessed from the API.
2573
+ - `$env.$request_method`: this is the method (GET, POST, DELETE, etc) of the incoming API request.
2574
+ - `$env.$request_querystring`: contains the query string of the URI that is being accessed from the API.
2575
+ - `$env.$request_auth_token`: contains the authorization token of the API request.
2576
+ - `$env.$datasource`: contains which datasource is being used.
2577
+ - `$env.$branch`: contains which branch is being used.
2578
+
2579
+ # $error
2580
+
2581
+ The `$error` variable only exists within the `catch` of a `try_catch` block and provides details about the most recent error that occurred within a `try` block. It contains properties such as `code`, `message`, `name`, and `result`, which can be used for error handling and logging purposes.
2582
+
2583
+ ```xs
2584
+ try_catch {
2585
+ try {
2586
+ function.run some_function {
2587
+ input = { param: "value" }
2588
+ }
2589
+ }
2590
+ catch {
2591
+ var.update $my_error {
2592
+ value = {
2593
+ code: $error.code
2594
+ message: $error.message
2595
+ name: $error.name
2596
+ result: $error.result
2597
+ }
2598
+ }
2599
+ }
2600
+ }
2601
+ ```
2602
+
2603
+ # $var
2604
+
2605
+ The `$var` variable provides access to all user-defined variables within the script. `$var` can also be accessed through their short form (e.g., `$counter`) so long that these do not conflict with reserved keywords (`$input`, `$env`, `$error`...).
2606
+
2607
+ You may use `var.update` to modify the value of a variable during script execution.
2608
+
2609
+ ```xs
2610
+ var $counter {
2611
+ value = 1
2612
+ }
2613
+
2614
+ var.update $counter {
2615
+ value = $var.counter + 1
2616
+ }
2617
+ ```