@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.
- package/.claude/settings.local.json +27 -0
- package/.github/copilot-instructions.md +190 -0
- package/.github/workflows/ci.yml +31 -0
- package/.husky/pre-commit +1 -0
- package/CLAUDE.md +121 -0
- package/LICENSE +21 -0
- package/README.md +55 -0
- package/connection.js +7 -0
- package/documents.js +5 -0
- package/embedded/README.md +102 -0
- package/embedded/embeddedContent.js +74 -0
- package/embedded/embeddedDocuments.js +57 -0
- package/embedded/jsLanguageService.js +74 -0
- package/eslint.config.js +24 -0
- package/language-server-worker.js +52 -0
- package/lexer/action.js +31 -0
- package/lexer/addon.js +31 -0
- package/lexer/agent.js +37 -0
- package/lexer/agent_trigger.js +42 -0
- package/lexer/ai.js +82 -0
- package/lexer/api.js +81 -0
- package/lexer/api_group.js +58 -0
- package/lexer/arrays.js +161 -0
- package/lexer/branch.js +31 -0
- package/lexer/cast.js +105 -0
- package/lexer/cloud.js +159 -0
- package/lexer/columns.js +234 -0
- package/lexer/comment.js +61 -0
- package/lexer/comment.spec.js +77 -0
- package/lexer/control.js +634 -0
- package/lexer/db.js +190 -0
- package/lexer/debug.js +37 -0
- package/lexer/expect.js +157 -0
- package/lexer/function.js +36 -0
- package/lexer/identifier.js +6 -0
- package/lexer/lexer.js +26 -0
- package/lexer/literal.js +77 -0
- package/lexer/math.js +97 -0
- package/lexer/mcp_server.js +51 -0
- package/lexer/mcp_server_trigger.js +42 -0
- package/lexer/middleware.js +42 -0
- package/lexer/multiline.js +24 -0
- package/lexer/multiline.spec.js +179 -0
- package/lexer/object.js +44 -0
- package/lexer/query.js +99 -0
- package/lexer/realtime_trigger.js +50 -0
- package/lexer/redis.js +145 -0
- package/lexer/security.js +161 -0
- package/lexer/storage.js +99 -0
- package/lexer/stream.js +49 -0
- package/lexer/table.js +38 -0
- package/lexer/table_trigger.js +50 -0
- package/lexer/task.js +83 -0
- package/lexer/tests/query/query_lexer.spec.js +36 -0
- package/lexer/tests/query/valid_sources/basic_query.xs +44 -0
- package/lexer/tests/query/valid_sources/db_query.xs +77 -0
- package/lexer/tests/query/valid_sources/empty_query.xs +5 -0
- package/lexer/tests/query/valid_sources/header_query.xs +15 -0
- package/lexer/tests/table/basic_table.xs +17 -0
- package/lexer/tests/table/empty_table.xs +3 -0
- package/lexer/tests/table/table_lexer.spec.js +324 -0
- package/lexer/text.js +114 -0
- package/lexer/tokens.js +526 -0
- package/lexer/tool.js +39 -0
- package/lexer/util.js +113 -0
- package/lexer/utils.js +56 -0
- package/lexer/utils.spec.js +61 -0
- package/lexer/var.js +30 -0
- package/lexer/variables.js +217 -0
- package/lexer/workflow_test.js +42 -0
- package/lexer/workspace.js +23 -0
- package/lexer/workspace_trigger.js +42 -0
- package/lexer/zip.js +63 -0
- package/logic-assistant-script.js +8 -0
- package/onCheckError/onCheckError.js +43 -0
- package/onCompletion/contentAssist.js +183 -0
- package/onCompletion/contentAssist.spec.js +275 -0
- package/onCompletion/onCompletion.js +38 -0
- package/onDidChangeContent/onDidChangeContent.js +128 -0
- package/onHover/FilterMessageProvider.js +102 -0
- package/onHover/FilterMessageProvider.spec.js +85 -0
- package/onHover/FunctionMessageProvider.js +122 -0
- package/onHover/FunctionMessageProvider.spec.js +128 -0
- package/onHover/HoverMessageProvider.js +31 -0
- package/onHover/InputFilterMessageProvider.js +140 -0
- package/onHover/InputFilterMessageProvider.spec.js +329 -0
- package/onHover/InputVariableMessageProvider.js +55 -0
- package/onHover/QueryFilterMessageProvider.spec.js +164 -0
- package/onHover/filters.md +2852 -0
- package/onHover/functions.md +2617 -0
- package/onHover/inputFilters.md +271 -0
- package/onHover/onHover.js +40 -0
- package/onHover/onHoverDocument.js +64 -0
- package/onHover/onHoverDocument.spec.js +486 -0
- package/onHover/queryFilterMessageProvider.js +122 -0
- package/onHover/queryFilters.md +489 -0
- package/onSemanticCheck/highlight.js +45 -0
- package/onSemanticCheck/onSemanticCheck.js +25 -0
- package/onSemanticCheck/tokens.js +40 -0
- package/package.json +48 -0
- package/parser/addon_parser.js +90 -0
- package/parser/addon_parser.spec.js +88 -0
- package/parser/agent_parser.js +281 -0
- package/parser/agent_parser.spec.js +599 -0
- package/parser/agent_trigger_parser.js +138 -0
- package/parser/agent_trigger_parser.spec.js +525 -0
- package/parser/api_group_parser.js +143 -0
- package/parser/api_group_parser.spec.js +127 -0
- package/parser/attributes/columnDefaultValueAttribute.js +33 -0
- package/parser/attributes/columnDefaultValueAttribute.spec.js +49 -0
- package/parser/attributes/descriptionFieldAttribute.js +24 -0
- package/parser/attributes/descriptionFieldAttribute.spec.js +39 -0
- package/parser/attributes/disabledFieldAttribute.js +19 -0
- package/parser/attributes/disabledFieldAttribute.spec.js +34 -0
- package/parser/attributes/docsFieldAttribute.js +24 -0
- package/parser/attributes/docsFieldAttribute.spec.js +39 -0
- package/parser/attributes/inputFilterFn.js +71 -0
- package/parser/attributes/inputFilterFn.spec.js +39 -0
- package/parser/attributes/register.js +41 -0
- package/parser/attributes/sensitiveFieldAttribute.js +17 -0
- package/parser/attributes/sensitiveFieldAttribute.spec.js +39 -0
- package/parser/attributes/valueFieldAttribute.js +17 -0
- package/parser/attributes/valueFieldAttribute.spec.js +54 -0
- package/parser/attributes/valuesFieldAttribute.js +18 -0
- package/parser/attributes/valuesFieldAttribute.spec.js +44 -0
- package/parser/base_parser.js +249 -0
- package/parser/branch_parser.js +49 -0
- package/parser/branch_parser.spec.js +34 -0
- package/parser/clauses/agentClause.js +23 -0
- package/parser/clauses/agentClause.spec.js +34 -0
- package/parser/clauses/authClause.js +17 -0
- package/parser/clauses/authClause.spec.js +39 -0
- package/parser/clauses/cacheClause.js +32 -0
- package/parser/clauses/cacheClause.spec.js +103 -0
- package/parser/clauses/canonicalClause.js +23 -0
- package/parser/clauses/canonicalClause.spec.js +34 -0
- package/parser/clauses/channelClause.js +23 -0
- package/parser/clauses/channelClause.spec.js +34 -0
- package/parser/clauses/dbTableClause.js +23 -0
- package/parser/clauses/dbTableClause.spec.js +34 -0
- package/parser/clauses/flexibleStringClause.js +43 -0
- package/parser/clauses/historyClause.js +19 -0
- package/parser/clauses/historyClause.spec.js +53 -0
- package/parser/clauses/indexClause.js +36 -0
- package/parser/clauses/indexClause.spec.js +47 -0
- package/parser/clauses/inputClause.js +35 -0
- package/parser/clauses/inputClause.spec.js +79 -0
- package/parser/clauses/mcpServerClause.js +23 -0
- package/parser/clauses/mcpServerClause.spec.js +34 -0
- package/parser/clauses/middlewareClause.js +39 -0
- package/parser/clauses/middlewareClause.spec.js +161 -0
- package/parser/clauses/nakedStackFn.js +69 -0
- package/parser/clauses/nakedStackFn.spec.js +63 -0
- package/parser/clauses/outputClause.js +33 -0
- package/parser/clauses/register.js +50 -0
- package/parser/clauses/responseClause.js +17 -0
- package/parser/clauses/responseClause.spec.js +42 -0
- package/parser/clauses/scheduleClause.js +37 -0
- package/parser/clauses/scheduleClause.spec.js +71 -0
- package/parser/clauses/schemaClause.js +66 -0
- package/parser/clauses/schemaClause.spec.js +66 -0
- package/parser/clauses/stackClause.js +16 -0
- package/parser/clauses/testClause.js +73 -0
- package/parser/clauses/testClause.spec.js +78 -0
- package/parser/clauses/viewClause.js +49 -0
- package/parser/clauses/viewClause.spec.js +154 -0
- package/parser/definitions/arraySlice.js +70 -0
- package/parser/definitions/arraySlice.spec.js +49 -0
- package/parser/definitions/columnDefinition.js +139 -0
- package/parser/definitions/columnDefinition.spec.js +199 -0
- package/parser/definitions/dbLinkColumnDefinition.js +24 -0
- package/parser/definitions/dbLinkColumnDefinition.spec.js +45 -0
- package/parser/definitions/enumColumnDefinition.js +55 -0
- package/parser/definitions/enumColumnDefinition.spec.js +108 -0
- package/parser/definitions/filterDefinition.js +23 -0
- package/parser/definitions/filterDefinition.spec.js +43 -0
- package/parser/definitions/objectColumnDefinition.js +52 -0
- package/parser/definitions/objectColumnDefinition.spec.js +118 -0
- package/parser/definitions/register.js +28 -0
- package/parser/function_parser.js +123 -0
- package/parser/function_parser.spec.js +83 -0
- package/parser/functions/actionCallFn.js +41 -0
- package/parser/functions/actionCallFn.spec.js +51 -0
- package/parser/functions/addonCallFn.js +39 -0
- package/parser/functions/addonCallFn.spec.js +41 -0
- package/parser/functions/ai/aiAgentRunFn.js +40 -0
- package/parser/functions/ai/aiAgentRunFn.spec.js +94 -0
- package/parser/functions/ai/aiExternalMcpServerDetailsFn.js +28 -0
- package/parser/functions/ai/aiExternalMcpServerDetailsFn.spec.js +85 -0
- package/parser/functions/ai/aiExternalMcpToolListFn.js +28 -0
- package/parser/functions/ai/aiExternalMcpToolListFn.spec.js +85 -0
- package/parser/functions/ai/aiExternalMcpToolRunFn.js +30 -0
- package/parser/functions/ai/aiExternalMcpToolRunFn.spec.js +101 -0
- package/parser/functions/ai/register.js +24 -0
- package/parser/functions/aiFn.js +61 -0
- package/parser/functions/aiFn.spec.js +51 -0
- package/parser/functions/api/apiCallFn.js +49 -0
- package/parser/functions/api/apiCallFn.spec.js +60 -0
- package/parser/functions/api/apiLambdaFn.js +19 -0
- package/parser/functions/api/apiLambdaFn.spec.js +63 -0
- package/parser/functions/api/apiRealtimeEventFn.js +25 -0
- package/parser/functions/api/apiRealtimeEventFn.spec.js +82 -0
- package/parser/functions/api/apiRequestFn.js +47 -0
- package/parser/functions/api/apiRequestFn.spec.js +113 -0
- package/parser/functions/api/apiStreamFn.js +22 -0
- package/parser/functions/api/apiStreamFn.spec.js +44 -0
- package/parser/functions/api/register.js +19 -0
- package/parser/functions/api/webflowRequestFn.js +47 -0
- package/parser/functions/api/webflowRequestFn.spec.js +114 -0
- package/parser/functions/apiFn.js +24 -0
- package/parser/functions/array/arrayDifferenceFn.js +37 -0
- package/parser/functions/array/arrayDifferenceFn.spec.js +34 -0
- package/parser/functions/array/arrayEveryFn.js +13 -0
- package/parser/functions/array/arrayFilterCountFn.js +14 -0
- package/parser/functions/array/arrayFilterFn.js +14 -0
- package/parser/functions/array/arrayFindFn.js +14 -0
- package/parser/functions/array/arrayFindFn.spec.js +44 -0
- package/parser/functions/array/arrayFindIndexFn.js +14 -0
- package/parser/functions/array/arrayGroupByFn.js +36 -0
- package/parser/functions/array/arrayGroupByFn.spec.js +41 -0
- package/parser/functions/array/arrayHasFn.js +14 -0
- package/parser/functions/array/arrayIntersectionFn.js +37 -0
- package/parser/functions/array/arrayIntersectionFn.spec.js +22 -0
- package/parser/functions/array/arrayMapFn.js +36 -0
- package/parser/functions/array/arrayMapFn.spec.js +37 -0
- package/parser/functions/array/arrayMergeFn.js +17 -0
- package/parser/functions/array/arrayNoValueAs.js +31 -0
- package/parser/functions/array/arrayNoValueAs.spec.js +56 -0
- package/parser/functions/array/arrayPartitionFn.js +19 -0
- package/parser/functions/array/arrayPartitionFn.spec.js +29 -0
- package/parser/functions/array/arrayPopFn.js +17 -0
- package/parser/functions/array/arrayPushFn.js +14 -0
- package/parser/functions/array/arrayShiftFn.js +15 -0
- package/parser/functions/array/arrayUnionFn.js +37 -0
- package/parser/functions/array/arrayUnionFn.spec.js +22 -0
- package/parser/functions/array/arrayUnshiftFn.js +14 -0
- package/parser/functions/array/arrayValueIfAs.js +51 -0
- package/parser/functions/array/arrayValueIfAs.spec.js +54 -0
- package/parser/functions/array/arrayValueOnly.js +40 -0
- package/parser/functions/array/arrayValueOnly.spec.js +61 -0
- package/parser/functions/array/register.js +49 -0
- package/parser/functions/array/valueAttrOnly.js +47 -0
- package/parser/functions/array/valueAttrOnly.spec.js +61 -0
- package/parser/functions/arrayFn.js +33 -0
- package/parser/functions/cloud/cloudAlgoliaFn.js +18 -0
- package/parser/functions/cloud/cloudAlgoliaRequestFn.js +26 -0
- package/parser/functions/cloud/cloudAlgoliaRequestFn.spec.js +30 -0
- package/parser/functions/cloud/cloudAwsFn.js +19 -0
- package/parser/functions/cloud/cloudAwsOpenSearchFn.js +19 -0
- package/parser/functions/cloud/cloudAwsS3Fn.js +22 -0
- package/parser/functions/cloud/cloudAwsS3Fn.spec.js +21 -0
- package/parser/functions/cloud/cloudAzureFn.js +18 -0
- package/parser/functions/cloud/cloudDeleteFileFn.js +23 -0
- package/parser/functions/cloud/cloudDeleteFileFn.spec.js +25 -0
- package/parser/functions/cloud/cloudElasticSearchFn.js +19 -0
- package/parser/functions/cloud/cloudGetFileInfoFn.js +24 -0
- package/parser/functions/cloud/cloudGetFileInfoFn.spec.js +25 -0
- package/parser/functions/cloud/cloudGoogleFn.js +18 -0
- package/parser/functions/cloud/cloudListDirectoryFn.js +24 -0
- package/parser/functions/cloud/cloudListDirectoryFn.spec.js +26 -0
- package/parser/functions/cloud/cloudReadFileFn.js +24 -0
- package/parser/functions/cloud/cloudReadFileFn.spec.js +25 -0
- package/parser/functions/cloud/cloudSearchDocumentFn.js +24 -0
- package/parser/functions/cloud/cloudSearchDocumentFn.spec.js +28 -0
- package/parser/functions/cloud/cloudSearchQueryFn.js +24 -0
- package/parser/functions/cloud/cloudSearchQueryFn.spec.js +32 -0
- package/parser/functions/cloud/cloudSearchRequestFn.js +24 -0
- package/parser/functions/cloud/cloudSearchRequestFn.spec.js +32 -0
- package/parser/functions/cloud/cloudSignUrlFn.js +24 -0
- package/parser/functions/cloud/cloudSignUrlFn.spec.js +26 -0
- package/parser/functions/cloud/cloudStorageFn.js +23 -0
- package/parser/functions/cloud/cloudStorageFn.spec.js +21 -0
- package/parser/functions/cloud/cloudUploadFileFn.js +24 -0
- package/parser/functions/cloud/cloudUploadFileFn.spec.js +29 -0
- package/parser/functions/cloud/register.js +61 -0
- package/parser/functions/cloudFn.js +21 -0
- package/parser/functions/controlFn.js +34 -0
- package/parser/functions/controls/awaitFn.js +21 -0
- package/parser/functions/controls/awaitFn.spec.js +48 -0
- package/parser/functions/controls/conditionalElifFn.js +19 -0
- package/parser/functions/controls/conditionalElseFn.js +13 -0
- package/parser/functions/controls/conditionalFn.js +62 -0
- package/parser/functions/controls/conditionalFn.spec.js +167 -0
- package/parser/functions/controls/conditionalIfFn.js +19 -0
- package/parser/functions/controls/forEachFn.js +70 -0
- package/parser/functions/controls/forEachFn.spec.js +101 -0
- package/parser/functions/controls/forFn.js +55 -0
- package/parser/functions/controls/forFn.spec.js +85 -0
- package/parser/functions/controls/functionCallFn.js +38 -0
- package/parser/functions/controls/functionRunFn.js +40 -0
- package/parser/functions/controls/functionRunFn.spec.js +77 -0
- package/parser/functions/controls/groupFn.js +42 -0
- package/parser/functions/controls/groupFn.spec.js +63 -0
- package/parser/functions/controls/preconditionFn.js +40 -0
- package/parser/functions/controls/preconditionFn.spec.js +97 -0
- package/parser/functions/controls/register.js +45 -0
- package/parser/functions/controls/returnFn.js +21 -0
- package/parser/functions/controls/returnFn.spec.js +44 -0
- package/parser/functions/controls/switchCaseFn.js +22 -0
- package/parser/functions/controls/switchDefaultFn.js +13 -0
- package/parser/functions/controls/switchFn.js +50 -0
- package/parser/functions/controls/switchFn.spec.js +104 -0
- package/parser/functions/controls/taskCallFn.js +31 -0
- package/parser/functions/controls/throwFn.js +21 -0
- package/parser/functions/controls/throwFn.spec.js +56 -0
- package/parser/functions/controls/tryCatchFn.js +67 -0
- package/parser/functions/controls/tryCatchFn.spec.js +180 -0
- package/parser/functions/controls/whileFn.js +52 -0
- package/parser/functions/controls/whileFn.spec.js +94 -0
- package/parser/functions/db/dbAddFn.js +38 -0
- package/parser/functions/db/dbAddFn.spec.js +72 -0
- package/parser/functions/db/dbAddOrEditFn.js +39 -0
- package/parser/functions/db/dbAddOrEditFn.spec.js +97 -0
- package/parser/functions/db/dbAddonAttr.js +17 -0
- package/parser/functions/db/dbBulkAddFn.js +54 -0
- package/parser/functions/db/dbBulkAddFn.spec.js +94 -0
- package/parser/functions/db/dbBulkDeleteFn.js +35 -0
- package/parser/functions/db/dbBulkDeleteFn.spec.js +28 -0
- package/parser/functions/db/dbBulkFn.js +20 -0
- package/parser/functions/db/dbBulkPatchFn.js +35 -0
- package/parser/functions/db/dbBulkPatchFn.spec.js +42 -0
- package/parser/functions/db/dbBulkUpdateFn.js +35 -0
- package/parser/functions/db/dbBulkUpdateFn.spec.js +42 -0
- package/parser/functions/db/dbDelFn.js +34 -0
- package/parser/functions/db/dbDelFn.spec.js +62 -0
- package/parser/functions/db/dbDirectQueryFn.js +37 -0
- package/parser/functions/db/dbDirectQueryFn.spec.js +104 -0
- package/parser/functions/db/dbEditFn.js +40 -0
- package/parser/functions/db/dbEditFn.spec.js +122 -0
- package/parser/functions/db/dbExternalDirectQueryFn.js +29 -0
- package/parser/functions/db/dbExternalDirectQueryFn.spec.js +103 -0
- package/parser/functions/db/dbExternalFn.js +29 -0
- package/parser/functions/db/dbGetFn.js +40 -0
- package/parser/functions/db/dbGetFn.spec.js +117 -0
- package/parser/functions/db/dbHasFn.js +34 -0
- package/parser/functions/db/dbHasFn.spec.js +62 -0
- package/parser/functions/db/dbPatchFn.js +39 -0
- package/parser/functions/db/dbPatchFn.spec.js +88 -0
- package/parser/functions/db/dbQueryFn.js +73 -0
- package/parser/functions/db/dbQueryFn.spec.js +333 -0
- package/parser/functions/db/dbSchemaFn.js +25 -0
- package/parser/functions/db/dbSchemaFn.spec.js +42 -0
- package/parser/functions/db/dbSetDatasourceFn.js +18 -0
- package/parser/functions/db/dbSetDatasourceFn.spec.js +44 -0
- package/parser/functions/db/dbTransactionFn.js +43 -0
- package/parser/functions/db/dbTransactionFn.spec.js +63 -0
- package/parser/functions/db/dbTruncateFn.js +33 -0
- package/parser/functions/db/dbTruncateFn.spec.js +42 -0
- package/parser/functions/db/register.js +52 -0
- package/parser/functions/db/schema.js +8 -0
- package/parser/functions/dbFn.js +31 -0
- package/parser/functions/debug/debugLogFn.js +21 -0
- package/parser/functions/debug/debugLogFn.spec.js +44 -0
- package/parser/functions/debug/debugStopFn.js +21 -0
- package/parser/functions/debug/debugStopFn.spec.js +44 -0
- package/parser/functions/debug/register.js +11 -0
- package/parser/functions/debugFn.js +18 -0
- package/parser/functions/expect/register.js +44 -0
- package/parser/functions/expect/unitExpectToBeWithinFn.js +28 -0
- package/parser/functions/expect/unitExpectToBeWithinFn.spec.js +61 -0
- package/parser/functions/expect/unitExpectToThrowFn.js +15 -0
- package/parser/functions/expect/unitExpectToThrowFn.spec.js +40 -0
- package/parser/functions/expect/unitExpectWithArgumentsFn.js +49 -0
- package/parser/functions/expect/unitExpectWithArgumentsFn.spec.js +341 -0
- package/parser/functions/expect/unitExpectWithoutArgumentsFn.js +42 -0
- package/parser/functions/expect/unitExpectWithoutArgumentsFn.spec.js +69 -0
- package/parser/functions/expect/workflowExpectToBeWithinFn.js +22 -0
- package/parser/functions/expect/workflowExpectToBeWithinFn.spec.js +70 -0
- package/parser/functions/expect/workflowExpectToThrowFn.js +21 -0
- package/parser/functions/expect/workflowExpectToThrowFn.spec.js +56 -0
- package/parser/functions/expect/workflowExpectWithArgumentsFn.js +40 -0
- package/parser/functions/expect/workflowExpectWithArgumentsFn.spec.js +301 -0
- package/parser/functions/expect/workflowExpectWithoutArgumentsFn.js +39 -0
- package/parser/functions/expect/workflowExpectWithoutArgumentsFn.spec.js +87 -0
- package/parser/functions/math/allMathFn.js +64 -0
- package/parser/functions/math/allMathFn.spec.js +100 -0
- package/parser/functions/math/register.js +9 -0
- package/parser/functions/mathFn.js +15 -0
- package/parser/functions/middlewareCallFn.js +43 -0
- package/parser/functions/middlewareCallFn.spec.js +44 -0
- package/parser/functions/object/objectEntriesFn.js +22 -0
- package/parser/functions/object/objectEntriesFn.spec.js +44 -0
- package/parser/functions/object/objectKeysFn.js +22 -0
- package/parser/functions/object/objectKeysFn.spec.js +44 -0
- package/parser/functions/object/objectValuesFn.js +22 -0
- package/parser/functions/object/objectValuesFn.spec.js +44 -0
- package/parser/functions/object/register.js +13 -0
- package/parser/functions/objectFn.js +22 -0
- package/parser/functions/redis/redisCountFn.js +26 -0
- package/parser/functions/redis/redisCountFn.spec.js +58 -0
- package/parser/functions/redis/redisDecrFn.js +28 -0
- package/parser/functions/redis/redisDecrFn.spec.js +47 -0
- package/parser/functions/redis/redisDelFn.js +25 -0
- package/parser/functions/redis/redisDelFn.spec.js +58 -0
- package/parser/functions/redis/redisGetFn.js +26 -0
- package/parser/functions/redis/redisGetFn.spec.js +67 -0
- package/parser/functions/redis/redisHasFn.js +26 -0
- package/parser/functions/redis/redisHasFn.spec.js +58 -0
- package/parser/functions/redis/redisIncrFn.js +28 -0
- package/parser/functions/redis/redisIncrFn.spec.js +74 -0
- package/parser/functions/redis/redisKeysFn.js +26 -0
- package/parser/functions/redis/redisKeysFn.spec.js +67 -0
- package/parser/functions/redis/redisPopFn.js +26 -0
- package/parser/functions/redis/redisPopFn.spec.js +67 -0
- package/parser/functions/redis/redisPushFn.js +28 -0
- package/parser/functions/redis/redisPushFn.spec.js +71 -0
- package/parser/functions/redis/redisRangeFn.js +30 -0
- package/parser/functions/redis/redisRangeFn.spec.js +80 -0
- package/parser/functions/redis/redisRateLimitFn.js +32 -0
- package/parser/functions/redis/redisRateLimitFn.spec.js +87 -0
- package/parser/functions/redis/redisRemoveFn.js +29 -0
- package/parser/functions/redis/redisRemoveFn.spec.js +65 -0
- package/parser/functions/redis/redisSetFn.js +29 -0
- package/parser/functions/redis/redisSetFn.spec.js +89 -0
- package/parser/functions/redis/redisShiftFn.js +26 -0
- package/parser/functions/redis/redisShiftFn.spec.js +67 -0
- package/parser/functions/redis/redisUnshiftFn.js +28 -0
- package/parser/functions/redis/redisUnshiftFn.spec.js +73 -0
- package/parser/functions/redis/register.js +37 -0
- package/parser/functions/redisFn.js +31 -0
- package/parser/functions/register.js +91 -0
- package/parser/functions/schema/register.js +30 -0
- package/parser/functions/schema/schemaFn.js +173 -0
- package/parser/functions/schema/schemaFn.spec.js +92 -0
- package/parser/functions/schema/schemaParseArrayFn.js +47 -0
- package/parser/functions/schema/schemaParseArrayFn.spec.js +134 -0
- package/parser/functions/schema/schemaParseAttributeFn.js +194 -0
- package/parser/functions/schema/schemaParseAttributeFn.spec.js +281 -0
- package/parser/functions/schema/schemaParseConstantFn.js +136 -0
- package/parser/functions/schema/schemaParseConstantFn.spec.js +122 -0
- package/parser/functions/schema/schemaParseEnum.js +52 -0
- package/parser/functions/schema/schemaParseEnum.spec.js +47 -0
- package/parser/functions/schema/schemaParseImmutableFn.js +134 -0
- package/parser/functions/schema/schemaParseImmutableFn.spec.js +99 -0
- package/parser/functions/schema/schemaParseObjectFn.js +171 -0
- package/parser/functions/schema/schemaParseObjectFn.spec.js +223 -0
- package/parser/functions/schema/utils.js +136 -0
- package/parser/functions/schema/utils.spec.js +27 -0
- package/parser/functions/security/register.js +64 -0
- package/parser/functions/security/securityCheckPasswordFn.js +24 -0
- package/parser/functions/security/securityCheckPasswordFn.spec.js +22 -0
- package/parser/functions/security/securityCreateAuthTokenFn.js +24 -0
- package/parser/functions/security/securityCreateAuthTokenFn.spec.js +24 -0
- package/parser/functions/security/securityCreateCurveKeyFn.js +19 -0
- package/parser/functions/security/securityCreateCurveKeyFn.spec.js +22 -0
- package/parser/functions/security/securityCreatePasswordFn.js +26 -0
- package/parser/functions/security/securityCreatePasswordFn.spec.js +26 -0
- package/parser/functions/security/securityCreateRsaKeyFn.js +19 -0
- package/parser/functions/security/securityCreateRsaKeyFn.spec.js +22 -0
- package/parser/functions/security/securityCreateSecretKeyFn.js +24 -0
- package/parser/functions/security/securityCreateSecretKeyFn.spec.js +22 -0
- package/parser/functions/security/securityCreateUuidFn.js +26 -0
- package/parser/functions/security/securityCreateUuidFn.spec.js +27 -0
- package/parser/functions/security/securityDecryptFn.js +24 -0
- package/parser/functions/security/securityDecryptFn.spec.js +24 -0
- package/parser/functions/security/securityEncryptFn.js +24 -0
- package/parser/functions/security/securityEncryptFn.spec.js +24 -0
- package/parser/functions/security/securityJweDecodeFn.js +24 -0
- package/parser/functions/security/securityJweDecodeFn.spec.js +26 -0
- package/parser/functions/security/securityJweEncodeFn.js +24 -0
- package/parser/functions/security/securityJweEncodeFn.spec.js +26 -0
- package/parser/functions/security/securityJwsDecodeFn.js +24 -0
- package/parser/functions/security/securityJwsDecodeFn.spec.js +25 -0
- package/parser/functions/security/securityJwsEncodeFn.js +24 -0
- package/parser/functions/security/securityJwsEncodeFn.spec.js +25 -0
- package/parser/functions/security/securityRandomBytesFn.js +24 -0
- package/parser/functions/security/securityRandomBytesFn.spec.js +21 -0
- package/parser/functions/security/securityRandomNumberFn.js +24 -0
- package/parser/functions/security/securityRandomNumberFn.spec.js +22 -0
- package/parser/functions/securityFn.js +30 -0
- package/parser/functions/storage/register.js +44 -0
- package/parser/functions/storage/storageCreateAttachmentFn.js +25 -0
- package/parser/functions/storage/storageCreateAttachmentFn.spec.js +87 -0
- package/parser/functions/storage/storageCreateAudioFn.js +29 -0
- package/parser/functions/storage/storageCreateAudioFn.spec.js +98 -0
- package/parser/functions/storage/storageCreateFileResourceFn.js +19 -0
- package/parser/functions/storage/storageCreateFileResourceFn.spec.js +72 -0
- package/parser/functions/storage/storageCreateImageFn.js +25 -0
- package/parser/functions/storage/storageCreateImageFn.spec.js +98 -0
- package/parser/functions/storage/storageCreateVideoFn.js +29 -0
- package/parser/functions/storage/storageCreateVideoFn.spec.js +99 -0
- package/parser/functions/storage/storageDeleteFileFn.js +17 -0
- package/parser/functions/storage/storageDeleteFileFn.spec.js +67 -0
- package/parser/functions/storage/storageReadFileResourceFn.js +19 -0
- package/parser/functions/storage/storageReadFileResourceFn.spec.js +60 -0
- package/parser/functions/storage/storageSignPrivateUrlFn.js +19 -0
- package/parser/functions/storage/storageSignPrivateUrlFn.spec.js +72 -0
- package/parser/functions/storageFn.js +24 -0
- package/parser/functions/stream/register.js +13 -0
- package/parser/functions/stream/streamFromCsvFn.js +20 -0
- package/parser/functions/stream/streamFromCsvFn.spec.js +69 -0
- package/parser/functions/stream/streamFromJsonlFn.js +21 -0
- package/parser/functions/stream/streamFromJsonlFn.spec.js +47 -0
- package/parser/functions/stream/streamFromRequestFn.js +50 -0
- package/parser/functions/stream/streamFromRequestFn.spec.js +103 -0
- package/parser/functions/streamFn.js +19 -0
- package/parser/functions/text/allTextWithReturnValueFn.js +36 -0
- package/parser/functions/text/allTextWithReturnValueFn.spec.js +100 -0
- package/parser/functions/text/allTextWithoutReturnValueFn.js +34 -0
- package/parser/functions/text/allTextWithoutReturnValueFn.spec.js +122 -0
- package/parser/functions/text/register.js +17 -0
- package/parser/functions/textFn.js +33 -0
- package/parser/functions/toolCallFn.js +40 -0
- package/parser/functions/toolCallFn.spec.js +28 -0
- package/parser/functions/unitExpectFn.js +20 -0
- package/parser/functions/unitExpectFn.spec.js +21 -0
- package/parser/functions/util/register.js +29 -0
- package/parser/functions/util/utilGeoDistanceFn.js +30 -0
- package/parser/functions/util/utilGeoDistanceFn.spec.js +79 -0
- package/parser/functions/util/utilGetAllInputFn.js +20 -0
- package/parser/functions/util/utilGetAllInputFn.spec.js +33 -0
- package/parser/functions/util/utilGetEnvFn.js +20 -0
- package/parser/functions/util/utilGetEnvFn.spec.js +33 -0
- package/parser/functions/util/utilGetRawInputFn.js +25 -0
- package/parser/functions/util/utilGetRawInputFn.spec.js +55 -0
- package/parser/functions/util/utilGetVarsFn.js +20 -0
- package/parser/functions/util/utilGetVarsFn.spec.js +33 -0
- package/parser/functions/util/utilIpLookupFn.js +22 -0
- package/parser/functions/util/utilIpLookupFn.spec.js +37 -0
- package/parser/functions/util/utilPostProcessFn.js +43 -0
- package/parser/functions/util/utilPostProcessFn.spec.js +63 -0
- package/parser/functions/util/utilSendEmailFn.js +108 -0
- package/parser/functions/util/utilSendEmailFn.spec.js +62 -0
- package/parser/functions/util/utilSetHeaderFn.js +22 -0
- package/parser/functions/util/utilSetHeaderFn.spec.js +48 -0
- package/parser/functions/util/utilSleepFn.js +19 -0
- package/parser/functions/util/utilSleepFn.spec.js +44 -0
- package/parser/functions/util/utilTemplateFn.js +19 -0
- package/parser/functions/util/utilTemplateFn.spec.js +78 -0
- package/parser/functions/utilFn.js +39 -0
- package/parser/functions/varFn.js +51 -0
- package/parser/functions/varFn.spec.js +173 -0
- package/parser/functions/webflowFn.js +19 -0
- package/parser/functions/workflowExpectFn.js +20 -0
- package/parser/functions/zip/register.js +20 -0
- package/parser/functions/zip/zipAddToArchiveFn.js +31 -0
- package/parser/functions/zip/zipAddToArchiveFn.spec.js +78 -0
- package/parser/functions/zip/zipCreateArchiveFn.js +29 -0
- package/parser/functions/zip/zipCreateArchiveFn.spec.js +53 -0
- package/parser/functions/zip/zipDeleteFromArchiveFn.js +23 -0
- package/parser/functions/zip/zipDeleteFromArchiveFn.spec.js +69 -0
- package/parser/functions/zip/zipExtractFn.js +23 -0
- package/parser/functions/zip/zipExtractFn.spec.js +52 -0
- package/parser/functions/zip/zipViewContentsFn.js +24 -0
- package/parser/functions/zip/zipViewContentsFn.spec.js +52 -0
- package/parser/functions/zipFn.js +21 -0
- package/parser/generic/arrayOfObjectAttrReq.js +47 -0
- package/parser/generic/arrayOfObjectAttrReq.spec.js +254 -0
- package/parser/generic/arrayOfStringLiterals.js +45 -0
- package/parser/generic/arrayOfStringLiterals.spec.js +56 -0
- package/parser/generic/arrayWithValues.js +35 -0
- package/parser/generic/arrayWithValues.spec.js +72 -0
- package/parser/generic/asVariable.js +23 -0
- package/parser/generic/asVariable.spec.js +37 -0
- package/parser/generic/assignableVariableAs.js +27 -0
- package/parser/generic/assignableVariableAs.spec.js +52 -0
- package/parser/generic/assignableVariableProperty.js +52 -0
- package/parser/generic/assignableVariableProperty.spec.js +52 -0
- package/parser/generic/booleanValue.js +22 -0
- package/parser/generic/bracketAccessor.js +53 -0
- package/parser/generic/castedValue.js +14 -0
- package/parser/generic/castedValue.spec.js +29 -0
- package/parser/generic/chainedIdentifier.js +48 -0
- package/parser/generic/chainedIdentifier.spec.js +89 -0
- package/parser/generic/completeAuthVariable.js +13 -0
- package/parser/generic/completeAuthVariable.spec.js +23 -0
- package/parser/generic/completeEnvVariable.js +79 -0
- package/parser/generic/completeEnvVariable.spec.js +94 -0
- package/parser/generic/completeErrorVariable.js +39 -0
- package/parser/generic/completeErrorVariable.spec.js +17 -0
- package/parser/generic/completeInputVariable.js +42 -0
- package/parser/generic/completeInputVariable.spec.js +53 -0
- package/parser/generic/enumValue.js +23 -0
- package/parser/generic/expressionFn.js +415 -0
- package/parser/generic/expressionFn.spec.js +588 -0
- package/parser/generic/filterFn.js +48 -0
- package/parser/generic/filterFn.spec.js +47 -0
- package/parser/generic/filterNames.js +381 -0
- package/parser/generic/functionAttrReq.js +279 -0
- package/parser/generic/functionAttrReq.spec.js +353 -0
- package/parser/generic/longFormVariable.js +46 -0
- package/parser/generic/longFormVariable.spec.js +25 -0
- package/parser/generic/minimalFnBody.js +24 -0
- package/parser/generic/minimalFnBody.spec.js +47 -0
- package/parser/generic/mockAttribute.js +21 -0
- package/parser/generic/mockAttribute.spec.js +57 -0
- package/parser/generic/multilineFilterFn.js +27 -0
- package/parser/generic/multilineFilterFn.spec.js +51 -0
- package/parser/generic/numberValue.js +27 -0
- package/parser/generic/objectAttrReq.js +243 -0
- package/parser/generic/objectAttrReq.spec.js +412 -0
- package/parser/generic/objectWithAttributes.js +74 -0
- package/parser/generic/objectWithAttributes.spec.js +147 -0
- package/parser/generic/optionalCommentBlock.js +32 -0
- package/parser/generic/pipedFilter.js +20 -0
- package/parser/generic/register.js +124 -0
- package/parser/generic/requiredValueFnBody.js +40 -0
- package/parser/generic/requiredValueFnBody.spec.js +56 -0
- package/parser/generic/shortFormVariable.js +17 -0
- package/parser/generic/shortFormVariable.spec.js +27 -0
- package/parser/generic/stringArray.js +33 -0
- package/parser/generic/stringArray.spec.js +55 -0
- package/parser/generic/tagsAttribute.js +14 -0
- package/parser/generic/tagsAttribute.spec.js +47 -0
- package/parser/generic/utils.js +14 -0
- package/parser/generic/valueExpressionForResponse.js +51 -0
- package/parser/generic/variableOnly.js +13 -0
- package/parser/generic/variableOnly.spec.js +47 -0
- package/parser/mcp_server_parser.js +130 -0
- package/parser/mcp_server_parser.spec.js +478 -0
- package/parser/mcp_server_trigger_parser.js +142 -0
- package/parser/mcp_server_trigger_parser.spec.js +396 -0
- package/parser/metadata/columnMetadataDefinition.js +32 -0
- package/parser/metadata/columnMetadataDefinition.spec.js +47 -0
- package/parser/metadata/enumColumnMetadataDefinition.js +46 -0
- package/parser/metadata/enumColumnMetadataDefinition.spec.js +59 -0
- package/parser/metadata/objectColumnMetadataDefinition.js +26 -0
- package/parser/metadata/register.js +22 -0
- package/parser/middleware_parser.js +137 -0
- package/parser/middleware_parser.spec.js +203 -0
- package/parser/parser.js +87 -0
- package/parser/query_parser.js +183 -0
- package/parser/query_parser.spec.js +141 -0
- package/parser/realtime_channel_parser.js +45 -0
- package/parser/realtime_channel_parser.spec.js +20 -0
- package/parser/realtime_trigger_parser.js +141 -0
- package/parser/realtime_trigger_parser.spec.js +469 -0
- package/parser/register.js +88 -0
- package/parser/table_parser.js +126 -0
- package/parser/table_parser.spec.js +138 -0
- package/parser/table_trigger_parser.js +144 -0
- package/parser/table_trigger_parser.spec.js +449 -0
- package/parser/task_parser.js +116 -0
- package/parser/task_parser.spec.js +83 -0
- package/parser/test_parser.js +39 -0
- package/parser/tests/agent/agent_parser.spec.js +52 -0
- package/parser/tests/agent/valid_sources/customer_servier_agent.xs +45 -0
- package/parser/tests/api_group/api_group_parser.spec.js +52 -0
- package/parser/tests/api_group/valid_sources/api_group_history.xs +4 -0
- package/parser/tests/api_group/valid_sources/basic_api_group.xs +3 -0
- package/parser/tests/api_group/valid_sources/complete_api_group.xs +7 -0
- package/parser/tests/api_group/valid_sources/protected_api_group.xs +7 -0
- package/parser/tests/function/function_parser.spec.js +52 -0
- package/parser/tests/function/valid_sources/all_controls.xs +68 -0
- package/parser/tests/function/valid_sources/all_query_return_types.xs +227 -0
- package/parser/tests/function/valid_sources/all_storage.xs +45 -0
- package/parser/tests/function/valid_sources/discord_poll_send_to_slack.xs +133 -0
- package/parser/tests/function/valid_sources/expression_in_response.xs +22 -0
- package/parser/tests/function/valid_sources/filter_by_value.xs +55 -0
- package/parser/tests/function/valid_sources/filter_query.xs +82 -0
- package/parser/tests/function/valid_sources/large_regex.xs +13 -0
- package/parser/tests/function/valid_sources/ledash_ends_with.xs +90 -0
- package/parser/tests/function/valid_sources/multiline_description.xs +28 -0
- package/parser/tests/function/valid_sources/multiline_expr.xs +41 -0
- package/parser/tests/function/valid_sources/set_theory_fn.xs +129 -0
- package/parser/tests/function/valid_sources/simple_unit_test.xs +33 -0
- package/parser/tests/function/valid_sources/valid_officer.xs +57 -0
- package/parser/tests/function/valid_sources/webflow.xs +18 -0
- package/parser/tests/query/query_parser.spec.js +54 -0
- package/parser/tests/query/valid_sources/all_basics.xs +51 -0
- package/parser/tests/query/valid_sources/all_cloud.xs +141 -0
- package/parser/tests/query/valid_sources/all_db.xs +102 -0
- package/parser/tests/query/valid_sources/all_external_db.xs +43 -0
- package/parser/tests/query/valid_sources/all_keywords.xs +65 -0
- package/parser/tests/query/valid_sources/all_math.xs +53 -0
- package/parser/tests/query/valid_sources/all_object.xs +25 -0
- package/parser/tests/query/valid_sources/all_redis.xs +106 -0
- package/parser/tests/query/valid_sources/all_security.xs +105 -0
- package/parser/tests/query/valid_sources/all_stream.xs +69 -0
- package/parser/tests/query/valid_sources/all_text.xs +54 -0
- package/parser/tests/query/valid_sources/all_util.xs +66 -0
- package/parser/tests/query/valid_sources/all_zip.xs +39 -0
- package/parser/tests/query/valid_sources/arrays.xs +33 -0
- package/parser/tests/query/valid_sources/disabled_response.xs +27 -0
- package/parser/tests/query/valid_sources/multiline_lambda_GET.xs +50 -0
- package/parser/tests/query/valid_sources/mutliline_query.xs +140 -0
- package/parser/tests/query/valid_sources/patch_expression_multiline.xs +27 -0
- package/parser/tests/query/valid_sources/query_cache.xs +34 -0
- package/parser/tests/query/valid_sources/query_example.xs +43 -0
- package/parser/tests/query/valid_sources/query_mini.xs +11 -0
- package/parser/tests/query/valid_sources/query_rich_inputs.xs +32 -0
- package/parser/tests/query/valid_sources/simple_unit_test.xs +33 -0
- package/parser/tests/query/valid_sources/test_with_slashes.xs +22 -0
- package/parser/tests/query/valid_sources/with_unit_test.xs +97 -0
- package/parser/tests/table/table_parser.spec.js +52 -0
- package/parser/tests/table/valid_sources/account.xs +31 -0
- package/parser/tests/table/valid_sources/all_basic_columns.xs +44 -0
- package/parser/tests/table/valid_sources/basic_table.xs +15 -0
- package/parser/tests/table/valid_sources/empty_object.xs +17 -0
- package/parser/tests/table/valid_sources/empty_table.xs +3 -0
- package/parser/tests/table/valid_sources/multiline_index.xs +33 -0
- package/parser/tests/table/valid_sources/relation.xs +44 -0
- package/parser/tests/table/valid_sources/rich_columns.xs +28 -0
- package/parser/tests/table/valid_sources/table_with_comments.xs +17 -0
- package/parser/tests/table/valid_sources/table_with_search_index.xs +31 -0
- package/parser/tests/table/valid_sources/view_table.xs +62 -0
- package/parser/tests/task/task_parser.spec.js +53 -0
- package/parser/tests/task/valid_sources/active_event.xs +11 -0
- package/parser/tests/task/valid_sources/all_events.xs +17 -0
- package/parser/tests/task/valid_sources/daily_sales_report.xs +56 -0
- package/parser/tests/task/valid_sources/inactive_event.xs +11 -0
- package/parser/tests/workflow_test/valid_sources/basic_workflow_test.xs +13 -0
- package/parser/tests/workflow_test/workflow_test_parser.spec.js +52 -0
- package/parser/tool_parser.js +121 -0
- package/parser/tool_parser.spec.js +102 -0
- package/parser/workflow_test_parser.js +73 -0
- package/parser/workflow_test_parser.spec.js +71 -0
- package/parser/workspace_parser.js +38 -0
- package/parser/workspace_parser.spec.js +142 -0
- package/parser/workspace_trigger_parser.js +118 -0
- package/parser/workspace_trigger_parser.spec.js +332 -0
- package/profile-parser.js +214 -0
- package/server.js +59 -0
- package/toTmLanguage.js +75 -0
- package/utils.js +55 -0
- 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
|
+
```
|