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
| Property | Type | Required | Description |
|---|---|---|---|
| scopeType | string | ✅ | Type of scope |
| scopeId | string | optional | Unique scope identifier |
| metadata | Record<string, any> | optional | Scope-specific context metadata |
ScopeInfo
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| scopeId | string | ✅ | Unique scope identifier |
| scopeType | string | ✅ | Type of scope |
| createdAt | integer | ✅ | Unix timestamp in milliseconds when scope was created |
| serviceCount | integer | optional | Number of services registered in this scope |
| metadata | Record<string, any> | optional | Scope-specific context metadata |
ServiceFactoryRegistration
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| name | string | ✅ | Unique service name identifier |
| scope | Enum<'singleton' | 'transient' | 'scoped'> | ✅ | Service scope type |
| factoryType | Enum<'sync' | 'async'> | ✅ | Whether factory is synchronous or asynchronous |
| singleton | boolean | ✅ | Whether to cache the factory result (singleton pattern) |
ServiceMetadata
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| name | string | ✅ | Unique service name identifier |
| scope | Enum<'singleton' | 'transient' | 'scoped'> | ✅ | Service scope type |
| type | string | optional | Service type or interface name |
| registeredAt | integer | optional | Unix timestamp in milliseconds when service was registered |
| metadata | Record<string, any> | optional | Additional service-specific metadata |
ServiceRegistryConfig
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| strictMode | boolean | ✅ | Throw errors on invalid operations (duplicate registration, service not found, etc.) |
| allowOverwrite | boolean | ✅ | Allow overwriting existing service registrations |
| enableLogging | boolean | ✅ | Enable logging for service registration and retrieval |
| scopeTypes | string[] | optional | Supported scope types |
| maxServices | integer | optional | Maximum number of services that can be registered |
ServiceScopeType
Service scope type
Allowed Values
singletontransientscoped