preprocess

package
v0.0.0-...-3776344 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Merge

func Merge(
	bp *schema.Blueprint,
	manifest *HandlerManifest,
	logger *zap.Logger,
) (*schema.Blueprint, error)

Merge enriches a blueprint with extracted handler metadata. For each handler in the manifest:

  • If a matching resource exists (by resource name): fill in missing annotations and spec
  • If no matching resource exists: create a new handler resource

func WriteMerged

func WriteMerged(
	bp *schema.Blueprint,
	format schema.SpecFormat,
	outputDir string,
) (string, error)

WriteMerged serializes the blueprint to the staging location. The output format matches the original blueprint format.

Types

type ClassHandler

type ClassHandler struct {
	ResourceName string         `json:"resourceName"`
	ClassName    string         `json:"className"`
	MethodName   string         `json:"methodName"`
	SourceFile   string         `json:"sourceFile"`
	HandlerType  string         `json:"handlerType"` // "http", "websocket", "consumer", "schedule"
	Annotations  map[string]any `json:"annotations"`
	Spec         HandlerSpec    `json:"spec"`
}

ClassHandler describes a handler discovered from a class-based decorator (e.g. @Controller + @Get in the Node.js SDK).

type Extractor

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

Extractor invokes the language-specific CLI to scan developer code and produce a HandlerManifest describing all discovered handlers.

func NewExtractor

func NewExtractor(config ExtractorConfig, logger *zap.Logger) *Extractor

NewExtractor creates an Extractor with the given config.

func (*Extractor) Extract

func (e *Extractor) Extract(ctx context.Context) (*HandlerManifest, error)

Extract runs the extraction CLI and returns the parsed manifest.

type ExtractorConfig

type ExtractorConfig struct {
	Runtime     string // e.g. "nodejs22.x"
	ModulePath  string // e.g. "src/app-module.ts"
	ProjectRoot string // Absolute path to the project directory
}

ExtractorConfig configures the language-specific handler extraction CLI.

type FunctionHandler

type FunctionHandler struct {
	ResourceName string         `json:"resourceName"`
	ExportName   string         `json:"exportName"`
	SourceFile   string         `json:"sourceFile"`
	Annotations  map[string]any `json:"annotations,omitempty"`
	Spec         HandlerSpec    `json:"spec"`
}

FunctionHandler describes a handler discovered from a function-based export.

type GuardHandler

type GuardHandler struct {
	ResourceName string         `json:"resourceName"`
	GuardName    string         `json:"guardName"`
	SourceFile   string         `json:"sourceFile"`
	GuardType    string         `json:"guardType"` // "class" or "function"
	ClassName    string         `json:"className,omitempty"`
	ExportName   string         `json:"exportName,omitempty"`
	Annotations  map[string]any `json:"annotations"`
	Spec         HandlerSpec    `json:"spec"`
}

GuardHandler describes a custom auth guard discovered from a @Guard decorator or a function-based guard export.

type HandlerManifest

type HandlerManifest struct {
	Version          string            `json:"version"`
	Handlers         []ClassHandler    `json:"handlers"`
	FunctionHandlers []FunctionHandler `json:"functionHandlers"`
	GuardHandlers    []GuardHandler    `json:"guardHandlers"`
}

HandlerManifest is the output of the language-specific extraction CLI, matching the handler-manifest.v1.schema.json format.

func (*HandlerManifest) AllHandlers

func (m *HandlerManifest) AllHandlers() int

AllHandlers returns a combined count of class, function, and guard handlers.

func (*HandlerManifest) Equal

func (m *HandlerManifest) Equal(other *HandlerManifest) bool

Equal compares two manifests by handler count and resource names to detect structural changes that require a container restart.

type HandlerSpec

type HandlerSpec struct {
	HandlerName  string `json:"handlerName"`
	CodeLocation string `json:"codeLocation"`
	Handler      string `json:"handler"`
	Timeout      *int   `json:"timeout,omitempty"`
}

HandlerSpec holds the blueprint spec fields for a handler resource.

Jump to

Keyboard shortcuts

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