ObjectStackObjectStack

Service Registry

Service Registry protocol schemas

Service Registry Protocol

Zod schemas for service registry data structures.

These schemas align with the IServiceRegistry contract interface.

Following ObjectStack "Zod First" principle - all data structures

must have Zod schemas for runtime validation and JSON Schema generation.

Note: IServiceRegistry itself is a runtime interface (methods only),

so it correctly remains a TypeScript interface. This file contains

schemas for configuration and metadata related to service registry.

Source: packages/spec/src/kernel/service-registry.zod.ts

TypeScript Usage

import { ScopeConfig, ScopeInfo, ServiceFactoryRegistration, ServiceMetadata, ServiceRegistryConfig, ServiceScopeType } from '@objectstack/spec/kernel';
import type { ScopeConfig, ScopeInfo, ServiceFactoryRegistration, ServiceMetadata, ServiceRegistryConfig, ServiceScopeType } from '@objectstack/spec/kernel';

// Validate data
const result = ScopeConfig.parse(data);

ScopeConfig

Properties

PropertyTypeRequiredDescription
scopeTypestringType of scope
scopeIdstringoptionalUnique scope identifier
metadataRecord<string, any>optionalScope-specific context metadata

ScopeInfo

Properties

PropertyTypeRequiredDescription
scopeIdstringUnique scope identifier
scopeTypestringType of scope
createdAtintegerUnix timestamp in milliseconds when scope was created
serviceCountintegeroptionalNumber of services registered in this scope
metadataRecord<string, any>optionalScope-specific context metadata

ServiceFactoryRegistration

Properties

PropertyTypeRequiredDescription
namestringUnique service name identifier
scopeEnum<'singleton' | 'transient' | 'scoped'>Service scope type
factoryTypeEnum<'sync' | 'async'>Whether factory is synchronous or asynchronous
singletonbooleanWhether to cache the factory result (singleton pattern)

ServiceMetadata

Properties

PropertyTypeRequiredDescription
namestringUnique service name identifier
scopeEnum<'singleton' | 'transient' | 'scoped'>Service scope type
typestringoptionalService type or interface name
registeredAtintegeroptionalUnix timestamp in milliseconds when service was registered
metadataRecord<string, any>optionalAdditional service-specific metadata

ServiceRegistryConfig

Properties

PropertyTypeRequiredDescription
strictModebooleanThrow errors on invalid operations (duplicate registration, service not found, etc.)
allowOverwritebooleanAllow overwriting existing service registrations
enableLoggingbooleanEnable logging for service registration and retrieval
scopeTypesstring[]optionalSupported scope types
maxServicesintegeroptionalMaximum number of services that can be registered

ServiceScopeType

Service scope type

Allowed Values

  • singleton
  • transient
  • scoped

On this page