インターフェース
このドキュメントでは、MBC CQRS Serverlessフレームワークで使用されるすべてのTypeScriptインターフェースの包括的なリファレンスを提供します。
コアインターフェース
コマンドインターフェース
CommandInputModel
新しいコマンドを作成するためのプライマリインターフェース。新しいエンティティを発行する際に使用します。
export interface CommandInputModel {
pk: string // Partition key (e.g., "ORDER#tenant001")
sk: string // Sort key (e.g., "ORDER#ORD001") — no version suffix needed
id: string // Unique identifier (e.g., UUID)
code: string // Business code (e.g., "ORD001")
name: string // Display name
version: number // Version number for optimistic locking
tenantCode: string // Tenant identifier
type: string // Entity type (e.g., "ORDER")
isDeleted?: boolean // Soft delete flag
seq?: number // Sequence number (auto-generated)
ttl?: number // Time-to-live in seconds
attributes?: Record<string, any> // Custom domain attributes
}
使用例:
const orderInput: CommandInputModel = {
pk: 'ORDER#tenant001',
sk: 'ORDER#ORD001', // No @version suffix — version is the separate field
id: crypto.randomUUID(),
code: 'ORD001',
name: 'Customer Order',
version: 0, // VERSION_FIRST for new entities
tenantCode: 'tenant001',
type: 'ORDER',
attributes: {
customerId: 'CUST001',
totalAmount: 1500,
status: 'pending',
},
};
CommandPartialInputModel
部分更新に使用します。pk、sk、versionのみが必須です。
export interface CommandPartialInputModel extends Partial<CommandInputModel> {
pk: string // Required: Partition key
sk: string // Required: Sort key
version: number // Required: Current version for optimistic locking
}
使用例:
const partialUpdate: CommandPartialInputModel = {
pk: 'ORDER#tenant001',
sk: 'ORDER#ORD001',
version: 2, // Must match current version
name: 'Updated Order Name',
attributes: {
status: 'confirmed',
},
};
ICommandOptions
コマンド発行メソッドに渡されるオプション。
export interface ICommandOptions {
source?: string // Source identifier for tracking
requestId?: string // Request ID for tracing
invokeContext: IInvoke // Required: Invocation context
}
使用例:
const options: ICommandOptions = {
source: 'order-service',
requestId: invokeContext.context.awsRequestId,
invokeContext, // Injected via @INVOKE_CONTEXT() decorator (@INVOKE_CONTEXT()デコレーターで注入)
};
キーインターフェース
DetailKey
DynamoDBアイテムのプライマリキーを表します。
export interface DetailKey {
pk: string // Partition key
sk: string // Sort key
}