OSS-first docs
These docs teach the open system first: contracts, generated surfaces, runtimes, governance, and incremental adoption. Studio shows up as the operating layer on top, not as the source of truth.
Record usage of a metered feature.
Goal
Track feature usage for billing.
Context
Called by services when metered features are used.
Emitted Events
•
`billing.usage.recorded` (v1.0.0)
Source Definition
import { defineCommand, defineQuery } from '@lssm-tech/lib.contracts-spec';
import {
CheckFeatureAccessInputModel,
CheckFeatureAccessOutputModel,
GetUsageSummaryInputModel,
GetUsageSummaryOutputModel,
RecordUsageInputModel,
RecordUsageOutputModel,
SubscriptionModel,
UsageRecordedPayloadModel,
} from './billing.schema';
export const RecordUsageContract = defineCommand({
meta: {
key: 'saas.billing.usage.record',
version: '1.0.0',
stability: 'stable',
owners: ['@example.saas-boilerplate'],
tags: ['saas', 'billing', 'usage'],
description: 'Record usage of a metered feature.',
goal: 'Track feature usage for billing.',
context: 'Called by services when metered features are used.',
},
io: {
input: RecordUsageInputModel,
output: RecordUsageOutputModel,
},
policy: {
auth: 'user',
},
sideEffects: {
emits: [
{
key: 'billing.usage.recorded',
version: '1.0.0',
when: 'Usage is recorded',
payload: UsageRecordedPayloadModel,
},
],
},
acceptance: {
scenarios: [
{
key: 'record-usage-happy-path',
given: ['Organization exists'],
when: ['System records feature usage'],
then: ['Usage is recorded'],
},
],
examples: [
{
key: 'record-api-call',
input: { feature: 'api_calls', quantity: 1, idempotencyKey: 'abc-123' },
output: { recorded: true, currentUsage: 100 },
},
],
},
});