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.

saas.billing.usage.record

Record usage of a metered feature.

  • Type: operation (command)
  • Version: 1.0.0
  • Stability: stable
  • Owners: @example.saas-boilerplate
  • Tags: saas, billing, usage
  • File: packages/examples/saas-boilerplate/src/billing/billing.operations.ts
  • field.key.label
    saas.billing.usage.record
    field.version.label
    1.0.0
    field.type.label
    operation (command)
    field.title.label
    saas.billing.usage.record
    field.description.label

    Record usage of a metered feature.

  • Type: operation (command)
  • Version: 1.0.0
  • Stability: stable
  • Owners: @example.saas-boilerplate
  • Tags: saas, billing, usage
  • File: packages/examples/saas-boilerplate/src/billing/billing.operations.ts
  • field.tags.label
    saas,billing,usage
    field.owners.label
    @example.saas-boilerplate
    field.stability.label
    stable

    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 },
    			},
    		],
    	},
    });