@digital-science-dsl/dimensions-analytics-mcp 0.5.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/CHANGELOG.md +61 -0
- package/README.md +152 -0
- package/bin/dimensions-analytics-mcp-http.js +2 -0
- package/bin/dimensions-analytics-mcp.js +2 -0
- package/dist/client/auth/config-loaders.d.ts +22 -0
- package/dist/client/auth/config-loaders.d.ts.map +1 -0
- package/dist/client/auth/config-loaders.js +68 -0
- package/dist/client/auth/config-loaders.js.map +1 -0
- package/dist/client/auth/decorators/index.d.ts +7 -0
- package/dist/client/auth/decorators/index.d.ts.map +1 -0
- package/dist/client/auth/decorators/index.js +6 -0
- package/dist/client/auth/decorators/index.js.map +1 -0
- package/dist/client/auth/decorators/with-caching.d.ts +81 -0
- package/dist/client/auth/decorators/with-caching.d.ts.map +1 -0
- package/dist/client/auth/decorators/with-caching.js +168 -0
- package/dist/client/auth/decorators/with-caching.js.map +1 -0
- package/dist/client/auth/factory.d.ts +13 -0
- package/dist/client/auth/factory.d.ts.map +1 -0
- package/dist/client/auth/factory.js +29 -0
- package/dist/client/auth/factory.js.map +1 -0
- package/dist/client/auth/index.d.ts +7 -0
- package/dist/client/auth/index.d.ts.map +1 -0
- package/dist/client/auth/index.js +6 -0
- package/dist/client/auth/index.js.map +1 -0
- package/dist/client/auth/jwt-utils.d.ts +17 -0
- package/dist/client/auth/jwt-utils.d.ts.map +1 -0
- package/dist/client/auth/jwt-utils.js +33 -0
- package/dist/client/auth/jwt-utils.js.map +1 -0
- package/dist/client/auth/node.d.ts +16 -0
- package/dist/client/auth/node.d.ts.map +1 -0
- package/dist/client/auth/node.js +15 -0
- package/dist/client/auth/node.js.map +1 -0
- package/dist/client/auth/providers/index.d.ts +2 -0
- package/dist/client/auth/providers/index.d.ts.map +1 -0
- package/dist/client/auth/providers/index.js +2 -0
- package/dist/client/auth/providers/index.js.map +1 -0
- package/dist/client/auth/providers/jwt-auth-provider.d.ts +70 -0
- package/dist/client/auth/providers/jwt-auth-provider.d.ts.map +1 -0
- package/dist/client/auth/providers/jwt-auth-provider.js +134 -0
- package/dist/client/auth/providers/jwt-auth-provider.js.map +1 -0
- package/dist/client/auth/schemas.d.ts +19 -0
- package/dist/client/auth/schemas.d.ts.map +1 -0
- package/dist/client/auth/schemas.js +23 -0
- package/dist/client/auth/schemas.js.map +1 -0
- package/dist/client/auth/types.d.ts +25 -0
- package/dist/client/auth/types.d.ts.map +1 -0
- package/dist/client/auth/types.js +9 -0
- package/dist/client/auth/types.js.map +1 -0
- package/dist/client/command.d.ts +44 -0
- package/dist/client/command.d.ts.map +1 -0
- package/dist/client/command.js +23 -0
- package/dist/client/command.js.map +1 -0
- package/dist/client/config/index.d.ts +11 -0
- package/dist/client/config/index.d.ts.map +1 -0
- package/dist/client/config/index.js +8 -0
- package/dist/client/config/index.js.map +1 -0
- package/dist/client/config/loader.d.ts +27 -0
- package/dist/client/config/loader.d.ts.map +1 -0
- package/dist/client/config/loader.js +128 -0
- package/dist/client/config/loader.js.map +1 -0
- package/dist/client/config/node.d.ts +18 -0
- package/dist/client/config/node.d.ts.map +1 -0
- package/dist/client/config/node.js +17 -0
- package/dist/client/config/node.js.map +1 -0
- package/dist/client/config/schemas.d.ts +23 -0
- package/dist/client/config/schemas.d.ts.map +1 -0
- package/dist/client/config/schemas.js +24 -0
- package/dist/client/config/schemas.js.map +1 -0
- package/dist/client/config/types.d.ts +37 -0
- package/dist/client/config/types.d.ts.map +1 -0
- package/dist/client/config/types.js +6 -0
- package/dist/client/config/types.js.map +1 -0
- package/dist/client/config/unified-loader.d.ts +41 -0
- package/dist/client/config/unified-loader.d.ts.map +1 -0
- package/dist/client/config/unified-loader.js +86 -0
- package/dist/client/config/unified-loader.js.map +1 -0
- package/dist/client/config.d.ts +43 -0
- package/dist/client/config.d.ts.map +1 -0
- package/dist/client/config.js +56 -0
- package/dist/client/config.js.map +1 -0
- package/dist/client/deployment-config.d.ts +36 -0
- package/dist/client/deployment-config.d.ts.map +1 -0
- package/dist/client/deployment-config.js +79 -0
- package/dist/client/deployment-config.js.map +1 -0
- package/dist/client/errors.d.ts +180 -0
- package/dist/client/errors.d.ts.map +1 -0
- package/dist/client/errors.js +253 -0
- package/dist/client/errors.js.map +1 -0
- package/dist/client/http-client.d.ts +215 -0
- package/dist/client/http-client.d.ts.map +1 -0
- package/dist/client/http-client.js +419 -0
- package/dist/client/http-client.js.map +1 -0
- package/dist/client/index.d.ts +28 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +18 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/internal-dsl-client.d.ts +30 -0
- package/dist/client/internal-dsl-client.d.ts.map +1 -0
- package/dist/client/internal-dsl-client.js +101 -0
- package/dist/client/internal-dsl-client.js.map +1 -0
- package/dist/client/rate-limiter.d.ts +79 -0
- package/dist/client/rate-limiter.d.ts.map +1 -0
- package/dist/client/rate-limiter.js +118 -0
- package/dist/client/rate-limiter.js.map +1 -0
- package/dist/client/resolve-api-key-user.d.ts +24 -0
- package/dist/client/resolve-api-key-user.d.ts.map +1 -0
- package/dist/client/resolve-api-key-user.js +80 -0
- package/dist/client/resolve-api-key-user.js.map +1 -0
- package/dist/client/types.d.ts +44 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +10 -0
- package/dist/client/types.js.map +1 -0
- package/dist/dsl/client.d.ts +330 -0
- package/dist/dsl/client.d.ts.map +1 -0
- package/dist/dsl/client.js +433 -0
- package/dist/dsl/client.js.map +1 -0
- package/dist/dsl/commands/apply-filters.d.ts +15 -0
- package/dist/dsl/commands/apply-filters.d.ts.map +1 -0
- package/dist/dsl/commands/apply-filters.js +29 -0
- package/dist/dsl/commands/apply-filters.js.map +1 -0
- package/dist/dsl/commands/facet/index.d.ts +6 -0
- package/dist/dsl/commands/facet/index.d.ts.map +1 -0
- package/dist/dsl/commands/facet/index.js +6 -0
- package/dist/dsl/commands/facet/index.js.map +1 -0
- package/dist/dsl/commands/facet/schemas.d.ts +71 -0
- package/dist/dsl/commands/facet/schemas.d.ts.map +1 -0
- package/dist/dsl/commands/facet/schemas.js +84 -0
- package/dist/dsl/commands/facet/schemas.js.map +1 -0
- package/dist/dsl/commands/functions/ClassifyCommand.d.ts +96 -0
- package/dist/dsl/commands/functions/ClassifyCommand.d.ts.map +1 -0
- package/dist/dsl/commands/functions/ClassifyCommand.js +95 -0
- package/dist/dsl/commands/functions/ClassifyCommand.js.map +1 -0
- package/dist/dsl/commands/functions/ExtractAffiliationsCommand.d.ts +86 -0
- package/dist/dsl/commands/functions/ExtractAffiliationsCommand.d.ts.map +1 -0
- package/dist/dsl/commands/functions/ExtractAffiliationsCommand.js +131 -0
- package/dist/dsl/commands/functions/ExtractAffiliationsCommand.js.map +1 -0
- package/dist/dsl/commands/functions/ExtractConceptsCommand.d.ts +73 -0
- package/dist/dsl/commands/functions/ExtractConceptsCommand.d.ts.map +1 -0
- package/dist/dsl/commands/functions/ExtractConceptsCommand.js +110 -0
- package/dist/dsl/commands/functions/ExtractConceptsCommand.js.map +1 -0
- package/dist/dsl/commands/functions/ExtractGrantsCommand.d.ts +66 -0
- package/dist/dsl/commands/functions/ExtractGrantsCommand.d.ts.map +1 -0
- package/dist/dsl/commands/functions/ExtractGrantsCommand.js +87 -0
- package/dist/dsl/commands/functions/ExtractGrantsCommand.js.map +1 -0
- package/dist/dsl/commands/functions/index.d.ts +10 -0
- package/dist/dsl/commands/functions/index.d.ts.map +1 -0
- package/dist/dsl/commands/functions/index.js +10 -0
- package/dist/dsl/commands/functions/index.js.map +1 -0
- package/dist/dsl/commands/index.d.ts +8 -0
- package/dist/dsl/commands/index.d.ts.map +1 -0
- package/dist/dsl/commands/index.js +7 -0
- package/dist/dsl/commands/index.js.map +1 -0
- package/dist/dsl/commands/validate-input.d.ts +18 -0
- package/dist/dsl/commands/validate-input.d.ts.map +1 -0
- package/dist/dsl/commands/validate-input.js +27 -0
- package/dist/dsl/commands/validate-input.js.map +1 -0
- package/dist/dsl/create-client.d.ts +32 -0
- package/dist/dsl/create-client.d.ts.map +1 -0
- package/dist/dsl/create-client.js +58 -0
- package/dist/dsl/create-client.js.map +1 -0
- package/dist/dsl/fluent-query-builder.d.ts +439 -0
- package/dist/dsl/fluent-query-builder.d.ts.map +1 -0
- package/dist/dsl/fluent-query-builder.js +534 -0
- package/dist/dsl/fluent-query-builder.js.map +1 -0
- package/dist/dsl/index.d.ts +32 -0
- package/dist/dsl/index.d.ts.map +1 -0
- package/dist/dsl/index.js +31 -0
- package/dist/dsl/index.js.map +1 -0
- package/dist/dsl/pagination.d.ts +82 -0
- package/dist/dsl/pagination.d.ts.map +1 -0
- package/dist/dsl/pagination.js +135 -0
- package/dist/dsl/pagination.js.map +1 -0
- package/dist/dsl/query-builder.d.ts +456 -0
- package/dist/dsl/query-builder.d.ts.map +1 -0
- package/dist/dsl/query-builder.js +994 -0
- package/dist/dsl/query-builder.js.map +1 -0
- package/dist/dsl/response-parser.d.ts +111 -0
- package/dist/dsl/response-parser.d.ts.map +1 -0
- package/dist/dsl/response-parser.js +210 -0
- package/dist/dsl/response-parser.js.map +1 -0
- package/dist/dsl/schema/cache.d.ts +52 -0
- package/dist/dsl/schema/cache.d.ts.map +1 -0
- package/dist/dsl/schema/cache.js +97 -0
- package/dist/dsl/schema/cache.js.map +1 -0
- package/dist/dsl/schema/extract.d.ts +18 -0
- package/dist/dsl/schema/extract.d.ts.map +1 -0
- package/dist/dsl/schema/extract.js +41 -0
- package/dist/dsl/schema/extract.js.map +1 -0
- package/dist/dsl/schema/index.d.ts +13 -0
- package/dist/dsl/schema/index.d.ts.map +1 -0
- package/dist/dsl/schema/index.js +12 -0
- package/dist/dsl/schema/index.js.map +1 -0
- package/dist/dsl/schema/load.d.ts +41 -0
- package/dist/dsl/schema/load.d.ts.map +1 -0
- package/dist/dsl/schema/load.js +119 -0
- package/dist/dsl/schema/load.js.map +1 -0
- package/dist/dsl/schema/store.d.ts +137 -0
- package/dist/dsl/schema/store.d.ts.map +1 -0
- package/dist/dsl/schema/store.js +204 -0
- package/dist/dsl/schema/store.js.map +1 -0
- package/dist/dsl/schema/structured-entities.d.ts +21 -0
- package/dist/dsl/schema/structured-entities.d.ts.map +1 -0
- package/dist/dsl/schema/structured-entities.js +39 -0
- package/dist/dsl/schema/structured-entities.js.map +1 -0
- package/dist/dsl/schema/summary.d.ts +51 -0
- package/dist/dsl/schema/summary.d.ts.map +1 -0
- package/dist/dsl/schema/summary.js +61 -0
- package/dist/dsl/schema/summary.js.map +1 -0
- package/dist/dsl/schema/types.d.ts +36 -0
- package/dist/dsl/schema/types.d.ts.map +1 -0
- package/dist/dsl/schema/types.js +6 -0
- package/dist/dsl/schema/types.js.map +1 -0
- package/dist/dsl/schema/validation.d.ts +21 -0
- package/dist/dsl/schema/validation.d.ts.map +1 -0
- package/dist/dsl/schema/validation.js +44 -0
- package/dist/dsl/schema/validation.js.map +1 -0
- package/dist/dsl/types/buckets.d.ts +18 -0
- package/dist/dsl/types/buckets.d.ts.map +1 -0
- package/dist/dsl/types/buckets.js +6 -0
- package/dist/dsl/types/buckets.js.map +1 -0
- package/dist/dsl/types/common.d.ts +91 -0
- package/dist/dsl/types/common.d.ts.map +1 -0
- package/dist/dsl/types/common.js +6 -0
- package/dist/dsl/types/common.js.map +1 -0
- package/dist/dsl/types/entities.d.ts +35 -0
- package/dist/dsl/types/entities.d.ts.map +1 -0
- package/dist/dsl/types/entities.js +11 -0
- package/dist/dsl/types/entities.js.map +1 -0
- package/dist/dsl/types/index.d.ts +12 -0
- package/dist/dsl/types/index.d.ts.map +1 -0
- package/dist/dsl/types/index.js +7 -0
- package/dist/dsl/types/index.js.map +1 -0
- package/dist/dsl/types/return-clauses.d.ts +107 -0
- package/dist/dsl/types/return-clauses.d.ts.map +1 -0
- package/dist/dsl/types/return-clauses.js +22 -0
- package/dist/dsl/types/return-clauses.js.map +1 -0
- package/dist/dsl/types/special-functions.d.ts +175 -0
- package/dist/dsl/types/special-functions.d.ts.map +1 -0
- package/dist/dsl/types/special-functions.js +25 -0
- package/dist/dsl/types/special-functions.js.map +1 -0
- package/dist/dsl/types/vocabulary.d.ts +21 -0
- package/dist/dsl/types/vocabulary.d.ts.map +1 -0
- package/dist/dsl/types/vocabulary.js +44 -0
- package/dist/dsl/types/vocabulary.js.map +1 -0
- package/dist/dsl/usage-policy.d.ts +87 -0
- package/dist/dsl/usage-policy.d.ts.map +1 -0
- package/dist/dsl/usage-policy.js +133 -0
- package/dist/dsl/usage-policy.js.map +1 -0
- package/dist/dsl/utils/escape.d.ts +24 -0
- package/dist/dsl/utils/escape.d.ts.map +1 -0
- package/dist/dsl/utils/escape.js +124 -0
- package/dist/dsl/utils/escape.js.map +1 -0
- package/dist/dsl/utils/sanitize.d.ts +13 -0
- package/dist/dsl/utils/sanitize.d.ts.map +1 -0
- package/dist/dsl/utils/sanitize.js +19 -0
- package/dist/dsl/utils/sanitize.js.map +1 -0
- package/dist/dsl/utils/string-utils.d.ts +35 -0
- package/dist/dsl/utils/string-utils.d.ts.map +1 -0
- package/dist/dsl/utils/string-utils.js +145 -0
- package/dist/dsl/utils/string-utils.js.map +1 -0
- package/dist/dsl/utils/validate-field-name.d.ts +11 -0
- package/dist/dsl/utils/validate-field-name.d.ts.map +1 -0
- package/dist/dsl/utils/validate-field-name.js +18 -0
- package/dist/dsl/utils/validate-field-name.js.map +1 -0
- package/dist/examples/dsl-examples.d.ts +11 -0
- package/dist/examples/dsl-examples.d.ts.map +1 -0
- package/dist/examples/dsl-examples.js +49 -0
- package/dist/examples/dsl-examples.js.map +1 -0
- package/dist/examples/usage-scenarios.d.ts +22 -0
- package/dist/examples/usage-scenarios.d.ts.map +1 -0
- package/dist/examples/usage-scenarios.js +173 -0
- package/dist/examples/usage-scenarios.js.map +1 -0
- package/dist/funder-org-names.d.ts +12 -0
- package/dist/funder-org-names.d.ts.map +1 -0
- package/dist/funder-org-names.js +30 -0
- package/dist/funder-org-names.js.map +1 -0
- package/dist/http-main.d.ts +7 -0
- package/dist/http-main.d.ts.map +1 -0
- package/dist/http-main.js +36 -0
- package/dist/http-main.js.map +1 -0
- package/dist/http.d.ts +29 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +173 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/kwq/build-query.d.ts +26 -0
- package/dist/kwq/build-query.d.ts.map +1 -0
- package/dist/kwq/build-query.js +37 -0
- package/dist/kwq/build-query.js.map +1 -0
- package/dist/kwq/concept-groups.d.ts +49 -0
- package/dist/kwq/concept-groups.d.ts.map +1 -0
- package/dist/kwq/concept-groups.js +55 -0
- package/dist/kwq/concept-groups.js.map +1 -0
- package/dist/kwq/dsl-assembler.d.ts +28 -0
- package/dist/kwq/dsl-assembler.d.ts.map +1 -0
- package/dist/kwq/dsl-assembler.js +124 -0
- package/dist/kwq/dsl-assembler.js.map +1 -0
- package/dist/kwq/ensemble.d.ts +38 -0
- package/dist/kwq/ensemble.d.ts.map +1 -0
- package/dist/kwq/ensemble.js +107 -0
- package/dist/kwq/ensemble.js.map +1 -0
- package/dist/kwq/index.d.ts +16 -0
- package/dist/kwq/index.d.ts.map +1 -0
- package/dist/kwq/index.js +14 -0
- package/dist/kwq/index.js.map +1 -0
- package/dist/kwq/types.d.ts +120 -0
- package/dist/kwq/types.d.ts.map +1 -0
- package/dist/kwq/types.js +11 -0
- package/dist/kwq/types.js.map +1 -0
- package/dist/lambda.d.ts +10 -0
- package/dist/lambda.d.ts.map +1 -0
- package/dist/lambda.js +4 -0
- package/dist/lambda.js.map +1 -0
- package/dist/main.d.ts +8 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +33 -0
- package/dist/main.js.map +1 -0
- package/dist/mcp/batch-fetch.d.ts +89 -0
- package/dist/mcp/batch-fetch.d.ts.map +1 -0
- package/dist/mcp/batch-fetch.js +178 -0
- package/dist/mcp/batch-fetch.js.map +1 -0
- package/dist/mcp/examples/dsl-examples.d.ts +21 -0
- package/dist/mcp/examples/dsl-examples.d.ts.map +1 -0
- package/dist/mcp/examples/dsl-examples.js +61 -0
- package/dist/mcp/examples/dsl-examples.js.map +1 -0
- package/dist/mcp/examples/usage-scenarios.d.ts +20 -0
- package/dist/mcp/examples/usage-scenarios.d.ts.map +1 -0
- package/dist/mcp/examples/usage-scenarios.js +169 -0
- package/dist/mcp/examples/usage-scenarios.js.map +1 -0
- package/dist/mcp/export-format.d.ts +43 -0
- package/dist/mcp/export-format.d.ts.map +1 -0
- package/dist/mcp/export-format.js +92 -0
- package/dist/mcp/export-format.js.map +1 -0
- package/dist/mcp/funder-org-names.d.ts +12 -0
- package/dist/mcp/funder-org-names.d.ts.map +1 -0
- package/dist/mcp/funder-org-names.js +30 -0
- package/dist/mcp/funder-org-names.js.map +1 -0
- package/dist/mcp/http-server.d.ts +20 -0
- package/dist/mcp/http-server.d.ts.map +1 -0
- package/dist/mcp/http-server.js +118 -0
- package/dist/mcp/http-server.js.map +1 -0
- package/dist/mcp/middleware/field-aliases.d.ts +97 -0
- package/dist/mcp/middleware/field-aliases.d.ts.map +1 -0
- package/dist/mcp/middleware/field-aliases.js +208 -0
- package/dist/mcp/middleware/field-aliases.js.map +1 -0
- package/dist/mcp/resources/schema.d.ts +13 -0
- package/dist/mcp/resources/schema.d.ts.map +1 -0
- package/dist/mcp/resources/schema.js +262 -0
- package/dist/mcp/resources/schema.js.map +1 -0
- package/dist/mcp/schema/context.d.ts +10 -0
- package/dist/mcp/schema/context.d.ts.map +1 -0
- package/dist/mcp/schema/context.js +6 -0
- package/dist/mcp/schema/context.js.map +1 -0
- package/dist/mcp/schema/index.d.ts +8 -0
- package/dist/mcp/schema/index.d.ts.map +1 -0
- package/dist/mcp/schema/index.js +6 -0
- package/dist/mcp/schema/index.js.map +1 -0
- package/dist/mcp/server.d.ts +56 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +168 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/shared-schema.d.ts +13 -0
- package/dist/mcp/shared-schema.d.ts.map +1 -0
- package/dist/mcp/shared-schema.js +28 -0
- package/dist/mcp/shared-schema.js.map +1 -0
- package/dist/mcp/tools/analytics-filters.d.ts +18 -0
- package/dist/mcp/tools/analytics-filters.d.ts.map +1 -0
- package/dist/mcp/tools/analytics-filters.js +35 -0
- package/dist/mcp/tools/analytics-filters.js.map +1 -0
- package/dist/mcp/tools/analytics.d.ts +16 -0
- package/dist/mcp/tools/analytics.d.ts.map +1 -0
- package/dist/mcp/tools/analytics.js +381 -0
- package/dist/mcp/tools/analytics.js.map +1 -0
- package/dist/mcp/tools/concept-profile.d.ts +14 -0
- package/dist/mcp/tools/concept-profile.d.ts.map +1 -0
- package/dist/mcp/tools/concept-profile.js +130 -0
- package/dist/mcp/tools/concept-profile.js.map +1 -0
- package/dist/mcp/tools/dataset-profile.d.ts +15 -0
- package/dist/mcp/tools/dataset-profile.d.ts.map +1 -0
- package/dist/mcp/tools/dataset-profile.js +194 -0
- package/dist/mcp/tools/dataset-profile.js.map +1 -0
- package/dist/mcp/tools/fetch-search-pages.d.ts +15 -0
- package/dist/mcp/tools/fetch-search-pages.d.ts.map +1 -0
- package/dist/mcp/tools/fetch-search-pages.js +237 -0
- package/dist/mcp/tools/fetch-search-pages.js.map +1 -0
- package/dist/mcp/tools/functions.d.ts +14 -0
- package/dist/mcp/tools/functions.d.ts.map +1 -0
- package/dist/mcp/tools/functions.js +87 -0
- package/dist/mcp/tools/functions.js.map +1 -0
- package/dist/mcp/tools/impact-chain.d.ts +15 -0
- package/dist/mcp/tools/impact-chain.d.ts.map +1 -0
- package/dist/mcp/tools/impact-chain.js +96 -0
- package/dist/mcp/tools/impact-chain.js.map +1 -0
- package/dist/mcp/tools/kwq.d.ts +19 -0
- package/dist/mcp/tools/kwq.d.ts.map +1 -0
- package/dist/mcp/tools/kwq.js +156 -0
- package/dist/mcp/tools/kwq.js.map +1 -0
- package/dist/mcp/tools/lookup.d.ts +14 -0
- package/dist/mcp/tools/lookup.d.ts.map +1 -0
- package/dist/mcp/tools/lookup.js +146 -0
- package/dist/mcp/tools/lookup.js.map +1 -0
- package/dist/mcp/tools/policy-profile.d.ts +15 -0
- package/dist/mcp/tools/policy-profile.d.ts.map +1 -0
- package/dist/mcp/tools/policy-profile.js +174 -0
- package/dist/mcp/tools/policy-profile.js.map +1 -0
- package/dist/mcp/tools/profile.d.ts +14 -0
- package/dist/mcp/tools/profile.d.ts.map +1 -0
- package/dist/mcp/tools/profile.js +349 -0
- package/dist/mcp/tools/profile.js.map +1 -0
- package/dist/mcp/tools/query.d.ts +16 -0
- package/dist/mcp/tools/query.d.ts.map +1 -0
- package/dist/mcp/tools/query.js +75 -0
- package/dist/mcp/tools/query.js.map +1 -0
- package/dist/mcp/tools/schema.d.ts +23 -0
- package/dist/mcp/tools/schema.d.ts.map +1 -0
- package/dist/mcp/tools/schema.js +124 -0
- package/dist/mcp/tools/schema.js.map +1 -0
- package/dist/mcp/tools/search-entity-metadata.d.ts +18 -0
- package/dist/mcp/tools/search-entity-metadata.d.ts.map +1 -0
- package/dist/mcp/tools/search-entity-metadata.js +221 -0
- package/dist/mcp/tools/search-entity-metadata.js.map +1 -0
- package/dist/mcp/tools/search-input.d.ts +58 -0
- package/dist/mcp/tools/search-input.d.ts.map +1 -0
- package/dist/mcp/tools/search-input.js +76 -0
- package/dist/mcp/tools/search-input.js.map +1 -0
- package/dist/mcp/tools/search.d.ts +24 -0
- package/dist/mcp/tools/search.d.ts.map +1 -0
- package/dist/mcp/tools/search.js +115 -0
- package/dist/mcp/tools/search.js.map +1 -0
- package/dist/mcp/utils.d.ts +82 -0
- package/dist/mcp/utils.d.ts.map +1 -0
- package/dist/mcp/utils.js +126 -0
- package/dist/mcp/utils.js.map +1 -0
- package/dist/middleware/field-aliases.d.ts +97 -0
- package/dist/middleware/field-aliases.d.ts.map +1 -0
- package/dist/middleware/field-aliases.js +208 -0
- package/dist/middleware/field-aliases.js.map +1 -0
- package/dist/resources/schema.d.ts +13 -0
- package/dist/resources/schema.d.ts.map +1 -0
- package/dist/resources/schema.js +204 -0
- package/dist/resources/schema.js.map +1 -0
- package/dist/schema/context.d.ts +10 -0
- package/dist/schema/context.d.ts.map +1 -0
- package/dist/schema/context.js +6 -0
- package/dist/schema/context.js.map +1 -0
- package/dist/schema/index.d.ts +9 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +6 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/load.d.ts +43 -0
- package/dist/schema/load.d.ts.map +1 -0
- package/dist/schema/load.js +139 -0
- package/dist/schema/load.js.map +1 -0
- package/dist/schema/store.d.ts +112 -0
- package/dist/schema/store.d.ts.map +1 -0
- package/dist/schema/store.js +173 -0
- package/dist/schema/store.js.map +1 -0
- package/dist/schema/structured-entities.d.ts +21 -0
- package/dist/schema/structured-entities.d.ts.map +1 -0
- package/dist/schema/structured-entities.js +39 -0
- package/dist/schema/structured-entities.js.map +1 -0
- package/dist/schema/types.d.ts +36 -0
- package/dist/schema/types.d.ts.map +1 -0
- package/dist/schema/types.js +6 -0
- package/dist/schema/types.js.map +1 -0
- package/dist/server.d.ts +57 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +144 -0
- package/dist/server.js.map +1 -0
- package/dist/telemetry.d.ts +172 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +233 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/tools/analytics-filters.d.ts +18 -0
- package/dist/tools/analytics-filters.d.ts.map +1 -0
- package/dist/tools/analytics-filters.js +35 -0
- package/dist/tools/analytics-filters.js.map +1 -0
- package/dist/tools/analytics.d.ts +16 -0
- package/dist/tools/analytics.d.ts.map +1 -0
- package/dist/tools/analytics.js +381 -0
- package/dist/tools/analytics.js.map +1 -0
- package/dist/tools/concept-profile.d.ts +14 -0
- package/dist/tools/concept-profile.d.ts.map +1 -0
- package/dist/tools/concept-profile.js +130 -0
- package/dist/tools/concept-profile.js.map +1 -0
- package/dist/tools/dataset-profile.d.ts +15 -0
- package/dist/tools/dataset-profile.d.ts.map +1 -0
- package/dist/tools/dataset-profile.js +194 -0
- package/dist/tools/dataset-profile.js.map +1 -0
- package/dist/tools/functions.d.ts +14 -0
- package/dist/tools/functions.d.ts.map +1 -0
- package/dist/tools/functions.js +294 -0
- package/dist/tools/functions.js.map +1 -0
- package/dist/tools/impact-chain.d.ts +15 -0
- package/dist/tools/impact-chain.d.ts.map +1 -0
- package/dist/tools/impact-chain.js +96 -0
- package/dist/tools/impact-chain.js.map +1 -0
- package/dist/tools/kwq.d.ts +19 -0
- package/dist/tools/kwq.d.ts.map +1 -0
- package/dist/tools/kwq.js +156 -0
- package/dist/tools/kwq.js.map +1 -0
- package/dist/tools/lookup.d.ts +14 -0
- package/dist/tools/lookup.d.ts.map +1 -0
- package/dist/tools/lookup.js +213 -0
- package/dist/tools/lookup.js.map +1 -0
- package/dist/tools/policy-profile.d.ts +15 -0
- package/dist/tools/policy-profile.d.ts.map +1 -0
- package/dist/tools/policy-profile.js +174 -0
- package/dist/tools/policy-profile.js.map +1 -0
- package/dist/tools/profile.d.ts +14 -0
- package/dist/tools/profile.d.ts.map +1 -0
- package/dist/tools/profile.js +349 -0
- package/dist/tools/profile.js.map +1 -0
- package/dist/tools/query.d.ts +16 -0
- package/dist/tools/query.d.ts.map +1 -0
- package/dist/tools/query.js +53 -0
- package/dist/tools/query.js.map +1 -0
- package/dist/tools/schema.d.ts +23 -0
- package/dist/tools/schema.d.ts.map +1 -0
- package/dist/tools/schema.js +124 -0
- package/dist/tools/schema.js.map +1 -0
- package/dist/tools/search-entity-metadata.d.ts +18 -0
- package/dist/tools/search-entity-metadata.d.ts.map +1 -0
- package/dist/tools/search-entity-metadata.js +221 -0
- package/dist/tools/search-entity-metadata.js.map +1 -0
- package/dist/tools/search.d.ts +23 -0
- package/dist/tools/search.d.ts.map +1 -0
- package/dist/tools/search.js +110 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/tools/solr-fields.d.ts +39 -0
- package/dist/tools/solr-fields.d.ts.map +1 -0
- package/dist/tools/solr-fields.js +40 -0
- package/dist/tools/solr-fields.js.map +1 -0
- package/dist/utils.d.ts +70 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +104 -0
- package/dist/utils.js.map +1 -0
- package/package.json +41 -0
- package/src/client/auth/config-loaders.ts +81 -0
- package/src/client/auth/decorators/index.ts +7 -0
- package/src/client/auth/decorators/with-caching.ts +237 -0
- package/src/client/auth/factory.ts +34 -0
- package/src/client/auth/index.ts +6 -0
- package/src/client/auth/jwt-utils.ts +36 -0
- package/src/client/auth/node.ts +16 -0
- package/src/client/auth/providers/index.ts +1 -0
- package/src/client/auth/providers/jwt-auth-provider.ts +153 -0
- package/src/client/auth/schemas.ts +25 -0
- package/src/client/auth/types.ts +30 -0
- package/src/client/command.ts +54 -0
- package/src/client/config/index.ts +15 -0
- package/src/client/config/loader.ts +155 -0
- package/src/client/config/node.ts +22 -0
- package/src/client/config/schemas.ts +28 -0
- package/src/client/config/types.ts +39 -0
- package/src/client/config/unified-loader.ts +118 -0
- package/src/client/config.ts +69 -0
- package/src/client/deployment-config.ts +98 -0
- package/src/client/errors.ts +295 -0
- package/src/client/http-client.ts +577 -0
- package/src/client/index.ts +68 -0
- package/src/client/internal-dsl-client.ts +128 -0
- package/src/client/rate-limiter.ts +139 -0
- package/src/client/resolve-api-key-user.ts +99 -0
- package/src/client/types.ts +44 -0
- package/src/dsl/client.ts +538 -0
- package/src/dsl/commands/apply-filters.ts +35 -0
- package/src/dsl/commands/facet/index.ts +12 -0
- package/src/dsl/commands/facet/schemas.ts +101 -0
- package/src/dsl/commands/functions/ClassifyCommand.ts +129 -0
- package/src/dsl/commands/functions/ExtractAffiliationsCommand.ts +163 -0
- package/src/dsl/commands/functions/ExtractConceptsCommand.ts +141 -0
- package/src/dsl/commands/functions/ExtractGrantsCommand.ts +112 -0
- package/src/dsl/commands/functions/index.ts +31 -0
- package/src/dsl/commands/index.ts +29 -0
- package/src/dsl/commands/validate-input.ts +29 -0
- package/src/dsl/create-client.ts +80 -0
- package/src/dsl/fluent-query-builder.ts +684 -0
- package/src/dsl/index.ts +206 -0
- package/src/dsl/pagination.ts +202 -0
- package/src/dsl/query-builder.ts +1120 -0
- package/src/dsl/response-parser.ts +299 -0
- package/src/dsl/schema/cache.ts +124 -0
- package/src/dsl/schema/extract.ts +44 -0
- package/src/dsl/schema/index.ts +50 -0
- package/src/dsl/schema/load.ts +160 -0
- package/src/dsl/schema/store.ts +253 -0
- package/src/dsl/schema/structured-entities.ts +44 -0
- package/src/dsl/schema/summary.ts +94 -0
- package/src/dsl/schema/types.ts +40 -0
- package/src/dsl/schema/validation.ts +56 -0
- package/src/dsl/types/buckets.ts +22 -0
- package/src/dsl/types/common.ts +99 -0
- package/src/dsl/types/entities.ts +43 -0
- package/src/dsl/types/index.ts +63 -0
- package/src/dsl/types/return-clauses.ts +147 -0
- package/src/dsl/types/special-functions.ts +220 -0
- package/src/dsl/types/vocabulary.ts +82 -0
- package/src/dsl/usage-policy.ts +219 -0
- package/src/dsl/utils/escape.ts +123 -0
- package/src/dsl/utils/sanitize.ts +21 -0
- package/src/dsl/utils/string-utils.ts +147 -0
- package/src/dsl/utils/validate-field-name.ts +19 -0
- package/src/http-main.ts +41 -0
- package/src/index.ts +14 -0
- package/src/main.ts +40 -0
- package/src/mcp/batch-fetch.ts +255 -0
- package/src/mcp/examples/dsl-examples.ts +66 -0
- package/src/mcp/examples/usage-scenarios.ts +185 -0
- package/src/mcp/export-format.ts +113 -0
- package/src/mcp/funder-org-names.ts +30 -0
- package/src/mcp/http-server.ts +148 -0
- package/src/mcp/middleware/field-aliases.ts +274 -0
- package/src/mcp/resources/schema.ts +364 -0
- package/src/mcp/schema/context.ts +11 -0
- package/src/mcp/schema/index.ts +38 -0
- package/src/mcp/server.ts +247 -0
- package/src/mcp/shared-schema.ts +34 -0
- package/src/mcp/tools/analytics-filters.ts +46 -0
- package/src/mcp/tools/analytics.ts +453 -0
- package/src/mcp/tools/fetch-search-pages.ts +329 -0
- package/src/mcp/tools/functions.ts +105 -0
- package/src/mcp/tools/lookup.ts +182 -0
- package/src/mcp/tools/query.ts +91 -0
- package/src/mcp/tools/schema.ts +147 -0
- package/src/mcp/tools/search-entity-metadata.ts +253 -0
- package/src/mcp/tools/search-input.ts +87 -0
- package/src/mcp/tools/search.ts +168 -0
- package/src/mcp/utils.ts +199 -0
- package/test/client/auth/config-loaders.test.ts +92 -0
- package/test/client/auth/decorators/with-caching.test.ts +482 -0
- package/test/client/auth/factory.test.ts +68 -0
- package/test/client/auth/providers/jwt-auth-provider.test.ts +398 -0
- package/test/client/auth/types.test.ts +18 -0
- package/test/client/command.test.ts +163 -0
- package/test/client/config/loader.test.ts +377 -0
- package/test/client/config/unified-loader.test.ts +136 -0
- package/test/client/deployment-config.test.ts +69 -0
- package/test/client/errors/index.test.ts +408 -0
- package/test/client/helpers/mock-fetch.ts +42 -0
- package/test/client/http-client.test.ts +1148 -0
- package/test/client/integration/auth-providers.integration.test.ts +186 -0
- package/test/client/internal-dsl-client.test.ts +76 -0
- package/test/client/rate-limiter.test.ts +204 -0
- package/test/client/resolve-api-key-user.test.ts +87 -0
- package/test/dsl/client.special-functions.test.ts +387 -0
- package/test/dsl/client.test.ts +457 -0
- package/test/dsl/commands/apply-filters.test.ts +147 -0
- package/test/dsl/commands/functions/ClassifyCommand.test.ts +170 -0
- package/test/dsl/commands/functions/ExtractAffiliationsCommand.test.ts +306 -0
- package/test/dsl/commands/functions/ExtractConceptsCommand.test.ts +136 -0
- package/test/dsl/commands/functions/ExtractGrantsCommand.test.ts +202 -0
- package/test/dsl/commands/search/filters.test.ts +42 -0
- package/test/dsl/fluent-query-builder.test.ts +865 -0
- package/test/dsl/integration/client.integration.test.ts +294 -0
- package/test/dsl/integration/facet-api.integration.test.ts +276 -0
- package/test/dsl/integration/field-existence.integration.test.ts +148 -0
- package/test/dsl/integration/fluent-api-docs-examples.integration.test.ts +988 -0
- package/test/dsl/integration/fluent-api.integration.test.ts +615 -0
- package/test/dsl/integration/search-helpers.ts +27 -0
- package/test/dsl/integration/special-functions.integration.test.ts +224 -0
- package/test/dsl/integration/test-config.ts +52 -0
- package/test/dsl/pagination.test.ts +86 -0
- package/test/dsl/query-builder.test.ts +1775 -0
- package/test/dsl/response-parser.test.ts +520 -0
- package/test/dsl/schema/cache.test.ts +53 -0
- package/test/dsl/schema/load.test.ts +165 -0
- package/test/dsl/schema/summary.test.ts +61 -0
- package/test/dsl/schema/validation.test.ts +46 -0
- package/test/dsl/time-series.test.ts +135 -0
- package/test/dsl/unnest.test.ts +151 -0
- package/test/dsl/usage-policy.test.ts +100 -0
- package/test/dsl/utils/escape.property.test.ts +109 -0
- package/test/dsl/utils/escape.test.ts +140 -0
- package/test/dsl/utils/validate-field-name.property.test.ts +99 -0
- package/test/dsl/utils/validate-field-name.test.ts +55 -0
- package/test/examples/dsl-examples.test.ts +29 -0
- package/test/examples/usage-scenarios.test.ts +90 -0
- package/test/fixtures/describe-schema.json +4000 -0
- package/test/funder-org-names.test.ts +20 -0
- package/test/helpers/schema-fixture.ts +18 -0
- package/test/helpers/tool-test-harness.ts +114 -0
- package/test/integration/assertions.ts +263 -0
- package/test/integration/env.ts +108 -0
- package/test/integration/harness.ts +307 -0
- package/test/integration/hosted-client.ts +56 -0
- package/test/integration/hosted-mocks.ts +81 -0
- package/test/integration/hosted-run.ts +86 -0
- package/test/integration/hosted.e2e.test.ts +101 -0
- package/test/integration/reporter.ts +100 -0
- package/test/integration/run.ts +74 -0
- package/test/integration/suites/analytics.integration.ts +72 -0
- package/test/integration/suites/functions.integration.ts +37 -0
- package/test/integration/suites/hosted-smoke.integration.ts +38 -0
- package/test/integration/suites/index.ts +22 -0
- package/test/integration/suites/lookup.integration.ts +57 -0
- package/test/integration/suites/query.integration.ts +49 -0
- package/test/integration/suites/resources.integration.ts +68 -0
- package/test/integration/suites/search.integration.ts +80 -0
- package/test/integration/types.ts +92 -0
- package/test/integration/verify-usage-scenarios.ts +162 -0
- package/test/mcp/export-format.test.ts +67 -0
- package/test/mcp/http-server.test.ts +80 -0
- package/test/middleware/field-aliases.test.ts +287 -0
- package/test/resources/schema.test.ts +28 -0
- package/test/schema/describe-contract.test.ts +24 -0
- package/test/schema/store.test.ts +45 -0
- package/test/server.test.ts +170 -0
- package/test/tools/analytics-filters.test.ts +35 -0
- package/test/tools/analytics.test.ts +419 -0
- package/test/tools/fetch-search-pages.test.ts +200 -0
- package/test/tools/functions.test.ts +153 -0
- package/test/tools/lookup.test.ts +296 -0
- package/test/tools/query.test.ts +100 -0
- package/test/tools/schema.test.ts +37 -0
- package/test/tools/search.test.ts +415 -0
- package/test/utils.test.ts +45 -0
- package/tsconfig.json +9 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module test/schema/load
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
6
|
+
import { tmpdir } from "node:os";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
9
|
+
import type { DimensionsClient } from "../../../src/dsl/client.js";
|
|
10
|
+
import {
|
|
11
|
+
DEFAULT_SCHEMA_CACHE_TTL_MS,
|
|
12
|
+
parseCachePayload,
|
|
13
|
+
writeSchemaCacheFile,
|
|
14
|
+
} from "../../../src/dsl/schema/cache.js";
|
|
15
|
+
import { clearSchemaCache, loadSchema } from "../../../src/dsl/schema/load.js";
|
|
16
|
+
|
|
17
|
+
const liveSchema = {
|
|
18
|
+
sources: { publications: { fields: { year: { type: "int", is_filter: true } } } },
|
|
19
|
+
entities: { journals: { fields: { title: { type: "string", is_filter: true } } } },
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
function createMockClient(handlers: {
|
|
23
|
+
schema?: () => Promise<unknown>;
|
|
24
|
+
version?: () => Promise<unknown>;
|
|
25
|
+
}): DimensionsClient {
|
|
26
|
+
return {
|
|
27
|
+
rawQuery: vi.fn(async (dsl: string) => {
|
|
28
|
+
if (dsl === "describe schema") {
|
|
29
|
+
if (!handlers.schema) throw new Error("schema fetch failed");
|
|
30
|
+
return handlers.schema();
|
|
31
|
+
}
|
|
32
|
+
if (dsl === "describe version") {
|
|
33
|
+
if (!handlers.version) throw new Error("version fetch failed");
|
|
34
|
+
return handlers.version();
|
|
35
|
+
}
|
|
36
|
+
throw new Error(`unexpected query: ${dsl}`);
|
|
37
|
+
}),
|
|
38
|
+
} as unknown as DimensionsClient;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
describe("loadSchema", () => {
|
|
42
|
+
let cacheDir: string;
|
|
43
|
+
let cachePath: string;
|
|
44
|
+
|
|
45
|
+
beforeEach(async () => {
|
|
46
|
+
clearSchemaCache();
|
|
47
|
+
cacheDir = await mkdtemp(join(tmpdir(), "dsl-schema-cache-"));
|
|
48
|
+
cachePath = join(cacheDir, "schema.json");
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
afterEach(async () => {
|
|
52
|
+
clearSchemaCache();
|
|
53
|
+
await rm(cacheDir, { recursive: true, force: true });
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("loads from API and writes cache envelope", async () => {
|
|
57
|
+
const client = createMockClient({
|
|
58
|
+
schema: async () => liveSchema,
|
|
59
|
+
version: async () => ({ version: "2.15.0" }),
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const store = await loadSchema(client, { cachePath, log: false });
|
|
63
|
+
expect(store.loadSource).toBe("api");
|
|
64
|
+
expect(store.stale).toBe(false);
|
|
65
|
+
expect(store.version).toBe("2.15.0");
|
|
66
|
+
|
|
67
|
+
const onDisk = parseCachePayload(JSON.parse(await readFile(cachePath, "utf8")));
|
|
68
|
+
expect(onDisk?.cachedAt).toBeDefined();
|
|
69
|
+
expect(onDisk?.version).toBe("2.15.0");
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("uses fresh cache without calling the API", async () => {
|
|
73
|
+
const seedClient = createMockClient({
|
|
74
|
+
schema: async () => liveSchema,
|
|
75
|
+
version: async () => ({ version: "2.15.0" }),
|
|
76
|
+
});
|
|
77
|
+
await loadSchema(seedClient, { cachePath, log: false });
|
|
78
|
+
|
|
79
|
+
clearSchemaCache();
|
|
80
|
+
const cachedClient = createMockClient({
|
|
81
|
+
schema: async () => {
|
|
82
|
+
throw new Error("should not fetch schema");
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const store = await loadSchema(cachedClient, {
|
|
87
|
+
cachePath,
|
|
88
|
+
cacheTtlMs: DEFAULT_SCHEMA_CACHE_TTL_MS,
|
|
89
|
+
log: false,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
expect(store.loadSource).toBe("cache");
|
|
93
|
+
expect(store.stale).toBe(false);
|
|
94
|
+
expect(cachedClient.rawQuery).not.toHaveBeenCalled();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("refreshes expired cache from the API", async () => {
|
|
98
|
+
await writeSchemaCacheFile(cachePath, liveSchema, "2.14.0");
|
|
99
|
+
const envelope = JSON.parse(await readFile(cachePath, "utf8")) as Record<string, unknown>;
|
|
100
|
+
envelope.cachedAt = new Date(Date.now() - DEFAULT_SCHEMA_CACHE_TTL_MS - 1000).toISOString();
|
|
101
|
+
await writeFile(cachePath, JSON.stringify(envelope), "utf8");
|
|
102
|
+
|
|
103
|
+
clearSchemaCache();
|
|
104
|
+
const client = createMockClient({
|
|
105
|
+
schema: async () => ({
|
|
106
|
+
...liveSchema,
|
|
107
|
+
sources: {
|
|
108
|
+
...liveSchema.sources,
|
|
109
|
+
grants: { fields: { title: { type: "string", is_filter: true } } },
|
|
110
|
+
},
|
|
111
|
+
}),
|
|
112
|
+
version: async () => ({ version: "2.15.0" }),
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const store = await loadSchema(client, { cachePath, log: false });
|
|
116
|
+
|
|
117
|
+
expect(store.loadSource).toBe("api");
|
|
118
|
+
expect(store.version).toBe("2.15.0");
|
|
119
|
+
expect(store.sourceNames()).toContain("grants");
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("falls back to stale cache when the API is unavailable", async () => {
|
|
123
|
+
await writeSchemaCacheFile(cachePath, liveSchema, "2.15.0");
|
|
124
|
+
const envelope = JSON.parse(await readFile(cachePath, "utf8")) as Record<string, unknown>;
|
|
125
|
+
envelope.cachedAt = new Date(Date.now() - DEFAULT_SCHEMA_CACHE_TTL_MS - 1000).toISOString();
|
|
126
|
+
await writeFile(cachePath, JSON.stringify(envelope), "utf8");
|
|
127
|
+
|
|
128
|
+
clearSchemaCache();
|
|
129
|
+
const failingClient = createMockClient({
|
|
130
|
+
schema: async () => {
|
|
131
|
+
throw new Error("network down");
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
const store = await loadSchema(failingClient, { cachePath, log: false });
|
|
136
|
+
|
|
137
|
+
expect(store.loadSource).toBe("cache");
|
|
138
|
+
expect(store.stale).toBe(true);
|
|
139
|
+
expect(store.version).toBe("2.15.0");
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it("forceRefresh bypasses fresh cache", async () => {
|
|
143
|
+
const seedClient = createMockClient({
|
|
144
|
+
schema: async () => liveSchema,
|
|
145
|
+
version: async () => ({ version: "2.14.0" }),
|
|
146
|
+
});
|
|
147
|
+
await loadSchema(seedClient, { cachePath, log: false });
|
|
148
|
+
|
|
149
|
+
clearSchemaCache();
|
|
150
|
+
const refreshClient = createMockClient({
|
|
151
|
+
schema: async () => liveSchema,
|
|
152
|
+
version: async () => ({ version: "2.15.0" }),
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
const store = await loadSchema(refreshClient, {
|
|
156
|
+
cachePath,
|
|
157
|
+
forceRefresh: true,
|
|
158
|
+
log: false,
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
expect(store.loadSource).toBe("api");
|
|
162
|
+
expect(store.version).toBe("2.15.0");
|
|
163
|
+
expect(refreshClient.rawQuery).toHaveBeenCalled();
|
|
164
|
+
});
|
|
165
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module test/schema/summary
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, expect, it } from "vitest";
|
|
6
|
+
import { createSchemaStoreFromResponse } from "../../../src/dsl/schema/store.js";
|
|
7
|
+
import { buildSchemaSummary, SCHEMA_RESOURCE_URIS } from "../../../src/dsl/schema/summary.js";
|
|
8
|
+
|
|
9
|
+
const sample = {
|
|
10
|
+
sources: {
|
|
11
|
+
publications: {
|
|
12
|
+
fields: {
|
|
13
|
+
year: { type: "int", is_filter: true, is_facet: true },
|
|
14
|
+
title: { type: "string", is_filter: true },
|
|
15
|
+
},
|
|
16
|
+
search_fields: ["full_data", "title"],
|
|
17
|
+
metrics: ["times_cited"],
|
|
18
|
+
fieldsets: { basic: ["id", "title"] },
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
entities: { journals: { fields: { title: { type: "string", is_filter: true } } } },
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
describe("buildSchemaSummary", () => {
|
|
25
|
+
it("returns compact counts and resource URIs", () => {
|
|
26
|
+
const store = createSchemaStoreFromResponse(
|
|
27
|
+
sample,
|
|
28
|
+
"2.15.0",
|
|
29
|
+
new Date("2026-01-01T00:00:00Z"),
|
|
30
|
+
{
|
|
31
|
+
loadSource: "api",
|
|
32
|
+
stale: false,
|
|
33
|
+
},
|
|
34
|
+
);
|
|
35
|
+
const summary = buildSchemaSummary(store);
|
|
36
|
+
|
|
37
|
+
expect(summary.version).toBe("2.15.0");
|
|
38
|
+
expect(summary.stats.sourceCount).toBe(1);
|
|
39
|
+
expect(summary.stats.entityCount).toBe(1);
|
|
40
|
+
expect(summary.sources.publications.filterableFieldCount).toBe(2);
|
|
41
|
+
expect(summary.sources.publications.facetFieldCount).toBe(1);
|
|
42
|
+
expect(summary.sources.publications.searchIndexCount).toBe(2);
|
|
43
|
+
expect(summary.sources.publications.metricCount).toBe(1);
|
|
44
|
+
expect(summary.resources).toEqual(SCHEMA_RESOURCE_URIS);
|
|
45
|
+
expect(summary.hint).toContain("dimensions://fields");
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("marks stale cache in the hint", () => {
|
|
49
|
+
const store = createSchemaStoreFromResponse(sample, "2.15.0", new Date(), {
|
|
50
|
+
loadSource: "cache",
|
|
51
|
+
stale: true,
|
|
52
|
+
cachedAt: new Date("2026-01-01T00:00:00Z"),
|
|
53
|
+
});
|
|
54
|
+
const summary = buildSchemaSummary(store);
|
|
55
|
+
|
|
56
|
+
expect(summary.stale).toBe(true);
|
|
57
|
+
expect(summary.loadSource).toBe("cache");
|
|
58
|
+
expect(summary.cachedAt).toBe("2026-01-01T00:00:00.000Z");
|
|
59
|
+
expect(summary.hint).toContain("refresh_schema");
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for describe-backed validation helpers.
|
|
3
|
+
* @module test/schema/validation
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { describe, expect, it } from "vitest";
|
|
7
|
+
import { ValidationError } from "../../../src/client/index.js";
|
|
8
|
+
import {
|
|
9
|
+
assertValidEntity,
|
|
10
|
+
assertValidSearchIndex,
|
|
11
|
+
createSchemaStoreFromResponse,
|
|
12
|
+
type DescribeSchemaResponse,
|
|
13
|
+
QueryBuilder,
|
|
14
|
+
} from "../../../src/dsl/index.js";
|
|
15
|
+
import fixture from "../../fixtures/describe-schema.json";
|
|
16
|
+
|
|
17
|
+
describe("schema validation", () => {
|
|
18
|
+
const store = createSchemaStoreFromResponse(fixture as DescribeSchemaResponse);
|
|
19
|
+
|
|
20
|
+
it("assertValidEntity accepts sources from describe", () => {
|
|
21
|
+
expect(() => assertValidEntity(store, "publications")).not.toThrow();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("assertValidEntity rejects unknown sources when store is set", () => {
|
|
25
|
+
expect(() => assertValidEntity(store, "not_a_source")).toThrow(ValidationError);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("assertValidSearchIndex accepts indexes from describe", () => {
|
|
29
|
+
expect(() => assertValidSearchIndex(store, "publications", "full_data")).not.toThrow();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("assertValidSearchIndex rejects unknown indexes when store is set", () => {
|
|
33
|
+
expect(() => assertValidSearchIndex(store, "publications", "not_an_index")).toThrow(
|
|
34
|
+
ValidationError,
|
|
35
|
+
);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("QueryBuilder uses schema store when provided", () => {
|
|
39
|
+
expect(() => new QueryBuilder(store).search("not_a_source")).toThrow(ValidationError);
|
|
40
|
+
expect(() =>
|
|
41
|
+
new QueryBuilder(store).search("publications").in("not_an_index").for("test"),
|
|
42
|
+
).toThrow(ValidationError);
|
|
43
|
+
const dsl = new QueryBuilder(store).search("publications").for("test").limit(1).build();
|
|
44
|
+
expect(dsl).toContain('search publications for "test"');
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for time-series return functions (citations_per_year, funding_per_year).
|
|
3
|
+
* @module test/core/time-series
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { describe, expect, it } from "vitest";
|
|
7
|
+
import { QueryBuilder } from "../../src/dsl/query-builder.js";
|
|
8
|
+
|
|
9
|
+
describe("QueryBuilder time-series functions", () => {
|
|
10
|
+
describe("returnCitationsPerYear", () => {
|
|
11
|
+
it("should generate correct DSL for citations_per_year", () => {
|
|
12
|
+
const query = new QueryBuilder()
|
|
13
|
+
.search("publications")
|
|
14
|
+
.for("machine learning")
|
|
15
|
+
.returnCitationsPerYear(2010, 2023)
|
|
16
|
+
.build();
|
|
17
|
+
|
|
18
|
+
expect(query).toContain("return citations_per_year(2010, 2023)");
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("should work with where clauses", () => {
|
|
22
|
+
const query = new QueryBuilder()
|
|
23
|
+
.search("publications")
|
|
24
|
+
.for("test")
|
|
25
|
+
.where("year", ">=", 2020)
|
|
26
|
+
.returnCitationsPerYear(2020, 2024)
|
|
27
|
+
.build();
|
|
28
|
+
|
|
29
|
+
expect(query).toContain("where year >= 2020");
|
|
30
|
+
expect(query).toContain("return citations_per_year(2020, 2024)");
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("should reject endYear before startYear", () => {
|
|
34
|
+
expect(() => {
|
|
35
|
+
new QueryBuilder()
|
|
36
|
+
.search("publications")
|
|
37
|
+
.for("test")
|
|
38
|
+
.returnCitationsPerYear(2024, 2020)
|
|
39
|
+
.build();
|
|
40
|
+
}).toThrow(/startYear must not be greater than endYear/);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("should allow same start and end year", () => {
|
|
44
|
+
const query = new QueryBuilder()
|
|
45
|
+
.search("publications")
|
|
46
|
+
.for("test")
|
|
47
|
+
.returnCitationsPerYear(2023, 2023)
|
|
48
|
+
.build();
|
|
49
|
+
|
|
50
|
+
expect(query).toContain("return citations_per_year(2023, 2023)");
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
describe("returnFundingPerYear", () => {
|
|
55
|
+
it("should generate correct DSL for funding_per_year with default USD", () => {
|
|
56
|
+
const query = new QueryBuilder()
|
|
57
|
+
.search("grants")
|
|
58
|
+
.for("cancer research")
|
|
59
|
+
.returnFundingPerYear(2015, 2023)
|
|
60
|
+
.build();
|
|
61
|
+
|
|
62
|
+
expect(query).toContain('return funding_per_year(2015, 2023, "USD")');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("should generate correct DSL with specified currency", () => {
|
|
66
|
+
const query = new QueryBuilder()
|
|
67
|
+
.search("grants")
|
|
68
|
+
.for("test")
|
|
69
|
+
.returnFundingPerYear(2015, 2023, "EUR")
|
|
70
|
+
.build();
|
|
71
|
+
|
|
72
|
+
expect(query).toContain('return funding_per_year(2015, 2023, "EUR")');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("should support all valid currencies", () => {
|
|
76
|
+
const currencies = ["AUD", "CAD", "CHF", "CNY", "EUR", "GBP", "JPY", "NZD", "USD"] as const;
|
|
77
|
+
|
|
78
|
+
for (const currency of currencies) {
|
|
79
|
+
const query = new QueryBuilder()
|
|
80
|
+
.search("grants")
|
|
81
|
+
.for("test")
|
|
82
|
+
.returnFundingPerYear(2020, 2024, currency)
|
|
83
|
+
.build();
|
|
84
|
+
|
|
85
|
+
expect(query).toContain(`"${currency}"`);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("should work with where clauses", () => {
|
|
90
|
+
const query = new QueryBuilder()
|
|
91
|
+
.search("grants")
|
|
92
|
+
.for("test")
|
|
93
|
+
.where("funding_usd", ">", 1000000)
|
|
94
|
+
.returnFundingPerYear(2020, 2024, "GBP")
|
|
95
|
+
.build();
|
|
96
|
+
|
|
97
|
+
expect(query).toContain("where funding_usd > 1000000");
|
|
98
|
+
expect(query).toContain('return funding_per_year(2020, 2024, "GBP")');
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("should reject endYear before startYear", () => {
|
|
102
|
+
expect(() => {
|
|
103
|
+
new QueryBuilder().search("grants").for("test").returnFundingPerYear(2024, 2020).build();
|
|
104
|
+
}).toThrow(/startYear must not be greater than endYear/);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
describe("combining time-series with entity return", () => {
|
|
109
|
+
it("should allow entity return before time-series", () => {
|
|
110
|
+
const query = new QueryBuilder()
|
|
111
|
+
.search("publications")
|
|
112
|
+
.for("test")
|
|
113
|
+
.fields(["id", "title"])
|
|
114
|
+
.limit(10)
|
|
115
|
+
.returnCitationsPerYear(2020, 2024)
|
|
116
|
+
.build();
|
|
117
|
+
|
|
118
|
+
expect(query).toContain("return publications[id+title]");
|
|
119
|
+
expect(query).toContain("limit 10");
|
|
120
|
+
expect(query).toContain("return citations_per_year(2020, 2024)");
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it("should allow both citations and funding in same query (grants)", () => {
|
|
124
|
+
const query = new QueryBuilder()
|
|
125
|
+
.search("grants")
|
|
126
|
+
.for("test")
|
|
127
|
+
.returnCitationsPerYear(2020, 2024)
|
|
128
|
+
.returnFundingPerYear(2020, 2024, "USD")
|
|
129
|
+
.build();
|
|
130
|
+
|
|
131
|
+
expect(query).toContain("return citations_per_year(2020, 2024)");
|
|
132
|
+
expect(query).toContain('return funding_per_year(2020, 2024, "USD")');
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
});
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for unnest functionality in QueryBuilder and FluentQueryBuilder.
|
|
3
|
+
* @module test/core/unnest
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { describe, expect, it } from "vitest";
|
|
7
|
+
import { ValidationError } from "../../src/client/index.js";
|
|
8
|
+
import { QueryBuilder } from "../../src/dsl/query-builder.js";
|
|
9
|
+
|
|
10
|
+
describe("QueryBuilder unnest", () => {
|
|
11
|
+
describe("fieldsWithUnnest", () => {
|
|
12
|
+
it("should generate correct DSL for single unnest", () => {
|
|
13
|
+
const query = new QueryBuilder()
|
|
14
|
+
.search("publications")
|
|
15
|
+
.for("test")
|
|
16
|
+
.fieldsWithUnnest(["id", "title"], ["researchers"])
|
|
17
|
+
.build();
|
|
18
|
+
|
|
19
|
+
expect(query).toContain("return publications[id+title+unnest(researchers)]");
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("should generate correct DSL for multiple unnests", () => {
|
|
23
|
+
const query = new QueryBuilder()
|
|
24
|
+
.search("publications")
|
|
25
|
+
.for("test")
|
|
26
|
+
.fieldsWithUnnest(["id", "title"], ["researchers", "category_for"])
|
|
27
|
+
.build();
|
|
28
|
+
|
|
29
|
+
expect(query).toContain(
|
|
30
|
+
"return publications[id+title+unnest(researchers)+unnest(category_for)]",
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("should work with only unnest fields (no regular fields)", () => {
|
|
35
|
+
const query = new QueryBuilder()
|
|
36
|
+
.search("publications")
|
|
37
|
+
.for("test")
|
|
38
|
+
.fieldsWithUnnest([], ["researchers"])
|
|
39
|
+
.build();
|
|
40
|
+
|
|
41
|
+
expect(query).toContain("return publications[unnest(researchers)]");
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("should work with only regular fields (no unnest)", () => {
|
|
45
|
+
const query = new QueryBuilder()
|
|
46
|
+
.search("publications")
|
|
47
|
+
.for("test")
|
|
48
|
+
.fieldsWithUnnest(["id", "title"], [])
|
|
49
|
+
.build();
|
|
50
|
+
|
|
51
|
+
expect(query).toContain("return publications[id+title]");
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("should combine with where clauses", () => {
|
|
55
|
+
const query = new QueryBuilder()
|
|
56
|
+
.search("publications")
|
|
57
|
+
.for("machine learning")
|
|
58
|
+
.where("year", ">=", 2020)
|
|
59
|
+
.fieldsWithUnnest(["id", "title"], ["researchers"])
|
|
60
|
+
.build();
|
|
61
|
+
|
|
62
|
+
expect(query).toContain("where year >= 2020");
|
|
63
|
+
expect(query).toContain("unnest(researchers)");
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("should combine with limit", () => {
|
|
67
|
+
const query = new QueryBuilder()
|
|
68
|
+
.search("publications")
|
|
69
|
+
.for("test")
|
|
70
|
+
.fieldsWithUnnest(["id"], ["researchers"])
|
|
71
|
+
.limit(100)
|
|
72
|
+
.build();
|
|
73
|
+
|
|
74
|
+
expect(query).toContain("limit 100");
|
|
75
|
+
expect(query).toContain("unnest(researchers)");
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("should throw for empty field name in unnest", () => {
|
|
79
|
+
expect(() => {
|
|
80
|
+
new QueryBuilder()
|
|
81
|
+
.search("publications")
|
|
82
|
+
.for("test")
|
|
83
|
+
.fieldsWithUnnest(["id"], [""])
|
|
84
|
+
.build();
|
|
85
|
+
}).toThrow(ValidationError);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("should throw for whitespace-only field name in unnest", () => {
|
|
89
|
+
expect(() => {
|
|
90
|
+
new QueryBuilder()
|
|
91
|
+
.search("publications")
|
|
92
|
+
.for("test")
|
|
93
|
+
.fieldsWithUnnest(["id"], [" "])
|
|
94
|
+
.build();
|
|
95
|
+
}).toThrow(ValidationError);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
describe("addUnnest", () => {
|
|
100
|
+
it("should add unnest to existing fields", () => {
|
|
101
|
+
const query = new QueryBuilder()
|
|
102
|
+
.search("publications")
|
|
103
|
+
.for("test")
|
|
104
|
+
.fields(["id", "title"])
|
|
105
|
+
.addUnnest("researchers")
|
|
106
|
+
.build();
|
|
107
|
+
|
|
108
|
+
expect(query).toContain("return publications[id+title+unnest(researchers)]");
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("should allow chaining multiple addUnnest calls", () => {
|
|
112
|
+
const query = new QueryBuilder()
|
|
113
|
+
.search("publications")
|
|
114
|
+
.for("test")
|
|
115
|
+
.fields(["id"])
|
|
116
|
+
.addUnnest("researchers")
|
|
117
|
+
.addUnnest("category_for")
|
|
118
|
+
.build();
|
|
119
|
+
|
|
120
|
+
expect(query).toContain("unnest(researchers)");
|
|
121
|
+
expect(query).toContain("unnest(category_for)");
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it("should throw for empty field name", () => {
|
|
125
|
+
expect(() => {
|
|
126
|
+
new QueryBuilder().search("publications").for("test").fields(["id"]).addUnnest("").build();
|
|
127
|
+
}).toThrow(ValidationError);
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
describe("Unnest response parsing", () => {
|
|
133
|
+
// Note: Full response parsing tests would require integration tests
|
|
134
|
+
// or mocking the client execution
|
|
135
|
+
|
|
136
|
+
it("should expect flattened row structure in response", () => {
|
|
137
|
+
// When unnesting, Dimensions API returns flattened rows
|
|
138
|
+
// For example, unnesting researchers creates one row per researcher
|
|
139
|
+
const exampleResponse = {
|
|
140
|
+
publications: [
|
|
141
|
+
{ id: "pub.123", title: "Paper 1", researchers: { id: "r.1", name: "Alice" } },
|
|
142
|
+
{ id: "pub.123", title: "Paper 1", researchers: { id: "r.2", name: "Bob" } },
|
|
143
|
+
{ id: "pub.456", title: "Paper 2", researchers: { id: "r.1", name: "Alice" } },
|
|
144
|
+
],
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// Same publication can appear multiple times (once per researcher)
|
|
148
|
+
expect(exampleResponse.publications).toHaveLength(3);
|
|
149
|
+
expect(exampleResponse.publications.filter((p) => p.id === "pub.123")).toHaveLength(2);
|
|
150
|
+
});
|
|
151
|
+
});
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for Dimensions reasonable-use policy guardrails.
|
|
3
|
+
* @module test/dsl/usage-policy
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { describe, expect, it } from "vitest";
|
|
7
|
+
import { ValidationError } from "../../src/client/index.js";
|
|
8
|
+
import {
|
|
9
|
+
buildExecuteDslPolicyHints,
|
|
10
|
+
buildUsagePolicy,
|
|
11
|
+
isFacetOnlyQuery,
|
|
12
|
+
parseDslPagination,
|
|
13
|
+
validateExecuteDslPolicy,
|
|
14
|
+
validateSearchPaginationPolicy,
|
|
15
|
+
} from "../../src/dsl/usage-policy.js";
|
|
16
|
+
|
|
17
|
+
describe("usage policy", () => {
|
|
18
|
+
describe("buildUsagePolicy", () => {
|
|
19
|
+
it("includes limits and guardrail thresholds", () => {
|
|
20
|
+
const policy = buildUsagePolicy();
|
|
21
|
+
expect(policy.limits.maxPages).toBe(50);
|
|
22
|
+
expect(policy.guardrails.largeResultWarningThreshold).toBe(10_000);
|
|
23
|
+
expect(policy.recommendations.length).toBeGreaterThan(2);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
describe("parseDslPagination", () => {
|
|
28
|
+
it("extracts limit and skip from DSL", () => {
|
|
29
|
+
expect(
|
|
30
|
+
parseDslPagination(
|
|
31
|
+
'search publications for "x" return publications sort by year desc limit 100 skip 5000',
|
|
32
|
+
),
|
|
33
|
+
).toEqual({ limit: 100, skip: 5000 });
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe("validateSearchPaginationPolicy", () => {
|
|
38
|
+
it("allows shallow pagination without confirmation", () => {
|
|
39
|
+
expect(() => validateSearchPaginationPolicy({ skip: 0, limit: 100 })).not.toThrow();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("requires confirmLargeFetch for deep skip", () => {
|
|
43
|
+
expect(() => validateSearchPaginationPolicy({ skip: 5000, limit: 100 })).toThrow(
|
|
44
|
+
ValidationError,
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("allows deep skip with confirmation", () => {
|
|
49
|
+
expect(() =>
|
|
50
|
+
validateSearchPaginationPolicy({
|
|
51
|
+
skip: 5000,
|
|
52
|
+
limit: 100,
|
|
53
|
+
confirmLargeFetch: true,
|
|
54
|
+
}),
|
|
55
|
+
).not.toThrow();
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe("validateExecuteDslPolicy", () => {
|
|
60
|
+
it("rejects skip on facet-only queries", () => {
|
|
61
|
+
expect(() =>
|
|
62
|
+
validateExecuteDslPolicy({
|
|
63
|
+
dsl: 'search publications for "ml" return year limit 20 skip 100',
|
|
64
|
+
}),
|
|
65
|
+
).toThrow(/Facet queries cannot be paginated/);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("requires confirmLargeFetch for deep DSL pagination", () => {
|
|
69
|
+
expect(() =>
|
|
70
|
+
validateExecuteDslPolicy({
|
|
71
|
+
dsl: 'search publications for "ml" return publications limit 100 skip 5000',
|
|
72
|
+
}),
|
|
73
|
+
).toThrow(/confirmLargeFetch/);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
describe("isFacetOnlyQuery", () => {
|
|
78
|
+
it("detects facet year returns", () => {
|
|
79
|
+
expect(isFacetOnlyQuery("search publications return year limit 20")).toBe(true);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("detects entity row returns", () => {
|
|
83
|
+
expect(isFacetOnlyQuery('search publications for "x" return publications limit 20')).toBe(
|
|
84
|
+
false,
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
describe("buildExecuteDslPolicyHints", () => {
|
|
90
|
+
it("adds largeResultWarning and paginationHint for big totals", () => {
|
|
91
|
+
const hints = buildExecuteDslPolicyHints(
|
|
92
|
+
'search publications for "ml" return publications limit 10',
|
|
93
|
+
{ publications: [], _stats: { total_count: 25_000 } },
|
|
94
|
+
);
|
|
95
|
+
expect(hints.largeResultWarning).toContain("25,000");
|
|
96
|
+
expect(hints.paginationHint).toContain("25");
|
|
97
|
+
expect(hints.policyNotice).toBeDefined();
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
});
|