@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,173 @@
|
|
|
1
|
+
import { isArray } from "lodash-es";
|
|
2
|
+
import { schemaExpectArray } from "./schemaParseArrayFn.js";
|
|
3
|
+
import { schemaExpectConstant } from "./schemaParseConstantFn.js";
|
|
4
|
+
import { schemaExpectEnum } from "./schemaParseEnum.js";
|
|
5
|
+
import { schemaExpectObject } from "./schemaParseObjectFn.js";
|
|
6
|
+
import { schemaExpectOneOf } from "./utils.js";
|
|
7
|
+
|
|
8
|
+
const getErrorMessageForSchema = (schema) => {
|
|
9
|
+
if (
|
|
10
|
+
schemaExpectOneOf(schema, [
|
|
11
|
+
"string",
|
|
12
|
+
"number",
|
|
13
|
+
"boolean",
|
|
14
|
+
"timestamp",
|
|
15
|
+
"null",
|
|
16
|
+
])
|
|
17
|
+
) {
|
|
18
|
+
if (isArray(schema)) {
|
|
19
|
+
return `Expected one of the following types: ${schema.join(", ")}`;
|
|
20
|
+
} else {
|
|
21
|
+
return `Expected a ${schema}`;
|
|
22
|
+
}
|
|
23
|
+
} else if (schemaExpectConstant(schema)) {
|
|
24
|
+
if (isArray(schema)) {
|
|
25
|
+
return `Expected one of the following constants: ${schema.join(", ")}`;
|
|
26
|
+
} else {
|
|
27
|
+
return `Expected a ${schema}`;
|
|
28
|
+
}
|
|
29
|
+
} else if (schemaExpectArray(schema)) {
|
|
30
|
+
return `Expected an array of ${schema[0]}`;
|
|
31
|
+
} else if (schemaExpectObject(schema)) {
|
|
32
|
+
return `Expected an object {}`;
|
|
33
|
+
} else if (schemaExpectEnum(schema)) {
|
|
34
|
+
return `Expected one of the following enum values: ${schema.join(", ")}`;
|
|
35
|
+
} else if (schemaExpectOneOf(schema, ["mock"])) {
|
|
36
|
+
return `Expected a mock`;
|
|
37
|
+
} else if (schemaExpectOneOf(schema, ["expression"])) {
|
|
38
|
+
return `Expected an expression`;
|
|
39
|
+
} else if (schemaExpectOneOf(schema, ["query"])) {
|
|
40
|
+
return `Expected a database query expression`;
|
|
41
|
+
} else if (schemaExpectOneOf(schema, ["constant"])) {
|
|
42
|
+
return `Expected a value expression (no variables allowed)`;
|
|
43
|
+
} else if (schemaExpectOneOf(schema, ["stack"])) {
|
|
44
|
+
return `Expected a stack definition`;
|
|
45
|
+
} else {
|
|
46
|
+
return `Invalid schema: received ${JSON.stringify(schema)}`;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Parses input based on a schema definition
|
|
52
|
+
* @param {import('../base_parser.js').XanoBaseParser} $
|
|
53
|
+
*/
|
|
54
|
+
export function schemaFn($) {
|
|
55
|
+
return (token, schema, captured = {}, options) => {
|
|
56
|
+
$.sectionStack.push("schema");
|
|
57
|
+
|
|
58
|
+
$.OR({
|
|
59
|
+
IGNORE_AMBIGUITIES: true,
|
|
60
|
+
ERR_MSG: getErrorMessageForSchema(schema),
|
|
61
|
+
DEF: [
|
|
62
|
+
{
|
|
63
|
+
GATE: () =>
|
|
64
|
+
schemaExpectOneOf(
|
|
65
|
+
schema,
|
|
66
|
+
["string", "number", "boolean", "timestamp"],
|
|
67
|
+
captured
|
|
68
|
+
),
|
|
69
|
+
ALT: () => {
|
|
70
|
+
$.SUBRULE($.schemaParseImmutableFn, {
|
|
71
|
+
ARGS: [token, schema, captured],
|
|
72
|
+
});
|
|
73
|
+
return true;
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
GATE: () => schemaExpectConstant(schema),
|
|
78
|
+
ALT: () => {
|
|
79
|
+
$.SUBRULE($.schemaParseConstantFn, {
|
|
80
|
+
ARGS: [token, schema, captured],
|
|
81
|
+
});
|
|
82
|
+
return true;
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
GATE: () => schemaExpectArray(schema),
|
|
87
|
+
ALT: () => {
|
|
88
|
+
$.SUBRULE($.schemaParseArrayFn, {
|
|
89
|
+
ARGS: [token, schema, captured],
|
|
90
|
+
});
|
|
91
|
+
return true;
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
GATE: () => schemaExpectObject(schema),
|
|
96
|
+
ALT: () => {
|
|
97
|
+
$.SUBRULE($.schemaParseObjectFn, {
|
|
98
|
+
ARGS: [token, schema, captured],
|
|
99
|
+
});
|
|
100
|
+
return true;
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
GATE: () => schemaExpectEnum(schema),
|
|
105
|
+
ALT: () => {
|
|
106
|
+
$.SUBRULE($.schemaParseEnumFn, { ARGS: [token, schema, captured] });
|
|
107
|
+
return true;
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
// FIXME: this is slowing down parsing significantly
|
|
112
|
+
// handles "[expression]" and "[query]" types
|
|
113
|
+
GATE: () =>
|
|
114
|
+
schemaExpectOneOf(schema, [
|
|
115
|
+
"expression",
|
|
116
|
+
"constant",
|
|
117
|
+
"query",
|
|
118
|
+
"stack",
|
|
119
|
+
"test-stack",
|
|
120
|
+
]),
|
|
121
|
+
ALT: () => {
|
|
122
|
+
$.OR1({
|
|
123
|
+
IGNORE_AMBIGUITIES: true,
|
|
124
|
+
DEF: [
|
|
125
|
+
{
|
|
126
|
+
GATE: () =>
|
|
127
|
+
schemaExpectOneOf(schema, ["stack", "test-stack"]),
|
|
128
|
+
ALT: () => {
|
|
129
|
+
const isTest = schemaExpectOneOf(schema, ["test-stack"]);
|
|
130
|
+
$.SUBRULE($.nakedStackFn, {
|
|
131
|
+
ARGS: [
|
|
132
|
+
{
|
|
133
|
+
allowExpectStatements: isTest,
|
|
134
|
+
allowCallStatements: isTest,
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
});
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
GATE: () =>
|
|
142
|
+
schemaExpectOneOf(schema, [
|
|
143
|
+
"expression",
|
|
144
|
+
"query",
|
|
145
|
+
"constant",
|
|
146
|
+
]),
|
|
147
|
+
ALT: () => {
|
|
148
|
+
// a different set of filters is allowed on query expressions
|
|
149
|
+
const isQuery = schemaExpectOneOf(schema, ["query"]);
|
|
150
|
+
const isValue = schemaExpectOneOf(schema, ["constant"]);
|
|
151
|
+
$.SUBRULE($.expressionFn, {
|
|
152
|
+
ARGS: [
|
|
153
|
+
token,
|
|
154
|
+
options || {
|
|
155
|
+
allowQueryExpression: isQuery,
|
|
156
|
+
allowVariable: !isValue,
|
|
157
|
+
allowExpression: !isValue,
|
|
158
|
+
allowComparison: !isValue,
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
}); // e.g., $foo.test
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
],
|
|
165
|
+
});
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
$.sectionStack.pop();
|
|
172
|
+
};
|
|
173
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { describe, it } from "mocha";
|
|
3
|
+
import { EqualToken } from "../../../lexer/control.js";
|
|
4
|
+
import { lexDocument } from "../../../lexer/lexer.js";
|
|
5
|
+
import { Identifier } from "../../../lexer/tokens.js";
|
|
6
|
+
import { parser } from "../../test_parser.js";
|
|
7
|
+
|
|
8
|
+
export function parserExtension() {
|
|
9
|
+
// this rule requires a foo field to be defined
|
|
10
|
+
this.schemaFn_test_immutable = this.RULE("schemaFn_test_immutable", () => {
|
|
11
|
+
const schema = "[string]";
|
|
12
|
+
const name = this.CONSUME(Identifier);
|
|
13
|
+
this.CONSUME(EqualToken); // "="
|
|
14
|
+
this.SUBRULE(this.schemaFn, { ARGS: [name, schema] });
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
// this rule requires a foo field to be defined
|
|
18
|
+
this.schemaFn_test_expression = this.RULE("schemaFn_test_expression", () => {
|
|
19
|
+
const schema = "[expression]";
|
|
20
|
+
const name = this.CONSUME(Identifier);
|
|
21
|
+
this.CONSUME(EqualToken); // "="
|
|
22
|
+
this.SUBRULE(this.schemaFn, { ARGS: [name, schema] });
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// this rule requires a foo field to be defined
|
|
26
|
+
this.schemaFn_test_mock = this.RULE("schemaFn_test_mock", () => {
|
|
27
|
+
const schema = "[mock]";
|
|
28
|
+
const name = this.CONSUME(Identifier);
|
|
29
|
+
this.CONSUME(EqualToken); // "="
|
|
30
|
+
this.SUBRULE(this.schemaFn, { ARGS: [name, schema] });
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// this rule requires a foo field to be defined
|
|
34
|
+
this.schemaFn_test_enum = this.RULE("schemaFn_test_enum", () => {
|
|
35
|
+
const schema = ["yes", 123];
|
|
36
|
+
const name = this.CONSUME(Identifier);
|
|
37
|
+
this.CONSUME(EqualToken); // "="
|
|
38
|
+
this.SUBRULE(this.schemaFn, { ARGS: [name, schema] });
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function parse(inputText) {
|
|
43
|
+
parser.reset();
|
|
44
|
+
const lexResult = lexDocument(inputText);
|
|
45
|
+
parser.input = lexResult.tokens;
|
|
46
|
+
return parser;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
describe("schemaFn", () => {
|
|
50
|
+
it("schemaFn immutable restrictions", () => {
|
|
51
|
+
parse(`something = "foo"`).schemaFn_test_immutable();
|
|
52
|
+
expect(parser.errors).to.be.empty;
|
|
53
|
+
|
|
54
|
+
parse(`something = 'bar'`).schemaFn_test_immutable();
|
|
55
|
+
expect(parser.errors).to.be.empty;
|
|
56
|
+
|
|
57
|
+
parse(`something = bar`).schemaFn_test_immutable();
|
|
58
|
+
expect(parser.errors).to.not.be.empty;
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("schemaFn rejects a bad immutable", () => {
|
|
62
|
+
parse(`something = true`).schemaFn_test_immutable();
|
|
63
|
+
expect(parser.errors).to.not.be.empty;
|
|
64
|
+
|
|
65
|
+
parse(`something = 123`).schemaFn_test_immutable();
|
|
66
|
+
expect(parser.errors).to.not.be.empty;
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("schemaFn rejects a bad value", () => {
|
|
70
|
+
parse(`something = true|something`).schemaFn_test_expression();
|
|
71
|
+
expect(parser.errors).to.not.be.empty;
|
|
72
|
+
|
|
73
|
+
parse(`something = 12 3`).schemaFn_test_expression();
|
|
74
|
+
expect(parser.errors).to.not.be.empty;
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("schemaFn accepts a value", () => {
|
|
78
|
+
parse(`something = true|not`).schemaFn_test_expression();
|
|
79
|
+
expect(parser.errors).to.be.empty;
|
|
80
|
+
|
|
81
|
+
parse(`something = [123 + 123]`).schemaFn_test_expression();
|
|
82
|
+
expect(parser.errors).to.be.empty;
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("schemaFn accepts an enum", () => {
|
|
86
|
+
parse(`something = "yes"`).schemaFn_test_enum();
|
|
87
|
+
expect(parser.errors).to.be.empty;
|
|
88
|
+
|
|
89
|
+
parse(`something = 123`).schemaFn_test_enum();
|
|
90
|
+
expect(parser.errors).to.be.empty;
|
|
91
|
+
});
|
|
92
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { first } from "lodash-es";
|
|
2
|
+
import { CommaToken, LSquare, RSquare } from "../../../lexer/control.js";
|
|
3
|
+
import { NewlineToken } from "../../../lexer/tokens.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @param {import('../../base_parser.js').XanoBaseParser} $
|
|
7
|
+
*/
|
|
8
|
+
export function schemaParseArrayFn($) {
|
|
9
|
+
return (token, schema, captured = {}, options) => {
|
|
10
|
+
let needSeparator = false;
|
|
11
|
+
captured.value = [];
|
|
12
|
+
$.CONSUME(LSquare); // "["
|
|
13
|
+
$.MANY1(() => $.CONSUME(NewlineToken));
|
|
14
|
+
$.MANY(() => {
|
|
15
|
+
const localCaptured = {};
|
|
16
|
+
$.SUBRULE($.schemaFn, {
|
|
17
|
+
ARGS: [token, first(schema), localCaptured, options],
|
|
18
|
+
});
|
|
19
|
+
if (needSeparator) {
|
|
20
|
+
$.addInvalidValueError(
|
|
21
|
+
"Expected a comma, a new line or closing bracket"
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
captured.value.push(localCaptured);
|
|
25
|
+
needSeparator = true;
|
|
26
|
+
$.OPTION(() => {
|
|
27
|
+
needSeparator = false;
|
|
28
|
+
return $.CONSUME1(CommaToken);
|
|
29
|
+
});
|
|
30
|
+
$.MANY2(() => {
|
|
31
|
+
needSeparator = false;
|
|
32
|
+
$.CONSUME1(NewlineToken);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
$.CONSUME(RSquare); // "]"
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @param {*} attr
|
|
42
|
+
* @returns
|
|
43
|
+
*/
|
|
44
|
+
export function schemaExpectArray(attr) {
|
|
45
|
+
if (typeof attr !== "object" || !Array.isArray(attr)) return false;
|
|
46
|
+
return attr.length == 1;
|
|
47
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { describe, it } from "mocha";
|
|
3
|
+
import { EqualToken } from "../../../lexer/control.js";
|
|
4
|
+
import { lexDocument } from "../../../lexer/lexer.js";
|
|
5
|
+
import { Identifier } from "../../../lexer/tokens.js";
|
|
6
|
+
import { parser } from "../../test_parser.js";
|
|
7
|
+
|
|
8
|
+
export function parserExtension() {
|
|
9
|
+
// this rule requires a foo field to be defined
|
|
10
|
+
this.schemaParseArrayFn_string_arr = this.RULE(
|
|
11
|
+
"schemaParseArrayFn_string_arr",
|
|
12
|
+
() => {
|
|
13
|
+
const schema = ["[string]"];
|
|
14
|
+
const name = this.CONSUME(Identifier);
|
|
15
|
+
this.CONSUME(EqualToken); // "="
|
|
16
|
+
this.SUBRULE(this.schemaParseArrayFn, { ARGS: [name, schema] });
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
// this rule requires a foo field to be defined
|
|
21
|
+
this.schemaParseArrayFn_string_arr_of_arr = this.RULE(
|
|
22
|
+
"schemaParseArrayFn_string_arr_of_arr",
|
|
23
|
+
() => {
|
|
24
|
+
const schema = [["[string]"]];
|
|
25
|
+
const name = this.CONSUME(Identifier);
|
|
26
|
+
this.CONSUME(EqualToken); // "="
|
|
27
|
+
this.SUBRULE(this.schemaParseArrayFn, { ARGS: [name, schema] });
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
// this rule requires a foo field to be defined
|
|
32
|
+
this.schemaParseArrayFn_number_arr = this.RULE(
|
|
33
|
+
"schemaParseArrayFn_number_arr",
|
|
34
|
+
() => {
|
|
35
|
+
const schema = ["[number]"];
|
|
36
|
+
const name = this.CONSUME(Identifier);
|
|
37
|
+
this.CONSUME(EqualToken); // "="
|
|
38
|
+
this.SUBRULE(this.schemaParseArrayFn, { ARGS: [name, schema] });
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
// this rule requires a foo field to be defined
|
|
43
|
+
this.schemaParseArrayFn_expression_arr = this.RULE(
|
|
44
|
+
"schemaParseArrayFn_expression_arr",
|
|
45
|
+
() => {
|
|
46
|
+
const schema = ["[expression]"];
|
|
47
|
+
const name = this.CONSUME(Identifier);
|
|
48
|
+
this.CONSUME(EqualToken); // "="
|
|
49
|
+
this.SUBRULE(this.schemaParseArrayFn, { ARGS: [name, schema] });
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function parse(inputText) {
|
|
55
|
+
parser.reset();
|
|
56
|
+
const lexResult = lexDocument(inputText);
|
|
57
|
+
parser.input = lexResult.tokens;
|
|
58
|
+
return parser;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
describe("schemaParseArrayFn", () => {
|
|
62
|
+
it("schemaParseArrayFn accepts an array of strings", () => {
|
|
63
|
+
parse(`something = ["test", 'bar']`).schemaParseArrayFn_string_arr();
|
|
64
|
+
expect(parser.errors).to.be.empty;
|
|
65
|
+
|
|
66
|
+
parse(`something = [
|
|
67
|
+
"""
|
|
68
|
+
and
|
|
69
|
+
test
|
|
70
|
+
"""
|
|
71
|
+
'bar'
|
|
72
|
+
]`).schemaParseArrayFn_string_arr();
|
|
73
|
+
expect(parser.errors).to.be.empty;
|
|
74
|
+
|
|
75
|
+
parse(`something = []`).schemaParseArrayFn_number_arr();
|
|
76
|
+
expect(parser.errors).to.be.empty;
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("schemaParseArrayFn rejects invalid types ", () => {
|
|
80
|
+
parse(`something = [false]`).schemaParseArrayFn_string_arr();
|
|
81
|
+
expect(parser.errors).to.not.be.empty;
|
|
82
|
+
|
|
83
|
+
parse(`something = [123]`).schemaParseArrayFn_string_arr();
|
|
84
|
+
expect(parser.errors).to.not.be.empty;
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("schemaParseArrayFn rejects invalid format ", () => {
|
|
88
|
+
parse(`something = [123 321]`).schemaParseArrayFn_number_arr();
|
|
89
|
+
expect(parser.errors).to.not.be.empty;
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("schemaParseArrayFn accept valid number array", () => {
|
|
93
|
+
parse(`something = [
|
|
94
|
+
123,
|
|
95
|
+
321
|
|
96
|
+
]`).schemaParseArrayFn_number_arr();
|
|
97
|
+
expect(parser.errors).to.be.empty;
|
|
98
|
+
|
|
99
|
+
parse(`something = [1,
|
|
100
|
+
2,
|
|
101
|
+
3,
|
|
102
|
+
]`).schemaParseArrayFn_number_arr();
|
|
103
|
+
expect(parser.errors).to.be.empty;
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("schemaParseArrayFn rejects bad types", () => {
|
|
107
|
+
parse(`something = [true]`).schemaParseArrayFn_number_arr();
|
|
108
|
+
expect(parser.errors).to.not.be.empty;
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("schemaParseArrayFn accepts an array of array of strings", () => {
|
|
112
|
+
parse(
|
|
113
|
+
`something = [["test", 'bar'], ["foo"]]`
|
|
114
|
+
).schemaParseArrayFn_string_arr_of_arr();
|
|
115
|
+
expect(parser.errors).to.be.empty;
|
|
116
|
+
|
|
117
|
+
parse(`something = [
|
|
118
|
+
['test', "bar"],
|
|
119
|
+
["foo"]
|
|
120
|
+
]`).schemaParseArrayFn_string_arr_of_arr();
|
|
121
|
+
expect(parser.errors).to.be.empty;
|
|
122
|
+
|
|
123
|
+
parse(`something = []`).schemaParseArrayFn_string_arr_of_arr();
|
|
124
|
+
expect(parser.errors).to.be.empty;
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it("schemaParseArrayFn accepts an array of expressions", () => {
|
|
128
|
+
parse(`something = [1,
|
|
129
|
+
$var.test
|
|
130
|
+
$input.value + 2,
|
|
131
|
+
]`).schemaParseArrayFn_expression_arr();
|
|
132
|
+
expect(parser.errors).to.be.empty;
|
|
133
|
+
});
|
|
134
|
+
});
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { get, isPlainObject, keys, some } from "lodash-es";
|
|
2
|
+
import { ExclamationToken } from "../../../lexer/cast.js";
|
|
3
|
+
import {
|
|
4
|
+
CommaToken,
|
|
5
|
+
EqualToken,
|
|
6
|
+
LCurly,
|
|
7
|
+
RCurly,
|
|
8
|
+
} from "../../../lexer/control.js";
|
|
9
|
+
import { StringLiteral } from "../../../lexer/literal.js";
|
|
10
|
+
import { Identifier, NewlineToken } from "../../../lexer/tokens.js";
|
|
11
|
+
import {
|
|
12
|
+
canBeDisabledAttribute,
|
|
13
|
+
isMultiAttribute,
|
|
14
|
+
isOptionalAttribute,
|
|
15
|
+
isSchemaGenericType,
|
|
16
|
+
valueMatchRequirements,
|
|
17
|
+
} from "./utils.js";
|
|
18
|
+
|
|
19
|
+
export function schemaParseAttributeFn($) {
|
|
20
|
+
$.requireRules(_schemaParseAttributeFn);
|
|
21
|
+
|
|
22
|
+
return (token, schema, captured = {}) => {
|
|
23
|
+
// attribute can be fully ignored when all the keys are optional
|
|
24
|
+
const isAllOptional = keys(schema).every((k) => isOptionalAttribute(k));
|
|
25
|
+
|
|
26
|
+
$.OR([
|
|
27
|
+
{
|
|
28
|
+
GATE: () => isAllOptional,
|
|
29
|
+
ALT: () => {
|
|
30
|
+
$.OPTION(() =>
|
|
31
|
+
$.SUBRULE($._schemaParseAttributeFn, {
|
|
32
|
+
ARGS: [token, schema, captured],
|
|
33
|
+
})
|
|
34
|
+
);
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
GATE: () => !isAllOptional,
|
|
39
|
+
ALT: () =>
|
|
40
|
+
$.SUBRULE1($._schemaParseAttributeFn, {
|
|
41
|
+
ARGS: [token, schema, captured],
|
|
42
|
+
}),
|
|
43
|
+
},
|
|
44
|
+
]);
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Similar to schemaParseObjectFn but for attributes (uses = instead of :)
|
|
50
|
+
* captured object will contain the tokens of the captured keys on the object
|
|
51
|
+
* allowing for better error messages later on
|
|
52
|
+
* @param {import('../../base_parser.js').XanoBaseParser} $
|
|
53
|
+
*/
|
|
54
|
+
function _schemaParseAttributeFn($) {
|
|
55
|
+
return (token, schema, captured = {}) => {
|
|
56
|
+
let needSeparator = false;
|
|
57
|
+
let lastToken = null;
|
|
58
|
+
|
|
59
|
+
// grab all the keys, they contain the schema for the keys
|
|
60
|
+
const objectKeys = keys(schema);
|
|
61
|
+
const missingKeys = [...objectKeys];
|
|
62
|
+
const attrNames = [];
|
|
63
|
+
|
|
64
|
+
// you cannot have a generic mixed with another generic
|
|
65
|
+
$.ACTION(() => {
|
|
66
|
+
if (
|
|
67
|
+
objectKeys.length > 1 &&
|
|
68
|
+
some(objectKeys, (k) => isSchemaGenericType(k))
|
|
69
|
+
) {
|
|
70
|
+
throw new Error(
|
|
71
|
+
"schemaParseAttributeFn supports only one generic type when multiple keys are defined"
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
$.CONSUME(LCurly); // "{"
|
|
77
|
+
$.MANY(() => {
|
|
78
|
+
$.MANY1(() => {
|
|
79
|
+
needSeparator = false;
|
|
80
|
+
$.CONSUME(NewlineToken);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
if (needSeparator) {
|
|
84
|
+
$.addInvalidValueError(
|
|
85
|
+
lastToken,
|
|
86
|
+
"Expected a comma, a new line or closing bracket"
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const disabledToken = $.OPTION1(() => $.CONSUME(ExclamationToken)); // "!"
|
|
91
|
+
|
|
92
|
+
// first we capture the key
|
|
93
|
+
let objectKeyToken;
|
|
94
|
+
const keyValue = $.OR([
|
|
95
|
+
{
|
|
96
|
+
ALT: () => {
|
|
97
|
+
objectKeyToken = $.CONSUME1(Identifier);
|
|
98
|
+
return objectKeyToken.image;
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
ALT: () => {
|
|
103
|
+
const objectKeyToken = $.CONSUME1(StringLiteral);
|
|
104
|
+
return objectKeyToken.image.slice(1, -1);
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
]);
|
|
108
|
+
|
|
109
|
+
const subSchemaKey = valueMatchRequirements(keyValue, objectKeys);
|
|
110
|
+
if (!subSchemaKey) {
|
|
111
|
+
$.addInvalidValueError(
|
|
112
|
+
objectKeyToken,
|
|
113
|
+
`The argument '${keyValue}' is not valid in this context`
|
|
114
|
+
);
|
|
115
|
+
} else if (disabledToken && !canBeDisabledAttribute(subSchemaKey)) {
|
|
116
|
+
$.addInvalidValueError(
|
|
117
|
+
disabledToken,
|
|
118
|
+
`The argument '${keyValue}' cannot be disabled`
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (attrNames.includes(keyValue) && !isMultiAttribute(subSchemaKey)) {
|
|
123
|
+
$.addInvalidValueError(
|
|
124
|
+
objectKeyToken,
|
|
125
|
+
`Duplicate argument '${keyValue}' found`
|
|
126
|
+
);
|
|
127
|
+
} else {
|
|
128
|
+
attrNames.push(keyValue);
|
|
129
|
+
captured[keyValue] = { key: objectKeyToken, value: null };
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// remove from missing keys
|
|
133
|
+
missingKeys.splice(missingKeys.indexOf(subSchemaKey), 1);
|
|
134
|
+
|
|
135
|
+
const subSchema = get(schema, subSchemaKey, null);
|
|
136
|
+
|
|
137
|
+
const isStack = ["[stack]", "[test-stack]"].includes(subSchema);
|
|
138
|
+
$.OR1([
|
|
139
|
+
{
|
|
140
|
+
GATE: () => !isStack,
|
|
141
|
+
ALT: () => $.CONSUME(EqualToken), // "="
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
GATE: () => isStack,
|
|
145
|
+
ALT: () => false,
|
|
146
|
+
},
|
|
147
|
+
]);
|
|
148
|
+
|
|
149
|
+
$.SUBRULE($.schemaFn, {
|
|
150
|
+
ARGS: [objectKeyToken, subSchema, captured[keyValue]],
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
needSeparator = true;
|
|
154
|
+
$.MANY2(() => {
|
|
155
|
+
needSeparator = false;
|
|
156
|
+
$.CONSUME1(NewlineToken);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
$.OPTION(() => {
|
|
160
|
+
needSeparator = false;
|
|
161
|
+
$.CONSUME1(CommaToken);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
$.CONSUME(RCurly); // "}"
|
|
165
|
+
|
|
166
|
+
if (missingKeys.length) {
|
|
167
|
+
const missingKeyNames = missingKeys.filter(
|
|
168
|
+
(k) => !isOptionalAttribute(k)
|
|
169
|
+
);
|
|
170
|
+
if (missingKeyNames.length > 1) {
|
|
171
|
+
$.addInvalidValueError(
|
|
172
|
+
lastToken || token,
|
|
173
|
+
`The following required arguments are missing: ${missingKeyNames.join(
|
|
174
|
+
", "
|
|
175
|
+
)}`
|
|
176
|
+
);
|
|
177
|
+
} else if (missingKeyNames.length === 1) {
|
|
178
|
+
$.addInvalidValueError(
|
|
179
|
+
lastToken || token,
|
|
180
|
+
`Missing required argument '${missingKeyNames[0]}'`
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
*
|
|
189
|
+
* @param {*} attr
|
|
190
|
+
* @returns
|
|
191
|
+
*/
|
|
192
|
+
export function schemaExpectObject(attr) {
|
|
193
|
+
return isPlainObject(attr);
|
|
194
|
+
}
|