Schemas
Package: github.com/emergent-company/emergent.memory/apps/server/pkg/sdk/schemas
Client field: client.Schemas
Schemas are versioned bundles of object type schemas, relationship type schemas, UI configs, and extraction prompts. They can be installed on projects to bootstrap a consistent graph schema, and are also produced by Discovery Jobs.
Project-Scoped Methods
Section titled “Project-Scoped Methods”These methods operate on the project set via SetContext.
GetCompiledTypes
Section titled “GetCompiledTypes”func (c *Client) GetCompiledTypes(ctx context.Context) (*CompiledTypesResponse, error)Returns the merged set of object and relationship type definitions for the current project (across all installed schemas).
GET /api/schemas/projects/:projectId/compiled-types
GetAvailableSchemas
Section titled “GetAvailableSchemas”func (c *Client) GetAvailableSchemas(ctx context.Context) ([]SchemaListItem, error)Lists schemas available to install on the current project.
GET /api/schemas/projects/:projectId/available
GetInstalledSchemas
Section titled “GetInstalledSchemas”func (c *Client) GetInstalledSchemas(ctx context.Context) ([]InstalledSchemaItem, error)Lists schemas already installed on the current project.
GET /api/schemas/projects/:projectId/installed
AssignSchema
Section titled “AssignSchema”func (c *Client) AssignSchema(ctx context.Context, req *AssignSchemaRequest) (*ProjectSchema, error)Installs a schema on the current project.
POST /api/schemas/projects/:projectId/assign
UpdateAssignment
Section titled “UpdateAssignment”func (c *Client) UpdateAssignment(ctx context.Context, assignmentID string, req *UpdateAssignmentRequest) (*UpdateAssignmentResponse, error)Updates an existing assignment (e.g. toggle Active).
PATCH /api/schemas/projects/:projectId/assignments/:assignmentId
DeleteAssignment
Section titled “DeleteAssignment”func (c *Client) DeleteAssignment(ctx context.Context, assignmentID string) errorRemoves a schema assignment from the current project.
DELETE /api/schemas/projects/:projectId/assignments/:assignmentId
GetPackClaims
Section titled “GetPackClaims”func (c *Client) GetPackClaims(ctx context.Context) ([]PackBlueprintClaim, error)Returns the mapping between compiled schema packs and the applied blueprints that claim them for the current project. Only packs claimed by at least one applied blueprint are returned; an empty result is [].
GET /api/schemas/projects/:projectId/pack-claims
Global Schema CRUD Methods
Section titled “Global Schema CRUD Methods”CreateSchema
Section titled “CreateSchema”func (c *Client) CreateSchema(ctx context.Context, req *CreateSchemaRequest) (*MemorySchema, error)Creates a new schema in the registry.
POST /api/schemas
GetSchema
Section titled “GetSchema”func (c *Client) GetSchema(ctx context.Context, schemaID string) (*MemorySchema, error)Retrieves a schema by ID.
GET /api/schemas/:schemaId
DeleteSchema
Section titled “DeleteSchema”func (c *Client) DeleteSchema(ctx context.Context, schemaID string) errorDeletes a schema. Fails if the schema is assigned to any projects.
DELETE /api/schemas/:schemaId
MemorySchema
Section titled “MemorySchema”type MemorySchema struct { ID string `json:"id"` Name string `json:"name"` Version string `json:"version"` Description *string `json:"description,omitempty"` Author *string `json:"author,omitempty"` Source *string `json:"source,omitempty"` License *string `json:"license,omitempty"` RepositoryURL *string `json:"repositoryUrl,omitempty"` DocumentationURL *string `json:"documentationUrl,omitempty"` ObjectTypeSchemas json.RawMessage `json:"objectTypeSchemas,omitempty"` RelationshipTypeSchemas json.RawMessage `json:"relationshipTypeSchemas,omitempty"` UIConfigs json.RawMessage `json:"uiConfigs,omitempty"` ExtractionPrompts json.RawMessage `json:"extractionPrompts,omitempty"` Checksum *string `json:"checksum,omitempty"` Draft bool `json:"draft"` PublishedAt *time.Time `json:"publishedAt,omitempty"` DeprecatedAt *time.Time `json:"deprecatedAt,omitempty"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"`}CompiledTypesResponse
Section titled “CompiledTypesResponse”type CompiledTypesResponse struct { ObjectTypes []ObjectTypeSchema `json:"objectTypes"` RelationshipTypes []RelationshipTypeSchema `json:"relationshipTypes"`}
type ObjectTypeSchema struct { Name string `json:"name"` Label string `json:"label,omitempty"` Description string `json:"description,omitempty"` Properties json.RawMessage `json:"properties,omitempty"` SchemaID string `json:"schemaId,omitempty"` SchemaName string `json:"schemaName,omitempty"`}
type RelationshipTypeSchema struct { Name string `json:"name"` Label string `json:"label,omitempty"` Description string `json:"description,omitempty"` SourceType string `json:"sourceType,omitempty"` TargetType string `json:"targetType,omitempty"` SchemaID string `json:"schemaId,omitempty"` SchemaName string `json:"schemaName,omitempty"`}InstalledSchemaItem
Section titled “InstalledSchemaItem”type InstalledSchemaItem struct { ID string `json:"id"` // assignment ID SchemaID string `json:"schemaId"` Name string `json:"name"` Version string `json:"version"` Description *string `json:"description,omitempty"` Active bool `json:"active"` InstalledAt time.Time `json:"installedAt"` Customizations map[string]interface{} `json:"customizations,omitempty"`}AssignSchemaRequest
Section titled “AssignSchemaRequest”type AssignSchemaRequest struct { SchemaID string `json:"schema_id"` Customizations map[string]interface{} `json:"customizations,omitempty"`}PackBlueprintClaim
Section titled “PackBlueprintClaim”type PackBlueprintClaim struct { SchemaID string `json:"schemaId"` Name string `json:"name"` Version string `json:"version"` Blueprints []ClaimingBlueprint `json:"blueprints"`}
type ClaimingBlueprint struct { BlueprintID string `json:"blueprintId"` Name string `json:"name"` Version string `json:"version"`}CreateSchemaRequest
Section titled “CreateSchemaRequest”type CreateSchemaRequest struct { Name string `json:"name"` Version string `json:"version"` Description *string `json:"description,omitempty"` Author *string `json:"author,omitempty"` License *string `json:"license,omitempty"` RepositoryURL *string `json:"repository_url,omitempty"` DocumentationURL *string `json:"documentation_url,omitempty"` ObjectTypeSchemas json.RawMessage `json:"object_type_schemas"` RelationshipTypeSchemas json.RawMessage `json:"relationship_type_schemas,omitempty"` UIConfigs json.RawMessage `json:"ui_configs,omitempty"` ExtractionPrompts json.RawMessage `json:"extraction_prompts,omitempty"`}Example
Section titled “Example”// Get types available for the current projecttypes, err := client.Schemas.GetCompiledTypes(ctx)if err != nil { log.Fatal(err)}for _, t := range types.ObjectTypes { fmt.Printf("Type: %s (from schema %s)\n", t.Name, t.SchemaName)}
// Install a schema on the current projectavailable, err := client.Schemas.GetAvailableSchemas(ctx)if err != nil || len(available) == 0 { log.Fatal("no schemas available")}assignment, err := client.Schemas.AssignSchema(ctx, &schemas.AssignSchemaRequest{ SchemaID: available[0].ID,})fmt.Println("Installed:", assignment.SchemaID, "assignment:", assignment.ID)