Documentation
¶
Overview ¶
Package sdk provides the public API for pdf-forge. Users interact exclusively with this package to configure and run the engine.
Index ¶
- Constants
- Variables
- func RunMigrations(configFilePath string) error
- type Engine
- func (e *Engine) GetRenderAuthenticator() port.RenderAuthenticator
- func (e *Engine) OnShutdown(fn func(ctx context.Context) error) *Engine
- func (e *Engine) OnStart(fn func(ctx context.Context) error) *Engine
- func (e *Engine) RegisterInjector(inj port.Injector) *Engine
- func (e *Engine) RegisterMapper(m port.RequestMapper) *Enginedeprecated
- func (e *Engine) Run() error
- func (e *Engine) RunMigrations() error
- func (e *Engine) SetInitFunc(fn port.InitFunc) *Engine
- func (e *Engine) SetMapper(m port.RequestMapper) *Engine
- func (e *Engine) SetRenderAuthenticator(auth port.RenderAuthenticator) *Engine
- func (e *Engine) SetWorkspaceInjectableProvider(p port.WorkspaceInjectableProvider) *Engine
- func (e *Engine) UseAPIMiddleware(mw gin.HandlerFunc) *Engine
- func (e *Engine) UseMiddleware(mw gin.HandlerFunc) *Engine
- type FormatConfig
- type GetInjectablesResult
- type InitFunc
- type InjectableDataType
- type InjectableValue
- type Injector
- type InjectorContext
- type InjectorResult
- type ListItem
- type ListSchema
- type ListSchemaProvider
- type ListStyles
- type ListSymbol
- type ListValue
- type MapperContext
- type Middleware
- type Option
- type ProviderFormat
- type ProviderGroup
- type ProviderInjectable
- type RenderAuthClaims
- type RenderAuthenticator
- type RequestMapper
- type ResolveFunc
- type ResolveInjectablesRequest
- type ResolveInjectablesResult
- type TableCell
- type TableColumn
- type TableRow
- type TableSchemaProvider
- type TableStyles
- type TableValue
- type ValueType
- type WorkspaceInjectableProvider
Constants ¶
const ( ValueTypeString = entity.ValueTypeString ValueTypeNumber = entity.ValueTypeNumber ValueTypeBool = entity.ValueTypeBool ValueTypeTime = entity.ValueTypeTime ValueTypeTable = entity.ValueTypeTable ValueTypeImage = entity.ValueTypeImage ValueTypeList = entity.ValueTypeList )
ValueType constants (used by Injectors)
const ( InjectableDataTypeText = entity.InjectableDataTypeText InjectableDataTypeNumber = entity.InjectableDataTypeNumber InjectableDataTypeDate = entity.InjectableDataTypeDate InjectableDataTypeCurrency = entity.InjectableDataTypeCurrency InjectableDataTypeBoolean = entity.InjectableDataTypeBoolean InjectableDataTypeImage = entity.InjectableDataTypeImage InjectableDataTypeTable = entity.InjectableDataTypeTable InjectableDataTypeList = entity.InjectableDataTypeList )
InjectableDataType constants (used by WorkspaceInjectableProvider)
const ( ListSymbolBullet = entity.ListSymbolBullet ListSymbolNumber = entity.ListSymbolNumber ListSymbolDash = entity.ListSymbolDash ListSymbolRoman = entity.ListSymbolRoman ListSymbolLetter = entity.ListSymbolLetter )
List symbol constants
Variables ¶
var ( StringValue = entity.StringValue NumberValue = entity.NumberValue BoolValue = entity.BoolValue TimeValue = entity.TimeValue TableValueData = entity.TableValueData ImageValue = entity.ImageValue ListValueData = entity.ListValueData )
Value constructors
var ( NewTableValue = entity.NewTableValue Cell = entity.Cell CellWithSpan = entity.CellWithSpan EmptyCell = entity.EmptyCell )
Table helpers
var ( NewListValue = entity.NewListValue ListItemValue = entity.ListItemValue ListItemNested = entity.ListItemNested )
List helpers
var ( StringPtr = entity.StringPtr IntPtr = entity.IntPtr )
Pointer helpers
Functions ¶
func RunMigrations ¶
RunMigrations is a standalone function that runs migrations with the given config file.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is the main entry point for pdf-forge. Create with New(), register extensions, then call Run().
func (*Engine) GetRenderAuthenticator ¶
func (e *Engine) GetRenderAuthenticator() port.RenderAuthenticator
GetRenderAuthenticator returns the registered render authenticator, or nil if not set.
func (*Engine) OnShutdown ¶
OnShutdown registers a hook that runs AFTER HTTP server stops, BEFORE exit. Hooks run synchronously in REVERSE registration order (LIFO). Use to gracefully stop background processes started in OnStart.
func (*Engine) OnStart ¶
OnStart registers a hook that runs AFTER config/preflight, BEFORE HTTP server starts. Hooks run synchronously in registration order. For background processes (schedulers, workers), spawn a goroutine inside the hook.
func (*Engine) RegisterInjector ¶
RegisterInjector adds a custom injector to the engine. Multiple injectors can be registered.
func (*Engine) RegisterMapper
deprecated
func (e *Engine) RegisterMapper(m port.RequestMapper) *Engine
Deprecated: Use SetMapper instead.
func (*Engine) Run ¶
Run starts the engine: loads config, runs preflight checks, initializes all components, and starts the HTTP server. Blocks until shutdown signal (SIGINT/SIGTERM).
func (*Engine) RunMigrations ¶
RunMigrations loads config and applies all pending database migrations.
func (*Engine) SetInitFunc ¶
SetInitFunc sets the global initialization function. Runs once before all injectors on each render request.
func (*Engine) SetMapper ¶
func (e *Engine) SetMapper(m port.RequestMapper) *Engine
SetMapper sets the request mapper for render requests. Only ONE mapper is supported.
func (*Engine) SetRenderAuthenticator ¶
func (e *Engine) SetRenderAuthenticator(auth port.RenderAuthenticator) *Engine
SetRenderAuthenticator sets custom authentication for render endpoints. When set, it replaces OIDC auth for render while panel OIDC continues working.
func (*Engine) SetWorkspaceInjectableProvider ¶
func (e *Engine) SetWorkspaceInjectableProvider(p port.WorkspaceInjectableProvider) *Engine
SetWorkspaceInjectableProvider sets the provider for workspace-specific injectables. If set, the provider's GetInjectables is called when listing injectables, and ResolveInjectables is called during render for provider-owned codes.
func (*Engine) UseAPIMiddleware ¶
func (e *Engine) UseAPIMiddleware(mw gin.HandlerFunc) *Engine
UseAPIMiddleware adds middleware to /api/v1/* routes only. Execution order: Operation → Auth → Identity → Roles → [User API Middleware] → Controller Use for rate limiting, tenant validation, custom authorization, etc.
func (*Engine) UseMiddleware ¶
func (e *Engine) UseMiddleware(mw gin.HandlerFunc) *Engine
UseMiddleware adds middleware to be applied globally to all routes. Execution order: Recovery → Logger → CORS → [User Global Middleware] → Routes Use for logging, tracing, custom headers, etc.
type FormatConfig ¶
type FormatConfig = entity.FormatConfig
FormatConfig defines formatting options for an injector.
type GetInjectablesResult ¶
type GetInjectablesResult = port.GetInjectablesResult
GetInjectablesResult contains the list of available injectables and groups.
type InjectableDataType ¶
type InjectableDataType = entity.InjectableDataType
InjectableDataType represents the data type sent to frontend. Use these constants for ProviderInjectable.DataType.
type InjectableValue ¶
type InjectableValue = entity.InjectableValue
InjectableValue is the typed value returned by an injector.
type Injector ¶
Injector defines the interface that users implement to provide custom injectable values.
type InjectorContext ¶
type InjectorContext = entity.InjectorContext
InjectorContext encapsulates context data available to injectors.
type InjectorResult ¶
type InjectorResult = entity.InjectorResult
InjectorResult is the result of resolving an injector.
type ListSchemaProvider ¶
type ListSchemaProvider = port.ListSchemaProvider
ListSchemaProvider is an optional interface for list injectors to expose list schema.
type MapperContext ¶
type MapperContext = port.MapperContext
MapperContext contains context data for request mapping.
type Middleware ¶
type Middleware = gin.HandlerFunc
Middleware is the function signature for HTTP middleware. Use with UseMiddleware() and UseAPIMiddleware().
type Option ¶
type Option func(*Engine)
Option configures the Engine.
func WithConfig ¶
WithConfig provides configuration programmatically. Takes precedence over WithConfigFile if both are set.
func WithConfigFile ¶
WithConfigFile loads configuration from a YAML file. Environment variables with DOC_ENGINE_ prefix override YAML values.
func WithDevFrontendURL ¶
WithDevFrontendURL sets a development frontend URL. When set, the engine proxies requests to this URL instead of serving embedded assets. Use this during frontend development for hot-reload support.
func WithI18nFile ¶
WithI18nFile loads injector translations from a YAML file.
type ProviderFormat ¶
type ProviderFormat = port.ProviderFormat
ProviderFormat represents a format option for an injectable.
type ProviderGroup ¶
type ProviderGroup = port.ProviderGroup
ProviderGroup represents a custom group for organizing injectables.
type ProviderInjectable ¶
type ProviderInjectable = port.ProviderInjectable
ProviderInjectable represents an injectable definition from the provider.
type RenderAuthClaims ¶
type RenderAuthClaims = port.RenderAuthClaims
RenderAuthenticator types for custom render endpoint authentication.
type RenderAuthenticator ¶
type RenderAuthenticator = port.RenderAuthenticator
RenderAuthenticator types for custom render endpoint authentication.
type RequestMapper ¶
type RequestMapper = port.RequestMapper
RequestMapper defines the interface for mapping incoming requests.
type ResolveFunc ¶
type ResolveFunc = port.ResolveFunc
ResolveFunc is the function signature for injector resolution.
type ResolveInjectablesRequest ¶
type ResolveInjectablesRequest = port.ResolveInjectablesRequest
ResolveInjectablesRequest contains parameters for resolving injectable values.
type ResolveInjectablesResult ¶
type ResolveInjectablesResult = port.ResolveInjectablesResult
ResolveInjectablesResult contains the resolved values and any non-critical errors.
type TableSchemaProvider ¶
type TableSchemaProvider = port.TableSchemaProvider
TableSchemaProvider is an optional interface for table injectors to expose column schema.
type WorkspaceInjectableProvider ¶
type WorkspaceInjectableProvider = port.WorkspaceInjectableProvider
WorkspaceInjectableProvider defines the interface for workspace-specific injectables.