vouchington-tooling 0.35.0 → 0.36.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/README.md +24 -221
- package/dist/agent-blackboard/feedback-audit-source.mjs +2 -2
- package/dist/agent-blackboard/feedback-canonical.mjs +1 -1
- package/dist/agent-blackboard/feedback-codec.mjs +3 -3
- package/dist/agent-blackboard/feedback-compose.mjs +5 -5
- package/dist/agent-blackboard/feedback-deadline.mjs +1 -1
- package/dist/agent-blackboard/feedback-delivery.mjs +6 -6
- package/dist/agent-blackboard/feedback-fields.mjs +1 -1
- package/dist/agent-blackboard/feedback-identity.mjs +3 -3
- package/dist/agent-blackboard/feedback-journal-audit.mjs +4 -4
- package/dist/agent-blackboard/feedback-journal-sandbox.mjs +1 -1
- package/dist/agent-blackboard/feedback-online-error.mjs +1 -1
- package/dist/agent-blackboard/feedback-online.mjs +7 -7
- package/dist/agent-blackboard/feedback-outbox-counts.mjs +2 -2
- package/dist/agent-blackboard/feedback-outbox.mjs +7 -7
- package/dist/agent-blackboard/index.mjs +13 -13
- package/dist/agent-blackboard/journal.mjs +3 -3
- package/dist/agent-blackboard/session-tools.mjs +4 -4
- package/dist/agent-blackboard/snapshot-cleanup-directory.mjs +3 -3
- package/dist/agent-blackboard/snapshot-cleanup-receipt.mjs +1 -1
- package/dist/agent-blackboard/snapshot-cleanup-resume.mjs +2 -2
- package/dist/agent-blackboard/snapshot-partition-cleanup.mjs +3 -3
- package/dist/agent-blackboard/snapshot-partition-format.mjs +3 -3
- package/dist/agent-blackboard/snapshot-partition-predicates.mjs +2 -2
- package/dist/agent-blackboard/snapshot-partition-read.mjs +2 -2
- package/dist/agent-blackboard/snapshot-partition-validate.mjs +2 -2
- package/dist/agent-blackboard/snapshot-partition-write.mjs +2 -2
- package/dist/agent-blackboard/snapshot-partitions.mjs +4 -4
- package/dist/agent-blackboard/snapshot.mjs +2 -2
- package/dist/agent-harness-identity/index.d.mts +1 -1
- package/dist/api-fixtures/fixture-contract-validation.mjs +1 -1
- package/dist/api-fixtures/index.mjs +3 -3
- package/dist/ast-grep-examples/companion-parity.mjs +1 -1
- package/dist/ast-grep-examples/index.mjs +1 -1
- package/dist/basic-auth-doc-sync/index.mjs +2 -2
- package/dist/basic-auth-doc-sync/runbook.mjs +4 -4
- package/dist/basic-auth-doc-sync/source.mjs +2 -2
- package/dist/browser-session-runner/attempt.mjs +5 -5
- package/dist/browser-session-runner/index.mjs +4 -4
- package/dist/browser-session-runner/output.mjs +1 -1
- package/dist/ci-local/index.mjs +2 -2
- package/dist/cli/commands/agent-blackboard-flags.mjs +1 -1
- package/dist/cli/commands/agent-blackboard.mjs +3 -3
- package/dist/cli/commands/ast-grep-examples.mjs +1 -1
- package/dist/cli/commands/ast-grep-pack.mjs +1 -1
- package/dist/cli/commands/gha-artifacts-cleanup.mjs +1 -1
- package/dist/cli/commands/gha-runtime-audit.mjs +1 -1
- package/dist/cli/commands/gha-workspace-policy.mjs +2 -2
- package/dist/cli/commands/http-origin.mjs +1 -1
- package/dist/cli/commands/link-skill.mjs +1 -1
- package/dist/cli/commands/mcp.mjs +2 -2
- package/dist/cli/commands/nuget-central-version.mjs +1 -1
- package/dist/cli/commands/pnpm-install.mjs +1 -1
- package/dist/cli/commands/prepare-vitest-reports.mjs +1 -1
- package/dist/cli/commands/require-up-to-date.mjs +1 -1
- package/dist/cli/commands/retrospective-facts.mjs +1 -1
- package/dist/cli/commands/retrospective-transcript.mjs +1 -1
- package/dist/cli/commands/runner-port-policy.mjs +1 -1
- package/dist/cli/commands/vitest-blob-manifest.mjs +1 -1
- package/dist/cli/commands/vitest-report-attempt.mjs +1 -1
- package/dist/cli/index.mjs +27 -27
- package/dist/cli/installed-version.mjs +1 -1
- package/dist/cli/parse-gha-runtime-audit.mjs +1 -1
- package/dist/cli/parse-options.mjs +2 -2
- package/dist/cli/parse.mjs +5 -5
- package/dist/compiler-build/index.mjs +3 -3
- package/dist/compiler-build/program.mjs +3 -3
- package/dist/config-inventory/collect.mjs +5 -5
- package/dist/config-inventory/dynamic-configs.mjs +1 -1
- package/dist/config-inventory/env-expression-readers.mjs +1 -1
- package/dist/config-inventory/env-prefix-readers.mjs +2 -2
- package/dist/config-inventory/env-var-accumulator.mjs +1 -1
- package/dist/config-inventory/env-vars.mjs +5 -5
- package/dist/config-inventory/index.mjs +2 -2
- package/dist/contract-schema/contract-schema-bounded-array.mjs +2 -2
- package/dist/contract-schema/contract-schema-extractor.mjs +3 -3
- package/dist/contract-schema/contract-schema-object-tuple.mjs +2 -2
- package/dist/contract-schema/contract-schema-type-extractor.mjs +5 -5
- package/dist/contract-schema/contract-schema-type-utils.mjs +2 -2
- package/dist/contract-schema/contract-schema-validator.mjs +1 -1
- package/dist/contract-schema/index.mjs +7 -7
- package/dist/contract-schema/type-query-call.mjs +3 -3
- package/dist/contract-schema/type-query.mjs +2 -2
- package/dist/contract-schema/virtual-program.mjs +1 -1
- package/dist/coverage-transport/control-v2-parse-object.mjs +2 -2
- package/dist/coverage-transport/control-v2.mjs +4 -4
- package/dist/coverage-transport/control.mjs +2 -2
- package/dist/coverage-transport/discovery.mjs +4 -4
- package/dist/coverage-transport/http.mjs +1 -1
- package/dist/coverage-transport/index.mjs +10 -10
- package/dist/coverage-transport/keys.mjs +1 -1
- package/dist/coverage-transport/lib.mjs +6 -6
- package/dist/coverage-transport/prefix-transfer.mjs +4 -4
- package/dist/coverage-transport/prefix.mjs +3 -3
- package/dist/coverage-transport/presign.mjs +1 -1
- package/dist/coverage-transport/vitest-blob-transport.mjs +2 -2
- package/dist/dependency-license-policy/collect.mjs +5 -5
- package/dist/dependency-license-policy/index.mjs +3 -3
- package/dist/dependency-license-policy/policy.mjs +1 -1
- package/dist/dependency-license-policy/workspace.mjs +1 -1
- package/dist/dockerfile-parse/index.mjs +2 -2
- package/dist/dockerfile-parse/prewarm-ports.mjs +1 -1
- package/dist/dockerfile-parse/runtime-cmd.mjs +2 -2
- package/dist/finite-enum-ripple/check.mjs +3 -3
- package/dist/finite-enum-ripple/compare.mjs +2 -2
- package/dist/finite-enum-ripple/component-paths.mjs +2 -2
- package/dist/finite-enum-ripple/configured-object-mutations.mjs +1 -1
- package/dist/finite-enum-ripple/create-page-jsx.mjs +1 -1
- package/dist/finite-enum-ripple/create-page-literals.mjs +4 -4
- package/dist/finite-enum-ripple/create-page-object-visitor.mjs +2 -2
- package/dist/finite-enum-ripple/create-page-properties.mjs +1 -1
- package/dist/finite-enum-ripple/index.mjs +1 -1
- package/dist/finite-enum-ripple/parser-support.mjs +2 -2
- package/dist/finite-enum-ripple/parsers.mjs +3 -3
- package/dist/finite-enum-ripple/structured-route-check.mjs +4 -4
- package/dist/finite-enum-ripple/types.mjs +3 -3
- package/dist/finite-enum-ripple/union-factory-check.mjs +2 -2
- package/dist/finite-enum-ripple/union-types.mjs +4 -4
- package/dist/gh-api-shell-quoting/index.mjs +2 -2
- package/dist/gh-api-shell-quoting/logical-line.mjs +1 -1
- package/dist/gh-api-shell-quoting/scan.mjs +1 -1
- package/dist/gh-api-shell-quoting/yaml.mjs +1 -1
- package/dist/gh-cli/index.mjs +4 -4
- package/dist/gha-artifacts-cleanup/commands.mjs +2 -2
- package/dist/gha-artifacts-cleanup/index.mjs +4 -4
- package/dist/gha-check-run/cli.mjs +2 -2
- package/dist/gha-check-run/index.mjs +2 -2
- package/dist/gha-claude-post-review/index.mjs +2 -2
- package/dist/gha-post-review/claude-token.d.mts +2 -2
- package/dist/gha-post-review/claude-token.mjs +1 -1
- package/dist/gha-post-review/cli.mjs +1 -1
- package/dist/gha-post-review/github.mjs +7 -7
- package/dist/gha-post-review/index.mjs +6 -6
- package/dist/gha-post-review/post.mjs +2 -2
- package/dist/gha-post-review/pull-io.mjs +1 -1
- package/dist/gha-post-review/token.mjs +1 -1
- package/dist/gha-pr-checkpoint/index.mjs +3 -3
- package/dist/gha-pr-checkpoint/resume.mjs +1 -1
- package/dist/gha-pr-checkpoint/update.mjs +1 -1
- package/dist/gha-review-payload/cli.mjs +2 -2
- package/dist/gha-review-payload/file.mjs +1 -1
- package/dist/gha-review-payload/index.mjs +4 -4
- package/dist/gha-review-payload/remap.mjs +1 -1
- package/dist/gha-runtime-audit/audit.mjs +4 -4
- package/dist/gha-runtime-audit/index.mjs +3 -3
- package/dist/gha-workspace-policy/docker-options.mjs +1 -1
- package/dist/gha-workspace-policy/docker-workspace-user.mjs +2 -2
- package/dist/gha-workspace-policy/index.mjs +3 -3
- package/dist/gha-workspace-policy/shell-tokens.mjs +1 -1
- package/dist/gha-workspace-policy/sparse-checkout.mjs +1 -1
- package/dist/github-projects/index.mjs +2 -2
- package/dist/github-projects/project-audit.mjs +1 -1
- package/dist/index.mjs +55 -55
- package/dist/markdown/content-facts.mjs +1 -1
- package/dist/markdown/document-sections.mjs +2 -2
- package/dist/markdown/html-blocks.mjs +1 -1
- package/dist/markdown/index.mjs +10 -10
- package/dist/markdown/sections.mjs +2 -2
- package/dist/markdown/tables.mjs +2 -2
- package/dist/markdown/tasks.mjs +1 -1
- package/dist/mcp-server/context.mjs +2 -2
- package/dist/mcp-server/dispatch.mjs +8 -8
- package/dist/mcp-server/git-fixture.test-helpers.mjs +1 -1
- package/dist/mcp-server/handlers-journal.mjs +4 -4
- package/dist/mcp-server/handlers-outbox.mjs +2 -2
- package/dist/mcp-server/handlers-session.mjs +3 -3
- package/dist/mcp-server/harness.test-helpers.mjs +4 -4
- package/dist/mcp-server/main.mjs +1 -1
- package/dist/mcp-server/run.mjs +3 -3
- package/dist/mcp-server/sdk.mjs +1 -1
- package/dist/mcp-server/server.mjs +2 -2
- package/dist/mcp-server/worktree.mjs +2 -2
- package/dist/nuget-central-version/cli.mjs +1 -1
- package/dist/openapi-document/build-openapi-catalog-sse.mjs +1 -1
- package/dist/openapi-document/build-openapi-document.mjs +8 -8
- package/dist/openapi-document/build-openapi-request.mjs +1 -1
- package/dist/openapi-document/build-openapi-response.mjs +3 -3
- package/dist/openapi-document/build-openapi-sse-events.mjs +1 -1
- package/dist/openapi-document/component-registry.mjs +1 -1
- package/dist/openapi-document/contract-schema-intersection-merge.mjs +1 -1
- package/dist/openapi-document/contract-schema-to-openapi.mjs +1 -1
- package/dist/openapi-document/index.mjs +12 -12
- package/dist/openapi-document/openapi-route-helpers.mjs +1 -1
- package/dist/pg-schema-snapshot/build-snapshot.mjs +3 -3
- package/dist/pg-schema-snapshot/catalog-objects.mjs +1 -1
- package/dist/pg-schema-snapshot/catalog-queries.mjs +4 -4
- package/dist/pg-schema-snapshot/catalog-table-constraints.mjs +1 -1
- package/dist/pg-schema-snapshot/catalog-table-indexes.mjs +1 -1
- package/dist/pg-schema-snapshot/catalog-tables.mjs +1 -1
- package/dist/pg-schema-snapshot/generate.mjs +5 -5
- package/dist/pg-schema-snapshot/index.mjs +6 -6
- package/dist/pg-schema-snapshot/markdown-files.mjs +1 -1
- package/dist/pg-schema-snapshot/render-markdown.mjs +1 -1
- package/dist/pg-schema-snapshot/table-snapshot-constraints.mjs +1 -1
- package/dist/pg-schema-snapshot/table-snapshot.mjs +3 -3
- package/dist/pnpm-deploy/index.mjs +3 -3
- package/dist/pnpm-deploy/restore.mjs +1 -1
- package/dist/pnpm-install/exec.mjs +1 -1
- package/dist/pnpm-install/index.mjs +8 -8
- package/dist/pnpm-install/install-operations.mjs +6 -6
- package/dist/pnpm-install/metadata-legacy.mjs +1 -1
- package/dist/pnpm-install/metadata.d.mts +1 -1
- package/dist/pnpm-install/metadata.mjs +2 -2
- package/dist/pnpm-install/native-health.mjs +2 -2
- package/dist/pnpm-install/pnpm-install-fixture.test-helpers.mjs +2 -2
- package/dist/pnpm-install/runner.mjs +7 -7
- package/dist/post-publication-inventory/index.d.mts +6 -0
- package/dist/post-publication-inventory/index.mjs +6 -2
- package/dist/post-publication-inventory/readers/compose-appends.d.mts +7 -0
- package/dist/post-publication-inventory/readers/compose-appends.mjs +38 -0
- package/dist/post-publication-inventory/readers/composes.d.mts +2 -0
- package/dist/post-publication-inventory/readers/composes.mjs +79 -0
- package/dist/post-publication-inventory/readers/composition.d.mts +2 -0
- package/dist/post-publication-inventory/readers/composition.mjs +62 -0
- package/dist/post-publication-inventory/readers/public-boundary-ast.d.mts +5 -0
- package/dist/post-publication-inventory/readers/public-boundary-ast.mjs +33 -0
- package/dist/post-publication-inventory/readers/public-boundary-consumed.d.mts +3 -0
- package/dist/post-publication-inventory/readers/public-boundary-consumed.mjs +39 -0
- package/dist/post-publication-inventory/readers/public-boundary-dataflow.d.mts +3 -0
- package/dist/post-publication-inventory/readers/public-boundary-dataflow.mjs +61 -0
- package/dist/post-publication-inventory/readers/public-boundary-then.d.mts +9 -0
- package/dist/post-publication-inventory/readers/public-boundary-then.mjs +31 -0
- package/dist/post-publication-inventory/readers/public-boundary.d.mts +3 -0
- package/dist/post-publication-inventory/readers/public-boundary.mjs +71 -0
- package/dist/post-publication-inventory/readers/public-view-ast.d.mts +6 -0
- package/dist/post-publication-inventory/readers/public-view-ast.mjs +67 -0
- package/dist/post-publication-inventory/readers/public-view-options.d.mts +8 -0
- package/dist/post-publication-inventory/readers/public-view-protection.d.mts +2 -0
- package/dist/post-publication-inventory/readers/public-view-protection.mjs +83 -0
- package/dist/post-publication-inventory/readers/public-view.d.mts +2 -0
- package/dist/post-publication-inventory/readers/public-view.mjs +117 -0
- package/dist/post-publication-inventory/readers/source-ast.d.mts +30 -0
- package/dist/post-publication-inventory/readers/source-ast.mjs +52 -0
- package/dist/post-publication-inventory/readers/source-executors.d.mts +4 -0
- package/dist/post-publication-inventory/readers/source-executors.mjs +38 -0
- package/dist/post-publication-inventory/readers/source-helpers.d.mts +16 -0
- package/dist/post-publication-inventory/readers/source-helpers.mjs +72 -0
- package/dist/post-publication-inventory/readers/source-options.d.mts +8 -0
- package/dist/post-publication-inventory/readers/source-sql.d.mts +3 -0
- package/dist/post-publication-inventory/readers/source-sql.mjs +17 -0
- package/dist/post-publication-inventory/readers/sql-executors.mjs +2 -2
- package/dist/post-publication-inventory/readers/sql-source.mjs +3 -3
- package/dist/post-publication-inventory/readers/sql-template.mjs +1 -1
- package/dist/post-publication-inventory/writers/source.mjs +1 -1
- package/dist/retrospective-facts/coverage.mjs +1 -1
- package/dist/retrospective-facts/foreign.mjs +3 -3
- package/dist/retrospective-facts/index.mjs +4 -4
- package/dist/retrospective-facts/local.mjs +4 -4
- package/dist/retrospective-transcript/claude-blocks.mjs +1 -1
- package/dist/retrospective-transcript/claude.mjs +2 -2
- package/dist/retrospective-transcript/codex-messages.mjs +1 -1
- package/dist/retrospective-transcript/codex-payload.mjs +2 -2
- package/dist/retrospective-transcript/codex-records.mjs +3 -3
- package/dist/retrospective-transcript/codex-segment.mjs +1 -1
- package/dist/retrospective-transcript/codex.mjs +2 -2
- package/dist/retrospective-transcript/index.mjs +9 -9
- package/dist/retrospective-transcript/resolve-transcript-file.mjs +2 -2
- package/dist/scc-complexity/baseline.mjs +2 -2
- package/dist/scc-complexity/index.mjs +8 -8
- package/dist/scc-complexity/parser.mjs +1 -1
- package/dist/scc-complexity/scope-config.mjs +1 -1
- package/dist/session-friction/audit-block.mjs +1 -1
- package/dist/session-friction/ci-failures.mjs +2 -2
- package/dist/session-friction/classify.mjs +2 -2
- package/dist/session-friction/coverage-ledger.mjs +1 -1
- package/dist/session-friction/index.mjs +5 -5
- package/dist/session-friction/log-file.mjs +2 -2
- package/dist/session-friction/log.mjs +7 -7
- package/dist/session-friction/normalize.mjs +1 -1
- package/dist/session-friction/report.mjs +5 -5
- package/dist/session-friction/sandbox.mjs +1 -1
- package/dist/session-friction/session-id.mjs +1 -1
- package/dist/shared-context/index.mjs +1 -1
- package/dist/skill-discovery/index.mjs +3 -3
- package/dist/sql-ast/add-column.mjs +1 -1
- package/dist/sql-ast/constraint-do-block.mjs +2 -2
- package/dist/sql-ast/constraint-shared.mjs +1 -1
- package/dist/sql-ast/constraint.mjs +4 -4
- package/dist/sql-ast/create-table.mjs +2 -2
- package/dist/sql-ast/drop-index.mjs +2 -2
- package/dist/sql-ast/implicit-indexes.mjs +1 -1
- package/dist/sql-ast/index-metadata.mjs +3 -3
- package/dist/sql-ast/index.mjs +8 -8
- package/dist/sql-scanner/comments.mjs +1 -1
- package/dist/sql-scanner/index.mjs +3 -3
- package/dist/sql-scanner/literals.mjs +1 -1
- package/dist/swift-semantic-equal/cli.mjs +1 -1
- package/dist/swift-semantic-equal/index.mjs +1 -1
- package/dist/transient-retry/index.mjs +2 -2
- package/dist/vitest-blob-manifest/cli.mjs +2 -2
- package/dist/vitest-blob-manifest/index.mjs +4 -4
- package/dist/vitest-blob-manifest/report-attempt-cli.mjs +2 -2
- package/dist/vitest-blob-manifest/report-attempt.mjs +1 -1
- package/dist/vitest-blob-manifest/reports-cli.mjs +3 -3
- package/dist/vitest-blob-manifest/reports-source.mjs +2 -2
- package/dist/vitest-blob-manifest/reports.mjs +2 -2
- package/dist/vitest-diagnostics/index.mjs +8 -8
- package/dist/vitest-diagnostics/vitest-fork-exit-records.mjs +1 -1
- package/dist/vitest-diagnostics/vitest-fork-exit-sentinel.mjs +2 -2
- package/dist/vitest-diagnostics/vitest-fork-leak-detection.mjs +2 -2
- package/dist/vitest-diagnostics/vitest-worker-exit-diagnostics-reporter.mjs +2 -2
- package/dist/workflow-policy/condition-entailment.mjs +1 -1
- package/dist/workflow-policy/index.mjs +4 -4
- package/dist/workflow-policy/permission-inheritance.mjs +1 -1
- package/dist/workflow-policy/permission-mismatches.mjs +2 -2
- package/dist/workflow-policy/secret-readiness.mjs +2 -2
- package/dist/workspace-gates/first-party-graph.mjs +2 -2
- package/dist/workspace-gates/index.mjs +1 -1
- package/dist/workspace-gates/manifest-version-assertions.mjs +2 -2
- package/dist/workspace-gates/manifest-version-parser.mjs +1 -1
- package/dist/workspace-gates/options.mjs +1 -1
- package/dist/workspace-gates/policy.mjs +7 -7
- package/dist/workspace-gates/test-helpers.d.mts +2 -2
- package/package.json +3 -6
- package/dist/api-contract-discovery/header-contract-parser.d.mts +0 -3
- package/dist/api-contract-discovery/header-contract-parser.mjs +0 -93
- package/dist/api-contract-discovery/header-contract-registry.d.mts +0 -3
- package/dist/api-contract-discovery/header-contract-registry.mjs +0 -40
- package/dist/api-contract-discovery/header-contract-types.d.mts +0 -19
- package/dist/api-contract-discovery/index.d.mts +0 -34
- package/dist/api-contract-discovery/index.mjs +0 -27
- package/dist/api-contract-discovery/protocol-analysis-cache.d.mts +0 -21
- package/dist/api-contract-discovery/protocol-analysis-cache.mjs +0 -7
- package/dist/api-contract-discovery/protocol-body-status.d.mts +0 -2
- package/dist/api-contract-discovery/protocol-body-status.mjs +0 -4
- package/dist/api-contract-discovery/protocol-callback-argument-bindings.d.mts +0 -7
- package/dist/api-contract-discovery/protocol-callback-argument-bindings.mjs +0 -33
- package/dist/api-contract-discovery/protocol-callback-invocation.d.mts +0 -6
- package/dist/api-contract-discovery/protocol-callback-invocation.mjs +0 -111
- package/dist/api-contract-discovery/protocol-callback-mutations.d.mts +0 -5
- package/dist/api-contract-discovery/protocol-callback-mutations.mjs +0 -42
- package/dist/api-contract-discovery/protocol-callback-registration.d.mts +0 -3
- package/dist/api-contract-discovery/protocol-callback-registration.mjs +0 -27
- package/dist/api-contract-discovery/protocol-callback-values.d.mts +0 -18
- package/dist/api-contract-discovery/protocol-callback-values.mjs +0 -114
- package/dist/api-contract-discovery/protocol-context-alias.d.mts +0 -3
- package/dist/api-contract-discovery/protocol-context-alias.mjs +0 -20
- package/dist/api-contract-discovery/protocol-contract-extraction.d.mts +0 -9
- package/dist/api-contract-discovery/protocol-contract-extraction.mjs +0 -87
- package/dist/api-contract-discovery/protocol-contract-keys.d.mts +0 -1
- package/dist/api-contract-discovery/protocol-contract-keys.mjs +0 -8
- package/dist/api-contract-discovery/protocol-contract-registry.d.mts +0 -5
- package/dist/api-contract-discovery/protocol-contract-registry.mjs +0 -133
- package/dist/api-contract-discovery/protocol-executable-path.d.mts +0 -3
- package/dist/api-contract-discovery/protocol-executable-path.mjs +0 -64
- package/dist/api-contract-discovery/protocol-execution-path.d.mts +0 -4
- package/dist/api-contract-discovery/protocol-execution-path.mjs +0 -16
- package/dist/api-contract-discovery/protocol-http-association.d.mts +0 -7
- package/dist/api-contract-discovery/protocol-http-association.mjs +0 -108
- package/dist/api-contract-discovery/protocol-http-body-kinds.d.mts +0 -3
- package/dist/api-contract-discovery/protocol-http-body-kinds.mjs +0 -19
- package/dist/api-contract-discovery/protocol-http-context-callers.d.mts +0 -7
- package/dist/api-contract-discovery/protocol-http-context-callers.mjs +0 -40
- package/dist/api-contract-discovery/protocol-http-context-escapes.d.mts +0 -3
- package/dist/api-contract-discovery/protocol-http-context-escapes.mjs +0 -95
- package/dist/api-contract-discovery/protocol-http-context.d.mts +0 -8
- package/dist/api-contract-discovery/protocol-http-context.mjs +0 -85
- package/dist/api-contract-discovery/protocol-http-emission.d.mts +0 -3
- package/dist/api-contract-discovery/protocol-http-emission.mjs +0 -76
- package/dist/api-contract-discovery/protocol-http-implicit-taint.d.mts +0 -7
- package/dist/api-contract-discovery/protocol-http-implicit-taint.mjs +0 -26
- package/dist/api-contract-discovery/protocol-http-method-access.d.mts +0 -9
- package/dist/api-contract-discovery/protocol-http-method-access.mjs +0 -34
- package/dist/api-contract-discovery/protocol-http-method-mutations.d.mts +0 -3
- package/dist/api-contract-discovery/protocol-http-method-mutations.mjs +0 -31
- package/dist/api-contract-discovery/protocol-http-reflect.d.mts +0 -5
- package/dist/api-contract-discovery/protocol-http-reflect.mjs +0 -45
- package/dist/api-contract-discovery/protocol-http-registration.d.mts +0 -12
- package/dist/api-contract-discovery/protocol-http-registration.mjs +0 -53
- package/dist/api-contract-discovery/protocol-http-response-mutations.d.mts +0 -3
- package/dist/api-contract-discovery/protocol-http-response-mutations.mjs +0 -31
- package/dist/api-contract-discovery/protocol-marker-analysis.d.mts +0 -7
- package/dist/api-contract-discovery/protocol-marker-analysis.mjs +0 -50
- package/dist/api-contract-discovery/protocol-opaque-callback.d.mts +0 -3
- package/dist/api-contract-discovery/protocol-opaque-callback.mjs +0 -107
- package/dist/api-contract-discovery/protocol-platform-callbacks.d.mts +0 -7
- package/dist/api-contract-discovery/protocol-platform-callbacks.mjs +0 -76
- package/dist/api-contract-discovery/protocol-platform-mutation-targets.d.mts +0 -5
- package/dist/api-contract-discovery/protocol-platform-mutation-targets.mjs +0 -89
- package/dist/api-contract-discovery/protocol-platform-writes.d.mts +0 -3
- package/dist/api-contract-discovery/protocol-platform-writes.mjs +0 -92
- package/dist/api-contract-discovery/protocol-requested-keys.d.mts +0 -5
- package/dist/api-contract-discovery/protocol-requested-keys.mjs +0 -45
- package/dist/api-contract-discovery/protocol-sse-callers.d.mts +0 -7
- package/dist/api-contract-discovery/protocol-sse-callers.mjs +0 -67
- package/dist/api-contract-discovery/protocol-sse-emission.d.mts +0 -11
- package/dist/api-contract-discovery/protocol-sse-emission.mjs +0 -61
- package/dist/api-contract-discovery/protocol-sse-feasible-status.d.mts +0 -3
- package/dist/api-contract-discovery/protocol-sse-feasible-status.mjs +0 -24
- package/dist/api-contract-discovery/protocol-sse-raw-writes.d.mts +0 -9
- package/dist/api-contract-discovery/protocol-sse-raw-writes.mjs +0 -99
- package/dist/api-contract-discovery/protocol-sse-status.d.mts +0 -3
- package/dist/api-contract-discovery/protocol-sse-status.mjs +0 -84
- package/dist/api-contract-discovery/protocol-sse-write-access.d.mts +0 -9
- package/dist/api-contract-discovery/protocol-sse-write-access.mjs +0 -42
- package/dist/api-contract-discovery/protocol-sse-write-helpers.d.mts +0 -7
- package/dist/api-contract-discovery/protocol-sse-write-helpers.mjs +0 -82
- package/dist/api-contract-discovery/protocol-sse-write-mutations.d.mts +0 -9
- package/dist/api-contract-discovery/protocol-sse-write-mutations.mjs +0 -42
- package/dist/api-contract-discovery/protocol-sse-write-resolution.d.mts +0 -14
- package/dist/api-contract-discovery/protocol-sse-write-resolution.mjs +0 -79
- package/dist/api-contract-discovery/protocol-status-dominance.d.mts +0 -5
- package/dist/api-contract-discovery/protocol-status-dominance.mjs +0 -35
- package/dist/api-contract-discovery/protocol-write-receiver.d.mts +0 -9
- package/dist/api-contract-discovery/protocol-write-receiver.mjs +0 -79
- package/dist/api-contract-discovery/query-contract-extraction.d.mts +0 -3
- package/dist/api-contract-discovery/query-contract-extraction.mjs +0 -82
- package/dist/api-contract-discovery/query-contract-literals.d.mts +0 -13
- package/dist/api-contract-discovery/query-contract-literals.mjs +0 -83
- package/dist/api-contract-discovery/query-contract-registry.d.mts +0 -3
- package/dist/api-contract-discovery/query-contract-registry.mjs +0 -70
- package/dist/api-contract-discovery/query-contract-types.d.mts +0 -8
- package/dist/api-contract-discovery/registered-route-binding-writes.d.mts +0 -4
- package/dist/api-contract-discovery/registered-route-binding-writes.mjs +0 -47
- package/dist/api-contract-discovery/registered-route-catalog.d.mts +0 -10
- package/dist/api-contract-discovery/registered-route-catalog.mjs +0 -85
- package/dist/api-contract-discovery/registered-route-factory-returns.d.mts +0 -3
- package/dist/api-contract-discovery/registered-route-factory-returns.mjs +0 -29
- package/dist/api-contract-discovery/registered-route-handler-analysis.d.mts +0 -12
- package/dist/api-contract-discovery/registered-route-handler-analysis.mjs +0 -119
- package/dist/api-contract-discovery/registered-route-handler-helpers.d.mts +0 -3
- package/dist/api-contract-discovery/registered-route-handler-helpers.mjs +0 -16
- package/dist/api-contract-discovery/registered-route-runtime-parameters.d.mts +0 -3
- package/dist/api-contract-discovery/registered-route-runtime-parameters.mjs +0 -5
- package/dist/api-contract-discovery/registered-route-terminal-error.d.mts +0 -3
- package/dist/api-contract-discovery/registered-route-terminal-error.mjs +0 -98
- package/dist/api-contract-discovery/request-contract-implicit.d.mts +0 -17
- package/dist/api-contract-discovery/request-contract-implicit.mjs +0 -73
- package/dist/api-contract-discovery/request-contract-lenient.d.mts +0 -28
- package/dist/api-contract-discovery/request-contract-lenient.mjs +0 -59
- package/dist/api-contract-discovery/request-contract-registry.d.mts +0 -14
- package/dist/api-contract-discovery/request-contract-registry.mjs +0 -63
- package/dist/api-contract-discovery/request-contract-route-analysis.d.mts +0 -25
- package/dist/api-contract-discovery/request-contract-route-analysis.mjs +0 -68
- package/dist/api-contract-discovery/request-contract-types.d.mts +0 -12
- package/dist/api-contract-discovery/request-contract-types.mjs +0 -1
- package/dist/api-contract-discovery/request-validation-callbacks.d.mts +0 -9
- package/dist/api-contract-discovery/request-validation-callbacks.mjs +0 -27
- package/dist/api-contract-discovery/request-validation-checker.d.mts +0 -7
- package/dist/api-contract-discovery/request-validation-checker.mjs +0 -25
- package/dist/api-contract-discovery/request-validation-conditional.d.mts +0 -6
- package/dist/api-contract-discovery/request-validation-conditional.mjs +0 -31
- package/dist/api-contract-discovery/request-validation-factory-calls.d.mts +0 -11
- package/dist/api-contract-discovery/request-validation-factory-calls.mjs +0 -23
- package/dist/api-contract-discovery/request-validation-facts.d.mts +0 -16
- package/dist/api-contract-discovery/request-validation-facts.mjs +0 -64
- package/dist/api-contract-discovery/request-validation-follow.d.mts +0 -24
- package/dist/api-contract-discovery/request-validation-follow.mjs +0 -38
- package/dist/api-contract-discovery/request-validation-handler-state.d.mts +0 -8
- package/dist/api-contract-discovery/request-validation-handler-state.mjs +0 -35
- package/dist/api-contract-discovery/request-validation-input.d.mts +0 -12
- package/dist/api-contract-discovery/request-validation-input.mjs +0 -43
- package/dist/api-contract-discovery/request-validation-keys.d.mts +0 -25
- package/dist/api-contract-discovery/request-validation-keys.mjs +0 -119
- package/dist/api-contract-discovery/request-validation-match.d.mts +0 -11
- package/dist/api-contract-discovery/request-validation-match.mjs +0 -47
- package/dist/api-contract-discovery/request-validation-mutation.d.mts +0 -7
- package/dist/api-contract-discovery/request-validation-mutation.mjs +0 -80
- package/dist/api-contract-discovery/request-validation-origin.d.mts +0 -20
- package/dist/api-contract-discovery/request-validation-origin.mjs +0 -71
- package/dist/api-contract-discovery/request-validation-reads.d.mts +0 -13
- package/dist/api-contract-discovery/request-validation-reads.mjs +0 -88
- package/dist/api-contract-discovery/request-validation-registration.d.mts +0 -9
- package/dist/api-contract-discovery/request-validation-registration.mjs +0 -32
- package/dist/api-contract-discovery/request-validation-report.d.mts +0 -3
- package/dist/api-contract-discovery/request-validation-report.mjs +0 -21
- package/dist/api-contract-discovery/request-validation-request-origin.d.mts +0 -5
- package/dist/api-contract-discovery/request-validation-request-origin.mjs +0 -13
- package/dist/api-contract-discovery/request-validation-select.d.mts +0 -9
- package/dist/api-contract-discovery/request-validation-select.mjs +0 -36
- package/dist/api-contract-discovery/request-validation-sites.d.mts +0 -9
- package/dist/api-contract-discovery/request-validation-sites.mjs +0 -77
- package/dist/api-contract-discovery/request-validation-state-key.d.mts +0 -13
- package/dist/api-contract-discovery/request-validation-state-key.mjs +0 -30
- package/dist/api-contract-discovery/request-validation-trace-helpers.d.mts +0 -14
- package/dist/api-contract-discovery/request-validation-trace-helpers.mjs +0 -80
- package/dist/api-contract-discovery/request-validation-trace-select.d.mts +0 -23
- package/dist/api-contract-discovery/request-validation-trace-select.mjs +0 -45
- package/dist/api-contract-discovery/request-validation-trace.d.mts +0 -8
- package/dist/api-contract-discovery/request-validation-trace.mjs +0 -130
- package/dist/api-contract-discovery/request-validation-types.d.mts +0 -84
- package/dist/api-contract-discovery/request-validation-types.mjs +0 -1
- package/dist/api-contract-discovery/request-validation-walker.d.mts +0 -26
- package/dist/api-contract-discovery/request-validation-walker.mjs +0 -143
- package/dist/api-contract-discovery/request-validation.test-helpers.d.mts +0 -39
- package/dist/api-contract-discovery/request-validation.test-helpers.mjs +0 -108
- package/dist/api-contract-discovery/response-contract-attribution-facts.d.mts +0 -2
- package/dist/api-contract-discovery/response-contract-attribution-facts.mjs +0 -18
- package/dist/api-contract-discovery/response-contract-attribution.d.mts +0 -3
- package/dist/api-contract-discovery/response-contract-attribution.mjs +0 -23
- package/dist/api-contract-discovery/response-contract-call-classification.d.mts +0 -3
- package/dist/api-contract-discovery/response-contract-call-classification.mjs +0 -37
- package/dist/api-contract-discovery/response-contract-ctx-analysis.d.mts +0 -7
- package/dist/api-contract-discovery/response-contract-ctx-analysis.mjs +0 -28
- package/dist/api-contract-discovery/response-contract-error-branch.d.mts +0 -15
- package/dist/api-contract-discovery/response-contract-error-branch.mjs +0 -150
- package/dist/api-contract-discovery/response-contract-handler-bindings.d.mts +0 -3
- package/dist/api-contract-discovery/response-contract-handler-bindings.mjs +0 -126
- package/dist/api-contract-discovery/response-contract-handler-calls.d.mts +0 -3
- package/dist/api-contract-discovery/response-contract-handler-calls.mjs +0 -81
- package/dist/api-contract-discovery/response-contract-implicit-sources.test-helpers.d.mts +0 -145
- package/dist/api-contract-discovery/response-contract-implicit-sources.test-helpers.mjs +0 -145
- package/dist/api-contract-discovery/response-contract-implicit-variants.d.mts +0 -2
- package/dist/api-contract-discovery/response-contract-implicit-variants.mjs +0 -6
- package/dist/api-contract-discovery/response-contract-implicit.d.mts +0 -6
- package/dist/api-contract-discovery/response-contract-implicit.mjs +0 -120
- package/dist/api-contract-discovery/response-contract-lenient.d.mts +0 -41
- package/dist/api-contract-discovery/response-contract-lenient.mjs +0 -52
- package/dist/api-contract-discovery/response-contract-media.d.mts +0 -3
- package/dist/api-contract-discovery/response-contract-media.mjs +0 -46
- package/dist/api-contract-discovery/response-contract-object-symbols.d.mts +0 -3
- package/dist/api-contract-discovery/response-contract-object-symbols.mjs +0 -80
- package/dist/api-contract-discovery/response-contract-property-mutations.d.mts +0 -5
- package/dist/api-contract-discovery/response-contract-property-mutations.mjs +0 -84
- package/dist/api-contract-discovery/response-contract-registration.d.mts +0 -11
- package/dist/api-contract-discovery/response-contract-registration.mjs +0 -65
- package/dist/api-contract-discovery/response-contract-registry.d.mts +0 -7
- package/dist/api-contract-discovery/response-contract-registry.mjs +0 -124
- package/dist/api-contract-discovery/response-contract-route-analysis.d.mts +0 -12
- package/dist/api-contract-discovery/response-contract-route-analysis.mjs +0 -65
- package/dist/api-contract-discovery/response-contract-route-syntax.d.mts +0 -7
- package/dist/api-contract-discovery/response-contract-route-syntax.mjs +0 -41
- package/dist/api-contract-discovery/response-contract-status.d.mts +0 -27
- package/dist/api-contract-discovery/response-contract-status.mjs +0 -82
- package/dist/api-contract-discovery/response-contract-symbols.d.mts +0 -5
- package/dist/api-contract-discovery/response-contract-symbols.mjs +0 -82
- package/dist/api-contract-discovery/response-contract-types.d.mts +0 -23
- package/dist/api-contract-discovery/response-contract-types.mjs +0 -1
- package/dist/api-contract-discovery/test-setup.test-helpers.d.mts +0 -3
- package/dist/api-contract-discovery/test-setup.test-helpers.mjs +0 -2
- /package/dist/{api-contract-discovery/header-contract-types.mjs → post-publication-inventory/readers/public-view-options.mjs} +0 -0
- /package/dist/{api-contract-discovery/query-contract-types.mjs → post-publication-inventory/readers/source-options.mjs} +0 -0
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import ts from '../contract-schema/typescript-api.mjs';
|
|
2
|
-
import { attributionSymbol, resolveSymbol } from './response-contract-symbols.mjs';
|
|
3
|
-
import { unwrapTransparentExpression, visit } from './response-contract-route-syntax.mjs';
|
|
4
|
-
/** Direct syntactic property writes are excluded; indirect mutation is outside this proof. */
|
|
5
|
-
export function findMutatedProperties(sourceFiles, checker) {
|
|
6
|
-
const mutated = new Set();
|
|
7
|
-
for (const sourceFile of sourceFiles) {
|
|
8
|
-
visit(sourceFile, (node) => {
|
|
9
|
-
let access;
|
|
10
|
-
if (ts.isBinaryExpression(node) &&
|
|
11
|
-
node.operatorToken.kind >= ts.SyntaxKind.FirstAssignment &&
|
|
12
|
-
node.operatorToken.kind <= ts.SyntaxKind.LastAssignment &&
|
|
13
|
-
ts.isPropertyAccessExpression(unwrapTransparentExpression(node.left)))
|
|
14
|
-
access = unwrapTransparentExpression(node.left);
|
|
15
|
-
else if ((ts.isPrefixUnaryExpression(node) || ts.isPostfixUnaryExpression(node)) &&
|
|
16
|
-
(node.operator === ts.SyntaxKind.PlusPlusToken ||
|
|
17
|
-
node.operator === ts.SyntaxKind.MinusMinusToken) &&
|
|
18
|
-
ts.isPropertyAccessExpression(node.operand))
|
|
19
|
-
access = node.operand;
|
|
20
|
-
if (!access)
|
|
21
|
-
return;
|
|
22
|
-
const symbol = checker.getSymbolAtLocation(access.name);
|
|
23
|
-
if (symbol)
|
|
24
|
-
mutated.add(attributionSymbol(resolveSymbol(symbol, checker), checker));
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
return mutated;
|
|
28
|
-
}
|
|
29
|
-
/** Direct identifier and destructuring writes are excluded; indirect writes are unproven. */
|
|
30
|
-
export function findMutatedBindings(sourceFiles, checker) {
|
|
31
|
-
const mutated = new Set();
|
|
32
|
-
for (const sourceFile of sourceFiles) {
|
|
33
|
-
visit(sourceFile, (node) => {
|
|
34
|
-
let identifiers = [];
|
|
35
|
-
if (ts.isBinaryExpression(node) &&
|
|
36
|
-
node.operatorToken.kind >= ts.SyntaxKind.FirstAssignment &&
|
|
37
|
-
node.operatorToken.kind <= ts.SyntaxKind.LastAssignment &&
|
|
38
|
-
isAssignmentTarget(node.left))
|
|
39
|
-
identifiers = assignmentTargetIdentifiers(node.left);
|
|
40
|
-
else if ((ts.isForInStatement(node) || ts.isForOfStatement(node)) &&
|
|
41
|
-
!ts.isVariableDeclarationList(node.initializer) &&
|
|
42
|
-
isAssignmentTarget(node.initializer))
|
|
43
|
-
identifiers = assignmentTargetIdentifiers(node.initializer);
|
|
44
|
-
else if ((ts.isPrefixUnaryExpression(node) || ts.isPostfixUnaryExpression(node)) &&
|
|
45
|
-
(node.operator === ts.SyntaxKind.PlusPlusToken ||
|
|
46
|
-
node.operator === ts.SyntaxKind.MinusMinusToken) &&
|
|
47
|
-
ts.isIdentifier(node.operand))
|
|
48
|
-
identifiers = [node.operand];
|
|
49
|
-
for (const identifier of identifiers) {
|
|
50
|
-
const symbol = checker.getSymbolAtLocation(identifier);
|
|
51
|
-
if (symbol)
|
|
52
|
-
mutated.add(attributionSymbol(resolveSymbol(symbol, checker), checker));
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
return mutated;
|
|
57
|
-
}
|
|
58
|
-
function isAssignmentTarget(expression) {
|
|
59
|
-
const target = unwrapTransparentExpression(expression);
|
|
60
|
-
return (ts.isIdentifier(target) ||
|
|
61
|
-
ts.isArrayLiteralExpression(target) ||
|
|
62
|
-
ts.isObjectLiteralExpression(target));
|
|
63
|
-
}
|
|
64
|
-
function assignmentTargetIdentifiers(expression) {
|
|
65
|
-
const target = unwrapTransparentExpression(expression);
|
|
66
|
-
if (ts.isIdentifier(target))
|
|
67
|
-
return [target];
|
|
68
|
-
if (ts.isArrayLiteralExpression(target))
|
|
69
|
-
return target.elements.flatMap((element) => ts.isOmittedExpression(element)
|
|
70
|
-
? []
|
|
71
|
-
: assignmentTargetIdentifiers(ts.isSpreadElement(element) ? element.expression : element));
|
|
72
|
-
if (!ts.isObjectLiteralExpression(target))
|
|
73
|
-
return [];
|
|
74
|
-
const identifiers = [];
|
|
75
|
-
for (const property of target.properties) {
|
|
76
|
-
if (ts.isShorthandPropertyAssignment(property))
|
|
77
|
-
identifiers.push(property.name);
|
|
78
|
-
else if (ts.isPropertyAssignment(property))
|
|
79
|
-
identifiers.push(...assignmentTargetIdentifiers(property.initializer));
|
|
80
|
-
else if (ts.isSpreadAssignment(property))
|
|
81
|
-
identifiers.push(...assignmentTargetIdentifiers(property.expression));
|
|
82
|
-
}
|
|
83
|
-
return identifiers;
|
|
84
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import ts from '../contract-schema/typescript-api.mts';
|
|
2
|
-
import type { ExtractedResponseContract, ExtractContractSchemaOptions } from '../contract-schema/index.mts';
|
|
3
|
-
import type { BackendResponseContract } from './response-contract-types.mts';
|
|
4
|
-
export declare function responseBodyExpression(call: ts.CallExpression, unwrapPipelineArguments?: boolean): ts.Expression | undefined;
|
|
5
|
-
export declare function containsResponseMarker(node: ts.Node): boolean;
|
|
6
|
-
export declare function extractBodyContract(call: ts.CallExpression, checker: ts.TypeChecker, sourceFile: ts.SourceFile, location: string, options?: ExtractContractSchemaOptions): ExtractedResponseContract;
|
|
7
|
-
export declare function registerContract(contracts: Map<string, BackendResponseContract>, key: string, contract: BackendResponseContract): void;
|
|
8
|
-
export declare function noContentContract(source: string): ExtractedResponseContract;
|
|
9
|
-
export declare function binaryContentContract(source: string): ExtractedResponseContract;
|
|
10
|
-
export declare function sourceLocation(sourceFile: ts.SourceFile, _node: ts.Node): string;
|
|
11
|
-
export declare function contractError(sourceFile: ts.SourceFile, node: ts.Node, message: string): Error;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import ts from '../contract-schema/typescript-api.mjs';
|
|
2
|
-
import { extractContractSchema, hashContractSchema } from '../contract-schema/index.mjs';
|
|
3
|
-
import { isContextMethod, responseMarker, visit } from './response-contract-route-analysis.mjs';
|
|
4
|
-
import { unwrapTransparentExpression } from './response-contract-route-syntax.mjs';
|
|
5
|
-
export function responseBodyExpression(call, unwrapPipelineArguments = false) {
|
|
6
|
-
if (isContextMethod(call.expression, 'json'))
|
|
7
|
-
return call.arguments[0];
|
|
8
|
-
if (!isContextMethod(call.expression, 'pipeline'))
|
|
9
|
-
return undefined;
|
|
10
|
-
const originalBody = call.arguments[0];
|
|
11
|
-
const pipelineBody = originalBody &&
|
|
12
|
-
(unwrapPipelineArguments ? unwrapTransparentExpression(originalBody) : originalBody);
|
|
13
|
-
if (!pipelineBody ||
|
|
14
|
-
!ts.isCallExpression(pipelineBody) ||
|
|
15
|
-
!ts.isIdentifier(pipelineBody.expression) ||
|
|
16
|
-
pipelineBody.expression.text !== 'streamJsonObject') {
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
|
-
const body = pipelineBody.arguments[0];
|
|
20
|
-
return body && (unwrapPipelineArguments ? unwrapTransparentExpression(body) : body);
|
|
21
|
-
}
|
|
22
|
-
export function containsResponseMarker(node) {
|
|
23
|
-
let found = false;
|
|
24
|
-
visit(node, (child) => {
|
|
25
|
-
if (ts.isCallExpression(child) && responseMarker(child.expression))
|
|
26
|
-
found = true;
|
|
27
|
-
});
|
|
28
|
-
return found;
|
|
29
|
-
}
|
|
30
|
-
export function extractBodyContract(call, checker, sourceFile, location, options = {}) {
|
|
31
|
-
const body = call.arguments[1];
|
|
32
|
-
if (!body)
|
|
33
|
-
throw contractError(sourceFile, call, 'apiResponse requires a response body');
|
|
34
|
-
return extractContractSchema(checker.getTypeAtLocation(body), checker, location, options);
|
|
35
|
-
}
|
|
36
|
-
export function registerContract(contracts, key, contract) {
|
|
37
|
-
const existing = contracts.get(key);
|
|
38
|
-
if (!existing) {
|
|
39
|
-
contracts.set(key, contract);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
if (existing.hash !== contract.hash) {
|
|
43
|
-
throw new Error(`Backend response contract "${key}" resolves to multiple backend response schemas at ${existing.source} and ${contract.source}`);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
export function noContentContract(source) {
|
|
47
|
-
const schema = { root: { type: 'null' }, definitions: {} };
|
|
48
|
-
return { source, schema, hash: hashContractSchema(schema) };
|
|
49
|
-
}
|
|
50
|
-
export function binaryContentContract(source) {
|
|
51
|
-
const schema = {
|
|
52
|
-
root: { type: 'string', format: 'binary' },
|
|
53
|
-
definitions: {},
|
|
54
|
-
};
|
|
55
|
-
return { source, schema, hash: hashContractSchema(schema) };
|
|
56
|
-
}
|
|
57
|
-
export function sourceLocation(sourceFile, _node) {
|
|
58
|
-
return normalizePath(sourceFile.fileName);
|
|
59
|
-
}
|
|
60
|
-
export function contractError(sourceFile, node, message) {
|
|
61
|
-
return new Error(`${sourceLocation(sourceFile, node)}: ${message}`);
|
|
62
|
-
}
|
|
63
|
-
function normalizePath(path) {
|
|
64
|
-
return path.replaceAll('\\', '/');
|
|
65
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import ts from '../contract-schema/typescript-api.mts';
|
|
2
|
-
import { type DiscoverApiResponseContractsOptions } from './response-contract-lenient.mts';
|
|
3
|
-
import type { BackendResponseContract } from './response-contract-types.mts';
|
|
4
|
-
export type { BackendResponseContract } from './response-contract-types.mts';
|
|
5
|
-
export type { DiscoverApiResponseContractsOptions } from './response-contract-lenient.mts';
|
|
6
|
-
export declare function discoverApiResponseContracts(program: ts.Program, sourceFiles: readonly ts.SourceFile[], requestedKeys?: ReadonlySet<string>, options?: DiscoverApiResponseContractsOptions): Record<string, BackendResponseContract>;
|
|
7
|
-
export declare function enclosingResponseEmission(call: ts.CallExpression): ts.CallExpression | undefined;
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import ts from '../contract-schema/typescript-api.mjs';
|
|
2
|
-
import { registerPlatformCompilerLibraries } from './protocol-platform-callbacks.mjs';
|
|
3
|
-
import { protocolBindingRequested, requestedProtocolKey } from './protocol-requested-keys.mjs';
|
|
4
|
-
import { discoverProtocolContracts } from './protocol-contract-registry.mjs';
|
|
5
|
-
import { discoverImplicitContract } from './response-contract-implicit.mjs';
|
|
6
|
-
import { ambiguousRoutesForCall } from './response-contract-attribution.mjs';
|
|
7
|
-
import { sortAttributionFacts } from './response-contract-attribution-facts.mjs';
|
|
8
|
-
import { implicitResponseCallLabel } from './response-contract-call-classification.mjs';
|
|
9
|
-
import { collectHandlerBindings } from './response-contract-handler-bindings.mjs';
|
|
10
|
-
import { registerRouteContract, } from './response-contract-lenient.mjs';
|
|
11
|
-
import { binaryContentContract, contractError, extractBodyContract, noContentContract, sourceLocation, } from './response-contract-registration.mjs';
|
|
12
|
-
import { enclosingRouteBinding, isContextMethod, responseMarker, visit, } from './response-contract-route-analysis.mjs';
|
|
13
|
-
import { resolveEmissionStatus } from './response-contract-status.mjs';
|
|
14
|
-
export function discoverApiResponseContracts(program, sourceFiles, requestedKeys, options) {
|
|
15
|
-
registerPlatformCompilerLibraries(program);
|
|
16
|
-
const checker = program.getTypeChecker();
|
|
17
|
-
const contracts = new Map();
|
|
18
|
-
const ambiguousBindings = options?.onAmbiguousAttribution
|
|
19
|
-
? new Map()
|
|
20
|
-
: undefined;
|
|
21
|
-
const handlerBindings = collectHandlerBindings(sourceFiles, checker, ambiguousBindings);
|
|
22
|
-
const attributionFacts = [];
|
|
23
|
-
const protocolContracts = new Map();
|
|
24
|
-
const protocolEmissions = discoverProtocolContracts(sourceFiles, checker, handlerBindings, protocolContracts, options, requestedKeys);
|
|
25
|
-
for (const [key, contract] of protocolContracts) {
|
|
26
|
-
const requestedKey = requestedProtocolKey(key, contract, requestedKeys);
|
|
27
|
-
if (requestedKey)
|
|
28
|
-
contracts.set(requestedKey, contract);
|
|
29
|
-
}
|
|
30
|
-
for (const sourceFile of sourceFiles) {
|
|
31
|
-
visit(sourceFile, (node) => {
|
|
32
|
-
if (!ts.isCallExpression(node))
|
|
33
|
-
return;
|
|
34
|
-
const marker = responseMarker(node.expression);
|
|
35
|
-
if (!marker)
|
|
36
|
-
return;
|
|
37
|
-
const keyNode = node.arguments[0];
|
|
38
|
-
if (!keyNode || !ts.isStringLiteral(keyNode)) {
|
|
39
|
-
throw contractError(sourceFile, node, `${marker} requires a literal contract key`);
|
|
40
|
-
}
|
|
41
|
-
const binding = enclosingRouteBinding(node, checker, handlerBindings);
|
|
42
|
-
if (!binding)
|
|
43
|
-
throw contractError(sourceFile, node, `${marker} must be inside an app.route handler`);
|
|
44
|
-
const expectedPrefix = `${binding.method}:${binding.routeTemplate}`;
|
|
45
|
-
if (keyNode.text !== expectedPrefix && !keyNode.text.startsWith(`${expectedPrefix}#`)) {
|
|
46
|
-
throw contractError(sourceFile, keyNode, `Contract key "${keyNode.text}" does not match enclosing route ${expectedPrefix}`);
|
|
47
|
-
}
|
|
48
|
-
const location = sourceLocation(sourceFile, node);
|
|
49
|
-
const responseEmission = enclosingResponseEmission(node) ?? node;
|
|
50
|
-
const status = resolveEmissionStatus(responseEmission);
|
|
51
|
-
const rawMediaType = rawResponseMediaType(marker, node, sourceFile);
|
|
52
|
-
registerRouteContract(contracts, keyNode.text, binding, location, {
|
|
53
|
-
bodyKind: marker === 'apiNoContent' ? 'none' : 'content',
|
|
54
|
-
...(marker === 'apiResponse'
|
|
55
|
-
? { mediaType: 'application/json', mediaTypeKnowledge: 'known' }
|
|
56
|
-
: rawMediaType
|
|
57
|
-
? { mediaType: rawMediaType, mediaTypeKnowledge: 'known' }
|
|
58
|
-
: { mediaTypeKnowledge: 'none' }),
|
|
59
|
-
...status,
|
|
60
|
-
}, () => marker === 'apiNoContent'
|
|
61
|
-
? noContentContract(location)
|
|
62
|
-
: marker === 'apiOpenApiRawResponse'
|
|
63
|
-
? binaryContentContract(location)
|
|
64
|
-
: extractBodyContract(node, checker, sourceFile, location, options), options);
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
for (const sourceFile of sourceFiles) {
|
|
68
|
-
visit(sourceFile, (node) => {
|
|
69
|
-
if (!ts.isCallExpression(node))
|
|
70
|
-
return;
|
|
71
|
-
const callLabel = implicitResponseCallLabel(node);
|
|
72
|
-
if (options?.onAmbiguousAttribution) {
|
|
73
|
-
const attributionLabel = implicitResponseCallLabel(node, true, checker);
|
|
74
|
-
const routes = attributionLabel
|
|
75
|
-
? ambiguousBindings &&
|
|
76
|
-
ambiguousRoutesForCall(node, checker, handlerBindings, ambiguousBindings)
|
|
77
|
-
: undefined;
|
|
78
|
-
const requestedRoute = !requestedKeys ||
|
|
79
|
-
routes?.some((route) => {
|
|
80
|
-
const separator = route.indexOf(':');
|
|
81
|
-
return (separator > 0 &&
|
|
82
|
-
protocolBindingRequested({ method: route.slice(0, separator), routeTemplate: route.slice(separator + 1) }, requestedKeys));
|
|
83
|
-
});
|
|
84
|
-
if (attributionLabel && routes && requestedRoute) {
|
|
85
|
-
const position = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));
|
|
86
|
-
attributionFacts.push({
|
|
87
|
-
sourceLocation: `${sourceLocation(sourceFile, node)}:${position.line + 1}:${position.character + 1}`,
|
|
88
|
-
label: attributionLabel,
|
|
89
|
-
routes: [...routes],
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
if (responseMarker(node.expression) || protocolEmissions.has(node))
|
|
94
|
-
return;
|
|
95
|
-
discoverImplicitContract(node, checker, sourceFile, contracts, handlerBindings, callLabel, requestedKeys, options);
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
const result = Object.fromEntries([...contracts.entries()].toSorted(([left], [right]) => left.localeCompare(right)));
|
|
99
|
-
if (options?.onAmbiguousAttribution) {
|
|
100
|
-
for (const fact of sortAttributionFacts(attributionFacts))
|
|
101
|
-
options.onAmbiguousAttribution(fact);
|
|
102
|
-
}
|
|
103
|
-
return result;
|
|
104
|
-
}
|
|
105
|
-
function rawResponseMediaType(marker, node, sourceFile) {
|
|
106
|
-
if (marker !== 'apiOpenApiRawResponse')
|
|
107
|
-
return undefined;
|
|
108
|
-
const mediaType = node.arguments[1];
|
|
109
|
-
if (!mediaType || !ts.isStringLiteral(mediaType)) {
|
|
110
|
-
throw contractError(sourceFile, node, 'apiOpenApiRawResponse requires a literal media type');
|
|
111
|
-
}
|
|
112
|
-
return mediaType.text;
|
|
113
|
-
}
|
|
114
|
-
export function enclosingResponseEmission(call) {
|
|
115
|
-
let current = call.parent;
|
|
116
|
-
while (current && !ts.isStatement(current)) {
|
|
117
|
-
if (ts.isCallExpression(current) &&
|
|
118
|
-
(isContextMethod(current.expression, 'json') ||
|
|
119
|
-
isContextMethod(current.expression, 'pipeline')))
|
|
120
|
-
return current;
|
|
121
|
-
current = current.parent;
|
|
122
|
-
}
|
|
123
|
-
return undefined;
|
|
124
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import ts from '../contract-schema/typescript-api.mts';
|
|
2
|
-
export { collectHandlerBindings } from './response-contract-handler-bindings.mts';
|
|
3
|
-
export { propertyName, routeTemplateFromExpression, visit, } from './response-contract-route-syntax.mts';
|
|
4
|
-
export { isContextMethod, isContextResponseBufferCall, isContextResponseEmptyCall, responseMarker, } from './response-contract-ctx-analysis.mts';
|
|
5
|
-
export type RouteBinding = {
|
|
6
|
-
method: string;
|
|
7
|
-
routeTemplate: string;
|
|
8
|
-
};
|
|
9
|
-
export type HandlerBindings = Map<ts.Symbol, RouteBinding>;
|
|
10
|
-
export type AmbiguousHandlerBindings = Map<ts.Symbol, readonly string[]>;
|
|
11
|
-
export declare function requestedKeyForBinding(binding: RouteBinding, requestedKeys?: ReadonlySet<string>): string | undefined;
|
|
12
|
-
export declare function enclosingRouteBinding(node: ts.Node, checker: ts.TypeChecker, handlerBindings: HandlerBindings, proveCallbacks?: boolean): RouteBinding | undefined;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import ts from '../contract-schema/typescript-api.mjs';
|
|
2
|
-
import { functionSymbol, resolveSymbol } from './response-contract-symbols.mjs';
|
|
3
|
-
import { executableProtocolPath } from './protocol-execution-path.mjs';
|
|
4
|
-
import { HTTP_METHODS, propertyName, routeTemplateFromExpression, } from './response-contract-route-syntax.mjs';
|
|
5
|
-
export { collectHandlerBindings } from './response-contract-handler-bindings.mjs';
|
|
6
|
-
export { propertyName, routeTemplateFromExpression, visit, } from './response-contract-route-syntax.mjs';
|
|
7
|
-
export { isContextMethod, isContextResponseBufferCall, isContextResponseEmptyCall, responseMarker, } from './response-contract-ctx-analysis.mjs';
|
|
8
|
-
export function requestedKeyForBinding(binding, requestedKeys) {
|
|
9
|
-
if (!requestedKeys)
|
|
10
|
-
return `${binding.method}:${binding.routeTemplate}`;
|
|
11
|
-
const exact = `${binding.method}:${binding.routeTemplate}`;
|
|
12
|
-
if (requestedKeys.has(exact))
|
|
13
|
-
return exact;
|
|
14
|
-
const bindingShape = routeShape(binding.routeTemplate);
|
|
15
|
-
return [...requestedKeys]
|
|
16
|
-
.filter((key) => !key.includes('#'))
|
|
17
|
-
.find((key) => {
|
|
18
|
-
const separator = key.indexOf(':');
|
|
19
|
-
return (key.slice(0, separator) === binding.method &&
|
|
20
|
-
routeShape(key.slice(separator + 1)) === bindingShape);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
function routeShape(routeTemplate) {
|
|
24
|
-
return routeTemplate.replace(/:[^/]+/g, ':');
|
|
25
|
-
}
|
|
26
|
-
export function enclosingRouteBinding(node, checker, handlerBindings, proveCallbacks = true) {
|
|
27
|
-
let current = node;
|
|
28
|
-
let insideHandlerFunction = false;
|
|
29
|
-
while (current) {
|
|
30
|
-
if (ts.isFunctionLike(current))
|
|
31
|
-
insideHandlerFunction = true;
|
|
32
|
-
if (insideHandlerFunction && ts.isCallExpression(current)) {
|
|
33
|
-
const method = propertyName(current.expression)?.toUpperCase();
|
|
34
|
-
const routeTemplate = routeTemplateFromExpression(current.expression);
|
|
35
|
-
if (method && HTTP_METHODS.has(method) && routeTemplate)
|
|
36
|
-
return !proveCallbacks || executableProtocolPath(node, checker)
|
|
37
|
-
? { method, routeTemplate }
|
|
38
|
-
: undefined;
|
|
39
|
-
}
|
|
40
|
-
if (isFunctionLike(current) && ts.isCallExpression(current.parent)) {
|
|
41
|
-
const handlerCall = current.parent;
|
|
42
|
-
const method = propertyName(handlerCall.expression)?.toUpperCase();
|
|
43
|
-
if (method && HTTP_METHODS.has(method)) {
|
|
44
|
-
const routeTemplate = routeTemplateFromExpression(handlerCall.expression);
|
|
45
|
-
if (routeTemplate)
|
|
46
|
-
return !proveCallbacks || executableProtocolPath(node, checker)
|
|
47
|
-
? { method, routeTemplate }
|
|
48
|
-
: undefined;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
const handlerSymbol = functionSymbol(current, checker);
|
|
52
|
-
if (handlerSymbol) {
|
|
53
|
-
const binding = handlerBindings.get(resolveSymbol(handlerSymbol, checker));
|
|
54
|
-
if (binding)
|
|
55
|
-
return !proveCallbacks || executableProtocolPath(node, checker, current)
|
|
56
|
-
? binding
|
|
57
|
-
: undefined;
|
|
58
|
-
}
|
|
59
|
-
current = current.parent;
|
|
60
|
-
}
|
|
61
|
-
return undefined;
|
|
62
|
-
}
|
|
63
|
-
function isFunctionLike(node) {
|
|
64
|
-
return ts.isArrowFunction(node) || ts.isFunctionExpression(node);
|
|
65
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import ts from '../contract-schema/typescript-api.mts';
|
|
2
|
-
export declare const HTTP_METHODS: Set<string>;
|
|
3
|
-
export declare function isInlineRouteHandler(node: ts.Node): boolean;
|
|
4
|
-
export declare function routeTemplateFromExpression(expression: ts.Expression): string | undefined;
|
|
5
|
-
export declare function propertyName(expression: ts.Expression): string | undefined;
|
|
6
|
-
export declare function unwrapTransparentExpression(expression: ts.Expression): ts.Expression;
|
|
7
|
-
export declare function visit(node: ts.Node, callback: (node: ts.Node) => void): void;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import ts from '../contract-schema/typescript-api.mjs';
|
|
2
|
-
export const HTTP_METHODS = new Set(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']);
|
|
3
|
-
export function isInlineRouteHandler(node) {
|
|
4
|
-
if ((!ts.isArrowFunction(node) && !ts.isFunctionExpression(node)) ||
|
|
5
|
-
!ts.isCallExpression(node.parent))
|
|
6
|
-
return false;
|
|
7
|
-
const method = propertyName(node.parent.expression)?.toUpperCase();
|
|
8
|
-
return (!!method && HTTP_METHODS.has(method) && !!routeTemplateFromExpression(node.parent.expression));
|
|
9
|
-
}
|
|
10
|
-
export function routeTemplateFromExpression(expression) {
|
|
11
|
-
if (!ts.isPropertyAccessExpression(expression))
|
|
12
|
-
return undefined;
|
|
13
|
-
return findRouteCall(expression.expression);
|
|
14
|
-
}
|
|
15
|
-
function findRouteCall(expression) {
|
|
16
|
-
if (!ts.isCallExpression(expression))
|
|
17
|
-
return undefined;
|
|
18
|
-
if (!ts.isPropertyAccessExpression(expression.expression))
|
|
19
|
-
return undefined;
|
|
20
|
-
if (expression.expression.name.text === 'route') {
|
|
21
|
-
const route = expression.arguments[0];
|
|
22
|
-
return route && ts.isStringLiteral(route) ? route.text : undefined;
|
|
23
|
-
}
|
|
24
|
-
return findRouteCall(expression.expression.expression);
|
|
25
|
-
}
|
|
26
|
-
export function propertyName(expression) {
|
|
27
|
-
return ts.isPropertyAccessExpression(expression) ? expression.name.text : undefined;
|
|
28
|
-
}
|
|
29
|
-
export function unwrapTransparentExpression(expression) {
|
|
30
|
-
while (ts.isParenthesizedExpression(expression) ||
|
|
31
|
-
ts.isAsExpression(expression) ||
|
|
32
|
-
ts.isTypeAssertionExpression(expression) ||
|
|
33
|
-
ts.isSatisfiesExpression(expression) ||
|
|
34
|
-
ts.isNonNullExpression(expression))
|
|
35
|
-
expression = expression.expression;
|
|
36
|
-
return expression;
|
|
37
|
-
}
|
|
38
|
-
export function visit(node, callback) {
|
|
39
|
-
callback(node);
|
|
40
|
-
node.forEachChild((child) => visit(child, callback));
|
|
41
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import ts from '../contract-schema/typescript-api.mts';
|
|
2
|
-
import type { BackendResponseContract } from './response-contract-types.mts';
|
|
3
|
-
export declare function responseStatusCodesForContract(contract: BackendResponseContract): number[];
|
|
4
|
-
/**
|
|
5
|
-
* Maps `METHOD:/route` to the non-error static `ctx.setStatus(NNN)` literal(s) found for that
|
|
6
|
-
* route binding: a plain literal contributes one status; `ctx.setStatus(cond ? A : B)` with both
|
|
7
|
-
* branches numeric contributes both (the doc can't know which branch fires at request time, so
|
|
8
|
-
* both are valid statuses for the operation). Statuses >= 400 are dropped per-branch: they mark
|
|
9
|
-
* hand-rolled error branches (the shared `default` -> `components/responses/Error` already
|
|
10
|
-
* documents error responses), and capturing them here would misattribute an error status to the
|
|
11
|
-
* whole operation. A route absent from the map never sets a non-error status explicitly (callers
|
|
12
|
-
* fall back to 200, or 204 when the response schema's root is `null`).
|
|
13
|
-
*/
|
|
14
|
-
/**
|
|
15
|
-
* Resolves the status documented for one specific `apiResponse`/`apiNoContent` marker call: the
|
|
16
|
-
* nearest preceding sibling `ctx.setStatus(NNN)` literal, walking outward through enclosing
|
|
17
|
-
* blocks (mirroring `response-contract-implicit.mts`'s `precededByErrorStatus` walk). Unlike
|
|
18
|
-
* `collectRouteStatusCodes`, this has no `>=400` filter: an explicit `#variant` marker is a
|
|
19
|
-
* deliberate author opt-in to document that exact status (e.g. 422 for a `#validation` variant),
|
|
20
|
-
* and the route-wide map (keyed only on `method:routeTemplate`) can't tell two markers in the
|
|
21
|
-
* same route apart when they're preceded by different statuses.
|
|
22
|
-
*/
|
|
23
|
-
export declare function resolveEmissionStatus(call: ts.CallExpression | ts.NewExpression, matchesContext?: (expression: ts.Expression) => boolean): {
|
|
24
|
-
statusCodes?: readonly [number, ...number[]];
|
|
25
|
-
statusKnowledge: 'default' | 'explicit' | 'unknown';
|
|
26
|
-
unavailableReason?: string;
|
|
27
|
-
};
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import ts from '../contract-schema/typescript-api.mjs';
|
|
2
|
-
import { isContextMethod } from './response-contract-route-analysis.mjs';
|
|
3
|
-
export function responseStatusCodesForContract(contract) {
|
|
4
|
-
if (contract.statusKnowledge === 'unknown')
|
|
5
|
-
return [];
|
|
6
|
-
if (contract.statusCodes)
|
|
7
|
-
return [...new Set(contract.statusCodes)].toSorted((a, b) => a - b);
|
|
8
|
-
const bodyKind = contract.bodyKind ?? (contract.schema.root.type === 'null' ? 'none' : 'content');
|
|
9
|
-
return [bodyKind === 'none' ? 204 : 200];
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Maps `METHOD:/route` to the non-error static `ctx.setStatus(NNN)` literal(s) found for that
|
|
13
|
-
* route binding: a plain literal contributes one status; `ctx.setStatus(cond ? A : B)` with both
|
|
14
|
-
* branches numeric contributes both (the doc can't know which branch fires at request time, so
|
|
15
|
-
* both are valid statuses for the operation). Statuses >= 400 are dropped per-branch: they mark
|
|
16
|
-
* hand-rolled error branches (the shared `default` -> `components/responses/Error` already
|
|
17
|
-
* documents error responses), and capturing them here would misattribute an error status to the
|
|
18
|
-
* whole operation. A route absent from the map never sets a non-error status explicitly (callers
|
|
19
|
-
* fall back to 200, or 204 when the response schema's root is `null`).
|
|
20
|
-
*/
|
|
21
|
-
/**
|
|
22
|
-
* Resolves the status documented for one specific `apiResponse`/`apiNoContent` marker call: the
|
|
23
|
-
* nearest preceding sibling `ctx.setStatus(NNN)` literal, walking outward through enclosing
|
|
24
|
-
* blocks (mirroring `response-contract-implicit.mts`'s `precededByErrorStatus` walk). Unlike
|
|
25
|
-
* `collectRouteStatusCodes`, this has no `>=400` filter: an explicit `#variant` marker is a
|
|
26
|
-
* deliberate author opt-in to document that exact status (e.g. 422 for a `#validation` variant),
|
|
27
|
-
* and the route-wide map (keyed only on `method:routeTemplate`) can't tell two markers in the
|
|
28
|
-
* same route apart when they're preceded by different statuses.
|
|
29
|
-
*/
|
|
30
|
-
export function resolveEmissionStatus(call, matchesContext = (expression) => isContextMethod(expression, 'setStatus')) {
|
|
31
|
-
if (ts.isCallExpression(call) && matchesContext(call.expression))
|
|
32
|
-
return statusArgument(call.arguments[0]);
|
|
33
|
-
let statement = call;
|
|
34
|
-
while (!ts.isStatement(statement))
|
|
35
|
-
statement = statement.parent;
|
|
36
|
-
return precedingStatus(statement, matchesContext);
|
|
37
|
-
}
|
|
38
|
-
function precedingStatus(statement, matchesContext) {
|
|
39
|
-
const block = statement.parent;
|
|
40
|
-
if (!ts.isBlock(block))
|
|
41
|
-
return { statusKnowledge: 'default' };
|
|
42
|
-
const index = block.statements.indexOf(statement);
|
|
43
|
-
for (let i = index - 1; i >= 0; i--) {
|
|
44
|
-
const status = statusStatement(block.statements[i], matchesContext);
|
|
45
|
-
if (status)
|
|
46
|
-
return status;
|
|
47
|
-
}
|
|
48
|
-
const enclosing = block.parent;
|
|
49
|
-
return ts.isStatement(enclosing)
|
|
50
|
-
? precedingStatus(enclosing, matchesContext)
|
|
51
|
-
: { statusKnowledge: 'default' };
|
|
52
|
-
}
|
|
53
|
-
function statusStatement(statement, matchesContext) {
|
|
54
|
-
if (!ts.isExpressionStatement(statement))
|
|
55
|
-
return undefined;
|
|
56
|
-
const expression = statement.expression;
|
|
57
|
-
if (!ts.isCallExpression(expression) || !matchesContext(expression.expression))
|
|
58
|
-
return undefined;
|
|
59
|
-
return statusArgument(expression.arguments[0]);
|
|
60
|
-
}
|
|
61
|
-
/** A `ctx.setStatus` argument's possible numeric literal value(s): one for a bare literal, up to two (sorted ascending) for `cond ? A : B` when both branches are numeric literals. */
|
|
62
|
-
function statusArgument(argument) {
|
|
63
|
-
if (!argument)
|
|
64
|
-
return {
|
|
65
|
-
statusKnowledge: 'unknown',
|
|
66
|
-
unavailableReason: 'ctx.setStatus has no statically known status',
|
|
67
|
-
};
|
|
68
|
-
if (ts.isNumericLiteral(argument))
|
|
69
|
-
return { statusCodes: [Number(argument.text)], statusKnowledge: 'explicit' };
|
|
70
|
-
if (ts.isConditionalExpression(argument) &&
|
|
71
|
-
ts.isNumericLiteral(argument.whenTrue) &&
|
|
72
|
-
ts.isNumericLiteral(argument.whenFalse)) {
|
|
73
|
-
const values = [
|
|
74
|
-
...new Set([Number(argument.whenTrue.text), Number(argument.whenFalse.text)]),
|
|
75
|
-
].toSorted((a, b) => a - b);
|
|
76
|
-
return { statusCodes: values, statusKnowledge: 'explicit' };
|
|
77
|
-
}
|
|
78
|
-
return {
|
|
79
|
-
statusKnowledge: 'unknown',
|
|
80
|
-
unavailableReason: 'nearest ctx.setStatus value is dynamic',
|
|
81
|
-
};
|
|
82
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import ts from '../contract-schema/typescript-api.mts';
|
|
2
|
-
export declare function functionSymbol(node: ts.Node, checker: ts.TypeChecker): ts.Symbol | undefined;
|
|
3
|
-
export declare function attributionFunctionSymbol(node: ts.Node, checker: ts.TypeChecker): ts.Symbol | undefined;
|
|
4
|
-
export declare function resolveSymbol(symbol: ts.Symbol, checker: ts.TypeChecker): ts.Symbol;
|
|
5
|
-
export declare function attributionSymbol(symbol: ts.Symbol, checker: ts.TypeChecker): ts.Symbol;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import ts from '../contract-schema/typescript-api.mjs';
|
|
2
|
-
export function functionSymbol(node, checker) {
|
|
3
|
-
if (ts.isFunctionDeclaration(node) && node.name)
|
|
4
|
-
return checker.getSymbolAtLocation(node.name);
|
|
5
|
-
if ((ts.isArrowFunction(node) || ts.isFunctionExpression(node)) &&
|
|
6
|
-
ts.isVariableDeclaration(node.parent) &&
|
|
7
|
-
ts.isIdentifier(node.parent.name)) {
|
|
8
|
-
return checker.getSymbolAtLocation(node.parent.name);
|
|
9
|
-
}
|
|
10
|
-
return undefined;
|
|
11
|
-
}
|
|
12
|
-
export function attributionFunctionSymbol(node, checker) {
|
|
13
|
-
const existing = functionSymbol(node, checker);
|
|
14
|
-
if (existing)
|
|
15
|
-
return existing;
|
|
16
|
-
if (ts.isMethodDeclaration(node) && node.name)
|
|
17
|
-
return checker.getSymbolAtLocation(node.name);
|
|
18
|
-
if (ts.isArrowFunction(node) || ts.isFunctionExpression(node)) {
|
|
19
|
-
const owner = wrappedFunctionOwner(node);
|
|
20
|
-
if (owner &&
|
|
21
|
-
(ts.isVariableDeclaration(owner) ||
|
|
22
|
-
ts.isPropertyAssignment(owner) ||
|
|
23
|
-
ts.isPropertyDeclaration(owner))) {
|
|
24
|
-
return checker.getSymbolAtLocation(owner.name);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
if (ts.isFunctionDeclaration(node) &&
|
|
28
|
-
!node.name &&
|
|
29
|
-
ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Default)
|
|
30
|
-
return defaultExportSymbol(node.getSourceFile(), checker);
|
|
31
|
-
if ((ts.isArrowFunction(node) || ts.isFunctionExpression(node)) &&
|
|
32
|
-
isDefaultExportExpression(node))
|
|
33
|
-
return defaultExportSymbol(node.getSourceFile(), checker);
|
|
34
|
-
return undefined;
|
|
35
|
-
}
|
|
36
|
-
function wrappedFunctionOwner(node) {
|
|
37
|
-
let current = node;
|
|
38
|
-
let parent = current.parent;
|
|
39
|
-
while (ts.isParenthesizedExpression(parent) ||
|
|
40
|
-
ts.isAsExpression(parent) ||
|
|
41
|
-
ts.isTypeAssertionExpression(parent) ||
|
|
42
|
-
ts.isSatisfiesExpression(parent) ||
|
|
43
|
-
ts.isNonNullExpression(parent)) {
|
|
44
|
-
current = parent;
|
|
45
|
-
parent = current.parent;
|
|
46
|
-
}
|
|
47
|
-
if ((ts.isVariableDeclaration(parent) ||
|
|
48
|
-
ts.isPropertyAssignment(parent) ||
|
|
49
|
-
ts.isPropertyDeclaration(parent)) &&
|
|
50
|
-
parent.initializer === current)
|
|
51
|
-
return parent;
|
|
52
|
-
return undefined;
|
|
53
|
-
}
|
|
54
|
-
function isDefaultExportExpression(node) {
|
|
55
|
-
let current = node;
|
|
56
|
-
let parent = current.parent;
|
|
57
|
-
while ((ts.isParenthesizedExpression(parent) ||
|
|
58
|
-
ts.isAsExpression(parent) ||
|
|
59
|
-
ts.isTypeAssertionExpression(parent) ||
|
|
60
|
-
ts.isSatisfiesExpression(parent) ||
|
|
61
|
-
ts.isNonNullExpression(parent)) &&
|
|
62
|
-
parent.expression === current) {
|
|
63
|
-
current = parent;
|
|
64
|
-
parent = current.parent;
|
|
65
|
-
}
|
|
66
|
-
return ts.isExportAssignment(parent) && !parent.isExportEquals && parent.expression === current;
|
|
67
|
-
}
|
|
68
|
-
function defaultExportSymbol(sourceFile, checker) {
|
|
69
|
-
const moduleSymbol = checker.getSymbolAtLocation(sourceFile);
|
|
70
|
-
return (moduleSymbol &&
|
|
71
|
-
checker.getExportsOfModule(moduleSymbol).find((symbol) => symbol.getName() === 'default'));
|
|
72
|
-
}
|
|
73
|
-
export function resolveSymbol(symbol, checker) {
|
|
74
|
-
return symbol.flags & ts.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
|
|
75
|
-
}
|
|
76
|
-
export function attributionSymbol(symbol, checker) {
|
|
77
|
-
const resolved = resolveSymbol(symbol, checker);
|
|
78
|
-
const name = resolved.valueDeclaration?.name;
|
|
79
|
-
if (!name || !ts.isIdentifier(name))
|
|
80
|
-
return resolved;
|
|
81
|
-
return checker.getSymbolAtLocation(name) ?? resolved;
|
|
82
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { ExtractedResponseContract } from '../contract-schema/index.mts';
|
|
2
|
-
export type BackendResponseContract = ExtractedResponseContract & {
|
|
3
|
-
method: string;
|
|
4
|
-
routeTemplate: string;
|
|
5
|
-
/** Statuses owned by this response emission. Defaults to 200, or 204 for an unannotated empty emission. */
|
|
6
|
-
statusCodes?: readonly [number, ...number[]];
|
|
7
|
-
/** Distinguishes a known framework default from an explicitly set or genuinely unknown status. */
|
|
8
|
-
statusKnowledge?: 'default' | 'explicit' | 'unknown';
|
|
9
|
-
bodyKind?: 'content' | 'none';
|
|
10
|
-
/** Required for content emissions and absent for bodyless emissions. */
|
|
11
|
-
mediaType?: string;
|
|
12
|
-
/** Raw buffers and arbitrary streams have an unknown media type; bodyless emissions have none. */
|
|
13
|
-
mediaTypeKnowledge?: 'known' | 'none' | 'unknown';
|
|
14
|
-
/** Named SSE frames carried by the string stream body. */
|
|
15
|
-
sseEvents?: readonly {
|
|
16
|
-
eventName: string;
|
|
17
|
-
contract: ExtractedResponseContract;
|
|
18
|
-
}[];
|
|
19
|
-
/** A concrete error status can also be produced by the framework before dispatch. */
|
|
20
|
-
includeDefaultError?: boolean;
|
|
21
|
-
/** Set when the route's response schema could not be extracted (lenient discovery mode). */
|
|
22
|
-
unavailableReason?: string;
|
|
23
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|