@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,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Load schema from the Dimensions API or optional disk cache.
|
|
3
|
+
* @module schema/load
|
|
4
|
+
*/
|
|
5
|
+
import type { DimensionsClient } from "../client.js";
|
|
6
|
+
import { type SchemaStore } from "./store.js";
|
|
7
|
+
/**
|
|
8
|
+
* Returns the module-level cached schema store, if loaded.
|
|
9
|
+
* @returns Cached store or undefined before first load
|
|
10
|
+
*/
|
|
11
|
+
export declare function getCachedSchemaStore(): SchemaStore | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Clears the module-level schema cache (for tests and refresh).
|
|
14
|
+
*/
|
|
15
|
+
export declare function clearSchemaCache(): void;
|
|
16
|
+
export type LoadSchemaOptions = {
|
|
17
|
+
/** Optional cache file path (defaults to `SCHEMA_CACHE_PATH` env) */
|
|
18
|
+
cachePath?: string;
|
|
19
|
+
/** Cache TTL in milliseconds (defaults to `SCHEMA_CACHE_TTL_MS` env or 24h) */
|
|
20
|
+
cacheTtlMs?: number;
|
|
21
|
+
/** Skip fresh cache and fetch from the API (stale fallback still applies on failure) */
|
|
22
|
+
forceRefresh?: boolean;
|
|
23
|
+
/** Log load stats to stderr (default true) */
|
|
24
|
+
log?: boolean;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Fetches schema from the Dimensions API, with TTL-aware cache and stale fallback.
|
|
28
|
+
* @param client - Authenticated Dimensions client
|
|
29
|
+
* @param options - Cache path, TTL, and logging options
|
|
30
|
+
* @returns Loaded schema store
|
|
31
|
+
*/
|
|
32
|
+
export declare function loadSchema(client: DimensionsClient, options?: LoadSchemaOptions | string): Promise<SchemaStore>;
|
|
33
|
+
/**
|
|
34
|
+
* Returns cached schema or loads once per process.
|
|
35
|
+
* @param client - Authenticated Dimensions client
|
|
36
|
+
* @param options - Cache path and logging options
|
|
37
|
+
* @returns Schema store
|
|
38
|
+
*/
|
|
39
|
+
export declare function getOrLoadSchema(client: DimensionsClient, options?: LoadSchemaOptions | string): Promise<SchemaStore>;
|
|
40
|
+
export { extractDescribeSchema, extractDescribeVersion } from "./extract.js";
|
|
41
|
+
//# sourceMappingURL=load.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../src/dsl/schema/load.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAQrD,OAAO,EAAiC,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAK7E;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,WAAW,GAAG,SAAS,CAE9D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAGvC;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,qEAAqE;IACrE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+EAA+E;IAC/E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wFAAwF;IACxF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,8CAA8C;IAC9C,GAAG,CAAC,EAAE,OAAO,CAAC;CACf,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,gBAAgB,EACxB,OAAO,CAAC,EAAE,iBAAiB,GAAG,MAAM,GACnC,OAAO,CAAC,WAAW,CAAC,CAuEtB;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,gBAAgB,EACxB,OAAO,CAAC,EAAE,iBAAiB,GAAG,MAAM,GACnC,OAAO,CAAC,WAAW,CAAC,CAUtB;AAaD,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Load schema from the Dimensions API or optional disk cache.
|
|
3
|
+
* @module schema/load
|
|
4
|
+
*/
|
|
5
|
+
import { isCacheFresh, readSchemaCacheFile, resolveCacheTtlMs, writeSchemaCacheFile, } from "./cache.js";
|
|
6
|
+
import { extractDescribeSchema, extractDescribeVersion } from "./extract.js";
|
|
7
|
+
import { createSchemaStoreFromResponse } from "./store.js";
|
|
8
|
+
let moduleCache;
|
|
9
|
+
let moduleLoadPromise;
|
|
10
|
+
/**
|
|
11
|
+
* Returns the module-level cached schema store, if loaded.
|
|
12
|
+
* @returns Cached store or undefined before first load
|
|
13
|
+
*/
|
|
14
|
+
export function getCachedSchemaStore() {
|
|
15
|
+
return moduleCache;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Clears the module-level schema cache (for tests and refresh).
|
|
19
|
+
*/
|
|
20
|
+
export function clearSchemaCache() {
|
|
21
|
+
moduleCache = undefined;
|
|
22
|
+
moduleLoadPromise = undefined;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Fetches schema from the Dimensions API, with TTL-aware cache and stale fallback.
|
|
26
|
+
* @param client - Authenticated Dimensions client
|
|
27
|
+
* @param options - Cache path, TTL, and logging options
|
|
28
|
+
* @returns Loaded schema store
|
|
29
|
+
*/
|
|
30
|
+
export async function loadSchema(client, options) {
|
|
31
|
+
const resolved = typeof options === "string" ? { cachePath: options, log: true } : (options ?? {});
|
|
32
|
+
const cachePath = resolved.cachePath ?? process.env.SCHEMA_CACHE_PATH;
|
|
33
|
+
const log = resolved.log ?? true;
|
|
34
|
+
const cacheTtlMs = resolveCacheTtlMs(resolved.cacheTtlMs);
|
|
35
|
+
const forceRefresh = resolved.forceRefresh ?? false;
|
|
36
|
+
const cached = cachePath ? await readSchemaCacheFile(cachePath) : undefined;
|
|
37
|
+
const cacheFresh = cached != null && isCacheFresh(cached.cachedAt, cacheTtlMs);
|
|
38
|
+
if (!forceRefresh && cacheFresh && cached) {
|
|
39
|
+
const store = createSchemaStoreFromResponse(cached.response, cached.version, new Date(), {
|
|
40
|
+
loadSource: "cache",
|
|
41
|
+
stale: false,
|
|
42
|
+
cachedAt: cached.cachedAt,
|
|
43
|
+
});
|
|
44
|
+
moduleCache = store;
|
|
45
|
+
if (log) {
|
|
46
|
+
logSchemaLoaded(store, "cache (fresh)");
|
|
47
|
+
}
|
|
48
|
+
return store;
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
const started = performance.now();
|
|
52
|
+
const [schemaRaw, versionRaw] = await Promise.all([
|
|
53
|
+
client.rawQuery("describe schema"),
|
|
54
|
+
client.rawQuery("describe version").catch(() => undefined),
|
|
55
|
+
]);
|
|
56
|
+
const response = extractDescribeSchema(schemaRaw);
|
|
57
|
+
const version = versionRaw ? extractDescribeVersion(versionRaw) : undefined;
|
|
58
|
+
if (cachePath) {
|
|
59
|
+
await writeSchemaCacheFile(cachePath, response, version);
|
|
60
|
+
}
|
|
61
|
+
const store = createSchemaStoreFromResponse(response, version, new Date(), {
|
|
62
|
+
loadSource: "api",
|
|
63
|
+
stale: false,
|
|
64
|
+
});
|
|
65
|
+
moduleCache = store;
|
|
66
|
+
if (log) {
|
|
67
|
+
const elapsed = Math.round(performance.now() - started);
|
|
68
|
+
logSchemaLoaded(store, `api (${elapsed}ms)`);
|
|
69
|
+
}
|
|
70
|
+
return store;
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
if (cached) {
|
|
74
|
+
const store = createSchemaStoreFromResponse(cached.response, cached.version, new Date(), {
|
|
75
|
+
loadSource: "cache",
|
|
76
|
+
stale: true,
|
|
77
|
+
cachedAt: cached.cachedAt,
|
|
78
|
+
});
|
|
79
|
+
moduleCache = store;
|
|
80
|
+
if (log) {
|
|
81
|
+
const age = cached.cachedAt != null
|
|
82
|
+
? `${Math.round((Date.now() - cached.cachedAt.getTime()) / 60_000)}m old`
|
|
83
|
+
: "legacy cache";
|
|
84
|
+
console.error(`[schema] API unavailable; using stale cache (${age}). ` +
|
|
85
|
+
`Call refresh_schema when the API is reachable.`);
|
|
86
|
+
logSchemaLoaded(store, "cache (stale fallback)");
|
|
87
|
+
}
|
|
88
|
+
return store;
|
|
89
|
+
}
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Returns cached schema or loads once per process.
|
|
95
|
+
* @param client - Authenticated Dimensions client
|
|
96
|
+
* @param options - Cache path and logging options
|
|
97
|
+
* @returns Schema store
|
|
98
|
+
*/
|
|
99
|
+
export async function getOrLoadSchema(client, options) {
|
|
100
|
+
if (moduleCache) {
|
|
101
|
+
return moduleCache;
|
|
102
|
+
}
|
|
103
|
+
if (!moduleLoadPromise) {
|
|
104
|
+
moduleLoadPromise = loadSchema(client, options).finally(() => {
|
|
105
|
+
moduleLoadPromise = undefined;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return moduleLoadPromise;
|
|
109
|
+
}
|
|
110
|
+
function logSchemaLoaded(store, via) {
|
|
111
|
+
const stats = store.stats();
|
|
112
|
+
const flags = [via, store.stale ? "stale" : undefined].filter(Boolean).join(", ");
|
|
113
|
+
console.error(`[schema] loaded ${stats.sourceCount} sources, ${stats.entityCount} entities` +
|
|
114
|
+
(stats.dslVersion ? ` (DSL ${stats.dslVersion})` : "") +
|
|
115
|
+
` [${flags}]`);
|
|
116
|
+
}
|
|
117
|
+
// Re-export extract helpers for backward compatibility
|
|
118
|
+
export { extractDescribeSchema, extractDescribeVersion } from "./extract.js";
|
|
119
|
+
//# sourceMappingURL=load.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load.js","sourceRoot":"","sources":["../../../src/dsl/schema/load.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAE,6BAA6B,EAAoB,MAAM,YAAY,CAAC;AAE7E,IAAI,WAAoC,CAAC;AACzC,IAAI,iBAAmD,CAAC;AAExD;;;GAGG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,WAAW,GAAG,SAAS,CAAC;IACxB,iBAAiB,GAAG,SAAS,CAAC;AAChC,CAAC;AAaD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,MAAwB,EACxB,OAAoC;IAEpC,MAAM,QAAQ,GACZ,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,IAAa,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;IAC7F,MAAM,SAAS,GAAG,QAAQ,CAAC,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;IACtE,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,IAAI,IAAI,CAAC;IACjC,MAAM,UAAU,GAAG,iBAAiB,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC1D,MAAM,YAAY,GAAG,QAAQ,CAAC,YAAY,IA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;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAAwB,EACxB,OAAoC;IAEpC,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,WAAW,CAAC;IACrB,CAAC;IACD,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,iBAAiB,GAAG,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE;YAC3D,iBAAiB,GAAG,SAAS,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED,SAAS,eAAe,CAAC,KAAkB,EAAE,GAAW;IACtD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;IAC5B,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClF,OAAO,CAAC,KAAK,CACX,mBAAmB,KAAK,CAAC,WAAW,aAAa,KAAK,CAAC,WAAW,WAAW;QAC3E,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACtD,KAAK,KAAK,GAAG,CAChB,CAAC;AACJ,CAAC;AAED,uDAAuD;AACvD,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory schema store built from `describe schema` responses.
|
|
3
|
+
* @module schema/store
|
|
4
|
+
*/
|
|
5
|
+
import { type StructuredEntityType } from "./structured-entities.js";
|
|
6
|
+
import { type SchemaSummary } from "./summary.js";
|
|
7
|
+
import type { DescribeSchemaResponse, EntityDescribe, SourceDescribe } from "./types.js";
|
|
8
|
+
/** How the schema store was populated. */
|
|
9
|
+
export type SchemaLoadSource = "api" | "cache";
|
|
10
|
+
/** Optional metadata when constructing a {@link SchemaStore}. */
|
|
11
|
+
export type SchemaStoreMetadata = {
|
|
12
|
+
readonly loadSource?: SchemaLoadSource;
|
|
13
|
+
readonly stale?: boolean;
|
|
14
|
+
readonly cachedAt?: Date;
|
|
15
|
+
};
|
|
16
|
+
/** Operational limits mirrored from upstream DSL constants. */
|
|
17
|
+
export declare const SCHEMA_LIMITS: {
|
|
18
|
+
readonly maxLimit: 1000;
|
|
19
|
+
readonly maxOffset: 50000;
|
|
20
|
+
readonly maxPages: 50;
|
|
21
|
+
readonly maxFacetBuckets: 1000;
|
|
22
|
+
readonly requestsPerMinute: 30;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Read-only schema catalog with derived helper views for tools and clients.
|
|
26
|
+
*/
|
|
27
|
+
export declare class SchemaStore {
|
|
28
|
+
#private;
|
|
29
|
+
/**
|
|
30
|
+
* @param response - Parsed `describe schema` payload
|
|
31
|
+
* @param version - Optional DSL version from `describe version`
|
|
32
|
+
* @param loadedAt - Timestamp when schema was loaded
|
|
33
|
+
* @param metadata - Cache/API provenance
|
|
34
|
+
*/
|
|
35
|
+
constructor(response: DescribeSchemaResponse, version?: string, loadedAt?: Date, metadata?: SchemaStoreMetadata);
|
|
36
|
+
/** Whether schema came from the API or disk cache. */
|
|
37
|
+
get loadSource(): SchemaLoadSource;
|
|
38
|
+
/** True when serving from cache after an API failure or expired TTL. */
|
|
39
|
+
get stale(): boolean;
|
|
40
|
+
/** When the on-disk cache was written, if known. */
|
|
41
|
+
get cachedAt(): Date | undefined;
|
|
42
|
+
/** DSL version string, if known. */
|
|
43
|
+
get version(): string | undefined;
|
|
44
|
+
/** When this store was populated. */
|
|
45
|
+
get loadedAt(): Date;
|
|
46
|
+
/** Full describe payload. */
|
|
47
|
+
get raw(): DescribeSchemaResponse;
|
|
48
|
+
/** All source names. */
|
|
49
|
+
sourceNames(): readonly string[];
|
|
50
|
+
/** All auxiliary entity names. */
|
|
51
|
+
entityNames(): readonly string[];
|
|
52
|
+
/**
|
|
53
|
+
* Returns a source schema by name.
|
|
54
|
+
* @param name - Source name (e.g. `publications`)
|
|
55
|
+
* @returns Source schema or undefined
|
|
56
|
+
*/
|
|
57
|
+
getSource(name: string): SourceDescribe | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Returns an auxiliary entity schema by name.
|
|
60
|
+
* @param name - Entity name (e.g. `journals`)
|
|
61
|
+
* @returns Entity schema or undefined
|
|
62
|
+
*/
|
|
63
|
+
getEntity(name: string): EntityDescribe | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Filterable field names for a source.
|
|
66
|
+
* @param source - Source name
|
|
67
|
+
* @returns Field names where `is_filter` is true
|
|
68
|
+
*/
|
|
69
|
+
filterableFields(source: string): readonly string[];
|
|
70
|
+
/**
|
|
71
|
+
* Facet field names for a source.
|
|
72
|
+
* @param source - Source name
|
|
73
|
+
* @returns Field names marked as facets or entity fields
|
|
74
|
+
*/
|
|
75
|
+
facetFields(source: string): readonly string[];
|
|
76
|
+
/**
|
|
77
|
+
* Search index names for a source.
|
|
78
|
+
* @param source - Source name
|
|
79
|
+
* @returns Search field/index names
|
|
80
|
+
*/
|
|
81
|
+
searchIndexes(source: string): readonly string[];
|
|
82
|
+
/**
|
|
83
|
+
* Aggregation indicator names for a source.
|
|
84
|
+
* @param source - Source name
|
|
85
|
+
* @returns Metric names
|
|
86
|
+
*/
|
|
87
|
+
metrics(source: string): readonly string[];
|
|
88
|
+
/**
|
|
89
|
+
* Named fieldsets for a source.
|
|
90
|
+
* @param source - Source name
|
|
91
|
+
* @returns Fieldset name to field list map
|
|
92
|
+
*/
|
|
93
|
+
fieldsets(source: string): Readonly<Record<string, readonly string[]>>;
|
|
94
|
+
/**
|
|
95
|
+
* Core entity types supported by structured search tools.
|
|
96
|
+
* @returns Structured sources that exist in the loaded describe schema
|
|
97
|
+
*/
|
|
98
|
+
structuredEntityTypes(): readonly StructuredEntityType[];
|
|
99
|
+
/**
|
|
100
|
+
* Health/stats payload for `/health`.
|
|
101
|
+
* @returns Summary object
|
|
102
|
+
*/
|
|
103
|
+
stats(): {
|
|
104
|
+
dslVersion: string | undefined;
|
|
105
|
+
sourceCount: number;
|
|
106
|
+
entityCount: number;
|
|
107
|
+
schemaLoadedAt: string;
|
|
108
|
+
loadSource: SchemaLoadSource;
|
|
109
|
+
stale: boolean;
|
|
110
|
+
cachedAt: string | undefined;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Compact overview for cold-start discovery (fields, facets, resource URIs).
|
|
114
|
+
* @returns Summary payload
|
|
115
|
+
*/
|
|
116
|
+
summary(): SchemaSummary;
|
|
117
|
+
/**
|
|
118
|
+
* Comma-separated facet fields for tool descriptions.
|
|
119
|
+
* @param source - Source name
|
|
120
|
+
* @returns Hint string
|
|
121
|
+
*/
|
|
122
|
+
facetFieldsHint(source: string): string;
|
|
123
|
+
/**
|
|
124
|
+
* Comma-separated metrics for tool descriptions.
|
|
125
|
+
* @param source - Source name
|
|
126
|
+
* @returns Hint string
|
|
127
|
+
*/
|
|
128
|
+
metricsHint(source: string): string;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Builds a {@link SchemaStore} from a describe response.
|
|
132
|
+
* @param response - `describe schema` JSON
|
|
133
|
+
* @param version - Optional DSL version
|
|
134
|
+
* @returns Schema store instance
|
|
135
|
+
*/
|
|
136
|
+
export declare function createSchemaStoreFromResponse(response: DescribeSchemaResponse, version?: string, loadedAt?: Date, metadata?: SchemaStoreMetadata): SchemaStore;
|
|
137
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/dsl/schema/store.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAA2B,KAAK,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC9F,OA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
|
+
import { STRUCTURED_ENTITY_TYPES } from "./structured-entities.js";
|
|
6
|
+
import { buildSchemaSummary } from "./summary.js";
|
|
7
|
+
/** Operational limits mirrored from upstream DSL constants. */
|
|
8
|
+
export const SCHEMA_LIMITS = {
|
|
9
|
+
maxLimit: 1000,
|
|
10
|
+
maxOffset: 50000,
|
|
11
|
+
maxPages: 50,
|
|
12
|
+
maxFacetBuckets: 1000,
|
|
13
|
+
requestsPerMinute: 30,
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Read-only schema catalog with derived helper views for tools and clients.
|
|
17
|
+
*/
|
|
18
|
+
export class SchemaStore {
|
|
19
|
+
#version;
|
|
20
|
+
#loadedAt;
|
|
21
|
+
#loadSource;
|
|
22
|
+
#stale;
|
|
23
|
+
#cachedAt;
|
|
24
|
+
#sources;
|
|
25
|
+
#entities;
|
|
26
|
+
#raw;
|
|
27
|
+
/**
|
|
28
|
+
* @param response - Parsed `describe schema` payload
|
|
29
|
+
* @param version - Optional DSL version from `describe version`
|
|
30
|
+
* @param loadedAt - Timestamp when schema was loaded
|
|
31
|
+
* @param metadata - Cache/API provenance
|
|
32
|
+
*/
|
|
33
|
+
constructor(response, version, loadedAt = new Date(), metadata = {}) {
|
|
34
|
+
this.#raw = response;
|
|
35
|
+
this.#version = version;
|
|
36
|
+
this.#loadedAt = loadedAt;
|
|
37
|
+
this.#loadSource = metadata.loadSource ?? "api";
|
|
38
|
+
this.#stale = metadata.stale ?? false;
|
|
39
|
+
this.#cachedAt = metadata.cachedAt;
|
|
40
|
+
this.#sources = new Map(Object.entries(response.sources ?? {}));
|
|
41
|
+
this.#entities = new Map(Object.entries(response.entities ?? {}));
|
|
42
|
+
}
|
|
43
|
+
/** Whether schema came from the API or disk cache. */
|
|
44
|
+
get loadSource() {
|
|
45
|
+
return this.#loadSource;
|
|
46
|
+
}
|
|
47
|
+
/** True when serving from cache after an API failure or expired TTL. */
|
|
48
|
+
get stale() {
|
|
49
|
+
return this.#stale;
|
|
50
|
+
}
|
|
51
|
+
/** When the on-disk cache was written, if known. */
|
|
52
|
+
get cachedAt() {
|
|
53
|
+
return this.#cachedAt;
|
|
54
|
+
}
|
|
55
|
+
/** DSL version string, if known. */
|
|
56
|
+
get version() {
|
|
57
|
+
return this.#version;
|
|
58
|
+
}
|
|
59
|
+
/** When this store was populated. */
|
|
60
|
+
get loadedAt() {
|
|
61
|
+
return this.#loadedAt;
|
|
62
|
+
}
|
|
63
|
+
/** Full describe payload. */
|
|
64
|
+
get raw() {
|
|
65
|
+
return this.#raw;
|
|
66
|
+
}
|
|
67
|
+
/** All source names. */
|
|
68
|
+
sourceNames() {
|
|
69
|
+
return [...this.#sources.keys()].sort();
|
|
70
|
+
}
|
|
71
|
+
/** All auxiliary entity names. */
|
|
72
|
+
entityNames() {
|
|
73
|
+
return [...this.#entities.keys()].sort();
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Returns a source schema by name.
|
|
77
|
+
* @param name - Source name (e.g. `publications`)
|
|
78
|
+
* @returns Source schema or undefined
|
|
79
|
+
*/
|
|
80
|
+
getSource(name) {
|
|
81
|
+
return this.#sources.get(name);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Returns an auxiliary entity schema by name.
|
|
85
|
+
* @param name - Entity name (e.g. `journals`)
|
|
86
|
+
* @returns Entity schema or undefined
|
|
87
|
+
*/
|
|
88
|
+
getEntity(name) {
|
|
89
|
+
return this.#entities.get(name);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Filterable field names for a source.
|
|
93
|
+
* @param source - Source name
|
|
94
|
+
* @returns Field names where `is_filter` is true
|
|
95
|
+
*/
|
|
96
|
+
filterableFields(source) {
|
|
97
|
+
const fields = this.#sources.get(source)?.fields ?? {};
|
|
98
|
+
return Object.entries(fields)
|
|
99
|
+
.filter(([, f]) => f.is_filter === true)
|
|
100
|
+
.map(([name]) => name)
|
|
101
|
+
.sort();
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Facet field names for a source.
|
|
105
|
+
* @param source - Source name
|
|
106
|
+
* @returns Field names marked as facets or entity fields
|
|
107
|
+
*/
|
|
108
|
+
facetFields(source) {
|
|
109
|
+
const fields = this.#sources.get(source)?.fields ?? {};
|
|
110
|
+
return Object.entries(fields)
|
|
111
|
+
.filter(([, f]) => f.is_facet === true || f.is_entity === true)
|
|
112
|
+
.map(([name]) => name)
|
|
113
|
+
.sort();
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Search index names for a source.
|
|
117
|
+
* @param source - Source name
|
|
118
|
+
* @returns Search field/index names
|
|
119
|
+
*/
|
|
120
|
+
searchIndexes(source) {
|
|
121
|
+
const raw = this.#sources.get(source)?.search_fields;
|
|
122
|
+
if (!raw)
|
|
123
|
+
return [];
|
|
124
|
+
if (Array.isArray(raw))
|
|
125
|
+
return [...raw].sort();
|
|
126
|
+
return Object.keys(raw).sort();
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Aggregation indicator names for a source.
|
|
130
|
+
* @param source - Source name
|
|
131
|
+
* @returns Metric names
|
|
132
|
+
*/
|
|
133
|
+
metrics(source) {
|
|
134
|
+
const raw = this.#sources.get(source)?.metrics;
|
|
135
|
+
if (!raw)
|
|
136
|
+
return [];
|
|
137
|
+
if (Array.isArray(raw))
|
|
138
|
+
return [...raw].sort();
|
|
139
|
+
return Object.keys(raw).sort();
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Named fieldsets for a source.
|
|
143
|
+
* @param source - Source name
|
|
144
|
+
* @returns Fieldset name to field list map
|
|
145
|
+
*/
|
|
146
|
+
fieldsets(source) {
|
|
147
|
+
return this.#sources.get(source)?.fieldsets ?? {};
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Core entity types supported by structured search tools.
|
|
151
|
+
* @returns Structured sources that exist in the loaded describe schema
|
|
152
|
+
*/
|
|
153
|
+
structuredEntityTypes() {
|
|
154
|
+
return STRUCTURED_ENTITY_TYPES.filter((entity) => this.#sources.has(entity));
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Health/stats payload for `/health`.
|
|
158
|
+
* @returns Summary object
|
|
159
|
+
*/
|
|
160
|
+
stats() {
|
|
161
|
+
return {
|
|
162
|
+
dslVersion: this.#version,
|
|
163
|
+
sourceCount: this.#sources.size,
|
|
164
|
+
entityCount: this.#entities.size,
|
|
165
|
+
schemaLoadedAt: this.#loadedAt.toISOString(),
|
|
166
|
+
loadSource: this.#loadSource,
|
|
167
|
+
stale: this.#stale,
|
|
168
|
+
cachedAt: this.#cachedAt?.toISOString(),
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Compact overview for cold-start discovery (fields, facets, resource URIs).
|
|
173
|
+
* @returns Summary payload
|
|
174
|
+
*/
|
|
175
|
+
summary() {
|
|
176
|
+
return buildSchemaSummary(this);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Comma-separated facet fields for tool descriptions.
|
|
180
|
+
* @param source - Source name
|
|
181
|
+
* @returns Hint string
|
|
182
|
+
*/
|
|
183
|
+
facetFieldsHint(source) {
|
|
184
|
+
return this.facetFields(source).join(", ") || "(none)";
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Comma-separated metrics for tool descriptions.
|
|
188
|
+
* @param source - Source name
|
|
189
|
+
* @returns Hint string
|
|
190
|
+
*/
|
|
191
|
+
metricsHint(source) {
|
|
192
|
+
return this.metrics(source).join(", ") || "(none)";
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Builds a {@link SchemaStore} from a describe response.
|
|
197
|
+
* @param response - `describe schema` JSON
|
|
198
|
+
* @param version - Optional DSL version
|
|
199
|
+
* @returns Schema store instance
|
|
200
|
+
*/
|
|
201
|
+
export function createSchemaStoreFromResponse(response, version, loadedAt, metadata) {
|
|
202
|
+
return new SchemaStore(response, version, loadedAt, metadata);
|
|
203
|
+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rD,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,6BAA6B,CAC3C,QAAgC,EAChC,OAAgB,EAChB,QAAe,EACf,QAA8B;IAE9B,OAAO,IAAI,WAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured search entity types supported by search tools.
|
|
3
|
+
* @module schema/structured-entities
|
|
4
|
+
*/
|
|
5
|
+
/** Source names that have dedicated structured search tools. */
|
|
6
|
+
export declare const STRUCTURED_ENTITY_TYPES: readonly ["publications", "grants", "researchers", "patents", "clinical_trials", "datasets", "policy_documents", "organizations"];
|
|
7
|
+
/** A source with a structured search tool. */
|
|
8
|
+
export type StructuredEntityType = (typeof STRUCTURED_ENTITY_TYPES)[number];
|
|
9
|
+
/**
|
|
10
|
+
* Tool name for a structured entity.
|
|
11
|
+
* @param source - Dimensions source name
|
|
12
|
+
* @returns Tool name (e.g. `search_publications`)
|
|
13
|
+
*/
|
|
14
|
+
export declare function searchToolName(source: StructuredEntityType): string;
|
|
15
|
+
/**
|
|
16
|
+
* JSON result key for entity rows (camelCase where historical tools used it).
|
|
17
|
+
* @param source - Dimensions source name
|
|
18
|
+
* @returns Property name in tool output
|
|
19
|
+
*/
|
|
20
|
+
export declare function searchResultKey(source: StructuredEntityType): string;
|
|
21
|
+
//# sourceMappingURL=structured-entities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"structured-entities.d.ts","sourceRoot":"","sources":["../../../src/dsl/schema/structured-entities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,gEAAgE;AAChE,eAAO,MAAM,uBAAuB,mIAS1B,CAAC;AAEX,8CAA8C;AAC9C,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5E;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,MAAM,CAEnE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,oBAAoB,GAAG,MAAM,CASpE"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured search entity types supported by search tools.
|
|
3
|
+
* @module schema/structured-entities
|
|
4
|
+
*/
|
|
5
|
+
/** Source names that have dedicated structured search tools. */
|
|
6
|
+
export const STRUCTURED_ENTITY_TYPES = [
|
|
7
|
+
"publications",
|
|
8
|
+
"grants",
|
|
9
|
+
"researchers",
|
|
10
|
+
"patents",
|
|
11
|
+
"clinical_trials",
|
|
12
|
+
"datasets",
|
|
13
|
+
"policy_documents",
|
|
14
|
+
"organizations",
|
|
15
|
+
];
|
|
16
|
+
/**
|
|
17
|
+
* Tool name for a structured entity.
|
|
18
|
+
* @param source - Dimensions source name
|
|
19
|
+
* @returns Tool name (e.g. `search_publications`)
|
|
20
|
+
*/
|
|
21
|
+
export function searchToolName(source) {
|
|
22
|
+
return `search_${source}`;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* JSON result key for entity rows (camelCase where historical tools used it).
|
|
26
|
+
* @param source - Dimensions source name
|
|
27
|
+
* @returns Property name in tool output
|
|
28
|
+
*/
|
|
29
|
+
export function searchResultKey(source) {
|
|
30
|
+
switch (source) {
|
|
31
|
+
case "clinical_trials":
|
|
32
|
+
return "clinicalTrials";
|
|
33
|
+
case "policy_documents":
|
|
34
|
+
return "policyDocuments";
|
|
35
|
+
default:
|
|
36
|
+
return source;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=structured-entities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"structured-entities.js","sourceRoot":"","sources":["../../../src/dsl/schema/structured-entities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,gEAAgE;AAChE,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,cAAc;IACd,QAAQ;IACR,aAAa;IACb,SAAS;IACT,iBAAiB;IACjB,UAAU;IACV,kBAAkB;IAClB,eAAe;CACP,CAAC;AAKX;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,MAA4B;IACzD,OAAO,UAAU,MAAM,EAAE,CAAC;AAC5B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,MAA4B;IAC1D,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,iBAAiB;YACpB,OAAO,gBAAgB,CAAC;QAC1B,KAAK,kBAAkB;YACrB,OAAO,iBAAiB,CAAC;QAC3B;YACE,OAAO,MAAM,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compact schema summary for cold-start and agent discovery.
|
|
3
|
+
* @module schema/summary
|
|
4
|
+
*/
|
|
5
|
+
import { SCHEMA_LIMITS, type SchemaStore } from "./store.js";
|
|
6
|
+
/** MCP resource URIs for drilling into the full schema. */
|
|
7
|
+
export declare const SCHEMA_RESOURCE_URIS: {
|
|
8
|
+
readonly full: "dimensions://schema";
|
|
9
|
+
readonly summary: "dimensions://schema/summary";
|
|
10
|
+
readonly version: "dimensions://schema/version";
|
|
11
|
+
readonly limits: "dimensions://schema/limits";
|
|
12
|
+
readonly policy: "dimensions://schema/policy";
|
|
13
|
+
readonly fields: "dimensions://fields/{entityType}";
|
|
14
|
+
readonly source: "dimensions://schema/sources/{sourceName}";
|
|
15
|
+
readonly entity: "dimensions://schema/entities/{entityName}";
|
|
16
|
+
readonly examples: "dimensions://examples";
|
|
17
|
+
readonly examplesBySource: "dimensions://examples/{source}";
|
|
18
|
+
};
|
|
19
|
+
/** Per-source counts derived from describe schema. */
|
|
20
|
+
export type SchemaSourceSummary = {
|
|
21
|
+
readonly filterableFieldCount: number;
|
|
22
|
+
readonly facetFieldCount: number;
|
|
23
|
+
readonly searchIndexCount: number;
|
|
24
|
+
readonly metricCount: number;
|
|
25
|
+
readonly fieldsetNames: readonly string[];
|
|
26
|
+
};
|
|
27
|
+
/** Compact schema overview for agents and MCP tools. */
|
|
28
|
+
export type SchemaSummary = {
|
|
29
|
+
readonly version: string | undefined;
|
|
30
|
+
readonly loadedAt: string;
|
|
31
|
+
readonly cachedAt: string | undefined;
|
|
32
|
+
readonly stale: boolean;
|
|
33
|
+
readonly loadSource: "api" | "cache";
|
|
34
|
+
readonly limits: typeof SCHEMA_LIMITS;
|
|
35
|
+
readonly stats: {
|
|
36
|
+
readonly sourceCount: number;
|
|
37
|
+
readonly entityCount: number;
|
|
38
|
+
readonly structuredEntityTypes: readonly string[];
|
|
39
|
+
};
|
|
40
|
+
readonly sources: Readonly<Record<string, SchemaSourceSummary>>;
|
|
41
|
+
readonly entities: readonly string[];
|
|
42
|
+
readonly resources: typeof SCHEMA_RESOURCE_URIS;
|
|
43
|
+
readonly hint: string;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Builds a compact schema summary from a loaded {@link SchemaStore}.
|
|
47
|
+
* @param store - Loaded schema store
|
|
48
|
+
* @returns Summary payload for tools and resources
|
|
49
|
+
*/
|
|
50
|
+
export declare function buildSchemaSummary(store: SchemaStore): SchemaSummary;
|
|
51
|
+
//# sourceMappingURL=summary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"summary.d.ts","sourceRoot":"","sources":["../../../src/dsl/schema/summary.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAE7D,2DAA2D;AAC3D,eAAO,MAAM,oBAAoB;;;;;;;;;;;CAWvB,CAAC;AAEX,sDAAsD;AACtD,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACtC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,gBAA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