@dotsetlabs/bellwether 0.10.0
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 +291 -0
- package/LICENSE +21 -0
- package/README.md +739 -0
- package/dist/auth/credentials.d.ts +64 -0
- package/dist/auth/credentials.js +218 -0
- package/dist/auth/index.d.ts +6 -0
- package/dist/auth/index.js +6 -0
- package/dist/auth/keychain.d.ts +64 -0
- package/dist/auth/keychain.js +268 -0
- package/dist/baseline/ab-testing.d.ts +80 -0
- package/dist/baseline/ab-testing.js +236 -0
- package/dist/baseline/ai-compatibility-scorer.d.ts +95 -0
- package/dist/baseline/ai-compatibility-scorer.js +606 -0
- package/dist/baseline/calibration.d.ts +77 -0
- package/dist/baseline/calibration.js +136 -0
- package/dist/baseline/category-matching.d.ts +85 -0
- package/dist/baseline/category-matching.js +289 -0
- package/dist/baseline/change-impact-analyzer.d.ts +98 -0
- package/dist/baseline/change-impact-analyzer.js +592 -0
- package/dist/baseline/comparator.d.ts +64 -0
- package/dist/baseline/comparator.js +916 -0
- package/dist/baseline/confidence.d.ts +55 -0
- package/dist/baseline/confidence.js +122 -0
- package/dist/baseline/converter.d.ts +61 -0
- package/dist/baseline/converter.js +585 -0
- package/dist/baseline/dependency-analyzer.d.ts +89 -0
- package/dist/baseline/dependency-analyzer.js +567 -0
- package/dist/baseline/deprecation-tracker.d.ts +133 -0
- package/dist/baseline/deprecation-tracker.js +322 -0
- package/dist/baseline/diff.d.ts +55 -0
- package/dist/baseline/diff.js +1584 -0
- package/dist/baseline/documentation-scorer.d.ts +205 -0
- package/dist/baseline/documentation-scorer.js +466 -0
- package/dist/baseline/embeddings.d.ts +118 -0
- package/dist/baseline/embeddings.js +251 -0
- package/dist/baseline/error-analyzer.d.ts +198 -0
- package/dist/baseline/error-analyzer.js +721 -0
- package/dist/baseline/evaluation/evaluator.d.ts +42 -0
- package/dist/baseline/evaluation/evaluator.js +323 -0
- package/dist/baseline/evaluation/expanded-dataset.d.ts +45 -0
- package/dist/baseline/evaluation/expanded-dataset.js +1164 -0
- package/dist/baseline/evaluation/golden-dataset.d.ts +58 -0
- package/dist/baseline/evaluation/golden-dataset.js +717 -0
- package/dist/baseline/evaluation/index.d.ts +15 -0
- package/dist/baseline/evaluation/index.js +15 -0
- package/dist/baseline/evaluation/types.d.ts +186 -0
- package/dist/baseline/evaluation/types.js +8 -0
- package/dist/baseline/external-dependency-detector.d.ts +181 -0
- package/dist/baseline/external-dependency-detector.js +524 -0
- package/dist/baseline/golden-output.d.ts +162 -0
- package/dist/baseline/golden-output.js +636 -0
- package/dist/baseline/health-scorer.d.ts +174 -0
- package/dist/baseline/health-scorer.js +451 -0
- package/dist/baseline/incremental-checker.d.ts +97 -0
- package/dist/baseline/incremental-checker.js +174 -0
- package/dist/baseline/index.d.ts +31 -0
- package/dist/baseline/index.js +42 -0
- package/dist/baseline/migration-generator.d.ts +137 -0
- package/dist/baseline/migration-generator.js +554 -0
- package/dist/baseline/migrations.d.ts +60 -0
- package/dist/baseline/migrations.js +197 -0
- package/dist/baseline/performance-tracker.d.ts +214 -0
- package/dist/baseline/performance-tracker.js +577 -0
- package/dist/baseline/pr-comment-generator.d.ts +117 -0
- package/dist/baseline/pr-comment-generator.js +546 -0
- package/dist/baseline/response-fingerprint.d.ts +127 -0
- package/dist/baseline/response-fingerprint.js +728 -0
- package/dist/baseline/response-schema-tracker.d.ts +129 -0
- package/dist/baseline/response-schema-tracker.js +420 -0
- package/dist/baseline/risk-scorer.d.ts +54 -0
- package/dist/baseline/risk-scorer.js +434 -0
- package/dist/baseline/saver.d.ts +89 -0
- package/dist/baseline/saver.js +554 -0
- package/dist/baseline/scenario-generator.d.ts +151 -0
- package/dist/baseline/scenario-generator.js +905 -0
- package/dist/baseline/schema-compare.d.ts +86 -0
- package/dist/baseline/schema-compare.js +557 -0
- package/dist/baseline/schema-evolution.d.ts +189 -0
- package/dist/baseline/schema-evolution.js +467 -0
- package/dist/baseline/semantic.d.ts +203 -0
- package/dist/baseline/semantic.js +908 -0
- package/dist/baseline/synonyms.d.ts +60 -0
- package/dist/baseline/synonyms.js +386 -0
- package/dist/baseline/telemetry.d.ts +165 -0
- package/dist/baseline/telemetry.js +294 -0
- package/dist/baseline/test-pruner.d.ts +120 -0
- package/dist/baseline/test-pruner.js +387 -0
- package/dist/baseline/types.d.ts +449 -0
- package/dist/baseline/types.js +5 -0
- package/dist/baseline/version.d.ts +138 -0
- package/dist/baseline/version.js +206 -0
- package/dist/cache/index.d.ts +5 -0
- package/dist/cache/index.js +5 -0
- package/dist/cache/response-cache.d.ts +151 -0
- package/dist/cache/response-cache.js +287 -0
- package/dist/ci/index.d.ts +60 -0
- package/dist/ci/index.js +342 -0
- package/dist/cli/commands/auth.d.ts +12 -0
- package/dist/cli/commands/auth.js +352 -0
- package/dist/cli/commands/badge.d.ts +3 -0
- package/dist/cli/commands/badge.js +74 -0
- package/dist/cli/commands/baseline-accept.d.ts +15 -0
- package/dist/cli/commands/baseline-accept.js +178 -0
- package/dist/cli/commands/baseline-migrate.d.ts +12 -0
- package/dist/cli/commands/baseline-migrate.js +164 -0
- package/dist/cli/commands/baseline.d.ts +14 -0
- package/dist/cli/commands/baseline.js +449 -0
- package/dist/cli/commands/beta.d.ts +10 -0
- package/dist/cli/commands/beta.js +231 -0
- package/dist/cli/commands/check.d.ts +11 -0
- package/dist/cli/commands/check.js +820 -0
- package/dist/cli/commands/cloud/badge.d.ts +3 -0
- package/dist/cli/commands/cloud/badge.js +74 -0
- package/dist/cli/commands/cloud/diff.d.ts +6 -0
- package/dist/cli/commands/cloud/diff.js +79 -0
- package/dist/cli/commands/cloud/history.d.ts +6 -0
- package/dist/cli/commands/cloud/history.js +102 -0
- package/dist/cli/commands/cloud/link.d.ts +9 -0
- package/dist/cli/commands/cloud/link.js +119 -0
- package/dist/cli/commands/cloud/login.d.ts +7 -0
- package/dist/cli/commands/cloud/login.js +499 -0
- package/dist/cli/commands/cloud/projects.d.ts +6 -0
- package/dist/cli/commands/cloud/projects.js +44 -0
- package/dist/cli/commands/cloud/shared.d.ts +7 -0
- package/dist/cli/commands/cloud/shared.js +42 -0
- package/dist/cli/commands/cloud/teams.d.ts +8 -0
- package/dist/cli/commands/cloud/teams.js +169 -0
- package/dist/cli/commands/cloud/upload.d.ts +8 -0
- package/dist/cli/commands/cloud/upload.js +181 -0
- package/dist/cli/commands/contract.d.ts +11 -0
- package/dist/cli/commands/contract.js +280 -0
- package/dist/cli/commands/discover.d.ts +3 -0
- package/dist/cli/commands/discover.js +82 -0
- package/dist/cli/commands/eval.d.ts +9 -0
- package/dist/cli/commands/eval.js +187 -0
- package/dist/cli/commands/explore.d.ts +11 -0
- package/dist/cli/commands/explore.js +437 -0
- package/dist/cli/commands/feedback.d.ts +9 -0
- package/dist/cli/commands/feedback.js +174 -0
- package/dist/cli/commands/golden.d.ts +12 -0
- package/dist/cli/commands/golden.js +407 -0
- package/dist/cli/commands/history.d.ts +10 -0
- package/dist/cli/commands/history.js +202 -0
- package/dist/cli/commands/init.d.ts +9 -0
- package/dist/cli/commands/init.js +219 -0
- package/dist/cli/commands/interview.d.ts +3 -0
- package/dist/cli/commands/interview.js +903 -0
- package/dist/cli/commands/link.d.ts +10 -0
- package/dist/cli/commands/link.js +169 -0
- package/dist/cli/commands/login.d.ts +7 -0
- package/dist/cli/commands/login.js +499 -0
- package/dist/cli/commands/preset.d.ts +33 -0
- package/dist/cli/commands/preset.js +297 -0
- package/dist/cli/commands/profile.d.ts +33 -0
- package/dist/cli/commands/profile.js +286 -0
- package/dist/cli/commands/registry.d.ts +11 -0
- package/dist/cli/commands/registry.js +146 -0
- package/dist/cli/commands/shared.d.ts +79 -0
- package/dist/cli/commands/shared.js +196 -0
- package/dist/cli/commands/teams.d.ts +8 -0
- package/dist/cli/commands/teams.js +169 -0
- package/dist/cli/commands/test.d.ts +9 -0
- package/dist/cli/commands/test.js +500 -0
- package/dist/cli/commands/upload.d.ts +8 -0
- package/dist/cli/commands/upload.js +223 -0
- package/dist/cli/commands/validate-config.d.ts +6 -0
- package/dist/cli/commands/validate-config.js +35 -0
- package/dist/cli/commands/verify.d.ts +11 -0
- package/dist/cli/commands/verify.js +283 -0
- package/dist/cli/commands/watch.d.ts +12 -0
- package/dist/cli/commands/watch.js +253 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.js +178 -0
- package/dist/cli/interactive.d.ts +47 -0
- package/dist/cli/interactive.js +216 -0
- package/dist/cli/output/terminal-reporter.d.ts +19 -0
- package/dist/cli/output/terminal-reporter.js +104 -0
- package/dist/cli/output.d.ts +226 -0
- package/dist/cli/output.js +438 -0
- package/dist/cli/utils/env.d.ts +5 -0
- package/dist/cli/utils/env.js +14 -0
- package/dist/cli/utils/progress.d.ts +59 -0
- package/dist/cli/utils/progress.js +206 -0
- package/dist/cli/utils/server-context.d.ts +10 -0
- package/dist/cli/utils/server-context.js +36 -0
- package/dist/cloud/auth.d.ts +144 -0
- package/dist/cloud/auth.js +374 -0
- package/dist/cloud/client.d.ts +24 -0
- package/dist/cloud/client.js +65 -0
- package/dist/cloud/http-client.d.ts +38 -0
- package/dist/cloud/http-client.js +215 -0
- package/dist/cloud/index.d.ts +23 -0
- package/dist/cloud/index.js +25 -0
- package/dist/cloud/mock-client.d.ts +107 -0
- package/dist/cloud/mock-client.js +545 -0
- package/dist/cloud/types.d.ts +515 -0
- package/dist/cloud/types.js +15 -0
- package/dist/config/defaults.d.ts +160 -0
- package/dist/config/defaults.js +169 -0
- package/dist/config/loader.d.ts +24 -0
- package/dist/config/loader.js +122 -0
- package/dist/config/template.d.ts +42 -0
- package/dist/config/template.js +647 -0
- package/dist/config/validator.d.ts +2112 -0
- package/dist/config/validator.js +658 -0
- package/dist/constants/cloud.d.ts +107 -0
- package/dist/constants/cloud.js +110 -0
- package/dist/constants/core.d.ts +521 -0
- package/dist/constants/core.js +556 -0
- package/dist/constants/testing.d.ts +1283 -0
- package/dist/constants/testing.js +1568 -0
- package/dist/constants.d.ts +10 -0
- package/dist/constants.js +10 -0
- package/dist/contract/index.d.ts +6 -0
- package/dist/contract/index.js +5 -0
- package/dist/contract/validator.d.ts +177 -0
- package/dist/contract/validator.js +574 -0
- package/dist/cost/index.d.ts +6 -0
- package/dist/cost/index.js +5 -0
- package/dist/cost/tracker.d.ts +134 -0
- package/dist/cost/tracker.js +313 -0
- package/dist/discovery/discovery.d.ts +16 -0
- package/dist/discovery/discovery.js +173 -0
- package/dist/discovery/types.d.ts +51 -0
- package/dist/discovery/types.js +2 -0
- package/dist/docs/agents.d.ts +3 -0
- package/dist/docs/agents.js +995 -0
- package/dist/docs/contract.d.ts +51 -0
- package/dist/docs/contract.js +1681 -0
- package/dist/docs/generator.d.ts +4 -0
- package/dist/docs/generator.js +4 -0
- package/dist/docs/html-reporter.d.ts +9 -0
- package/dist/docs/html-reporter.js +757 -0
- package/dist/docs/index.d.ts +10 -0
- package/dist/docs/index.js +11 -0
- package/dist/docs/junit-reporter.d.ts +18 -0
- package/dist/docs/junit-reporter.js +210 -0
- package/dist/docs/report.d.ts +14 -0
- package/dist/docs/report.js +44 -0
- package/dist/docs/sarif-reporter.d.ts +19 -0
- package/dist/docs/sarif-reporter.js +335 -0
- package/dist/docs/shared.d.ts +35 -0
- package/dist/docs/shared.js +162 -0
- package/dist/docs/templates.d.ts +12 -0
- package/dist/docs/templates.js +76 -0
- package/dist/errors/index.d.ts +6 -0
- package/dist/errors/index.js +6 -0
- package/dist/errors/retry.d.ts +92 -0
- package/dist/errors/retry.js +323 -0
- package/dist/errors/types.d.ts +321 -0
- package/dist/errors/types.js +584 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +32 -0
- package/dist/interview/dependency-resolver.d.ts +11 -0
- package/dist/interview/dependency-resolver.js +32 -0
- package/dist/interview/interviewer.d.ts +232 -0
- package/dist/interview/interviewer.js +1939 -0
- package/dist/interview/mock-response-generator.d.ts +7 -0
- package/dist/interview/mock-response-generator.js +102 -0
- package/dist/interview/orchestrator.d.ts +237 -0
- package/dist/interview/orchestrator.js +1296 -0
- package/dist/interview/rate-limiter.d.ts +15 -0
- package/dist/interview/rate-limiter.js +55 -0
- package/dist/interview/response-validator.d.ts +10 -0
- package/dist/interview/response-validator.js +132 -0
- package/dist/interview/schema-inferrer.d.ts +8 -0
- package/dist/interview/schema-inferrer.js +71 -0
- package/dist/interview/schema-test-generator.d.ts +71 -0
- package/dist/interview/schema-test-generator.js +834 -0
- package/dist/interview/smart-value-generator.d.ts +155 -0
- package/dist/interview/smart-value-generator.js +554 -0
- package/dist/interview/stateful-test-runner.d.ts +19 -0
- package/dist/interview/stateful-test-runner.js +106 -0
- package/dist/interview/types.d.ts +561 -0
- package/dist/interview/types.js +2 -0
- package/dist/llm/anthropic.d.ts +41 -0
- package/dist/llm/anthropic.js +355 -0
- package/dist/llm/client.d.ts +123 -0
- package/dist/llm/client.js +42 -0
- package/dist/llm/factory.d.ts +38 -0
- package/dist/llm/factory.js +145 -0
- package/dist/llm/fallback.d.ts +140 -0
- package/dist/llm/fallback.js +379 -0
- package/dist/llm/index.d.ts +18 -0
- package/dist/llm/index.js +15 -0
- package/dist/llm/ollama.d.ts +37 -0
- package/dist/llm/ollama.js +330 -0
- package/dist/llm/openai.d.ts +25 -0
- package/dist/llm/openai.js +320 -0
- package/dist/llm/token-budget.d.ts +161 -0
- package/dist/llm/token-budget.js +395 -0
- package/dist/logging/logger.d.ts +70 -0
- package/dist/logging/logger.js +130 -0
- package/dist/metrics/collector.d.ts +106 -0
- package/dist/metrics/collector.js +547 -0
- package/dist/metrics/index.d.ts +7 -0
- package/dist/metrics/index.js +7 -0
- package/dist/metrics/prometheus.d.ts +20 -0
- package/dist/metrics/prometheus.js +241 -0
- package/dist/metrics/types.d.ts +209 -0
- package/dist/metrics/types.js +5 -0
- package/dist/persona/builtins.d.ts +54 -0
- package/dist/persona/builtins.js +219 -0
- package/dist/persona/index.d.ts +8 -0
- package/dist/persona/index.js +8 -0
- package/dist/persona/loader.d.ts +30 -0
- package/dist/persona/loader.js +190 -0
- package/dist/persona/types.d.ts +144 -0
- package/dist/persona/types.js +5 -0
- package/dist/persona/validation.d.ts +94 -0
- package/dist/persona/validation.js +332 -0
- package/dist/prompts/index.d.ts +5 -0
- package/dist/prompts/index.js +5 -0
- package/dist/prompts/templates.d.ts +180 -0
- package/dist/prompts/templates.js +431 -0
- package/dist/registry/client.d.ts +49 -0
- package/dist/registry/client.js +191 -0
- package/dist/registry/index.d.ts +7 -0
- package/dist/registry/index.js +6 -0
- package/dist/registry/types.d.ts +140 -0
- package/dist/registry/types.js +6 -0
- package/dist/scenarios/evaluator.d.ts +43 -0
- package/dist/scenarios/evaluator.js +206 -0
- package/dist/scenarios/index.d.ts +10 -0
- package/dist/scenarios/index.js +9 -0
- package/dist/scenarios/loader.d.ts +20 -0
- package/dist/scenarios/loader.js +285 -0
- package/dist/scenarios/types.d.ts +153 -0
- package/dist/scenarios/types.js +8 -0
- package/dist/security/index.d.ts +17 -0
- package/dist/security/index.js +18 -0
- package/dist/security/payloads.d.ts +61 -0
- package/dist/security/payloads.js +268 -0
- package/dist/security/security-tester.d.ts +42 -0
- package/dist/security/security-tester.js +582 -0
- package/dist/security/types.d.ts +166 -0
- package/dist/security/types.js +8 -0
- package/dist/transport/base-transport.d.ts +59 -0
- package/dist/transport/base-transport.js +38 -0
- package/dist/transport/http-transport.d.ts +67 -0
- package/dist/transport/http-transport.js +238 -0
- package/dist/transport/mcp-client.d.ts +141 -0
- package/dist/transport/mcp-client.js +496 -0
- package/dist/transport/sse-transport.d.ts +88 -0
- package/dist/transport/sse-transport.js +316 -0
- package/dist/transport/stdio-transport.d.ts +43 -0
- package/dist/transport/stdio-transport.js +238 -0
- package/dist/transport/types.d.ts +125 -0
- package/dist/transport/types.js +16 -0
- package/dist/utils/concurrency.d.ts +123 -0
- package/dist/utils/concurrency.js +213 -0
- package/dist/utils/formatters.d.ts +16 -0
- package/dist/utils/formatters.js +37 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/jsonpath.d.ts +87 -0
- package/dist/utils/jsonpath.js +326 -0
- package/dist/utils/markdown.d.ts +113 -0
- package/dist/utils/markdown.js +265 -0
- package/dist/utils/network.d.ts +14 -0
- package/dist/utils/network.js +17 -0
- package/dist/utils/sanitize.d.ts +92 -0
- package/dist/utils/sanitize.js +191 -0
- package/dist/utils/semantic.d.ts +194 -0
- package/dist/utils/semantic.js +1051 -0
- package/dist/utils/smart-truncate.d.ts +94 -0
- package/dist/utils/smart-truncate.js +361 -0
- package/dist/utils/timeout.d.ts +153 -0
- package/dist/utils/timeout.js +205 -0
- package/dist/utils/yaml-parser.d.ts +58 -0
- package/dist/utils/yaml-parser.js +86 -0
- package/dist/validation/index.d.ts +32 -0
- package/dist/validation/index.js +32 -0
- package/dist/validation/semantic-test-generator.d.ts +50 -0
- package/dist/validation/semantic-test-generator.js +176 -0
- package/dist/validation/semantic-types.d.ts +66 -0
- package/dist/validation/semantic-types.js +94 -0
- package/dist/validation/semantic-validator.d.ts +38 -0
- package/dist/validation/semantic-validator.js +340 -0
- package/dist/verification/index.d.ts +6 -0
- package/dist/verification/index.js +5 -0
- package/dist/verification/types.d.ts +133 -0
- package/dist/verification/types.js +5 -0
- package/dist/verification/verifier.d.ts +30 -0
- package/dist/verification/verifier.js +309 -0
- package/dist/version.d.ts +19 -0
- package/dist/version.js +48 -0
- package/dist/workflow/auto-generator.d.ts +27 -0
- package/dist/workflow/auto-generator.js +513 -0
- package/dist/workflow/discovery.d.ts +40 -0
- package/dist/workflow/discovery.js +195 -0
- package/dist/workflow/executor.d.ts +82 -0
- package/dist/workflow/executor.js +611 -0
- package/dist/workflow/index.d.ts +10 -0
- package/dist/workflow/index.js +10 -0
- package/dist/workflow/loader.d.ts +24 -0
- package/dist/workflow/loader.js +194 -0
- package/dist/workflow/state-tracker.d.ts +98 -0
- package/dist/workflow/state-tracker.js +424 -0
- package/dist/workflow/types.d.ts +337 -0
- package/dist/workflow/types.js +5 -0
- package/package.json +94 -0
- package/schemas/bellwether-check.schema.json +651 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Smart test value generation for schema-based testing.
|
|
3
|
+
*
|
|
4
|
+
* This module provides intelligent value generation for test cases by:
|
|
5
|
+
* 1. Recognizing semantic patterns in field names and descriptions
|
|
6
|
+
* 2. Respecting JSON Schema format fields
|
|
7
|
+
* 3. Generating syntactically and semantically valid test values
|
|
8
|
+
*
|
|
9
|
+
* The goal is to generate values that are more likely to be accepted by
|
|
10
|
+
* real-world tools, rather than random strings that get rejected.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Pattern matchers for detecting date/time formats.
|
|
14
|
+
*/
|
|
15
|
+
export declare const DATE_TIME_PATTERNS: {
|
|
16
|
+
/** Field name patterns that suggest date fields */
|
|
17
|
+
readonly FIELD_NAME: readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp];
|
|
18
|
+
/** Description patterns that suggest date formats */
|
|
19
|
+
readonly DESCRIPTION: readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp];
|
|
20
|
+
/** Default date value if format not specified */
|
|
21
|
+
readonly DEFAULT_DATE: "2024-01-15";
|
|
22
|
+
readonly DEFAULT_DATETIME: "2024-01-15T14:30:00Z";
|
|
23
|
+
readonly DEFAULT_TIME: "14:30:00";
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Pattern matchers for detecting email fields.
|
|
27
|
+
*/
|
|
28
|
+
export declare const EMAIL_PATTERNS: {
|
|
29
|
+
/** Field name patterns */
|
|
30
|
+
readonly FIELD_NAME: readonly [RegExp, RegExp, RegExp];
|
|
31
|
+
/** Description patterns */
|
|
32
|
+
readonly DESCRIPTION: readonly [RegExp, RegExp, RegExp];
|
|
33
|
+
/** Default email value */
|
|
34
|
+
readonly DEFAULT: "test@example.com";
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Pattern matchers for detecting URL fields.
|
|
38
|
+
*/
|
|
39
|
+
export declare const URL_PATTERNS: {
|
|
40
|
+
/** Field name patterns */
|
|
41
|
+
readonly FIELD_NAME: readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp];
|
|
42
|
+
/** Description patterns */
|
|
43
|
+
readonly DESCRIPTION: readonly [RegExp, RegExp, RegExp, RegExp];
|
|
44
|
+
/** Default URL value */
|
|
45
|
+
readonly DEFAULT: "https://example.com";
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Pattern matchers for detecting ID fields.
|
|
49
|
+
*/
|
|
50
|
+
export declare const ID_PATTERNS: {
|
|
51
|
+
/** Field name patterns */
|
|
52
|
+
readonly FIELD_NAME: readonly [RegExp, RegExp, RegExp, RegExp, RegExp];
|
|
53
|
+
/** Description patterns */
|
|
54
|
+
readonly DESCRIPTION: readonly [RegExp, RegExp, RegExp];
|
|
55
|
+
/** Default ID value */
|
|
56
|
+
readonly DEFAULT: "test-id-123";
|
|
57
|
+
readonly DEFAULT_UUID: "550e8400-e29b-41d4-a716-446655440000";
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Pattern matchers for detecting phone fields.
|
|
61
|
+
*/
|
|
62
|
+
export declare const PHONE_PATTERNS: {
|
|
63
|
+
/** Field name patterns */
|
|
64
|
+
readonly FIELD_NAME: readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp];
|
|
65
|
+
/** Description patterns */
|
|
66
|
+
readonly DESCRIPTION: readonly [RegExp, RegExp, RegExp];
|
|
67
|
+
/** Default phone value */
|
|
68
|
+
readonly DEFAULT: "+1-555-123-4567";
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Pattern matchers for detecting monetary/amount fields.
|
|
72
|
+
*/
|
|
73
|
+
export declare const AMOUNT_PATTERNS: {
|
|
74
|
+
/** Field name patterns */
|
|
75
|
+
readonly FIELD_NAME: readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp];
|
|
76
|
+
/** Description patterns */
|
|
77
|
+
readonly DESCRIPTION: readonly [RegExp, RegExp, RegExp, RegExp, RegExp];
|
|
78
|
+
/** Default amount value */
|
|
79
|
+
readonly DEFAULT: "100.00";
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Pattern matchers for detecting month fields.
|
|
83
|
+
*/
|
|
84
|
+
export declare const MONTH_PATTERNS: {
|
|
85
|
+
/** Field name patterns */
|
|
86
|
+
readonly FIELD_NAME: readonly [RegExp, RegExp];
|
|
87
|
+
/** Description patterns */
|
|
88
|
+
readonly DESCRIPTION: readonly [RegExp, RegExp];
|
|
89
|
+
/** Valid month names */
|
|
90
|
+
readonly VALID_VALUES: readonly ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"];
|
|
91
|
+
/** Default month value */
|
|
92
|
+
readonly DEFAULT: "january";
|
|
93
|
+
readonly DEFAULT_NUMERIC: "01";
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Pattern matchers for detecting year fields.
|
|
97
|
+
*/
|
|
98
|
+
export declare const YEAR_PATTERNS: {
|
|
99
|
+
/** Field name patterns */
|
|
100
|
+
readonly FIELD_NAME: readonly [RegExp, RegExp];
|
|
101
|
+
/** Description patterns */
|
|
102
|
+
readonly DESCRIPTION: readonly [RegExp, RegExp];
|
|
103
|
+
/** Default year value */
|
|
104
|
+
readonly DEFAULT: "2024";
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Property schema interface (JSON Schema subset).
|
|
108
|
+
*/
|
|
109
|
+
export interface PropertySchema {
|
|
110
|
+
type?: string | string[];
|
|
111
|
+
enum?: unknown[];
|
|
112
|
+
const?: unknown;
|
|
113
|
+
default?: unknown;
|
|
114
|
+
examples?: unknown[];
|
|
115
|
+
minimum?: number;
|
|
116
|
+
maximum?: number;
|
|
117
|
+
minLength?: number;
|
|
118
|
+
maxLength?: number;
|
|
119
|
+
pattern?: string;
|
|
120
|
+
format?: string;
|
|
121
|
+
items?: PropertySchema;
|
|
122
|
+
properties?: Record<string, PropertySchema>;
|
|
123
|
+
required?: string[];
|
|
124
|
+
description?: string;
|
|
125
|
+
oneOf?: PropertySchema[];
|
|
126
|
+
anyOf?: PropertySchema[];
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Result of smart value generation.
|
|
130
|
+
*/
|
|
131
|
+
export interface SmartValueResult {
|
|
132
|
+
/** The generated value */
|
|
133
|
+
value: unknown;
|
|
134
|
+
/** The detected semantic type */
|
|
135
|
+
semanticType: string | null;
|
|
136
|
+
/** Confidence level of the type detection */
|
|
137
|
+
confidence: 'high' | 'medium' | 'low';
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Generate a smart string value based on field name, description, and schema.
|
|
141
|
+
*/
|
|
142
|
+
export declare function generateSmartStringValue(propName: string, prop: PropertySchema): SmartValueResult;
|
|
143
|
+
/**
|
|
144
|
+
* Generate a smart number value based on schema constraints.
|
|
145
|
+
*/
|
|
146
|
+
export declare function generateSmartNumberValue(prop: PropertySchema): SmartValueResult;
|
|
147
|
+
/**
|
|
148
|
+
* Generate a complete smart value for any type.
|
|
149
|
+
*/
|
|
150
|
+
export declare function generateSmartValue(propName: string, prop: PropertySchema): SmartValueResult;
|
|
151
|
+
/**
|
|
152
|
+
* Generate multiple alternative values for a field (for varied testing).
|
|
153
|
+
*/
|
|
154
|
+
export declare function generateAlternativeValues(propName: string, prop: PropertySchema, count?: number): SmartValueResult[];
|
|
155
|
+
//# sourceMappingURL=smart-value-generator.d.ts.map
|
|
@@ -0,0 +1,554 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Smart test value generation for schema-based testing.
|
|
3
|
+
*
|
|
4
|
+
* This module provides intelligent value generation for test cases by:
|
|
5
|
+
* 1. Recognizing semantic patterns in field names and descriptions
|
|
6
|
+
* 2. Respecting JSON Schema format fields
|
|
7
|
+
* 3. Generating syntactically and semantically valid test values
|
|
8
|
+
*
|
|
9
|
+
* The goal is to generate values that are more likely to be accepted by
|
|
10
|
+
* real-world tools, rather than random strings that get rejected.
|
|
11
|
+
*/
|
|
12
|
+
// ==================== Configuration Constants ====================
|
|
13
|
+
/**
|
|
14
|
+
* Pattern matchers for detecting date/time formats.
|
|
15
|
+
*/
|
|
16
|
+
export const DATE_TIME_PATTERNS = {
|
|
17
|
+
/** Field name patterns that suggest date fields */
|
|
18
|
+
FIELD_NAME: [
|
|
19
|
+
/date$/i, // end_date, start_date
|
|
20
|
+
/_at$/i, // created_at, updated_at
|
|
21
|
+
/_on$/i, // posted_on, modified_on
|
|
22
|
+
/timestamp$/i, // created_timestamp
|
|
23
|
+
/^date$/i, // date
|
|
24
|
+
/birth/i, // birthdate
|
|
25
|
+
/expir/i, // expiration, expiry
|
|
26
|
+
/when$/i, // when
|
|
27
|
+
],
|
|
28
|
+
/** Description patterns that suggest date formats */
|
|
29
|
+
DESCRIPTION: [
|
|
30
|
+
/YYYY-MM-DD/i,
|
|
31
|
+
/ISO\s*8601/i,
|
|
32
|
+
/date\s*format/i,
|
|
33
|
+
/unix\s*timestamp/i,
|
|
34
|
+
/epoch\s*time/i,
|
|
35
|
+
/date\s*string/i,
|
|
36
|
+
],
|
|
37
|
+
/** Default date value if format not specified */
|
|
38
|
+
DEFAULT_DATE: '2024-01-15',
|
|
39
|
+
DEFAULT_DATETIME: '2024-01-15T14:30:00Z',
|
|
40
|
+
DEFAULT_TIME: '14:30:00',
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Pattern matchers for detecting email fields.
|
|
44
|
+
*/
|
|
45
|
+
export const EMAIL_PATTERNS = {
|
|
46
|
+
/** Field name patterns */
|
|
47
|
+
FIELD_NAME: [
|
|
48
|
+
/email$/i,
|
|
49
|
+
/e-mail/i,
|
|
50
|
+
/mail$/i,
|
|
51
|
+
],
|
|
52
|
+
/** Description patterns */
|
|
53
|
+
DESCRIPTION: [
|
|
54
|
+
/email\s*address/i,
|
|
55
|
+
/e-mail/i,
|
|
56
|
+
/valid.*email/i,
|
|
57
|
+
],
|
|
58
|
+
/** Default email value */
|
|
59
|
+
DEFAULT: 'test@example.com',
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Pattern matchers for detecting URL fields.
|
|
63
|
+
*/
|
|
64
|
+
export const URL_PATTERNS = {
|
|
65
|
+
/** Field name patterns */
|
|
66
|
+
FIELD_NAME: [
|
|
67
|
+
/url$/i,
|
|
68
|
+
/uri$/i,
|
|
69
|
+
/link$/i,
|
|
70
|
+
/href$/i,
|
|
71
|
+
/endpoint$/i,
|
|
72
|
+
/callback$/i,
|
|
73
|
+
/redirect$/i,
|
|
74
|
+
/webhook$/i,
|
|
75
|
+
],
|
|
76
|
+
/** Description patterns */
|
|
77
|
+
DESCRIPTION: [
|
|
78
|
+
/URL/i,
|
|
79
|
+
/URI/i,
|
|
80
|
+
/http.*link/i,
|
|
81
|
+
/web\s*address/i,
|
|
82
|
+
],
|
|
83
|
+
/** Default URL value */
|
|
84
|
+
DEFAULT: 'https://example.com',
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Pattern matchers for detecting ID fields.
|
|
88
|
+
*/
|
|
89
|
+
export const ID_PATTERNS = {
|
|
90
|
+
/** Field name patterns */
|
|
91
|
+
FIELD_NAME: [
|
|
92
|
+
/^id$/i,
|
|
93
|
+
/_id$/i,
|
|
94
|
+
/Id$/, // camelCase: userId
|
|
95
|
+
/uuid$/i,
|
|
96
|
+
/guid$/i,
|
|
97
|
+
],
|
|
98
|
+
/** Description patterns */
|
|
99
|
+
DESCRIPTION: [
|
|
100
|
+
/unique\s*identifier/i,
|
|
101
|
+
/UUID/i,
|
|
102
|
+
/GUID/i,
|
|
103
|
+
],
|
|
104
|
+
/** Default ID value */
|
|
105
|
+
DEFAULT: 'test-id-123',
|
|
106
|
+
DEFAULT_UUID: '550e8400-e29b-41d4-a716-446655440000',
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Pattern matchers for detecting phone fields.
|
|
110
|
+
*/
|
|
111
|
+
export const PHONE_PATTERNS = {
|
|
112
|
+
/** Field name patterns */
|
|
113
|
+
FIELD_NAME: [
|
|
114
|
+
/phone$/i,
|
|
115
|
+
/mobile$/i,
|
|
116
|
+
/tel$/i,
|
|
117
|
+
/telephone$/i,
|
|
118
|
+
/cell$/i,
|
|
119
|
+
/fax$/i,
|
|
120
|
+
],
|
|
121
|
+
/** Description patterns */
|
|
122
|
+
DESCRIPTION: [
|
|
123
|
+
/phone\s*number/i,
|
|
124
|
+
/telephone/i,
|
|
125
|
+
/mobile\s*number/i,
|
|
126
|
+
],
|
|
127
|
+
/** Default phone value */
|
|
128
|
+
DEFAULT: '+1-555-123-4567',
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Pattern matchers for detecting monetary/amount fields.
|
|
132
|
+
*/
|
|
133
|
+
export const AMOUNT_PATTERNS = {
|
|
134
|
+
/** Field name patterns */
|
|
135
|
+
FIELD_NAME: [
|
|
136
|
+
/amount$/i,
|
|
137
|
+
/price$/i,
|
|
138
|
+
/cost$/i,
|
|
139
|
+
/total$/i,
|
|
140
|
+
/balance$/i,
|
|
141
|
+
/fee$/i,
|
|
142
|
+
],
|
|
143
|
+
/** Description patterns */
|
|
144
|
+
DESCRIPTION: [
|
|
145
|
+
/amount/i,
|
|
146
|
+
/currency/i,
|
|
147
|
+
/dollar/i,
|
|
148
|
+
/price/i,
|
|
149
|
+
/USD|EUR|GBP/i,
|
|
150
|
+
],
|
|
151
|
+
/** Default amount value */
|
|
152
|
+
DEFAULT: '100.00',
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Pattern matchers for detecting month fields.
|
|
156
|
+
*/
|
|
157
|
+
export const MONTH_PATTERNS = {
|
|
158
|
+
/** Field name patterns */
|
|
159
|
+
FIELD_NAME: [
|
|
160
|
+
/month$/i,
|
|
161
|
+
/_month$/i,
|
|
162
|
+
],
|
|
163
|
+
/** Description patterns */
|
|
164
|
+
DESCRIPTION: [
|
|
165
|
+
/month/i,
|
|
166
|
+
/january|february|march|april|may|june|july|august|september|october|november|december/i,
|
|
167
|
+
],
|
|
168
|
+
/** Valid month names */
|
|
169
|
+
VALID_VALUES: [
|
|
170
|
+
'january', 'february', 'march', 'april', 'may', 'june',
|
|
171
|
+
'july', 'august', 'september', 'october', 'november', 'december',
|
|
172
|
+
],
|
|
173
|
+
/** Default month value */
|
|
174
|
+
DEFAULT: 'january',
|
|
175
|
+
DEFAULT_NUMERIC: '01',
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* Pattern matchers for detecting year fields.
|
|
179
|
+
*/
|
|
180
|
+
export const YEAR_PATTERNS = {
|
|
181
|
+
/** Field name patterns */
|
|
182
|
+
FIELD_NAME: [
|
|
183
|
+
/year$/i,
|
|
184
|
+
/_year$/i,
|
|
185
|
+
],
|
|
186
|
+
/** Description patterns */
|
|
187
|
+
DESCRIPTION: [
|
|
188
|
+
/\byear\b/i,
|
|
189
|
+
/YYYY/i,
|
|
190
|
+
],
|
|
191
|
+
/** Default year value */
|
|
192
|
+
DEFAULT: '2024',
|
|
193
|
+
};
|
|
194
|
+
// ==================== Helper Functions ====================
|
|
195
|
+
/**
|
|
196
|
+
* Test if a string matches any pattern in a list.
|
|
197
|
+
*/
|
|
198
|
+
function matchesAny(str, patterns) {
|
|
199
|
+
return patterns.some(pattern => pattern.test(str));
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Get the primary type from a schema property.
|
|
203
|
+
*/
|
|
204
|
+
function getPrimaryType(schema) {
|
|
205
|
+
if (Array.isArray(schema.type)) {
|
|
206
|
+
return schema.type.find((t) => t !== 'null') ?? schema.type[0];
|
|
207
|
+
}
|
|
208
|
+
return schema.type;
|
|
209
|
+
}
|
|
210
|
+
// ==================== Smart Value Generation ====================
|
|
211
|
+
/**
|
|
212
|
+
* Generate a smart string value based on field name, description, and schema.
|
|
213
|
+
*/
|
|
214
|
+
export function generateSmartStringValue(propName, prop) {
|
|
215
|
+
const lowerName = propName.toLowerCase();
|
|
216
|
+
const description = prop.description ?? '';
|
|
217
|
+
// Priority 1: Check schema format field (JSON Schema standard)
|
|
218
|
+
if (prop.format) {
|
|
219
|
+
const formatValue = getValueForFormat(prop.format);
|
|
220
|
+
if (formatValue !== null) {
|
|
221
|
+
return {
|
|
222
|
+
value: formatValue.value,
|
|
223
|
+
semanticType: formatValue.type,
|
|
224
|
+
confidence: 'high',
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
// Priority 2: Check for enum values - use first valid enum
|
|
229
|
+
if (prop.enum && prop.enum.length > 0) {
|
|
230
|
+
return {
|
|
231
|
+
value: prop.enum[0],
|
|
232
|
+
semanticType: 'enum',
|
|
233
|
+
confidence: 'high',
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
// Priority 3: Check for example values
|
|
237
|
+
if (prop.examples && prop.examples.length > 0) {
|
|
238
|
+
return {
|
|
239
|
+
value: prop.examples[0],
|
|
240
|
+
semanticType: 'example',
|
|
241
|
+
confidence: 'high',
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
// Priority 4: Detect semantic type from field name and description
|
|
245
|
+
const detected = detectSemanticType(lowerName, description, propName);
|
|
246
|
+
if (detected) {
|
|
247
|
+
return detected;
|
|
248
|
+
}
|
|
249
|
+
// Priority 5: Default fallback
|
|
250
|
+
return {
|
|
251
|
+
value: 'test',
|
|
252
|
+
semanticType: null,
|
|
253
|
+
confidence: 'low',
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Get a value for a JSON Schema format field.
|
|
258
|
+
*/
|
|
259
|
+
function getValueForFormat(format) {
|
|
260
|
+
switch (format) {
|
|
261
|
+
case 'date':
|
|
262
|
+
return { value: DATE_TIME_PATTERNS.DEFAULT_DATE, type: 'date' };
|
|
263
|
+
case 'date-time':
|
|
264
|
+
return { value: DATE_TIME_PATTERNS.DEFAULT_DATETIME, type: 'datetime' };
|
|
265
|
+
case 'time':
|
|
266
|
+
return { value: DATE_TIME_PATTERNS.DEFAULT_TIME, type: 'time' };
|
|
267
|
+
case 'email':
|
|
268
|
+
return { value: EMAIL_PATTERNS.DEFAULT, type: 'email' };
|
|
269
|
+
case 'uri':
|
|
270
|
+
case 'url':
|
|
271
|
+
return { value: URL_PATTERNS.DEFAULT, type: 'url' };
|
|
272
|
+
case 'uuid':
|
|
273
|
+
return { value: ID_PATTERNS.DEFAULT_UUID, type: 'uuid' };
|
|
274
|
+
case 'ipv4':
|
|
275
|
+
return { value: '192.168.1.100', type: 'ipv4' };
|
|
276
|
+
case 'hostname':
|
|
277
|
+
return { value: 'example.com', type: 'hostname' };
|
|
278
|
+
default:
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Detect semantic type from field name and description.
|
|
284
|
+
*/
|
|
285
|
+
function detectSemanticType(lowerName, description, originalName) {
|
|
286
|
+
// Check for date/time patterns
|
|
287
|
+
if (matchesAny(lowerName, DATE_TIME_PATTERNS.FIELD_NAME) ||
|
|
288
|
+
matchesAny(description, DATE_TIME_PATTERNS.DESCRIPTION)) {
|
|
289
|
+
return {
|
|
290
|
+
value: DATE_TIME_PATTERNS.DEFAULT_DATE,
|
|
291
|
+
semanticType: 'date',
|
|
292
|
+
confidence: 'medium',
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
// Check for email patterns
|
|
296
|
+
if (matchesAny(lowerName, EMAIL_PATTERNS.FIELD_NAME) ||
|
|
297
|
+
matchesAny(description, EMAIL_PATTERNS.DESCRIPTION)) {
|
|
298
|
+
return {
|
|
299
|
+
value: EMAIL_PATTERNS.DEFAULT,
|
|
300
|
+
semanticType: 'email',
|
|
301
|
+
confidence: 'medium',
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
// Check for URL patterns
|
|
305
|
+
if (matchesAny(lowerName, URL_PATTERNS.FIELD_NAME) ||
|
|
306
|
+
matchesAny(description, URL_PATTERNS.DESCRIPTION)) {
|
|
307
|
+
return {
|
|
308
|
+
value: URL_PATTERNS.DEFAULT,
|
|
309
|
+
semanticType: 'url',
|
|
310
|
+
confidence: 'medium',
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
// Check for phone patterns
|
|
314
|
+
if (matchesAny(lowerName, PHONE_PATTERNS.FIELD_NAME) ||
|
|
315
|
+
matchesAny(description, PHONE_PATTERNS.DESCRIPTION)) {
|
|
316
|
+
return {
|
|
317
|
+
value: PHONE_PATTERNS.DEFAULT,
|
|
318
|
+
semanticType: 'phone',
|
|
319
|
+
confidence: 'medium',
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
// Check for ID patterns (including camelCase like userId)
|
|
323
|
+
if (matchesAny(lowerName, ID_PATTERNS.FIELD_NAME) ||
|
|
324
|
+
matchesAny(originalName, ID_PATTERNS.FIELD_NAME) ||
|
|
325
|
+
matchesAny(description, ID_PATTERNS.DESCRIPTION)) {
|
|
326
|
+
// If description mentions UUID, use UUID format
|
|
327
|
+
if (/uuid|guid/i.test(description)) {
|
|
328
|
+
return {
|
|
329
|
+
value: ID_PATTERNS.DEFAULT_UUID,
|
|
330
|
+
semanticType: 'uuid',
|
|
331
|
+
confidence: 'medium',
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
return {
|
|
335
|
+
value: ID_PATTERNS.DEFAULT,
|
|
336
|
+
semanticType: 'id',
|
|
337
|
+
confidence: 'medium',
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
// Check for amount/currency patterns
|
|
341
|
+
if (matchesAny(lowerName, AMOUNT_PATTERNS.FIELD_NAME) ||
|
|
342
|
+
matchesAny(description, AMOUNT_PATTERNS.DESCRIPTION)) {
|
|
343
|
+
return {
|
|
344
|
+
value: AMOUNT_PATTERNS.DEFAULT,
|
|
345
|
+
semanticType: 'amount',
|
|
346
|
+
confidence: 'medium',
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
// Check for month patterns
|
|
350
|
+
if (matchesAny(lowerName, MONTH_PATTERNS.FIELD_NAME) ||
|
|
351
|
+
matchesAny(description, MONTH_PATTERNS.DESCRIPTION)) {
|
|
352
|
+
return {
|
|
353
|
+
value: MONTH_PATTERNS.DEFAULT,
|
|
354
|
+
semanticType: 'month',
|
|
355
|
+
confidence: 'medium',
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
// Check for year patterns
|
|
359
|
+
if (matchesAny(lowerName, YEAR_PATTERNS.FIELD_NAME) ||
|
|
360
|
+
matchesAny(description, YEAR_PATTERNS.DESCRIPTION)) {
|
|
361
|
+
return {
|
|
362
|
+
value: YEAR_PATTERNS.DEFAULT,
|
|
363
|
+
semanticType: 'year',
|
|
364
|
+
confidence: 'medium',
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
// Check for common field name patterns
|
|
368
|
+
if (lowerName.includes('name')) {
|
|
369
|
+
return {
|
|
370
|
+
value: 'test-name',
|
|
371
|
+
semanticType: 'name',
|
|
372
|
+
confidence: 'low',
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
if (lowerName.includes('path') || lowerName.includes('directory')) {
|
|
376
|
+
return {
|
|
377
|
+
value: '/tmp/test',
|
|
378
|
+
semanticType: 'path',
|
|
379
|
+
confidence: 'low',
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
if (lowerName.includes('query') || lowerName.includes('search')) {
|
|
383
|
+
return {
|
|
384
|
+
value: 'test query',
|
|
385
|
+
semanticType: 'search_query',
|
|
386
|
+
confidence: 'low',
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
if (lowerName.includes('token') || lowerName.includes('key') || lowerName.includes('secret')) {
|
|
390
|
+
return {
|
|
391
|
+
value: 'test-token-abc123',
|
|
392
|
+
semanticType: 'token',
|
|
393
|
+
confidence: 'low',
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
if (lowerName.includes('account')) {
|
|
397
|
+
return {
|
|
398
|
+
value: 'test-account-123',
|
|
399
|
+
semanticType: 'account',
|
|
400
|
+
confidence: 'low',
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
if (lowerName.includes('category')) {
|
|
404
|
+
return {
|
|
405
|
+
value: 'test-category',
|
|
406
|
+
semanticType: 'category',
|
|
407
|
+
confidence: 'low',
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
return null;
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Generate a smart number value based on schema constraints.
|
|
414
|
+
*/
|
|
415
|
+
export function generateSmartNumberValue(prop) {
|
|
416
|
+
const type = getPrimaryType(prop);
|
|
417
|
+
const isInteger = type === 'integer';
|
|
418
|
+
// Use example if available
|
|
419
|
+
if (prop.examples && prop.examples.length > 0) {
|
|
420
|
+
return {
|
|
421
|
+
value: prop.examples[0],
|
|
422
|
+
semanticType: 'example',
|
|
423
|
+
confidence: 'high',
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
// Use default if available
|
|
427
|
+
if (prop.default !== undefined) {
|
|
428
|
+
return {
|
|
429
|
+
value: prop.default,
|
|
430
|
+
semanticType: 'default',
|
|
431
|
+
confidence: 'high',
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
const min = prop.minimum ?? 0;
|
|
435
|
+
const max = prop.maximum ?? (min + 100);
|
|
436
|
+
// Calculate a value in the valid range
|
|
437
|
+
let value = Math.floor((min + max) / 2);
|
|
438
|
+
if (!isInteger) {
|
|
439
|
+
value = Math.round(((min + max) / 2) * 100) / 100;
|
|
440
|
+
}
|
|
441
|
+
return {
|
|
442
|
+
value,
|
|
443
|
+
semanticType: isInteger ? 'integer' : 'number',
|
|
444
|
+
confidence: 'low',
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Generate a complete smart value for any type.
|
|
449
|
+
*/
|
|
450
|
+
export function generateSmartValue(propName, prop) {
|
|
451
|
+
const type = getPrimaryType(prop);
|
|
452
|
+
// Use default if available
|
|
453
|
+
if (prop.default !== undefined) {
|
|
454
|
+
return {
|
|
455
|
+
value: prop.default,
|
|
456
|
+
semanticType: 'default',
|
|
457
|
+
confidence: 'high',
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
// Use first example if available
|
|
461
|
+
if (prop.examples && prop.examples.length > 0) {
|
|
462
|
+
return {
|
|
463
|
+
value: prop.examples[0],
|
|
464
|
+
semanticType: 'example',
|
|
465
|
+
confidence: 'high',
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
// Use first enum value if available
|
|
469
|
+
if (prop.enum && prop.enum.length > 0) {
|
|
470
|
+
return {
|
|
471
|
+
value: prop.enum[0],
|
|
472
|
+
semanticType: 'enum',
|
|
473
|
+
confidence: 'high',
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
// Use const if available
|
|
477
|
+
if (prop.const !== undefined) {
|
|
478
|
+
return {
|
|
479
|
+
value: prop.const,
|
|
480
|
+
semanticType: 'const',
|
|
481
|
+
confidence: 'high',
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
switch (type) {
|
|
485
|
+
case 'string':
|
|
486
|
+
return generateSmartStringValue(propName, prop);
|
|
487
|
+
case 'number':
|
|
488
|
+
case 'integer':
|
|
489
|
+
return generateSmartNumberValue(prop);
|
|
490
|
+
case 'boolean':
|
|
491
|
+
return { value: true, semanticType: 'boolean', confidence: 'high' };
|
|
492
|
+
case 'array':
|
|
493
|
+
return { value: [], semanticType: 'array', confidence: 'low' };
|
|
494
|
+
case 'object':
|
|
495
|
+
return { value: {}, semanticType: 'object', confidence: 'low' };
|
|
496
|
+
default:
|
|
497
|
+
return { value: 'test', semanticType: null, confidence: 'low' };
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Generate multiple alternative values for a field (for varied testing).
|
|
502
|
+
*/
|
|
503
|
+
export function generateAlternativeValues(propName, prop, count = 3) {
|
|
504
|
+
const results = [];
|
|
505
|
+
const type = getPrimaryType(prop);
|
|
506
|
+
// If enum, return different enum values
|
|
507
|
+
if (prop.enum && prop.enum.length > 1) {
|
|
508
|
+
for (let i = 0; i < Math.min(count, prop.enum.length); i++) {
|
|
509
|
+
results.push({
|
|
510
|
+
value: prop.enum[i],
|
|
511
|
+
semanticType: 'enum',
|
|
512
|
+
confidence: 'high',
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
return results;
|
|
516
|
+
}
|
|
517
|
+
// Generate alternatives based on type
|
|
518
|
+
if (type === 'string') {
|
|
519
|
+
const base = generateSmartStringValue(propName, prop);
|
|
520
|
+
results.push(base);
|
|
521
|
+
// Generate variations based on semantic type
|
|
522
|
+
if (base.semanticType === 'date') {
|
|
523
|
+
results.push({ value: '2024-06-30', semanticType: 'date', confidence: 'medium' });
|
|
524
|
+
results.push({ value: '2024-12-31', semanticType: 'date', confidence: 'medium' });
|
|
525
|
+
}
|
|
526
|
+
else if (base.semanticType === 'email') {
|
|
527
|
+
results.push({ value: 'user@test.com', semanticType: 'email', confidence: 'medium' });
|
|
528
|
+
results.push({ value: 'admin@example.org', semanticType: 'email', confidence: 'medium' });
|
|
529
|
+
}
|
|
530
|
+
else if (base.semanticType === 'id') {
|
|
531
|
+
results.push({ value: 'test-id-456', semanticType: 'id', confidence: 'medium' });
|
|
532
|
+
results.push({ value: 'test-id-789', semanticType: 'id', confidence: 'medium' });
|
|
533
|
+
}
|
|
534
|
+
else {
|
|
535
|
+
results.push({ value: 'alternative-1', semanticType: null, confidence: 'low' });
|
|
536
|
+
results.push({ value: 'alternative-2', semanticType: null, confidence: 'low' });
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
else if (type === 'number' || type === 'integer') {
|
|
540
|
+
const min = prop.minimum ?? 0;
|
|
541
|
+
const max = prop.maximum ?? 100;
|
|
542
|
+
const step = (max - min) / (count + 1);
|
|
543
|
+
for (let i = 1; i <= count; i++) {
|
|
544
|
+
const value = type === 'integer' ? Math.floor(min + step * i) : min + step * i;
|
|
545
|
+
results.push({ value, semanticType: type, confidence: 'medium' });
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
else if (type === 'boolean') {
|
|
549
|
+
results.push({ value: true, semanticType: 'boolean', confidence: 'high' });
|
|
550
|
+
results.push({ value: false, semanticType: 'boolean', confidence: 'high' });
|
|
551
|
+
}
|
|
552
|
+
return results.slice(0, count);
|
|
553
|
+
}
|
|
554
|
+
//# sourceMappingURL=smart-value-generator.js.map
|