Pre-alpha. No tagged release and no upgrade path between versions. Use for evaluation and development only, not production.
Core DevPre-alpha

SDK API

Import sumeru/core/sdk from addon code — not sumeru/core/orm or sumeru/core/server directly.

Source: sumeru/core/sdk/

Model definition

Define models as structs embedding sdk.Model with typed fields and sumeru struct tags. Run make generate to produce models/zmodels.go, which calls sdk.MustRegister. Authors do not write registration or field metadata by hand.

type MyModel struct {
    sdk.Model `sumeru:"model=my.module"`
    Name      sdk.String  `sumeru:"required,string=Name"`
    State     sdk.String  `sumeru:"selection=draft:Draft,done:Done,string=State"`
    PartnerID sdk.Many2One[sdk.Any] `sumeru:"comodel=core.partner,string=Partner"`
}

See Models and fields and Field types.

Field markers

TypePurpose
sdk.ModelEmbed; sumeru:"model=dotted.name" sets model identity
sdk.String, sdk.Text, sdk.Integer, sdk.Float, sdk.Float64, sdk.Boolean, …Scalar columns
sdk.Many2One[T], sdk.One2Many[T], sdk.Many2Many[T]Relations

Selection fields use sdk.String with a selection= tag (not a separate type).

Registration

Generated only — do not call manually:

// models/zmodels.go (generated)
func init() {
    sdk.MustRegister("my_module", &MyModel{}, &MyModelLine{})
}

Database bootstrap

FunctionPurpose
InitDB(InitDBInput{DSN})Open PostgreSQL
SyncModels(SyncModelsInput{})Create/alter tables from registered models

Queries

FunctionInputReturns
SearchOneSearchOneInput{ModelName, Criteria}One row map
SearchSearchInput{ModelName, Domain}Row maps
CreateCreateInput{ModelName, Values}New id
UpsertUpsertInput{ModelName, Values, ConflictCol}Id
ResolveXmlIdResolveXmlIdInput{XMLID}id, model name

Helpers

FunctionPurpose
Cfg()INI config singleton
AsStringCoerce field values to string
CoerceInt64Coerce to int64

Report

Import sumeru/core/sdk only. Implementation: sumeru/core/report/. See Report engine.

Constants

NameValue
PageSizeA4"a4"
PageSizeLegal"legal"
PageSizeLetter"letter"
ImportModeCreate"create"
ImportModeUpsert"upsert"

Functions

FunctionPurpose
ExportCSV(ctx, ExportCSVInput)CSV bytes for model rows and fields
ExportPDF(ctx, ExportPDFInput)PDF table for model rows and fields
BulkTemplateCSV(model, fields)Header-only CSV template
PreviewBulkImport(ctx, PreviewBulkImportInput)Validate mapped rows before confirm
ExecuteBulkImport(ctx, ExecuteBulkImportInput)Run create/upsert after user confirms
RegisterReportCellFormatter(model, fn)Optional per-field export cell text

Input types (aliases)

TypeKey fields
ExportCSVInputModel, Fields, Domain, RecordID, Title
ExportPDFInputSame + PageSize
PreviewBulkImportInputBatchID, Mapping
ExecuteBulkImportInputBatchID, Mapping, SkipInvalid
ImportResultCreated, Updated, Skipped
PreviewResultRows, ErrorCount, TotalRows, BlockingErr

Addon HTTP routes for export/import are not supported — enable via view XML instead.

Not in SDK

NeedPackage
HTTP route registrationsumeru/core/server/router
Render hookssumeru/core/engine/render
Event subscriptionssumeru/core/event
Object actionssumeru/core/orm
Module install CLIProcess entrypoint / sumeru/core/module

See also