@xano/xanoscript-language-server 11.12.1 → 11.12.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/lexer/tokens.js +22 -3
- package/package.json +25 -1
- package/.claude/memory/feedback_no_git.md +0 -11
- package/.claude/settings.local.json +0 -21
- package/.github/copilot-instructions.md +0 -190
- package/.github/workflows/ci.yml +0 -31
- package/.husky/pre-commit +0 -1
- package/CLAUDE.md +0 -256
- package/eslint.config.js +0 -24
- package/lexer/comment.spec.js +0 -77
- package/lexer/multiline.spec.js +0 -179
- package/lexer/tests/query/query_lexer.spec.js +0 -36
- package/lexer/tests/query/valid_sources/basic_query.xs +0 -44
- package/lexer/tests/query/valid_sources/db_query.xs +0 -77
- package/lexer/tests/query/valid_sources/empty_query.xs +0 -5
- package/lexer/tests/query/valid_sources/header_query.xs +0 -15
- package/lexer/tests/table/basic_table.xs +0 -17
- package/lexer/tests/table/empty_table.xs +0 -3
- package/lexer/tests/table/table_lexer.spec.js +0 -324
- package/lexer/utils.spec.js +0 -61
- package/onCompletion/contentAssist.spec.js +0 -275
- package/onDefinition/onDefinition.spec.js +0 -313
- package/onHover/FilterMessageProvider.spec.js +0 -85
- package/onHover/FunctionMessageProvider.spec.js +0 -128
- package/onHover/InputFilterMessageProvider.spec.js +0 -329
- package/onHover/QueryFilterMessageProvider.spec.js +0 -164
- package/onHover/onHoverDocument.spec.js +0 -660
- package/parser/addon_parser.spec.js +0 -88
- package/parser/agent_parser.spec.js +0 -599
- package/parser/agent_trigger_parser.spec.js +0 -525
- package/parser/api_group_parser.spec.js +0 -137
- package/parser/attributes/columnDefaultValueAttribute.spec.js +0 -49
- package/parser/attributes/descriptionFieldAttribute.spec.js +0 -39
- package/parser/attributes/disabledFieldAttribute.spec.js +0 -34
- package/parser/attributes/docsFieldAttribute.spec.js +0 -44
- package/parser/attributes/guidFieldAttribute.spec.js +0 -93
- package/parser/attributes/inputFilterFn.spec.js +0 -39
- package/parser/attributes/sensitiveFieldAttribute.spec.js +0 -39
- package/parser/attributes/valueFieldAttribute.spec.js +0 -54
- package/parser/attributes/valuesFieldAttribute.spec.js +0 -44
- package/parser/attributes/visibilityFieldAttribute.spec.js +0 -44
- package/parser/branch_parser.spec.js +0 -34
- package/parser/clauses/agentClause.spec.js +0 -34
- package/parser/clauses/authClause.spec.js +0 -39
- package/parser/clauses/cacheClause.spec.js +0 -103
- package/parser/clauses/canonicalClause.spec.js +0 -34
- package/parser/clauses/channelClause.spec.js +0 -34
- package/parser/clauses/dbTableClause.spec.js +0 -34
- package/parser/clauses/historyClause.spec.js +0 -53
- package/parser/clauses/indexClause.spec.js +0 -47
- package/parser/clauses/inputClause.spec.js +0 -96
- package/parser/clauses/mcpServerClause.spec.js +0 -34
- package/parser/clauses/middlewareClause.spec.js +0 -161
- package/parser/clauses/nakedStackFn.spec.js +0 -73
- package/parser/clauses/responseClause.spec.js +0 -47
- package/parser/clauses/scheduleClause.spec.js +0 -71
- package/parser/clauses/schemaClause.spec.js +0 -102
- package/parser/clauses/testClause.spec.js +0 -69
- package/parser/clauses/viewClause.spec.js +0 -163
- package/parser/definitions/arraySlice.spec.js +0 -49
- package/parser/definitions/columnDefinition.spec.js +0 -199
- package/parser/definitions/dbLinkColumnDefinition.spec.js +0 -45
- package/parser/definitions/enumColumnDefinition.spec.js +0 -108
- package/parser/definitions/filterDefinition.spec.js +0 -43
- package/parser/definitions/objectColumnDefinition.spec.js +0 -118
- package/parser/function_parser.spec.js +0 -131
- package/parser/functions/actionCallFn.spec.js +0 -51
- package/parser/functions/addonCallFn.spec.js +0 -41
- package/parser/functions/ai/aiAgentRunFn.spec.js +0 -94
- package/parser/functions/ai/aiExternalMcpServerDetailsFn.spec.js +0 -85
- package/parser/functions/ai/aiExternalMcpToolListFn.spec.js +0 -85
- package/parser/functions/ai/aiExternalMcpToolRunFn.spec.js +0 -101
- package/parser/functions/aiFn.spec.js +0 -51
- package/parser/functions/api/apiCallFn.spec.js +0 -62
- package/parser/functions/api/apiLambdaFn.spec.js +0 -63
- package/parser/functions/api/apiRealtimeEventFn.spec.js +0 -82
- package/parser/functions/api/apiRequestFn.spec.js +0 -113
- package/parser/functions/api/apiStreamFn.spec.js +0 -44
- package/parser/functions/api/webflowRequestFn.spec.js +0 -114
- package/parser/functions/array/arrayDifferenceFn.spec.js +0 -34
- package/parser/functions/array/arrayFindFn.spec.js +0 -44
- package/parser/functions/array/arrayGroupByFn.spec.js +0 -41
- package/parser/functions/array/arrayIntersectionFn.spec.js +0 -22
- package/parser/functions/array/arrayMapFn.spec.js +0 -37
- package/parser/functions/array/arrayNoValueAs.spec.js +0 -56
- package/parser/functions/array/arrayPartitionFn.spec.js +0 -29
- package/parser/functions/array/arrayUnionFn.spec.js +0 -22
- package/parser/functions/array/arrayValueIfAs.spec.js +0 -54
- package/parser/functions/array/arrayValueOnly.spec.js +0 -61
- package/parser/functions/array/valueAttrOnly.spec.js +0 -61
- package/parser/functions/cloud/cloudAlgoliaRequestFn.spec.js +0 -30
- package/parser/functions/cloud/cloudAwsS3Fn.spec.js +0 -21
- package/parser/functions/cloud/cloudDeleteFileFn.spec.js +0 -25
- package/parser/functions/cloud/cloudGetFileInfoFn.spec.js +0 -25
- package/parser/functions/cloud/cloudListDirectoryFn.spec.js +0 -26
- package/parser/functions/cloud/cloudReadFileFn.spec.js +0 -25
- package/parser/functions/cloud/cloudSearchDocumentFn.spec.js +0 -28
- package/parser/functions/cloud/cloudSearchQueryFn.spec.js +0 -32
- package/parser/functions/cloud/cloudSearchRequestFn.spec.js +0 -32
- package/parser/functions/cloud/cloudSignUrlFn.spec.js +0 -26
- package/parser/functions/cloud/cloudStorageFn.spec.js +0 -21
- package/parser/functions/cloud/cloudUploadFileFn.spec.js +0 -29
- package/parser/functions/controls/awaitFn.spec.js +0 -48
- package/parser/functions/controls/conditionalFn.spec.js +0 -188
- package/parser/functions/controls/forEachFn.spec.js +0 -109
- package/parser/functions/controls/forFn.spec.js +0 -85
- package/parser/functions/controls/functionRunFn.spec.js +0 -77
- package/parser/functions/controls/groupFn.spec.js +0 -63
- package/parser/functions/controls/preconditionFn.spec.js +0 -107
- package/parser/functions/controls/returnFn.spec.js +0 -44
- package/parser/functions/controls/switchFn.spec.js +0 -118
- package/parser/functions/controls/throwFn.spec.js +0 -56
- package/parser/functions/controls/tryCatchFn.spec.js +0 -193
- package/parser/functions/controls/whileFn.spec.js +0 -94
- package/parser/functions/db/dbAddFn.spec.js +0 -72
- package/parser/functions/db/dbAddOrEditFn.spec.js +0 -97
- package/parser/functions/db/dbBulkAddFn.spec.js +0 -94
- package/parser/functions/db/dbBulkDeleteFn.spec.js +0 -28
- package/parser/functions/db/dbBulkPatchFn.spec.js +0 -42
- package/parser/functions/db/dbBulkUpdateFn.spec.js +0 -42
- package/parser/functions/db/dbDelFn.spec.js +0 -67
- package/parser/functions/db/dbDirectQueryFn.spec.js +0 -104
- package/parser/functions/db/dbEditFn.spec.js +0 -122
- package/parser/functions/db/dbExternalDirectQueryFn.spec.js +0 -103
- package/parser/functions/db/dbGetFn.spec.js +0 -117
- package/parser/functions/db/dbHasFn.spec.js +0 -62
- package/parser/functions/db/dbPatchFn.spec.js +0 -88
- package/parser/functions/db/dbQueryFn.spec.js +0 -380
- package/parser/functions/db/dbSchemaFn.spec.js +0 -42
- package/parser/functions/db/dbSetDatasourceFn.spec.js +0 -44
- package/parser/functions/db/dbTransactionFn.spec.js +0 -63
- package/parser/functions/db/dbTruncateFn.spec.js +0 -42
- package/parser/functions/debug/debugLogFn.spec.js +0 -44
- package/parser/functions/debug/debugStopFn.spec.js +0 -44
- package/parser/functions/expect/unitExpectToBeWithinFn.spec.js +0 -63
- package/parser/functions/expect/unitExpectToThrowFn.spec.js +0 -40
- package/parser/functions/expect/unitExpectWithArgumentsFn.spec.js +0 -355
- package/parser/functions/expect/unitExpectWithoutArgumentsFn.spec.js +0 -69
- package/parser/functions/expect/workflowExpectToBeWithinFn.spec.js +0 -70
- package/parser/functions/expect/workflowExpectToThrowFn.spec.js +0 -56
- package/parser/functions/expect/workflowExpectWithArgumentsFn.spec.js +0 -308
- package/parser/functions/expect/workflowExpectWithoutArgumentsFn.spec.js +0 -87
- package/parser/functions/math/allMathFn.spec.js +0 -100
- package/parser/functions/middlewareCallFn.spec.js +0 -44
- package/parser/functions/object/objectEntriesFn.spec.js +0 -44
- package/parser/functions/object/objectKeysFn.spec.js +0 -44
- package/parser/functions/object/objectValuesFn.spec.js +0 -44
- package/parser/functions/redis/redisCountFn.spec.js +0 -58
- package/parser/functions/redis/redisDecrFn.spec.js +0 -47
- package/parser/functions/redis/redisDelFn.spec.js +0 -58
- package/parser/functions/redis/redisGetFn.spec.js +0 -67
- package/parser/functions/redis/redisHasFn.spec.js +0 -58
- package/parser/functions/redis/redisIncrFn.spec.js +0 -74
- package/parser/functions/redis/redisKeysFn.spec.js +0 -67
- package/parser/functions/redis/redisPopFn.spec.js +0 -75
- package/parser/functions/redis/redisPushFn.spec.js +0 -71
- package/parser/functions/redis/redisRangeFn.spec.js +0 -80
- package/parser/functions/redis/redisRateLimitFn.spec.js +0 -87
- package/parser/functions/redis/redisRemoveFn.spec.js +0 -65
- package/parser/functions/redis/redisSetFn.spec.js +0 -89
- package/parser/functions/redis/redisShiftFn.spec.js +0 -75
- package/parser/functions/redis/redisUnshiftFn.spec.js +0 -73
- package/parser/functions/schema/schemaFn.spec.js +0 -92
- package/parser/functions/schema/schemaParseArrayFn.spec.js +0 -134
- package/parser/functions/schema/schemaParseAttributeFn.spec.js +0 -285
- package/parser/functions/schema/schemaParseConstantFn.spec.js +0 -122
- package/parser/functions/schema/schemaParseEnum.spec.js +0 -47
- package/parser/functions/schema/schemaParseImmutableFn.spec.js +0 -99
- package/parser/functions/schema/schemaParseObjectFn.spec.js +0 -223
- package/parser/functions/schema/utils.spec.js +0 -27
- package/parser/functions/security/securityCheckPasswordFn.spec.js +0 -22
- package/parser/functions/security/securityCreateAuthTokenFn.spec.js +0 -51
- package/parser/functions/security/securityCreateCurveKeyFn.spec.js +0 -22
- package/parser/functions/security/securityCreatePasswordFn.spec.js +0 -26
- package/parser/functions/security/securityCreateRsaKeyFn.spec.js +0 -22
- package/parser/functions/security/securityCreateSecretKeyFn.spec.js +0 -22
- package/parser/functions/security/securityCreateUuidFn.spec.js +0 -27
- package/parser/functions/security/securityDecryptFn.spec.js +0 -24
- package/parser/functions/security/securityEncryptFn.spec.js +0 -24
- package/parser/functions/security/securityJweDecodeFn.spec.js +0 -26
- package/parser/functions/security/securityJweDecodeLegacyFn.spec.js +0 -26
- package/parser/functions/security/securityJweEncodeFn.spec.js +0 -26
- package/parser/functions/security/securityJweEncodeLegacyFn.spec.js +0 -25
- package/parser/functions/security/securityJwsDecodeFn.spec.js +0 -25
- package/parser/functions/security/securityJwsEncodeFn.spec.js +0 -25
- package/parser/functions/security/securityRandomBytesFn.spec.js +0 -21
- package/parser/functions/security/securityRandomNumberFn.spec.js +0 -22
- package/parser/functions/storage/storageCreateAttachmentFn.spec.js +0 -87
- package/parser/functions/storage/storageCreateAudioFn.spec.js +0 -98
- package/parser/functions/storage/storageCreateFileResourceFn.spec.js +0 -72
- package/parser/functions/storage/storageCreateImageFn.spec.js +0 -98
- package/parser/functions/storage/storageCreateVideoFn.spec.js +0 -99
- package/parser/functions/storage/storageDeleteFileFn.spec.js +0 -67
- package/parser/functions/storage/storageReadFileResourceFn.spec.js +0 -60
- package/parser/functions/storage/storageSignPrivateUrlFn.spec.js +0 -72
- package/parser/functions/stream/streamFromCsvFn.spec.js +0 -69
- package/parser/functions/stream/streamFromJsonlFn.spec.js +0 -47
- package/parser/functions/stream/streamFromRequestFn.spec.js +0 -103
- package/parser/functions/text/allTextWithReturnValueFn.spec.js +0 -100
- package/parser/functions/text/allTextWithoutReturnValueFn.spec.js +0 -122
- package/parser/functions/toolCallFn.spec.js +0 -28
- package/parser/functions/triggerCallFn.spec.js +0 -51
- package/parser/functions/unitExpectFn.spec.js +0 -21
- package/parser/functions/util/utilGeoDistanceFn.spec.js +0 -79
- package/parser/functions/util/utilGetAllInputFn.spec.js +0 -33
- package/parser/functions/util/utilGetEnvFn.spec.js +0 -33
- package/parser/functions/util/utilGetRawInputFn.spec.js +0 -62
- package/parser/functions/util/utilGetVarsFn.spec.js +0 -33
- package/parser/functions/util/utilIpLookupFn.spec.js +0 -37
- package/parser/functions/util/utilPostProcessFn.spec.js +0 -63
- package/parser/functions/util/utilSendEmailFn.spec.js +0 -62
- package/parser/functions/util/utilSetHeaderFn.spec.js +0 -48
- package/parser/functions/util/utilSleepFn.spec.js +0 -44
- package/parser/functions/util/utilTemplateFn.spec.js +0 -78
- package/parser/functions/varFn.spec.js +0 -332
- package/parser/functions/workflowExpectFn.spec.js +0 -32
- package/parser/functions/zip/zipAddToArchiveFn.spec.js +0 -78
- package/parser/functions/zip/zipCreateArchiveFn.spec.js +0 -53
- package/parser/functions/zip/zipDeleteFromArchiveFn.spec.js +0 -69
- package/parser/functions/zip/zipExtractFn.spec.js +0 -52
- package/parser/functions/zip/zipViewContentsFn.spec.js +0 -52
- package/parser/generic/arrayWithValues.spec.js +0 -72
- package/parser/generic/asVariable.spec.js +0 -117
- package/parser/generic/assignableVariableAs.spec.js +0 -126
- package/parser/generic/assignableVariableProperty.spec.js +0 -138
- package/parser/generic/castedValue.spec.js +0 -29
- package/parser/generic/chainedIdentifier.spec.js +0 -89
- package/parser/generic/completeAuthVariable.spec.js +0 -23
- package/parser/generic/completeEnvVariable.spec.js +0 -99
- package/parser/generic/completeErrorVariable.spec.js +0 -17
- package/parser/generic/completeInputVariable.spec.js +0 -53
- package/parser/generic/expressionFn.spec.js +0 -605
- package/parser/generic/filterFn.spec.js +0 -47
- package/parser/generic/functionAttrReq.spec.js +0 -353
- package/parser/generic/longFormVariable.spec.js +0 -25
- package/parser/generic/minimalFnBody.spec.js +0 -47
- package/parser/generic/mockAttribute.spec.js +0 -57
- package/parser/generic/multilineFilterFn.spec.js +0 -51
- package/parser/generic/objectWithAttributes.spec.js +0 -147
- package/parser/generic/requiredValueFnBody.spec.js +0 -56
- package/parser/generic/shortFormVariable.spec.js +0 -27
- package/parser/generic/stringArray.spec.js +0 -55
- package/parser/generic/tagsAttribute.spec.js +0 -47
- package/parser/generic/variableOnly.spec.js +0 -47
- package/parser/mcp_server_parser.spec.js +0 -478
- package/parser/mcp_server_trigger_parser.spec.js +0 -396
- package/parser/metadata/columnMetadataDefinition.spec.js +0 -47
- package/parser/metadata/enumColumnMetadataDefinition.spec.js +0 -81
- package/parser/middleware_parser.spec.js +0 -230
- package/parser/multidoc.spec.js +0 -946
- package/parser/query_parser.spec.js +0 -202
- package/parser/realtime_channel_parser.spec.js +0 -20
- package/parser/realtime_trigger_parser.spec.js +0 -469
- package/parser/run_parser.spec.js +0 -100
- package/parser/table_parser.spec.js +0 -176
- package/parser/table_trigger_parser.spec.js +0 -478
- package/parser/task_parser.spec.js +0 -94
- package/parser/tests/agent/agent_parser.spec.js +0 -52
- package/parser/tests/agent/valid_sources/customer_servier_agent.xs +0 -45
- package/parser/tests/api_group/api_group_parser.spec.js +0 -52
- package/parser/tests/api_group/valid_sources/api_group_history.xs +0 -4
- package/parser/tests/api_group/valid_sources/basic_api_group.xs +0 -3
- package/parser/tests/api_group/valid_sources/complete_api_group.xs +0 -7
- package/parser/tests/api_group/valid_sources/protected_api_group.xs +0 -7
- package/parser/tests/function/function_parser.spec.js +0 -52
- package/parser/tests/function/valid_sources/all_controls.xs +0 -68
- package/parser/tests/function/valid_sources/all_query_return_types.xs +0 -227
- package/parser/tests/function/valid_sources/all_storage.xs +0 -45
- package/parser/tests/function/valid_sources/discord_poll_send_to_slack.xs +0 -133
- package/parser/tests/function/valid_sources/expression_in_response.xs +0 -22
- package/parser/tests/function/valid_sources/filter_by_value.xs +0 -55
- package/parser/tests/function/valid_sources/filter_query.xs +0 -82
- package/parser/tests/function/valid_sources/large_regex.xs +0 -13
- package/parser/tests/function/valid_sources/ledash_ends_with.xs +0 -90
- package/parser/tests/function/valid_sources/multiline_description.xs +0 -28
- package/parser/tests/function/valid_sources/multiline_expr.xs +0 -41
- package/parser/tests/function/valid_sources/set_theory_fn.xs +0 -129
- package/parser/tests/function/valid_sources/simple_unit_test.xs +0 -33
- package/parser/tests/function/valid_sources/valid_officer.xs +0 -57
- package/parser/tests/function/valid_sources/webflow.xs +0 -18
- package/parser/tests/multidoc/multidoc_parser.spec.js +0 -55
- package/parser/tests/multidoc/valid_sources/function_stack.xs +0 -130603
- package/parser/tests/query/query_parser.spec.js +0 -54
- package/parser/tests/query/valid_sources/all_basics.xs +0 -51
- package/parser/tests/query/valid_sources/all_cloud.xs +0 -141
- package/parser/tests/query/valid_sources/all_db.xs +0 -102
- package/parser/tests/query/valid_sources/all_external_db.xs +0 -43
- package/parser/tests/query/valid_sources/all_keywords.xs +0 -65
- package/parser/tests/query/valid_sources/all_math.xs +0 -53
- package/parser/tests/query/valid_sources/all_object.xs +0 -25
- package/parser/tests/query/valid_sources/all_redis.xs +0 -106
- package/parser/tests/query/valid_sources/all_security.xs +0 -105
- package/parser/tests/query/valid_sources/all_stream.xs +0 -69
- package/parser/tests/query/valid_sources/all_text.xs +0 -54
- package/parser/tests/query/valid_sources/all_util.xs +0 -66
- package/parser/tests/query/valid_sources/all_zip.xs +0 -39
- package/parser/tests/query/valid_sources/arrays.xs +0 -33
- package/parser/tests/query/valid_sources/disabled_response.xs +0 -27
- package/parser/tests/query/valid_sources/multiline_lambda_GET.xs +0 -50
- package/parser/tests/query/valid_sources/mutliline_query.xs +0 -140
- package/parser/tests/query/valid_sources/patch_expression_multiline.xs +0 -27
- package/parser/tests/query/valid_sources/query_cache.xs +0 -34
- package/parser/tests/query/valid_sources/query_example.xs +0 -43
- package/parser/tests/query/valid_sources/query_mini.xs +0 -11
- package/parser/tests/query/valid_sources/query_rich_inputs.xs +0 -32
- package/parser/tests/query/valid_sources/simple_unit_test.xs +0 -33
- package/parser/tests/query/valid_sources/test_with_slashes.xs +0 -22
- package/parser/tests/query/valid_sources/with_unit_test.xs +0 -97
- package/parser/tests/table/table_parser.spec.js +0 -52
- package/parser/tests/table/valid_sources/account.xs +0 -31
- package/parser/tests/table/valid_sources/all_basic_columns.xs +0 -44
- package/parser/tests/table/valid_sources/basic_table.xs +0 -15
- package/parser/tests/table/valid_sources/empty_object.xs +0 -17
- package/parser/tests/table/valid_sources/empty_table.xs +0 -3
- package/parser/tests/table/valid_sources/multiline_index.xs +0 -33
- package/parser/tests/table/valid_sources/relation.xs +0 -44
- package/parser/tests/table/valid_sources/rich_columns.xs +0 -31
- package/parser/tests/table/valid_sources/table_with_comments.xs +0 -17
- package/parser/tests/table/valid_sources/table_with_search_index.xs +0 -31
- package/parser/tests/table/valid_sources/view_table.xs +0 -62
- package/parser/tests/task/task_parser.spec.js +0 -53
- package/parser/tests/task/valid_sources/active_event.xs +0 -11
- package/parser/tests/task/valid_sources/all_events.xs +0 -17
- package/parser/tests/task/valid_sources/create_leak.xs +0 -165
- package/parser/tests/task/valid_sources/daily_sales_report.xs +0 -56
- package/parser/tests/task/valid_sources/inactive_event.xs +0 -11
- package/parser/tests/variable_test/coverage_check.xs +0 -293
- package/parser/tests/workflow_test/valid_sources/basic_workflow_test.xs +0 -13
- package/parser/tests/workflow_test/workflow_test_parser.spec.js +0 -52
- package/parser/tool_parser.spec.js +0 -115
- package/parser/variableValidator.spec.js +0 -179
- package/parser/workflow_test_parser.spec.js +0 -136
- package/parser/workspace_parser.spec.js +0 -142
- package/parser/workspace_trigger_parser.spec.js +0 -332
- package/toTmLanguage.js +0 -75
- package/utils.spec.js +0 -369
- package/workspace/crossFileValidator.spec.js +0 -654
- package/workspace/referenceTracking.spec.js +0 -420
- package/workspace/workspaceIndex.spec.js +0 -189
|
@@ -1,420 +0,0 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import { describe, it } from "mocha";
|
|
3
|
-
import { xanoscriptParser } from "../parser/parser.js";
|
|
4
|
-
|
|
5
|
-
describe("reference tracking in __symbolTable", () => {
|
|
6
|
-
it("should track function.run reference", () => {
|
|
7
|
-
const parser = xanoscriptParser(`function "caller" {
|
|
8
|
-
stack {
|
|
9
|
-
function.run "my_target" as $result
|
|
10
|
-
}
|
|
11
|
-
}`);
|
|
12
|
-
const refs = parser.__symbolTable.references;
|
|
13
|
-
expect(refs).to.have.length(1);
|
|
14
|
-
expect(refs[0].refType).to.equal("function");
|
|
15
|
-
expect(refs[0].name).to.equal("my_target");
|
|
16
|
-
expect(refs[0].startOffset).to.be.a("number");
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("should track function.call reference", () => {
|
|
20
|
-
const parser = xanoscriptParser(`function "caller" {
|
|
21
|
-
stack {
|
|
22
|
-
function.call "my_target" as $result
|
|
23
|
-
}
|
|
24
|
-
}`);
|
|
25
|
-
const refs = parser.__symbolTable.references;
|
|
26
|
-
expect(refs).to.have.length(1);
|
|
27
|
-
expect(refs[0].refType).to.equal("function");
|
|
28
|
-
expect(refs[0].name).to.equal("my_target");
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("should track db.get table reference", () => {
|
|
32
|
-
const parser = xanoscriptParser(`function "caller" {
|
|
33
|
-
stack {
|
|
34
|
-
db.get users {
|
|
35
|
-
field_name = id
|
|
36
|
-
field_value = 1
|
|
37
|
-
} as $user
|
|
38
|
-
}
|
|
39
|
-
}`);
|
|
40
|
-
const refs = parser.__symbolTable.references;
|
|
41
|
-
expect(refs).to.have.length(1);
|
|
42
|
-
expect(refs[0].refType).to.equal("table");
|
|
43
|
-
expect(refs[0].name).to.equal("users");
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("should track db.query table reference", () => {
|
|
47
|
-
const parser = xanoscriptParser(`function "caller" {
|
|
48
|
-
stack {
|
|
49
|
-
db.query users {
|
|
50
|
-
return {
|
|
51
|
-
type = list
|
|
52
|
-
}
|
|
53
|
-
} as $users
|
|
54
|
-
}
|
|
55
|
-
}`);
|
|
56
|
-
const refs = parser.__symbolTable.references;
|
|
57
|
-
expect(refs).to.have.length(1);
|
|
58
|
-
expect(refs[0].refType).to.equal("table");
|
|
59
|
-
expect(refs[0].name).to.equal("users");
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it("should track multiple references in one file", () => {
|
|
63
|
-
const parser = xanoscriptParser(`function "caller" {
|
|
64
|
-
stack {
|
|
65
|
-
db.get users {
|
|
66
|
-
field_name = "user_id"
|
|
67
|
-
field_value = 1
|
|
68
|
-
} as $user
|
|
69
|
-
function.run "helper" as $result
|
|
70
|
-
}
|
|
71
|
-
}`);
|
|
72
|
-
const refs = parser.__symbolTable.references;
|
|
73
|
-
expect(refs).to.have.length(2);
|
|
74
|
-
expect(refs[0].refType).to.equal("table");
|
|
75
|
-
expect(refs[0].name).to.equal("users");
|
|
76
|
-
expect(refs[1].refType).to.equal("function");
|
|
77
|
-
expect(refs[1].name).to.equal("helper");
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it("should track task.call reference", () => {
|
|
81
|
-
const parser = xanoscriptParser(`function "caller" {
|
|
82
|
-
stack {
|
|
83
|
-
task.call "my_task" as $result
|
|
84
|
-
}
|
|
85
|
-
}`);
|
|
86
|
-
const refs = parser.__symbolTable.references;
|
|
87
|
-
expect(refs).to.have.length(1);
|
|
88
|
-
expect(refs[0].refType).to.equal("task");
|
|
89
|
-
expect(refs[0].name).to.equal("my_task");
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it("should track db.bulk.delete table reference", () => {
|
|
93
|
-
const parser = xanoscriptParser(`function "caller" {
|
|
94
|
-
stack {
|
|
95
|
-
db.bulk.delete users {
|
|
96
|
-
field_name = id
|
|
97
|
-
field_value = [1, 2, 3]
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}`);
|
|
101
|
-
const refs = parser.__symbolTable.references;
|
|
102
|
-
expect(refs).to.have.length(1);
|
|
103
|
-
expect(refs[0].refType).to.equal("table");
|
|
104
|
-
expect(refs[0].name).to.equal("users");
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it("should track string literal table names", () => {
|
|
108
|
-
const parser = xanoscriptParser(`function "caller" {
|
|
109
|
-
stack {
|
|
110
|
-
db.get "user table" {
|
|
111
|
-
field_name = id
|
|
112
|
-
field_value = 1
|
|
113
|
-
} as $user
|
|
114
|
-
}
|
|
115
|
-
}`);
|
|
116
|
-
const refs = parser.__symbolTable.references;
|
|
117
|
-
expect(refs).to.have.length(1);
|
|
118
|
-
expect(refs[0].name).to.equal("user table");
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it("should capture input args on function.run reference", () => {
|
|
122
|
-
const parser = xanoscriptParser(`function "caller" {
|
|
123
|
-
stack {
|
|
124
|
-
function.run "my_target" {
|
|
125
|
-
input = { user_id: 1, name: "test" }
|
|
126
|
-
} as $result
|
|
127
|
-
}
|
|
128
|
-
}`);
|
|
129
|
-
const refs = parser.__symbolTable.references;
|
|
130
|
-
expect(refs).to.have.length(1);
|
|
131
|
-
expect(refs[0].refType).to.equal("function");
|
|
132
|
-
expect(refs[0].args).to.be.an("object");
|
|
133
|
-
expect(refs[0].args).to.have.property("user_id");
|
|
134
|
-
expect(refs[0].args).to.have.property("name");
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it("should capture literal types on input args", () => {
|
|
138
|
-
const parser = xanoscriptParser(`function "caller" {
|
|
139
|
-
stack {
|
|
140
|
-
function.run "my_target" {
|
|
141
|
-
input = { count: 100, name: "test", rate: 3.14, active: true }
|
|
142
|
-
} as $result
|
|
143
|
-
}
|
|
144
|
-
}`);
|
|
145
|
-
const refs = parser.__symbolTable.references;
|
|
146
|
-
expect(refs).to.have.length(1);
|
|
147
|
-
const args = refs[0].args;
|
|
148
|
-
expect(args.count.type).to.equal("int");
|
|
149
|
-
expect(args.name.type).to.equal("text");
|
|
150
|
-
expect(args.rate.type).to.equal("decimal");
|
|
151
|
-
expect(args.active.type).to.equal("bool");
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it("should capture input args with variable values as unknown type", () => {
|
|
155
|
-
const parser = xanoscriptParser(`function "caller" {
|
|
156
|
-
stack {
|
|
157
|
-
function.run "my_target" {
|
|
158
|
-
input = { user_id: $var1 }
|
|
159
|
-
} as $result
|
|
160
|
-
}
|
|
161
|
-
}`);
|
|
162
|
-
const refs = parser.__symbolTable.references;
|
|
163
|
-
expect(refs).to.have.length(1);
|
|
164
|
-
expect(refs[0].args).to.have.property("user_id");
|
|
165
|
-
expect(refs[0].args.user_id.type).to.be.null;
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it("should not have args when function.run has no input", () => {
|
|
169
|
-
const parser = xanoscriptParser(`function "caller" {
|
|
170
|
-
stack {
|
|
171
|
-
function.run "my_target" as $result
|
|
172
|
-
}
|
|
173
|
-
}`);
|
|
174
|
-
const refs = parser.__symbolTable.references;
|
|
175
|
-
expect(refs).to.have.length(1);
|
|
176
|
-
expect(refs[0].args).to.be.undefined;
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it("should not have args when function.run has non-input attributes only", () => {
|
|
180
|
-
const parser = xanoscriptParser(`function "caller" {
|
|
181
|
-
stack {
|
|
182
|
-
function.run "my_target" {
|
|
183
|
-
description = "testing"
|
|
184
|
-
} as $result
|
|
185
|
-
}
|
|
186
|
-
}`);
|
|
187
|
-
const refs = parser.__symbolTable.references;
|
|
188
|
-
expect(refs).to.have.length(1);
|
|
189
|
-
expect(refs[0].args).to.be.undefined;
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
it("should capture field_name on db.get reference with string literal", () => {
|
|
193
|
-
const parser = xanoscriptParser(`function "caller" {
|
|
194
|
-
stack {
|
|
195
|
-
db.get users {
|
|
196
|
-
field_name = "id"
|
|
197
|
-
field_value = 1
|
|
198
|
-
} as $user
|
|
199
|
-
}
|
|
200
|
-
}`);
|
|
201
|
-
const refs = parser.__symbolTable.references;
|
|
202
|
-
expect(refs).to.have.length(1);
|
|
203
|
-
expect(refs[0].refType).to.equal("table");
|
|
204
|
-
expect(refs[0].fieldName).to.equal("id");
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
it("should capture field_name on db.edit reference with string literal", () => {
|
|
208
|
-
const parser = xanoscriptParser(`function "caller" {
|
|
209
|
-
stack {
|
|
210
|
-
db.edit users {
|
|
211
|
-
field_name = "id"
|
|
212
|
-
field_value = 1
|
|
213
|
-
data = { name: "test" }
|
|
214
|
-
} as $user
|
|
215
|
-
}
|
|
216
|
-
}`);
|
|
217
|
-
const refs = parser.__symbolTable.references;
|
|
218
|
-
expect(refs).to.have.length(1);
|
|
219
|
-
expect(refs[0].fieldName).to.equal("id");
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
it("should not capture field_name when value is a variable expression", () => {
|
|
223
|
-
const parser = xanoscriptParser(`function "caller" {
|
|
224
|
-
stack {
|
|
225
|
-
db.get users {
|
|
226
|
-
field_name = $input.field
|
|
227
|
-
field_value = 1
|
|
228
|
-
} as $user
|
|
229
|
-
}
|
|
230
|
-
}`);
|
|
231
|
-
const refs = parser.__symbolTable.references;
|
|
232
|
-
expect(refs).to.have.length(1);
|
|
233
|
-
expect(refs[0].fieldName).to.be.undefined;
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
it("should not have field_name when db function has no field_name attribute", () => {
|
|
237
|
-
const parser = xanoscriptParser(`function "caller" {
|
|
238
|
-
stack {
|
|
239
|
-
db.query users {
|
|
240
|
-
return {
|
|
241
|
-
type = list
|
|
242
|
-
}
|
|
243
|
-
} as $users
|
|
244
|
-
}
|
|
245
|
-
}`);
|
|
246
|
-
const refs = parser.__symbolTable.references;
|
|
247
|
-
expect(refs).to.have.length(1);
|
|
248
|
-
expect(refs[0].fieldName).to.be.undefined;
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
it("should track middleware references from query middleware clause", () => {
|
|
252
|
-
const parser = xanoscriptParser(`query foo verb=GET {
|
|
253
|
-
input {
|
|
254
|
-
text user_id filters=trim
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
stack {
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
response = null
|
|
261
|
-
|
|
262
|
-
middleware = {pre: [{name: "auth_middle"}], post: [{name: "log_middle"}]}
|
|
263
|
-
}`);
|
|
264
|
-
const refs = parser.__symbolTable.references;
|
|
265
|
-
const mwRefs = refs.filter((r) => r.refType === "middleware");
|
|
266
|
-
expect(mwRefs).to.have.length(2);
|
|
267
|
-
expect(mwRefs[0].name).to.equal("auth_middle");
|
|
268
|
-
expect(mwRefs[1].name).to.equal("log_middle");
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
it("should track middleware.call reference", () => {
|
|
272
|
-
const parser = xanoscriptParser(`workflow_test test_middleware {
|
|
273
|
-
stack {
|
|
274
|
-
middleware.call "auth_check" {
|
|
275
|
-
input = {
|
|
276
|
-
vars: $input,
|
|
277
|
-
type: "pre"
|
|
278
|
-
}
|
|
279
|
-
} as $result
|
|
280
|
-
}
|
|
281
|
-
}`);
|
|
282
|
-
const refs = parser.__symbolTable.references;
|
|
283
|
-
const mwRefs = refs.filter((r) => r.refType === "middleware");
|
|
284
|
-
expect(mwRefs).to.have.length(1);
|
|
285
|
-
expect(mwRefs[0].name).to.equal("auth_check");
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
it("should track data keys on db.edit reference", () => {
|
|
289
|
-
const parser = xanoscriptParser(`function "caller" {
|
|
290
|
-
stack {
|
|
291
|
-
db.edit users {
|
|
292
|
-
field_name = "id"
|
|
293
|
-
field_value = 1
|
|
294
|
-
data = { name: "test", email: "foo@bar.com" }
|
|
295
|
-
} as $user
|
|
296
|
-
}
|
|
297
|
-
}`);
|
|
298
|
-
const refs = parser.__symbolTable.references;
|
|
299
|
-
expect(refs).to.have.length(1);
|
|
300
|
-
expect(refs[0].refType).to.equal("table");
|
|
301
|
-
expect(refs[0].dataKeys).to.be.an("array");
|
|
302
|
-
const keyNames = refs[0].dataKeys.map((k) => k.name);
|
|
303
|
-
expect(keyNames).to.include("name");
|
|
304
|
-
expect(keyNames).to.include("email");
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
it("should not have dataKeys when db function has no data attribute", () => {
|
|
308
|
-
const parser = xanoscriptParser(`function "caller" {
|
|
309
|
-
stack {
|
|
310
|
-
db.get users {
|
|
311
|
-
field_name = "id"
|
|
312
|
-
field_value = 1
|
|
313
|
-
} as $user
|
|
314
|
-
}
|
|
315
|
-
}`);
|
|
316
|
-
const refs = parser.__symbolTable.references;
|
|
317
|
-
expect(refs).to.have.length(1);
|
|
318
|
-
expect(refs[0].dataKeys).to.be.undefined;
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
it("should track join table references in db.query", () => {
|
|
322
|
-
const parser = xanoscriptParser(`function "caller" {
|
|
323
|
-
stack {
|
|
324
|
-
db.query users {
|
|
325
|
-
join = {
|
|
326
|
-
profile: {
|
|
327
|
-
type: "left"
|
|
328
|
-
table: "user_profiles"
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
return = {type: "list"}
|
|
332
|
-
} as $users
|
|
333
|
-
}
|
|
334
|
-
}`);
|
|
335
|
-
const refs = parser.__symbolTable.references;
|
|
336
|
-
const tableRefs = refs.filter((r) => r.refType === "table");
|
|
337
|
-
expect(tableRefs).to.have.length(2);
|
|
338
|
-
expect(tableRefs[0].name).to.equal("users");
|
|
339
|
-
expect(tableRefs[1].name).to.equal("user_profiles");
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
it("should track addon name references in db.query", () => {
|
|
343
|
-
const parser = xanoscriptParser(`function "caller" {
|
|
344
|
-
stack {
|
|
345
|
-
db.query users {
|
|
346
|
-
addon = [{name: "get_posts", as: "_posts"}]
|
|
347
|
-
return = {type: "list"}
|
|
348
|
-
} as $users
|
|
349
|
-
}
|
|
350
|
-
}`);
|
|
351
|
-
const refs = parser.__symbolTable.references;
|
|
352
|
-
const fnRefs = refs.filter((r) => r.refType === "function");
|
|
353
|
-
expect(fnRefs).to.have.length(1);
|
|
354
|
-
expect(fnRefs[0].name).to.equal("get_posts");
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
it("should track table relation references from column definitions", () => {
|
|
358
|
-
const parser = xanoscriptParser(`table beer {
|
|
359
|
-
schema {
|
|
360
|
-
int brewery_id {
|
|
361
|
-
table = "brewery"
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
}`);
|
|
365
|
-
const refs = parser.__symbolTable.references;
|
|
366
|
-
const tableRefs = refs.filter((r) => r.refType === "table");
|
|
367
|
-
expect(tableRefs).to.have.length(1);
|
|
368
|
-
expect(tableRefs[0].name).to.equal("brewery");
|
|
369
|
-
});
|
|
370
|
-
|
|
371
|
-
it("should track function.run with empty name and not leak args to previous reference", () => {
|
|
372
|
-
const parser = xanoscriptParser(`function "caller" {
|
|
373
|
-
stack {
|
|
374
|
-
db.edit claim {
|
|
375
|
-
field_name = "id"
|
|
376
|
-
field_value = 1
|
|
377
|
-
data = {status: "active"}
|
|
378
|
-
} as $updated_claim
|
|
379
|
-
|
|
380
|
-
function.run "" {
|
|
381
|
-
input = {
|
|
382
|
-
claim_id: 1
|
|
383
|
-
to_status: "assessment"
|
|
384
|
-
}
|
|
385
|
-
} as $transition_result
|
|
386
|
-
}
|
|
387
|
-
}`);
|
|
388
|
-
const refs = parser.__symbolTable.references;
|
|
389
|
-
const tableRefs = refs.filter((r) => r.refType === "table");
|
|
390
|
-
const fnRefs = refs.filter((r) => r.refType === "function");
|
|
391
|
-
|
|
392
|
-
// The table ref should NOT have args from the function.run
|
|
393
|
-
expect(tableRefs).to.have.length(1);
|
|
394
|
-
expect(tableRefs[0].name).to.equal("claim");
|
|
395
|
-
expect(tableRefs[0].args).to.be.undefined;
|
|
396
|
-
|
|
397
|
-
// The function ref should exist (even with empty name) and carry the args
|
|
398
|
-
expect(fnRefs).to.have.length(1);
|
|
399
|
-
expect(fnRefs[0].name).to.equal("");
|
|
400
|
-
expect(fnRefs[0].args).to.have.property("claim_id");
|
|
401
|
-
expect(fnRefs[0].args).to.have.property("to_status");
|
|
402
|
-
});
|
|
403
|
-
|
|
404
|
-
it("should track security.create_auth_token table reference", () => {
|
|
405
|
-
const parser = xanoscriptParser(`function "caller" {
|
|
406
|
-
stack {
|
|
407
|
-
security.create_auth_token {
|
|
408
|
-
table = "users"
|
|
409
|
-
extras = {}
|
|
410
|
-
expiration = 86400
|
|
411
|
-
id = ""
|
|
412
|
-
} as $token
|
|
413
|
-
}
|
|
414
|
-
}`);
|
|
415
|
-
const refs = parser.__symbolTable.references;
|
|
416
|
-
const tableRefs = refs.filter((r) => r.refType === "table");
|
|
417
|
-
expect(tableRefs).to.have.length(1);
|
|
418
|
-
expect(tableRefs[0].name).to.equal("users");
|
|
419
|
-
});
|
|
420
|
-
});
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import { beforeEach, describe, it } from "mocha";
|
|
3
|
-
import { xanoscriptParser } from "../parser/parser.js";
|
|
4
|
-
import { getSchemeFromContent } from "../utils.js";
|
|
5
|
-
import { WorkspaceIndex } from "./workspaceIndex.js";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Helper to add a file with pre-parsed inputs (simulates what onDidChangeContent does).
|
|
9
|
-
*/
|
|
10
|
-
function addWithInputs(index, uri, content) {
|
|
11
|
-
const scheme = getSchemeFromContent(content);
|
|
12
|
-
const parser = xanoscriptParser(content, scheme);
|
|
13
|
-
return index.addParsed(uri, content, parser.__symbolTable);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
describe("WorkspaceIndex", () => {
|
|
17
|
-
let index;
|
|
18
|
-
|
|
19
|
-
beforeEach(() => {
|
|
20
|
-
index = new WorkspaceIndex();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
describe("addFile (lightweight indexing)", () => {
|
|
24
|
-
it("should index type and name from a function file", () => {
|
|
25
|
-
index.addFile(
|
|
26
|
-
"file:///workspace/my_func.xs",
|
|
27
|
-
`function "my_func" {
|
|
28
|
-
input {
|
|
29
|
-
int user_id
|
|
30
|
-
text? name
|
|
31
|
-
}
|
|
32
|
-
}`
|
|
33
|
-
);
|
|
34
|
-
expect(index.has("function", "my_func")).to.be.true;
|
|
35
|
-
const entry = index.getByUri("file:///workspace/my_func.xs");
|
|
36
|
-
expect(entry.type).to.equal("function");
|
|
37
|
-
expect(entry.name).to.equal("my_func");
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("should index a query file", () => {
|
|
41
|
-
index.addFile(
|
|
42
|
-
"file:///workspace/get_users.xs",
|
|
43
|
-
'query "/users" GET {\n}'
|
|
44
|
-
);
|
|
45
|
-
expect(index.has("query", "/users")).to.be.true;
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it("should index a task file", () => {
|
|
49
|
-
index.addFile(
|
|
50
|
-
"file:///workspace/cleanup.xs",
|
|
51
|
-
'task "daily_cleanup" {\n}'
|
|
52
|
-
);
|
|
53
|
-
expect(index.has("task", "daily_cleanup")).to.be.true;
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it("should return false for unparseable content", () => {
|
|
57
|
-
const result = index.addFile("file:///workspace/bad.xs", "not valid");
|
|
58
|
-
expect(result).to.be.false;
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("should update entry when file content changes", () => {
|
|
62
|
-
index.addFile(
|
|
63
|
-
"file:///workspace/my_func.xs",
|
|
64
|
-
'function "my_func" {\n}'
|
|
65
|
-
);
|
|
66
|
-
index.addFile(
|
|
67
|
-
"file:///workspace/my_func.xs",
|
|
68
|
-
'function "renamed" {\n}'
|
|
69
|
-
);
|
|
70
|
-
expect(index.has("function", "my_func")).to.be.false;
|
|
71
|
-
expect(index.has("function", "renamed")).to.be.true;
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
describe("addParsed (with inputs)", () => {
|
|
76
|
-
it("should index a function file with inputs", () => {
|
|
77
|
-
const content = `function "my_func" {
|
|
78
|
-
input {
|
|
79
|
-
int user_id
|
|
80
|
-
text? name
|
|
81
|
-
}
|
|
82
|
-
}`;
|
|
83
|
-
addWithInputs(index, "file:///workspace/my_func.xs", content);
|
|
84
|
-
const entry = index.get("function", "my_func");
|
|
85
|
-
expect(entry).to.exist;
|
|
86
|
-
expect(entry.uri).to.equal("file:///workspace/my_func.xs");
|
|
87
|
-
expect(entry.type).to.equal("function");
|
|
88
|
-
expect(entry.name).to.equal("my_func");
|
|
89
|
-
expect(entry.inputs).to.have.property("user_id");
|
|
90
|
-
expect(entry.inputs.user_id.type).to.equal("int");
|
|
91
|
-
expect(entry.inputs.name.nullable).to.be.true;
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it("should index a table file with columns", () => {
|
|
95
|
-
const content = `table users {
|
|
96
|
-
schema {
|
|
97
|
-
int id
|
|
98
|
-
text name
|
|
99
|
-
timestamp created_at?=now
|
|
100
|
-
}
|
|
101
|
-
}`;
|
|
102
|
-
addWithInputs(index, "file:///workspace/users.xs", content);
|
|
103
|
-
const entry = index.get("table", "users");
|
|
104
|
-
expect(entry).to.exist;
|
|
105
|
-
expect(entry.name).to.equal("users");
|
|
106
|
-
expect(entry.inputs).to.have.property("id");
|
|
107
|
-
expect(entry.inputs.id.type).to.equal("int");
|
|
108
|
-
expect(entry.inputs).to.have.property("name");
|
|
109
|
-
expect(entry.inputs.name.type).to.equal("text");
|
|
110
|
-
expect(entry.inputs.created_at.optional).to.be.true;
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
describe("removeFile", () => {
|
|
115
|
-
it("should remove an indexed file", () => {
|
|
116
|
-
index.addFile(
|
|
117
|
-
"file:///workspace/my_func.xs",
|
|
118
|
-
'function "my_func" {\n}'
|
|
119
|
-
);
|
|
120
|
-
index.removeFile("file:///workspace/my_func.xs");
|
|
121
|
-
expect(index.get("function", "my_func")).to.be.undefined;
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it("should be a no-op for unknown URIs", () => {
|
|
125
|
-
index.removeFile("file:///workspace/unknown.xs");
|
|
126
|
-
// No error thrown
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
describe("getByType", () => {
|
|
131
|
-
it("should return all entries for a type", () => {
|
|
132
|
-
index.addFile("file:///workspace/a.xs", 'function "func_a" {\n}');
|
|
133
|
-
index.addFile("file:///workspace/b.xs", 'function "func_b" {\n}');
|
|
134
|
-
index.addFile("file:///workspace/t.xs", "table users {\n}");
|
|
135
|
-
|
|
136
|
-
const functions = index.getByType("function");
|
|
137
|
-
expect(functions).to.have.length(2);
|
|
138
|
-
expect(functions.map((f) => f.name)).to.include.members([
|
|
139
|
-
"func_a",
|
|
140
|
-
"func_b",
|
|
141
|
-
]);
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it("should return empty array for unknown type", () => {
|
|
145
|
-
expect(index.getByType("function")).to.deep.equal([]);
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
describe("has", () => {
|
|
150
|
-
it("should return true for indexed entries", () => {
|
|
151
|
-
index.addFile("file:///workspace/a.xs", 'function "my_func" {\n}');
|
|
152
|
-
expect(index.has("function", "my_func")).to.be.true;
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
it("should return false for missing entries", () => {
|
|
156
|
-
expect(index.has("function", "nonexistent")).to.be.false;
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
describe("getAllNames", () => {
|
|
161
|
-
it("should return all names for a type", () => {
|
|
162
|
-
index.addFile("file:///workspace/a.xs", 'function "func_a" {\n}');
|
|
163
|
-
index.addFile("file:///workspace/b.xs", 'function "func_b" {\n}');
|
|
164
|
-
const names = index.getAllNames("function");
|
|
165
|
-
expect(names).to.include.members(["func_a", "func_b"]);
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
describe("uri reverse lookup", () => {
|
|
170
|
-
it("should find entry by URI", () => {
|
|
171
|
-
index.addFile("file:///workspace/a.xs", 'function "my_func" {\n}');
|
|
172
|
-
const entry = index.getByUri("file:///workspace/a.xs");
|
|
173
|
-
expect(entry).to.exist;
|
|
174
|
-
expect(entry.name).to.equal("my_func");
|
|
175
|
-
expect(entry.type).to.equal("function");
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
describe("name collision", () => {
|
|
180
|
-
it("should overwrite when two files define same type+name", () => {
|
|
181
|
-
index.addFile("file:///workspace/a.xs", 'function "helper" {\n}');
|
|
182
|
-
index.addFile("file:///workspace/b.xs", 'function "helper" {\n}');
|
|
183
|
-
const entry = index.get("function", "helper");
|
|
184
|
-
expect(entry).to.exist;
|
|
185
|
-
expect(entry.uri).to.equal("file:///workspace/b.xs");
|
|
186
|
-
expect(index.getByUri("file:///workspace/a.xs")).to.be.undefined;
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
});
|