typescript

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package typescript is the TypeScript/TSX LanguageProvider. It parses with gotreesitter (pure Go, no CGO — see ADR 0002) and adapts its AST to the core's parser-agnostic syntax.Node (ADR 0003).

This phase (Prompt 1.1) implements identity + parsing only. The deterministic rules and surface mapping (AnalyzeSecurity/Practices/Surface) are stubs here; they arrive in Prompts 1.2/1.3.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option added in v0.1.2

type Option func(*Provider)

Option configures a Provider at construction.

func WithAuthzHelpers added in v0.1.2

func WithAuthzHelpers(names []string) Option

WithAuthzHelpers registers project-specific authorization helper names the provider recognizes in addition to the built-in set. The names come from the committed baseline (a human-approved decision), never from guessing.

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider implements providers.LanguageProvider for TypeScript and TSX. authzHelpers holds the project's registered custom authz helpers (in addition to the built-in NextAuth-style set), so surface recognition reflects per-project knowledge without the agent re-reasoning (ADR 0013). Empty for the stateless file-level surface tools; populated by the project-scan path from the baseline.

func New

func New(opts ...Option) *Provider

New returns a TypeScript language provider. With no options it recognizes only the built-in authz helpers (the stateless default).

func (*Provider) AnalyzePractices

func (*Provider) AnalyzePractices(providers.SourceFile) ([]findings.Finding, error)

AnalyzePractices is a stub; the best-practice rules arrive in Prompt 1.2.

func (*Provider) AnalyzeSecurity

func (p *Provider) AnalyzeSecurity(src providers.SourceFile) ([]findings.Finding, error)

AnalyzeSecurity runs the embedded deterministic security rules over src and returns the findings. The provider is a thin adapter: it loads/compiles the rules (once), parses the file, and hands both to the language-agnostic ruleengine — no detection logic lives here.

func (*Provider) AnalyzeSurface

func (p *Provider) AnalyzeSurface(src providers.SourceFile) ([]findings.SurfaceItem, error)

AnalyzeSurface maps the auditable structural surface of a TypeScript file by running the provider's surface queries through the agnostic framework, which stamps the stable ids. Today only IDOR (Next App Router) is wired; authz and over-fetching are added as their queries land.

func (*Provider) CoverageManifest

func (*Provider) CoverageManifest() coverage.Manifest

CoverageManifest declares, in plain prose, what codefit audits for TypeScript and how — the single source for the human-facing COVERAGE.md and the codefit-coverage tool (PRD §10, RF-07). The two categories that split between a deterministic rule and mapped surface (ADR 0004) appear in BOTH lists, each side describing exactly what it covers, so an evaluator reads a division of labor, not a gap.

CoverageManifest is a provider method (not yet on the shared LanguageProvider interface) — the interface convergence is deferred until the Go provider also emits this (ADR 0003).

func (*Provider) DefaultPathCriticality

func (*Provider) DefaultPathCriticality() config.PathCriticality

func (*Provider) FileExtensions

func (*Provider) FileExtensions() []string

func (*Provider) Frameworks

func (*Provider) Frameworks() []string

func (*Provider) Language

func (*Provider) Language() string

func (*Provider) Parse

func (*Provider) Parse(src providers.SourceFile) (syntax.Node, error)

Parse parses a TypeScript (.ts) or TSX (.tsx) file and returns the root of the parser-agnostic AST. The concrete gotreesitter tree is hidden behind syntax.Node so the core never depends on the parser.

func (*Provider) ParseSchema added in v0.2.0

func (*Provider) ParseSchema(sources []providers.SourceFile) (*db.Schema, error)

ParseSchema parses Prisma schema source(s) into the neutral db.Schema model. It is a hand-written, line-oriented parser over the Prisma DSL (not tree-sitter — ADR 0014), so it yields a Pos line for every element for free. It is TWO-PASS: a field's type can be a scalar, a model name (a virtual relation field — excluded as a column) or an enum name (a real column). Pass one collects the model and enum names; pass two resolves each field against those sets. Without it, an enum column (role Role) would be silently dropped as a relation.

Prisma view blocks are out of scope this slice and are skipped without error (Schema.Views stays empty; the SQL-DDL parser of slice 3 fills views).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL