@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,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command for classifying text using Dimensions classification systems.
|
|
3
|
+
* @module commands/functions/ClassifyCommand
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import { Command, ValidationError } from "../../../client/index.js";
|
|
8
|
+
import {
|
|
9
|
+
CLASSIFICATION_SYSTEMS,
|
|
10
|
+
type ClassificationSystem,
|
|
11
|
+
type ClassifyInput,
|
|
12
|
+
type ClassifyResponse,
|
|
13
|
+
} from "../../types/special-functions.js";
|
|
14
|
+
import { escapeDslString } from "../../utils/escape.js";
|
|
15
|
+
import { validateInput } from "../validate-input.js";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Zod schema for ClassifyCommand input validation.
|
|
19
|
+
*/
|
|
20
|
+
export const ClassifyInputSchema = z
|
|
21
|
+
.object({
|
|
22
|
+
/** Document title (at least title or abstract must be provided) */
|
|
23
|
+
title: z.string().optional().describe("Document title for classification"),
|
|
24
|
+
/** Document abstract (at least title or abstract must be provided) */
|
|
25
|
+
abstract: z.string().optional().describe("Document abstract for classification"),
|
|
26
|
+
/** Classification system to use */
|
|
27
|
+
system: z.enum(CLASSIFICATION_SYSTEMS).describe("Classification system to use"),
|
|
28
|
+
})
|
|
29
|
+
.refine((data) => data.title || data.abstract, {
|
|
30
|
+
message: "At least one of title or abstract must be provided",
|
|
31
|
+
path: ["title", "abstract"],
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Input type for ClassifyCommand (raw input).
|
|
36
|
+
*/
|
|
37
|
+
export type ClassifyCommandInput = z.input<typeof ClassifyInputSchema>;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Parsed input type for ClassifyCommand (after validation).
|
|
41
|
+
*/
|
|
42
|
+
export type ClassifyCommandParsedInput = z.output<typeof ClassifyInputSchema>;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Zod schema for validating API response structure.
|
|
46
|
+
*/
|
|
47
|
+
const ClassifyApiResponseSchema = z.record(
|
|
48
|
+
z.string(),
|
|
49
|
+
z.array(
|
|
50
|
+
z.object({
|
|
51
|
+
id: z.string(),
|
|
52
|
+
name: z.string(),
|
|
53
|
+
}),
|
|
54
|
+
),
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Command for classifying text using Dimensions classification systems.
|
|
59
|
+
* Supports FOR, SDG, RCDC, and other research classification taxonomies.
|
|
60
|
+
*
|
|
61
|
+
* @template S - The classification system type
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* const cmd = new ClassifyCommand({
|
|
66
|
+
* title: "Burnout and intentions to quit the nursing profession",
|
|
67
|
+
* abstract: "BACKGROUND: Burnout is an occupational disease...",
|
|
68
|
+
* system: "FOR"
|
|
69
|
+
* });
|
|
70
|
+
*
|
|
71
|
+
* const result = await client.send(cmd);
|
|
72
|
+
* console.log(result.FOR); // Array of classification entries
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export class ClassifyCommand<S extends ClassificationSystem = ClassificationSystem> extends Command<
|
|
76
|
+
ClassifyCommandParsedInput,
|
|
77
|
+
ClassifyResponse<S>
|
|
78
|
+
> {
|
|
79
|
+
static readonly inputSchema = ClassifyInputSchema;
|
|
80
|
+
|
|
81
|
+
readonly input: ClassifyCommandParsedInput;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Creates a new ClassifyCommand.
|
|
85
|
+
* @param input - Command input parameters
|
|
86
|
+
* @throws {ValidationError} If input validation fails
|
|
87
|
+
*/
|
|
88
|
+
constructor(input: ClassifyInput & { system: S }) {
|
|
89
|
+
super();
|
|
90
|
+
this.input = validateInput(ClassifyInputSchema, input);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Resolves the DSL query for this command.
|
|
95
|
+
* @returns The constructed DSL query string
|
|
96
|
+
*/
|
|
97
|
+
resolveQuery(): string {
|
|
98
|
+
const parts: string[] = [];
|
|
99
|
+
|
|
100
|
+
if (this.input.title) {
|
|
101
|
+
parts.push(`title="${escapeDslString(this.input.title)}"`);
|
|
102
|
+
}
|
|
103
|
+
if (this.input.abstract) {
|
|
104
|
+
parts.push(`abstract="${escapeDslString(this.input.abstract)}"`);
|
|
105
|
+
}
|
|
106
|
+
parts.push(`system="${this.input.system}"`);
|
|
107
|
+
|
|
108
|
+
return `classify(${parts.join(", ")})`;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Transforms raw API response to typed output.
|
|
113
|
+
* @param response - Raw API response
|
|
114
|
+
* @returns Typed classification results
|
|
115
|
+
* @throws {ValidationError} If response structure is invalid
|
|
116
|
+
*/
|
|
117
|
+
transformResponse(response: unknown): ClassifyResponse<S> {
|
|
118
|
+
const parseResult = ClassifyApiResponseSchema.safeParse(response);
|
|
119
|
+
|
|
120
|
+
if (!parseResult.success) {
|
|
121
|
+
throw new ValidationError("Invalid API response structure", {
|
|
122
|
+
zodErrors: parseResult.error.issues,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Return the response with the correct system key
|
|
127
|
+
return parseResult.data as unknown as ClassifyResponse<S>;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command for extracting/resolving affiliations using the Dimensions API.
|
|
3
|
+
* @module commands/functions/ExtractAffiliationsCommand
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import { Command, ValidationError } from "../../../client/index.js";
|
|
8
|
+
import type {
|
|
9
|
+
AffiliationInput,
|
|
10
|
+
ExtractAffiliationsInput,
|
|
11
|
+
ExtractAffiliationsResponse,
|
|
12
|
+
} from "../../types/special-functions.js";
|
|
13
|
+
import { escapeDslString } from "../../utils/escape.js";
|
|
14
|
+
import { validateInput } from "../validate-input.js";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Schema for a single affiliation input.
|
|
18
|
+
* Must have either affiliation (freetext) or at least name (structured).
|
|
19
|
+
*/
|
|
20
|
+
const AffiliationInputSchema = z
|
|
21
|
+
.object({
|
|
22
|
+
affiliation: z.string().optional().describe("Freetext affiliation string"),
|
|
23
|
+
name: z.string().optional().describe("Organization name"),
|
|
24
|
+
city: z.string().optional().describe("City"),
|
|
25
|
+
state: z.string().optional().describe("State/province"),
|
|
26
|
+
country: z.string().optional().describe("Country"),
|
|
27
|
+
})
|
|
28
|
+
.refine((data) => data.affiliation || data.name, {
|
|
29
|
+
message: "At least one of affiliation (freetext) or name (structured) must be provided",
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Zod schema for ExtractAffiliationsCommand input validation.
|
|
34
|
+
*/
|
|
35
|
+
export const ExtractAffiliationsInputSchema = z.object({
|
|
36
|
+
affiliations: z
|
|
37
|
+
.array(AffiliationInputSchema)
|
|
38
|
+
.min(1, "At least one affiliation must be provided")
|
|
39
|
+
.describe("Array of affiliations to resolve"),
|
|
40
|
+
results: z
|
|
41
|
+
.enum(["basic", "full", "publisher"])
|
|
42
|
+
.optional()
|
|
43
|
+
.describe('Results detail level: "basic" (default), "full", or "publisher"'),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Input type for ExtractAffiliationsCommand (raw input).
|
|
48
|
+
*/
|
|
49
|
+
export type ExtractAffiliationsCommandInput = z.input<typeof ExtractAffiliationsInputSchema>;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Parsed input type for ExtractAffiliationsCommand (after validation).
|
|
53
|
+
*/
|
|
54
|
+
export type ExtractAffiliationsCommandParsedInput = z.output<typeof ExtractAffiliationsInputSchema>;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Schema for a single affiliation result.
|
|
58
|
+
*/
|
|
59
|
+
const AffiliationResultSchema = z.object({
|
|
60
|
+
id: z.string(),
|
|
61
|
+
name: z.string(),
|
|
62
|
+
country: z.string().optional(),
|
|
63
|
+
score: z.number().optional(),
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Zod schema for validating API response structure.
|
|
68
|
+
*/
|
|
69
|
+
const ExtractAffiliationsResponseSchema = z.object({
|
|
70
|
+
extracted_affiliations: z.array(AffiliationResultSchema),
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Converts an affiliation input to its JSON representation for DSL.
|
|
75
|
+
* @param aff - The affiliation input
|
|
76
|
+
* @returns JSON object string
|
|
77
|
+
*/
|
|
78
|
+
function affiliationToJsonObject(aff: AffiliationInput): string {
|
|
79
|
+
const parts: string[] = [];
|
|
80
|
+
|
|
81
|
+
if (aff.affiliation) {
|
|
82
|
+
parts.push(`"affiliation": "${escapeDslString(aff.affiliation)}"`);
|
|
83
|
+
}
|
|
84
|
+
if (aff.name) {
|
|
85
|
+
parts.push(`"name": "${escapeDslString(aff.name)}"`);
|
|
86
|
+
}
|
|
87
|
+
if (aff.city) {
|
|
88
|
+
parts.push(`"city": "${escapeDslString(aff.city)}"`);
|
|
89
|
+
}
|
|
90
|
+
if (aff.state) {
|
|
91
|
+
parts.push(`"state": "${escapeDslString(aff.state)}"`);
|
|
92
|
+
}
|
|
93
|
+
if (aff.country) {
|
|
94
|
+
parts.push(`"country": "${escapeDslString(aff.country)}"`);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return `{${parts.join(", ")}}`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Command for extracting/resolving affiliations using the Dimensions API.
|
|
102
|
+
* Takes freetext or structured affiliation data and returns matched organizations.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* const cmd = new ExtractAffiliationsCommand({
|
|
107
|
+
* affiliations: [
|
|
108
|
+
* { affiliation: "University of Oxford, UK" },
|
|
109
|
+
* { name: "Stanford", city: "Stanford", country: "USA" }
|
|
110
|
+
* ]
|
|
111
|
+
* });
|
|
112
|
+
*
|
|
113
|
+
* const result = await client.send(cmd);
|
|
114
|
+
* console.log(result.extracted_affiliations);
|
|
115
|
+
* // [{ id: "grid.xxx", name: "University of Oxford", ... }, ...]
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export class ExtractAffiliationsCommand extends Command<
|
|
119
|
+
ExtractAffiliationsCommandParsedInput,
|
|
120
|
+
ExtractAffiliationsResponse
|
|
121
|
+
> {
|
|
122
|
+
static readonly inputSchema = ExtractAffiliationsInputSchema;
|
|
123
|
+
|
|
124
|
+
readonly input: ExtractAffiliationsCommandParsedInput;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Creates a new ExtractAffiliationsCommand.
|
|
128
|
+
* @param input - Command input parameters
|
|
129
|
+
* @throws {ValidationError} If input validation fails
|
|
130
|
+
*/
|
|
131
|
+
constructor(input: ExtractAffiliationsInput) {
|
|
132
|
+
super();
|
|
133
|
+
this.input = validateInput(ExtractAffiliationsInputSchema, input);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Resolves the DSL query for this command.
|
|
138
|
+
* @returns The constructed DSL query string
|
|
139
|
+
*/
|
|
140
|
+
resolveQuery(): string {
|
|
141
|
+
const jsonObjects = this.input.affiliations.map(affiliationToJsonObject);
|
|
142
|
+
const resultsSuffix = this.input.results ? `, results="${this.input.results}"` : "";
|
|
143
|
+
return `extract_affiliations(json=[${jsonObjects.join(", ")}]${resultsSuffix})`;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Transforms raw API response to typed output.
|
|
148
|
+
* @param response - Raw API response
|
|
149
|
+
* @returns Typed extraction results
|
|
150
|
+
* @throws {ValidationError} If response structure is invalid
|
|
151
|
+
*/
|
|
152
|
+
transformResponse(response: unknown): ExtractAffiliationsResponse {
|
|
153
|
+
const parseResult = ExtractAffiliationsResponseSchema.safeParse(response);
|
|
154
|
+
|
|
155
|
+
if (!parseResult.success) {
|
|
156
|
+
throw new ValidationError("Invalid API response structure", {
|
|
157
|
+
zodErrors: parseResult.error.issues,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return parseResult.data;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command for extracting concepts from text using the Dimensions API.
|
|
3
|
+
* @module commands/functions/ExtractConceptsCommand
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import { Command, ValidationError } from "../../../client/index.js";
|
|
8
|
+
import type {
|
|
9
|
+
ExtractConceptsInput,
|
|
10
|
+
ExtractConceptsResponse,
|
|
11
|
+
} from "../../types/special-functions.js";
|
|
12
|
+
import { escapeDslString } from "../../utils/escape.js";
|
|
13
|
+
import { validateInput } from "../validate-input.js";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Zod schema for ExtractConceptsCommand input validation.
|
|
17
|
+
*/
|
|
18
|
+
export const ExtractConceptsInputSchema = z.object({
|
|
19
|
+
/** Text to extract concepts from */
|
|
20
|
+
text: z.string().min(1, "Text must not be empty").describe("Text to extract concepts from"),
|
|
21
|
+
/** Whether to include relevance scores in the response */
|
|
22
|
+
returnScores: z
|
|
23
|
+
.boolean()
|
|
24
|
+
.optional()
|
|
25
|
+
.default(false)
|
|
26
|
+
.describe("Include relevance scores for concepts"),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Input type for ExtractConceptsCommand (raw input).
|
|
31
|
+
*/
|
|
32
|
+
export type ExtractConceptsCommandInput = z.input<typeof ExtractConceptsInputSchema>;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Parsed input type for ExtractConceptsCommand (after validation with defaults).
|
|
36
|
+
*/
|
|
37
|
+
export type ExtractConceptsCommandParsedInput = z.output<typeof ExtractConceptsInputSchema>;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Zod schema for validating API response with concept strings.
|
|
41
|
+
*/
|
|
42
|
+
const ConceptsSimpleResponseSchema = z.object({
|
|
43
|
+
extracted_concepts: z.array(z.string()),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Zod schema for validating API response with concept objects.
|
|
48
|
+
*/
|
|
49
|
+
const ConceptsWithScoresResponseSchema = z.object({
|
|
50
|
+
extracted_concepts: z.array(
|
|
51
|
+
z.object({
|
|
52
|
+
concept: z.string(),
|
|
53
|
+
relevance: z.number(),
|
|
54
|
+
}),
|
|
55
|
+
),
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Command for extracting concepts from text using the Dimensions API.
|
|
60
|
+
*
|
|
61
|
+
* @template WithScores - Whether relevance scores are included
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* // Simple extraction
|
|
66
|
+
* const cmd = new ExtractConceptsCommand({
|
|
67
|
+
* text: "Machine learning algorithms for drug discovery"
|
|
68
|
+
* });
|
|
69
|
+
* const result = await client.send(cmd);
|
|
70
|
+
* console.log(result.extracted_concepts); // string[]
|
|
71
|
+
*
|
|
72
|
+
* // With scores
|
|
73
|
+
* const cmdScores = new ExtractConceptsCommand({
|
|
74
|
+
* text: "Machine learning algorithms for drug discovery",
|
|
75
|
+
* returnScores: true
|
|
76
|
+
* });
|
|
77
|
+
* const resultScores = await client.send(cmdScores);
|
|
78
|
+
* console.log(resultScores.extracted_concepts); // { concept, relevance }[]
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export class ExtractConceptsCommand<WithScores extends boolean = false> extends Command<
|
|
82
|
+
ExtractConceptsCommandParsedInput,
|
|
83
|
+
ExtractConceptsResponse<WithScores>
|
|
84
|
+
> {
|
|
85
|
+
static readonly inputSchema = ExtractConceptsInputSchema;
|
|
86
|
+
|
|
87
|
+
readonly input: ExtractConceptsCommandParsedInput;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Creates a new ExtractConceptsCommand.
|
|
91
|
+
* @param input - Command input parameters
|
|
92
|
+
* @throws {ValidationError} If input validation fails
|
|
93
|
+
*/
|
|
94
|
+
constructor(input: ExtractConceptsInput & { returnScores?: WithScores }) {
|
|
95
|
+
super();
|
|
96
|
+
this.input = validateInput(ExtractConceptsInputSchema, input);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Resolves the DSL query for this command.
|
|
101
|
+
* @returns The constructed DSL query string
|
|
102
|
+
*/
|
|
103
|
+
resolveQuery(): string {
|
|
104
|
+
const escapedText = escapeDslString(this.input.text);
|
|
105
|
+
|
|
106
|
+
if (this.input.returnScores) {
|
|
107
|
+
return `extract_concepts("${escapedText}", return_scores=true)`;
|
|
108
|
+
}
|
|
109
|
+
return `extract_concepts("${escapedText}")`;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Transforms raw API response to typed output.
|
|
114
|
+
* @param response - Raw API response
|
|
115
|
+
* @returns Typed extraction results
|
|
116
|
+
* @throws {ValidationError} If response structure is invalid
|
|
117
|
+
*/
|
|
118
|
+
transformResponse(response: unknown): ExtractConceptsResponse<WithScores> {
|
|
119
|
+
if (this.input.returnScores) {
|
|
120
|
+
const parseResult = ConceptsWithScoresResponseSchema.safeParse(response);
|
|
121
|
+
|
|
122
|
+
if (!parseResult.success) {
|
|
123
|
+
throw new ValidationError("Invalid API response structure", {
|
|
124
|
+
zodErrors: parseResult.error.issues,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return parseResult.data as unknown as ExtractConceptsResponse<WithScores>;
|
|
129
|
+
} else {
|
|
130
|
+
const parseResult = ConceptsSimpleResponseSchema.safeParse(response);
|
|
131
|
+
|
|
132
|
+
if (!parseResult.success) {
|
|
133
|
+
throw new ValidationError("Invalid API response structure", {
|
|
134
|
+
zodErrors: parseResult.error.issues,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return parseResult.data as unknown as ExtractConceptsResponse<WithScores>;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command for extracting/resolving grants using the Dimensions API.
|
|
3
|
+
* @module commands/functions/ExtractGrantsCommand
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import { Command, ValidationError } from "../../../client/index.js";
|
|
8
|
+
import type { ExtractGrantsInput, ExtractGrantsResponse } from "../../types/special-functions.js";
|
|
9
|
+
import { escapeDslString } from "../../utils/escape.js";
|
|
10
|
+
import { validateInput } from "../validate-input.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Zod schema for ExtractGrantsCommand input validation.
|
|
14
|
+
*/
|
|
15
|
+
export const ExtractGrantsInputSchema = z.object({
|
|
16
|
+
grantNumber: z
|
|
17
|
+
.string()
|
|
18
|
+
.min(1, "Grant number must not be empty")
|
|
19
|
+
.describe("Grant number to look up"),
|
|
20
|
+
fundref: z.string().optional().describe("FundRef ID of the funder"),
|
|
21
|
+
funderName: z.string().optional().describe("Funder name (alternative to fundref)"),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Input type for ExtractGrantsCommand (raw input).
|
|
26
|
+
*/
|
|
27
|
+
export type ExtractGrantsCommandInput = z.input<typeof ExtractGrantsInputSchema>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Parsed input type for ExtractGrantsCommand (after validation).
|
|
31
|
+
*/
|
|
32
|
+
export type ExtractGrantsCommandParsedInput = z.output<typeof ExtractGrantsInputSchema>;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Zod schema for validating API response structure.
|
|
36
|
+
* The Dimensions API returns a single resolved grant ID, or null if not found.
|
|
37
|
+
*/
|
|
38
|
+
const ExtractGrantsResponseSchema = z.object({
|
|
39
|
+
grant_id: z.string().nullable(),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Command for extracting/resolving grants using the Dimensions API.
|
|
44
|
+
* Takes a grant number and optional funder information to find matching grants.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const cmd = new ExtractGrantsCommand({
|
|
49
|
+
* grantNumber: "R01HL117329",
|
|
50
|
+
* fundref: "100000050"
|
|
51
|
+
* });
|
|
52
|
+
*
|
|
53
|
+
* const result = await client.send(cmd);
|
|
54
|
+
* console.log(result.extracted_grants);
|
|
55
|
+
* // [{ id: "grant.xxx", title: "...", funder: "NIH", ... }]
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export class ExtractGrantsCommand extends Command<
|
|
59
|
+
ExtractGrantsCommandParsedInput,
|
|
60
|
+
ExtractGrantsResponse
|
|
61
|
+
> {
|
|
62
|
+
static readonly inputSchema = ExtractGrantsInputSchema;
|
|
63
|
+
|
|
64
|
+
readonly input: ExtractGrantsCommandParsedInput;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Creates a new ExtractGrantsCommand.
|
|
68
|
+
* @param input - Command input parameters
|
|
69
|
+
* @throws {ValidationError} If input validation fails
|
|
70
|
+
*/
|
|
71
|
+
constructor(input: ExtractGrantsInput) {
|
|
72
|
+
super();
|
|
73
|
+
this.input = validateInput(ExtractGrantsInputSchema, input);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Resolves the DSL query for this command.
|
|
78
|
+
* @returns The constructed DSL query string
|
|
79
|
+
*/
|
|
80
|
+
resolveQuery(): string {
|
|
81
|
+
const parts: string[] = [];
|
|
82
|
+
|
|
83
|
+
parts.push(`grant_number="${escapeDslString(this.input.grantNumber)}"`);
|
|
84
|
+
|
|
85
|
+
// Prefer fundref over funderName if both are provided
|
|
86
|
+
if (this.input.fundref) {
|
|
87
|
+
parts.push(`fundref="${escapeDslString(this.input.fundref)}"`);
|
|
88
|
+
} else if (this.input.funderName) {
|
|
89
|
+
parts.push(`funder_name="${escapeDslString(this.input.funderName)}"`);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return `extract_grants(${parts.join(", ")})`;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Transforms raw API response to typed output.
|
|
97
|
+
* @param response - Raw API response
|
|
98
|
+
* @returns Typed extraction results
|
|
99
|
+
* @throws {ValidationError} If response structure is invalid
|
|
100
|
+
*/
|
|
101
|
+
transformResponse(response: unknown): ExtractGrantsResponse {
|
|
102
|
+
const parseResult = ExtractGrantsResponseSchema.safeParse(response);
|
|
103
|
+
|
|
104
|
+
if (!parseResult.success) {
|
|
105
|
+
throw new ValidationError("Invalid API response structure", {
|
|
106
|
+
zodErrors: parseResult.error.issues,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return parseResult.data;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DSL special function commands for the Dimensions API.
|
|
3
|
+
* Provides classify, extract_concepts, extract_affiliations, and extract_grants operations.
|
|
4
|
+
* @module commands/functions
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
ClassifyCommand,
|
|
9
|
+
type ClassifyCommandInput,
|
|
10
|
+
type ClassifyCommandParsedInput,
|
|
11
|
+
ClassifyInputSchema,
|
|
12
|
+
} from "./ClassifyCommand.js";
|
|
13
|
+
export {
|
|
14
|
+
ExtractAffiliationsCommand,
|
|
15
|
+
type ExtractAffiliationsCommandInput,
|
|
16
|
+
type ExtractAffiliationsCommandParsedInput,
|
|
17
|
+
ExtractAffiliationsInputSchema,
|
|
18
|
+
} from "./ExtractAffiliationsCommand.js";
|
|
19
|
+
export {
|
|
20
|
+
ExtractConceptsCommand,
|
|
21
|
+
type ExtractConceptsCommandInput,
|
|
22
|
+
type ExtractConceptsCommandParsedInput,
|
|
23
|
+
ExtractConceptsInputSchema,
|
|
24
|
+
} from "./ExtractConceptsCommand.js";
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
ExtractGrantsCommand,
|
|
28
|
+
type ExtractGrantsCommandInput,
|
|
29
|
+
type ExtractGrantsCommandParsedInput,
|
|
30
|
+
ExtractGrantsInputSchema,
|
|
31
|
+
} from "./ExtractGrantsCommand.js";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commands for the Dimensions API client.
|
|
3
|
+
* @module commands
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export type { ExtendedWhereFilterInput, WhereFilterInput } from "./facet/index.js";
|
|
7
|
+
export {
|
|
8
|
+
EntitySchema,
|
|
9
|
+
ExtendedWhereFilterSchema,
|
|
10
|
+
WhereFilterSchema,
|
|
11
|
+
} from "./facet/index.js";
|
|
12
|
+
export {
|
|
13
|
+
ClassifyCommand,
|
|
14
|
+
type ClassifyCommandInput,
|
|
15
|
+
type ClassifyCommandParsedInput,
|
|
16
|
+
ClassifyInputSchema,
|
|
17
|
+
ExtractAffiliationsCommand,
|
|
18
|
+
type ExtractAffiliationsCommandInput,
|
|
19
|
+
type ExtractAffiliationsCommandParsedInput,
|
|
20
|
+
ExtractAffiliationsInputSchema,
|
|
21
|
+
ExtractConceptsCommand,
|
|
22
|
+
type ExtractConceptsCommandInput,
|
|
23
|
+
type ExtractConceptsCommandParsedInput,
|
|
24
|
+
ExtractConceptsInputSchema,
|
|
25
|
+
ExtractGrantsCommand,
|
|
26
|
+
type ExtractGrantsCommandInput,
|
|
27
|
+
type ExtractGrantsCommandParsedInput,
|
|
28
|
+
ExtractGrantsInputSchema,
|
|
29
|
+
} from "./functions/index.js";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared input validation helper for command constructors.
|
|
3
|
+
* Reduces boilerplate across all Command subclasses.
|
|
4
|
+
* @module commands/validate-input
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { z } from "zod";
|
|
8
|
+
import { ValidationError } from "../../client/index.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Validates input against a Zod schema, returning the parsed result.
|
|
12
|
+
* Throws a {@link ValidationError} with the first Zod issue message on failure.
|
|
13
|
+
*
|
|
14
|
+
* @template T - The Zod schema type
|
|
15
|
+
* @param schema - Zod schema to validate against
|
|
16
|
+
* @param input - Raw input to validate
|
|
17
|
+
* @returns The parsed and validated input
|
|
18
|
+
* @throws {ValidationError} If validation fails
|
|
19
|
+
*/
|
|
20
|
+
export function validateInput<T extends z.ZodTypeAny>(schema: T, input: unknown): z.output<T> {
|
|
21
|
+
const result = schema.safeParse(input);
|
|
22
|
+
if (!result.success) {
|
|
23
|
+
const firstError = result.error.issues[0];
|
|
24
|
+
throw new ValidationError(firstError?.message ?? "Validation failed", {
|
|
25
|
+
zodErrors: result.error.issues,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return result.data;
|
|
29
|
+
}
|